20 #include "GaudiKernel/MsgStream.h"
21 #include "GaudiKernel/StatusCode.h"
64 m_configSvc(
"TrigConf::TrigConfigSvc/TrigConfigSvc",
name),
65 m_errorTool(
"LVL1::TrigT1CaloMonErrorTool/TrigT1CaloMonErrorTool"),
66 m_histTool(
"LVL1::TrigT1CaloLWHistogramTool/TrigT1CaloLWHistogramTool"),
67 m_debug(false), m_histBooked(false),
69 m_h_ctp_1d_L1CaloNeCTPSummary(0),
70 m_h_ctp_1d_L1CaloEqCTPSummary(0),
71 m_h_ctp_1d_TIPMatches(0),
72 m_h_ctp_1d_HitNoTIPMismatch(0),
73 m_h_ctp_1d_TIPNoHitMismatch(0),
74 m_h_ctp_2d_MismatchEvents(0)
112 if (
sc.isFailure())
return sc;
117 if (
sc.isFailure() ) {
118 msg(MSG::ERROR) <<
"Couldn't connect to " <<
m_configSvc.typeAndName()
126 if(
sc.isFailure() ) {
127 msg(MSG::ERROR) <<
"Unable to locate Tool TrigT1CaloMonErrorTool"
133 if(
sc.isFailure() ) {
134 msg(MSG::ERROR) <<
"Unable to locate Tool TrigT1CaloLWHistogramTool"
139 return StatusCode::SUCCESS;
170 "Transmission Errors between L1Calo and CTP",
174 "Transmission Matches between L1Calo and CTP",
181 "L1Calo Hit but no CTP TIP Mismatches;TIP",
m_nTIP, 0.,
m_nTIP);
183 "CTP TIP but no L1Calo Hit Mismatches;TIP",
m_nTIP, 0.,
m_nTIP);
188 "Transmission Errors between L1Calo and CTP Event Numbers",
199 const int l1caloBits =
202 def.max_XE_Threshold_Number() + def.max_TE_Threshold_Number() + def.max_XS_Threshold_Number();
206 <<
" XE: " << def.max_XE_Threshold_Number() <<
" XS: " << def.max_XS_Threshold_Number() <<
endmsg;
210 m_tipMap.assign(l1caloBits, std::make_pair(
" ", -1));
213 std::map<std::string, int> threshMap;
214 const std::vector<TrigConf::TriggerThreshold*>&
215 thresholds(
m_configSvc->ctpConfig()->menu().thresholdVector());
216 std::vector<TrigConf::TriggerThreshold*>::const_iterator
it;
219 for (
it = thresholds.begin();
it != thresholds.end(); ++
it) {
222 const int threshNumber = (*it)->thresholdNumber();
223 int fixedThreshNumber = threshNumber;
226 if ( (*it)->type() == def.emType() ) {
227 if (threshNumber >= (
int)def.max_EM_Threshold_Number()/2) {
228 offset += nbits*def.max_EM_Threshold_Number()/2;
229 fixedThreshNumber -= def.max_EM_Threshold_Number()/2;
233 offset += nbits*def.max_EM_Threshold_Number();
234 if ( (*it)->type() == def.tauType() ) {
235 if (threshNumber >= (
int)def.max_TAU_Threshold_Number()/2) {
236 offset += nbits*def.max_TAU_Threshold_Number()/2;
237 fixedThreshNumber -= def.max_TAU_Threshold_Number()/2;
241 offset += nbits*def.max_TAU_Threshold_Number();
242 if ( (*it)->type() == def.jetType() ) {
254 if ( (*it)->type() == def.teType()) {
255 if (threshNumber >= (
int)def.max_TE_Threshold_Number()/2) {
256 offset += nbits*def.max_TE_Threshold_Number()/2 + nbits*def.max_XE_Threshold_Number()/2 + nbits*def.max_XS_Threshold_Number();
257 fixedThreshNumber -= def.max_TE_Threshold_Number()/2;
261 offset += nbits*def.max_TE_Threshold_Number()/2;
262 if ( (*it)->type() == def.xeType() ) {
263 if (threshNumber >= (
int)def.max_XE_Threshold_Number()/2) {
264 offset += nbits*def.max_TE_Threshold_Number()/2 + nbits*def.max_XE_Threshold_Number()/2 + nbits*def.max_XS_Threshold_Number();
265 fixedThreshNumber -= def.max_XE_Threshold_Number()/2;
269 offset += nbits*def.max_XE_Threshold_Number()/2;
270 if ( (*it)->type() == def.xsType() )
break;
271 offset += nbits*def.max_XS_Threshold_Number();
275 if (nbits == 0)
continue;
276 if (threshNumber < 0)
continue;
277 threshMap.insert(std::make_pair((*it)->name(),
278 offset + fixedThreshNumber*nbits));
279 msg(
MSG::DEBUG) <<
"threshMap: name, offset, threshNumber, nbits "
280 << (*it)->name() <<
" " <<
offset <<
" "
281 << fixedThreshNumber <<
" " << nbits <<
endmsg;
286 const std::vector<TrigConf::TIP*>&
287 tips(
m_configSvc->ctpConfig()->menu().tipVector());
291 std::vector<TrigConf::TIP*>::const_iterator
itp;
293 for (
itp = tips.begin();
itp != tips.end(); ++
itp) {
294 std::map<std::string, int>::const_iterator miter =
295 threshMap.find((*itp)->thresholdName());
296 if (miter != threshMap.end()) {
297 const int pos = miter->second + (*itp)->thresholdBit();
298 if (
pos < l1caloBits) {
299 m_tipMap[
pos] = std::make_pair((*itp)->thresholdName(), (*itp)->tipNumber());
301 }
else msg(MSG::WARNING) <<
"Error setting up TIP map" <<
endmsg;
302 }
else msg(
MSG::DEBUG) <<
"TIP name " << (*itp)->thresholdName()
303 <<
" not found in threshMap" <<
endmsg;
310 msg(
MSG::DEBUG) <<
"tipmap[" << icount <<
"] " << (*it).first <<
" TIP number: " << (*it).second <<
endmsg;
314 }
else msg(MSG::WARNING) <<
"No ctpConfig found" <<
endmsg;
316 return StatusCode::SUCCESS;
328 return StatusCode::SUCCESS;
335 return StatusCode::SUCCESS;
345 if (
sc == StatusCode::FAILURE || !cmxCpHitsTES) {
348 return StatusCode::SUCCESS;
361 for (; cmxIterator != cmxIteratorEnd; ++cmxIterator) {
363 const uint8_t source = (*cmxIterator)->sourceComponent();
364 const uint8_t crate = (*cmxIterator)->crate();
365 const uint8_t cmx = (*cmxIterator)->cmx();
369 EMHits0 = (*cmxIterator)->hits0();
370 EMHits1 = (*cmxIterator)->hits1();
373 TauHits0 = (*cmxIterator)->hits0();
374 TauHits1 = (*cmxIterator)->hits1();
387 if (
sc == StatusCode::FAILURE || !cmxJetHitsTES) {
390 return StatusCode::SUCCESS;
396 int Jet3BitHits0 = 0;
397 int Jet3BitHits1 = 0;
398 int Jet2BitHits0 = 0;
399 int Jet2BitHits1 = 0;
405 for (; cmxJetIterator != cmxJetIteratorEnd; ++cmxJetIterator) {
406 const uint32_t source = (*cmxJetIterator)->sourceComponent();
407 const uint32_t crate = (*cmxJetIterator)->crate();
410 Jet3BitHits0 = (*cmxJetIterator)->hits0();
411 Jet3BitHits1 = (*cmxJetIterator)->hits1();
412 Jet3BitHits = Jet3BitHits0 + (Jet3BitHits1<<15);
415 Jet2BitHits0 = (*cmxJetIterator)->hits0();
416 Jet2BitHits1 = (*cmxJetIterator)->hits1();
417 Jet2BitHits = Jet2BitHits0 + (Jet2BitHits1<<16);
424 if (
sc == StatusCode::FAILURE || !cmxEtSumsTES) {
427 return StatusCode::SUCCESS;
439 for (; cmxEtSumsIterator != cmxEtSumsIteratorEnd; ++ cmxEtSumsIterator) {
440 const uint32_t source = (*cmxEtSumsIterator)->sourceComponent();
441 const uint32_t crate = (*cmxEtSumsIterator)->crate();
445 TEHits = (*cmxEtSumsIterator)->et();
450 XEHits = (*cmxEtSumsIterator)->et();
455 XSHits = (*cmxEtSumsIterator)->et();
460 TERestHits = (*cmxEtSumsIterator)->et();
465 XERestHits = (*cmxEtSumsIterator)->et();
475 if (
sc == StatusCode::FAILURE || !ctpRDO) {
478 return StatusCode::SUCCESS;
485 if (l1aPos >=
ctp.getBunchCrossings().size()) {
486 msg(MSG::WARNING) <<
"Invalid l1aPos" <<
endmsg;
487 return StatusCode::SUCCESS;
490 <<
ctp.getBunchCrossings().size() <<
endmsg;
491 const CTP_BC& bunch =
ctp.getBunchCrossings().at(l1aPos);
503 int totalBits = threshBits*def.max_EM_Threshold_Number()/2;
532 totalBits = threshBits*def.max_TE_Threshold_Number()/2;
537 totalBits = threshBits*def.max_XE_Threshold_Number()/2;
542 totalBits = threshBits*def.max_XS_Threshold_Number();
547 totalBits = threshBits*def.max_TE_Threshold_Number()/2;
552 totalBits = threshBits*def.max_XE_Threshold_Number()/2;
555 return StatusCode::SUCCESS;
566 return StatusCode::SUCCESS;
591 for (
int bit = 0; bit <
totalBits; ++bit) {
597 const int HITbit= ((
hits >> bit) & 0
x1);
598 const int TIPbit = bunch.
getTIP().test( TIPid );
601 tipHits |= (TIPbit << bit);
605 else if (HITbit != TIPbit) {