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::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 L1TMicroGMTInputProducerFromGen (const edm::ParameterSet &)
 
 ~L1TMicroGMTInputProducerFromGen ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

virtual void beginJob () override
 
virtual void beginLuminosityBlock (const edm::LuminosityBlock &, edm::EventSetup const &) override
 
virtual void beginRun (const edm::Run &, edm::EventSetup const &) override
 
virtual void endJob () override
 
virtual void endLuminosityBlock (const edm::LuminosityBlock &, edm::EventSetup const &) override
 
virtual void endRun (const edm::Run &, edm::EventSetup const &) override
 
virtual 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

static const int m_maxMuons = 108
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

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

Implementation: [Notes on implementation]

Definition at line 51 of file L1TMicroGMTInputProducerFromGen.cc.

Constructor & Destructor Documentation

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

Definition at line 89 of file L1TMicroGMTInputProducerFromGen.cc.

References genParticlesToken, and AlCaHLTBitMon_QueryRunRegistry::string.

89  :
90  m_currEvt(0), m_rnd(0)
91 {
92  //register your inputs:
93  genParticlesToken = consumes <reco::GenParticleCollection> (std::string("genParticles"));
94  //register your products
95  produces<RegionalMuonCandBxCollection>("BarrelTFMuons");
96  produces<RegionalMuonCandBxCollection>("OverlapTFMuons");
97  produces<RegionalMuonCandBxCollection>("ForwardTFMuons");
98  produces<MuonCaloSumBxCollection>("TriggerTowerSums");
99 }
edm::EDGetTokenT< reco::GenParticleCollection > genParticlesToken
L1TMicroGMTInputProducerFromGen::~L1TMicroGMTInputProducerFromGen ( )

Definition at line 102 of file L1TMicroGMTInputProducerFromGen.cc.

103 {
104  // do anything here that needs to be done at desctruction time
105  // (e.g. close files, deallocate resources etc.)
106 }

Member Function Documentation

void L1TMicroGMTInputProducerFromGen::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 259 of file L1TMicroGMTInputProducerFromGen.cc.

260 {
261 }
void L1TMicroGMTInputProducerFromGen::beginLuminosityBlock ( const edm::LuminosityBlock ,
edm::EventSetup const &   
)
overrideprivatevirtual

Definition at line 282 of file L1TMicroGMTInputProducerFromGen.cc.

283 {
284 }
void L1TMicroGMTInputProducerFromGen::beginRun ( const edm::Run ,
edm::EventSetup const &   
)
overrideprivatevirtual

Definition at line 270 of file L1TMicroGMTInputProducerFromGen.cc.

271 {
272 }
bool L1TMicroGMTInputProducerFromGen::compareMuons ( const RegionalMuonCand mu1,
const RegionalMuonCand mu2 
)
staticprivate

Definition at line 114 of file L1TMicroGMTInputProducerFromGen.cc.

References l1t::RegionalMuonCand::processor().

Referenced by produce().

115 {
116  return mu1.processor() < mu2.processor();
117 }
const int processor() const
Get processor ID on which the candidate was found (0..5 for OMTF/EMTF; 0..11 for BMTF) ...
void L1TMicroGMTInputProducerFromGen::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 265 of file L1TMicroGMTInputProducerFromGen.cc.

265  {
266 }
void L1TMicroGMTInputProducerFromGen::endLuminosityBlock ( const edm::LuminosityBlock ,
edm::EventSetup const &   
)
overrideprivatevirtual

Definition at line 288 of file L1TMicroGMTInputProducerFromGen.cc.

289 {
290 }
void L1TMicroGMTInputProducerFromGen::endRun ( const edm::Run ,
edm::EventSetup const &   
)
overrideprivatevirtual

Definition at line 276 of file L1TMicroGMTInputProducerFromGen.cc.

277 {
278 }
void L1TMicroGMTInputProducerFromGen::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 294 of file L1TMicroGMTInputProducerFromGen.cc.

References edm::ConfigurationDescriptions::addDefault(), DEFINE_FWK_MODULE, and edm::ParameterSetDescription::setUnknown().

294  {
295  //The following says we do not know what parameters are allowed so do no validation
296  // Please change this to state exactly what you do use, even if it is no parameters
298  desc.setUnknown();
299  descriptions.addDefault(desc);
300 }
void addDefault(ParameterSetDescription const &psetDescription)
void L1TMicroGMTInputProducerFromGen::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Definition at line 121 of file L1TMicroGMTInputProducerFromGen.cc.

References funct::abs(), l1t::bmtf, reco::Candidate::charge(), compareMuons(), l1t::emtf_neg, l1t::emtf_pos, stringResolutionProvider_cfi::eta, reco::Candidate::eta(), GenHFHadronMatcher_cfi::genParticles, genParticlesToken, edm::Event::getByToken(), mps_fire::i, createfilelist::int, LogTrace, m_currEvt, m_maxMuons, m_rnd, MuonErrorMatrixAnalyzer_cfi::maxPt, eostools::move(), RPCpg::mu, l1t::omtf_neg, l1t::omtf_pos, reco::Candidate::pdgId(), phi, reco::Candidate::phi(), Pi, reco::Candidate::pt(), edm::Event::put(), l1t::RegionalMuonCand::setHwEta(), l1t::RegionalMuonCand::setHwPhi(), l1t::RegionalMuonCand::setHwPt(), l1t::RegionalMuonCand::setHwQual(), l1t::RegionalMuonCand::setHwSign(), l1t::RegionalMuonCand::setHwSignValid(), l1t::RegionalMuonCand::setTFIdentifiers(), reco::Candidate::status(), and Geom::twoPi().

122 {
123  using namespace edm;
124 
125  std::unique_ptr<RegionalMuonCandBxCollection> barrelMuons (new RegionalMuonCandBxCollection());
126  std::unique_ptr<RegionalMuonCandBxCollection> overlapMuons (new RegionalMuonCandBxCollection());
127  std::unique_ptr<RegionalMuonCandBxCollection> endcapMuons (new RegionalMuonCandBxCollection());
128  std::unique_ptr<MuonCaloSumBxCollection> towerSums (new MuonCaloSumBxCollection());
129 
130  std::vector<RegionalMuonCand> bmMuons;
131  std::vector<RegionalMuonCand> omMuons;
132  std::vector<RegionalMuonCand> emMuons;
133 
134 
135  std::vector<int> muIndices;
137  // Make sure that you can get genParticles
138  if (iEvent.getByToken(genParticlesToken, genParticles)) {
139  int cntr = 0;
140  for (auto it = genParticles->cbegin(); it != genParticles->cend(); ++it) {
141  const reco::Candidate& mcParticle = *it;
142  if( abs(mcParticle.pdgId()) == 13 && mcParticle.status() == 1 ) muIndices.push_back(cntr);
143  cntr++;
144  }
145  }
146  else {
147  LogTrace("GlobalMuon") << " GenParticleCollection not found." << std::endl;
148  }
149 
151  MuonCaloSum tSum;
152  // alternative scale (using full phi bit-width): 163.4521265553765f;
153  const float phiToInt = 91.67324722093171f;
154  // alternative scale: 100.0f;
155  const float etaToInt = 90.9090909090f;
156  const int maxPt = (1 << 9)-1;
157  int muCntr = 0;
158 
159  double twoPi = TMath::Pi() * 2.;
160 
161  for (auto it = muIndices.begin(); it != muIndices.end(); ++it) {
162  // don't really care which muons are taken...
163  // guess there ain't 108 generated anyways
164  if (muCntr == m_maxMuons) break;
165  int gen_idx = *it;
166  const reco::Candidate& mcMuon = genParticles->at(gen_idx);
167  double eta = mcMuon.eta();
168  if (fabs(eta) > 2.45) continue; // out of acceptance
169  int hwPt = int(mcMuon.pt() * 2);
170  hwPt = (hwPt < maxPt ? hwPt : maxPt);
171  int hwEta = int(eta * etaToInt);
172  double phi = mcMuon.phi();
173  if (phi < 0) phi += twoPi; // add 2*pi
174  int hwPhi = (int(phi * phiToInt))%576;
175  int hwQual = 8;
176  int hwCharge = (mcMuon.charge() > 0) ? 0 : 1;
177  int hwChargeValid = 1;
178 
179  mu.setHwPt(hwPt);
180 
181 
182 
183  tftype tf(tftype::bmtf);
184  int globalWedgePhi = (hwPhi+24)%576; // this sets CMS phi = 0 to -15 deg
185  int localPhi = globalWedgePhi%48;
186  int processor = globalWedgePhi / 48 + 1;
187  int globalSectorPhi = (hwPhi-24); // this sets CMS phi = 0 to +15 deg
188  if (globalSectorPhi < 0) {
189  globalSectorPhi += 576;
190  }
191 
192 
193  if (fabs(eta) > 0.8) {
194  if (fabs(eta) < 1.2) {
195  tf = (eta > 0 ? tftype::omtf_pos : tftype::omtf_neg);
196  processor = globalSectorPhi / 96 + 1;
197  localPhi = globalSectorPhi%96;
198  } else {
199  tf = (eta > 0 ? tftype::emtf_pos : tftype::emtf_neg);
200  processor = globalSectorPhi / 96 + 1;
201  localPhi = globalSectorPhi%96;
202  }
203  }
204  mu.setHwPhi(localPhi);
205  mu.setTFIdentifiers(processor, tf);
206 
207  mu.setHwEta(hwEta);
208  mu.setHwSign(hwCharge);
209  mu.setHwSignValid(hwChargeValid);
210  mu.setHwQual(hwQual);
211 
212  if (fabs(eta) < 0.8 && bmMuons.size() < 36) {
213  bmMuons.push_back(mu);
214  muCntr++;
215  } else if (fabs(eta) < 1.2 && omMuons.size() < 36) {
216  omMuons.push_back(mu);
217  muCntr++;
218  } else if (emMuons.size() < 36) {
219  emMuons.push_back(mu);
220  muCntr++;
221  }
222  }
223 
224  std::sort(bmMuons.begin(), bmMuons.end(), L1TMicroGMTInputProducerFromGen::compareMuons);
225  std::sort(omMuons.begin(), omMuons.end(), L1TMicroGMTInputProducerFromGen::compareMuons);
226  std::sort(emMuons.begin(), emMuons.end(), L1TMicroGMTInputProducerFromGen::compareMuons);
227 
228  for (const auto& mu:bmMuons) {
229  barrelMuons->push_back(0, mu);
230  }
231 
232  for (const auto& mu:omMuons) {
233  overlapMuons->push_back(0, mu);
234  }
235 
236  for (const auto& mu:emMuons) {
237  endcapMuons->push_back(0, mu);
238  }
239 
240  for (int i = 0; i < 1008; ++i) {
241  // from where could I take the tower energies?
242  int energy = int(m_rnd.Gaus(12, 6));
243  if (energy < 0) energy = 0;
244  if (energy > 31) energy = 31;
245  MuonCaloSum sum(energy, i/28, i%28, i);
246  towerSums->push_back(0, sum);
247  }
248 
249  iEvent.put(std::move(barrelMuons), "BarrelTFMuons");
250  iEvent.put(std::move(overlapMuons), "OverlapTFMuons");
251  iEvent.put(std::move(endcapMuons), "ForwardTFMuons");
252  iEvent.put(std::move(towerSums), "TriggerTowerSums");
253  m_currEvt++;
254 
255 }
const double Pi
void setHwPhi(int bits)
Set compressed relative phi as transmitted by hardware LSB = 2*pi/576 (8 bits)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
BXVector< RegionalMuonCand > RegionalMuonCandBxCollection
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
BXVector< MuonCaloSum > MuonCaloSumBxCollection
Definition: MuonCaloSumFwd.h:7
virtual int status() const =0
status word
void setTFIdentifiers(int processor, tftype trackFinder)
Set the processor ID, track-finder type. From these two, the link is set.
virtual int pdgId() const =0
PDG identifier.
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::EDGetTokenT< reco::GenParticleCollection > genParticlesToken
const int mu
Definition: Constants.h:22
#define LogTrace(id)
static bool compareMuons(const RegionalMuonCand &, const RegionalMuonCand &)
void setHwQual(int bits)
Set compressed quality code as transmitted by hardware (4 bits)
void setHwPt(int bits)
Set compressed pT as transmitted by hardware LSB = 0.5 (9 bits)
void setHwEta(int bits)
Set compressed eta as transmitted by hardware LSB = 0.010875 (9 bits)
virtual double eta() const =0
momentum pseudorapidity
virtual double pt() const =0
transverse momentum
virtual int charge() const =0
electric charge
HLT enums.
void setHwSignValid(int bits)
Set whether charge measurement is valid (0 for high pT muons)
constexpr double twoPi()
Definition: Pi.h:32
virtual double phi() const =0
momentum azimuthal angle
def move(src, dest)
Definition: eostools.py:510
void setHwSign(int bits)
Set charge sign bit (charge = (-1)^(sign))

Member Data Documentation

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

Definition at line 71 of file L1TMicroGMTInputProducerFromGen.cc.

Referenced by L1TMicroGMTInputProducerFromGen(), and produce().

int L1TMicroGMTInputProducerFromGen::m_currEvt
private

Definition at line 72 of file L1TMicroGMTInputProducerFromGen.cc.

Referenced by produce().

const int L1TMicroGMTInputProducerFromGen::m_maxMuons = 108
staticprivate

Definition at line 73 of file L1TMicroGMTInputProducerFromGen.cc.

Referenced by produce().

TRandom3 L1TMicroGMTInputProducerFromGen::m_rnd
private

Definition at line 74 of file L1TMicroGMTInputProducerFromGen.cc.

Referenced by produce().