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  * $Date: 2010/01/05 10:14:40 $
5  * $Revision: 1.62 $
6  * \author M. Zanetti - INFN Padova
7  *
8  */
9 
11 
12 // Framework
14 
15 // Digis
20 
21 // Geometry
26 
27 // T0s
32 
35 
39 
40 #include <sstream>
41 #include <math.h>
42 
43 using namespace edm;
44 using namespace std;
45 
46 
47 
48 // Contructor
50  // switch for the verbosity
51  LogTrace("DTDQM|DTMonitorModule|DTDigiTask") << "[DTDigiTask]: Constructor" << endl;
52 
53  // The label to retrieve the digis
54  dtDigiLabel = ps.getParameter<InputTag>("dtDigiLabel");
55  // Read the configuration parameters
56  maxTDCHits = ps.getUntrackedParameter<int>("maxTDCHitsPerChamber",30000);
57  // Set to true to read the ttrig from DB (useful to determine in-time and out-of-time hits)
58  readTTrigDB = ps.getUntrackedParameter<bool>("readDB", false);
59  // Set to true to subtract t0 from test pulses
60  subtractT0 = ps.getParameter<bool>("performPerWireT0Calibration");
61  // Tmax value (TDC counts)
62  defaultTmax = ps.getParameter<int>("defaultTmax");
63  // Switch from static to dinamic histo booking
64  doStaticBooking = ps.getUntrackedParameter<bool>("staticBooking", true);
65  // Switch for local/global runs
66  isLocalRun = ps.getUntrackedParameter<bool>("localrun", true);
67  // Setting for the reset of the ME after n (= ResetCycle) luminosity sections
68  resetCycle = ps.getUntrackedParameter<int>("ResetCycle", 3);
69  // Check the DB of noisy channels
70  checkNoisyChannels = ps.getUntrackedParameter<bool>("checkNoisyChannels","false");
71  // Default TTrig to be used when not reading the TTrig DB
72  defaultTTrig = ps.getParameter<int>("defaultTtrig");
73  inTimeHitsLowerBound = ps.getParameter<int>("inTimeHitsLowerBound");
74  inTimeHitsUpperBound = ps.getParameter<int>("inTimeHitsUpperBound");
75  timeBoxGranularity = ps.getUntrackedParameter<int>("timeBoxGranularity",4);
76  maxTDCCounts = ps.getUntrackedParameter<int>("maxTDCCounts", 6400);
77 
78  doAllHitsOccupancies = ps.getUntrackedParameter<bool>("doAllHitsOccupancies", true);
79  doNoiseOccupancies = ps.getUntrackedParameter<bool>("doNoiseOccupancies", false);
80  doInTimeOccupancies = ps.getUntrackedParameter<bool>("doInTimeOccupancies", false);
81 
82  // switch on the mode for running on test pulses (different top folder)
83  tpMode = ps.getUntrackedParameter<bool>("testPulseMode", false);
84  // switch on/off the filtering of synchronous noise events (cutting on the # of digis)
85  // time-boxes and occupancy plots are not filled and summary plots are created to report the problem
86  filterSyncNoise = ps.getUntrackedParameter<bool>("filterSyncNoise", false);
87  // look for synch noisy events, produce histograms but do not filter them
88  lookForSyncNoise = ps.getUntrackedParameter<bool>("lookForSyncNoise", false);
89  // switch on production of time-boxes with layer granularity
90  doLayerTimeBoxes = ps.getUntrackedParameter<bool>("doLayerTimeBoxes", false);
91 
92  dbe = edm::Service<DQMStore>().operator->();
93 
94  syncNumTot = 0;
95  syncNum = 0;
96 
97 }
98 
99 
100 
101 // destructor
103  LogTrace("DTDQM|DTMonitorModule|DTDigiTask") << "DTDigiTask: analyzed " << nevents << " events" << endl;
104 
105 }
106 
107 
108 
109 
111  LogTrace("DTDQM|DTMonitorModule|DTDigiTask") <<"[DTDigiTask] endjob called!"<<endl;
112 
113 }
114 
115 
116 
117 
119  LogTrace("DTDQM|DTMonitorModule|DTDigiTask") <<"[DTDigiTask]: BeginJob"<<endl;
120 
121  nevents = 0;
122 }
123 
124 
125 void DTDigiTask::beginRun(const edm::Run& run, const edm::EventSetup& context) {
126  LogTrace("DTDQM|DTMonitorModule|DTDigiTask") << "[DTDigiTask]: begin run" << endl;
127 
128  // Get the geometry
129  context.get<MuonGeometryRecord>().get(muonGeom);
130 
131  // tTrig
132  if (readTTrigDB)
133  context.get<DTTtrigRcd>().get(tTrigMap);
134  // t0s
135  if (subtractT0)
136  context.get<DTT0Rcd>().get(t0Map);
137  // FIXME: tMax (not yet from the DB)
138  tMax = defaultTmax;
139 
140  // ----------------------------------------------------------------------
141  if(doStaticBooking) { // Static histo booking
142  // book the event counter
143  dbe->setCurrentFolder(topFolder());
144  nEventMonitor = dbe->bookFloat("nProcessedEvents");
145  for(int wh = -2; wh <= 2; ++wh) { // loop over wheels
146  if(doAllHitsOccupancies) bookHistos(wh,string("Occupancies"),"OccupancyAllHits");
147  if(doNoiseOccupancies) bookHistos(wh,string("Occupancies"),"OccupancyNoiseHits");
148  if(doInTimeOccupancies) bookHistos(wh,string("Occupancies"),"OccupancyInTimeHits");
149 
150  if(lookForSyncNoise || filterSyncNoise) {
151  bookHistos(wh,string("SynchNoise"),"SyncNoiseEvents");
152  bookHistos(wh,string("SynchNoise"),"SyncNoiseChambs");
153  }
154 
155  for(int st = 1; st <= 4; ++st) { // loop over stations
156  for(int sect = 1; sect <= 14; ++sect) { // loop over sectors
157  if((sect == 13 || sect == 14) && st != 4) continue;
158  // Get the chamber ID
159  const DTChamberId dtChId(wh,st,sect);
160 
161  // Occupancies
162  if (doAllHitsOccupancies)
163  bookHistos(dtChId,string("Occupancies"),"OccupancyAllHits_perCh");
164  if(doNoiseOccupancies)
165  bookHistos(dtChId,string("Occupancies"),"OccupancyNoise_perCh");
166  if(doInTimeOccupancies)
167  bookHistos(dtChId,string("Occupancies"),"OccupancyInTimeHits_perCh");
168 
169 
170 
171 
172  for(int sl = 1; sl <= 3; ++sl) { // Loop over SLs
173  if(st == 4 && sl == 2) continue;
174  const DTSuperLayerId dtSLId(wh,st,sect,sl);
175  if(isLocalRun) {
176  bookHistos(dtSLId,string("TimeBoxes"),"TimeBox");
177  } else {
178  // TimeBoxes for different triggers
179  bookHistos(dtSLId,string("TimeBoxes"),"TimeBoxDTonly");
180  bookHistos(dtSLId,string("TimeBoxes"),"TimeBoxNoDT");
181  bookHistos(dtSLId,string("TimeBoxes"),"TimeBoxDTalso");
182  }
183  }
184  }
185  }
186  }
187  }
188 }
189 
190 
191 
192 
193 void DTDigiTask::beginLuminosityBlock(LuminosityBlock const& lumiSeg, EventSetup const& context) {
194 
195  LogTrace("DTDQM|DTMonitorModule|DTDigiTask") << "[DTDigiTask]: Begin of LS transition" << endl;
196 
197  // Reset the MonitorElements every n (= ResetCycle) Lumi Blocks
198  int lumiBlock = lumiSeg.id().luminosityBlock();
199  if(lumiBlock % resetCycle == 0) {
200  LogVerbatim("DTDQM|DTMonitorModule|DTDigiTask")
201  <<"[DTDigiTask]: Reset at the LS transition : "
202  << lumiBlock << endl;
203  // Loop over all ME
204  map<string,map<uint32_t,MonitorElement*> >::const_iterator histosIt = digiHistos.begin();
205  map<string,map<uint32_t,MonitorElement*> >::const_iterator histosEnd = digiHistos.end();
206  for(;histosIt != histosEnd ; ++histosIt) {
207  map<uint32_t,MonitorElement*>::const_iterator histoIt = (*histosIt).second.begin();
208  map<uint32_t,MonitorElement*>::const_iterator histoEnd = (*histosIt).second.end();
209  for(;histoIt != histoEnd; ++histoIt) { (*histoIt).second->Reset(); }
210  }
211 
212  // loop over wheel summaries
213  map<string,map<int,MonitorElement*> >::const_iterator whHistosIt = wheelHistos.begin();
214  map<string,map<int,MonitorElement*> >::const_iterator whHistosEnd = wheelHistos.end();
215  for(; whHistosIt != whHistosEnd ; ++whHistosIt) {
216  if ((*whHistosIt).first.find("Sync") == string::npos) { // FIXME skips synch noise plots
217  map<int,MonitorElement*>::const_iterator histoIt = (*whHistosIt).second.begin();
218  map<int,MonitorElement*>::const_iterator histoEnd = (*whHistosIt).second.end();
219  for(;histoIt != histoEnd; ++histoIt) { (*histoIt).second->Reset(); }
220  }
221  }
222  }
223 
224 }
225 
226 
227 
228 
229 void DTDigiTask::bookHistos(const DTSuperLayerId& dtSL, string folder, string histoTag) {
230  // set the folder
231  stringstream wheel; wheel << dtSL.wheel();
232  stringstream station; station << dtSL.station();
233  stringstream sector; sector << dtSL.sector();
234  stringstream superLayer; superLayer << dtSL.superlayer();
235  dbe->setCurrentFolder(topFolder() + "Wheel" + wheel.str() +
236  "/Sector" + sector.str() +
237  "/Station" + station.str());
238 
239  // Build the histo name
240  string histoName = histoTag
241  + "_W" + wheel.str()
242  + "_St" + station.str()
243  + "_Sec" + sector.str()
244  + "_SL" + superLayer.str();
245 
246  LogTrace("DTDQM|DTMonitorModule|DTDigiTask")
247  << "[DTDigiTask]: booking SL histo:" << histoName
248  << " (tag: " << histoTag
249  << ") folder: " << topFolder() + "Wheel" + wheel.str() +
250  "/Station" + station.str() +
251  "/Sector" + sector.str() + "/" + folder << endl;
252 
253 
254  // ttrig and rms are TDC counts
255  if ( readTTrigDB )
256  tTrigMap->get(dtSL, tTrig, tTrigRMS, kFactor, DTTimeUnits::counts);
257  else tTrig = defaultTTrig;
258 
259 
260  if ( folder == "TimeBoxes") {
261  string histoTitle = histoName + " (TDC Counts)";
262 
263  if (!readTTrigDB) {
264  (digiHistos[histoTag])[dtSL.rawId()] =
265  dbe->book1D(histoName,histoTitle, maxTDCCounts/timeBoxGranularity, 0, maxTDCCounts);
266  if(doLayerTimeBoxes) { // Book TimeBoxes per layer
267  for(int layer = 1; layer != 5; ++layer) {
268  DTLayerId layerId(dtSL, layer);
269  stringstream layerHistoName; layerHistoName << histoName << "_L" << layer;
270  (digiHistos[histoTag])[layerId.rawId()] =
271  dbe->book1D(layerHistoName.str(),layerHistoName.str(), maxTDCCounts/timeBoxGranularity, 0, maxTDCCounts);
272  }
273  }
274  }
275  else {
276  (digiHistos[histoTag])[dtSL.rawId()] =
277  dbe->book1D(histoName,histoTitle, 3*tMax/timeBoxGranularity, tTrig-tMax, tTrig+2*tMax);
278  if(doLayerTimeBoxes) {
279  // Book TimeBoxes per layer
280  for(int layer = 1; layer != 5; ++layer) {
281  DTLayerId layerId(dtSL, layer);
282  stringstream layerHistoName; layerHistoName << histoName << "_L" << layer;
283  (digiHistos[histoTag])[layerId.rawId()] =
284  dbe->book1D(layerHistoName.str(),layerHistoName.str(), 3*tMax/timeBoxGranularity, tTrig-tMax, tTrig+2*tMax);
285  }
286  }
287  }
288  }
289 
290  if ( folder == "CathodPhotoPeaks" ) {
291  dbe->setCurrentFolder(topFolder() + "Wheel" + wheel.str() +
292  "/Sector" + sector.str() +
293  "/Station" + station.str() + "/" + folder);
294  (digiHistos[histoTag])[dtSL.rawId()] = dbe->book1D(histoName,histoName,500,0,1000);
295  }
296 
297 }
298 
299 
300 
301 
302 void DTDigiTask::bookHistos(const DTChamberId& dtCh, string folder, string histoTag) {
303  // set the current folder
304  stringstream wheel; wheel << dtCh.wheel();
305  stringstream station; station << dtCh.station();
306  stringstream sector; sector << dtCh.sector();
307  dbe->setCurrentFolder(topFolder() + "Wheel" + wheel.str() +
308  "/Sector" + sector.str() +
309  "/Station" + station.str());
310 
311  // build the histo name
312  string histoName = histoTag
313  + "_W" + wheel.str()
314  + "_St" + station.str()
315  + "_Sec" + sector.str();
316 
317 
318  LogTrace("DTDQM|DTMonitorModule|DTDigiTask")
319  << "[DTDigiTask]: booking chamber histo:"
320  << " (tag: " << histoTag
321  << ") folder: " << topFolder() + "Wheel" + wheel.str() +
322  "/Station" + station.str() +
323  "/Sector" + sector.str() << endl;
324 
325 
326  if (folder == "Occupancies") {
327 
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; superLayer << (*suly)->id().superlayer();
342 
343  while(ly != lyend) {
344  nWires = muonGeom->layer((*ly)->id())->specificTopology().channels();
345  firstWire = muonGeom->layer((*ly)->id())->specificTopology().firstChannel();
346  stringstream layer; layer << (*ly)->id().layer();
347  string histoName_layer = histoName + "_SL" + superLayer.str() + "_L" + layer.str();
348  if(histoTag == "OccupancyAllHits_perL"
349  || histoTag == "OccupancyNoise_perL"
350  || histoTag == "OccupancyInTimeHits_perL")
351  (digiHistos[histoTag])[(*ly)->id().rawId()] = dbe->book1D(histoName_layer,histoName_layer,nWires,firstWire,nWires+firstWire);
352  ++ly;
353  if((nWires+firstWire) > nWires_max) nWires_max = (nWires+firstWire);
354 
355  }
356  ++suly;
357  }
358 
359  if(histoTag != "OccupancyAllHits_perL"
360  && histoTag != "OccupancyNoise_perL"
361  && histoTag != "OccupancyInTimeHits_perL"){
362  // Set the title to show the time interval used (only if unique == not from DB)
363  string histoTitle = histoName;
364  if(!readTTrigDB && histoTag == "OccupancyInTimeHits_perCh") {
365  stringstream title;
366  int inTimeHitsLowerBoundCorr = int(round(defaultTTrig)) - inTimeHitsLowerBound;
367  int inTimeHitsUpperBoundCorr = int(round(defaultTTrig)) + defaultTmax + inTimeHitsUpperBound;
368  title << "Occ. digis in time [" << inTimeHitsLowerBoundCorr << ", "
369  << inTimeHitsUpperBoundCorr << "] (TDC counts)";
370  histoTitle = title.str();
371  }
372  (digiHistos[histoTag])[dtCh.rawId()] = dbe->book2D(histoName,histoTitle,nWires_max,1,nWires_max+1,12,0,12);
373 
374  for(int i=1;i<=12;i++) {
375  if(i<5){
376  stringstream layer;
377  string layer_name;
378  layer<<i;
379  layer>>layer_name;
380  string label="SL1: L"+layer_name;
381  (digiHistos[histoTag])[dtCh.rawId()]->setBinLabel(i,label,2);
382  }
383  else if(i>4 && i<9){
384  stringstream layer;
385  string layer_name;
386  layer<<(i-4);
387  layer>>layer_name;
388  string label="SL2: L"+layer_name;
389  (digiHistos[histoTag])[dtCh.rawId()]->setBinLabel(i,label,2);
390  }
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 
405 
406 
407 void DTDigiTask::bookHistos(const int wheelId, string folder, string histoTag) {
408  // Set the current folder
409  stringstream wheel; wheel << wheelId;
410 
411 
412  // build the histo name
413  string histoName = histoTag + "_W" + wheel.str();
414 
415 
416  LogTrace("DTDQM|DTMonitorModule|DTDigiTask")
417  << "[DTDigiTask]: booking wheel histo:" << histoName
418  << " (tag: " << histoTag
419  << ") folder: " << topFolder() + "Wheel" + wheel.str() + "/" <<endl;
420 
421  if(folder == "Occupancies") {
422  dbe->setCurrentFolder(topFolder() + "Wheel" + wheel.str());
423  string histoTitle = "# of digis per chamber WHEEL: "+wheel.str();
424  (wheelHistos[histoTag])[wheelId] = dbe->book2D(histoName,histoTitle,12,1,13,4,1,5);
425  (wheelHistos[histoTag])[wheelId]->setBinLabel(1,"MB1",2);
426  (wheelHistos[histoTag])[wheelId]->setBinLabel(2,"MB2",2);
427  (wheelHistos[histoTag])[wheelId]->setBinLabel(3,"MB3",2);
428  (wheelHistos[histoTag])[wheelId]->setBinLabel(4,"MB4",2);
429  (wheelHistos[histoTag])[wheelId]->setAxisTitle("sector",1);
430  } else if(folder == "SynchNoise") {
431  dbe->setCurrentFolder("DT/05-Noise/SynchNoise");
432  if (histoTag== "SyncNoiseEvents") {
433  string histoTitle = "# of Syncronous-noise events WHEEL: "+wheel.str();
434  (wheelHistos[histoTag])[wheelId] = dbe->book2D(histoName,histoTitle,12,1,13,4,1,5);
435  (wheelHistos[histoTag])[wheelId]->setBinLabel(1,"MB1",2);
436  (wheelHistos[histoTag])[wheelId]->setBinLabel(2,"MB2",2);
437  (wheelHistos[histoTag])[wheelId]->setBinLabel(3,"MB3",2);
438  (wheelHistos[histoTag])[wheelId]->setBinLabel(4,"MB4",2);
439  (wheelHistos[histoTag])[wheelId]->setAxisTitle("sector",1);
440  } else if (histoTag== "SyncNoiseChambs") {
441  string histoTitle = "# of Synchornous-noise chamb per evt. WHEEL: "+wheel.str();
442  (wheelHistos[histoTag])[wheelId] = dbe->book1D(histoName,histoTitle,50,0.5,50.5);
443  (wheelHistos[histoTag])[wheelId]->setAxisTitle("# of noisy chambs.",1);
444  (wheelHistos[histoTag])[wheelId]->setAxisTitle("# of evts.",2);
445  }
446  }
447 
448 }
449 
450 
451 
452 // does the real job
454  nevents++;
455  nEventMonitor->Fill(nevents);
456  if (nevents%1000 == 0) {
457  LogTrace("DTDQM|DTMonitorModule|DTDigiTask") << "[DTDigiTask] Analyze #Run: " << event.id().run()
458  << " #Event: " << event.id().event() << endl;
459  }
460 
461  // Get the ingredients from the event
462 
463  // Digi collection
465  event.getByLabel(dtDigiLabel, dtdigis);
466 
467  // LTC digis
468  if (!isLocalRun) event.getByType(ltcdigis);
469 
470  // Status map (for noisy channels)
472  if(checkNoisyChannels) {
473  // Get the map of noisy channels
474  c.get<DTStatusFlagRcd>().get(statusMap);
475  }
476 
477  string histoTag;
478 
479 
480  // Check if the digi container is empty
481  if(dtdigis->begin() == dtdigis->end()) {
482  LogTrace("DTDQM|DTMonitorModule|DTDigiTask") << "Event " << nevents << " empty." << endl;
483  }
484 
485  if (lookForSyncNoise || filterSyncNoise) { // dosync
486  // Count the # of digis per chamber
488  for (dtLayerId_It=dtdigis->begin(); dtLayerId_It!=dtdigis->end(); dtLayerId_It++) {
489  DTChamberId chId = ((*dtLayerId_It).first).chamberId();
490  if(hitMap.find(chId) == hitMap.end()) {// new chamber
491  hitMap[chId] = 0;
492  }
493  hitMap[chId] += (((*dtLayerId_It).second).second - ((*dtLayerId_It).second).first);
494  }
495 
496 
497 
498  // check chamber with # of digis above threshold and flag them as noisy
499  map<DTChamberId,int>::const_iterator hitMapIt = hitMap.begin();
500  map<DTChamberId,int>::const_iterator hitMapEnd = hitMap.end();
501 
502  map<int,int> chMap;
503 
504  for (; hitMapIt != hitMapEnd; ++hitMapIt) {
505  if((hitMapIt->second) > maxTDCHits) {
506 
507  DTChamberId chId = hitMapIt->first;
508  int wh = chId.wheel();
509 
510  LogTrace("DTDQM|DTMonitorModule|DTDigiTask") << "[DTDigiTask] Synch noise in chamber: " << chId
511  << " with # digis: " << hitMapIt->second << endl;
512 
513  if(chMap.find(wh) == chMap.end()) { chMap[wh] = 0; }
514  chMap[wh]++ ;
515 
516  syncNoisyChambers.insert(chId);
517 
518  wheelHistos["SyncNoiseEvents"][wh]->Fill(chId.sector(),chId.station());
519 
520  // Only needed in case of ratio map not used right now
521  // FIXME check and optimize
522  // nSynchNoiseEvents[iter->first]++;
523  // FIXME: should update all chambers each event
524  // wheelHistos["SyncNoiseEvents"][(*iter).first.wheel()]->setBinContent((*iter).first.sector(),(*iter).first.station(),
525  // (double)nSynchNoiseEvents[iter->first]/(double)nevents);
526 
527  }
528  }
529 
530  // fill # of noisy ch per wheel plot
531  map<int,int>::const_iterator chMapIt = chMap.begin();
532  map<int,int>::const_iterator chMapEnd = chMap.end();
533  for (; chMapIt != chMapEnd; ++chMapIt) {
534  wheelHistos["SyncNoiseChambs"][(*chMapIt).first]->Fill((*chMapIt).second);
535  }
536 
537  // clear the map of # of digis per chamber: not needed anymore
538  hitMap.clear();
539 
540  if (syncNoisyChambers.size() != 0) {
541  LogVerbatim("DTDQM|DTMonitorModule|DTDigiTask") << "[DTDigiTask] Synch Noise in event: " << nevents;
542  if(filterSyncNoise) LogVerbatim("DTDQM|DTMonitorModule|DTDigiTask") << "\tnoisy time-boxes and occupancy will not be filled!" << endl;
543  syncNumTot++;
544  syncNum++;
545  }
546 
547  // Logging of "large" synch Noisy events in private DQM
548  if (syncNoisyChambers.size() > 3) {
549  time_t eventTime = time_t(event.time().value()>>32);
550 
551  LogVerbatim("DTDQM|DTMonitorModule|DTDigiTask|DTSynchNoise")
552  << "[DTDigiTask] At least 4 Synch Noisy chambers in Run : " << event.id().run()
553  << " Lumi : " << event.id().luminosityBlock()
554  << " Event : " << event.id().event()
555  << " at time : " << ctime(&eventTime) << endl;
556 
557  set<DTChamberId>::const_iterator chIt = syncNoisyChambers.begin();
558  set<DTChamberId>::const_iterator chEnd = syncNoisyChambers.end();
559 
560  stringstream synchNoisyCh;
561  for (;chIt!=chEnd;++chIt) { synchNoisyCh << " " << (*chIt); }
562  LogVerbatim("DTDQM|DTMonitorModule|DTDigiTask|DTSynchNoise") <<
563  "[DTDigiTask] Chamber List :" << synchNoisyCh.str() << endl;
564 
565  }
566 
567 
568  if (nevents%1000 == 0) {
569  LogVerbatim("DTDQM|DTMonitorModule|DTDigiTask") << (syncNumTot*100./nevents) << "% sync noise events since the beginning \n"
570  << (syncNum*0.1) << "% sync noise events in the last 1000 events " << endl;
571  syncNum = 0;
572  }
573  }
574 
575  bool isSyncNoisy = false;
576 
578  for (dtLayerId_It=dtdigis->begin(); dtLayerId_It!=dtdigis->end(); ++dtLayerId_It) { // Loop over layers
579  isSyncNoisy = false;
580  // check if chamber labeled as synch noisy
581  if (filterSyncNoise) {
582  DTChamberId chId = ((*dtLayerId_It).first).chamberId();
583  if(syncNoisyChambers.find(chId) != syncNoisyChambers.end()) {
584  isSyncNoisy = true;
585  }
586  }
587 
588  for (DTDigiCollection::const_iterator digiIt = ((*dtLayerId_It).second).first;
589  digiIt!=((*dtLayerId_It).second).second; ++digiIt) { // Loop over all digis
590 
591  bool isNoisy = false;
592  bool isFEMasked = false;
593  bool isTDCMasked = false;
594  bool isTrigMask = false;
595  bool isDead = false;
596  bool isNohv = false;
597  if(checkNoisyChannels) {
598  const DTWireId wireId(((*dtLayerId_It).first), (*digiIt).wire());
599  statusMap->cellStatus(wireId, isNoisy, isFEMasked, isTDCMasked, isTrigMask, isDead, isNohv);
600  }
601 
602 
603 
604  // Get the useful IDs
605  const DTSuperLayerId dtSLId = ((*dtLayerId_It).first).superlayerId();
606  uint32_t indexSL = dtSLId.rawId();
607  const DTChamberId dtChId = dtSLId.chamberId();
608  uint32_t indexCh = dtChId.rawId();
609  int layer_number=((*dtLayerId_It).first).layer();
610  int superlayer_number=dtSLId.superlayer();
611  const DTLayerId dtLId = (*dtLayerId_It).first;
612 
613  // Read the ttrig DB or set a rough value from config
614  // ttrig and rms are TDC counts
615  if (readTTrigDB)
616  tTrigMap->get( ((*dtLayerId_It).first).superlayerId(),
617  tTrig, tTrigRMS, kFactor, DTTimeUnits::counts);
618  else tTrig = defaultTTrig;
619 
620  int inTimeHitsLowerBoundCorr = int(round(tTrig)) - inTimeHitsLowerBound;
621  int inTimeHitsUpperBoundCorr = int(round(tTrig)) + tMax + inTimeHitsUpperBound;
622 
623  float t0; float t0RMS;
624  int tdcTime = (*digiIt).countsTDC();
625 
626  if (subtractT0) {
627  const DTWireId dtWireId(((*dtLayerId_It).first), (*digiIt).wire());
628  // t0s and rms are TDC counts
629  t0Map->get(dtWireId, t0, t0RMS, DTTimeUnits::counts) ;
630  tdcTime += int(round(t0));
631  }
632 
633 
634 
635  // Fill Time-Boxes
636  // NOTE: avoid to fill TB and PhotoPeak with noise. Occupancy are filled anyway
637  if (( !isNoisy ) && (!isSyncNoisy)) { // Discard noisy channels
638  // TimeBoxes per SL
639  histoTag = "TimeBox" + triggerSource();
640  if (digiHistos[histoTag].find(indexSL) == digiHistos[histoTag].end())
641  bookHistos( dtSLId, string("TimeBoxes"), histoTag );
642  (digiHistos.find(histoTag)->second).find(indexSL)->second->Fill(tdcTime);
643  if(doLayerTimeBoxes)
644  (digiHistos.find(histoTag)->second).find((*dtLayerId_It).first.rawId())->second->Fill(tdcTime);
645  // FIXME: remove the time distribution for the after-pulses
646  // 2nd - 1st (CathodPhotoPeak) per SL
647  // if ( (*digiIt).number() == 1 ) {
648 
649  // DTDigiCollection::const_iterator firstDigiIt = digiIt;
650  // firstDigiIt--;
651 
652  // histoTag = "CathodPhotoPeak";
653  // if (digiHistos[histoTag].find(indexSL) == digiHistos[histoTag].end())
654  // bookHistos( dtSLId, string("CathodPhotoPeaks"), histoTag );
655  // (digiHistos.find(histoTag)->second).find(indexSL)->second->Fill((*digiIt).countsTDC()-
656  // (*firstDigiIt).countsTDC());
657  // }
658  }
659 
660  // Fill Occupancies
661  if (!isSyncNoisy) { // Discard synch noisy channels
662 
663  if (doAllHitsOccupancies) { // fill occupancies for all hits
664  //Occupancies per chamber & layer
665  histoTag = "OccupancyAllHits_perCh";
666  map<uint32_t, MonitorElement*>::const_iterator mappedHisto =
667  digiHistos[histoTag].find(indexCh);
668  if (mappedHisto == digiHistos[histoTag].end()) { // dynamic booking
669  bookHistos(dtChId, string("Occupancies"), histoTag);
670  mappedHisto = digiHistos[histoTag].find(indexCh);
671  }
672  mappedHisto->second->Fill((*digiIt).wire(),(layer_number+(superlayer_number-1)*4)-1);
673 
674 
675  // Fill the chamber occupancy
676  histoTag = "OccupancyAllHits";
677  map<int, MonitorElement*>::const_iterator histoPerWheel =
678  wheelHistos[histoTag].find(dtChId.wheel());
679  if(histoPerWheel == wheelHistos[histoTag].end()) { // dynamic booking
680  bookHistos(dtChId.wheel(), string("Occupancies"), histoTag);
681  histoPerWheel = wheelHistos[histoTag].find(dtChId.wheel());
682  }
683  histoPerWheel->second->Fill(dtChId.sector(),dtChId.station()); // FIXME: normalize to # of layers
684 
685 
686  }
687 
688  if(doNoiseOccupancies) { // fill occupancies for hits before the ttrig
689  if (tdcTime < inTimeHitsLowerBoundCorr ) {
690  // FIXME: what about tdcTime > inTimeHitsUpperBoundCorr ???
691 
692  // Noise: Before tTrig
693  //Occupancies Noise per chamber & layer
694  histoTag = "OccupancyNoise_perCh";
695  map<uint32_t, MonitorElement*>::const_iterator mappedHisto =
696  digiHistos[histoTag].find(indexCh);
697  if(mappedHisto == digiHistos[histoTag].end()) {
698  bookHistos(dtChId, string("Occupancies"), histoTag);
699  mappedHisto = digiHistos[histoTag].find(indexCh);
700  }
701  mappedHisto->second->Fill((*digiIt).wire(),
702  (layer_number+(superlayer_number-1)*4)-1);
703 
704  // Fill the chamber occupancy
705  histoTag = "OccupancyNoise";
706  map<int, MonitorElement*>::const_iterator histoPerWheel =
707  wheelHistos[histoTag].find(dtChId.wheel());
708  if(histoPerWheel == wheelHistos[histoTag].end()) { // dynamic booking
709  bookHistos(dtChId.wheel(), string("Occupancies"), histoTag);
710  histoPerWheel = wheelHistos[histoTag].find(dtChId.wheel());
711  }
712  histoPerWheel->second->Fill(dtChId.sector(),dtChId.station()); // FIXME: normalize to # of layers
713 
714  }
715  }
716 
717  if(doInTimeOccupancies) { // fill occpunacies for in-time hits only
718  if (tdcTime > inTimeHitsLowerBoundCorr && tdcTime < inTimeHitsUpperBoundCorr) {
719  // Physical hits: within the time window
720 
721  //Occupancies Signal per chamber & layer
722  histoTag = "OccupancyInTimeHits_perCh";
723  map<uint32_t, MonitorElement*>::const_iterator mappedHisto =
724  digiHistos[histoTag].find(indexCh);
725  if(mappedHisto == digiHistos[histoTag].end()) {
726  bookHistos(dtChId, string("Occupancies"), histoTag);
727  mappedHisto = digiHistos[histoTag].find(indexCh);
728  }
729  mappedHisto->second->Fill((*digiIt).wire(),
730  (layer_number+(superlayer_number-1)*4)-1);
731 
732  // Fill the chamber occupancy
733  histoTag = "OccupancyInTimeHits";
734  map<int, MonitorElement*>::const_iterator histoPerWheel =
735  wheelHistos[histoTag].find(dtChId.wheel());
736  if(histoPerWheel == wheelHistos[histoTag].end()) { // dynamic booking
737  bookHistos(dtChId.wheel(), string("Occupancies"), histoTag);
738  histoPerWheel = wheelHistos[histoTag].find(dtChId.wheel());
739  }
740  histoPerWheel->second->Fill(dtChId.sector(),dtChId.station()); // FIXME: normalize to # of layers
741 
742  }
743  }
744  }
745  }
746  }
747 
748  syncNoisyChambers.clear();
749 }
750 
751 
753 
754  string l1ASource;
755 
756  if (!isLocalRun) {
757  for (std::vector<LTCDigi>::const_iterator ltc_it = ltcdigis->begin(); ltc_it != ltcdigis->end(); ltc_it++){
758  int otherTriggerSum=0;
759  for (int i = 1; i < 6; i++)
760  otherTriggerSum += int((*ltc_it).HasTriggered(i));
761 
762  if ((*ltc_it).HasTriggered(0) && otherTriggerSum == 0)
763  l1ASource = "DTonly";
764  else if (!(*ltc_it).HasTriggered(0))
765  l1ASource = "NoDT";
766  else if ((*ltc_it).HasTriggered(0) && otherTriggerSum > 0)
767  l1ASource = "DTalso";
768  }
769  }
770 
771  return l1ASource;
772 
773 }
774 
775 
776 string DTDigiTask::topFolder() const {
777 
778  if(tpMode) return string("DT/10-TestPulses/");
779  return string("DT/01-Digi/");
780 
781 }
782 
783 
784 
785 
787 
788 // To be used for ratio plots not used right now
789 // Update all histos for SynchNoise if needed
790 // if(lookForSyncNoise || filterSyncNoise) {
791 // //loop over chambers with synch noise events and update their entries in the histos
792 // for(map<DTChamberId, int>::const_iterator nEvPerch = nSynchNoiseEvents.begin();
793 // nEvPerch != nSynchNoiseEvents.end(); ++nEvPerch) {
794 // DTChamberId chId = (*nEvPerch).first;
795 // wheelHistos["SyncNoiseEvents"][chId.wheel()]->setBinContent(chId.sector(),chId.station(),
796 // (double)nSynchNoiseEvents[chId]/(double)nevents);
797 // }
798 // }
799 
800 }
LuminosityBlockID id() const
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
void beginRun(const edm::Run &, const edm::EventSetup &)
Definition: DTDigiTask.cc:125
void analyze(const edm::Event &e, const edm::EventSetup &c)
Analyze.
Definition: DTDigiTask.cc:453
void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &setup)
Definition: DTDigiTask.cc:786
const std::string & label
Definition: MVAComputer.cc:186
DTChamberId chamberId() const
Return the corresponding ChamberId.
std::string topFolder() const
Definition: DTDigiTask.cc:776
void beginLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &context)
To reset the MEs.
Definition: DTDigiTask.cc:193
void endJob()
Endjob.
Definition: DTDigiTask.cc:110
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:49
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
U second(std::pair< T, U > const &p)
void bookHistos(const DTSuperLayerId &dtSL, std::string folder, std::string histoTag)
Book the ME.
const std::vector< const DTSuperLayer * > & superLayers() const
Return the superlayers in the chamber.
Definition: DTChamber.cc:62
int nevents
#define end
Definition: vmac.h:38
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:102
int superlayer() const
Return the superlayer number (deprecated method name)
TimeValue_t value() const
Definition: Timestamp.cc:72
const T & get() const
Definition: EventSetup.h:55
LuminosityBlockNumber_t luminosityBlock() const
std::vector< DigiType >::const_iterator const_iterator
Definition: DTT0Rcd.h:9
int sector() const
Definition: DTChamberId.h:63
void beginJob()
BeginJob.
Definition: DTDigiTask.cc:118
int station() const
Return the station number.
Definition: DTChamberId.h:53
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:47
std::string triggerSource()
get the L1A source
Definition: DTDigiTask.cc:752
edm::Timestamp time() const
Definition: EventBase.h:57
Definition: Run.h:31