CMS 3D CMS Logo

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