CMS 3D CMS Logo

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