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 hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () 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 46 of file L1TMicroGMTInputProducer.cc.

Constructor & Destructor Documentation

◆ L1TMicroGMTInputProducer()

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

Definition at line 86 of file L1TMicroGMTInputProducer.cc.

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 }

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

◆ ~L1TMicroGMTInputProducer()

L1TMicroGMTInputProducer::~L1TMicroGMTInputProducer ( )
override

Definition at line 101 of file L1TMicroGMTInputProducer.cc.

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 }

References m_filestream.

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.

110  {
111  return mu1.processor() < mu2.processor();
112 }

References l1t::RegionalMuonCand::processor().

◆ convertToInt()

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

Definition at line 130 of file L1TMicroGMTInputProducer.cc.

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 }

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

◆ 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.

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 }

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

◆ openFile()

void L1TMicroGMTInputProducer::openFile ( )
private

Definition at line 114 of file L1TMicroGMTInputProducer.cc.

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 }

References Exception, m_filestream, and m_fname.

Referenced by L1TMicroGMTInputProducer().

◆ produce()

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

Definition at line 141 of file L1TMicroGMTInputProducer.cc.

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 }

References l1t::bmtf, l1t::emtf_neg, l1t::emtf_pos, EgHLTOffHistBins_cfi::et, f, mps_fire::i, LEDCalibrationChannels::ieta, iEvent, createfilelist::int, LEDCalibrationChannels::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.

◆ skipHeader()

void L1TMicroGMTInputProducer::skipHeader ( )
private

Definition at line 123 of file L1TMicroGMTInputProducer.cc.

123  {
124  while (m_filestream.peek() == '#') {
126  getline(m_filestream, tmp);
127  }
128 }

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

Referenced by L1TMicroGMTInputProducer().

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.

l1t::bmtf
Definition: RegionalMuonCandFwd.h:8
l1t::emtf_neg
Definition: RegionalMuonCandFwd.h:8
l1t::RegionalMuonCand::processor
const int processor() const
Get processor ID on which the candidate was found (0..5 for OMTF/EMTF; 0..11 for BMTF)
Definition: RegionalMuonCand.h:179
mps_fire.i
i
Definition: mps_fire.py:355
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
l1t::omtf_pos
Definition: RegionalMuonCandFwd.h:8
amptDefaultParameters_cff.mu
mu
Definition: amptDefaultParameters_cff.py:16
L1TMicroGMTInputProducer::openFile
void openFile()
Definition: L1TMicroGMTInputProducer.cc:114
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
l1t::MuonCaloSum::setPhiBits
void setPhiBits(int bits)
Definition: MuonCaloSum.h:16
l1t::MuonCaloSum::setEtaBits
void setEtaBits(int bits)
Definition: MuonCaloSum.h:17
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
LEDCalibrationChannels.iphi
iphi
Definition: LEDCalibrationChannels.py:64
optionsL1T.skip
skip
Definition: optionsL1T.py:30
l1t::MuonCaloSum::setEtBits
void setEtBits(int bits)
Definition: MuonCaloSum.h:15
L1TMicroGMTInputProducer::m_endOfBx
bool m_endOfBx
Definition: L1TMicroGMTInputProducer.cc:69
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
L1TMicroGMTInputProducer::m_fname
std::string m_fname
Definition: L1TMicroGMTInputProducer.cc:67
L1TMicroGMTInputProducer::m_currEvt
int m_currEvt
Definition: L1TMicroGMTInputProducer.cc:72
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::ParameterSetDescription::setUnknown
void setUnknown()
Definition: ParameterSetDescription.cc:39
l1t::RegionalMuonCandBxCollection
BXVector< RegionalMuonCand > RegionalMuonCandBxCollection
Definition: RegionalMuonCandFwd.h:9
EgHLTOffHistBins_cfi.et
et
Definition: EgHLTOffHistBins_cfi.py:8
l1t::MuonCaloSumBxCollection
BXVector< MuonCaloSum > MuonCaloSumBxCollection
Definition: MuonCaloSumFwd.h:7
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
EgammaValidation_cff.num
num
Definition: EgammaValidation_cff.py:34
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
eostools.move
def move(src, dest)
Definition: eostools.py:511
l1t::emtf_pos
Definition: RegionalMuonCandFwd.h:8
l1t::MuonCaloSum
Definition: MuonCaloSum.h:7
Exception
Definition: hltDiff.cc:246
MTDTopologyMode::Mode::bar
l1t::MuonCaloSum::setIndex
void setIndex(int idx)
Definition: MuonCaloSum.h:18
L1TMicroGMTInputProducer::m_currType
int m_currType
Definition: L1TMicroGMTInputProducer.cc:71
L1TMicroGMTInputProducer::skipHeader
void skipHeader()
Definition: L1TMicroGMTInputProducer.cc:123
l1t::omtf_neg
Definition: RegionalMuonCandFwd.h:8
edm::ConfigurationDescriptions::addDefault
void addDefault(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:99
L1TMicroGMTInputProducer::m_filestream
std::ifstream m_filestream
Definition: L1TMicroGMTInputProducer.cc:68
l1t::RegionalMuonCand
Definition: RegionalMuonCand.h:8