CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DTDigiTask.cc
Go to the documentation of this file.
1 /*
2  * \file DTDigiTask.cc
3  *
4  * \author M. Zanetti - INFN Padova
5  *
6  */
7 
9 
10 // Framework
12 
13 // Digis
16 
17 // Geometry
21 
22 // T0s
25 
28 
29 #include <sstream>
30 #include <cmath>
31 
32 using namespace edm;
33 using namespace std;
34 
35 // Contructor
37  : muonGeomToken_(esConsumes<edm::Transition::BeginRun>()),
38  readOutMapToken_(esConsumes<edm::Transition::BeginRun>()),
39  TtrigToken_(esConsumes<edm::Transition::BeginRun>()),
40  T0Token_(esConsumes<edm::Transition::BeginRun>()),
41  statusMapToken_(esConsumes()) {
42  // switch for the verbosity
43  LogTrace("DTDQM|DTMonitorModule|DTDigiTask") << "[DTDigiTask]: Constructor" << endl;
44 
45  // The label to retrieve the digis
46  dtDigiToken_ = consumes<DTDigiCollection>(ps.getParameter<InputTag>("dtDigiLabel"));
47  // Read the configuration parameters
48  maxTDCHits = ps.getUntrackedParameter<int>("maxTDCHitsPerChamber", 30000);
49  // Set to true to read the ttrig from DB (useful to determine in-time and out-of-time hits)
50  readTTrigDB = ps.getUntrackedParameter<bool>("readDB", false);
51  // Set to true to subtract t0 from test pulses
52  subtractT0 = ps.getParameter<bool>("performPerWireT0Calibration");
53  // Tmax value (TDC counts)
54  defaultTmax = ps.getParameter<int>("defaultTmax");
55  // Switch from static to dinamic histo booking
56  doStaticBooking = ps.getUntrackedParameter<bool>("staticBooking", true);
57 
58  // Switch for local/global runs
59  isLocalRun = ps.getUntrackedParameter<bool>("localrun", true);
60  if (!isLocalRun) {
61  ltcDigiCollectionToken_ = consumes<LTCDigiCollection>(ps.getParameter<edm::InputTag>("ltcDigiCollectionTag"));
62  }
63 
64  // Setting for the reset of the ME after n (= ResetCycle) luminosity sections
65  resetCycle = ps.getUntrackedParameter<int>("ResetCycle", 3);
66  // Check the DB of noisy channels
67  checkNoisyChannels = ps.getUntrackedParameter<bool>("checkNoisyChannels", false);
68  // Default TTrig to be used when not reading the TTrig DB
69  defaultTTrig = ps.getParameter<int>("defaultTtrig");
70  inTimeHitsLowerBound = ps.getParameter<int>("inTimeHitsLowerBound");
71  inTimeHitsUpperBound = ps.getParameter<int>("inTimeHitsUpperBound");
72  timeBoxGranularity = ps.getUntrackedParameter<int>("timeBoxGranularity", 4);
73  maxTTMounts = ps.getUntrackedParameter<int>("maxTTMounts", 6400);
74 
75  doAllHitsOccupancies = ps.getUntrackedParameter<bool>("doAllHitsOccupancies", true);
76  doNoiseOccupancies = ps.getUntrackedParameter<bool>("doNoiseOccupancies", false);
77  doInTimeOccupancies = ps.getUntrackedParameter<bool>("doInTimeOccupancies", false);
78 
79  // switch on the mode for running on test pulses (different top folder)
80  tpMode = ps.getUntrackedParameter<bool>("testPulseMode", false);
81  // switch on/off the filtering of synchronous noise events (cutting on the # of digis)
82  // time-boxes and occupancy plots are not filled and summary plots are created to report the problem
83  filterSyncNoise = ps.getUntrackedParameter<bool>("filterSyncNoise", false);
84  // look for synch noisy events, produce histograms but do not filter them
85  lookForSyncNoise = ps.getUntrackedParameter<bool>("lookForSyncNoise", false);
86 
87  // switch on the mode for running on slice test (different top folder and other customizations)
88  sliceTestMode = ps.getUntrackedParameter<bool>("sliceTestMode", false);
89  // time pedestal used to set the minimum in the time box plot
90  tdcPedestal = ps.getUntrackedParameter<int>("tdcPedestal", 0);
91 
92  // switch on production of time-boxes with layer granularity
93  doLayerTimeBoxes = ps.getUntrackedParameter<bool>("doLayerTimeBoxes", false);
94 
95  syncNumTot = 0;
96  syncNum = 0;
97 }
98 
99 // destructor
101  LogTrace("DTDQM|DTMonitorModule|DTDigiTask") << "DTDigiTask: analyzed " << nevents << " events" << endl;
102 }
103 
105  LogTrace("DTDQM|DTMonitorModule|DTDigiTask") << "[DTDigiTask]: begin run" << endl;
106  nevents = 0;
107 
108  // Get the geometry
109  muonGeom = &context.getData(muonGeomToken_);
110 
111  // map of the channels
112  mapping = &context.getData(readOutMapToken_);
113 
114  // tTrig
115  if (readTTrigDB)
116  tTrigMap = &context.getData(TtrigToken_);
117  // t0s
118  if (subtractT0)
119  t0Map = &context.getData(T0Token_);
120  // FIXME: tMax (not yet from the DB)
121  tMax = defaultTmax;
122 
123  // ----------------------------------------------------------------------
124 }
125 
127  if (doStaticBooking) { // Static histo booking
128  // book the event counter
129  ibooker.setCurrentFolder("DT/EventInfo/Counters");
130  nEventMonitor = ibooker.bookFloat(tpMode ? "nProcessedEventsDigiTP" : "nProcessedEventsDigi");
131  ibooker.setCurrentFolder(topFolder());
132  for (int wh = -2; wh <= 2; ++wh) { // loop over wheels
133  if (sliceTestMode && wh != 2)
134  continue;
135 
137  bookHistos(ibooker, wh, string("Occupancies"), "OccupancyAllHits");
138 
139  if (doNoiseOccupancies)
140  bookHistos(ibooker, wh, string("Occupancies"), "OccupancyNoise");
142  bookHistos(ibooker, wh, string("Occupancies"), "OccupancyInTimeHits");
143 
145  bookHistos(ibooker, wh, string("SynchNoise"), "SyncNoiseEvents");
146  bookHistos(ibooker, wh, string("SynchNoise"), "SyncNoiseChambs");
147  }
148 
149  for (int st = 1; st <= 4; ++st) { // loop over stations
150  for (int sect = 1; sect <= 14; ++sect) { // loop over sectors
151  if ((sect == 13 || sect == 14) && st != 4)
152  continue;
153 
154  if (sliceTestMode && (sect != 12 || wh != 2))
155  continue;
156 
157  // Get the chamber ID
158  const DTChamberId dtChId(wh, st, sect);
159 
160  // Occupancies
161  if (doAllHitsOccupancies) {
162  bookHistos(ibooker, dtChId, string("Occupancies"), "OccupancyAllHits_perCh");
163  // set channel mapping
164  channelsMap(dtChId, "OccupancyAllHits_perCh");
165  }
166  if (doNoiseOccupancies)
167  bookHistos(ibooker, dtChId, string("Occupancies"), "OccupancyNoise_perCh");
169  bookHistos(ibooker, dtChId, string("Occupancies"), "OccupancyInTimeHits_perCh");
170 
171  for (int sl = 1; sl <= 3; ++sl) { // Loop over SLs
172  if (st == 4 && sl == 2)
173  continue;
174  const DTSuperLayerId dtSLId(wh, st, sect, sl);
175  if (isLocalRun) {
176  bookHistos(ibooker, dtSLId, string("TimeBoxes"), "TimeBox");
177  } else {
178  // TimeBoxes for different triggers
179  bookHistos(ibooker, dtSLId, string("TimeBoxes"), "TimeBoxDTonly");
180  bookHistos(ibooker, dtSLId, string("TimeBoxes"), "TimeBoxNoDT");
181  bookHistos(ibooker, dtSLId, string("TimeBoxes"), "TimeBoxDTalso");
182  }
183  }
184  }
185  }
186  }
187  }
188 }
189 
191  LogTrace("DTDQM|DTMonitorModule|DTDigiTask") << "[DTDigiTask]: Begin of LS transition" << endl;
192 
193  // Reset the MonitorElements every n (= ResetCycle) Lumi Blocks
194  int lumiBlock = lumiSeg.id().luminosityBlock();
195  if (lumiBlock % resetCycle == 0) {
196  LogVerbatim("DTDQM|DTMonitorModule|DTDigiTask")
197  << "[DTDigiTask]: Reset at the LS transition : " << lumiBlock << endl;
198  // Loop over all ME
199  map<string, map<uint32_t, MonitorElement*> >::const_iterator histosIt = digiHistos.begin();
200  map<string, map<uint32_t, MonitorElement*> >::const_iterator histosEnd = digiHistos.end();
201  for (; histosIt != histosEnd; ++histosIt) {
202  map<uint32_t, MonitorElement*>::const_iterator histoIt = (*histosIt).second.begin();
203  map<uint32_t, MonitorElement*>::const_iterator histoEnd = (*histosIt).second.end();
204  for (; histoIt != histoEnd; ++histoIt) {
205  (*histoIt).second->Reset();
206  }
207  }
208 
209  // re-set mapping for not real channels in the occupancyHits per chamber
210  for (int wh = -2; wh <= 2; wh++) {
211  for (int sect = 1; sect <= 14; sect++) {
212  for (int st = 1; st <= 4; st++) {
213  if (sliceTestMode && (sect != 12 || wh != 2)) {
214  continue;
215  }
216  if ((sect == 13 || sect == 14) && st != 4) {
217  continue;
218  }
219  const DTChamberId dtChId(wh, st, sect);
220  channelsMap(dtChId, "OccupancyAllHits_perCh");
221  }
222  }
223  }
224 
225  // loop over wheel summaries
226  map<string, map<int, MonitorElement*> >::const_iterator whHistosIt = wheelHistos.begin();
227  map<string, map<int, MonitorElement*> >::const_iterator whHistosEnd = wheelHistos.end();
228  for (; whHistosIt != whHistosEnd; ++whHistosIt) {
229  if ((*whHistosIt).first.find("Sync") == string::npos) { // FIXME skips synch noise plots
230  map<int, MonitorElement*>::const_iterator histoIt = (*whHistosIt).second.begin();
231  map<int, MonitorElement*>::const_iterator histoEnd = (*whHistosIt).second.end();
232  for (; histoIt != histoEnd; ++histoIt) {
233  (*histoIt).second->Reset();
234  }
235  }
236  }
237  }
238 }
239 
240 void DTDigiTask::bookHistos(DQMStore::IBooker& ibooker, const DTSuperLayerId& dtSL, string folder, string histoTag) {
241  // set the folder
242  stringstream wheel;
243  wheel << dtSL.wheel();
244  stringstream station;
245  station << dtSL.station();
246  stringstream sector;
247  sector << dtSL.sector();
248  stringstream superLayer;
249  superLayer << dtSL.superlayer();
250  ibooker.setCurrentFolder(topFolder() + "Wheel" + wheel.str() + "/Sector" + sector.str() + "/Station" + station.str());
251 
252  // Build the histo name
253  string histoName =
254  histoTag + "_W" + wheel.str() + "_St" + station.str() + "_Sec" + sector.str() + "_SL" + superLayer.str();
255 
256  LogTrace("DTDQM|DTMonitorModule|DTDigiTask")
257  << "[DTDigiTask]: booking SL histo:" << histoName << " (tag: " << histoTag << ") folder: "
258  << topFolder() + "Wheel" + wheel.str() + "/Station" + station.str() + "/Sector" + sector.str() + "/" + folder
259  << endl;
260 
261  // ttrig and rms are TDC counts
262  if (readTTrigDB)
264  else
266 
267  if (folder == "TimeBoxes") {
268  string histoTitle = histoName + " (TDC Counts)";
269 
270  if (!readTTrigDB) {
271  (digiHistos[histoTag])[dtSL.rawId()] = ibooker.book1D(
272  histoName, histoTitle, maxTTMounts / timeBoxGranularity, tdcPedestal, maxTTMounts + tdcPedestal);
273  if (doLayerTimeBoxes) { // Book TimeBoxes per layer
274  for (int layer = 1; layer != 5; ++layer) {
275  DTLayerId layerId(dtSL, layer);
276  stringstream layerHistoName;
277  layerHistoName << histoName << "_L" << layer;
278  (digiHistos[histoTag])[layerId.rawId()] = ibooker.book1D(layerHistoName.str(),
279  layerHistoName.str(),
281  tdcPedestal,
283  }
284  }
285  } else {
286  (digiHistos[histoTag])[dtSL.rawId()] =
287  ibooker.book1D(histoName, histoTitle, 3 * tMax / timeBoxGranularity, tTrig - tMax, tTrig + 2 * tMax);
288  if (doLayerTimeBoxes) {
289  // Book TimeBoxes per layer
290  for (int layer = 1; layer != 5; ++layer) {
291  DTLayerId layerId(dtSL, layer);
292  stringstream layerHistoName;
293  layerHistoName << histoName << "_L" << layer;
294  (digiHistos[histoTag])[layerId.rawId()] = ibooker.book1D(
295  layerHistoName.str(), layerHistoName.str(), 3 * tMax / timeBoxGranularity, tTrig - tMax, tTrig + 2 * tMax);
296  }
297  }
298  }
299  }
300 
301  if (folder == "CathodPhotoPeaks") {
302  ibooker.setCurrentFolder(topFolder() + "Wheel" + wheel.str() + "/Sector" + sector.str() + "/Station" +
303  station.str() + "/" + folder);
304  (digiHistos[histoTag])[dtSL.rawId()] = ibooker.book1D(histoName, histoName, 500, 0, 1000);
305  }
306 }
307 
308 void DTDigiTask::bookHistos(DQMStore::IBooker& ibooker, const DTChamberId& dtCh, string folder, string histoTag) {
309  // set the current folder
310  stringstream wheel;
311  wheel << dtCh.wheel();
312  stringstream station;
313  station << dtCh.station();
314  stringstream sector;
315  sector << dtCh.sector();
316  ibooker.setCurrentFolder(topFolder() + "Wheel" + wheel.str() + "/Sector" + sector.str() + "/Station" + station.str());
317 
318  // build the histo name
319  string histoName = histoTag + "_W" + wheel.str() + "_St" + station.str() + "_Sec" + sector.str();
320 
321  LogTrace("DTDQM|DTMonitorModule|DTDigiTask")
322  << "[DTDigiTask]: booking chamber histo:"
323  << " (tag: " << histoTag
324  << ") folder: " << topFolder() + "Wheel" + wheel.str() + "/Station" + station.str() + "/Sector" + sector.str()
325  << endl;
326 
327  if (folder == "Occupancies") {
328  const DTChamber* dtchamber = muonGeom->chamber(dtCh);
329  const std::vector<const DTSuperLayer*>& dtSupLylist = dtchamber->superLayers();
330  std::vector<const DTSuperLayer*>::const_iterator suly = dtSupLylist.begin();
331  std::vector<const DTSuperLayer*>::const_iterator sulyend = dtSupLylist.end();
332 
333  int nWires = 0;
334  int firstWire = 0;
335  int nWires_max = 0;
336 
337  while (suly != sulyend) {
338  const std::vector<const DTLayer*> dtLyList = (*suly)->layers();
339  std::vector<const DTLayer*>::const_iterator ly = dtLyList.begin();
340  std::vector<const DTLayer*>::const_iterator lyend = dtLyList.end();
341  stringstream superLayer;
342  superLayer << (*suly)->id().superlayer();
343 
344  while (ly != lyend) {
345  nWires = muonGeom->layer((*ly)->id())->specificTopology().channels();
346  firstWire = muonGeom->layer((*ly)->id())->specificTopology().firstChannel();
347  stringstream layer;
348  layer << (*ly)->id().layer();
349  string histoName_layer = histoName + "_SL" + superLayer.str() + "_L" + layer.str();
350  if (histoTag == "OccupancyAllHits_perL" || histoTag == "OccupancyNoise_perL" ||
351  histoTag == "OccupancyInTimeHits_perL")
352  (digiHistos[histoTag])[(*ly)->id().rawId()] =
353  ibooker.book1D(histoName_layer, histoName_layer, nWires, firstWire, nWires + firstWire);
354  ++ly;
355  if ((nWires + firstWire) > nWires_max)
356  nWires_max = (nWires + firstWire);
357  }
358  ++suly;
359  }
360 
361  if (histoTag != "OccupancyAllHits_perL" && histoTag != "OccupancyNoise_perL" &&
362  histoTag != "OccupancyInTimeHits_perL") {
363  // Set the title to show the time interval used (only if unique == not from DB)
364  string histoTitle = histoName;
365  if (!readTTrigDB && histoTag == "OccupancyInTimeHits_perCh") {
366  stringstream title;
367  int inTimeHitsLowerBoundCorr = int(round(defaultTTrig)) - inTimeHitsLowerBound;
368  int inTimeHitsUpperBoundCorr = int(round(defaultTTrig)) + defaultTmax + inTimeHitsUpperBound;
369  title << "Occ. digis in time [" << inTimeHitsLowerBoundCorr << ", " << inTimeHitsUpperBoundCorr
370  << "] (TDC counts)";
371  histoTitle = title.str();
372  }
373  (digiHistos[histoTag])[dtCh.rawId()] =
374  ibooker.book2D(histoName, histoTitle, nWires_max, 1, nWires_max + 1, 12, 0, 12);
375 
376  for (int i = 1; i <= 12; i++) {
377  if (i < 5) {
378  stringstream layer;
379  string layer_name;
380  layer << i;
381  layer >> layer_name;
382  string label = "SL1: L" + layer_name;
383  (digiHistos[histoTag])[dtCh.rawId()]->setBinLabel(i, label, 2);
384  } else if (i > 4 && i < 9) {
385  stringstream layer;
386  string layer_name;
387  layer << (i - 4);
388  layer >> layer_name;
389  string label = "SL2: L" + layer_name;
390  (digiHistos[histoTag])[dtCh.rawId()]->setBinLabel(i, label, 2);
391  } else if (i > 8 && i < 13) {
392  stringstream layer;
393  string layer_name;
394  layer << (i - 8);
395  layer >> layer_name;
396  string label = "SL3: L" + layer_name;
397  (digiHistos[histoTag])[dtCh.rawId()]->setBinLabel(i, label, 2);
398  }
399  }
400  }
401  }
402 }
403 
404 void DTDigiTask::bookHistos(DQMStore::IBooker& ibooker, const int wheelId, string folder, string histoTag) {
405  // Set the current folder
406  stringstream wheel;
407  wheel << wheelId;
408 
409  // build the histo name
410  string histoName = histoTag + "_W" + wheel.str();
411 
412  LogTrace("DTDQM|DTMonitorModule|DTDigiTask")
413  << "[DTDigiTask]: booking wheel histo:" << histoName << " (tag: " << histoTag
414  << ") folder: " << topFolder() + "Wheel" + wheel.str() + "/" << endl;
415 
416  if (folder == "Occupancies") {
417  ibooker.setCurrentFolder(topFolder() + "Wheel" + wheel.str());
418  string histoTitle = "# of digis per chamber WHEEL: " + wheel.str();
419  (wheelHistos[histoTag])[wheelId] = ibooker.book2D(histoName, histoTitle, 12, 1, 13, 4, 1, 5);
420  (wheelHistos[histoTag])[wheelId]->setBinLabel(1, "MB1", 2);
421  (wheelHistos[histoTag])[wheelId]->setBinLabel(2, "MB2", 2);
422  (wheelHistos[histoTag])[wheelId]->setBinLabel(3, "MB3", 2);
423  (wheelHistos[histoTag])[wheelId]->setBinLabel(4, "MB4", 2);
424  (wheelHistos[histoTag])[wheelId]->setAxisTitle("sector", 1);
425  } else if (folder == "SynchNoise") {
426  ibooker.setCurrentFolder("DT/05-Noise/SynchNoise");
427  if (histoTag == "SyncNoiseEvents") {
428  string histoTitle = "# of Syncronous-noise events WHEEL: " + wheel.str();
429  (wheelHistos[histoTag])[wheelId] = ibooker.book2D(histoName, histoTitle, 12, 1, 13, 4, 1, 5);
430  (wheelHistos[histoTag])[wheelId]->setBinLabel(1, "MB1", 2);
431  (wheelHistos[histoTag])[wheelId]->setBinLabel(2, "MB2", 2);
432  (wheelHistos[histoTag])[wheelId]->setBinLabel(3, "MB3", 2);
433  (wheelHistos[histoTag])[wheelId]->setBinLabel(4, "MB4", 2);
434  (wheelHistos[histoTag])[wheelId]->setAxisTitle("sector", 1);
435  } else if (histoTag == "SyncNoiseChambs") {
436  string histoTitle = "# of Synchornous-noise chamb per evt. WHEEL: " + wheel.str();
437  (wheelHistos[histoTag])[wheelId] = ibooker.book1D(histoName, histoTitle, 50, 0.5, 50.5);
438  (wheelHistos[histoTag])[wheelId]->setAxisTitle("# of noisy chambs.", 1);
439  (wheelHistos[histoTag])[wheelId]->setAxisTitle("# of evts.", 2);
440  }
441  }
442 }
443 // does the real job
445  nevents++;
447  if (nevents % 1000 == 0) {
448  LogTrace("DTDQM|DTMonitorModule|DTDigiTask")
449  << "[DTDigiTask] Analyze #Run: " << event.id().run() << " #Event: " << event.id().event() << endl;
450  }
451 
452  // Get the ingredients from the event
453 
454  // Digi collection
456  event.getByToken(dtDigiToken_, dtdigis);
457 
458  // LTC digis
459  if (!isLocalRun)
460  event.getByToken(ltcDigiCollectionToken_, ltcdigis);
461 
462  // Status map (for noisy channels)
463  if (checkNoisyChannels) {
464  // Get the map of noisy channels
466  }
467 
468  string histoTag;
469 
470  // Check if the digi container is empty
471  if (dtdigis->begin() == dtdigis->end()) {
472  LogTrace("DTDQM|DTMonitorModule|DTDigiTask") << "Event " << nevents << " empty." << endl;
473  }
474 
475  if (lookForSyncNoise || filterSyncNoise) { // dosync
476  // Count the # of digis per chamber
478  for (dtLayerId_It = dtdigis->begin(); dtLayerId_It != dtdigis->end(); dtLayerId_It++) {
479  DTChamberId chId = ((*dtLayerId_It).first).chamberId();
480  if (hitMap.find(chId) == hitMap.end()) { // new chamber
481  hitMap[chId] = 0;
482  }
483  hitMap[chId] += (((*dtLayerId_It).second).second - ((*dtLayerId_It).second).first);
484  }
485 
486  // check chamber with # of digis above threshold and flag them as noisy
487  map<DTChamberId, int>::const_iterator hitMapIt = hitMap.begin();
488  map<DTChamberId, int>::const_iterator hitMapEnd = hitMap.end();
489 
490  map<int, int> chMap;
491 
492  for (; hitMapIt != hitMapEnd; ++hitMapIt) {
493  if ((hitMapIt->second) > maxTDCHits) {
494  DTChamberId chId = hitMapIt->first;
495  int wh = chId.wheel();
496 
497  LogTrace("DTDQM|DTMonitorModule|DTDigiTask")
498  << "[DTDigiTask] Synch noise in chamber: " << chId << " with # digis: " << hitMapIt->second << endl;
499 
500  if (chMap.find(wh) == chMap.end()) {
501  chMap[wh] = 0;
502  }
503  chMap[wh]++;
504 
505  syncNoisyChambers.insert(chId);
506 
507  wheelHistos["SyncNoiseEvents"][wh]->Fill(chId.sector(), chId.station());
508  }
509  }
510 
511  // fill # of noisy ch per wheel plot
512  map<int, int>::const_iterator chMapIt = chMap.begin();
513  map<int, int>::const_iterator chMapEnd = chMap.end();
514  for (; chMapIt != chMapEnd; ++chMapIt) {
515  wheelHistos["SyncNoiseChambs"][(*chMapIt).first]->Fill((*chMapIt).second);
516  }
517 
518  // clear the map of # of digis per chamber: not needed anymore
519  hitMap.clear();
520 
521  if (!syncNoisyChambers.empty()) {
522  LogVerbatim("DTDQM|DTMonitorModule|DTDigiTask") << "[DTDigiTask] Synch Noise in event: " << nevents;
523  if (filterSyncNoise)
524  LogVerbatim("DTDQM|DTMonitorModule|DTDigiTask")
525  << "\tnoisy time-boxes and occupancy will not be filled!" << endl;
526  syncNumTot++;
527  syncNum++;
528  }
529 
530  // Logging of "large" synch Noisy events in private DQM
531  if (syncNoisyChambers.size() > 3) {
532  time_t eventTime = time_t(event.time().value() >> 32);
533 
534  LogVerbatim("DTDQM|DTMonitorModule|DTDigiTask|DTSynchNoise")
535  << "[DTDigiTask] At least 4 Synch Noisy chambers in Run : " << event.id().run()
536  << " Lumi : " << event.id().luminosityBlock() << " Event : " << event.id().event()
537  << " at time : " << ctime(&eventTime) << endl;
538 
539  set<DTChamberId>::const_iterator chIt = syncNoisyChambers.begin();
540  set<DTChamberId>::const_iterator chEnd = syncNoisyChambers.end();
541 
542  stringstream synchNoisyCh;
543  for (; chIt != chEnd; ++chIt) {
544  synchNoisyCh << " " << (*chIt);
545  }
546  LogVerbatim("DTDQM|DTMonitorModule|DTDigiTask|DTSynchNoise")
547  << "[DTDigiTask] Chamber List :" << synchNoisyCh.str() << endl;
548  }
549 
550  if (nevents % 1000 == 0) {
551  LogVerbatim("DTDQM|DTMonitorModule|DTDigiTask")
552  << (syncNumTot * 100. / nevents) << "% sync noise events since the beginning \n"
553  << (syncNum * 0.1) << "% sync noise events in the last 1000 events " << endl;
554  syncNum = 0;
555  }
556  }
557 
558  bool isSyncNoisy = false;
559 
561  for (dtLayerId_It = dtdigis->begin(); dtLayerId_It != dtdigis->end(); ++dtLayerId_It) { // Loop over layers
562  isSyncNoisy = false;
563  // check if chamber labeled as synch noisy
564  if (filterSyncNoise) {
565  DTChamberId chId = ((*dtLayerId_It).first).chamberId();
566  if (syncNoisyChambers.find(chId) != syncNoisyChambers.end()) {
567  isSyncNoisy = true;
568  }
569  }
570 
571  for (DTDigiCollection::const_iterator digiIt = ((*dtLayerId_It).second).first;
572  digiIt != ((*dtLayerId_It).second).second;
573  ++digiIt) { // Loop over all digis
574 
575  bool isNoisy = false;
576  bool isFEMasked = false;
577  bool isTDCMasked = false;
578  bool isTrigMask = false;
579  bool isDead = false;
580  bool isNohv = false;
581  if (checkNoisyChannels) {
582  const DTWireId wireId(((*dtLayerId_It).first), (*digiIt).wire());
583  statusMap->cellStatus(wireId, isNoisy, isFEMasked, isTDCMasked, isTrigMask, isDead, isNohv);
584  }
585 
586  // Get the useful IDs
587  const DTSuperLayerId dtSLId = ((*dtLayerId_It).first).superlayerId();
588  uint32_t indexSL = dtSLId.rawId();
589  const DTChamberId dtChId = dtSLId.chamberId();
590  uint32_t indexCh = dtChId.rawId();
591  int layer_number = ((*dtLayerId_It).first).layer();
592  int superlayer_number = dtSLId.superlayer();
593 
594  // Read the ttrig DB or set a rough value from config
595  // ttrig and rms are TDC counts
596  if (readTTrigDB)
597  tTrigMap->get(((*dtLayerId_It).first).superlayerId(), tTrig, tTrigRMS, kFactor, DTTimeUnits::counts);
598  else
600 
601  int inTimeHitsLowerBoundCorr = int(round(tTrig)) - inTimeHitsLowerBound;
602  int inTimeHitsUpperBoundCorr = int(round(tTrig)) + tMax + inTimeHitsUpperBound;
603 
604  float t0;
605  float t0RMS;
606  int tdcTime = (*digiIt).countsTDC();
607 
608  if (subtractT0) {
609  const DTWireId dtWireId(((*dtLayerId_It).first), (*digiIt).wire());
610  // t0s and rms are TDC counts
611  t0Map->get(dtWireId, t0, t0RMS, DTTimeUnits::counts);
612  tdcTime += int(round(t0));
613  }
614 
615  if (sliceTestMode) {
616  tdcTime = std::max(tdcPedestal + 1, std::min(tdcPedestal + maxTTMounts - 1, tdcTime));
617  // std::cout << tdcTime << std::endl;
618  }
619 
620  // Fill Time-Boxes
621  // NOTE: avoid to fill TB and PhotoPeak with noise. Occupancy are filled anyway
622  if ((!isNoisy) && (!isSyncNoisy)) { // Discard noisy channels
623  // TimeBoxes per SL
624  histoTag = "TimeBox" + triggerSource();
625 
626  (digiHistos.find(histoTag)->second).find(indexSL)->second->Fill(tdcTime);
627  if (doLayerTimeBoxes)
628  (digiHistos.find(histoTag)->second).find((*dtLayerId_It).first.rawId())->second->Fill(tdcTime);
629  }
630 
631  // Fill Occupancies
632  if (!isSyncNoisy) { // Discard synch noisy channels
633 
634  if (doAllHitsOccupancies) { // fill occupancies for all hits
635  //Occupancies per chamber & layer
636  histoTag = "OccupancyAllHits_perCh";
637  map<uint32_t, MonitorElement*>::const_iterator mappedHisto = digiHistos[histoTag].find(indexCh);
638 
639  //FR comment the following cannot pass ibooker to analyze method!
640  /*
641  if (mappedHisto == digiHistos[histoTag].end()) { // dynamic booking
642  bookHistos(ibooker, dtChId, string("Occupancies"), histoTag);
643  mappedHisto = digiHistos[histoTag].find(indexCh);
644  }
645  */
646  mappedHisto->second->Fill((*digiIt).wire(), (layer_number + (superlayer_number - 1) * 4) - 1);
647 
648  // Fill the chamber occupancy
649  histoTag = "OccupancyAllHits";
650  map<int, MonitorElement*>::const_iterator histoPerWheel = wheelHistos[histoTag].find(dtChId.wheel());
651 
652  histoPerWheel->second->Fill(dtChId.sector(), dtChId.station()); // FIXME: normalize to # of layers
653  }
654 
655  if (doNoiseOccupancies) { // fill occupancies for hits before the ttrig
656  if (tdcTime < inTimeHitsLowerBoundCorr) {
657  // FIXME: what about tdcTime > inTimeHitsUpperBoundCorr ???
658 
659  // Noise: Before tTrig
660  //Occupancies Noise per chamber & layer
661  histoTag = "OccupancyNoise_perCh";
662  map<uint32_t, MonitorElement*>::const_iterator mappedHisto = digiHistos[histoTag].find(indexCh);
663 
664  mappedHisto->second->Fill((*digiIt).wire(), (layer_number + (superlayer_number - 1) * 4) - 1);
665 
666  // Fill the chamber occupancy
667 
668  histoTag = "OccupancyNoise";
669  map<int, MonitorElement*>::const_iterator histoPerWheel = wheelHistos[histoTag].find(dtChId.wheel());
670 
671  histoPerWheel->second->Fill(dtChId.sector(), dtChId.station()); // FIXME: normalize to # of layers
672  }
673  }
674 
675  if (doInTimeOccupancies) { // fill occpunacies for in-time hits only
676  if (tdcTime > inTimeHitsLowerBoundCorr && tdcTime < inTimeHitsUpperBoundCorr) {
677  // Physical hits: within the time window
678 
679  //Occupancies Signal per chamber & layer
680  histoTag = "OccupancyInTimeHits_perCh";
681  map<uint32_t, MonitorElement*>::const_iterator mappedHisto = digiHistos[histoTag].find(indexCh);
682 
683  mappedHisto->second->Fill((*digiIt).wire(), (layer_number + (superlayer_number - 1) * 4) - 1);
684 
685  // Fill the chamber occupancy
686  histoTag = "OccupancyInTimeHits";
687  map<int, MonitorElement*>::const_iterator histoPerWheel = wheelHistos[histoTag].find(dtChId.wheel());
688 
689  histoPerWheel->second->Fill(dtChId.sector(), dtChId.station()); // FIXME: normalize to # of layers
690  }
691  }
692  }
693  }
694  }
695 
696  syncNoisyChambers.clear();
697 }
698 
700  string l1ASource;
701  if (isLocalRun)
702  return l1ASource;
703 
704  for (std::vector<LTCDigi>::const_iterator ltc_it = ltcdigis->begin(); ltc_it != ltcdigis->end(); ltc_it++) {
705  size_t otherTriggerSum = 0;
706  for (size_t i = 1; i < 6; i++)
707  otherTriggerSum += size_t((*ltc_it).HasTriggered(i));
708 
709  if ((*ltc_it).HasTriggered(0) && otherTriggerSum == 0)
710  l1ASource = "DTonly";
711  else if (!(*ltc_it).HasTriggered(0))
712  l1ASource = "NoDT";
713  else if ((*ltc_it).HasTriggered(0) && otherTriggerSum > 0)
714  l1ASource = "DTalso";
715  }
716 
717  return l1ASource;
718 }
719 
720 string DTDigiTask::topFolder() const {
721  if (tpMode)
722  return string("DT/10-TestPulses/");
723  else if (sliceTestMode)
724  return string("DT/01-SliceTestDigi/");
725  return string("DT/01-Digi/");
726 }
727 
728 void DTDigiTask::channelsMap(const DTChamberId& dtCh, string histoTag) {
729  // n max channels
730  int nWires_max = (digiHistos[histoTag])[dtCh.rawId()]->getNbinsX();
731 
732  // set bin content = -1 for each not real channel. For visualization purposes
733  for (int sl = 1; sl <= 3; sl++) {
734  for (int ly = 1; ly <= 4; ly++) {
735  for (int ch = 1; ch <= nWires_max; ch++) {
736  int dduId = -1, rosId = -1, robId = -1, tdcId = -1, channelId = -1;
737  int realCh = mapping->geometryToReadOut(
738  dtCh.wheel(), dtCh.station(), dtCh.sector(), sl, ly, ch, dduId, rosId, robId, tdcId, channelId);
739 
740  // realCh = 0 if the channel exists, while realCh = 1 if it does not exist
741  if (realCh) {
742  int lybin = (4 * sl - 4) + ly;
743  (digiHistos[histoTag])[dtCh.rawId()]->setBinContent(ch, lybin, -1.);
744  }
745  }
746  }
747  }
748 }
749 
750 // Local Variables:
751 // show-trailing-whitespace: t
752 // truncate-lines: t
753 // End:
LuminosityBlockID id() const
Log< level::Info, true > LogVerbatim
T getUntrackedParameter(std::string const &, T const &) const
int defaultTmax
Definition: DTDigiTask.h:138
bool doStaticBooking
Definition: DTDigiTask.h:141
MonitorElement * bookFloat(TString const &name, FUNC onbooking=NOOP())
Definition: DQMStore.h:80
const edm::EventSetup & c
void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override
Definition: DTDigiTask.cc:104
void channelsMap(const DTChamberId &dtCh, std::string histoTag)
To map real channels.
Definition: DTDigiTask.cc:728
bool tpMode
Definition: DTDigiTask.h:159
bool doLayerTimeBoxes
Definition: DTDigiTask.h:166
bool filterSyncNoise
Definition: DTDigiTask.h:161
const DTReadOutMapping * mapping
Definition: DTDigiTask.h:112
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
int maxTTMounts
Definition: DTDigiTask.h:154
const DTChamber * chamber(const DTChamberId &id) const
Return a DTChamber given its id.
Definition: DTGeometry.cc:90
DTChamberId chamberId() const
Return the corresponding ChamberId.
std::string topFolder() const
Definition: DTDigiTask.cc:720
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
edm::ESGetToken< DTStatusFlag, DTStatusFlagRcd > statusMapToken_
Definition: DTDigiTask.h:120
bool readTTrigDB
Definition: DTDigiTask.h:134
bool lookForSyncNoise
Definition: DTDigiTask.h:160
float kFactor
Definition: DTDigiTask.h:98
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
int get(int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId, float &t0mean, float &t0rms, DTTimeUnits::type unit) const
Definition: DTT0.cc:48
std::map< DTChamberId, int > hitMap
Definition: DTDigiTask.h:102
#define LogTrace(id)
constexpr std::array< uint8_t, layerIndexSize > layer
edm::ESGetToken< DTReadOutMapping, DTReadOutMappingRcd > readOutMapToken_
Definition: DTDigiTask.h:111
const DTStatusFlag * statusMap
Definition: DTDigiTask.h:121
DTDigiTask(const edm::ParameterSet &ps)
Constructor.
Definition: DTDigiTask.cc:36
void Fill(long long x)
bool getData(T &iHolder) const
Definition: EventSetup.h:122
U second(std::pair< T, U > const &p)
edm::EDGetTokenT< DTDigiCollection > dtDigiToken_
Definition: DTDigiTask.h:129
char const * label
bool checkNoisyChannels
Definition: DTDigiTask.h:147
bool isLocalRun
Definition: DTDigiTask.h:143
edm::ESGetToken< DTT0, DTT0Rcd > T0Token_
Definition: DTDigiTask.h:116
const std::vector< const DTSuperLayer * > & superLayers() const
Return the superlayers in the chamber.
Definition: DTChamber.cc:51
bool doInTimeOccupancies
Definition: DTDigiTask.h:157
edm::ESGetToken< DTGeometry, MuonGeometryRecord > muonGeomToken_
Definition: DTDigiTask.h:109
bool doNoiseOccupancies
Definition: DTDigiTask.h:156
Transition
Definition: Transition.h:12
std::map< std::string, std::map< int, MonitorElement * > > wheelHistos
Definition: DTDigiTask.h:124
int nevents
Definition: DTDigiTask.h:89
const DTTtrig * tTrigMap
Definition: DTDigiTask.h:115
int resetCycle
Definition: DTDigiTask.h:145
int inTimeHitsUpperBound
Definition: DTDigiTask.h:152
int defaultTTrig
Definition: DTDigiTask.h:149
float tTrig
tTrig from the DB
Definition: DTDigiTask.h:96
int tMax
no needs to be precise. Value from PSets will always be used
Definition: DTDigiTask.h:92
int geometryToReadOut(int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId, int &dduId, int &rosId, int &robId, int &tdcId, int &channelId) const
int superlayer() const
Return the superlayer number (deprecated method name)
int tdcPedestal
Definition: DTDigiTask.h:164
const DTGeometry * muonGeom
Definition: DTDigiTask.h:110
bool doAllHitsOccupancies
Definition: DTDigiTask.h:155
int maxTDCHits
Definition: DTDigiTask.h:93
int get(int wheelId, int stationId, int sectorId, int slId, float &tTrig, float &tTrms, float &kFact, DTTimeUnits::type unit) const
get content
Definition: DTTtrig.cc:59
bool subtractT0
Definition: DTDigiTask.h:136
void bookHistos(DQMStore::IBooker &ibooker, const DTSuperLayerId &dtSL, std::string folder, std::string histoTag)
Book the ME.
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:177
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: DTDigiTask.cc:126
LuminosityBlockNumber_t luminosityBlock() const
std::vector< DigiType >::const_iterator const_iterator
int timeBoxGranularity
Definition: DTDigiTask.h:153
int cellStatus(int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId, bool &noiseFlag, bool &feMask, bool &tdcMask, bool &trigMask, bool &deadFlag, bool &nohvFlag) const
get content
Definition: DTStatusFlag.h:90
~DTDigiTask() override
Destructor.
Definition: DTDigiTask.cc:100
std::set< DTChamberId > syncNoisyChambers
Definition: DTDigiTask.h:103
int syncNumTot
Definition: DTDigiTask.h:104
MonitorElement * nEventMonitor
Definition: DTDigiTask.h:169
int inTimeHitsLowerBound
Definition: DTDigiTask.h:151
float tTrigRMS
Definition: DTDigiTask.h:97
int sector() const
Definition: DTChamberId.h:49
void beginLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &context) override
To reset the MEs.
Definition: DTDigiTask.cc:190
edm::ESGetToken< DTTtrig, DTTtrigRcd > TtrigToken_
Definition: DTDigiTask.h:114
const DTLayer * layer(const DTLayerId &id) const
Return a layer given its id.
Definition: DTGeometry.cc:96
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
int station() const
Return the station number.
Definition: DTChamberId.h:42
std::map< std::string, std::map< uint32_t, MonitorElement * > > digiHistos
Definition: DTDigiTask.h:123
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:39
std::string triggerSource()
get the L1A source
Definition: DTDigiTask.cc:699
const DTT0 * t0Map
Definition: DTDigiTask.h:117
edm::Handle< LTCDigiCollection > ltcdigis
Definition: DTDigiTask.h:107
bool sliceTestMode
Definition: DTDigiTask.h:163
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
TimeValue_t value() const
Definition: Timestamp.h:45
edm::Timestamp time() const
Definition: EventBase.h:60
void analyze(const edm::Event &e, const edm::EventSetup &c) override
Analyze.
Definition: DTDigiTask.cc:444
edm::EDGetTokenT< LTCDigiCollection > ltcDigiCollectionToken_
Definition: DTDigiTask.h:131
Definition: Run.h:45