CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1GtPackUnpackAnalyzer.cc
Go to the documentation of this file.
1 
17 // this class header
19 
20 // system include files
21 #include <memory>
22 
23 // user include files
25 
28 
30 
31 
32 
33 // constructor(s)
35 {
36 
37  // input tag for the initial GT DAQ record:
38  m_initialDaqGtInputTag = parSet.getParameter<edm::InputTag>("InitialDaqGtInputTag");
39 
40  // input tag for the initial GMT readout collection:
41  m_initialMuGmtInputTag = parSet.getParameter<edm::InputTag>("InitialMuGmtInputTag");
42 
43  // input tag for the final GT DAQ and GMT records:
44  m_finalGtGmtInputTag = parSet.getParameter<edm::InputTag>("FinalGtGmtInputTag");
45 
46 
47  edm::LogInfo("L1GtPackUnpackAnalyzer")
48  << "\nInput tag for the initial GT DAQ record: "
49  << m_initialDaqGtInputTag << " \n"
50  << "\nInput tag for the initial GMT readout collection: "
51  << m_initialMuGmtInputTag << " \n"
52  << "\nInput tag for the final GT DAQ and GMT records: "
53  << m_finalGtGmtInputTag << " \n"
54  << std::endl;
55 
56 }
57 
58 // destructor
60 {
61  // empty
62 }
63 
64 // member functions
65 
66 // method called once each job just before starting event loop
68 {
69  // empty
70 }
71 
72 
73 // GT comparison
75 {
76 
77  // define an output stream to print into
78  // it can then be directed to whatever log level is desired
79  std::ostringstream myCoutStream;
80 
81  // get the initial L1GlobalTriggerReadoutRecord
82  edm::Handle<L1GlobalTriggerReadoutRecord> gtReadoutRecordInitial;
83  iEvent.getByLabel(m_initialDaqGtInputTag, gtReadoutRecordInitial);
84 
85  if (!gtReadoutRecordInitial.isValid()) {
86  edm::LogError("L1GtTrigReport")
87  << "Initial L1GlobalTriggerReadoutRecord with input tag \n "
88  << m_initialDaqGtInputTag << " not found.\n\n"
89  << std::endl;
90  return;
91 
92  }
93 
94  // get the final L1GlobalTriggerReadoutRecord
95  edm::Handle<L1GlobalTriggerReadoutRecord> gtReadoutRecordFinal;
96  iEvent.getByLabel(m_finalGtGmtInputTag, gtReadoutRecordFinal);
97 
98  if (!gtReadoutRecordFinal.isValid()) {
99  edm::LogError("L1GtTrigReport")
100  << "Final L1GlobalTriggerReadoutRecord with input tag \n "
101  << m_finalGtGmtInputTag << " not found.\n\n"
102  << std::endl;
103  return;
104 
105  }
106 
107  // compare GTFE
108  const L1GtfeWord& gtfeWordInitial = gtReadoutRecordInitial->gtfeWord();
109  const L1GtfeWord& gtfeWordFinal = gtReadoutRecordFinal->gtfeWord();
110 
111  if (gtfeWordInitial == gtfeWordFinal) {
112  myCoutStream << "\nInitial and final GTFE blocks: identical.\n";
113  gtfeWordInitial.print(myCoutStream);
114  } else {
115  myCoutStream << "\nInitial and final GTFE blocks: different.\n";
116 
117  myCoutStream << "\nInitial GTFE block\n";
118  gtfeWordInitial.print(myCoutStream);
119 
120  myCoutStream << "\nFinal GTFE block\n";
121  gtfeWordFinal.print(myCoutStream);
122 
123  }
124 
125  edm::LogInfo("L1GtPackUnpackAnalyzer")
126  << myCoutStream.str()
127  << std::endl;
128 
129 
130  myCoutStream.str("");
131  myCoutStream.clear();
132 
133  // FDL comparison
134  const std::vector<L1GtFdlWord>& gtFdlVectorInitial = gtReadoutRecordInitial->gtFdlVector();
135  const std::vector<L1GtFdlWord>& gtFdlVectorFinal = gtReadoutRecordFinal->gtFdlVector();
136 
137  int gtFdlVectorInitialSize = gtFdlVectorInitial.size();
138  int gtFdlVectorFinalSize = gtFdlVectorFinal.size();
139 
140  if (gtFdlVectorInitialSize == gtFdlVectorFinalSize) {
141  myCoutStream << "\nInitial and final FDL vector size: identical.\n";
142  myCoutStream << " Size: " << gtFdlVectorInitialSize << std::endl;
143 
144  for (int iFdl = 0; iFdl < gtFdlVectorInitialSize; ++iFdl) {
145 
146  const L1GtFdlWord& fdlWordInitial = gtFdlVectorInitial[iFdl];
147  const L1GtFdlWord& fdlWordFinal = gtFdlVectorFinal[iFdl];
148 
149  if (fdlWordInitial == fdlWordFinal) {
150  myCoutStream << "\nInitial and final FDL blocks: identical.\n";
151  fdlWordInitial.print(myCoutStream);
152 
153  } else {
154  myCoutStream << "\nInitial and final FDL blocks: different.\n";
155 
156  myCoutStream << "\nInitial FDL block\n";
157  fdlWordInitial.print(myCoutStream);
158 
159  myCoutStream << "\nFinal FDL block\n";
160  fdlWordFinal.print(myCoutStream);
161 
162  }
163 
164  }
165  }
166  else {
167  myCoutStream << "\nInitial and final FDL vector size: different.\n";
168  myCoutStream << " Initial size: " << gtFdlVectorInitialSize << std::endl;
169  myCoutStream << " Final size: " << gtFdlVectorFinalSize << std::endl;
170 
171  }
172 
173  edm::LogInfo("L1GtPackUnpackAnalyzer") << myCoutStream.str() << std::endl;
174 
175  myCoutStream.str("");
176  myCoutStream.clear();
177 
178 
179  // PSB comparison
180  const std::vector<L1GtPsbWord>& gtPsbVectorInitial = gtReadoutRecordInitial->gtPsbVector();
181  const std::vector<L1GtPsbWord>& gtPsbVectorFinal = gtReadoutRecordFinal->gtPsbVector();
182 
183  int gtPsbVectorInitialSize = gtPsbVectorInitial.size();
184  int gtPsbVectorFinalSize = gtPsbVectorFinal.size();
185 
186  if (gtPsbVectorInitialSize == gtPsbVectorFinalSize) {
187  myCoutStream << "\nInitial and final PSB vector size: identical.\n";
188  myCoutStream << " Size: " << gtPsbVectorInitialSize << std::endl;
189 
190  // the order of PSB block in the gtPsbVector is different in emulator and unpacker
191  // TODO can be fixed?
192  for (int iPsb = 0; iPsb < gtPsbVectorInitialSize; ++iPsb) {
193 
194  const L1GtPsbWord& psbWordInitial = gtPsbVectorInitial[iPsb];
195  const boost::uint16_t boardIdInitial = psbWordInitial.boardId();
196  const int bxInEventInitial = psbWordInitial.bxInEvent();
197 
198  // search the corresponding PSB in the final record using the
199  // BoardId and the BxInEvent
200 
201  bool foundPSB = false;
202 
203  for (int iPsbF = 0; iPsbF < gtPsbVectorFinalSize; ++iPsbF) {
204 
205  const L1GtPsbWord& psbWordFinal = gtPsbVectorFinal[iPsbF];
206  const boost::uint16_t boardIdFinal = psbWordFinal.boardId();
207  const int bxInEventFinal = psbWordFinal.bxInEvent();
208 
209  if ((boardIdFinal == boardIdInitial) && (bxInEventInitial
210  == bxInEventFinal)) {
211 
212  foundPSB = true;
213 
214  // compare the boards
215  if (psbWordInitial == psbWordFinal) {
216  myCoutStream
217  << "\nInitial and final PSB blocks: identical.\n";
218  psbWordInitial.print(myCoutStream);
219 
220  }
221  else {
222  myCoutStream
223  << "\nInitial and final PSB blocks: different.\n";
224 
225  myCoutStream << "\nInitial PSB block\n";
226  psbWordInitial.print(myCoutStream);
227 
228  myCoutStream << "\nFinal PSB block\n";
229  psbWordFinal.print(myCoutStream);
230 
231  }
232  }
233 
234  }
235 
236  if (!foundPSB) {
237  myCoutStream
238  << "\nNo final PSB with boardID = " << boardIdInitial
239  << " and BxINEvent = " << bxInEventInitial << " was found"
240  << "\nInitial and final PSB vectors: different";
241 
242  }
243 
244  }
245  }
246  else {
247  myCoutStream << "\nInitial and final PSB vector size: different.\n";
248  myCoutStream << " Initial size: " << gtPsbVectorInitialSize << std::endl;
249  myCoutStream << " Final size: " << gtPsbVectorFinalSize << std::endl;
250 
251  }
252 
253  edm::LogInfo("L1GtPackUnpackAnalyzer") << myCoutStream.str() << std::endl;
254 
255  myCoutStream.str("");
256  myCoutStream.clear();
257 
258 
259 
260 
261 
262  // get reference to muon collection
263  const edm::RefProd<L1MuGMTReadoutCollection> muCollRefProdInitial =
264  gtReadoutRecordInitial->muCollectionRefProd();
265 
266  const edm::RefProd<L1MuGMTReadoutCollection> muCollRefProdFinal =
267  gtReadoutRecordFinal->muCollectionRefProd();
268 
269  if (muCollRefProdInitial == muCollRefProdFinal) {
270  myCoutStream
271  << "\nInitial and final RefProd<L1MuGMTReadoutCollection>: identical.\n";
272  }
273  else {
274  myCoutStream
275  << "\nInitial and final RefProd<L1MuGMTReadoutCollection>: different.\n";
276 
277  }
278 
279  edm::LogInfo("L1GtPackUnpackAnalyzer")
280  << myCoutStream.str()
281  << std::endl;
282 
283  myCoutStream.str("");
284  myCoutStream.clear();
285 
286 
287 }
288 
289 // GMT comparison
291  const edm::EventSetup& evSetup) {
292 
293  // define an output stream to print into
294  // it can then be directed to whatever log level is desired
295  std::ostringstream myCoutStream;
296 
297  // get initial L1MuGMTReadoutCollection
299  iEvent.getByLabel(m_initialMuGmtInputTag, gmtRcInitial);
300 
301  if (!gmtRcInitial.isValid()) {
302  edm::LogError("L1GtPackUnpackAnalyzer")
303  << "Initial L1MuGMTReadoutCollection with input tag \n "
304  << m_initialMuGmtInputTag << " not found.\n\n"
305  << std::endl;
306  return;
307 
308  }
309 
310  std::vector<L1MuGMTReadoutRecord> muRecordsInitial = gmtRcInitial->getRecords();
311 
312  // get final L1MuGMTReadoutCollection
314  iEvent.getByLabel(m_finalGtGmtInputTag, gmtRcFinal);
315 
316  if (!gmtRcFinal.isValid()) {
317  edm::LogError("L1GtPackUnpackAnalyzer")
318  << "Final L1MuGMTReadoutCollection with input tag \n "
319  << m_finalGtGmtInputTag << " not found.\n\n"
320  << std::endl;
321  return;
322 
323  }
324 
325  std::vector<L1MuGMTReadoutRecord> muRecordsFinal = gmtRcFinal->getRecords();
326 
327  int muRecordsInitialSize = muRecordsInitial.size();
328  int muRecordsFinalSize = muRecordsFinal.size();
329 
330  if (muRecordsInitialSize == muRecordsFinalSize) {
331  myCoutStream
332  << "\nInitial and final L1MuGMTReadoutCollection record size: identical.\n";
333  myCoutStream << " Size: " << muRecordsInitialSize << std::endl;
334  }
335  else {
336  myCoutStream
337  << "\nInitial and final L1MuGMTReadoutCollection record size: different.\n";
338  myCoutStream << " Initial size: " << muRecordsInitialSize << std::endl;
339  myCoutStream << " Final size: " << muRecordsFinalSize << std::endl;
340 
341  }
342 
343  edm::LogInfo("L1GtPackUnpackAnalyzer") << myCoutStream.str() << std::endl;
344 
345  myCoutStream.str("");
346  myCoutStream.clear();
347 
348 }
349 
350 // analyze each event: event loop
352 {
353 
354  // GT DAQ comparison
355  analyzeGT(iEvent, evSetup);
356 
357  // GMT comparison
358  analyzeGMT(iEvent, evSetup);
359 
360 }
361 
362 
363 // method called once each job just after ending the event loop
365 {
366 
367  // empty
368 
369 }
370 
T getParameter(std::string const &) const
const cms_uint16_t boardId() const
get/set board ID
Definition: L1GtPsbWord.h:68
virtual void print(std::ostream &myCout) const
pretty print the content of a L1GtfeWord
Definition: L1GtfeWord.cc:323
L1GtPackUnpackAnalyzer(const edm::ParameterSet &)
virtual void analyzeGMT(const edm::Event &, const edm::EventSetup &)
GMT comparison.
edm::InputTag m_initialMuGmtInputTag
input tag for the initial GMT readout collection:
int iEvent
Definition: GenABIO.cc:243
virtual void analyze(const edm::Event &, const edm::EventSetup &)
analyze each event
virtual void endJob()
end of job
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
void print(std::ostream &myCout) const
pretty print the content of a L1GtFdlWord
Definition: L1GtFdlWord.cc:768
void print(std::ostream &myCout) const
pretty print
Definition: L1GtPsbWord.cc:455
const int bxInEvent() const
get/set bunch cross in the GT event record
Definition: L1GtPsbWord.h:89
virtual void analyzeGT(const edm::Event &, const edm::EventSetup &)
GT comparison.
edm::InputTag m_initialDaqGtInputTag
input tag for the initial GT DAQ record:
edm::InputTag m_finalGtGmtInputTag
input tag for the final GT DAQ and GMT records: