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