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

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<>
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 86 of file L1TMicroGMTInputProducer.cc.

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

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

◆ ~L1TMicroGMTInputProducer()

L1TMicroGMTInputProducer::~L1TMicroGMTInputProducer ( )
override

Definition at line 101 of file L1TMicroGMTInputProducer.cc.

References m_filestream.

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

Member Function Documentation

◆ beginLuminosityBlock()

void L1TMicroGMTInputProducer::beginLuminosityBlock ( const edm::LuminosityBlock ,
edm::EventSetup const &   
)
overrideprivate

Definition at line 307 of file L1TMicroGMTInputProducer.cc.

307 {}

◆ beginRun()

void L1TMicroGMTInputProducer::beginRun ( const edm::Run ,
edm::EventSetup const &   
)
overrideprivate

Definition at line 301 of file L1TMicroGMTInputProducer.cc.

301 {}

◆ cmpProc()

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

Definition at line 110 of file L1TMicroGMTInputProducer.cc.

References l1t::RegionalMuonCand::processor().

110  {
111  return mu1.processor() < mu2.processor();
112 }
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 130 of file L1TMicroGMTInputProducer.cc.

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

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

◆ endLuminosityBlock()

void L1TMicroGMTInputProducer::endLuminosityBlock ( const edm::LuminosityBlock ,
edm::EventSetup const &   
)
overrideprivate

Definition at line 310 of file L1TMicroGMTInputProducer.cc.

310 {}

◆ endRun()

void L1TMicroGMTInputProducer::endRun ( const edm::Run ,
edm::EventSetup const &   
)
overrideprivate

Definition at line 304 of file L1TMicroGMTInputProducer.cc.

304 {}

◆ fillDescriptions()

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

Definition at line 313 of file L1TMicroGMTInputProducer.cc.

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

313  {
314  //The following says we do not know what parameters are allowed so do no validation
315  // Please change this to state exactly what you do use, even if it is no parameters
317  desc.setUnknown();
318  descriptions.addDefault(desc);
319 }
void addDefault(ParameterSetDescription const &psetDescription)

◆ openFile()

void L1TMicroGMTInputProducer::openFile ( )
private

Definition at line 114 of file L1TMicroGMTInputProducer.cc.

References Exception, m_filestream, and m_fname.

Referenced by L1TMicroGMTInputProducer().

114  {
115  if (!m_filestream.is_open()) {
116  m_filestream.open(m_fname.c_str());
117  if (!m_filestream.good()) {
118  cms::Exception("FileOpenError") << "Failed to open input file";
119  }
120  }
121 }

◆ produce()

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

Definition at line 141 of file L1TMicroGMTInputProducer.cc.

References l1t::bmtf, l1t::emtf_neg, l1t::emtf_pos, EgHLTOffHistBins_cfi::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.

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

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

Referenced by L1TMicroGMTInputProducer().

123  {
124  while (m_filestream.peek() == '#') {
126  getline(m_filestream, tmp);
127  }
128 }
tmp
align.sh
Definition: createJobs.py:716

Member Data Documentation

◆ m_currEvt

int L1TMicroGMTInputProducer::m_currEvt
private

Definition at line 72 of file L1TMicroGMTInputProducer.cc.

Referenced by produce().

◆ m_currType

int L1TMicroGMTInputProducer::m_currType
private

Definition at line 71 of file L1TMicroGMTInputProducer.cc.

Referenced by produce().

◆ m_endOfBx

bool L1TMicroGMTInputProducer::m_endOfBx
private

Definition at line 69 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 67 of file L1TMicroGMTInputProducer.cc.

Referenced by L1TMicroGMTInputProducer(), and openFile().

◆ m_lastMuInBx

bool L1TMicroGMTInputProducer::m_lastMuInBx
private

Definition at line 70 of file L1TMicroGMTInputProducer.cc.