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
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Member Functions

int convertToInt (std::string &bitstr) const
 
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<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Description: Takes txt-file input and produces barrel- / overlap- / forward TF muons

Implementation: [Notes on implementation]

Definition at line 46 of file L1TMicroGMTInputProducer.cc.

Constructor & Destructor Documentation

◆ L1TMicroGMTInputProducer()

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

Definition at line 81 of file L1TMicroGMTInputProducer.cc.

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

82  : m_endOfBx(false), m_currType(0), m_currEvt(0) {
83  //register your products
84  produces<RegionalMuonCandBxCollection>("BarrelTFMuons");
85  produces<RegionalMuonCandBxCollection>("OverlapTFMuons");
86  produces<RegionalMuonCandBxCollection>("ForwardTFMuons");
87  produces<MuonCaloSumBxCollection>("TriggerTowerSums");
88 
89  //now do what ever other initialization is needed
90  m_fname = iConfig.getParameter<std::string>("inputFileName");
91 
92  openFile();
93  skipHeader();
94 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307

◆ ~L1TMicroGMTInputProducer()

L1TMicroGMTInputProducer::~L1TMicroGMTInputProducer ( )
override

Definition at line 96 of file L1TMicroGMTInputProducer.cc.

References m_filestream.

96  {
97  // do anything here that needs to be done at desctruction time
98  // (e.g. close files, deallocate resources etc.)
99  m_filestream.close();
100 }

Member Function Documentation

◆ cmpProc()

bool L1TMicroGMTInputProducer::cmpProc ( const RegionalMuonCand mu1,
const RegionalMuonCand mu2 
)
staticprivate

Definition at line 105 of file L1TMicroGMTInputProducer.cc.

References l1t::RegionalMuonCand::processor().

105  {
106  return mu1.processor() < mu2.processor();
107 }
const int processor() const
Get processor ID on which the candidate was found (0..5 for OMTF/EMTF; 0..11 for BMTF) ...

◆ convertToInt()

int L1TMicroGMTInputProducer::convertToInt ( std::string &  bitstr) const
private

Definition at line 125 of file L1TMicroGMTInputProducer.cc.

References DummyCfis::c, and EgammaValidation_cff::num.

125  {
126  int num = 0;
127  for (size_t cntr = 0; cntr < bitstr.size(); ++cntr) {
128  char c = bitstr[cntr];
129  num = (num << 1) | // Shift the current set of bits to the left one bit
130  (c - '0'); // Add in the current bit via a bitwise-or
131  }
132  return num;
133 }

◆ fillDescriptions()

void L1TMicroGMTInputProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 296 of file L1TMicroGMTInputProducer.cc.

References edm::ConfigurationDescriptions::addDefault(), and submitPVResolutionJobs::desc.

296  {
297  //The following says we do not know what parameters are allowed so do no validation
298  // Please change this to state exactly what you do use, even if it is no parameters
300  desc.setUnknown();
301  descriptions.addDefault(desc);
302 }
void addDefault(ParameterSetDescription const &psetDescription)

◆ openFile()

void L1TMicroGMTInputProducer::openFile ( )
private

Definition at line 109 of file L1TMicroGMTInputProducer.cc.

References Exception, m_filestream, and m_fname.

Referenced by L1TMicroGMTInputProducer().

109  {
110  if (!m_filestream.is_open()) {
111  m_filestream.open(m_fname.c_str());
112  if (!m_filestream.good()) {
113  cms::Exception("FileOpenError") << "Failed to open input file";
114  }
115  }
116 }

◆ produce()

void L1TMicroGMTInputProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 136 of file L1TMicroGMTInputProducer.cc.

References l1t::bmtf, l1t::emtf_neg, l1t::emtf_pos, l1tnanotables_cff::et, f, mps_fire::i, hcalRecHitTable_cff::ieta, iEvent, createfilelist::int, hcalRecHitTable_cff::iphi, m_currEvt, m_currType, m_endOfBx, m_filestream, eostools::move(), amptDefaultParameters_cff::mu, l1t::omtf_neg, l1t::omtf_pos, l1t::MuonCaloSum::setEtaBits(), l1t::MuonCaloSum::setEtBits(), l1t::MuonCaloSum::setIndex(), l1t::MuonCaloSum::setPhiBits(), optionsL1T::skip, AlCaHLTBitMon_QueryRunRegistry::string, and createJobs::tmp.

136  {
137  using namespace edm;
138 
139  std::unique_ptr<RegionalMuonCandBxCollection> barrelMuons(new RegionalMuonCandBxCollection());
140  std::unique_ptr<RegionalMuonCandBxCollection> overlapMuons(new RegionalMuonCandBxCollection());
141  std::unique_ptr<RegionalMuonCandBxCollection> endcapMuons(new RegionalMuonCandBxCollection());
142  std::unique_ptr<MuonCaloSumBxCollection> towerSums(new MuonCaloSumBxCollection());
143 
145  MuonCaloSum tSum;
146  m_endOfBx = false;
147  int caloCounter = 0;
148  std::vector<int> bar{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
149  std::vector<int> ovl_neg{0, 0, 0, 0, 0, 0};
150  std::vector<int> ovl_pos{0, 0, 0, 0, 0, 0};
151  std::vector<int> fwd_neg{0, 0, 0, 0, 0, 0};
152  std::vector<int> fwd_pos{0, 0, 0, 0, 0, 0};
153  while (!m_endOfBx && !m_filestream.eof()) {
154  std::string lineID;
155  m_filestream >> lineID;
156  std::string restOfLine;
157 
158  if (lineID == "BAR" || lineID == "OVL-" || lineID == "FWD-" || lineID == "OVL+" || lineID == "FWD+") {
159  int tmp;
160  m_filestream >> tmp; // cable no
161  // if (lineID == "BAR") tmp += 12;
162  // if (lineID == "OVL-") tmp = (tmp-6)+24;
163  // if (lineID == "OVL+") tmp = tmp + 6;
164  // if (lineID == "FWD-") tmp = (tmp-6)+30;
165 
166  // mu.setLink(tmp);
167  m_filestream >> tmp;
168  mu.setHwPt(tmp);
169 
170  m_filestream >> tmp;
171 
172  int globalPhi = int(tmp * 0.560856864654333f); // correction from txt file producer!
173  int globalWedgePhi = (globalPhi + 24) % 576; // this sets CMS phi = 0 to -15 deg
174  int globalSectorPhi = (globalPhi - 24); // this sets CMS phi = 0 to +15 deg
175  if (globalSectorPhi < 0) {
176  globalSectorPhi += 576;
177  }
178 
179  // int globalMuonPhi = int(tmp*0.560856864654333f); // make sure scale is correct
180  bool skip = false;
181  if (lineID == "BAR") {
182  int processor = globalWedgePhi / 48 + 1;
183  int localPhi = globalWedgePhi % 48;
184  mu.setTFIdentifiers(processor, tftype::bmtf);
185  mu.setHwPhi(localPhi);
186  bar[processor - 1]++;
187  if (bar[processor - 1] > 3)
188  skip = true;
189  }
190  if (lineID == "OVL-") {
191  int processor = globalSectorPhi / 96 + 1;
192  int localPhi = globalSectorPhi % 96;
193  mu.setTFIdentifiers(processor, tftype::omtf_neg);
194  mu.setHwPhi(localPhi);
195  ovl_neg[processor - 1]++;
196  if (ovl_neg[processor - 1] > 3)
197  skip = true;
198  }
199  if (lineID == "OVL+") {
200  int processor = globalSectorPhi / 96 + 1;
201  int localPhi = globalSectorPhi % 96;
202  mu.setTFIdentifiers(processor, tftype::omtf_pos);
203  mu.setHwPhi(localPhi);
204  ovl_pos[processor - 1]++;
205  if (ovl_pos[processor - 1] > 3)
206  skip = true;
207  }
208  if (lineID == "FWD-") {
209  int processor = globalSectorPhi / 96 + 1;
210  int localPhi = globalSectorPhi % 96;
211  mu.setTFIdentifiers(processor, tftype::emtf_neg);
212  mu.setHwPhi(localPhi);
213  fwd_neg[processor - 1]++;
214  if (fwd_neg[processor - 1] > 3)
215  skip = true;
216  }
217  if (lineID == "FWD+") {
218  int processor = globalSectorPhi / 96 + 1;
219  int localPhi = globalSectorPhi % 96;
220  mu.setTFIdentifiers(processor, tftype::emtf_pos);
221  mu.setHwPhi(localPhi);
222  fwd_pos[processor - 1]++;
223  if (fwd_pos[processor - 1] > 3)
224  skip = true;
225  }
226 
227  m_filestream >> tmp;
228  tmp = int(tmp * 0.9090909090f);
229  mu.setHwEta(tmp);
230 
231  m_filestream >> tmp;
232  mu.setHwSign(tmp);
233 
234  m_filestream >> tmp;
235  mu.setHwSignValid(tmp);
236 
237  m_filestream >> tmp;
238  mu.setHwQual(tmp);
239 
240  if (lineID == "BAR")
241  m_currType = 0;
242  if (lineID == "OVL-")
243  m_currType = 1;
244  if (lineID == "OVL+")
245  m_currType = 2;
246  if (lineID == "FWD-")
247  m_currType = 3;
248  if (lineID == "FWD+")
249  m_currType = 4;
250 
251  if (m_currType == 0 && !skip)
252  barrelMuons->push_back(0, mu);
253  if ((m_currType == 1 || m_currType == 2) && !skip)
254  overlapMuons->push_back(0, mu);
255  if ((m_currType == 3 || m_currType == 4) && !skip)
256  endcapMuons->push_back(0, mu);
257  }
258 
259  if (lineID == "EVT" && m_currEvt != 0) {
260  m_endOfBx = true;
261  } else if (lineID == "EVT") {
262  m_currEvt++;
263  }
264 
265  if (lineID == "CALO") {
266  for (int i = 0; i < 28; ++i) {
267  int ieta = i; //caloCounter%28;
268  int iphi = caloCounter;
269  int et;
270 
271  m_filestream >> et;
272  tSum.setEtBits(et);
273  tSum.setEtaBits(ieta);
274  tSum.setPhiBits(iphi);
275  tSum.setIndex(caloCounter * 28 + i);
276  towerSums->push_back(0, tSum);
277  }
278  caloCounter++;
279  }
280  getline(m_filestream, restOfLine);
281  //std::cout << restOfLine;
282  }
283 
284  // std::sort(barrelMuons->begin(0), barrelMuons->end(0), L1TMicroGMTInputProducer::cmpProc);
285  // std::sort(overlapMuons->begin(0), overlapMuons->end(0), L1TMicroGMTInputProducer::cmpProc);
286  // std::sort(endcapMuons->begin(0), endcapMuons->end(0), L1TMicroGMTInputProducer::cmpProc);
287 
288  iEvent.put(std::move(barrelMuons), "BarrelTFMuons");
289  iEvent.put(std::move(overlapMuons), "OverlapTFMuons");
290  iEvent.put(std::move(endcapMuons), "ForwardTFMuons");
291  iEvent.put(std::move(towerSums), "TriggerTowerSums");
292  m_currEvt++;
293 }
void setEtaBits(int bits)
Definition: MuonCaloSum.h:17
BXVector< RegionalMuonCand > RegionalMuonCandBxCollection
BXVector< MuonCaloSum > MuonCaloSumBxCollection
Definition: MuonCaloSumFwd.h:7
void setIndex(int idx)
Definition: MuonCaloSum.h:18
int iEvent
Definition: GenABIO.cc:224
double f[11][100]
void setPhiBits(int bits)
Definition: MuonCaloSum.h:16
void setEtBits(int bits)
Definition: MuonCaloSum.h:15
HLT enums.
tmp
align.sh
Definition: createJobs.py:716
def move(src, dest)
Definition: eostools.py:511

◆ skipHeader()

void L1TMicroGMTInputProducer::skipHeader ( )
private

Definition at line 118 of file L1TMicroGMTInputProducer.cc.

References m_filestream, AlCaHLTBitMon_QueryRunRegistry::string, and createJobs::tmp.

Referenced by L1TMicroGMTInputProducer().

118  {
119  while (m_filestream.peek() == '#') {
121  getline(m_filestream, tmp);
122  }
123 }
tmp
align.sh
Definition: createJobs.py:716

Member Data Documentation

◆ m_currEvt

int L1TMicroGMTInputProducer::m_currEvt
private

Definition at line 67 of file L1TMicroGMTInputProducer.cc.

Referenced by produce().

◆ m_currType

int L1TMicroGMTInputProducer::m_currType
private

Definition at line 66 of file L1TMicroGMTInputProducer.cc.

Referenced by produce().

◆ m_endOfBx

bool L1TMicroGMTInputProducer::m_endOfBx
private

Definition at line 64 of file L1TMicroGMTInputProducer.cc.

Referenced by produce().

◆ m_filestream

std::ifstream L1TMicroGMTInputProducer::m_filestream
private

◆ m_fname

std::string L1TMicroGMTInputProducer::m_fname
private

Definition at line 62 of file L1TMicroGMTInputProducer.cc.

Referenced by L1TMicroGMTInputProducer(), and openFile().

◆ m_lastMuInBx

bool L1TMicroGMTInputProducer::m_lastMuInBx
private

Definition at line 65 of file L1TMicroGMTInputProducer.cc.