CMS 3D CMS Logo

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