CMS 3D CMS Logo

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

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

Inheritance diagram for L1TMicroGMTInputProducer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 L1TMicroGMTInputProducer (const edm::ParameterSet &)
 
 ~L1TMicroGMTInputProducer ()
 
- 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 & itemsToGetFrom (BranchType iType) 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
 
int convertToInt (std::string &bitstr) const
 
virtual void endJob () override
 
virtual void endLuminosityBlock (const edm::LuminosityBlock &, edm::EventSetup const &) override
 
virtual void endRun (const edm::Run &, edm::EventSetup const &) override
 
void openFile ()
 
virtual void produce (edm::Event &, const edm::EventSetup &) override
 
void skipHeader ()
 

Static Private Member Functions

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

Private Attributes

int m_currEvt
 
int m_currType
 
bool m_endOfBx
 
std::ifstream m_filestream
 
std::string m_fname
 
bool m_lastMuInBx
 

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 txt-file input and produces barrel- / overlap- / forward TF muons

Implementation: [Notes on implementation]

Definition at line 47 of file L1TMicroGMTInputProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 90 of file L1TMicroGMTInputProducer.cc.

References edm::ParameterSet::getParameter(), m_fname, openFile(), skipHeader(), and AlCaHLTBitMon_QueryRunRegistry::string.

90  :
91  m_endOfBx(false), m_currType(0), m_currEvt(0)
92 {
93  //register your products
94  produces<RegionalMuonCandBxCollection>("BarrelTFMuons");
95  produces<RegionalMuonCandBxCollection>("OverlapTFMuons");
96  produces<RegionalMuonCandBxCollection>("ForwardTFMuons");
97  produces<MuonCaloSumBxCollection>("TriggerTowerSums");
98 
99  //now do what ever other initialization is needed
100  m_fname = iConfig.getParameter<std::string> ("inputFileName");
101 
102  openFile();
103  skipHeader();
104 }
T getParameter(std::string const &) const
L1TMicroGMTInputProducer::~L1TMicroGMTInputProducer ( )

Definition at line 107 of file L1TMicroGMTInputProducer.cc.

References m_filestream.

108 {
109  // do anything here that needs to be done at desctruction time
110  // (e.g. close files, deallocate resources etc.)
111  m_filestream.close();
112 }

Member Function Documentation

void L1TMicroGMTInputProducer::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 315 of file L1TMicroGMTInputProducer.cc.

316 {
317 }
void L1TMicroGMTInputProducer::beginLuminosityBlock ( const edm::LuminosityBlock ,
edm::EventSetup const &   
)
overrideprivatevirtual

Definition at line 338 of file L1TMicroGMTInputProducer.cc.

339 {
340 }
void L1TMicroGMTInputProducer::beginRun ( const edm::Run ,
edm::EventSetup const &   
)
overrideprivatevirtual

Definition at line 326 of file L1TMicroGMTInputProducer.cc.

327 {
328 }
bool L1TMicroGMTInputProducer::cmpProc ( const RegionalMuonCand mu1,
const RegionalMuonCand mu2 
)
staticprivate

Definition at line 119 of file L1TMicroGMTInputProducer.cc.

References l1t::RegionalMuonCand::processor().

120 {
121  return mu1.processor() < mu2.processor();
122 }
const int processor() const
Get processor ID on which the candidate was found (0..5 for OMTF/EMTF; 0..11 for BMTF) ...
int L1TMicroGMTInputProducer::convertToInt ( std::string &  bitstr) const
private

Definition at line 145 of file L1TMicroGMTInputProducer.cc.

References EnergyCorrector::c, and pileupDistInMC::num.

146 {
147  int num = 0;
148  for (size_t cntr = 0; cntr < bitstr.size(); ++cntr) {
149  char c = bitstr[cntr];
150  num = (num << 1) | // Shift the current set of bits to the left one bit
151  (c - '0'); // Add in the current bit via a bitwise-or
152  }
153  return num;
154 }
void L1TMicroGMTInputProducer::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 321 of file L1TMicroGMTInputProducer.cc.

321  {
322 }
void L1TMicroGMTInputProducer::endLuminosityBlock ( const edm::LuminosityBlock ,
edm::EventSetup const &   
)
overrideprivatevirtual

Definition at line 344 of file L1TMicroGMTInputProducer.cc.

345 {
346 }
void L1TMicroGMTInputProducer::endRun ( const edm::Run ,
edm::EventSetup const &   
)
overrideprivatevirtual

Definition at line 332 of file L1TMicroGMTInputProducer.cc.

333 {
334 }
void L1TMicroGMTInputProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 350 of file L1TMicroGMTInputProducer.cc.

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

350  {
351  //The following says we do not know what parameters are allowed so do no validation
352  // Please change this to state exactly what you do use, even if it is no parameters
354  desc.setUnknown();
355  descriptions.addDefault(desc);
356 }
void addDefault(ParameterSetDescription const &psetDescription)
void L1TMicroGMTInputProducer::openFile ( )
private

Definition at line 125 of file L1TMicroGMTInputProducer.cc.

References Exception, m_filestream, and m_fname.

Referenced by L1TMicroGMTInputProducer().

126 {
127  if (!m_filestream.is_open()) {
128  m_filestream.open(m_fname.c_str());
129  if (!m_filestream.good()) {
130  cms::Exception("FileOpenError") << "Failed to open input file";
131  }
132  }
133 }
void L1TMicroGMTInputProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Definition at line 160 of file L1TMicroGMTInputProducer.cc.

References l1t::bmtf, l1t::emtf_neg, l1t::emtf_pos, stringResolutionProvider_cfi::et, f, mps_fire::i, createfilelist::int, m_currEvt, m_currType, m_endOfBx, m_filestream, eostools::move(), RPCpg::mu, l1t::omtf_neg, l1t::omtf_pos, edm::Event::put(), l1t::MuonCaloSum::setEtaBits(), l1t::MuonCaloSum::setEtBits(), l1t::RegionalMuonCand::setHwEta(), l1t::RegionalMuonCand::setHwPhi(), l1t::RegionalMuonCand::setHwPt(), l1t::RegionalMuonCand::setHwQual(), l1t::RegionalMuonCand::setHwSign(), l1t::RegionalMuonCand::setHwSignValid(), l1t::MuonCaloSum::setIndex(), l1t::MuonCaloSum::setPhiBits(), l1t::RegionalMuonCand::setTFIdentifiers(), createPayload::skip, AlCaHLTBitMon_QueryRunRegistry::string, and tmp.

161 {
162  using namespace edm;
163 
164  std::unique_ptr<RegionalMuonCandBxCollection> barrelMuons (new RegionalMuonCandBxCollection());
165  std::unique_ptr<RegionalMuonCandBxCollection> overlapMuons (new RegionalMuonCandBxCollection());
166  std::unique_ptr<RegionalMuonCandBxCollection> endcapMuons (new RegionalMuonCandBxCollection());
167  std::unique_ptr<MuonCaloSumBxCollection> towerSums (new MuonCaloSumBxCollection());
168 
170  MuonCaloSum tSum;
171  m_endOfBx = false;
172  int caloCounter = 0;
173  std::vector<int> bar{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
174  std::vector<int> ovl_neg{0, 0, 0, 0, 0, 0};
175  std::vector<int> ovl_pos{0, 0, 0, 0, 0, 0};
176  std::vector<int> fwd_neg{0, 0, 0, 0, 0, 0};
177  std::vector<int> fwd_pos{0, 0, 0, 0, 0, 0};
178  while(!m_endOfBx && !m_filestream.eof()) {
179  std::string lineID;
180  m_filestream >> lineID;
181  std::string restOfLine;
182 
183 
184  if (lineID == "BAR" || lineID == "OVL-" || lineID == "FWD-" || lineID == "OVL+" || lineID == "FWD+") {
185  int tmp;
186  m_filestream >> tmp; // cable no
187  // if (lineID == "BAR") tmp += 12;
188  // if (lineID == "OVL-") tmp = (tmp-6)+24;
189  // if (lineID == "OVL+") tmp = tmp + 6;
190  // if (lineID == "FWD-") tmp = (tmp-6)+30;
191 
192  // mu.setLink(tmp);
193  m_filestream >> tmp;
194  mu.setHwPt(tmp);
195 
196  m_filestream >> tmp;
197 
198  int globalPhi = int(tmp*0.560856864654333f); // correction from txt file producer!
199  int globalWedgePhi = (globalPhi+24)%576; // this sets CMS phi = 0 to -15 deg
200  int globalSectorPhi = (globalPhi-24); // this sets CMS phi = 0 to +15 deg
201  if (globalSectorPhi < 0) {
202  globalSectorPhi += 576;
203  }
204 
205 
206  // int globalMuonPhi = int(tmp*0.560856864654333f); // make sure scale is correct
207  bool skip = false;
208  if (lineID == "BAR") {
209  int processor = globalWedgePhi / 48 + 1;
210  int localPhi = globalWedgePhi%48;
211  mu.setTFIdentifiers(processor, tftype::bmtf);
212  mu.setHwPhi(localPhi);
213  bar[processor-1]++;
214  if (bar[processor-1] > 3) skip = true;
215  }
216  if (lineID == "OVL-") {
217  int processor = globalSectorPhi / 96 + 1;
218  int localPhi = globalSectorPhi%96;
219  mu.setTFIdentifiers(processor, tftype::omtf_neg);
220  mu.setHwPhi(localPhi);
221  ovl_neg[processor-1]++;
222  if (ovl_neg[processor-1] > 3) skip = true;
223  }
224  if (lineID == "OVL+") {
225  int processor = globalSectorPhi / 96 + 1;
226  int localPhi = globalSectorPhi%96;
227  mu.setTFIdentifiers(processor, tftype::omtf_pos);
228  mu.setHwPhi(localPhi);
229  ovl_pos[processor-1]++;
230  if (ovl_pos[processor-1] > 3) skip = true;
231  }
232  if (lineID == "FWD-") {
233  int processor = globalSectorPhi / 96 + 1;
234  int localPhi = globalSectorPhi%96;
235  mu.setTFIdentifiers(processor, tftype::emtf_neg);
236  mu.setHwPhi(localPhi);
237  fwd_neg[processor-1]++;
238  if (fwd_neg[processor-1] > 3) skip = true;
239  }
240  if (lineID == "FWD+") {
241  int processor = globalSectorPhi / 96 + 1;
242  int localPhi = globalSectorPhi%96;
243  mu.setTFIdentifiers(processor, tftype::emtf_pos);
244  mu.setHwPhi(localPhi);
245  fwd_pos[processor-1]++;
246  if (fwd_pos[processor-1] > 3) skip = true;
247  }
248 
249  m_filestream >> tmp;
250  tmp = int(tmp*0.9090909090f);
251  mu.setHwEta(tmp);
252 
253 
254 
255  m_filestream >> tmp;
256  mu.setHwSign(tmp);
257 
258  m_filestream >> tmp;
259  mu.setHwSignValid(tmp);
260 
261  m_filestream >> tmp;
262  mu.setHwQual(tmp);
263 
264  if (lineID == "BAR") m_currType = 0;
265  if (lineID == "OVL-") m_currType = 1;
266  if (lineID == "OVL+") m_currType = 2;
267  if (lineID == "FWD-") m_currType = 3;
268  if (lineID == "FWD+") m_currType = 4;
269 
270  if (m_currType == 0 && !skip) barrelMuons->push_back(0, mu);
271  if ((m_currType == 1 || m_currType == 2) && !skip) overlapMuons->push_back(0, mu);
272  if ((m_currType == 3 || m_currType == 4) && !skip) endcapMuons->push_back(0, mu);
273  }
274 
275  if (lineID == "EVT" && m_currEvt != 0) {
276  m_endOfBx = true;
277  } else if (lineID == "EVT") {
278  m_currEvt++;
279  }
280 
281  if (lineID == "CALO") {
282  for (int i = 0; i < 28; ++i) {
283  int ieta = i; //caloCounter%28;
284  int iphi = caloCounter;
285  int et;
286 
287  m_filestream >> et;
288  tSum.setEtBits(et);
289  tSum.setEtaBits(ieta);
290  tSum.setPhiBits(iphi);
291  tSum.setIndex(caloCounter*28+i);
292  towerSums->push_back(0, tSum);
293  }
294  caloCounter++;
295  }
296  getline(m_filestream, restOfLine);
297  //std::cout << restOfLine;
298  }
299 
300 
301  // std::sort(barrelMuons->begin(0), barrelMuons->end(0), L1TMicroGMTInputProducer::cmpProc);
302  // std::sort(overlapMuons->begin(0), overlapMuons->end(0), L1TMicroGMTInputProducer::cmpProc);
303  // std::sort(endcapMuons->begin(0), endcapMuons->end(0), L1TMicroGMTInputProducer::cmpProc);
304 
305  iEvent.put(std::move(barrelMuons), "BarrelTFMuons");
306  iEvent.put(std::move(overlapMuons), "OverlapTFMuons");
307  iEvent.put(std::move(endcapMuons), "ForwardTFMuons");
308  iEvent.put(std::move(towerSums), "TriggerTowerSums");
309  m_currEvt++;
310 
311 }
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
void setEtaBits(int bits)
Definition: MuonCaloSum.h:19
BXVector< RegionalMuonCand > RegionalMuonCandBxCollection
BXVector< MuonCaloSum > MuonCaloSumBxCollection
Definition: MuonCaloSumFwd.h:7
void setIndex(int idx)
Definition: MuonCaloSum.h:20
void setTFIdentifiers(int processor, tftype trackFinder)
Set the processor ID, track-finder type. From these two, the link is set.
double f[11][100]
const int mu
Definition: Constants.h:22
void setPhiBits(int bits)
Definition: MuonCaloSum.h:18
void setHwQual(int bits)
Set compressed quality code as transmitted by hardware (4 bits)
void setEtBits(int bits)
Definition: MuonCaloSum.h:17
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)
et
define resolution functions of each parameter
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
HLT enums.
void setHwSignValid(int bits)
Set whether charge measurement is valid (0 for high pT muons)
def move(src, dest)
Definition: eostools.py:510
void setHwSign(int bits)
Set charge sign bit (charge = (-1)^(sign))
void L1TMicroGMTInputProducer::skipHeader ( )
private

Definition at line 136 of file L1TMicroGMTInputProducer.cc.

References m_filestream, AlCaHLTBitMon_QueryRunRegistry::string, and tmp.

Referenced by L1TMicroGMTInputProducer().

137 {
138  while (m_filestream.peek() == '#') {
140  getline(m_filestream, tmp);
141  }
142 }
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100

Member Data Documentation

int L1TMicroGMTInputProducer::m_currEvt
private

Definition at line 75 of file L1TMicroGMTInputProducer.cc.

Referenced by produce().

int L1TMicroGMTInputProducer::m_currType
private

Definition at line 74 of file L1TMicroGMTInputProducer.cc.

Referenced by produce().

bool L1TMicroGMTInputProducer::m_endOfBx
private

Definition at line 72 of file L1TMicroGMTInputProducer.cc.

Referenced by produce().

std::ifstream L1TMicroGMTInputProducer::m_filestream
private
std::string L1TMicroGMTInputProducer::m_fname
private

Definition at line 70 of file L1TMicroGMTInputProducer.cc.

Referenced by L1TMicroGMTInputProducer(), and openFile().

bool L1TMicroGMTInputProducer::m_lastMuInBx
private

Definition at line 73 of file L1TMicroGMTInputProducer.cc.