CMS 3D CMS Logo

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