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::stream::EDProducer<>

Public Member Functions

 L1TMicroGMTInputProducer (const edm::ParameterSet &)
 
 ~L1TMicroGMTInputProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () 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
 
int convertToInt (std::string &bitstr) const
 
void endLuminosityBlock (const edm::LuminosityBlock &, edm::EventSetup const &) override
 
void endRun (const edm::Run &, edm::EventSetup const &) override
 
void openFile ()
 
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::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 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 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<MuonCaloSumBxCollection>("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 ( )
override

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::beginLuminosityBlock ( const edm::LuminosityBlock ,
edm::EventSetup const &   
)
overrideprivate

Definition at line 325 of file L1TMicroGMTInputProducer.cc.

326 {
327 }
void L1TMicroGMTInputProducer::beginRun ( const edm::Run ,
edm::EventSetup const &   
)
overrideprivate

Definition at line 313 of file L1TMicroGMTInputProducer.cc.

314 {
315 }
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 (0..5 for OMTF/EMTF; 0..11 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::endLuminosityBlock ( const edm::LuminosityBlock ,
edm::EventSetup const &   
)
overrideprivate

Definition at line 331 of file L1TMicroGMTInputProducer.cc.

332 {
333 }
void L1TMicroGMTInputProducer::endRun ( const edm::Run ,
edm::EventSetup const &   
)
overrideprivate

Definition at line 319 of file L1TMicroGMTInputProducer.cc.

320 {
321 }
void L1TMicroGMTInputProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 337 of file L1TMicroGMTInputProducer.cc.

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

337  {
338  //The following says we do not know what parameters are allowed so do no validation
339  // Please change this to state exactly what you do use, even if it is no parameters
341  desc.setUnknown();
342  descriptions.addDefault(desc);
343 }
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 
)
overrideprivate

Definition at line 158 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.

159 {
160  using namespace edm;
161 
162  std::unique_ptr<RegionalMuonCandBxCollection> barrelMuons (new RegionalMuonCandBxCollection());
163  std::unique_ptr<RegionalMuonCandBxCollection> overlapMuons (new RegionalMuonCandBxCollection());
164  std::unique_ptr<RegionalMuonCandBxCollection> endcapMuons (new RegionalMuonCandBxCollection());
165  std::unique_ptr<MuonCaloSumBxCollection> towerSums (new MuonCaloSumBxCollection());
166 
168  MuonCaloSum 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(std::move(barrelMuons), "BarrelTFMuons");
304  iEvent.put(std::move(overlapMuons), "OverlapTFMuons");
305  iEvent.put(std::move(endcapMuons), "ForwardTFMuons");
306  iEvent.put(std::move(towerSums), "TriggerTowerSums");
307  m_currEvt++;
308 
309 }
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:136
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 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.