45 LogTrace(
"DTDQM|DTMonitorModule|DTDigiTask") <<
"[DTDigiTask]: Constructor" << endl;
54 subtractT0 = ps.
getParameter<
bool>(
"performPerWireT0Calibration");
103 LogTrace(
"DTDQM|DTMonitorModule|DTDigiTask") <<
"DTDigiTask: analyzed " <<
nevents <<
" events" << endl;
107 LogTrace(
"DTDQM|DTMonitorModule|DTDigiTask") <<
"[DTDigiTask]: begin run" << endl;
129 if (doStaticBooking) {
132 nEventMonitor = ibooker.
bookFloat(tpMode ?
"nProcessedEventsDigiTP" :
"nProcessedEventsDigi");
134 for (
int wh = -2; wh <= 2; ++wh) {
136 bookHistos(ibooker, wh,
string(
"Occupancies"),
"OccupancyAllHits");
139 bookHistos(ibooker, wh,
string(
"Occupancies"),
"OccupancyNoise");
141 bookHistos(ibooker, wh,
string(
"Occupancies"),
"OccupancyInTimeHits");
144 bookHistos(ibooker, wh,
string(
"SynchNoise"),
"SyncNoiseEvents");
145 bookHistos(ibooker, wh,
string(
"SynchNoise"),
"SyncNoiseChambs");
148 for (
int st = 1; st <= 4; ++st) {
149 for (
int sect = 1; sect <= 14; ++sect) {
150 if ((sect == 13 || sect == 14) && st != 4)
157 bookHistos(ibooker, dtChId,
string(
"Occupancies"),
"OccupancyAllHits_perCh");
159 channelsMap(dtChId,
"OccupancyAllHits_perCh");
162 bookHistos(ibooker, dtChId,
string(
"Occupancies"),
"OccupancyNoise_perCh");
164 bookHistos(ibooker, dtChId,
string(
"Occupancies"),
"OccupancyInTimeHits_perCh");
166 for (
int sl = 1; sl <= 3; ++sl) {
167 if (st == 4 && sl == 2)
171 bookHistos(ibooker, dtSLId,
string(
"TimeBoxes"),
"TimeBox");
174 bookHistos(ibooker, dtSLId,
string(
"TimeBoxes"),
"TimeBoxDTonly");
175 bookHistos(ibooker, dtSLId,
string(
"TimeBoxes"),
"TimeBoxNoDT");
176 bookHistos(ibooker, dtSLId,
string(
"TimeBoxes"),
"TimeBoxDTalso");
186 LogTrace(
"DTDQM|DTMonitorModule|DTDigiTask") <<
"[DTDigiTask]: Begin of LS transition" << endl;
190 if (lumiBlock % resetCycle == 0) {
192 <<
"[DTDigiTask]: Reset at the LS transition : " << lumiBlock << endl;
194 map<string, map<uint32_t, MonitorElement*> >::const_iterator histosIt = digiHistos.begin();
195 map<string, map<uint32_t, MonitorElement*> >::const_iterator histosEnd = digiHistos.end();
196 for (; histosIt != histosEnd; ++histosIt) {
197 map<uint32_t, MonitorElement*>::const_iterator histoIt = (*histosIt).second.begin();
198 map<uint32_t, MonitorElement*>::const_iterator histoEnd = (*histosIt).second.end();
199 for (; histoIt != histoEnd; ++histoIt) {
200 (*histoIt).second->Reset();
205 for (
int wh = -2; wh <= 2; wh++) {
206 for (
int sect = 1; sect <= 14; sect++) {
207 for (
int st = 1; st <= 4; st++) {
208 if ((sect == 13 || sect == 14) && st != 4) {
212 channelsMap(dtChId,
"OccupancyAllHits_perCh");
218 map<string, map<int, MonitorElement*> >::const_iterator whHistosIt = wheelHistos.begin();
219 map<string, map<int, MonitorElement*> >::const_iterator whHistosEnd = wheelHistos.end();
220 for (; whHistosIt != whHistosEnd; ++whHistosIt) {
221 if ((*whHistosIt).first.find(
"Sync") == string::npos) {
222 map<int, MonitorElement*>::const_iterator histoIt = (*whHistosIt).second.begin();
223 map<int, MonitorElement*>::const_iterator histoEnd = (*whHistosIt).second.end();
224 for (; histoIt != histoEnd; ++histoIt) {
225 (*histoIt).second->Reset();
240 stringstream superLayer;
246 histoTag +
"_W" +
wheel.str() +
"_St" +
station.str() +
"_Sec" + sector.str() +
"_SL" + superLayer.str();
248 LogTrace(
"DTDQM|DTMonitorModule|DTDigiTask")
249 <<
"[DTDigiTask]: booking SL histo:" <<
histoName <<
" (tag: " <<
histoTag <<
") folder: "
250 << topFolder() +
"Wheel" +
wheel.str() +
"/Station" +
station.str() +
"/Sector" + sector.str() +
"/" +
folder
257 tTrig = defaultTTrig;
259 if (
folder ==
"TimeBoxes") {
260 string histoTitle =
histoName +
" (TDC Counts)";
266 for (
int layer = 1; layer != 5; ++layer) {
268 stringstream layerHistoName;
269 layerHistoName <<
histoName <<
"_L" << layer;
279 for (
int layer = 1; layer != 5; ++layer) {
281 stringstream layerHistoName;
282 layerHistoName <<
histoName <<
"_L" << layer;
290 if (
folder ==
"CathodPhotoPeaks") {
291 ibooker.
setCurrentFolder(topFolder() +
"Wheel" +
wheel.str() +
"/Sector" + sector.str() +
"/Station" +
310 LogTrace(
"DTDQM|DTMonitorModule|DTDigiTask")
311 <<
"[DTDigiTask]: booking chamber histo:"
313 <<
") folder: " << topFolder() +
"Wheel" +
wheel.str() +
"/Station" +
station.str() +
"/Sector" + sector.str()
316 if (
folder ==
"Occupancies") {
317 const DTChamber* dtchamber = muonGeom->chamber(dtCh);
318 const std::vector<const DTSuperLayer*>& dtSupLylist = dtchamber->
superLayers();
319 std::vector<const DTSuperLayer*>::const_iterator suly = dtSupLylist.begin();
320 std::vector<const DTSuperLayer*>::const_iterator sulyend = dtSupLylist.end();
326 while (suly != sulyend) {
327 const std::vector<const DTLayer*> dtLyList = (*suly)->layers();
328 std::vector<const DTLayer*>::const_iterator ly = dtLyList.begin();
329 std::vector<const DTLayer*>::const_iterator lyend = dtLyList.end();
330 stringstream superLayer;
331 superLayer << (*suly)->id().superlayer();
333 while (ly != lyend) {
334 nWires = muonGeom->layer((*ly)->id())->specificTopology().channels();
335 firstWire = muonGeom->layer((*ly)->id())->specificTopology().firstChannel();
337 layer << (*ly)->id().layer();
338 string histoName_layer =
histoName +
"_SL" + superLayer.str() +
"_L" + layer.str();
339 if (
histoTag ==
"OccupancyAllHits_perL" ||
histoTag ==
"OccupancyNoise_perL" ||
340 histoTag ==
"OccupancyInTimeHits_perL")
341 (digiHistos[
histoTag])[(*ly)->id().rawId()] =
342 ibooker.
book1D(histoName_layer, histoName_layer, nWires, firstWire, nWires + firstWire);
344 if ((nWires + firstWire) > nWires_max)
345 nWires_max = (nWires + firstWire);
350 if (
histoTag !=
"OccupancyAllHits_perL" &&
histoTag !=
"OccupancyNoise_perL" &&
351 histoTag !=
"OccupancyInTimeHits_perL") {
354 if (!readTTrigDB &&
histoTag ==
"OccupancyInTimeHits_perCh") {
358 title <<
"Occ. digis in time [" << inTimeHitsLowerBoundCorr <<
", " << inTimeHitsUpperBoundCorr
360 histoTitle =
title.str();
363 ibooker.
book2D(
histoName, histoTitle, nWires_max, 1, nWires_max + 1, 12, 0, 12);
365 for (
int i = 1;
i <= 12;
i++) {
371 string label =
"SL1: L" + layer_name;
373 }
else if (
i > 4 &&
i < 9) {
378 string label =
"SL2: L" + layer_name;
380 }
else if (
i > 8 &&
i < 13) {
385 string label =
"SL3: L" + layer_name;
401 LogTrace(
"DTDQM|DTMonitorModule|DTDigiTask")
403 <<
") folder: " << topFolder() +
"Wheel" +
wheel.str() +
"/" << endl;
405 if (
folder ==
"Occupancies") {
407 string histoTitle =
"# of digis per chamber WHEEL: " +
wheel.str();
409 (wheelHistos[
histoTag])[wheelId]->setBinLabel(1,
"MB1", 2);
410 (wheelHistos[
histoTag])[wheelId]->setBinLabel(2,
"MB2", 2);
411 (wheelHistos[
histoTag])[wheelId]->setBinLabel(3,
"MB3", 2);
412 (wheelHistos[
histoTag])[wheelId]->setBinLabel(4,
"MB4", 2);
413 (wheelHistos[
histoTag])[wheelId]->setAxisTitle(
"sector", 1);
414 }
else if (
folder ==
"SynchNoise") {
416 if (
histoTag ==
"SyncNoiseEvents") {
417 string histoTitle =
"# of Syncronous-noise events WHEEL: " +
wheel.str();
419 (wheelHistos[
histoTag])[wheelId]->setBinLabel(1,
"MB1", 2);
420 (wheelHistos[
histoTag])[wheelId]->setBinLabel(2,
"MB2", 2);
421 (wheelHistos[
histoTag])[wheelId]->setBinLabel(3,
"MB3", 2);
422 (wheelHistos[
histoTag])[wheelId]->setBinLabel(4,
"MB4", 2);
423 (wheelHistos[
histoTag])[wheelId]->setAxisTitle(
"sector", 1);
424 }
else if (
histoTag ==
"SyncNoiseChambs") {
425 string histoTitle =
"# of Synchornous-noise chamb per evt. WHEEL: " +
wheel.str();
427 (wheelHistos[
histoTag])[wheelId]->setAxisTitle(
"# of noisy chambs.", 1);
428 (wheelHistos[
histoTag])[wheelId]->setAxisTitle(
"# of evts.", 2);
437 LogTrace(
"DTDQM|DTMonitorModule|DTDigiTask")
438 <<
"[DTDigiTask] Analyze #Run: " <<
event.id().run() <<
" #Event: " <<
event.id().event() << endl;
445 event.getByToken(dtDigiToken_, dtdigis);
449 event.getByToken(ltcDigiCollectionToken_, ltcdigis);
461 if (dtdigis->begin() == dtdigis->end()) {
462 LogTrace(
"DTDQM|DTMonitorModule|DTDigiTask") <<
"Event " <<
nevents <<
" empty." << endl;
468 for (dtLayerId_It = dtdigis->begin(); dtLayerId_It != dtdigis->end(); dtLayerId_It++) {
469 DTChamberId chId = ((*dtLayerId_It).first).chamberId();
470 if (hitMap.find(chId) == hitMap.end()) {
473 hitMap[chId] += (((*dtLayerId_It).second).
second - ((*dtLayerId_It).second).first);
477 map<DTChamberId, int>::const_iterator hitMapIt = hitMap.begin();
478 map<DTChamberId, int>::const_iterator hitMapEnd = hitMap.end();
482 for (; hitMapIt != hitMapEnd; ++hitMapIt) {
483 if ((hitMapIt->second) > maxTDCHits) {
485 int wh = chId.
wheel();
487 LogTrace(
"DTDQM|DTMonitorModule|DTDigiTask")
488 <<
"[DTDigiTask] Synch noise in chamber: " << chId <<
" with # digis: " << hitMapIt->second << endl;
490 if (chMap.find(wh) == chMap.end()) {
495 syncNoisyChambers.insert(chId);
497 wheelHistos[
"SyncNoiseEvents"][wh]->Fill(chId.
sector(), chId.
station());
502 map<int, int>::const_iterator chMapIt = chMap.begin();
503 map<int, int>::const_iterator chMapEnd = chMap.end();
504 for (; chMapIt != chMapEnd; ++chMapIt) {
505 wheelHistos[
"SyncNoiseChambs"][(*chMapIt).first]->Fill((*chMapIt).second);
511 if (!syncNoisyChambers.empty()) {
512 LogVerbatim(
"DTDQM|DTMonitorModule|DTDigiTask") <<
"[DTDigiTask] Synch Noise in event: " <<
nevents;
515 <<
"\tnoisy time-boxes and occupancy will not be filled!" << endl;
521 if (syncNoisyChambers.size() > 3) {
522 time_t eventTime = time_t(
event.time().value() >> 32);
524 LogVerbatim(
"DTDQM|DTMonitorModule|DTDigiTask|DTSynchNoise")
525 <<
"[DTDigiTask] At least 4 Synch Noisy chambers in Run : " <<
event.id().run()
526 <<
" Lumi : " <<
event.id().luminosityBlock() <<
" Event : " <<
event.id().event()
527 <<
" at time : " << ctime(&eventTime) << endl;
529 set<DTChamberId>::const_iterator chIt = syncNoisyChambers.begin();
530 set<DTChamberId>::const_iterator chEnd = syncNoisyChambers.end();
532 stringstream synchNoisyCh;
533 for (; chIt != chEnd; ++chIt) {
534 synchNoisyCh <<
" " << (*chIt);
536 LogVerbatim(
"DTDQM|DTMonitorModule|DTDigiTask|DTSynchNoise")
537 <<
"[DTDigiTask] Chamber List :" << synchNoisyCh.str() << endl;
542 << (syncNumTot * 100. /
nevents) <<
"% sync noise events since the beginning \n"
543 << (syncNum * 0.1) <<
"% sync noise events in the last 1000 events " << endl;
548 bool isSyncNoisy =
false;
551 for (dtLayerId_It = dtdigis->begin(); dtLayerId_It != dtdigis->end(); ++dtLayerId_It) {
555 DTChamberId chId = ((*dtLayerId_It).first).chamberId();
556 if (syncNoisyChambers.find(chId) != syncNoisyChambers.end()) {
562 digiIt != ((*dtLayerId_It).second).
second;
565 bool isNoisy =
false;
566 bool isFEMasked =
false;
567 bool isTDCMasked =
false;
568 bool isTrigMask =
false;
572 const DTWireId wireId(((*dtLayerId_It).first), (*digiIt).wire());
573 statusMap->
cellStatus(wireId, isNoisy, isFEMasked, isTDCMasked, isTrigMask, isDead, isNohv);
577 const DTSuperLayerId dtSLId = ((*dtLayerId_It).first).superlayerId();
578 uint32_t indexSL = dtSLId.
rawId();
580 uint32_t indexCh = dtChId.
rawId();
581 int layer_number = ((*dtLayerId_It).first).layer();
589 tTrig = defaultTTrig;
596 int tdcTime = (*digiIt).countsTDC();
599 const DTWireId dtWireId(((*dtLayerId_It).first), (*digiIt).wire());
602 tdcTime +=
int(round(
t0));
613 if ((!isNoisy) && (!isSyncNoisy)) {
615 histoTag =
"TimeBox" + triggerSource();
617 (digiHistos.find(
histoTag)->second).
find(indexSL)->second->Fill(tdcTime);
619 (digiHistos.find(
histoTag)->second).
find((*dtLayerId_It).first.rawId())->
second->Fill(tdcTime);
627 histoTag =
"OccupancyAllHits_perCh";
628 map<uint32_t, MonitorElement*>::const_iterator mappedHisto = digiHistos[
histoTag].find(indexCh);
637 mappedHisto->second->Fill((*digiIt).wire(), (layer_number + (superlayer_number - 1) * 4) - 1);
641 map<int, MonitorElement*>::const_iterator histoPerWheel = wheelHistos[
histoTag].find(dtChId.
wheel());
643 histoPerWheel->second->Fill(dtChId.
sector(), dtChId.
station());
647 if (tdcTime < inTimeHitsLowerBoundCorr) {
653 map<uint32_t, MonitorElement*>::const_iterator mappedHisto = digiHistos[
histoTag].find(indexCh);
655 mappedHisto->second->Fill((*digiIt).wire(), (layer_number + (superlayer_number - 1) * 4) - 1);
660 map<int, MonitorElement*>::const_iterator histoPerWheel = wheelHistos[
histoTag].find(dtChId.
wheel());
662 histoPerWheel->second->Fill(dtChId.
sector(), dtChId.
station());
667 if (tdcTime > inTimeHitsLowerBoundCorr && tdcTime < inTimeHitsUpperBoundCorr) {
671 histoTag =
"OccupancyInTimeHits_perCh";
672 map<uint32_t, MonitorElement*>::const_iterator mappedHisto = digiHistos[
histoTag].find(indexCh);
674 mappedHisto->second->Fill((*digiIt).wire(), (layer_number + (superlayer_number - 1) * 4) - 1);
678 map<int, MonitorElement*>::const_iterator histoPerWheel = wheelHistos[
histoTag].find(dtChId.
wheel());
680 histoPerWheel->second->Fill(dtChId.
sector(), dtChId.
station());
687 syncNoisyChambers.clear();
695 for (std::vector<LTCDigi>::const_iterator ltc_it = ltcdigis->begin(); ltc_it != ltcdigis->end(); ltc_it++) {
696 size_t otherTriggerSum = 0;
697 for (
size_t i = 1;
i < 6;
i++)
698 otherTriggerSum +=
size_t((*ltc_it).HasTriggered(
i));
700 if ((*ltc_it).HasTriggered(0) && otherTriggerSum == 0)
701 l1ASource =
"DTonly";
702 else if (!(*ltc_it).HasTriggered(0))
704 else if ((*ltc_it).HasTriggered(0) && otherTriggerSum > 0)
705 l1ASource =
"DTalso";
713 return string(
"DT/10-TestPulses/");
715 return string(
"DT/01-SliceTestDigi/");
716 return string(
"DT/01-Digi/");
721 int nWires_max = (digiHistos[
histoTag])[dtCh.
rawId()]->getNbinsX();
724 for (
int sl = 1; sl <= 3; sl++) {
725 for (
int ly = 1; ly <= 4; ly++) {
726 for (
int ch = 1; ch <= nWires_max; ch++) {
727 int dduId = -1, rosId = -1, robId = -1, tdcId = -1, channelId = -1;
728 int realCh =
mapping->geometryToReadOut(
729 dtCh.
wheel(), dtCh.
station(), dtCh.
sector(), sl, ly, ch, dduId, rosId, robId, tdcId, channelId);
733 int lybin = (4 * sl - 4) + ly;
734 (digiHistos[
histoTag])[dtCh.
rawId()]->setBinContent(ch, lybin, -1.);