CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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

Static Private Member Functions

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

Private Attributes

edm::EDGetTokenT
< reco::GenParticleCollection
genParticlesToken
 
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 49 of file L1TMicroGMTInputProducerFromGen.cc.

Constructor & Destructor Documentation

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

Definition at line 87 of file L1TMicroGMTInputProducerFromGen.cc.

References genParticlesToken, and AlCaHLTBitMon_QueryRunRegistry::string.

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

Definition at line 100 of file L1TMicroGMTInputProducerFromGen.cc.

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

Member Function Documentation

void L1TMicroGMTInputProducerFromGen::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 257 of file L1TMicroGMTInputProducerFromGen.cc.

258 {
259 }
void L1TMicroGMTInputProducerFromGen::beginLuminosityBlock ( edm::LuminosityBlock ,
edm::EventSetup const &   
)
privatevirtual

Definition at line 280 of file L1TMicroGMTInputProducerFromGen.cc.

281 {
282 }
void L1TMicroGMTInputProducerFromGen::beginRun ( edm::Run ,
edm::EventSetup const &   
)
privatevirtual

Definition at line 268 of file L1TMicroGMTInputProducerFromGen.cc.

269 {
270 }
bool L1TMicroGMTInputProducerFromGen::compareMuons ( const RegionalMuonCand mu1,
const RegionalMuonCand mu2 
)
staticprivate

Definition at line 112 of file L1TMicroGMTInputProducerFromGen.cc.

References l1t::RegionalMuonCand::processor().

Referenced by produce().

113 {
114  return mu1.processor() < mu2.processor();
115 }
const int processor() const
Get processor ID on which the candidate was found (1..6 for OMTF/EMTF; 1..12 for BMTF) ...
void L1TMicroGMTInputProducerFromGen::endJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 263 of file L1TMicroGMTInputProducerFromGen.cc.

263  {
264 }
void L1TMicroGMTInputProducerFromGen::endLuminosityBlock ( edm::LuminosityBlock ,
edm::EventSetup const &   
)
privatevirtual

Definition at line 286 of file L1TMicroGMTInputProducerFromGen.cc.

287 {
288 }
void L1TMicroGMTInputProducerFromGen::endRun ( edm::Run ,
edm::EventSetup const &   
)
privatevirtual

Definition at line 274 of file L1TMicroGMTInputProducerFromGen.cc.

275 {
276 }
void L1TMicroGMTInputProducerFromGen::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 292 of file L1TMicroGMTInputProducerFromGen.cc.

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

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

Implements edm::EDProducer.

Definition at line 119 of file L1TMicroGMTInputProducerFromGen.cc.

References funct::abs(), l1t::bmtf, reco::Candidate::charge(), compareMuons(), l1t::emtf_neg, l1t::emtf_pos, relval_parameters_module::energy, eta, reco::Candidate::eta(), genParticleCandidates2GenParticles_cfi::genParticles, genParticlesToken, edm::Event::getByToken(), i, LogTrace, m_currEvt, m_maxMuons, m_rnd, RPCpg::mu, l1t::omtf_neg, l1t::omtf_pos, reco::Candidate::pdgId(), phi, reco::Candidate::phi(), Pi, reco::Candidate::pt(), edm::Event::put(), python.multivaluedict::sort(), reco::Candidate::status(), and Geom::twoPi().

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

Member Data Documentation

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

Definition at line 69 of file L1TMicroGMTInputProducerFromGen.cc.

Referenced by L1TMicroGMTInputProducerFromGen(), and produce().

int L1TMicroGMTInputProducerFromGen::m_currEvt
private

Definition at line 70 of file L1TMicroGMTInputProducerFromGen.cc.

Referenced by produce().

const int L1TMicroGMTInputProducerFromGen::m_maxMuons = 108
staticprivate

Definition at line 71 of file L1TMicroGMTInputProducerFromGen.cc.

Referenced by produce().

TRandom3 L1TMicroGMTInputProducerFromGen::m_rnd
private

Definition at line 72 of file L1TMicroGMTInputProducerFromGen.cc.

Referenced by produce().