CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripMonitorDigi.cc
Go to the documentation of this file.
1 // -*- c++ -*-
4 // Original Author: Dorian Kcira
5 // Created: Sat Feb 4 20:49:10 CET 2006
6 #include<fstream>
7 #include "TNamed.h"
27 
30 
31 #include "TMath.h"
33 
34 #include <iostream>
35 
41 
42 /* mia: but is there not a smarter way ?!?!?! */
43 const double NORBITS_PER_SECOND = 11223.;
44 
45 //--------------------------------------------------------------------------------------------
47  dqmStore_(edm::Service<DQMStore>().operator->()),
48  conf_(iConfig),
49  show_mechanical_structure_view(true),
50  show_readout_view (false),
51  show_control_view (false),
52  select_all_detectors (true),
53  reset_each_run (false),
54  folder_organizer(),
55  m_cacheID_(0)
56 {
57  firstEvent = -1;
58  eventNb = 0;
59 
60  // Detector Partitions
61  SubDetPhasePartMap["TIB"] = "TI";
62  SubDetPhasePartMap["TID__MINUS"] = "TI";
63  SubDetPhasePartMap["TID__PLUS"] = "TI";
64  SubDetPhasePartMap["TOB"] = "TO";
65  SubDetPhasePartMap["TEC__MINUS"] = "TM";
66  SubDetPhasePartMap["TEC__PLUS"] = "TP";
67 
68  topFolderName_ = conf_.getParameter<std::string>("TopFolderName");
69 
70  // get Digi Producer List
71  digiProducerList = conf_.getParameter<std::vector<edm::InputTag> >("DigiProducersList");
72  for (auto const& tag : digiProducerList) {
74  }
75 
76  //get on/off option for every cluster from cfi
77  edm::ParameterSet ParametersNumberOfDigis = conf_.getParameter<edm::ParameterSet>("TH1NumberOfDigis");
78  layerswitchnumdigison = ParametersNumberOfDigis.getParameter<bool>("layerswitchon");
79  moduleswitchnumdigison = ParametersNumberOfDigis.getParameter<bool>("moduleswitchon");
80 
81  edm::ParameterSet ParametersNumberOfDigisPerStrip = conf_.getParameter<edm::ParameterSet>("TH1NumberOfDigisPerStrip");
82  moduleswitchnumdigispstripon = ParametersNumberOfDigisPerStrip.getParameter<bool>("moduleswitchon");
83 
84  edm::ParameterSet ParametersADCsHottestStrip = conf_.getParameter<edm::ParameterSet>("TH1ADCsHottestStrip");
85  layerswitchadchotteston = ParametersADCsHottestStrip.getParameter<bool>("layerswitchon");
86  moduleswitchadchotteston = ParametersADCsHottestStrip.getParameter<bool>("moduleswitchon");
87 
88  edm::ParameterSet ParametersADCsCoolestStrip = conf_.getParameter<edm::ParameterSet>("TH1ADCsCoolestStrip");
89  layerswitchadccooleston = ParametersADCsCoolestStrip.getParameter<bool>("layerswitchon");
90  moduleswitchadccooleston = ParametersADCsCoolestStrip.getParameter<bool>("moduleswitchon");
91 
92  edm::ParameterSet ParametersDigiADCs = conf_.getParameter<edm::ParameterSet>("TH1DigiADCs");
93  layerswitchdigiadcson = ParametersDigiADCs.getParameter<bool>("layerswitchon");
94  moduleswitchdigiadcson = ParametersDigiADCs.getParameter<bool>("moduleswitchon");
95 
96  edm::ParameterSet ParametersStripOccupancy = conf_.getParameter<edm::ParameterSet>("TH1StripOccupancy");
97  layerswitchstripoccupancyon = ParametersStripOccupancy.getParameter<bool>("layerswitchon");
98  moduleswitchstripoccupancyon = ParametersStripOccupancy.getParameter<bool>("moduleswitchon");
99 
100  edm::ParameterSet ParametersDigiProf = conf_.getParameter<edm::ParameterSet>("TProfNumberOfDigi");
101  layerswitchnumdigisprofon = ParametersDigiProf.getParameter<bool>("layerswitchon");
102 
103  edm::ParameterSet ParametersDigiADC = conf_.getParameter<edm::ParameterSet>("TProfDigiADC");
104  layerswitchdigiadcprofon = ParametersDigiProf.getParameter<bool>("layerswitchon");
105 
106  edm::ParameterSet ParametersTotDigiProf = conf_.getParameter<edm::ParameterSet>("TProfTotalNumberOfDigis");
107  subdetswitchtotdigiprofon = ParametersTotDigiProf.getParameter<bool>("subdetswitchon");
108 
109  edm::ParameterSet ParametersTotDigiFailure = conf_.getParameter<edm::ParameterSet>("TotalNumberOfDigisFailure");
110  subdetswitchtotdigifailureon = ParametersTotDigiFailure.getParameter<bool>("subdetswitchon");
111 
112  edm::ParameterSet ParametersDigiApvProf = conf_.getParameter<edm::ParameterSet>("TProfDigiApvCycle");
113  subdetswitchapvcycleprofon = ParametersDigiApvProf.getParameter<bool>("subdetswitchon");
114 
115  edm::ParameterSet ParametersDigiApvTH2 = conf_.getParameter<edm::ParameterSet>("TH2DigiApvCycle");
116  subdetswitchapvcycleth2on = ParametersDigiApvTH2.getParameter<bool>("subdetswitchon");
117 
118  edm::ParameterSet ParametersNApvShots = conf_.getParameter<edm::ParameterSet>("TH1NApvShots");
119  subdetswitchnapvshotson = ParametersNApvShots.getParameter<bool>("subdetswitchon");
120 
121  edm::ParameterSet ParametersNStripApvShots = conf_.getParameter<edm::ParameterSet>("TH1NStripsApvShots");
122  subdetswitchnstripsapvshotson = ParametersNStripApvShots.getParameter<bool>("subdetswitchon");
123 
124  edm::ParameterSet ParametersChargeMedianApvShots = conf_.getParameter<edm::ParameterSet>("TH1ChargeMedianApvShots");
125  subdetswitchchargemedianapvshotson = ParametersChargeMedianApvShots.getParameter<bool>("subdetswitchon");
126 
127  edm::ParameterSet ParametersApvNumberApvShots = conf_.getParameter<edm::ParameterSet>("TH1ApvNumApvShots");
128  subdetswitchapvshotsApvon = ParametersChargeMedianApvShots.getParameter<bool>("subdetswitchon");
129 
130  edm::ParameterSet ParametersNApvShotsProf = conf_.getParameter<edm::ParameterSet>("TProfNShotsVsTime");
131  subdetswitchapvshotsonprof = ParametersNApvShotsProf.getParameter<bool>("subdetswitchon");
132 
133  //Global Histograms
134 
135  edm::ParameterSet ParametersGlobalNApvShots = conf_.getParameter<edm::ParameterSet>("TH1NApvShots");
136  globalswitchnapvshotson = ParametersGlobalNApvShots.getParameter<bool>("globalswitchon");
137 
138  edm::ParameterSet ParametersGlobalNApvShotsProf = conf_.getParameter<edm::ParameterSet>("TProfGlobalNShots");
139  globalsummaryapvshotson = ParametersGlobalNApvShotsProf.getParameter<bool>("globalswitchon");
140 
141  edm::ParameterSet ParametersGlobalNStripApvShots = conf_.getParameter<edm::ParameterSet>("TH1NStripsApvShots");
142  globalswitchnstripsapvshotson = ParametersGlobalNStripApvShots.getParameter<bool>("globalswitchon");
143 
144  edm::ParameterSet ParametersGlobalApvNumApvShots = conf_.getParameter<edm::ParameterSet>("TH1ApvNumApvShots");
145  globalswitchapvshotsApvon = ParametersGlobalApvNumApvShots.getParameter<bool>("globalswitchon");
146 
147  edm::ParameterSet ParametersGlobalChargeMedianApvShots = conf_.getParameter<edm::ParameterSet>("TH1ChargeMedianApvShots");
148  globalswitchchargemedianapvshotson = ParametersGlobalChargeMedianApvShots.getParameter<bool>("globalswitchon");
149 
150  edm::ParameterSet ParametersGlobalNApvShotsTimeProf = conf_.getParameter<edm::ParameterSet>("TProfNShotsVsTime");
151  globalswitchapvshotsonprof = ParametersGlobalNApvShotsTimeProf.getParameter<bool>("globalswitchon");
152 
153  //Digi and APV Shots Maps
154 
155  digitkhistomapon = conf_.getParameter<bool>("TkHistoMap_On");
156 
157  shotshistomapon = conf_.getParameter<bool>("TkHistoMapNApvShots_On");
158  shotsstripshistomapon = conf_.getParameter<bool>("TkHistoMapNStripApvShots_On");
159  shotschargehistomapon = conf_.getParameter<bool>("TkHistoMapMedianChargeApvShots_On");
160 
161  createTrendMEs = conf_.getParameter<bool>("CreateTrendMEs");
162  Mod_On_ = conf_.getParameter<bool>("Mod_On");
163  // xLumiProf = conf_.getParameter<int>("xLumiProf");
164  // Event History Producer
165  historyProducer_ = conf_.getParameter<edm::InputTag>("HistoryProducer");
166  historyProducerToken_ = consumes<EventWithHistory>(conf_.getParameter<edm::InputTag>("HistoryProducer") );
167 
168  // Apv Phase Producer
169  apvPhaseProducer_ = conf_.getParameter<edm::InputTag>("ApvPhaseProducer");
170  apvPhaseProducerToken_ = consumes<APVCyclePhaseCollection>(conf_.getParameter<edm::InputTag>("ApvPhaseProducer") );
171 
172  gtEvmToken_ = consumes<L1GlobalTriggerEvmReadoutRecord>(edm::InputTag("gtEvmDigis") );
173 
174  // Create DCS Status
175  bool checkDCS = conf_.getParameter<bool>("UseDCSFiltering");
176  if (checkDCS) dcsStatus_ = new SiStripDCSStatus(consumesCollector());
177  else dcsStatus_ = 0;
178 
179  //initialize boolean for the data-presence check (needed for TotalNumberOfDigisFailure histogram)
180  isStableBeams = false;
181  SBTransitionDone = false;
182  SBDeclaredAt = 0;
183  ignoreFirstNLumisections_ = TMath::Max ( 0 , ParametersTotDigiFailure.getParameter<int32_t>("ignoreFirstNLumisections") );
184  integrateNLumisections_ = TMath::Max ( 1 , ParametersTotDigiFailure.getParameter<int32_t>("integrateNLumisections") );
185 }
186 //------------------------------------------------------------------------------------------
187 
189  if (dcsStatus_) delete dcsStatus_;
190 }
191 
192 
194 {
196  unsigned long long cacheID = es.get<SiStripDetCablingRcd>().cacheIdentifier();
197  if (m_cacheID_ != cacheID) {
198  m_cacheID_ = cacheID;
199  edm::LogInfo("SiStripMonitorDigi") <<"SiStripMonitorDigi::bookHistograms: "
200  << " Creating MEs for new Cabling ";
201  createMEs( ibooker, es );
202  }
203  } else if (reset_each_run) {
204  edm::LogInfo("SiStripMonitorDigi") <<"SiStripMonitorDigi::bookHistograms: "
205  << " Resetting MEs ";
206  for (std::map<uint32_t, ModMEs >::const_iterator idet = DigiMEs.begin() ; idet!=DigiMEs.end() ; idet++) {
207  ResetModuleMEs(idet->first);
208  }
209  }
210 
211 }
212 
213 
214 
215 
216 
217 //--------------------------------------------------------------------------------------------
219 
221  //get FED cabling to know if SiStrip is in DAQ or no
222  unsigned long long cacheID = es.get<SiStripDetCablingRcd>().cacheIdentifier();
223  if (m_cacheID_ != cacheID) {
224  m_cacheID_ = cacheID;
225  }
227  es.get<SiStripDetCablingRcd>().get(detCabling_);
228 
229  //nFEDConnected = 0;
230  nFedTIB = 0;
231  nFedTIDm = 0;
232  nFedTIDp = 0;
233  nFedTECm = 0;
234  nFedTECp = 0;
235  nFedTOB = 0;
236 
237  //const int siStripFedIdMin = FEDNumbering::MINSiStripFEDID;
238  //const int siStripFedIdMax = FEDNumbering::MAXSiStripFEDID;
239 
241  if( es.find( recordKey ) != 0) {
242 
243  edm::ESHandle<RunInfo> sumFED;
244  es.get<RunInfoRcd>().get(sumFED);
245 
246  if ( sumFED.isValid() ) {
247  std::vector<int> FedsInIds= sumFED->m_fed_in;
248  for(unsigned int it = 0; it < FedsInIds.size(); ++it) {
249  int fedID = FedsInIds[it];
250  // if(fedID>=siStripFedIdMin && fedID<=siStripFedIdMax) ++nFEDConnected;
251  /* mia: but is there not a smarter way !?!?!? */
252  if ( fedID >= 50 && fedID <= 133 ) ++nFedTIB;
253  if ( fedID >= 134 && fedID <= 148 ) ++nFedTIDm;
254  if ( fedID >= 149 && fedID <= 163 ) ++nFedTIDp;
255  if ( fedID >= 164 && fedID <= 259 ) ++nFedTECm;
256  if ( fedID >= 260 && fedID <= 355 ) ++nFedTECp;
257  if ( fedID >= 356 && fedID <= 489 ) ++nFedTOB;
258 
259  }
260  }
261  }
262  }
263 
264 }
265 
266 //--------------------------------------------------------------------------------------------
268 }
269 
270 //--------------------------------------------------------------------------------------------
273  isStableBeams = false;
274  //integrate stats over several LS to prevent eventual low trigger rates
276  }
277 }
278 
279 //--------------------------------------------------------------------------------------------
281 
283  {
284  SBDeclaredAt = (int)lb.id().luminosityBlock();
285  SBTransitionDone = true;
286  }
287 
289 
290  int nFeds [6] = { 96 , 96 , 84 , 15 , 15 , 134 }; // tec- , tec+ , tib , tid- , tid+ , tob
291  int nFedsConnected [6] = { nFedTECm , nFedTECp , nFedTIB , nFedTIDm , nFedTIDp , nFedTOB };
292 
293  MonitorElement * me = dqmStore_->get(topFolderName_+"/MechanicalView/NumberOfDigisInLastLS");
294  if (me) {
295 
296  for (int ibin = 1; ibin<7;ibin++){
297 
298  float value = me->getBinContent(ibin);
299 
300  float fillvalue = 2;
301  if ( isStableBeams
302  // && (int)lb.id().luminosityBlock() > ignoreFirstNLumisections_ //ignore first X lumisections for HV rampup
304  && (float)nFedsConnected[ibin-1] / nFeds[ibin-1] > 0.5
305  && value < 50. ){
306 
307  fillvalue = 1.01;
308  }
309 
310  //account for integrated LS: fill previous bins as well
311  for ( int fillbin = (int)lb.id().luminosityBlock() - integrateNLumisections_ + 1 ; fillbin <= (int)lb.id().luminosityBlock() ; fillbin++ )
312  digiFailureMEs.SubDetDigiFailures2D -> Fill( fillbin , ibin-1 , fillvalue );
313  }
314  }
315  }
316 
317 }
318 //--------------------------------------------------------------------------------------------
320 }
321 
322 
323 //--------------------------------------------------------------------------------------------
325 
327 
328  //Retrieve tracker topology from geometry
329  edm::ESHandle<TrackerTopology> tTopoHandle;
330  es.get<IdealGeometryRecord>().get(tTopoHandle);
331  const TrackerTopology* const tTopo = tTopoHandle.product();
332 
333  // take from eventSetup the SiStripDetCabling object - here will use SiStripDetControl later on
335 
336  // get list of active detectors from SiStripDetCabling
337  std::vector<uint32_t> activeDets;
338  activeDets.clear(); // just in case
339  SiStripDetCabling_->addActiveDetectorsRawIds(activeDets);
340 
341  SiStripSubStructure substructure;
342 
343  // remove any eventual zero elements - there should be none, but just in case
344  for(std::vector<uint32_t>::iterator idets = activeDets.begin(); idets != activeDets.end(); idets++){
345  if(*idets == 0) activeDets.erase(idets);
346  }
347 
348  // create SiStripFolderOrganizer
350 
351  // Create TkHistoMap for Digi and APV shots properies
352 
353  if (digitkhistomapon) tkmapdigi = new TkHistoMap(ibooker , topFolderName_,"TkHMap_NumberOfDigi", 0.0,true);
354  if (shotshistomapon) tkmapNApvshots = new TkHistoMap(ibooker , topFolderName_,"TkHMap_NApvShots", 0.0,true);
355  if (shotsstripshistomapon) tkmapNstripApvshot = new TkHistoMap(ibooker , topFolderName_,"TkHMap_NStripApvShots", 0.0,true);
356  if (shotschargehistomapon) tkmapMedianChargeApvshots= new TkHistoMap(ibooker , topFolderName_,"TkHMap_MedianChargeApvShots",0.0,true);
357 
358  std::vector<uint32_t> tibDetIds;
359 
360  // loop over detectors and book MEs
361  edm::LogInfo("SiStripTkDQM|SiStripMonitorDigi")<<"nr. of activeDets: "<<activeDets.size();
362  for(std::vector<uint32_t>::const_iterator detid_iterator = activeDets.begin(); detid_iterator!=activeDets.end(); detid_iterator++){
363 
364  uint32_t detid = (*detid_iterator);
365 
366  ModMEs local_modmes;
367 
368  local_modmes.NumberOfDigis = 0;
369  local_modmes.NumberOfDigisPerStrip = 0;
370  local_modmes.ADCsHottestStrip = 0;
371  local_modmes.ADCsCoolestStrip = 0;
372  local_modmes.DigiADCs = 0;
373  local_modmes.StripOccupancy = 0;
374 
375  if (Mod_On_) {
376 
377  // set appropriate folder using SiStripFolderOrganizer
378  folder_organizer.setDetectorFolder(detid, tTopo); // pass the detid to this method
379  if (reset_each_run) ResetModuleMEs(detid);
380  createModuleMEs( ibooker , local_modmes, detid );
381 
382  // append to DigiMEs
383  DigiMEs.insert( std::make_pair(detid, local_modmes));
384  }
385 
386  // Create Layer Level MEs if they are not created already
387  std::pair<std::string,int32_t> det_layer_pair = folder_organizer.GetSubDetAndLayer(detid, tTopo);
388  SiStripHistoId hidmanager;
389  std::string label = hidmanager.getSubdetid(detid,tTopo,false);
390 
391  // get detids for the layer
392  std::map<std::string, LayerMEs>::iterator iLayerME = LayerMEsMap.find(label);
393 
394  if(iLayerME==LayerMEsMap.end()) {
395  int32_t lnumber = det_layer_pair.second;
396  std::vector<uint32_t> layerDetIds;
397  if (det_layer_pair.first == "TIB") {
398  substructure.getTIBDetectors(activeDets,layerDetIds,lnumber,0,0,0);
399  } else if (det_layer_pair.first == "TOB") {
400  substructure.getTOBDetectors(activeDets,layerDetIds,lnumber,0,0);
401  } else if (det_layer_pair.first == "TID" && lnumber > 0) {
402  substructure.getTIDDetectors(activeDets,layerDetIds,2,abs(lnumber),0,0);
403  } else if (det_layer_pair.first == "TID" && lnumber < 0) {
404  substructure.getTIDDetectors(activeDets,layerDetIds,1,abs(lnumber),0,0);
405  } else if (det_layer_pair.first == "TEC" && lnumber > 0) {
406  substructure.getTECDetectors(activeDets,layerDetIds,2,abs(lnumber),0,0,0,0);
407  } else if (det_layer_pair.first == "TEC" && lnumber < 0) {
408  substructure.getTECDetectors(activeDets,layerDetIds,1,abs(lnumber),0,0,0,0);
409  }
410 
411  LayerDetMap[label] = layerDetIds;
412 
413  // book Layer plots
414  folder_organizer.setLayerFolder(detid,tTopo,det_layer_pair.second);
415  createLayerMEs( ibooker , label, layerDetIds.size() );
416  }
417 
418  // book sub-detector plots
419  std::pair<std::string,std::string> sdet_pair = folder_organizer.getSubDetFolderAndTag(detid, tTopo);
420  if (SubDetMEsMap.find(sdet_pair.second) == SubDetMEsMap.end()){
421  ibooker.setCurrentFolder(sdet_pair.first);
422  createSubDetMEs( ibooker , sdet_pair.second );
423  }
424 
425  }//end of loop over detectors
426 
427  //book some Summary histograms on APV shots in the MechanicalView
428 
429  ibooker.setCurrentFolder(topFolderName_+"/MechanicalView/");
430 
432  const char* HistoName = "Summary Mean Apv shots for SubDets";
433  NApvShotsGlobalProf= ibooker.bookProfile(HistoName, HistoName,
434  6,0.5,6.5,
435  100, 0., 0., "" );
442  NApvShotsGlobalProf->setAxisTitle(" mean APV shots # / evt",2);
443  }
444 
445  //cumulative number of APV shots Vs Time
448  const char* HistoName = "NApv_Shots_vs_Time";
449  ShotsVsTimeApvShotsGlobal=ibooker.bookProfile(HistoName,HistoName,
450  Parameters.getParameter<int32_t>("Nbins"),
451  Parameters.getParameter<double>("xmin"),
452  Parameters.getParameter<double>("xmax"),
453  200, //that parameter should not be there !?
454  Parameters.getParameter<double>("ymin"),
455  Parameters.getParameter<double>("ymax"),
456  "" );
458  ShotsVsTimeApvShotsGlobal->setAxisTitle("# Apv Shots",2);
460  }
461 
462  //cumulative number of Strips in APV shots
465  const char* HistoName = "Number_of_Strips_in_Apv_Shots";
466  StripMultiplicityApvShotsGlobal=ibooker.book1D(HistoName,HistoName,
467  Parameters.getParameter<int32_t>("Nbins"),
468  Parameters.getParameter<double>("xmin"),
469  Parameters.getParameter<double>("xmax"));
470  StripMultiplicityApvShotsGlobal->setAxisTitle("# strips in Apv Shots",1);
471  }
472 
473  //cumulative number of APV shots
476  const char* HistoName = "Number_of_Apv_Shots";
477  NApvShotsGlobal=ibooker.book1D(HistoName,HistoName,
478  Parameters.getParameter<int32_t>("Nbins"),
479  Parameters.getParameter<double>("xmin"),
480  Parameters.getParameter<double>("xmax"));
481  NApvShotsGlobal->setAxisTitle("# Apv Shots",1);
482  }
483 
484  //cumulative Median Charge in APV shots
486  edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>("TH1ChargeMedianApvShots");
487  //dqmStore_->setCurrentFolder("SiStrip/MechanicalView/"+label);
488  const char* HistoName = "Apv_Shots_Charge_Median";
489  MedianChargeApvShotsGlobal=ibooker.book1D(HistoName,HistoName,
490  Parameters.getParameter<int32_t>("Nbins"),
491  Parameters.getParameter<double>("xmin"),
492  Parameters.getParameter<double>("xmax"));
493  MedianChargeApvShotsGlobal->setAxisTitle("Apv Shots Charge Median (ADC)",1);
494  }
495 
496  //cmulative APV number with shots
499  //dqmStore_->setCurrentFolder("SiStrip/MechanicalView/"+label);
500  const char* HistoName = "Apv_Shots_Apv_Number";
501  NApvApvShotsGlobal=ibooker.book1D(HistoName,HistoName,
502  Parameters.getParameter<int32_t>("Nbins"),
503  Parameters.getParameter<double>("xmin"),
504  Parameters.getParameter<double>("xmax"));
505  NApvApvShotsGlobal->setAxisTitle("Apv Number",1);
506  }
507 
508  //
509  // Book new histogram to monitor digi in last LS
510  //
511 
514 
515  std::stringstream ss;
516 
517  folder_organizer.getLayerFolderName(ss, 0, tTopo);
518  ibooker.setCurrentFolder(ss.str().c_str());
519 
521  const char* HistoName = "NumberOfDigisInLastLS";
522  digiFailureMEs.SubDetTotDigiProfLS= ibooker.bookProfile(HistoName, HistoName,
523  6,0.5,6.5,
524  0., 0., "" );
531  }
532 
534  std::string HistoName = "DataPresentInLS";
535  edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>("TotalNumberOfDigisFailure");
536 
537  digiFailureMEs.SubDetDigiFailures2D = ibooker.book2D(HistoName,HistoName,
538  Parameters.getParameter<int32_t>("Nbins"), //bins X
539  1, //xmin
540  Parameters.getParameter<int32_t>("Nbins") + 1, //xmax
541  6, //bins Y
542  0, //ymin
543  6); //ymax
544 
551  digiFailureMEs.SubDetDigiFailures2D->setAxisTitle("Luminosity Section");
552  }
553  }//end of if
554 
555 }//end of method
556 
557 //--------------------------------------------------------------------------------------------
559 
560  // Filter out events if DCS Event if requested
561  if (dcsStatus_ && !dcsStatus_->getStatus(iEvent, iSetup)) return;
562 
563  //Retrieve tracker topology from geometry
564  edm::ESHandle<TrackerTopology> tTopoHandle;
565  iSetup.get<IdealGeometryRecord>().get(tTopoHandle);
566  const TrackerTopology* const tTopo = tTopoHandle.product();
567 
568  TotalNShots=0;
569 
570  runNb = iEvent.id().run();
571  eventNb++;
572 
573  float iOrbitSec = iEvent.orbitNumber()/NORBITS_PER_SECOND;
574 
575  digi_detset_handles.clear();
576 
577  std::vector<edm::EDGetTokenT<edm::DetSetVector<SiStripDigi> > >::const_iterator iToken = digiProducerTokenList.begin();
578  for(std::vector<edm::InputTag>::const_iterator iter = digiProducerList.begin(), iEnd = digiProducerList.end();
579  iter != iEnd; ++iter, ++iToken) {
581  iEvent.getByToken( *iToken, digi_handle );
582  if (digi_handle.isValid()) digi_detset_handles.push_back(digi_handle.product());
583  }
584 
585  // initialise # of clusters to zero
586  for (std::map<std::string, SubDetMEs>::iterator iSubdet = SubDetMEsMap.begin();
587  iSubdet != SubDetMEsMap.end(); iSubdet++) {
588  iSubdet->second.totNDigis = 0;
589  iSubdet->second.SubDetApvShots.clear();
590  }
591 
592  for (std::map<std::string, std::vector< uint32_t > >::const_iterator iterLayer = LayerDetMap.begin();
593  iterLayer != LayerDetMap.end(); iterLayer++) {
594 
595  std::string layer_label = iterLayer->first;
596 
597  std::vector< uint32_t > layer_dets = iterLayer->second;
598  std::map<std::string, LayerMEs>::iterator iLayerME = LayerMEsMap.find(layer_label);
599 
600  //get Layer MEs
601  LayerMEs local_layermes;
602 
603  if(iLayerME == LayerMEsMap.end()) continue;
604  else local_layermes = iLayerME->second;
605 
606  int largest_adc_layer= 0;
607  int smallest_adc_layer= 99999;
608 
609  int ndigi_layer = 0;
610 
611  uint16_t iDet = 0;
612 
613  std::string subdet_label = "";
614 
615  // loop over all modules in the layer
616  for (std::vector< uint32_t >::const_iterator iterDets = layer_dets.begin() ;
617  iterDets != layer_dets.end() ; iterDets++) {
618  iDet++;
619 
620  // detid and type of ME
621  uint32_t detid = (*iterDets);
622 
623  // Get SubDet label once
624  if (subdet_label.size() == 0) subdet_label = folder_organizer.getSubDetFolderAndTag(detid, tTopo).second;
625 
626  // DetId and corresponding set of MEs
627 
628  std::map<uint32_t, ModMEs >::iterator pos = DigiMEs.find(detid);
629  ModMEs local_modmes = pos->second;
630 
631  // search digis of detid
632  int loc = getDigiSourceIndex(detid);
633 
634  int ndigi_det = 0;
635 
636  if (loc > -1) {
637  ndigi_det = (*(digi_detset_handles[loc]))[detid].size();
638  APVShotFinder theShotFinder = APVShotFinder((*(digi_detset_handles[loc]))[detid]);
639  const std::vector<APVShot>& shots = theShotFinder.getShots();
640  AddApvShotsToSubDet(shots,SubDetMEsMap[subdet_label].SubDetApvShots);
641  if (shotshistomapon) tkmapNApvshots->fill(detid,shots.size());
644  }
645 
646  if(Mod_On_ && moduleswitchnumdigison && (local_modmes.NumberOfDigis != NULL))
647  (local_modmes.NumberOfDigis)->Fill(ndigi_det);
648 
650  local_layermes.LayerNumberOfDigisProfile->Fill(iDet*1.0,ndigi_det);
651 
652  if (digitkhistomapon) tkmapdigi->fill(detid,ndigi_det);
653 
654  if (ndigi_det == 0) continue; // no digis for this detid => jump to next step of loop
655 
656  const edm::DetSet<SiStripDigi> & digi_detset = (*(digi_detset_handles[loc]))[detid];
657 
658  ndigi_layer += ndigi_det;
659 
660  // ADCs
661  int largest_adc=(digi_detset.data.begin())->adc();
662  int smallest_adc=(digi_detset.data.begin())->adc();
663 
664 
665  // Check if these parameters are really needed
666  float det_occupancy = 0.0;
667 
668  for(edm::DetSet<SiStripDigi>::const_iterator digiIter = digi_detset.data.begin();
669  digiIter!= digi_detset.data.end(); digiIter++ ){
670 
671  int this_adc = digiIter->adc();
672 
673  if (this_adc > 0.0) det_occupancy++;
674 
675  if(this_adc>largest_adc) largest_adc = this_adc;
676  if(this_adc<smallest_adc) smallest_adc = this_adc;
677 
678  if(Mod_On_ && moduleswitchnumdigispstripon && (local_modmes.NumberOfDigisPerStrip != NULL) && (this_adc > 0.0) )
679  (local_modmes.NumberOfDigisPerStrip)->Fill(digiIter->strip());
680 
681  if(Mod_On_ && moduleswitchdigiadcson && (local_modmes.DigiADCs != NULL) )
682  (local_modmes.DigiADCs)->Fill(static_cast<float>(this_adc));
683 
684  //Fill #ADCs for this digi at layer level
686  fillME(local_layermes.LayerDigiADCs , this_adc);
687  if (createTrendMEs) fillTrend(local_layermes.LayerDigiADCsTrend, this_adc, iOrbitSec);
688  }
689 
691  local_layermes.LayerDigiADCProfile->Fill(iDet*1.0,this_adc);
692 
693  }//end of loop over digis in this det
694 
695  // Occupancy
696  short nstrips = SiStripDetCabling_->nApvPairs(detid) * 2 * 128;
697  if (nstrips > 0 && det_occupancy > 0 ) {
698  det_occupancy = det_occupancy/nstrips;
699  if (Mod_On_ && moduleswitchstripoccupancyon && (local_modmes.StripOccupancy != NULL))
700  (local_modmes.StripOccupancy)->Fill(det_occupancy);
702  fillME(local_layermes.LayerStripOccupancy, det_occupancy);
703  if (createTrendMEs) fillTrend(local_layermes.LayerStripOccupancyTrend, det_occupancy, iOrbitSec);
704  }
705  }
706 
707  if (largest_adc > largest_adc_layer) largest_adc_layer = largest_adc;
708  if (smallest_adc < smallest_adc_layer) smallest_adc_layer = smallest_adc;
709 
710  // nr. of adcs for hottest strip
711  if( Mod_On_ && moduleswitchadchotteston && (local_modmes.ADCsHottestStrip != NULL))
712  (local_modmes.ADCsHottestStrip)->Fill(static_cast<float>(largest_adc));
713 
714  // nr. of adcs for coolest strip
715  if(Mod_On_ && moduleswitchadccooleston && (local_modmes.ADCsCoolestStrip != NULL))
716  (local_modmes.ADCsCoolestStrip)->Fill(static_cast<float>(smallest_adc));
717 
718  }//end of loop over DetIds
719 
721  fillME(local_layermes.LayerNumberOfDigis,ndigi_layer);
722  if (createTrendMEs) fillTrend(local_layermes.LayerNumberOfDigisTrend, ndigi_layer, iOrbitSec);
723  }
725  fillME(local_layermes.LayerADCsHottestStrip,largest_adc_layer);
726  if (createTrendMEs) fillTrend(local_layermes.LayerADCsHottestStripTrend, largest_adc_layer, iOrbitSec);
727  }
729  fillME(local_layermes.LayerADCsCoolestStrip ,smallest_adc_layer);
730  if (createTrendMEs) fillTrend(local_layermes.LayerADCsCoolestStripTrend, smallest_adc_layer, iOrbitSec);
731  }
732 
733  std::map<std::string, SubDetMEs>::iterator iSubdet = SubDetMEsMap.find(subdet_label);
734  if(iSubdet != SubDetMEsMap.end()) {
735  iSubdet->second.totNDigis += ndigi_layer;
736  //std::cout << " totDigis" << iSubdet->second.totNDigis << " in " << subdet_label << std::endl;
737  }
738  }
739 
741 
742  //check Stable beams bit
744  iEvent.getByToken( gtEvmToken_, gtEvm_handle );
745  L1GlobalTriggerEvmReadoutRecord const* gtevm = gtEvm_handle.product();
746 
747  L1GtfeExtWord gtfeEvmExtWord;
748  if (gtevm)
749  {
750  gtfeEvmExtWord = gtevm->gtfeWord();
751  }
752  else
753  edm::LogInfo("DQMProvInfo") << " gtfeEvmWord inaccessible" ;
754 
755  /* mia: is there not a smarter way !?!?!?!? */
756  if ( gtfeEvmExtWord.beamMode() == 11 )
757  isStableBeams = true;
758  }
759 
760  for (std::map<std::string, SubDetMEs>::iterator it = SubDetMEsMap.begin();
761  it != SubDetMEsMap.end(); it++) {
762 
764  if (strcmp(it->first.c_str(),"TEC__MINUS")==0){
765  digiFailureMEs.SubDetTotDigiProfLS->Fill(1, it->second.totNDigis);
766  }else if (strcmp(it->first.c_str(),"TEC__PLUS")==0){
767  digiFailureMEs.SubDetTotDigiProfLS->Fill(2, it->second.totNDigis);
768  }else if (strcmp(it->first.c_str(),"TIB")==0){
769  digiFailureMEs.SubDetTotDigiProfLS->Fill(3, it->second.totNDigis);
770  }else if (strcmp(it->first.c_str(),"TID__MINUS")==0){
771  digiFailureMEs.SubDetTotDigiProfLS->Fill(4, it->second.totNDigis);
772  }else if (strcmp(it->first.c_str(),"TID__PLUS")==0){
773  digiFailureMEs.SubDetTotDigiProfLS->Fill(5, it->second.totNDigis);
774  }else if (strcmp(it->first.c_str(),"TOB")==0){
775  digiFailureMEs.SubDetTotDigiProfLS->Fill(6, it->second.totNDigis);
776  }
777  }
778 
780  if (strcmp(it->first.c_str(),"TEC__MINUS")==0){
781  NApvShotsGlobalProf->Fill(1,it->second.SubDetApvShots.size());
782  }else if (strcmp(it->first.c_str(),"TEC__PLUS")==0){
783  NApvShotsGlobalProf->Fill(2,it->second.SubDetApvShots.size());
784  }else if (strcmp(it->first.c_str(),"TIB")==0){
785  NApvShotsGlobalProf->Fill(3,it->second.SubDetApvShots.size());
786  }else if (strcmp(it->first.c_str(),"TID__MINUS")==0){
787  NApvShotsGlobalProf->Fill(4,it->second.SubDetApvShots.size());
788  }else if (strcmp(it->first.c_str(),"TID__PLUS")==0){
789  NApvShotsGlobalProf->Fill(5,it->second.SubDetApvShots.size());
790  }else if (strcmp(it->first.c_str(),"TOB")==0){
791  NApvShotsGlobalProf->Fill(6,it->second.SubDetApvShots.size());
792  }
793  }
794 
795  SubDetMEs subdetmes= it->second;
796  std::string subdet = it->first;
797 
798  // Fill APV shots histograms for SubDet
799 
800  uint ShotsSize=subdetmes.SubDetApvShots.size();
801  TotalNShots+=ShotsSize; //Counter for total Shots in the SiStrip Tracker
802 
803  if (subdetswitchnapvshotson ) subdetmes.SubDetNApvShotsTH1->Fill(ShotsSize);// N shots
804  if (subdetswitchapvshotsonprof) subdetmes.SubDetNApvShotsProf ->Fill(iOrbitSec,ShotsSize); //N shots vs time
805 
806  for (uint i=0; i< ShotsSize; ++i){ // Strip multiplicity, charge median and APV number distributions for APV shots
807 
808  if (subdetswitchapvshotsApvon) subdetmes.SubDetNApvShotsNApvTH1->Fill((subdetmes.SubDetApvShots[i].apvNumber()+1));//APV are defined by 0 to 5 I want 1 to 6
809  if (globalswitchapvshotsApvon) NApvApvShotsGlobal->Fill((subdetmes.SubDetApvShots[i].apvNumber()+1));
810 
811  if (subdetswitchnstripsapvshotson) subdetmes.SubDetNStripsApvShotsTH1->Fill(subdetmes.SubDetApvShots[i].nStrips());
813 
816 
817  }
818 
819  if (subdetswitchtotdigiprofon)subdetmes.SubDetTotDigiProf->Fill(iOrbitSec,subdetmes.totNDigis);
820  }
821 
824 
825  // get EventHistory
826 
827  edm::Handle<EventWithHistory> event_history;
828  iEvent.getByToken(historyProducerToken_,event_history);
829 
830  // get Phase of APV
831  edm::Handle<APVCyclePhaseCollection> apv_phase_collection;
832  iEvent.getByToken(apvPhaseProducerToken_,apv_phase_collection);
833 
834  if (event_history.isValid()
835  && !event_history.failedToGet()
836  && apv_phase_collection.isValid()
837  && !apv_phase_collection.failedToGet()) {
838 
839 
840  long long tbx = event_history->absoluteBX();
841 
842 
843  for (std::map<std::string, SubDetMEs>::iterator it = SubDetMEsMap.begin();
844  it != SubDetMEsMap.end(); it++) {
845 
846  SubDetMEs subdetmes;
847  std::string subdet = it->first;
848  subdetmes = it->second;
849 
850  int the_phase = APVCyclePhaseCollection::invalid;
851  long long tbx_corr = tbx;
852 
853  if (SubDetPhasePartMap.find(subdet) != SubDetPhasePartMap.end()) the_phase = apv_phase_collection->getPhase(SubDetPhasePartMap[subdet]);
854  if(the_phase==APVCyclePhaseCollection::nopartition ||
856  the_phase==APVCyclePhaseCollection::invalid) the_phase=30;
857  tbx_corr -= the_phase;
858 
859  if (subdetswitchapvcycleprofon)subdetmes.SubDetDigiApvProf->Fill(tbx_corr%70,subdetmes.totNDigis);
860  if (subdetswitchapvcycleth2on) subdetmes.SubDetDigiApvTH2->Fill(tbx_corr%70,subdetmes.totNDigis);
861  }
862  }
863 }//end of method analyze
864 //--------------------------------------------------------------------------------------------
865 
867  bool outputMEsInRootFile = conf_.getParameter<bool>("OutputMEsInRootFile");
869 
870  // save histograms in a file
871  if(outputMEsInRootFile) dqmStore_->save(outputFileName);
872 
873 }//end of method
874 //--------------------------------------------------------------------------------------------
876  std::map<uint32_t, ModMEs >::iterator pos = DigiMEs.find(idet);
877  ModMEs mod_me = pos->second;
878 
883  if(Mod_On_ && moduleswitchdigiadcson) mod_me.DigiADCs->Reset();
885 
886 }
887 //------------------------------------------------------------------------------------------
888 MonitorElement* SiStripMonitorDigi::bookMETrend(DQMStore::IBooker & ibooker , const char* ParameterSetLabel, const char* HistoName )
889 {
890  edm::ParameterSet ParametersTrend = conf_.getParameter<edm::ParameterSet>("Trending");
891  MonitorElement* me = ibooker.bookProfile(HistoName,HistoName,
892  ParametersTrend.getParameter<int32_t>("Nbins"),
893  // 0,
894  ParametersTrend.getParameter<double>("xmin"),
895  ParametersTrend.getParameter<double>("xmax"),
896  // ParametersTrend.getParameter<int32_t>("Nbins"),
897  100, //that parameter should not be there !?
898  ParametersTrend.getParameter<double>("ymin"),
899  ParametersTrend.getParameter<double>("ymax"),
900  "" );
901  if(!me) return me;
902 
903  me->setAxisTitle("Event Time in Seconds",1);
904  if (me->kind() == MonitorElement::DQM_KIND_TPROFILE) me->getTH1()->SetBit(TH1::kCanRebin);
905  return me;
906 }
907 
908 //------------------------------------------------------------------------------------------
909 MonitorElement* SiStripMonitorDigi::bookME1D(DQMStore::IBooker & ibooker , const char* ParameterSetLabel, const char* HistoName )
910 {
912  return ibooker.book1D(HistoName,HistoName,
913  Parameters.getParameter<int32_t>("Nbinx"),
914  Parameters.getParameter<double>("xmin"),
915  Parameters.getParameter<double>("xmax")
916  );
917 }
918 
919 //--------------------------------------------------------------------------------
920 void SiStripMonitorDigi::fillTrend(MonitorElement* me ,float value, float timeinorbit)
921 {
922  if(!me) return;
923  me->Fill(timeinorbit,value);
924 }
925 
926 //
927 // -- Create Module Level MEs
928 //
929 void SiStripMonitorDigi::createModuleMEs(DQMStore::IBooker & ibooker , ModMEs& mod_single, uint32_t detid ) {
930 
931  // use SistripHistoId for producing histogram id (and title)
932  SiStripHistoId hidmanager;
933  std::string hid;
934 
935  //nr. of digis per module
937  hid = hidmanager.createHistoId("NumberOfDigis","det",detid);
938  mod_single.NumberOfDigis = ibooker.book1D(hid, hid, 21, -0.5, 20.5);
939  ibooker.tag(mod_single.NumberOfDigis, detid);
940  mod_single.NumberOfDigis->setAxisTitle("number of digis in one detector module");
941  mod_single.NumberOfDigis->getTH1()->StatOverflows(kTRUE); // over/underflows in Mean calculation
942  }
943 
944  //nr. of digis per strip in module
946  hid = hidmanager.createHistoId("NumberOfDigisPerStrip","det",detid);
947  short nstrips = SiStripDetCabling_->nApvPairs(detid) * 2 * 128;
948  mod_single.NumberOfDigisPerStrip = ibooker.book1D(hid, hid, nstrips, -0.5, nstrips+0.5);
949  ibooker.tag(mod_single.NumberOfDigisPerStrip, detid);
950  mod_single.NumberOfDigisPerStrip->setAxisTitle("number of (digis > 0) per strip");
951  mod_single.NumberOfDigisPerStrip->getTH1()->StatOverflows(kTRUE); // over/underflows in Mean calculation
952  }
953  //#ADCs for hottest strip
955  hid = hidmanager.createHistoId("ADCsHottestStrip","det",detid);
956  mod_single.ADCsHottestStrip = bookME1D(ibooker , "TH1ADCsHottestStrip", hid.c_str() );
957  ibooker.tag(mod_single.ADCsHottestStrip, detid); // 6 APVs -> 768 strips
958  mod_single.ADCsHottestStrip->setAxisTitle("number of ADCs for hottest strip");
959  }
960 
961  //#ADCs for coolest strip
963  hid = hidmanager.createHistoId("ADCsCoolestStrip","det",detid);
964  mod_single.ADCsCoolestStrip = bookME1D(ibooker , "TH1ADCsCoolestStrip", hid.c_str() );
965  ibooker.tag(mod_single.ADCsCoolestStrip, detid);
966  mod_single.ADCsCoolestStrip->setAxisTitle("number of ADCs for coolest strip");
967  }
968 
969  //#ADCs for each digi
971  hid = hidmanager.createHistoId("DigiADCs","det",detid);
972  mod_single.DigiADCs = bookME1D( ibooker , "TH1DigiADCs", hid.c_str() );
973  ibooker.tag(mod_single.DigiADCs, detid);
974  mod_single.DigiADCs->setAxisTitle("number of ADCs for each digi");
975  }
976 
977  //Strip occupancy
979  hid = hidmanager.createHistoId("StripOccupancy","det",detid);
980  mod_single.StripOccupancy = bookME1D( ibooker , "TH1StripOccupancy", hid.c_str() );
981  ibooker.tag(mod_single.StripOccupancy, detid);
982  mod_single.StripOccupancy->setAxisTitle("strip occupancy");
983  }
984 
985 }
986 
987 //
988 // -- Create Module Level MEs
989 //
990 
992 
993  std::map<std::string, LayerMEs>::iterator iLayerME = LayerMEsMap.find(label);
994  if(iLayerME==LayerMEsMap.end()){
995  SiStripHistoId hidmanager;
996  LayerMEs layerMEs;
997  layerMEs.LayerNumberOfDigis = 0;
998  layerMEs.LayerNumberOfDigisTrend = 0;
999  layerMEs.LayerADCsHottestStrip = 0;
1000  layerMEs.LayerADCsHottestStripTrend = 0;
1001  layerMEs.LayerADCsCoolestStrip = 0;
1002  layerMEs.LayerADCsCoolestStripTrend = 0;
1003  layerMEs.LayerDigiADCs = 0;
1004  layerMEs.LayerDigiADCsTrend = 0;
1005  layerMEs.LayerStripOccupancy = 0;
1006  layerMEs.LayerStripOccupancyTrend = 0;
1007  layerMEs.LayerNumberOfDigisProfile = 0;
1008  layerMEs.LayerDigiADCProfile = 0;
1009 
1010 
1011  //#Digis
1012  if(layerswitchnumdigison) {
1013  layerMEs.LayerNumberOfDigis=bookME1D( ibooker , "TH1NumberOfDigis", hidmanager.createHistoLayer("Summary_TotalNumberOfDigis","layer",label,"").c_str() );
1014  if (createTrendMEs) layerMEs.LayerNumberOfDigisTrend=bookMETrend( ibooker , "TH1NumberOfDigis", hidmanager.createHistoLayer("Trend_NumberOfDigis","layer",label,"").c_str() );
1015  }
1016 
1017  //#ADCs for hottest strip
1019  layerMEs.LayerADCsHottestStrip=bookME1D( ibooker , "TH1ADCsHottestStrip", hidmanager.createHistoLayer("Summary_ADCsHottestStrip","layer",label,"").c_str() );
1020  if (createTrendMEs) layerMEs.LayerADCsHottestStripTrend=bookMETrend( ibooker , "TH1ADCsHottestStrip", hidmanager.createHistoLayer("Trend_ADCsHottestStrip","layer",label,"").c_str() );
1021  }
1022 
1023  //#ADCs for coolest strip
1025  layerMEs.LayerADCsCoolestStrip=bookME1D(ibooker , "TH1ADCsCoolestStrip", hidmanager.createHistoLayer("Summary_ADCsCoolestStrip","layer",label,"").c_str() );
1026  if (createTrendMEs) layerMEs.LayerADCsCoolestStripTrend=bookMETrend( ibooker , "TH1ADCsCoolestStrip", hidmanager.createHistoLayer("Trend_ADCsCoolestStrip","layer",label,"").c_str() );
1027  }
1028 
1029  //#ADCs for each digi
1030  if(layerswitchdigiadcson) {
1031  layerMEs.LayerDigiADCs=bookME1D( ibooker , "TH1DigiADCs", hidmanager.createHistoLayer("Summary_DigiADCs","layer",label,"").c_str() );
1032  if (createTrendMEs) layerMEs.LayerDigiADCsTrend=bookMETrend( ibooker , "TH1DigiADCs", hidmanager.createHistoLayer("Trend_DigiADCs","layer",label,"").c_str() );
1033  }
1034 
1035  //Strip Occupancy
1037  layerMEs.LayerStripOccupancy=bookME1D( ibooker , "TH1StripOccupancy", hidmanager.createHistoLayer("Summary_StripOccupancy","layer",label,"").c_str() );
1038  if (createTrendMEs) layerMEs.LayerStripOccupancyTrend=bookMETrend( ibooker , "TH1StripOccupancy", hidmanager.createHistoLayer("Trend_StripOccupancy","layer",label,"").c_str() );
1039 
1040  }
1041  // # of Digis
1043  std::string hid = hidmanager.createHistoLayer("NumberOfDigiProfile","layer",label,"");
1044  layerMEs.LayerNumberOfDigisProfile = ibooker.bookProfile(hid, hid, ndets, 0.5, ndets+0.5,21, -0.5, 200.5);
1045  }
1046 
1047  // # of Digis
1049  std::string hid = hidmanager.createHistoLayer("DigiADCProfile","layer",label,"");
1050  layerMEs.LayerDigiADCProfile = ibooker.bookProfile(hid, hid, ndets, 0.5, ndets+0.5, 64, -0.5, 255.5);
1051  }
1052 
1053  LayerMEsMap[label]=layerMEs;
1054  }
1055 }
1056 //
1057 // -- Create SubDetector MEs
1058 //
1060 
1061  SubDetMEs subdetMEs;
1062  subdetMEs.totNDigis = 0;
1063  subdetMEs.SubDetTotDigiProf = 0;
1064  subdetMEs.SubDetDigiApvProf = 0;
1065  subdetMEs.SubDetDigiApvTH2 = 0;
1066 
1067  subdetMEs.SubDetApvShots.clear();
1068  subdetMEs.SubDetNApvShotsTH1 = 0;
1069  subdetMEs.SubDetChargeMedianApvShotsTH1 = 0;
1070  subdetMEs.SubDetNStripsApvShotsTH1 = 0;
1071  subdetMEs.SubDetNApvShotsProf = 0;
1072 
1074 
1075  // Total Number of Digi - Profile
1077  edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>("TProfTotalNumberOfDigis");
1078  HistoName = "TotalNumberOfDigiProfile__" + label;
1079  subdetMEs.SubDetTotDigiProf=ibooker.bookProfile(HistoName,HistoName,
1080  Parameters.getParameter<int32_t>("Nbins"),
1081  Parameters.getParameter<double>("xmin"),
1082  Parameters.getParameter<double>("xmax"),
1083  100, //that parameter should not be there !?
1084  Parameters.getParameter<double>("ymin"),
1085  Parameters.getParameter<double>("ymax"),
1086  "" );
1087  subdetMEs.SubDetTotDigiProf->setAxisTitle("Event Time in Seconds",1);
1088  if (subdetMEs.SubDetTotDigiProf->kind() == MonitorElement::DQM_KIND_TPROFILE) subdetMEs.SubDetTotDigiProf->getTH1()->SetBit(TH1::kCanRebin);
1089  }
1090 
1091  // Number of Digi vs Bx - Profile
1094  HistoName = "Digi_vs_ApvCycle__" + label;
1095  subdetMEs.SubDetDigiApvProf=ibooker.bookProfile(HistoName,HistoName,
1096  Parameters.getParameter<int32_t>("Nbins"),
1097  Parameters.getParameter<double>("xmin"),
1098  Parameters.getParameter<double>("xmax"),
1099  200, //that parameter should not be there !?
1100  Parameters.getParameter<double>("ymin"),
1101  Parameters.getParameter<double>("ymax"),
1102  "" );
1103  subdetMEs.SubDetDigiApvProf->setAxisTitle("ApvCycle (Corrected Absolute Bx % 70)",1);
1104  }
1105 
1106  // Number of Digi vs Bx - TH2
1109  //dqmStore_->setCurrentFolder("SiStrip/MechanicalView/"+label);
1110  HistoName = "Digi_vs_ApvCycle_2D__" + label;
1111  // Adjusting the scale for 2D histogram
1112  double h2ymax = 9999.0;
1113  double yfact = Parameters.getParameter<double>("yfactor");
1114  if(label.find("TIB") != std::string::npos) h2ymax = (6984.*256.)*yfact;
1115  else if (label.find("TID") != std::string::npos) h2ymax = (2208.*256.)*yfact;
1116  else if (label.find("TOB") != std::string::npos) h2ymax = (12906.*256.)*yfact;
1117  else if (label.find("TEC") != std::string::npos) h2ymax = (7552.*2.*256.)*yfact;
1118  subdetMEs.SubDetDigiApvTH2=ibooker.book2D(HistoName,HistoName,
1119  Parameters.getParameter<int32_t>("Nbins"),
1120  Parameters.getParameter<double>("xmin"),
1121  Parameters.getParameter<double>("xmax"),
1122  Parameters.getParameter<int32_t>("Nbinsy"), //it was 100 that parameter should not be there !?
1123  Parameters.getParameter<double>("ymin"),
1124  h2ymax);
1125  subdetMEs.SubDetDigiApvTH2->setAxisTitle("absolute Bx mod(70)",1);
1126  }
1127 
1128  //Number of APV Shots
1131  //dqmStore_->setCurrentFolder("SiStrip/MechanicalView/"+label);
1132  HistoName = "Number_of_Apv_Shots_" + label;
1133  subdetMEs.SubDetNApvShotsTH1=ibooker.book1D(HistoName,HistoName,
1134  Parameters.getParameter<int32_t>("Nbins"),
1135  Parameters.getParameter<double>("xmin"),
1136  Parameters.getParameter<double>("xmax"));
1137  subdetMEs.SubDetNApvShotsTH1->setAxisTitle("# Apv Shots",1);
1138  }
1139 
1140  //Strip multiplicity of APV Shots
1143  //dqmStore_->setCurrentFolder("SiStrip/MechanicalView/"+label);
1144  HistoName = "Number_of_Strips_in_Apv_Shots_" + label;
1145  subdetMEs.SubDetNStripsApvShotsTH1=ibooker.book1D(HistoName,HistoName,
1146  Parameters.getParameter<int32_t>("Nbins"),
1147  Parameters.getParameter<double>("xmin"),
1148  Parameters.getParameter<double>("xmax"));
1149  subdetMEs.SubDetNStripsApvShotsTH1->setAxisTitle("# strips in Apv Shots",1);
1150  }
1151 
1152  //Charge median of APV Shots
1154  edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>("TH1ChargeMedianApvShots");
1155  //dqmStore_->setCurrentFolder("SiStrip/MechanicalView/"+label);
1156  HistoName = "Apv_Shots_Charge_Median_" + label;
1157  subdetMEs.SubDetChargeMedianApvShotsTH1=ibooker.book1D(HistoName,HistoName,
1158  Parameters.getParameter<int32_t>("Nbins"),
1159  Parameters.getParameter<double>("xmin"),
1160  Parameters.getParameter<double>("xmax"));
1161  subdetMEs.SubDetChargeMedianApvShotsTH1->setAxisTitle("Apv Shots Charge Median (ADC)",1);
1162  }
1163 
1164 
1167  //dqmStore_->setCurrentFolder("SiStrip/MechanicalView/"+label);
1168  HistoName = "Apv_Shots_Apv_Number_" + label;
1169  subdetMEs.SubDetNApvShotsNApvTH1=ibooker.book1D(HistoName,HistoName,
1170  Parameters.getParameter<int32_t>("Nbins"),
1171  Parameters.getParameter<double>("xmin"),
1172  Parameters.getParameter<double>("xmax"));
1173  subdetMEs.SubDetNApvShotsNApvTH1->setAxisTitle("Apv Number",1);
1174  }
1175 
1176 
1177 
1178 
1179 
1180  //APV Shots number Vs time
1183  HistoName = "NApv_Shots_vs_Time_" + label;
1184  subdetMEs.SubDetNApvShotsProf=ibooker.bookProfile(HistoName,HistoName,
1185  Parameters.getParameter<int32_t>("Nbins"),
1186  Parameters.getParameter<double>("xmin"),
1187  Parameters.getParameter<double>("xmax"),
1188  200, //that parameter should not be there !?
1189  Parameters.getParameter<double>("ymin"),
1190  Parameters.getParameter<double>("ymax"),
1191  "" );
1192  subdetMEs.SubDetNApvShotsProf->setAxisTitle("Time (s)",1);
1193  subdetMEs.SubDetNApvShotsProf->setAxisTitle("# Apv Shots",2);
1194  if (subdetMEs.SubDetNApvShotsProf->kind() == MonitorElement::DQM_KIND_TPROFILE) subdetMEs.SubDetNApvShotsProf->getTH1()->SetBit(TH1::kCanRebin);
1195  }
1196 
1197 
1198 
1199 
1200 
1201 
1202 
1203  SubDetMEsMap[label]=subdetMEs;
1204 }
1205 //
1206 // -- Get DetSet vector for a given Detector
1207 //
1209  int location = -1;
1210  for (unsigned int ival = 0; ival < digi_detset_handles.size(); ++ival){
1212  if(isearch != digi_detset_handles[ival]->end()) {
1213  location = ival;
1214  break;
1215  }
1216  }
1217  return location;
1218 }
1219 
1220 void SiStripMonitorDigi::AddApvShotsToSubDet(const std::vector<APVShot> & moduleShots, std::vector<APVShot> & subdetShots){
1221 
1222  for (uint i=0; i<moduleShots.size(); i++){
1223  subdetShots.push_back(moduleShots[i]);
1224  }
1225 }
1226 
1227 void SiStripMonitorDigi::FillApvShotsMap(TkHistoMap* the_map, const std::vector<APVShot> & shots, uint32_t id ,int mode){
1228 
1229  for (uint i=0; i<shots.size(); i++){
1230  if (mode==1) the_map->fill(id,shots[i].nStrips()); //mode == 1 fill with strip multiplicity
1231  if (mode==2) the_map->fill(id,shots[i].median()); // mode == 2 fill with charge median
1232  }
1233 }
1234 
1235 //define this as a plug-in
int adc(sample_type sample)
get the ADC sample (12 bits)
RunNumber_t run() const
Definition: EventID.h:39
MonitorElement * bookME1D(DQMStore::IBooker &ibooker, const char *ParameterSetLabel, const char *HistoName)
LuminosityBlockID id() const
void ResetModuleMEs(uint32_t idet)
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
std::map< std::string, LayerMEs > LayerMEsMap
void createMEs(DQMStore::IBooker &ibooker, const edm::EventSetup &es)
MonitorElement * LayerNumberOfDigisTrend
MonitorElement * bookProfile(Args &&...args)
Definition: DQMStore.h:157
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:446
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
MonitorElement * LayerStripOccupancy
MonitorElement * LayerADCsHottestStrip
edm::InputTag historyProducer_
const L1GtfeExtWord gtfeWord() const
get / set GTFE word (record) in the GT readout record
void getLayerFolderName(std::stringstream &ss, uint32_t rawdetid, const TrackerTopology *tTopo, bool ring_flag=0)
MonitorElement * LayerADCsHottestStripTrend
void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
void dqmBeginRun(const edm::Run &r, const edm::EventSetup &c)
MonitorElement * NApvShotsGlobalProf
std::pair< std::string, int32_t > GetSubDetAndLayer(const uint32_t &detid, const TrackerTopology *tTopo, bool ring_flag=0)
std::map< uint32_t, ModMEs > DigiMEs
#define NULL
Definition: scimark2.h:8
std::map< std::string, std::string > SubDetPhasePartMap
MonitorElement * MedianChargeApvShotsGlobal
MonitorElement * StripMultiplicityApvShotsGlobal
TkHistoMap * tkmapNstripApvshot
MonitorElement * LayerNumberOfDigisProfile
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
const eventsetup::EventSetupRecord * find(const eventsetup::EventSetupRecordKey &) const
Definition: EventSetup.cc:90
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
void Fill(long long x)
std::vector< APVShot > SubDetApvShots
virtual void beginLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &)
void setDetectorFolder(uint32_t rawdetid, const TrackerTopology *tTopo)
unsigned long long m_cacheID_
MonitorElement * SubDetNApvShotsNApvTH1
void createSubDetMEs(DQMStore::IBooker &ibooker, std::string label)
bool getStatus(edm::Event const &e, edm::EventSetup const &eSetup)
MonitorElement * NumberOfDigisPerStrip
const std::vector< APVShot > & getShots() const
int iEvent
Definition: GenABIO.cc:230
MonitorElement * ADCsCoolestStrip
vector< ParameterSet > Parameters
SiStripDCSStatus * dcsStatus_
const double NORBITS_PER_SECOND
edm::ESHandle< SiStripDetCabling > SiStripDetCabling_
void getTOBDetectors(const std::vector< uint32_t > &inputDetRawIds, std::vector< uint32_t > &tobDetRawIds, uint32_t layer=0, uint32_t bkw_frw=0, uint32_t rod=0) const
MonitorElement * LayerADCsCoolestStripTrend
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
MonitorElement * SubDetNStripsApvShotsTH1
DigiFailureMEs digiFailureMEs
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
void fill(uint32_t &detid, float value)
Definition: TkHistoMap.cc:180
edm::EDGetTokenT< EventWithHistory > historyProducerToken_
void fillME(MonitorElement *ME, float value1)
MonitorElement * NApvApvShotsGlobal
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
std::vector< const edm::DetSetVector< SiStripDigi > * > digi_detset_handles
void tag(MonitorElement *, unsigned int)
Definition: DQMStore.cc:286
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
virtual void analyze(const edm::Event &, const edm::EventSetup &)
TH1 * getTH1(void) const
#define end
Definition: vmac.h:37
int orbitNumber() const
Definition: EventBase.h:63
Kind kind(void) const
Get the type of the monitor element.
std::map< std::string, SubDetMEs > SubDetMEsMap
std::string getSubdetid(uint32_t id, const TrackerTopology *tTopo, bool flag_ring)
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1725
MonitorElement * ADCsHottestStrip
bool isValid() const
Definition: HandleBase.h:76
void createLayerMEs(DQMStore::IBooker &ibooker, std::string label, int ndet)
void fillTrend(MonitorElement *me, float value, float timeinorbit)
edm::EDGetTokenT< L1GlobalTriggerEvmReadoutRecord > gtEvmToken_
MonitorElement * NApvShotsGlobal
std::vector< edm::EDGetTokenT< edm::DetSetVector< SiStripDigi > > > digiProducerTokenList
MonitorElement * LayerDigiADCProfile
T Max(T a, T b)
Definition: MathUtil.h:44
bool failedToGet() const
Definition: HandleBase.h:80
int getDigiSourceIndex(uint32_t id)
SiStripMonitorDigi(const edm::ParameterSet &)
edm::InputTag apvPhaseProducer_
void setLayerFolder(uint32_t rawdetid, const TrackerTopology *tTopo, int32_t layer=0, bool ring_flag=0)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
std::map< std::string, std::vector< uint32_t > > LayerDetMap
T const * product() const
Definition: Handle.h:81
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
std::string createHistoId(std::string description, std::string id_type, uint32_t component_id)
MonitorElement * SubDetChargeMedianApvShotsTH1
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:86
LuminosityBlockNumber_t luminosityBlock() const
std::string topFolderName_
edm::ParameterSet conf_
std::pair< std::string, std::string > getSubDetFolderAndTag(const uint32_t &detid, const TrackerTopology *tTopo)
std::string HistoName
void getTECDetectors(const std::vector< uint32_t > &inputDetRawIds, std::vector< uint32_t > &tecDetRawIds, uint32_t side=0, uint32_t wheel=0, uint32_t petal_bkw_frw=0, uint32_t petal=0, uint32_t ring=0, uint32_t ster=0) const
std::vector< edm::InputTag > digiProducerList
TkHistoMap * tkmapMedianChargeApvshots
edm::EDGetTokenT< APVCyclePhaseCollection > apvPhaseProducerToken_
double getBinContent(int binx) const
get content of bin (1-D)
edm::EventID id() const
Definition: EventBase.h:56
collection_type data
Definition: DetSet.h:78
TkHistoMap * tkmapNApvshots
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", const uint32_t run=0, const uint32_t lumi=0, SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE", const bool resetMEsAfterWriting=false)
Definition: DQMStore.cc:2562
MonitorElement * LayerStripOccupancyTrend
void getTIBDetectors(const std::vector< uint32_t > &inputDetRawIds, std::vector< uint32_t > &tibDetRawIds, uint32_t layer=0, uint32_t bkw_frw=0, uint32_t int_ext=0, uint32_t string=0) const
virtual void endRun(const edm::Run &, const edm::EventSetup &)
MonitorElement * LayerADCsCoolestStrip
MonitorElement * bookMETrend(DQMStore::IBooker &ibooker, const char *ParameterSetLabel, const char *HistoName)
void AddApvShotsToSubDet(const std::vector< APVShot > &, std::vector< APVShot > &)
virtual void endLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &)
SiStripFolderOrganizer folder_organizer
void getTIDDetectors(const std::vector< uint32_t > &inputDetRawIds, std::vector< uint32_t > &tidDetRawIds, uint32_t side=0, uint32_t wheel=0, uint32_t ring=0, uint32_t ster=0) const
MonitorElement * ShotsVsTimeApvShotsGlobal
volatile std::atomic< bool > shutdown_flag false
std::string createHistoLayer(std::string description, std::string id_type, std::string path, std::string flag)
collection_type::const_iterator const_iterator
Definition: DetSet.h:33
bool isValid() const
Definition: ESHandle.h:47
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:108
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
void Reset(void)
reset ME (ie. contents, errors, etc)
const cms_uint16_t beamMode() const
void FillApvShotsMap(TkHistoMap *, const std::vector< APVShot > &, uint32_t id, int)
void createModuleMEs(DQMStore::IBooker &ibooker, ModMEs &mod_single, uint32_t detid)
Definition: Run.h:41
static HCTypeTag findType(char const *iTypeName)
find a type based on the types name, if not found will return default HCTypeTag
Definition: HCTypeTag.cc:125