CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes
L1TMicroGMTInputProducerFromGen Class Reference

#include <L1Trigger/L1TGlobalMuon/plugins/L1TMicroGMTInputProducerFromGen.cc>

Inheritance diagram for L1TMicroGMTInputProducerFromGen:
edm::stream::EDProducer<>

Public Member Functions

 L1TMicroGMTInputProducerFromGen (const edm::ParameterSet &)
 
 ~L1TMicroGMTInputProducerFromGen () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Member Functions

void beginLuminosityBlock (const edm::LuminosityBlock &, edm::EventSetup const &) override
 
void beginRun (const edm::Run &, edm::EventSetup const &) override
 
void endLuminosityBlock (const edm::LuminosityBlock &, edm::EventSetup const &) override
 
void endRun (const edm::Run &, edm::EventSetup const &) override
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Static Private Member Functions

static bool compareMuons (const RegionalMuonCand &, const RegionalMuonCand &)
 

Private Attributes

edm::EDGetTokenT< reco::GenParticleCollectiongenParticlesToken
 
int m_currEvt
 
TRandom3 m_rnd
 

Static Private Attributes

const static int m_maxMuons = 108
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Description: takes generated muons and fills them in the expected collections for the MicroGMT

Implementation: [Notes on implementation]

Definition at line 50 of file L1TMicroGMTInputProducerFromGen.cc.

Constructor & Destructor Documentation

◆ L1TMicroGMTInputProducerFromGen()

L1TMicroGMTInputProducerFromGen::L1TMicroGMTInputProducerFromGen ( const edm::ParameterSet iConfig)
explicit

Definition at line 85 of file L1TMicroGMTInputProducerFromGen.cc.

86  : m_currEvt(0), m_rnd(0) {
87  //register your inputs:
88  genParticlesToken = consumes<reco::GenParticleCollection>(std::string("genParticles"));
89  //register your products
90  produces<RegionalMuonCandBxCollection>("BarrelTFMuons");
91  produces<RegionalMuonCandBxCollection>("OverlapTFMuons");
92  produces<RegionalMuonCandBxCollection>("ForwardTFMuons");
93  produces<MuonCaloSumBxCollection>("TriggerTowerSums");
94 }

References genParticlesToken, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ ~L1TMicroGMTInputProducerFromGen()

L1TMicroGMTInputProducerFromGen::~L1TMicroGMTInputProducerFromGen ( )
override

Definition at line 96 of file L1TMicroGMTInputProducerFromGen.cc.

96  {
97  // do anything here that needs to be done at desctruction time
98  // (e.g. close files, deallocate resources etc.)
99 }

Member Function Documentation

◆ beginLuminosityBlock()

void L1TMicroGMTInputProducerFromGen::beginLuminosityBlock ( const edm::LuminosityBlock ,
edm::EventSetup const &   
)
overrideprivate

Definition at line 252 of file L1TMicroGMTInputProducerFromGen.cc.

252 {}

◆ beginRun()

void L1TMicroGMTInputProducerFromGen::beginRun ( const edm::Run ,
edm::EventSetup const &   
)
overrideprivate

Definition at line 246 of file L1TMicroGMTInputProducerFromGen.cc.

246 {}

◆ compareMuons()

bool L1TMicroGMTInputProducerFromGen::compareMuons ( const RegionalMuonCand mu1,
const RegionalMuonCand mu2 
)
staticprivate

Definition at line 105 of file L1TMicroGMTInputProducerFromGen.cc.

105  {
106  return mu1.processor() < mu2.processor();
107 }

References l1t::RegionalMuonCand::processor().

Referenced by produce().

◆ endLuminosityBlock()

void L1TMicroGMTInputProducerFromGen::endLuminosityBlock ( const edm::LuminosityBlock ,
edm::EventSetup const &   
)
overrideprivate

Definition at line 255 of file L1TMicroGMTInputProducerFromGen.cc.

255 {}

◆ endRun()

void L1TMicroGMTInputProducerFromGen::endRun ( const edm::Run ,
edm::EventSetup const &   
)
overrideprivate

Definition at line 249 of file L1TMicroGMTInputProducerFromGen.cc.

249 {}

◆ fillDescriptions()

void L1TMicroGMTInputProducerFromGen::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 258 of file L1TMicroGMTInputProducerFromGen.cc.

258  {
259  //The following says we do not know what parameters are allowed so do no validation
260  // Please change this to state exactly what you do use, even if it is no parameters
262  desc.setUnknown();
263  descriptions.addDefault(desc);
264 }

References edm::ConfigurationDescriptions::addDefault(), and submitPVResolutionJobs::desc.

◆ produce()

void L1TMicroGMTInputProducerFromGen::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 110 of file L1TMicroGMTInputProducerFromGen.cc.

110  {
111  using namespace edm;
112 
113  std::unique_ptr<RegionalMuonCandBxCollection> barrelMuons(new RegionalMuonCandBxCollection());
114  std::unique_ptr<RegionalMuonCandBxCollection> overlapMuons(new RegionalMuonCandBxCollection());
115  std::unique_ptr<RegionalMuonCandBxCollection> endcapMuons(new RegionalMuonCandBxCollection());
116  std::unique_ptr<MuonCaloSumBxCollection> towerSums(new MuonCaloSumBxCollection());
117 
118  std::vector<RegionalMuonCand> bmMuons;
119  std::vector<RegionalMuonCand> omMuons;
120  std::vector<RegionalMuonCand> emMuons;
121 
122  std::vector<int> muIndices;
124  // Make sure that you can get genParticles
125  if (iEvent.getByToken(genParticlesToken, genParticles)) {
126  int cntr = 0;
127  for (auto it = genParticles->cbegin(); it != genParticles->cend(); ++it) {
128  const reco::Candidate& mcParticle = *it;
129  if (abs(mcParticle.pdgId()) == 13 && mcParticle.status() == 1)
130  muIndices.push_back(cntr);
131  cntr++;
132  }
133  } else {
134  LogTrace("GlobalMuon") << " GenParticleCollection not found." << std::endl;
135  }
136 
138  MuonCaloSum tSum;
139  // alternative scale (using full phi bit-width): 163.4521265553765f;
140  const float phiToInt = 91.67324722093171f;
141  // alternative scale: 100.0f;
142  const float etaToInt = 90.9090909090f;
143  const int maxPt = (1 << 9) - 1;
144  int muCntr = 0;
145 
146  double twoPi = TMath::Pi() * 2.;
147 
148  for (auto it = muIndices.begin(); it != muIndices.end(); ++it) {
149  // don't really care which muons are taken...
150  // guess there ain't 108 generated anyways
151  if (muCntr == m_maxMuons)
152  break;
153  int gen_idx = *it;
154  const reco::Candidate& mcMuon = genParticles->at(gen_idx);
155  double eta = mcMuon.eta();
156  if (fabs(eta) > 2.45)
157  continue; // out of acceptance
158  int hwPt = int(mcMuon.pt() * 2);
159  hwPt = (hwPt < maxPt ? hwPt : maxPt);
160  int hwEta = int(eta * etaToInt);
161  double phi = mcMuon.phi();
162  if (phi < 0)
163  phi += twoPi; // add 2*pi
164  int hwPhi = (int(phi * phiToInt)) % 576;
165  int hwQual = 8;
166  int hwCharge = (mcMuon.charge() > 0) ? 0 : 1;
167  int hwChargeValid = 1;
168 
169  mu.setHwPt(hwPt);
170 
171  tftype tf(tftype::bmtf);
172  int globalWedgePhi = (hwPhi + 24) % 576; // this sets CMS phi = 0 to -15 deg
173  int localPhi = globalWedgePhi % 48;
174  int processor = globalWedgePhi / 48 + 1;
175  int globalSectorPhi = (hwPhi - 24); // this sets CMS phi = 0 to +15 deg
176  if (globalSectorPhi < 0) {
177  globalSectorPhi += 576;
178  }
179 
180  if (fabs(eta) > 0.8) {
181  if (fabs(eta) < 1.2) {
182  tf = (eta > 0 ? tftype::omtf_pos : tftype::omtf_neg);
183  processor = globalSectorPhi / 96 + 1;
184  localPhi = globalSectorPhi % 96;
185  } else {
186  tf = (eta > 0 ? tftype::emtf_pos : tftype::emtf_neg);
187  processor = globalSectorPhi / 96 + 1;
188  localPhi = globalSectorPhi % 96;
189  }
190  }
191  mu.setHwPhi(localPhi);
192  mu.setTFIdentifiers(processor, tf);
193 
194  mu.setHwEta(hwEta);
195  mu.setHwSign(hwCharge);
196  mu.setHwSignValid(hwChargeValid);
197  mu.setHwQual(hwQual);
198 
199  if (fabs(eta) < 0.8 && bmMuons.size() < 36) {
200  bmMuons.push_back(mu);
201  muCntr++;
202  } else if (fabs(eta) < 1.2 && omMuons.size() < 36) {
203  omMuons.push_back(mu);
204  muCntr++;
205  } else if (emMuons.size() < 36) {
206  emMuons.push_back(mu);
207  muCntr++;
208  }
209  }
210 
211  std::sort(bmMuons.begin(), bmMuons.end(), L1TMicroGMTInputProducerFromGen::compareMuons);
212  std::sort(omMuons.begin(), omMuons.end(), L1TMicroGMTInputProducerFromGen::compareMuons);
213  std::sort(emMuons.begin(), emMuons.end(), L1TMicroGMTInputProducerFromGen::compareMuons);
214 
215  for (const auto& mu : bmMuons) {
216  barrelMuons->push_back(0, mu);
217  }
218 
219  for (const auto& mu : omMuons) {
220  overlapMuons->push_back(0, mu);
221  }
222 
223  for (const auto& mu : emMuons) {
224  endcapMuons->push_back(0, mu);
225  }
226 
227  for (int i = 0; i < 1008; ++i) {
228  // from where could I take the tower energies?
229  int energy = int(m_rnd.Gaus(12, 6));
230  if (energy < 0)
231  energy = 0;
232  if (energy > 31)
233  energy = 31;
234  MuonCaloSum sum(energy, i / 28, i % 28, i);
235  towerSums->push_back(0, sum);
236  }
237 
238  iEvent.put(std::move(barrelMuons), "BarrelTFMuons");
239  iEvent.put(std::move(overlapMuons), "OverlapTFMuons");
240  iEvent.put(std::move(endcapMuons), "ForwardTFMuons");
241  iEvent.put(std::move(towerSums), "TriggerTowerSums");
242  m_currEvt++;
243 }

References funct::abs(), l1t::bmtf, reco::Candidate::charge(), compareMuons(), l1t::emtf_neg, l1t::emtf_pos, HCALHighEnergyHPDFilter_cfi::energy, PVValHelper::eta, reco::Candidate::eta(), genParticles2HepMC_cfi::genParticles, genParticlesToken, mps_fire::i, iEvent, createfilelist::int, LogTrace, m_currEvt, m_maxMuons, m_rnd, MuonErrorMatrixAnalyzer_cfi::maxPt, eostools::move(), amptDefaultParameters_cff::mu, l1t::omtf_neg, l1t::omtf_pos, reco::Candidate::pdgId(), phi, reco::Candidate::phi(), Pi, reco::Candidate::pt(), reco::Candidate::status(), and Geom::twoPi().

Member Data Documentation

◆ genParticlesToken

edm::EDGetTokenT<reco::GenParticleCollection> L1TMicroGMTInputProducerFromGen::genParticlesToken
private

Definition at line 68 of file L1TMicroGMTInputProducerFromGen.cc.

Referenced by L1TMicroGMTInputProducerFromGen(), and produce().

◆ m_currEvt

int L1TMicroGMTInputProducerFromGen::m_currEvt
private

Definition at line 69 of file L1TMicroGMTInputProducerFromGen.cc.

Referenced by produce().

◆ m_maxMuons

const static int L1TMicroGMTInputProducerFromGen::m_maxMuons = 108
staticprivate

Definition at line 70 of file L1TMicroGMTInputProducerFromGen.cc.

Referenced by produce().

◆ m_rnd

TRandom3 L1TMicroGMTInputProducerFromGen::m_rnd
private

Definition at line 71 of file L1TMicroGMTInputProducerFromGen.cc.

Referenced by produce().

l1t::bmtf
Definition: RegionalMuonCandFwd.h:8
l1t::emtf_neg
Definition: RegionalMuonCandFwd.h:8
l1t::RegionalMuonCand::processor
const int processor() const
Get processor ID on which the candidate was found (0..5 for OMTF/EMTF; 0..11 for BMTF)
Definition: RegionalMuonCand.h:179
mps_fire.i
i
Definition: mps_fire.py:428
genParticles2HepMC_cfi.genParticles
genParticles
Definition: genParticles2HepMC_cfi.py:4
l1t::omtf_pos
Definition: RegionalMuonCandFwd.h:8
l1t::tftype
tftype
Definition: RegionalMuonCandFwd.h:8
amptDefaultParameters_cff.mu
mu
Definition: amptDefaultParameters_cff.py:16
reco::Candidate::eta
virtual double eta() const =0
momentum pseudorapidity
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
reco::Candidate::pt
virtual double pt() const =0
transverse momentum
reco::Candidate::status
virtual int status() const =0
status word
edm::Handle< reco::GenParticleCollection >
MuonErrorMatrixAnalyzer_cfi.maxPt
maxPt
Definition: MuonErrorMatrixAnalyzer_cfi.py:19
reco::Candidate::charge
virtual int charge() const =0
electric charge
PVValHelper::eta
Definition: PVValidationHelpers.h:69
Geom::twoPi
constexpr double twoPi()
Definition: Pi.h:32
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
L1TMicroGMTInputProducerFromGen::genParticlesToken
edm::EDGetTokenT< reco::GenParticleCollection > genParticlesToken
Definition: L1TMicroGMTInputProducerFromGen.cc:68
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
L1TMicroGMTInputProducerFromGen::m_currEvt
int m_currEvt
Definition: L1TMicroGMTInputProducerFromGen.cc:69
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
l1t::RegionalMuonCandBxCollection
BXVector< RegionalMuonCand > RegionalMuonCandBxCollection
Definition: RegionalMuonCandFwd.h:9
L1TMicroGMTInputProducerFromGen::m_rnd
TRandom3 m_rnd
Definition: L1TMicroGMTInputProducerFromGen.cc:71
l1t::MuonCaloSumBxCollection
BXVector< MuonCaloSum > MuonCaloSumBxCollection
Definition: MuonCaloSumFwd.h:7
L1TMicroGMTInputProducerFromGen::compareMuons
static bool compareMuons(const RegionalMuonCand &, const RegionalMuonCand &)
Definition: L1TMicroGMTInputProducerFromGen.cc:105
reco::Candidate::pdgId
virtual int pdgId() const =0
PDG identifier.
reco::Candidate
Definition: Candidate.h:27
DDAxes::phi
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
l1t::emtf_pos
Definition: RegionalMuonCandFwd.h:8
l1t::MuonCaloSum
Definition: MuonCaloSum.h:7
Pi
const double Pi
Definition: CosmicMuonParameters.h:18
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
L1TMicroGMTInputProducerFromGen::m_maxMuons
const static int m_maxMuons
Definition: L1TMicroGMTInputProducerFromGen.cc:70
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:224
l1t::omtf_neg
Definition: RegionalMuonCandFwd.h:8
edm::ConfigurationDescriptions::addDefault
void addDefault(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:99
reco::Candidate::phi
virtual double phi() const =0
momentum azimuthal angle
l1t::RegionalMuonCand
Definition: RegionalMuonCand.h:8