CMS 3D CMS Logo

L1MuGMTHWFileReader.cc
Go to the documentation of this file.
1 //-------------------------------------------------
2 //
3 // \class L1MuGMTHWFileReader
4 //
5 // Description: Puts the GMT input information from
6 // a GMT ascii HW testfile into the Event
7 //
8 //
9 //
10 // Author :
11 // Tobias Noebauer HEPHY Vienna
12 // Ivan Mikulec HEPHY Vienna
13 //
14 //--------------------------------------------------
15 
16 //-----------------------
17 // This Class's Header --
18 //-----------------------
20 
21 //---------------
22 // C++ Headers --
23 //---------------
24 #include <stdexcept>
25 
26 //-------------------------------
27 // Collaborating Class Headers --
28 //-------------------------------
31 
33 
34 //----------------
35 // Constructors --
36 //----------------
38  : ProducerSourceFromFiles(ps, desc, true) {
39  produces<std::vector<L1MuRegionalCand> >("DT");
40  produces<std::vector<L1MuRegionalCand> >("CSC");
41  produces<std::vector<L1MuRegionalCand> >("RPCb");
42  produces<std::vector<L1MuRegionalCand> >("RPCf");
43 
44  produces<L1CaloRegionCollection>();
45 
46  if (fileNames(0).empty()) {
47  throw std::runtime_error("L1MuGMTHWFileReader: no input file");
48  }
49  edm::LogInfo("GMT_HWFileReader_info") << "opening file " << fileNames(0)[0];
50  m_in.open((fileNames(0)[0].substr(fileNames(0)[0].find(':') + 1)).c_str());
51  if (!m_in) {
52  throw std::runtime_error("L1MuGMTHWFileReader: file " + fileNames(0)[0] + " could not be openned");
53  }
54 }
55 
56 //--------------
57 // Destructor --
58 //--------------
60 
61 //--------------
62 // Operations --
63 //--------------
67  readNextEvent();
69  return false;
70  id = edm::EventID(m_evt.getRunNumber(), id.luminosityBlock(), m_evt.getEventNumber());
71 
72  edm::LogInfo("GMT_HWFileReader_info") << "run: " << m_evt.getRunNumber() << " evt: " << m_evt.getEventNumber();
73  return true;
74 }
75 
77  L1MuRegionalCand empty_mu;
78 
79  std::unique_ptr<std::vector<L1MuRegionalCand> > DTCands(new std::vector<L1MuRegionalCand>);
80  for (unsigned i = 0; i < 4; i++) {
81  const L1MuRegionalCand* mu = m_evt.getInputMuon("IND", i);
82  if (!mu)
83  mu = &empty_mu;
84  DTCands->push_back(*mu);
85  }
86  e.put(std::move(DTCands), "DT");
87 
88  std::unique_ptr<std::vector<L1MuRegionalCand> > CSCCands(new std::vector<L1MuRegionalCand>);
89  for (unsigned i = 0; i < 4; i++) {
90  const L1MuRegionalCand* mu = m_evt.getInputMuon("INC", i);
91  if (!mu)
92  mu = &empty_mu;
93  CSCCands->push_back(*mu);
94  }
95  e.put(std::move(CSCCands), "CSC");
96 
97  std::unique_ptr<std::vector<L1MuRegionalCand> > RPCbCands(new std::vector<L1MuRegionalCand>);
98  for (unsigned i = 0; i < 4; i++) {
99  const L1MuRegionalCand* mu = m_evt.getInputMuon("INB", i);
100  if (!mu)
101  mu = &empty_mu;
102  RPCbCands->push_back(*mu);
103  }
104  e.put(std::move(RPCbCands), "RPCb");
105 
106  std::unique_ptr<std::vector<L1MuRegionalCand> > RPCfCands(new std::vector<L1MuRegionalCand>);
107  for (unsigned i = 0; i < 4; i++) {
108  const L1MuRegionalCand* mu = m_evt.getInputMuon("INF", i);
109  if (!mu)
110  mu = &empty_mu;
111  RPCfCands->push_back(*mu);
112  }
113  e.put(std::move(RPCfCands), "RPCf");
114 
115  std::unique_ptr<L1CaloRegionCollection> rctRegions(new L1CaloRegionCollection);
116  for (int ieta = 4; ieta < 18; ieta++) {
117  for (int iphi = 0; iphi < 18; iphi++) {
118  rctRegions->push_back(
119  L1CaloRegion(0, false, true, m_evt.getMipBit(ieta - 4, iphi), m_evt.getIsoBit(ieta - 4, iphi), ieta, iphi));
120  }
121  }
122 
123  e.put(std::move(rctRegions));
124 }
125 
127  m_evt.reset();
128 
129  std::string line_id;
130  do {
131  int bx = 0;
132 
133  m_in >> line_id;
134  if (line_id == "--")
135  continue;
136 
137  if (line_id == "RUN") {
138  unsigned long runnr;
139  m_in >> runnr;
141  }
142 
143  if (line_id == "EVT") {
144  unsigned long evtnr;
145  m_in >> evtnr;
146  m_evt.setEventNumber(evtnr);
147  }
148 
149  if (line_id == "DT" || line_id == "CSC" || line_id == "BRPC" || line_id == "FRPC") {
150  // decode input muon
151 
152  unsigned inpmu = 0;
153  unsigned val;
154  m_in >> val;
155  inpmu |= (val & 0x01) << 24; // valid charge
156  m_in >> val;
157  inpmu |= (val & 0x01) << 23; // charge
158  m_in >> val;
159  inpmu |= (val & 0x01) << 22; // halo / fine
160  m_in >> val;
161  inpmu |= (val & 0x3f) << 16; // eta
162  m_in >> val;
163  inpmu |= (val & 0x07) << 13; // quality
164  m_in >> val;
165  inpmu |= (val & 0x1f) << 8; // pt
166  m_in >> val;
167  inpmu |= (val & 0xff); // phi
168 
169  std::string chipid("IN");
170  chipid += line_id[0];
171 
172  int type = 0;
173  if (line_id == "DT")
174  type = 0;
175  if (line_id == "CSC")
176  type = 2;
177  if (line_id == "BRPC")
178  type = 1;
179  if (line_id == "FRPC")
180  type = 3;
181 
182  L1MuRegionalCand cand(inpmu);
183  cand.setType(type);
184  cand.setBx(bx);
185  m_evt.addInputMuon(chipid, cand);
186  }
187 
188  if (line_id == "MIP") {
189  int nPairs;
190  m_in >> nPairs;
191  for (int i = 0; i < nPairs; i++) {
192  unsigned eta;
193  unsigned phi;
194  m_in >> eta;
195  m_in >> phi;
196  if (phi >= 9)
197  phi -= 9;
198  else
199  phi += 9;
200  m_evt.setMipBit(eta, phi, true);
201  }
202  }
203 
204  if (line_id == "NQ") {
205  int nPairs;
206  m_in >> nPairs;
207  for (int i = 0; i < nPairs; i++) {
208  unsigned eta;
209  unsigned phi;
210  m_in >> eta;
211  m_in >> phi;
212  if (phi >= 9)
213  phi -= 9;
214  else
215  phi += 9;
216  m_evt.setIsoBit(eta, phi, false);
217  }
218  }
219 
220  //read the rest of the line
221  const int sz = 4000;
222  char buf[sz];
223  m_in.getline(buf, sz);
224 
225  } while (line_id != "NQ" && !m_in.eof());
226 }
L1MuGMTInputEvent::setEventNumber
void setEventNumber(unsigned long eventnr)
Definition: L1MuGMTInputEvent.h:56
L1MuGMTHWFileReader::setRunAndEventInfo
bool setRunAndEventInfo(edm::EventID &id, edm::TimeValue_t &time, edm::EventAuxiliary::ExperimentType &eType) override
Definition: L1MuGMTHWFileReader.cc:64
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
L1CaloRegion
A calorimeter trigger region (sum of 4x4 trigger towers)
Definition: L1CaloRegion.h:21
L1MuGMTInputEvent::setMipBit
void setMipBit(unsigned etaIndex, unsigned phiIndex, bool val)
Definition: L1MuGMTInputEvent.h:61
amptDefaultParameters_cff.mu
mu
Definition: amptDefaultParameters_cff.py:16
l1GtPatternGenerator_cfi.bx
bx
Definition: l1GtPatternGenerator_cfi.py:18
edm::InputSourceDescription
Definition: InputSourceDescription.h:20
protons_cff.time
time
Definition: protons_cff.py:39
L1MuGMTInputEvent::getInputMuon
const L1MuRegionalCand * getInputMuon(std::string chipid, unsigned index) const
Definition: L1MuGMTInputEvent.cc:86
fileCollector.runnr
runnr
Definition: fileCollector.py:87
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
L1MuRegionalCand.h
L1MuGMTHWFileReader::produce
void produce(edm::Event &) override
Definition: L1MuGMTHWFileReader.cc:76
LEDCalibrationChannels.iphi
iphi
Definition: LEDCalibrationChannels.py:64
L1MuGMTHWFileReader::L1MuGMTHWFileReader
L1MuGMTHWFileReader(edm::ParameterSet const &, edm::InputSourceDescription const &)
Definition: L1MuGMTHWFileReader.cc:37
L1MuGMTInputEvent::setRunNumber
void setRunNumber(unsigned long runnr)
Definition: L1MuGMTInputEvent.h:54
PVValHelper::eta
Definition: PVValidationHelpers.h:70
L1MuGMTInputEvent::addInputMuon
void addInputMuon(std::string chipid, const L1MuRegionalCand &inMu)
Definition: L1MuGMTInputEvent.cc:67
L1MuRegionalCand
Definition: L1MuRegionalCand.h:26
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
funct::true
true
Definition: Factorize.h:173
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
edm::ParameterSet
Definition: ParameterSet.h:47
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
L1MuGMTInputEvent::getEventNumber
unsigned long getEventNumber() const
get the Event number
Definition: L1MuGMTInputEvent.h:70
cand
Definition: decayParser.h:32
L1CaloCollections.h
edm::FromFiles::fileNames
std::vector< std::string > fileNames(unsigned iCatalog) const
Definition: FromFiles.h:22
L1MuGMTHWFileReader::m_evt
L1MuGMTInputEvent m_evt
Definition: L1MuGMTHWFileReader.h:56
L1MuGMTHWFileReader.h
visDQMUpload.buf
buf
Definition: visDQMUpload.py:154
L1MuGMTHWFileReader::readNextEvent
void readNextEvent()
Definition: L1MuGMTHWFileReader.cc:126
DDAxes::phi
L1MuGMTHWFileReader::m_in
std::ifstream m_in
Definition: L1MuGMTHWFileReader.h:55
L1MuGMTInputEvent::reset
void reset()
Definition: L1MuGMTInputEvent.cc:73
gpuPixelDoublets::nPairs
constexpr int nPairs
Definition: gpuPixelDoublets.h:12
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
heppy_batch.val
val
Definition: heppy_batch.py:351
eostools.move
def move(src, dest)
Definition: eostools.py:511
L1CaloRegionCollection
std::vector< L1CaloRegion > L1CaloRegionCollection
Definition: L1CaloCollections.h:11
L1MuGMTInputEvent::getIsoBit
const bool & getIsoBit(unsigned etaIndex, unsigned phiIndex)
Definition: L1MuGMTInputEvent.h:87
L1MuGMTInputEvent::getMipBit
const bool & getMipBit(unsigned etaIndex, unsigned phiIndex)
Definition: L1MuGMTInputEvent.h:86
L1MuGMTInputEvent::setIsoBit
void setIsoBit(unsigned etaIndex, unsigned phiIndex, bool val)
Definition: L1MuGMTInputEvent.h:64
edm::EventAuxiliary::ExperimentType
ExperimentType
Definition: EventAuxiliary.h:18
relativeConstraints.empty
bool empty
Definition: relativeConstraints.py:46
L1MuGMTInputEvent::getRunNumber
unsigned long getRunNumber() const
get the Run number
Definition: L1MuGMTInputEvent.h:67
L1MuGMTHWFileReader::~L1MuGMTHWFileReader
~L1MuGMTHWFileReader() override
Definition: L1MuGMTHWFileReader.cc:59
edm::EventID
Definition: EventID.h:31
edm::Event
Definition: Event.h:73
edm::TimeValue_t
unsigned long long TimeValue_t
Definition: Timestamp.h:28
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37