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