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
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)
 
 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 &)
 
int convertToInt (std::string &bitstr) const
 
virtual void endJob ()
 
virtual void endLuminosityBlock (edm::LuminosityBlock &, edm::EventSetup const &)
 
virtual void endRun (edm::Run &, edm::EventSetup const &)
 
void openFile ()
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 
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 45 of file L1TMicroGMTInputProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 88 of file L1TMicroGMTInputProducer.cc.

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

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

Definition at line 105 of file L1TMicroGMTInputProducer.cc.

References m_filestream.

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

Member Function Documentation

void L1TMicroGMTInputProducer::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 313 of file L1TMicroGMTInputProducer.cc.

314 {
315 }
void L1TMicroGMTInputProducer::beginLuminosityBlock ( edm::LuminosityBlock ,
edm::EventSetup const &   
)
privatevirtual

Definition at line 336 of file L1TMicroGMTInputProducer.cc.

337 {
338 }
void L1TMicroGMTInputProducer::beginRun ( edm::Run ,
edm::EventSetup const &   
)
privatevirtual

Definition at line 324 of file L1TMicroGMTInputProducer.cc.

325 {
326 }
bool L1TMicroGMTInputProducer::cmpProc ( const RegionalMuonCand mu1,
const RegionalMuonCand mu2 
)
staticprivate

Definition at line 117 of file L1TMicroGMTInputProducer.cc.

References l1t::RegionalMuonCand::processor().

118 {
119  return mu1.processor() < mu2.processor();
120 }
const int processor() const
Get processor ID on which the candidate was found (1..6 for OMTF/EMTF; 1..12 for BMTF) ...
int L1TMicroGMTInputProducer::convertToInt ( std::string &  bitstr) const
private

Definition at line 143 of file L1TMicroGMTInputProducer.cc.

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

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

Reimplemented from edm::EDProducer.

Definition at line 319 of file L1TMicroGMTInputProducer.cc.

319  {
320 }
void L1TMicroGMTInputProducer::endLuminosityBlock ( edm::LuminosityBlock ,
edm::EventSetup const &   
)
privatevirtual

Definition at line 342 of file L1TMicroGMTInputProducer.cc.

343 {
344 }
void L1TMicroGMTInputProducer::endRun ( edm::Run ,
edm::EventSetup const &   
)
privatevirtual

Definition at line 330 of file L1TMicroGMTInputProducer.cc.

331 {
332 }
void L1TMicroGMTInputProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 348 of file L1TMicroGMTInputProducer.cc.

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

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

Definition at line 123 of file L1TMicroGMTInputProducer.cc.

References Exception, m_filestream, and m_fname.

Referenced by L1TMicroGMTInputProducer().

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

Implements edm::EDProducer.

Definition at line 158 of file L1TMicroGMTInputProducer.cc.

References l1t::bmtf, l1t::emtf_neg, l1t::emtf_pos, f, i, m_currEvt, m_currType, m_endOfBx, m_filestream, RPCpg::mu, l1t::omtf_neg, l1t::omtf_pos, edm::Event::put(), runGlobalFakeInputProducer::skip, AlCaHLTBitMon_QueryRunRegistry::string, and tmp.

159 {
160  using namespace edm;
161 
162  std::auto_ptr<RegionalMuonCandBxCollection> barrelMuons (new RegionalMuonCandBxCollection());
163  std::auto_ptr<RegionalMuonCandBxCollection> overlapMuons (new RegionalMuonCandBxCollection());
164  std::auto_ptr<RegionalMuonCandBxCollection> endcapMuons (new RegionalMuonCandBxCollection());
165  std::auto_ptr<GMTInputCaloSumBxCollection> towerSums (new GMTInputCaloSumBxCollection());
166 
168  GMTInputCaloSum tSum;
169  m_endOfBx = false;
170  int caloCounter = 0;
171  std::vector<int> bar{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
172  std::vector<int> ovl_neg{0, 0, 0, 0, 0, 0};
173  std::vector<int> ovl_pos{0, 0, 0, 0, 0, 0};
174  std::vector<int> fwd_neg{0, 0, 0, 0, 0, 0};
175  std::vector<int> fwd_pos{0, 0, 0, 0, 0, 0};
176  while(!m_endOfBx && !m_filestream.eof()) {
177  std::string lineID;
178  m_filestream >> lineID;
179  std::string restOfLine;
180 
181 
182  if (lineID == "BAR" || lineID == "OVL-" || lineID == "FWD-" || lineID == "OVL+" || lineID == "FWD+") {
183  int tmp;
184  m_filestream >> tmp; // cable no
185  // if (lineID == "BAR") tmp += 12;
186  // if (lineID == "OVL-") tmp = (tmp-6)+24;
187  // if (lineID == "OVL+") tmp = tmp + 6;
188  // if (lineID == "FWD-") tmp = (tmp-6)+30;
189 
190  // mu.setLink(tmp);
191  m_filestream >> tmp;
192  mu.setHwPt(tmp);
193 
194  m_filestream >> tmp;
195 
196  int globalPhi = int(tmp*0.560856864654333f); // correction from txt file producer!
197  int globalWedgePhi = (globalPhi+24)%576; // this sets CMS phi = 0 to -15 deg
198  int globalSectorPhi = (globalPhi-24); // this sets CMS phi = 0 to +15 deg
199  if (globalSectorPhi < 0) {
200  globalSectorPhi += 576;
201  }
202 
203 
204  // int globalMuonPhi = int(tmp*0.560856864654333f); // make sure scale is correct
205  bool skip = false;
206  if (lineID == "BAR") {
207  int processor = globalWedgePhi / 48 + 1;
208  int localPhi = globalWedgePhi%48;
209  mu.setTFIdentifiers(processor, tftype::bmtf);
210  mu.setHwPhi(localPhi);
211  bar[processor-1]++;
212  if (bar[processor-1] > 3) skip = true;
213  }
214  if (lineID == "OVL-") {
215  int processor = globalSectorPhi / 96 + 1;
216  int localPhi = globalSectorPhi%96;
217  mu.setTFIdentifiers(processor, tftype::omtf_neg);
218  mu.setHwPhi(localPhi);
219  ovl_neg[processor-1]++;
220  if (ovl_neg[processor-1] > 3) skip = true;
221  }
222  if (lineID == "OVL+") {
223  int processor = globalSectorPhi / 96 + 1;
224  int localPhi = globalSectorPhi%96;
225  mu.setTFIdentifiers(processor, tftype::omtf_pos);
226  mu.setHwPhi(localPhi);
227  ovl_pos[processor-1]++;
228  if (ovl_pos[processor-1] > 3) skip = true;
229  }
230  if (lineID == "FWD-") {
231  int processor = globalSectorPhi / 96 + 1;
232  int localPhi = globalSectorPhi%96;
233  mu.setTFIdentifiers(processor, tftype::emtf_neg);
234  mu.setHwPhi(localPhi);
235  fwd_neg[processor-1]++;
236  if (fwd_neg[processor-1] > 3) skip = true;
237  }
238  if (lineID == "FWD+") {
239  int processor = globalSectorPhi / 96 + 1;
240  int localPhi = globalSectorPhi%96;
241  mu.setTFIdentifiers(processor, tftype::emtf_pos);
242  mu.setHwPhi(localPhi);
243  fwd_pos[processor-1]++;
244  if (fwd_pos[processor-1] > 3) skip = true;
245  }
246 
247  m_filestream >> tmp;
248  tmp = int(tmp*0.9090909090f);
249  mu.setHwEta(tmp);
250 
251 
252 
253  m_filestream >> tmp;
254  mu.setHwSign(tmp);
255 
256  m_filestream >> tmp;
257  mu.setHwSignValid(tmp);
258 
259  m_filestream >> tmp;
260  mu.setHwQual(tmp);
261 
262  if (lineID == "BAR") m_currType = 0;
263  if (lineID == "OVL-") m_currType = 1;
264  if (lineID == "OVL+") m_currType = 2;
265  if (lineID == "FWD-") m_currType = 3;
266  if (lineID == "FWD+") m_currType = 4;
267 
268  if (m_currType == 0 && !skip) barrelMuons->push_back(0, mu);
269  if ((m_currType == 1 || m_currType == 2) && !skip) overlapMuons->push_back(0, mu);
270  if ((m_currType == 3 || m_currType == 4) && !skip) endcapMuons->push_back(0, mu);
271  }
272 
273  if (lineID == "EVT" && m_currEvt != 0) {
274  m_endOfBx = true;
275  } else if (lineID == "EVT") {
276  m_currEvt++;
277  }
278 
279  if (lineID == "CALO") {
280  for (int i = 0; i < 28; ++i) {
281  int ieta = i; //caloCounter%28;
282  int iphi = caloCounter;
283  int et;
284 
285  m_filestream >> et;
286  tSum.setEtBits(et);
287  tSum.setEtaBits(ieta);
288  tSum.setPhiBits(iphi);
289  tSum.setIndex(caloCounter*28+i);
290  towerSums->push_back(0, tSum);
291  }
292  caloCounter++;
293  }
294  getline(m_filestream, restOfLine);
295  //std::cout << restOfLine;
296  }
297 
298 
299  // std::sort(barrelMuons->begin(0), barrelMuons->end(0), L1TMicroGMTInputProducer::cmpProc);
300  // std::sort(overlapMuons->begin(0), overlapMuons->end(0), L1TMicroGMTInputProducer::cmpProc);
301  // std::sort(endcapMuons->begin(0), endcapMuons->end(0), L1TMicroGMTInputProducer::cmpProc);
302 
303  iEvent.put(barrelMuons, "BarrelTFMuons");
304  iEvent.put(overlapMuons, "OverlapTFMuons");
305  iEvent.put(endcapMuons, "ForwardTFMuons");
306  iEvent.put(towerSums, "TriggerTowerSums");
307  m_currEvt++;
308 
309 }
int i
Definition: DBlmapReader.cc:9
BXVector< RegionalMuonCand > RegionalMuonCandBxCollection
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:120
double f[11][100]
const int mu
Definition: Constants.h:22
BXVector< GMTInputCaloSum > GMTInputCaloSumBxCollection
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
void L1TMicroGMTInputProducer::skipHeader ( )
private

Definition at line 134 of file L1TMicroGMTInputProducer.cc.

References m_filestream, AlCaHLTBitMon_QueryRunRegistry::string, and tmp.

Referenced by L1TMicroGMTInputProducer().

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

Member Data Documentation

int L1TMicroGMTInputProducer::m_currEvt
private

Definition at line 73 of file L1TMicroGMTInputProducer.cc.

Referenced by produce().

int L1TMicroGMTInputProducer::m_currType
private

Definition at line 72 of file L1TMicroGMTInputProducer.cc.

Referenced by produce().

bool L1TMicroGMTInputProducer::m_endOfBx
private

Definition at line 70 of file L1TMicroGMTInputProducer.cc.

Referenced by produce().

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

Definition at line 68 of file L1TMicroGMTInputProducer.cc.

Referenced by L1TMicroGMTInputProducer(), and openFile().

bool L1TMicroGMTInputProducer::m_lastMuInBx
private

Definition at line 71 of file L1TMicroGMTInputProducer.cc.