CMS 3D CMS Logo

SiStripHitEffFromCalibTree.cc
Go to the documentation of this file.
1 //Original Author: Christopher Edelmaier
2 // Created: Feb. 11, 2010
3 
4 // system includes
5 #include <memory>
6 #include <string>
7 #include <iostream>
8 #include <fstream>
9 #include <sstream>
10 
11 // user includes
61 
62 // ROOT includes
63 #include "TCanvas.h"
64 #include "TEfficiency.h"
65 #include "TF1.h"
66 #include "TFile.h"
67 #include "TGaxis.h"
68 #include "TGraphAsymmErrors.h"
69 #include "TH1F.h"
70 #include "TH2F.h"
71 #include "TLatex.h"
72 #include "TLeaf.h"
73 #include "TLegend.h"
74 #include "TObjString.h"
75 #include "TProfile.h"
76 #include "TROOT.h"
77 #include "TString.h"
78 #include "TStyle.h"
79 #include "TTree.h"
80 
81 // custom made printout
82 #define LOGPRINT edm::LogPrint("SiStripHitEffFromCalibTree")
83 
84 using namespace edm;
85 using namespace reco;
86 using namespace std;
87 
88 struct hit {
89  double x;
90  double y;
91  double z;
92  unsigned int id;
93 };
94 
95 class SiStripHitEffFromCalibTree : public ConditionDBWriter<SiStripBadStrip> {
96 public:
98  ~SiStripHitEffFromCalibTree() override = default;
99 
100 private:
101  // overridden from ConditionDBWriter
102  void algoAnalyze(const edm::Event& e, const edm::EventSetup& c) override;
103  std::unique_ptr<SiStripBadStrip> getNewObject() override;
104 
105  // native methods
106  void setBadComponents(int i,
107  int component,
109  std::stringstream ssV[4][19],
110  int NBadComponent[4][19][4]);
111  void makeTKMap(bool autoTagging);
112  void makeHotColdMaps();
113  void makeSQLite();
114  void totalStatistics();
115  void makeSummary();
116  void makeSummaryVsBx();
117  void computeEff(vector<TH1F*>& vhfound, vector<TH1F*>& vhtotal, string name);
118  void makeSummaryVsLumi();
119  void makeSummaryVsCM();
120  TString getLayerSideName(Long_t k);
121 
122  // to be used everywhere
123  static constexpr int siStripLayers_ = 22;
124  static constexpr double nBxInAnOrbit_ = 3565;
125 
130 
133 
134  TTree* calibTree_;
135  vector<string> calibTreeFileNames_;
136  float threshold_;
137  unsigned int nModsMin_;
141  float resXSig_;
145  unsigned int bunchX_;
146  unsigned int spaceBetweenTrains_;
147  bool useCM_;
152  float tkMapMin_;
153  float effPlotMin_;
154  TString title_;
155 
156  unsigned int nTEClayers;
157 
158  TH1F* bxHisto;
160  TH1F* PUHisto;
161 
162  // for association of informations of the hitEff tree and the event infos tree
163  map<pair<unsigned int, unsigned int>, array<double, 3> > eventInfos;
164 
165  vector<hit> hits[23];
166  vector<TH2F*> HotColdMaps;
167  map<unsigned int, pair<unsigned int, unsigned int> > modCounter[23];
173  long layerfound[23];
174  long layertotal[23];
175  map<unsigned int, vector<int> > layerfound_perBx;
176  map<unsigned int, vector<int> > layertotal_perBx;
177  vector<TH1F*> layerfound_vsLumi;
178  vector<TH1F*> layertotal_vsLumi;
179  vector<TH1F*> layerfound_vsPU;
180  vector<TH1F*> layertotal_vsPU;
181  vector<TH1F*> layerfound_vsCM;
182  vector<TH1F*> layertotal_vsCM;
183  vector<TH1F*> layerfound_vsBX;
184  vector<TH1F*> layertotal_vsBX;
185  int goodlayertotal[35];
186  int goodlayerfound[35];
187  int alllayertotal[35];
188  int alllayerfound[35];
189  map<unsigned int, double> BadModules;
190 };
191 
195  tkGeomToken_(esConsumes()),
196  tTopoToken_(esConsumes()) {
197  usesResource(TFileService::kSharedResource);
198  calibTreeFileNames_ = conf.getUntrackedParameter<vector<std::string> >("CalibTreeFilenames");
199  threshold_ = conf.getParameter<double>("Threshold");
200  nModsMin_ = conf.getParameter<int>("nModsMin");
201  badModulesFile_ = conf.getUntrackedParameter<std::string>("BadModulesFile", "");
202  autoIneffModTagging_ = conf.getUntrackedParameter<bool>("AutoIneffModTagging", false);
203  clusterMatchingMethod_ = conf.getUntrackedParameter<int>("ClusterMatchingMethod", 0);
204  resXSig_ = conf.getUntrackedParameter<double>("ResXSig", -1);
205  clusterTrajDist_ = conf.getUntrackedParameter<double>("ClusterTrajDist", 64.0);
206  stripsApvEdge_ = conf.getUntrackedParameter<double>("StripsApvEdge", 10.0);
207  useOnlyHighPurityTracks_ = conf.getUntrackedParameter<bool>("UseOnlyHighPurityTracks", true);
208  bunchX_ = conf.getUntrackedParameter<int>("BunchCrossing", 0);
209  spaceBetweenTrains_ = conf.getUntrackedParameter<int>("SpaceBetweenTrains", 25);
210  useCM_ = conf.getUntrackedParameter<bool>("UseCommonMode", false);
211  showEndcapSides_ = conf.getUntrackedParameter<bool>("ShowEndcapSides", true);
212  showRings_ = conf.getUntrackedParameter<bool>("ShowRings", false);
213  showTOB6TEC9_ = conf.getUntrackedParameter<bool>("ShowTOB6TEC9", false);
214  showOnlyGoodModules_ = conf.getUntrackedParameter<bool>("ShowOnlyGoodModules", false);
215  tkMapMin_ = conf.getUntrackedParameter<double>("TkMapMin", 0.9);
216  effPlotMin_ = conf.getUntrackedParameter<double>("EffPlotMin", 0.9);
217  title_ = conf.getParameter<std::string>("Title");
219 
220  nTEClayers = 9; // number of wheels
221  if (showRings_)
222  nTEClayers = 7; // number of rings
223 
225 }
226 
228  const auto& tkgeom = c.getData(tkGeomToken_);
229  const auto& tTopo = c.getData(tTopoToken_);
230 
231  // read bad modules to mask
232  ifstream badModules_file;
233  set<uint32_t> badModules_list;
234  if (!badModulesFile_.empty()) {
235  badModules_file.open(badModulesFile_.c_str());
236  uint32_t badmodule_detid;
237  int mods, fiber1, fiber2, fiber3;
238  if (badModules_file.is_open()) {
239  string line;
240  while (getline(badModules_file, line)) {
241  if (badModules_file.eof())
242  continue;
243  stringstream ss(line);
244  ss >> badmodule_detid >> mods >> fiber1 >> fiber2 >> fiber3;
245  if (badmodule_detid != 0 && mods == 1 && (fiber1 == 1 || fiber2 == 1 || fiber3 == 1))
246  badModules_list.insert(badmodule_detid);
247  }
248  badModules_file.close();
249  }
250  }
251  if (!badModules_list.empty())
252  LOGPRINT << "Remove additionnal bad modules from the analysis: ";
253  set<uint32_t>::iterator itBadMod;
254  for (const auto& badMod : badModules_list) {
255  LOGPRINT << " " << badMod;
256  }
257 
258  // initialze counters and histos
259 
260  bxHisto = fs->make<TH1F>("bx", "bx", 3600, 0, 3600);
261  instLumiHisto = fs->make<TH1F>("instLumi", "inst. lumi.", 250, 0, 25000);
262  PUHisto = fs->make<TH1F>("PU", "PU", 200, 0, 200);
263 
264  for (int l = 0; l < 35; l++) {
265  goodlayertotal[l] = 0;
266  goodlayerfound[l] = 0;
267  alllayertotal[l] = 0;
268  alllayerfound[l] = 0;
269  }
270 
271  TH1F* resolutionPlots[23];
272  for (Long_t ilayer = 0; ilayer < 23; ilayer++) {
273  std::string lyrName = ::layerName(ilayer, showRings_, nTEClayers);
274 
275  resolutionPlots[ilayer] = fs->make<TH1F>(Form("resol_layer_%i", (int)(ilayer)), lyrName.c_str(), 125, -125, 125);
276  resolutionPlots[ilayer]->GetXaxis()->SetTitle("trajX-clusX [strip unit]");
277 
278  layerfound_vsLumi.push_back(
279  fs->make<TH1F>(Form("layerfound_vsLumi_layer_%i", (int)(ilayer)), lyrName.c_str(), 100, 0, 25000));
280  layertotal_vsLumi.push_back(
281  fs->make<TH1F>(Form("layertotal_vsLumi_layer_%i", (int)(ilayer)), lyrName.c_str(), 100, 0, 25000));
282  layerfound_vsPU.push_back(
283  fs->make<TH1F>(Form("layerfound_vsPU_layer_%i", (int)(ilayer)), lyrName.c_str(), 45, 0, 90));
284  layertotal_vsPU.push_back(
285  fs->make<TH1F>(Form("layertotal_vsPU_layer_%i", (int)(ilayer)), lyrName.c_str(), 45, 0, 90));
286 
287  layerfound_vsBX.push_back(fs->make<TH1F>(
288  Form("foundVsBx_layer%i", (int)ilayer), Form("layer %i", (int)ilayer), nBxInAnOrbit_, 0, nBxInAnOrbit_));
289  layertotal_vsBX.push_back(fs->make<TH1F>(
290  Form("totalVsBx_layer%i", (int)ilayer), Form("layer %i", (int)ilayer), nBxInAnOrbit_, 0, nBxInAnOrbit_));
291 
292  if (useCM_) {
293  layerfound_vsCM.push_back(
294  fs->make<TH1F>(Form("layerfound_vsCM_layer_%i", (int)(ilayer)), lyrName.c_str(), 20, 0, 400));
295  layertotal_vsCM.push_back(
296  fs->make<TH1F>(Form("layertotal_vsCM_layer_%i", (int)(ilayer)), lyrName.c_str(), 20, 0, 400));
297  }
298  layertotal[ilayer] = 0;
299  layerfound[ilayer] = 0;
300  }
301 
303  LOGPRINT << "A module is bad if efficiency < " << threshold_ << " and has at least " << nModsMin_ << " nModsMin.";
304  else
305  LOGPRINT << "A module is bad if the upper limit on the efficiency is < to the avg in the layer - " << threshold_
306  << " and has at least " << nModsMin_ << " nModsMin.";
307 
308  unsigned int run, evt, bx{0};
309  double instLumi, PU;
310 
311  //Open the ROOT Calib Tree
312  for (const auto& calibTreeFileName : calibTreeFileNames_) {
313  LOGPRINT << "Loading file: " << calibTreeFileName;
314  TFile* CalibTreeFile = TFile::Open(calibTreeFileName.c_str(), "READ");
315 
316  // Get event infos
317  bool foundEventInfos = false;
318  try {
319  CalibTreeFile->cd("eventInfo");
320  } catch (exception& e) {
321  LOGPRINT << "No event infos tree";
322  }
323  TTree* EventTree = (TTree*)(gDirectory->Get("tree"));
324 
325  TLeaf* runLf;
326  TLeaf* evtLf;
327  TLeaf* BunchLf;
328  TLeaf* InstLumiLf;
329  TLeaf* PULf;
330  if (EventTree) {
331  LOGPRINT << "Found event infos tree";
332 
333  runLf = EventTree->GetLeaf("run");
334  evtLf = EventTree->GetLeaf("event");
335 
336  BunchLf = EventTree->GetLeaf("bx");
337  InstLumiLf = EventTree->GetLeaf("instLumi");
338  PULf = EventTree->GetLeaf("PU");
339 
340  int nevt = EventTree->GetEntries();
341  if (nevt)
342  foundEventInfos = true;
343 
344  for (int j = 0; j < nevt; j++) {
345  EventTree->GetEntry(j);
346  run = runLf->GetValue();
347  evt = evtLf->GetValue();
348  bx = BunchLf->GetValue();
349  instLumi = InstLumiLf->GetValue();
350  PU = PULf->GetValue();
351 
352  bxHisto->Fill(bx);
353  instLumiHisto->Fill(instLumi);
354  PUHisto->Fill(PU);
355 
356  eventInfos[make_pair(run, evt)] = array<double, 3>{{(double)bx, instLumi, PU}};
357  }
358  }
359 
360  // Get hit infos
361  CalibTreeFile->cd("anEff");
362  calibTree_ = (TTree*)(gDirectory->Get("traj"));
363 
364  runLf = calibTree_->GetLeaf("run");
365  evtLf = calibTree_->GetLeaf("event");
366  TLeaf* BadLf = calibTree_->GetLeaf("ModIsBad");
367  TLeaf* sistripLf = calibTree_->GetLeaf("SiStripQualBad");
368  TLeaf* idLf = calibTree_->GetLeaf("Id");
369  TLeaf* acceptLf = calibTree_->GetLeaf("withinAcceptance");
370  TLeaf* layerLf = calibTree_->GetLeaf("layer");
371  //TLeaf* nHitsLf = calibTree_->GetLeaf("nHits");
372  TLeaf* highPurityLf = calibTree_->GetLeaf("highPurity");
373  TLeaf* xLf = calibTree_->GetLeaf("TrajGlbX");
374  TLeaf* yLf = calibTree_->GetLeaf("TrajGlbY");
375  TLeaf* zLf = calibTree_->GetLeaf("TrajGlbZ");
376  TLeaf* ResXSigLf = calibTree_->GetLeaf("ResXSig");
377  TLeaf* TrajLocXLf = calibTree_->GetLeaf("TrajLocX");
378  TLeaf* TrajLocYLf = calibTree_->GetLeaf("TrajLocY");
379  TLeaf* ClusterLocXLf = calibTree_->GetLeaf("ClusterLocX");
380  BunchLf = calibTree_->GetLeaf("bunchx");
381  InstLumiLf = calibTree_->GetLeaf("instLumi");
382  PULf = calibTree_->GetLeaf("PU");
383  TLeaf* CMLf = nullptr;
384  if (useCM_)
385  CMLf = calibTree_->GetLeaf("commonMode");
386 
387  int nevents = calibTree_->GetEntries();
388  LOGPRINT << "Successfully loaded analyze function with " << nevents << " events!\n";
389 
390  map<pair<unsigned int, unsigned int>, array<double, 3> >::iterator itEventInfos;
391 
392  //Loop through all of the events
393  for (int j = 0; j < nevents; j++) {
394  calibTree_->GetEntry(j);
395  run = (unsigned int)runLf->GetValue();
396  evt = (unsigned int)evtLf->GetValue();
397  unsigned int isBad = (unsigned int)BadLf->GetValue();
398  unsigned int quality = (unsigned int)sistripLf->GetValue();
399  unsigned int id = (unsigned int)idLf->GetValue();
400  unsigned int accept = (unsigned int)acceptLf->GetValue();
401  unsigned int layer_wheel = (unsigned int)layerLf->GetValue();
402  unsigned int layer = layer_wheel;
403  if (showRings_ && layer > 10) { // use rings instead of wheels
404  if (layer < 14)
405  layer = 10 + ((id >> 9) & 0x3); //TID 3 disks and also 3 rings -> use the same container
406  else
407  layer = 13 + ((id >> 5) & 0x7); //TEC
408  }
409  //unsigned int nHits = (unsigned int)nHitsLf->GetValue();
410  bool highPurity = (bool)highPurityLf->GetValue();
411  double x = xLf->GetValue();
412  double y = yLf->GetValue();
413  double z = zLf->GetValue();
414  double resxsig = ResXSigLf->GetValue();
415  double TrajLocX = TrajLocXLf->GetValue();
416  double TrajLocY = TrajLocYLf->GetValue();
417  double ClusterLocX = ClusterLocXLf->GetValue();
418  double TrajLocXMid;
419  double stripTrajMid;
420  double stripCluster;
421  bool badquality = false;
422 
423  instLumi = 0;
424  PU = 0;
425 
426  // if no special tree with event infos, they may be stored in the hit eff tree
427  if (!foundEventInfos) {
428  bx = (unsigned int)BunchLf->GetValue();
429  if (InstLumiLf != nullptr)
430  instLumi = InstLumiLf->GetValue(); // branch not filled by default
431  if (PULf != nullptr)
432  PU = PULf->GetValue(); // branch not filled by default
433  }
434  int CM = -100;
435  if (useCM_)
436  CM = CMLf->GetValue();
437 
438  // Get infos from eventInfos if they exist
439  if (foundEventInfos) {
440  itEventInfos = eventInfos.find(make_pair(run, evt));
441  if (itEventInfos != eventInfos.end()) {
442  bx = itEventInfos->second[0];
443  instLumi = itEventInfos->second[1];
444  PU = itEventInfos->second[2];
445  }
446  }
447 
448  //We have two things we want to do, both an XY color plot, and the efficiency measurement
449  //First, ignore anything that isn't in acceptance and isn't good quality
450 
451  if (bunchX_ > 0 && bunchX_ != bx)
452  continue;
453 
454  //if(quality == 1 || accept != 1 || nHits < 8) continue;
455  if (accept != 1)
456  continue;
458  continue;
459  if (quality == 1)
460  badquality = true;
461 
462  // don't compute efficiencies in modules from TOB6 and TEC9
463  if (!showTOB6TEC9_ && (layer_wheel == 10 || layer_wheel == siStripLayers_))
464  continue;
465 
466  // don't use bad modules given in the bad module list
467  itBadMod = badModules_list.find(id);
468  if (itBadMod != badModules_list.end())
469  continue;
470 
471  //Now that we have a good event, we need to look at if we expected it or not, and the location
472  //if we didn't
473  //Fill the missing hit information first
474  bool badflag = false;
475 
476  // By default uses the old matching method
477  if (resXSig_ < 0) {
478  if (isBad == 1)
479  badflag = true; // isBad set to false in the tree when resxsig<999.0
480  } else {
481  if (isBad == 1 || resxsig > resXSig_)
482  badflag = true;
483  }
484 
485  // Conversion of positions in strip unit
486  int nstrips = -9;
487  float Pitch = -9.0;
488 
489  if (resxsig == 1000.0) { // special treatment, no GeomDetUnit associated in some cases when no cluster found
490  Pitch = 0.0205; // maximum
491  nstrips = 768; // maximum
492  stripTrajMid = TrajLocX / Pitch + nstrips / 2.0;
493  stripCluster = ClusterLocX / Pitch + nstrips / 2.0;
494  } else {
495  DetId ClusterDetId(id);
496  const StripGeomDetUnit* stripdet = (const StripGeomDetUnit*)tkgeom.idToDetUnit(ClusterDetId);
497  const StripTopology& Topo = stripdet->specificTopology();
498  nstrips = Topo.nstrips();
499  Pitch = stripdet->surface().bounds().width() / Topo.nstrips();
500  stripTrajMid = TrajLocX / Pitch + nstrips / 2.0; //layer01->10
501  stripCluster = ClusterLocX / Pitch + nstrips / 2.0;
502 
503  // For trapezoidal modules: extrapolation of x trajectory position to the y middle of the module
504  // for correct comparison with cluster position
505  float hbedge = 0;
506  float htedge = 0;
507  float hapoth = 0;
508  if (layer >= 11) {
509  const BoundPlane& plane = stripdet->surface();
510  const TrapezoidalPlaneBounds* trapezoidalBounds(
511  dynamic_cast<const TrapezoidalPlaneBounds*>(&(plane.bounds())));
512  std::array<const float, 4> const& parameters = (*trapezoidalBounds).parameters();
513  hbedge = parameters[0];
514  htedge = parameters[1];
515  hapoth = parameters[3];
516  TrajLocXMid = TrajLocX / (1 + (htedge - hbedge) * TrajLocY / (htedge + hbedge) /
517  hapoth); // radialy extrapolated x loc position at middle
518  stripTrajMid = TrajLocXMid / Pitch + nstrips / 2.0;
519  }
520  }
521 
522  if (!badquality && layer < 23) {
523  if (resxsig != 1000.0)
524  resolutionPlots[layer]->Fill(stripTrajMid - stripCluster);
525  else
526  resolutionPlots[layer]->Fill(1000);
527  }
528 
529  // New matching methods
530  int tapv = -9;
531  int capv = -9;
532  float stripInAPV = 64.;
533 
534  if (clusterMatchingMethod_ >= 1) {
535  badflag = false; // reset
536  if (resxsig == 1000.0) { // default value when no cluster found in the module
537  badflag = true; // consider the module inefficient in this case
538  } else {
539  if (clusterMatchingMethod_ == 2 ||
540  clusterMatchingMethod_ == 4) { // check the distance between cluster and trajectory position
541  if (abs(stripCluster - stripTrajMid) > clusterTrajDist_)
542  badflag = true;
543  }
544  if (clusterMatchingMethod_ == 3 ||
546  4) { // cluster and traj have to be in the same APV (don't take edges into accounts)
547  tapv = (int)stripTrajMid / 128;
548  capv = (int)stripCluster / 128;
549  stripInAPV = stripTrajMid - tapv * 128;
550 
551  if (stripInAPV < stripsApvEdge_ || stripInAPV > 128 - stripsApvEdge_)
552  continue;
553  if (tapv != capv)
554  badflag = true;
555  }
556  }
557  }
558 
559  if (badflag && !badquality) {
560  hit temphit;
561  temphit.x = x;
562  temphit.y = y;
563  temphit.z = z;
564  temphit.id = id;
565  hits[layer].push_back(temphit);
566  }
567  pair<unsigned int, unsigned int> newgoodpair(1, 1);
568  pair<unsigned int, unsigned int> newbadpair(1, 0);
569  //First, figure out if the module already exists in the map of maps
570  map<unsigned int, pair<unsigned int, unsigned int> >::iterator it = modCounter[layer].find(id);
571  if (!badquality) {
572  if (it == modCounter[layer].end()) {
573  if (badflag)
574  modCounter[layer][id] = newbadpair;
575  else
576  modCounter[layer][id] = newgoodpair;
577  } else {
578  ((*it).second.first)++;
579  if (!badflag)
580  ((*it).second.second)++;
581  }
582 
583  if (layerfound_perBx.find(bx) == layerfound_perBx.end()) {
584  layerfound_perBx[bx] = vector<int>(23, 0);
585  layertotal_perBx[bx] = vector<int>(23, 0);
586  }
587  if (!badflag)
590 
591  if (!badflag)
594  if (!badflag)
595  layerfound_vsPU[layer]->Fill(PU);
596  layertotal_vsPU[layer]->Fill(PU);
597 
598  if (useCM_) {
599  if (!badflag)
600  layerfound_vsCM[layer]->Fill(CM);
601  layertotal_vsCM[layer]->Fill(CM);
602  }
603 
604  //Have to do the decoding for which side to go on (ugh)
605  if (layer <= 10) {
606  if (!badflag)
609  } else if (layer > 10 && layer < 14) {
610  if (((id >> 13) & 0x3) == 1) {
611  if (!badflag)
614  } else if (((id >> 13) & 0x3) == 2) {
615  if (!badflag)
616  goodlayerfound[layer + 3]++;
617  goodlayertotal[layer + 3]++;
618  }
619  } else if (layer > 13 && layer <= siStripLayers_) {
620  if (((id >> 18) & 0x3) == 1) {
621  if (!badflag)
622  goodlayerfound[layer + 3]++;
623  goodlayertotal[layer + 3]++;
624  } else if (((id >> 18) & 0x3) == 2) {
625  if (!badflag)
628  }
629  }
630  }
631  //Do the one where we don't exclude bad modules!
632  if (layer <= 10) {
633  if (!badflag)
634  alllayerfound[layer]++;
635  alllayertotal[layer]++;
636  } else if (layer > 10 && layer < 14) {
637  if (((id >> 13) & 0x3) == 1) {
638  if (!badflag)
639  alllayerfound[layer]++;
640  alllayertotal[layer]++;
641  } else if (((id >> 13) & 0x3) == 2) {
642  if (!badflag)
643  alllayerfound[layer + 3]++;
644  alllayertotal[layer + 3]++;
645  }
646  } else if (layer > 13 && layer <= siStripLayers_) {
647  if (((id >> 18) & 0x3) == 1) {
648  if (!badflag)
649  alllayerfound[layer + 3]++;
650  alllayertotal[layer + 3]++;
651  } else if (((id >> 18) & 0x3) == 2) {
652  if (!badflag)
653  alllayerfound[layer + 3 + nTEClayers]++;
654  alllayertotal[layer + 3 + nTEClayers]++;
655  }
656  }
657  //At this point, both of our maps are loaded with the correct information
658  }
659  } // go to next CalibTreeFile
660 
661  makeHotColdMaps();
663  makeSQLite();
664  totalStatistics();
665  makeSummary();
666  makeSummaryVsBx();
668  if (useCM_)
669  makeSummaryVsCM();
670 
672  //try to write out what's in the quality record
674  int NTkBadComponent[4]; //k: 0=BadModule, 1=BadFiber, 2=BadApv, 3=BadStrips
675  int NBadComponent[4][19][4];
676  //legend: NBadComponent[i][j][k]= SubSystem i, layer/disk/wheel j, BadModule/Fiber/Apv k
677  // i: 0=TIB, 1=TID, 2=TOB, 3=TEC
678  // k: 0=BadModule, 1=BadFiber, 2=BadApv, 3=BadStrips
679  std::stringstream ssV[4][19];
680 
681  for (int i = 0; i < 4; ++i) {
682  NTkBadComponent[i] = 0;
683  for (int j = 0; j < 19; ++j) {
684  ssV[i][j].str("");
685  for (int k = 0; k < 4; ++k)
686  NBadComponent[i][j][k] = 0;
687  }
688  }
689 
690  std::vector<SiStripQuality::BadComponent> BC = quality_->getBadComponentList();
691 
692  for (size_t i = 0; i < BC.size(); ++i) {
693  //&&&&&&&&&&&&&
694  //Full Tk
695  //&&&&&&&&&&&&&
696 
697  if (BC[i].BadModule)
698  NTkBadComponent[0]++;
699  if (BC[i].BadFibers)
700  NTkBadComponent[1] += ((BC[i].BadFibers >> 2) & 0x1) + ((BC[i].BadFibers >> 1) & 0x1) + ((BC[i].BadFibers) & 0x1);
701  if (BC[i].BadApvs)
702  NTkBadComponent[2] += ((BC[i].BadApvs >> 5) & 0x1) + ((BC[i].BadApvs >> 4) & 0x1) + ((BC[i].BadApvs >> 3) & 0x1) +
703  ((BC[i].BadApvs >> 2) & 0x1) + ((BC[i].BadApvs >> 1) & 0x1) + ((BC[i].BadApvs) & 0x1);
704 
705  //&&&&&&&&&&&&&&&&&
706  //Single SubSystem
707  //&&&&&&&&&&&&&&&&&
708 
709  int component;
710  SiStripDetId a(BC[i].detid);
711  if (a.subdetId() == SiStripDetId::TIB) {
712  //&&&&&&&&&&&&&&&&&
713  //TIB
714  //&&&&&&&&&&&&&&&&&
715 
716  component = tTopo.tibLayer(BC[i].detid);
717  setBadComponents(0, component, BC[i], ssV, NBadComponent);
718 
719  } else if (a.subdetId() == SiStripDetId::TID) {
720  //&&&&&&&&&&&&&&&&&
721  //TID
722  //&&&&&&&&&&&&&&&&&
723 
724  component = tTopo.tidSide(BC[i].detid) == 2 ? tTopo.tidWheel(BC[i].detid) : tTopo.tidWheel(BC[i].detid) + 3;
725  setBadComponents(1, component, BC[i], ssV, NBadComponent);
726 
727  } else if (a.subdetId() == SiStripDetId::TOB) {
728  //&&&&&&&&&&&&&&&&&
729  //TOB
730  //&&&&&&&&&&&&&&&&&
731 
732  component = tTopo.tobLayer(BC[i].detid);
733  setBadComponents(2, component, BC[i], ssV, NBadComponent);
734 
735  } else if (a.subdetId() == SiStripDetId::TEC) {
736  //&&&&&&&&&&&&&&&&&
737  //TEC
738  //&&&&&&&&&&&&&&&&&
739 
740  component = tTopo.tecSide(BC[i].detid) == 2 ? tTopo.tecWheel(BC[i].detid) : tTopo.tecWheel(BC[i].detid) + 9;
741  setBadComponents(3, component, BC[i], ssV, NBadComponent);
742  }
743  }
744 
745  //&&&&&&&&&&&&&&&&&&
746  // Single Strip Info
747  //&&&&&&&&&&&&&&&&&&
748  float percentage = 0;
749 
752 
753  for (SiStripBadStrip::RegistryIterator rp = rbegin; rp != rend; ++rp) {
754  unsigned int detid = rp->detid;
755 
756  int subdet = -999;
757  int component = -999;
758  SiStripDetId a(detid);
759  if (a.subdetId() == 3) {
760  subdet = 0;
761  component = tTopo.tibLayer(detid);
762  } else if (a.subdetId() == 4) {
763  subdet = 1;
764  component = tTopo.tidSide(detid) == 2 ? tTopo.tidWheel(detid) : tTopo.tidWheel(detid) + 3;
765  } else if (a.subdetId() == 5) {
766  subdet = 2;
767  component = tTopo.tobLayer(detid);
768  } else if (a.subdetId() == 6) {
769  subdet = 3;
770  component = tTopo.tecSide(detid) == 2 ? tTopo.tecWheel(detid) : tTopo.tecWheel(detid) + 9;
771  }
772 
773  SiStripQuality::Range sqrange =
775 
776  percentage = 0;
777  for (int it = 0; it < sqrange.second - sqrange.first; it++) {
778  unsigned int range = quality_->decode(*(sqrange.first + it)).range;
779  NTkBadComponent[3] += range;
780  NBadComponent[subdet][0][3] += range;
781  NBadComponent[subdet][component][3] += range;
782  percentage += range;
783  }
784  if (percentage != 0)
785  percentage /= 128. * detInfo_.getNumberOfApvsAndStripLength(detid).first;
786  if (percentage > 1)
787  edm::LogError("SiStripQualityStatistics") << "PROBLEM detid " << detid << " value " << percentage << std::endl;
788  }
789  //&&&&&&&&&&&&&&&&&&
790  // printout
791  //&&&&&&&&&&&&&&&&&&
792  std::ostringstream ss;
793 
794  ss << "\n-----------------\nNew IOV starting from run " << e.id().run() << " event " << e.id().event()
795  << " lumiBlock " << e.luminosityBlock() << " time " << e.time().value() << "\n-----------------\n";
796  ss << "\n-----------------\nGlobal Info\n-----------------";
797  ss << "\nBadComponent \t Modules \tFibers "
798  "\tApvs\tStrips\n----------------------------------------------------------------";
799  ss << "\nTracker:\t\t" << NTkBadComponent[0] << "\t" << NTkBadComponent[1] << "\t" << NTkBadComponent[2] << "\t"
800  << NTkBadComponent[3];
801  ss << "\nTIB:\t\t\t" << NBadComponent[0][0][0] << "\t" << NBadComponent[0][0][1] << "\t" << NBadComponent[0][0][2]
802  << "\t" << NBadComponent[0][0][3];
803  ss << "\nTID:\t\t\t" << NBadComponent[1][0][0] << "\t" << NBadComponent[1][0][1] << "\t" << NBadComponent[1][0][2]
804  << "\t" << NBadComponent[1][0][3];
805  ss << "\nTOB:\t\t\t" << NBadComponent[2][0][0] << "\t" << NBadComponent[2][0][1] << "\t" << NBadComponent[2][0][2]
806  << "\t" << NBadComponent[2][0][3];
807  ss << "\nTEC:\t\t\t" << NBadComponent[3][0][0] << "\t" << NBadComponent[3][0][1] << "\t" << NBadComponent[3][0][2]
808  << "\t" << NBadComponent[3][0][3];
809  ss << "\n";
810 
811  for (int i = 1; i < 5; ++i)
812  ss << "\nTIB Layer " << i << " :\t\t" << NBadComponent[0][i][0] << "\t" << NBadComponent[0][i][1] << "\t"
813  << NBadComponent[0][i][2] << "\t" << NBadComponent[0][i][3];
814  ss << "\n";
815  for (int i = 1; i < 4; ++i)
816  ss << "\nTID+ Disk " << i << " :\t\t" << NBadComponent[1][i][0] << "\t" << NBadComponent[1][i][1] << "\t"
817  << NBadComponent[1][i][2] << "\t" << NBadComponent[1][i][3];
818  for (int i = 4; i < 7; ++i)
819  ss << "\nTID- Disk " << i - 3 << " :\t\t" << NBadComponent[1][i][0] << "\t" << NBadComponent[1][i][1] << "\t"
820  << NBadComponent[1][i][2] << "\t" << NBadComponent[1][i][3];
821  ss << "\n";
822  for (int i = 1; i < 7; ++i)
823  ss << "\nTOB Layer " << i << " :\t\t" << NBadComponent[2][i][0] << "\t" << NBadComponent[2][i][1] << "\t"
824  << NBadComponent[2][i][2] << "\t" << NBadComponent[2][i][3];
825  ss << "\n";
826  for (int i = 1; i < 10; ++i)
827  ss << "\nTEC+ Disk " << i << " :\t\t" << NBadComponent[3][i][0] << "\t" << NBadComponent[3][i][1] << "\t"
828  << NBadComponent[3][i][2] << "\t" << NBadComponent[3][i][3];
829  for (int i = 10; i < 19; ++i)
830  ss << "\nTEC- Disk " << i - 9 << " :\t\t" << NBadComponent[3][i][0] << "\t" << NBadComponent[3][i][1] << "\t"
831  << NBadComponent[3][i][2] << "\t" << NBadComponent[3][i][3];
832  ss << "\n";
833 
834  ss << "\n----------------------------------------------------------------\n\t\t Detid \tModules Fibers "
835  "Apvs\n----------------------------------------------------------------";
836  for (int i = 1; i < 5; ++i)
837  ss << "\nTIB Layer " << i << " :" << ssV[0][i].str();
838  ss << "\n";
839  for (int i = 1; i < 4; ++i)
840  ss << "\nTID+ Disk " << i << " :" << ssV[1][i].str();
841  for (int i = 4; i < 7; ++i)
842  ss << "\nTID- Disk " << i - 3 << " :" << ssV[1][i].str();
843  ss << "\n";
844  for (int i = 1; i < 7; ++i)
845  ss << "\nTOB Layer " << i << " :" << ssV[2][i].str();
846  ss << "\n";
847  for (int i = 1; i < 10; ++i)
848  ss << "\nTEC+ Disk " << i << " :" << ssV[3][i].str();
849  for (int i = 10; i < 19; ++i)
850  ss << "\nTEC- Disk " << i - 9 << " :" << ssV[3][i].str();
851 
852  LOGPRINT << ss.str();
853 
854  // store also bad modules in log file
855  ofstream badModules;
856  badModules.open("BadModules.log");
857  badModules << "\n----------------------------------------------------------------\n\t\t Detid \tModules Fibers "
858  "Apvs\n----------------------------------------------------------------";
859  for (int i = 1; i < 5; ++i)
860  badModules << "\nTIB Layer " << i << " :" << ssV[0][i].str();
861  badModules << "\n";
862  for (int i = 1; i < 4; ++i)
863  badModules << "\nTID+ Disk " << i << " :" << ssV[1][i].str();
864  for (int i = 4; i < 7; ++i)
865  badModules << "\nTID- Disk " << i - 3 << " :" << ssV[1][i].str();
866  badModules << "\n";
867  for (int i = 1; i < 7; ++i)
868  badModules << "\nTOB Layer " << i << " :" << ssV[2][i].str();
869  badModules << "\n";
870  for (int i = 1; i < 10; ++i)
871  badModules << "\nTEC+ Disk " << i << " :" << ssV[3][i].str();
872  for (int i = 10; i < 19; ++i)
873  badModules << "\nTEC- Disk " << i - 9 << " :" << ssV[3][i].str();
874  badModules.close();
875 }
876 
878  LOGPRINT << "Entering hot cold map generation!\n";
879  TStyle* gStyle = new TStyle("gStyle", "myStyle");
880  gStyle->cd();
881  gStyle->SetPalette(1);
882  gStyle->SetCanvasColor(kWhite);
883  gStyle->SetOptStat(0);
884  //Here we make the hot/cold color maps that we love so very much
885  //Already have access to the data as a private variable
886  //Create all of the histograms in the TFileService
887  TH2F* temph2;
888  for (Long_t maplayer = 1; maplayer <= siStripLayers_; maplayer++) {
889  //Initialize all of the histograms
890  if (maplayer > 0 && maplayer <= 4) {
891  //We are in the TIB
892  temph2 = fs->make<TH2F>(Form("%s%i", "TIB", (int)(maplayer)), "TIB", 100, -1, 361, 100, -100, 100);
893  temph2->GetXaxis()->SetTitle("Phi");
894  temph2->GetXaxis()->SetBinLabel(1, TString("360"));
895  temph2->GetXaxis()->SetBinLabel(50, TString("180"));
896  temph2->GetXaxis()->SetBinLabel(100, TString("0"));
897  temph2->GetYaxis()->SetTitle("Global Z");
898  temph2->SetOption("colz");
899  HotColdMaps.push_back(temph2);
900  } else if (maplayer > 4 && maplayer <= 10) {
901  //We are in the TOB
902  temph2 = fs->make<TH2F>(Form("%s%i", "TOB", (int)(maplayer - 4)), "TOB", 100, -1, 361, 100, -120, 120);
903  temph2->GetXaxis()->SetTitle("Phi");
904  temph2->GetXaxis()->SetBinLabel(1, TString("360"));
905  temph2->GetXaxis()->SetBinLabel(50, TString("180"));
906  temph2->GetXaxis()->SetBinLabel(100, TString("0"));
907  temph2->GetYaxis()->SetTitle("Global Z");
908  temph2->SetOption("colz");
909  HotColdMaps.push_back(temph2);
910  } else if (maplayer > 10 && maplayer <= 13) {
911  //We are in the TID
912  //Split by +/-
913  temph2 = fs->make<TH2F>(Form("%s%i", "TID-", (int)(maplayer - 10)), "TID-", 100, -100, 100, 100, -100, 100);
914  temph2->GetXaxis()->SetTitle("Global Y");
915  temph2->GetXaxis()->SetBinLabel(1, TString("+Y"));
916  temph2->GetXaxis()->SetBinLabel(50, TString("0"));
917  temph2->GetXaxis()->SetBinLabel(100, TString("-Y"));
918  temph2->GetYaxis()->SetTitle("Global X");
919  temph2->GetYaxis()->SetBinLabel(1, TString("-X"));
920  temph2->GetYaxis()->SetBinLabel(50, TString("0"));
921  temph2->GetYaxis()->SetBinLabel(100, TString("+X"));
922  temph2->SetOption("colz");
923  HotColdMaps.push_back(temph2);
924  temph2 = fs->make<TH2F>(Form("%s%i", "TID+", (int)(maplayer - 10)), "TID+", 100, -100, 100, 100, -100, 100);
925  temph2->GetXaxis()->SetTitle("Global Y");
926  temph2->GetXaxis()->SetBinLabel(1, TString("+Y"));
927  temph2->GetXaxis()->SetBinLabel(50, TString("0"));
928  temph2->GetXaxis()->SetBinLabel(100, TString("-Y"));
929  temph2->GetYaxis()->SetTitle("Global X");
930  temph2->GetYaxis()->SetBinLabel(1, TString("-X"));
931  temph2->GetYaxis()->SetBinLabel(50, TString("0"));
932  temph2->GetYaxis()->SetBinLabel(100, TString("+X"));
933  temph2->SetOption("colz");
934  HotColdMaps.push_back(temph2);
935  } else if (maplayer > 13) {
936  //We are in the TEC
937  //Split by +/-
938  temph2 = fs->make<TH2F>(Form("%s%i", "TEC-", (int)(maplayer - 13)), "TEC-", 100, -120, 120, 100, -120, 120);
939  temph2->GetXaxis()->SetTitle("Global Y");
940  temph2->GetXaxis()->SetBinLabel(1, TString("+Y"));
941  temph2->GetXaxis()->SetBinLabel(50, TString("0"));
942  temph2->GetXaxis()->SetBinLabel(100, TString("-Y"));
943  temph2->GetYaxis()->SetTitle("Global X");
944  temph2->GetYaxis()->SetBinLabel(1, TString("-X"));
945  temph2->GetYaxis()->SetBinLabel(50, TString("0"));
946  temph2->GetYaxis()->SetBinLabel(100, TString("+X"));
947  temph2->SetOption("colz");
948  HotColdMaps.push_back(temph2);
949  temph2 = fs->make<TH2F>(Form("%s%i", "TEC+", (int)(maplayer - 13)), "TEC+", 100, -120, 120, 100, -120, 120);
950  temph2->GetXaxis()->SetTitle("Global Y");
951  temph2->GetXaxis()->SetBinLabel(1, TString("+Y"));
952  temph2->GetXaxis()->SetBinLabel(50, TString("0"));
953  temph2->GetXaxis()->SetBinLabel(100, TString("-Y"));
954  temph2->GetYaxis()->SetTitle("Global X");
955  temph2->GetYaxis()->SetBinLabel(1, TString("-X"));
956  temph2->GetYaxis()->SetBinLabel(50, TString("0"));
957  temph2->GetYaxis()->SetBinLabel(100, TString("+X"));
958  temph2->SetOption("colz");
959  HotColdMaps.push_back(temph2);
960  }
961  }
962  for (Long_t mylayer = 1; mylayer <= siStripLayers_; mylayer++) {
963  //Determine what kind of plot we want to write out
964  //Loop through the entirety of each layer
965  //Create an array of the histograms
966  vector<hit>::const_iterator iter;
967  for (iter = hits[mylayer].begin(); iter != hits[mylayer].end(); iter++) {
968  //Looping over the particular layer
969  //Fill by 360-x to get the proper location to compare with TKMaps of phi
970  //Also global xy is messed up
971  if (mylayer > 0 && mylayer <= 4) {
972  //We are in the TIB
973  float phi = ::calcPhi(iter->x, iter->y);
974  HotColdMaps[mylayer - 1]->Fill(360. - phi, iter->z, 1.);
975  } else if (mylayer > 4 && mylayer <= 10) {
976  //We are in the TOB
977  float phi = ::calcPhi(iter->x, iter->y);
978  HotColdMaps[mylayer - 1]->Fill(360. - phi, iter->z, 1.);
979  } else if (mylayer > 10 && mylayer <= 13) {
980  //We are in the TID
981  //There are 2 different maps here
982  int side = (((iter->id) >> 13) & 0x3);
983  if (side == 1)
984  HotColdMaps[(mylayer - 1) + (mylayer - 11)]->Fill(-iter->y, iter->x, 1.);
985  else if (side == 2)
986  HotColdMaps[(mylayer - 1) + (mylayer - 10)]->Fill(-iter->y, iter->x, 1.);
987  //if(side == 1) HotColdMaps[(mylayer - 1) + (mylayer - 11)]->Fill(iter->x,iter->y,1.);
988  //else if(side == 2) HotColdMaps[(mylayer - 1) + (mylayer - 10)]->Fill(iter->x,iter->y,1.);
989  } else if (mylayer > 13) {
990  //We are in the TEC
991  //There are 2 different maps here
992  int side = (((iter->id) >> 18) & 0x3);
993  if (side == 1)
994  HotColdMaps[(mylayer + 2) + (mylayer - 14)]->Fill(-iter->y, iter->x, 1.);
995  else if (side == 2)
996  HotColdMaps[(mylayer + 2) + (mylayer - 13)]->Fill(-iter->y, iter->x, 1.);
997  //if(side == 1) HotColdMaps[(mylayer + 2) + (mylayer - 14)]->Fill(iter->x,iter->y,1.);
998  //else if(side == 2) HotColdMaps[(mylayer + 2) + (mylayer - 13)]->Fill(iter->x,iter->y,1.);
999  }
1000  }
1001  }
1002  LOGPRINT << "Finished HotCold Map Generation\n";
1003 }
1004 
1005 void SiStripHitEffFromCalibTree::makeTKMap(bool autoTagging = false) {
1006  LOGPRINT << "Entering TKMap generation!\n";
1007  tkmap = new TrackerMap(" Detector Inefficiency ");
1008  tkmapbad = new TrackerMap(" Inefficient Modules ");
1009  tkmapeff = new TrackerMap(title_.Data());
1010  tkmapnum = new TrackerMap(" Detector numerator ");
1011  tkmapden = new TrackerMap(" Detector denominator ");
1012 
1013  double myeff, mynum, myden, myeff_up;
1014  double layer_min_eff = 0;
1015 
1016  for (Long_t i = 1; i <= siStripLayers_; i++) {
1017  //Loop over every layer, extracting the information from
1018  //the map of the efficiencies
1019  layertotal[i] = 0;
1020  layerfound[i] = 0;
1021  TH1F* hEffInLayer =
1022  fs->make<TH1F>(Form("eff_layer%i", int(i)), Form("Module efficiency in layer %i", int(i)), 201, 0, 1.005);
1023 
1024  for (const auto& ih : modCounter[i]) {
1025  //We should be in the layer in question, and looping over all of the modules in said layer
1026  //Generate the list for the TKmap, and the bad module list
1027  mynum = (double)((ih.second).second);
1028  myden = (double)((ih.second).first);
1029  if (myden > 0)
1030  myeff = mynum / myden;
1031  else
1032  myeff = 0;
1033  hEffInLayer->Fill(myeff);
1034 
1035  if (!autoTagging) {
1036  if ((myden >= nModsMin_) && (myeff < threshold_)) {
1037  //We have a bad module, put it in the list!
1038  BadModules[ih.first] = myeff;
1039  tkmapbad->fillc(ih.first, 255, 0, 0);
1040  LOGPRINT << "Layer " << i << " (" << ::layerName(i, showRings_, nTEClayers) << ") module " << ih.first
1041  << " efficiency: " << myeff << " , " << mynum << "/" << myden;
1042  } else {
1043  //Fill the bad list with empty results for every module
1044  tkmapbad->fillc(ih.first, 255, 255, 255);
1045  }
1046  if (myeff < threshold_)
1047  LOGPRINT << "Layer " << i << " (" << ::layerName(i, showRings_, nTEClayers) << ") module " << ih.first
1048  << " efficiency: " << myeff << " , " << mynum << "/" << myden;
1049  if (myden < nModsMin_) {
1050  LOGPRINT << "Layer " << i << " (" << ::layerName(i, showRings_, nTEClayers) << ") module " << ih.first
1051  << " is under occupancy at " << myden;
1052  }
1053  }
1054 
1055  //Put any module into the TKMap
1056  tkmap->fill(ih.first, 1. - myeff);
1057  tkmapeff->fill(ih.first, myeff);
1058  tkmapnum->fill(ih.first, mynum);
1059  tkmapden->fill(ih.first, myden);
1060 
1061  //Add the number of hits in the layer
1062  layertotal[i] += long(myden);
1063  layerfound[i] += long(mynum);
1064  }
1065 
1066  if (autoTagging) {
1067  //Compute threshold to use for each layer
1068  hEffInLayer->GetXaxis()->SetRange(3, hEffInLayer->GetNbinsX() + 1); // Remove from the avg modules below 1%
1069  layer_min_eff =
1070  hEffInLayer->GetMean() - 2.5 * hEffInLayer->GetRMS(); // uses RMS in case the distribution is wide
1071  if (threshold_ > 2.5 * hEffInLayer->GetRMS())
1072  layer_min_eff = hEffInLayer->GetMean() - threshold_; // otherwise uses the parameter 'threshold'
1073  LOGPRINT << "Layer " << i << " threshold for bad modules: <" << layer_min_eff
1074  << " (layer mean: " << hEffInLayer->GetMean() << " rms: " << hEffInLayer->GetRMS() << ")";
1075 
1076  hEffInLayer->GetXaxis()->SetRange(1, hEffInLayer->GetNbinsX() + 1);
1077 
1078  for (const auto& ih : modCounter[i]) {
1079  // Second loop over modules to tag inefficient ones
1080  mynum = (double)((ih.second).second);
1081  myden = (double)((ih.second).first);
1082  if (myden > 0)
1083  myeff = mynum / myden;
1084  else
1085  myeff = 0;
1086  // upper limit on the efficiency
1087  myeff_up = TEfficiency::Bayesian(myden, mynum, .99, 1, 1, true);
1088  if ((myden >= nModsMin_) && (myeff_up < layer_min_eff)) {
1089  //We have a bad module, put it in the list!
1090  BadModules[ih.first] = myeff;
1091  tkmapbad->fillc(ih.first, 255, 0, 0);
1092  } else {
1093  //Fill the bad list with empty results for every module
1094  tkmapbad->fillc(ih.first, 255, 255, 255);
1095  }
1096  if (myeff_up < layer_min_eff + 0.08) // printing message also for modules slighly above (8%) the limit
1097  LOGPRINT << "Layer " << i << " (" << ::layerName(i, showRings_, nTEClayers) << ") module " << ih.first
1098  << " efficiency: " << myeff << " , " << mynum << "/" << myden << " , upper limit: " << myeff_up;
1099  if (myden < nModsMin_) {
1100  LOGPRINT << "Layer " << i << " (" << ::layerName(i, showRings_, nTEClayers) << ") module " << ih.first
1101  << " layer " << i << " is under occupancy at " << myden;
1102  }
1103  }
1104  }
1105  }
1106  tkmap->save(true, 0, 0, "SiStripHitEffTKMap.png");
1107  tkmapbad->save(true, 0, 0, "SiStripHitEffTKMapBad.png");
1108  tkmapeff->save(true, tkMapMin_, 1., "SiStripHitEffTKMapEff.png");
1109  tkmapnum->save(true, 0, 0, "SiStripHitEffTKMapNum.png");
1110  tkmapden->save(true, 0, 0, "SiStripHitEffTKMapDen.png");
1111  LOGPRINT << "Finished TKMap Generation\n";
1112 }
1113 
1115  //Generate the SQLite file for use in the Database of the bad modules!
1116  LOGPRINT << "Entering SQLite file generation!\n";
1117  std::vector<unsigned int> BadStripList;
1118  unsigned short NStrips;
1119  unsigned int id1;
1120  std::unique_ptr<SiStripQuality> pQuality = std::make_unique<SiStripQuality>(detInfo_);
1121  //This is the list of the bad strips, use to mask out entire APVs
1122  //Now simply go through the bad hit list and mask out things that
1123  //are bad!
1124  for (const auto& it : BadModules) {
1125  //We need to figure out how many strips are in this particular module
1126  //To Mask correctly!
1127  NStrips = detInfo_.getNumberOfApvsAndStripLength(it.first).first * 128;
1128  LOGPRINT << "Number of strips module " << it.first << " is " << NStrips;
1129  BadStripList.push_back(pQuality->encode(0, NStrips, 0));
1130  //Now compact into a single bad module
1131  id1 = (unsigned int)it.first;
1132  LOGPRINT << "ID1 shoudl match list of modules above " << id1;
1133  quality_->compact(id1, BadStripList);
1134  SiStripQuality::Range range(BadStripList.begin(), BadStripList.end());
1135  quality_->put(id1, range);
1136  BadStripList.clear();
1137  }
1138  //Fill all the bad components now
1140 }
1141 
1143  //Calculate the statistics by layer
1144  int totalfound = 0;
1145  int totaltotal = 0;
1146  double layereff;
1147  int subdetfound[5];
1148  int subdettotal[5];
1149 
1150  for (Long_t i = 1; i < 5; i++) {
1151  subdetfound[i] = 0;
1152  subdettotal[i] = 0;
1153  }
1154 
1155  for (Long_t i = 1; i <= siStripLayers_; i++) {
1156  layereff = double(layerfound[i]) / double(layertotal[i]);
1157  LOGPRINT << "Layer " << i << " (" << ::layerName(i, showRings_, nTEClayers) << ") has total efficiency " << layereff
1158  << " " << layerfound[i] << "/" << layertotal[i];
1159  totalfound += layerfound[i];
1160  totaltotal += layertotal[i];
1161  if (i < 5) {
1162  subdetfound[1] += layerfound[i];
1163  subdettotal[1] += layertotal[i];
1164  }
1165  if (i >= 5 && i < 11) {
1166  subdetfound[2] += layerfound[i];
1167  subdettotal[2] += layertotal[i];
1168  }
1169  if (i >= 11 && i < 14) {
1170  subdetfound[3] += layerfound[i];
1171  subdettotal[3] += layertotal[i];
1172  }
1173  if (i >= 14) {
1174  subdetfound[4] += layerfound[i];
1175  subdettotal[4] += layertotal[i];
1176  }
1177  }
1178 
1179  LOGPRINT << "The total efficiency is " << double(totalfound) / double(totaltotal);
1180  LOGPRINT << " TIB: " << double(subdetfound[1]) / subdettotal[1] << " " << subdetfound[1] << "/"
1181  << subdettotal[1];
1182  LOGPRINT << " TOB: " << double(subdetfound[2]) / subdettotal[2] << " " << subdetfound[2] << "/"
1183  << subdettotal[2];
1184  LOGPRINT << " TID: " << double(subdetfound[3]) / subdettotal[3] << " " << subdetfound[3] << "/"
1185  << subdettotal[3];
1186  LOGPRINT << " TEC: " << double(subdetfound[4]) / subdettotal[4] << " " << subdetfound[4] << "/"
1187  << subdettotal[4];
1188 }
1189 
1191  //setTDRStyle();
1192 
1193  int nLayers = 34;
1194  if (showRings_)
1195  nLayers = 30;
1196  if (!showEndcapSides_) {
1197  if (!showRings_)
1199  else
1200  nLayers = 20;
1201  }
1202 
1203  TH1F* found = fs->make<TH1F>("found", "found", nLayers + 1, 0, nLayers + 1);
1204  TH1F* all = fs->make<TH1F>("all", "all", nLayers + 1, 0, nLayers + 1);
1205  TH1F* found2 = fs->make<TH1F>("found2", "found2", nLayers + 1, 0, nLayers + 1);
1206  TH1F* all2 = fs->make<TH1F>("all2", "all2", nLayers + 1, 0, nLayers + 1);
1207  // first bin only to keep real data off the y axis so set to -1
1208  found->SetBinContent(0, -1);
1209  all->SetBinContent(0, 1);
1210 
1211  // new ROOT version: TGraph::Divide don't handle null or negative values
1212  for (Long_t i = 1; i < nLayers + 2; ++i) {
1213  found->SetBinContent(i, 1e-6);
1214  all->SetBinContent(i, 1);
1215  found2->SetBinContent(i, 1e-6);
1216  all2->SetBinContent(i, 1);
1217  }
1218 
1219  TCanvas* c7 = new TCanvas("c7", " test ", 10, 10, 800, 600);
1220  c7->SetFillColor(0);
1221  c7->SetGrid();
1222 
1223  int nLayers_max = nLayers + 1; // barrel+endcap
1224  if (!showEndcapSides_)
1225  nLayers_max = 11; // barrel
1226  for (Long_t i = 1; i < nLayers_max; ++i) {
1227  LOGPRINT << "Fill only good modules layer " << i << ": S = " << goodlayerfound[i]
1228  << " B = " << goodlayertotal[i];
1229  if (goodlayertotal[i] > 5) {
1230  found->SetBinContent(i, goodlayerfound[i]);
1231  all->SetBinContent(i, goodlayertotal[i]);
1232  }
1233 
1234  LOGPRINT << "Filling all modules layer " << i << ": S = " << alllayerfound[i] << " B = " << alllayertotal[i];
1235  if (alllayertotal[i] > 5) {
1236  found2->SetBinContent(i, alllayerfound[i]);
1237  all2->SetBinContent(i, alllayertotal[i]);
1238  }
1239  }
1240 
1241  // endcap - merging sides
1242  if (!showEndcapSides_) {
1243  for (Long_t i = 11; i < 14; ++i) { // TID disks
1244  LOGPRINT << "Fill only good modules layer " << i << ": S = " << goodlayerfound[i] + goodlayerfound[i + 3]
1245  << " B = " << goodlayertotal[i] + goodlayertotal[i + 3];
1246  if (goodlayertotal[i] + goodlayertotal[i + 3] > 5) {
1247  found->SetBinContent(i, goodlayerfound[i] + goodlayerfound[i + 3]);
1248  all->SetBinContent(i, goodlayertotal[i] + goodlayertotal[i + 3]);
1249  }
1250  LOGPRINT << "Filling all modules layer " << i << ": S = " << alllayerfound[i] + alllayerfound[i + 3]
1251  << " B = " << alllayertotal[i] + alllayertotal[i + 3];
1252  if (alllayertotal[i] + alllayertotal[i + 3] > 5) {
1253  found2->SetBinContent(i, alllayerfound[i] + alllayerfound[i + 3]);
1254  all2->SetBinContent(i, alllayertotal[i] + alllayertotal[i + 3]);
1255  }
1256  }
1257  for (Long_t i = 17; i < 17 + nTEClayers; ++i) { // TEC disks
1258  LOGPRINT << "Fill only good modules layer " << i - 3
1259  << ": S = " << goodlayerfound[i] + goodlayerfound[i + nTEClayers]
1260  << " B = " << goodlayertotal[i] + goodlayertotal[i + nTEClayers];
1261  if (goodlayertotal[i] + goodlayertotal[i + nTEClayers] > 5) {
1262  found->SetBinContent(i - 3, goodlayerfound[i] + goodlayerfound[i + nTEClayers]);
1263  all->SetBinContent(i - 3, goodlayertotal[i] + goodlayertotal[i + nTEClayers]);
1264  }
1265  LOGPRINT << "Filling all modules layer " << i - 3 << ": S = " << alllayerfound[i] + alllayerfound[i + nTEClayers]
1266  << " B = " << alllayertotal[i] + alllayertotal[i + nTEClayers];
1267  if (alllayertotal[i] + alllayertotal[i + nTEClayers] > 5) {
1268  found2->SetBinContent(i - 3, alllayerfound[i] + alllayerfound[i + nTEClayers]);
1269  all2->SetBinContent(i - 3, alllayertotal[i] + alllayertotal[i + nTEClayers]);
1270  }
1271  }
1272  }
1273 
1274  found->Sumw2();
1275  all->Sumw2();
1276 
1277  found2->Sumw2();
1278  all2->Sumw2();
1279 
1280  TGraphAsymmErrors* gr = fs->make<TGraphAsymmErrors>(nLayers + 1);
1281  gr->SetName("eff_good");
1282  gr->BayesDivide(found, all);
1283 
1284  TGraphAsymmErrors* gr2 = fs->make<TGraphAsymmErrors>(nLayers + 1);
1285  gr2->SetName("eff_all");
1286  gr2->BayesDivide(found2, all2);
1287 
1288  for (int j = 0; j < nLayers + 1; j++) {
1289  gr->SetPointError(j, 0., 0., gr->GetErrorYlow(j), gr->GetErrorYhigh(j));
1290  gr2->SetPointError(j, 0., 0., gr2->GetErrorYlow(j), gr2->GetErrorYhigh(j));
1291  }
1292 
1293  gr->GetXaxis()->SetLimits(0, nLayers);
1294  gr->SetMarkerColor(2);
1295  gr->SetMarkerSize(1.2);
1296  gr->SetLineColor(2);
1297  gr->SetLineWidth(4);
1298  gr->SetMarkerStyle(20);
1299  gr->SetMinimum(effPlotMin_);
1300  gr->SetMaximum(1.001);
1301  gr->GetYaxis()->SetTitle("Efficiency");
1302  gStyle->SetTitleFillColor(0);
1303  gStyle->SetTitleBorderSize(0);
1304  gr->SetTitle(title_);
1305 
1306  gr2->GetXaxis()->SetLimits(0, nLayers);
1307  gr2->SetMarkerColor(1);
1308  gr2->SetMarkerSize(1.2);
1309  gr2->SetLineColor(1);
1310  gr2->SetLineWidth(4);
1311  gr2->SetMarkerStyle(21);
1312  gr2->SetMinimum(effPlotMin_);
1313  gr2->SetMaximum(1.001);
1314  gr2->GetYaxis()->SetTitle("Efficiency");
1315  gr2->SetTitle(title_);
1316 
1317  for (Long_t k = 1; k < nLayers + 1; k++) {
1318  TString label;
1319  if (showEndcapSides_)
1321  else
1322  label = ::layerName(k, showRings_, nTEClayers);
1323  if (!showTOB6TEC9_) {
1324  if (k == 10)
1325  label = "";
1326  if (!showRings_ && k == nLayers)
1327  label = "";
1328  if (!showRings_ && showEndcapSides_ && k == 25)
1329  label = "";
1330  }
1331  if (!showRings_) {
1332  if (showEndcapSides_) {
1333  gr->GetXaxis()->SetBinLabel(((k + 1) * 100 + 2) / (nLayers)-4, label);
1334  gr2->GetXaxis()->SetBinLabel(((k + 1) * 100 + 2) / (nLayers)-4, label);
1335  } else {
1336  gr->GetXaxis()->SetBinLabel((k + 1) * 100 / (nLayers)-6, label);
1337  gr2->GetXaxis()->SetBinLabel((k + 1) * 100 / (nLayers)-6, label);
1338  }
1339  } else {
1340  if (showEndcapSides_) {
1341  gr->GetXaxis()->SetBinLabel((k + 1) * 100 / (nLayers)-4, label);
1342  gr2->GetXaxis()->SetBinLabel((k + 1) * 100 / (nLayers)-4, label);
1343  } else {
1344  gr->GetXaxis()->SetBinLabel((k + 1) * 100 / (nLayers)-7, label);
1345  gr2->GetXaxis()->SetBinLabel((k + 1) * 100 / (nLayers)-7, label);
1346  }
1347  }
1348  }
1349 
1350  gr->Draw("AP");
1351  gr->GetXaxis()->SetNdivisions(36);
1352 
1353  c7->cd();
1354  TPad* overlay = new TPad("overlay", "", 0, 0, 1, 1);
1355  overlay->SetFillStyle(4000);
1356  overlay->SetFillColor(0);
1357  overlay->SetFrameFillStyle(4000);
1358  overlay->Draw("same");
1359  overlay->cd();
1360  if (!showOnlyGoodModules_)
1361  gr2->Draw("AP");
1362 
1363  TLegend* leg = new TLegend(0.70, 0.27, 0.88, 0.40);
1364  leg->AddEntry(gr, "Good Modules", "p");
1365  if (!showOnlyGoodModules_)
1366  leg->AddEntry(gr2, "All Modules", "p");
1367  leg->SetTextSize(0.020);
1368  leg->SetFillColor(0);
1369  leg->Draw("same");
1370 
1371  c7->SaveAs("Summary.png");
1372 }
1373 
1375  LOGPRINT << "Computing efficiency vs bx";
1376 
1377  unsigned int nLayers = siStripLayers_;
1378  if (showRings_)
1379  nLayers = 20;
1380 
1381  for (unsigned int ilayer = 1; ilayer < nLayers; ilayer++) {
1382  for (unsigned int ibx = 0; ibx <= nBxInAnOrbit_; ibx++) {
1383  layerfound_vsBX[ilayer]->SetBinContent(ibx, 1e-6);
1384  layertotal_vsBX[ilayer]->SetBinContent(ibx, 1);
1385  }
1386 
1387  for (const auto& iterMapvsBx : layerfound_perBx) {
1388  layerfound_vsBX[ilayer]->SetBinContent(iterMapvsBx.first, iterMapvsBx.second[ilayer]);
1389  }
1390  for (const auto& iterMapvsBx : layertotal_perBx) {
1391  if (iterMapvsBx.second[ilayer] > 0) {
1392  layertotal_vsBX[ilayer]->SetBinContent(iterMapvsBx.first, iterMapvsBx.second[ilayer]);
1393  }
1394  }
1395 
1396  layerfound_vsBX[ilayer]->Sumw2();
1397  layertotal_vsBX[ilayer]->Sumw2();
1398 
1399  TGraphAsymmErrors* geff = fs->make<TGraphAsymmErrors>(nBxInAnOrbit_ - 1);
1400  geff->SetName(Form("effVsBx_layer%i", ilayer));
1401 
1402  geff->SetTitle(fmt::format("Hit Efficiency vs bx - {}", ::layerName(ilayer, showRings_, nTEClayers)).c_str());
1403  geff->BayesDivide(layerfound_vsBX[ilayer], layertotal_vsBX[ilayer]);
1404 
1405  //Average over trains
1406  TGraphAsymmErrors* geff_avg = fs->make<TGraphAsymmErrors>();
1407  geff_avg->SetName(Form("effVsBxAvg_layer%i", ilayer));
1408  geff_avg->SetTitle(fmt::format("Hit Efficiency vs bx - {}", ::layerName(ilayer, showRings_, nTEClayers)).c_str());
1409  geff_avg->SetMarkerStyle(20);
1410  int ibx = 0;
1411  int previous_bx = -80;
1412  int delta_bx = 0;
1413  int nbx = 0;
1414  int found = 0;
1415  int total = 0;
1416  double sum_bx = 0;
1417  int ipt = 0;
1418  float low, up, eff;
1419  int firstbx = 0;
1420  for (const auto& iterMapvsBx : layertotal_perBx) {
1421  ibx = iterMapvsBx.first;
1422  delta_bx = ibx - previous_bx;
1423  // consider a new train
1424  if (delta_bx > (int)spaceBetweenTrains_ && nbx > 0 && total > 0) {
1425  eff = found / (float)total;
1426  //LOGPRINT<<"new train "<<ipt<<" "<<sum_bx/nbx<<" "<<eff<<endl;
1427  geff_avg->SetPoint(ipt, sum_bx / nbx, eff);
1428  low = TEfficiency::Bayesian(total, found, .683, 1, 1, false);
1429  up = TEfficiency::Bayesian(total, found, .683, 1, 1, true);
1430  geff_avg->SetPointError(ipt, sum_bx / nbx - firstbx, previous_bx - sum_bx / nbx, eff - low, up - eff);
1431  ipt++;
1432  sum_bx = 0;
1433  found = 0;
1434  total = 0;
1435  nbx = 0;
1436  firstbx = ibx;
1437  }
1438  sum_bx += ibx;
1439  found += layerfound_vsBX[ilayer]->GetBinContent(ibx);
1440  total += layertotal_vsBX[ilayer]->GetBinContent(ibx);
1441  nbx++;
1442 
1443  previous_bx = ibx;
1444  }
1445  //last train
1446  eff = found / (float)total;
1447  //LOGPRINT<<"new train "<<ipt<<" "<<sum_bx/nbx<<" "<<eff<<endl;
1448  geff_avg->SetPoint(ipt, sum_bx / nbx, eff);
1449  low = TEfficiency::Bayesian(total, found, .683, 1, 1, false);
1450  up = TEfficiency::Bayesian(total, found, .683, 1, 1, true);
1451  geff_avg->SetPointError(ipt, sum_bx / nbx - firstbx, previous_bx - sum_bx / nbx, eff - low, up - eff);
1452  }
1453 }
1454 
1455 void SiStripHitEffFromCalibTree::computeEff(vector<TH1F*>& vhfound, vector<TH1F*>& vhtotal, string name) {
1456  unsigned int nLayers = siStripLayers_;
1457  if (showRings_)
1458  nLayers = 20;
1459 
1460  TH1F* hfound;
1461  TH1F* htotal;
1462 
1463  for (unsigned int ilayer = 1; ilayer < nLayers; ilayer++) {
1464  hfound = vhfound[ilayer];
1465  htotal = vhtotal[ilayer];
1466 
1467  hfound->Sumw2();
1468  htotal->Sumw2();
1469 
1470  // new ROOT version: TGraph::Divide don't handle null or negative values
1471  for (Long_t i = 0; i < hfound->GetNbinsX() + 1; ++i) {
1472  if (hfound->GetBinContent(i) == 0)
1473  hfound->SetBinContent(i, 1e-6);
1474  if (htotal->GetBinContent(i) == 0)
1475  htotal->SetBinContent(i, 1);
1476  }
1477 
1478  TGraphAsymmErrors* geff = fs->make<TGraphAsymmErrors>(hfound->GetNbinsX());
1479  geff->SetName(Form("%s_layer%i", name.c_str(), ilayer));
1480  geff->BayesDivide(hfound, htotal);
1481  if (name == "effVsLumi")
1482  geff->SetTitle(
1483  fmt::format("Hit Efficiency vs inst. lumi. - {}", ::layerName(ilayer, showRings_, nTEClayers)).c_str());
1484  if (name == "effVsPU")
1485  geff->SetTitle(fmt::format("Hit Efficiency vs pileup - {}", ::layerName(ilayer, showRings_, nTEClayers)).c_str());
1486  if (name == "effVsCM")
1487  geff->SetTitle(
1488  fmt::format("Hit Efficiency vs common Mode - {}", ::layerName(ilayer, showRings_, nTEClayers)).c_str());
1489  geff->SetMarkerStyle(20);
1490  }
1491 }
1492 
1494  LOGPRINT << "Computing efficiency vs lumi";
1495 
1496  if (instLumiHisto->GetEntries()) // from infos per event
1497  LOGPRINT << "Avg conditions (avg+/-rms): lumi :" << instLumiHisto->GetMean() << "+/-" << instLumiHisto->GetRMS()
1498  << " pu: " << PUHisto->GetMean() << "+/-" << PUHisto->GetRMS();
1499 
1500  else { // from infos per hit
1501 
1502  unsigned int nLayers = siStripLayers_;
1503  if (showRings_)
1504  nLayers = 20;
1505  unsigned int nLayersForAvg = 0;
1506  float layerLumi = 0;
1507  float layerPU = 0;
1508  float avgLumi = 0;
1509  float avgPU = 0;
1510 
1511  LOGPRINT << "Lumi summary: (avg over trajectory measurements)";
1512  for (unsigned int ilayer = 1; ilayer < nLayers; ilayer++) {
1513  layerLumi = layertotal_vsLumi[ilayer]->GetMean();
1514  layerPU = layertotal_vsPU[ilayer]->GetMean();
1515  //LOGPRINT<<" layer "<<ilayer<<" lumi: "<<layerLumi<<" pu: "<<layerPU<<endl;
1516  if (layerLumi != 0 && layerPU != 0) {
1517  avgLumi += layerLumi;
1518  avgPU += layerPU;
1519  nLayersForAvg++;
1520  }
1521  }
1522  avgLumi /= nLayersForAvg;
1523  avgPU /= nLayersForAvg;
1524  LOGPRINT << "Avg conditions: lumi :" << avgLumi << " pu: " << avgPU;
1525  }
1526 
1529 }
1530 
1532  LOGPRINT << "Computing efficiency vs CM";
1534 }
1535 
1537  TString layername = "";
1538  TString ringlabel = "D";
1539  if (showRings_)
1540  ringlabel = "R";
1541  if (k > 0 && k < 5) {
1542  layername = TString("TIB L") + k;
1543  } else if (k > 4 && k < 11) {
1544  layername = TString("TOB L") + (k - 4);
1545  } else if (k > 10 && k < 14) {
1546  layername = TString("TID- ") + ringlabel + (k - 10);
1547  } else if (k > 13 && k < 17) {
1548  layername = TString("TID+ ") + ringlabel + (k - 13);
1549  } else if (k > 16 && k < 17 + nTEClayers) {
1550  layername = TString("TEC- ") + ringlabel + (k - 16);
1551  } else if (k > 16 + nTEClayers) {
1552  layername = TString("TEC+ ") + ringlabel + (k - 16 - nTEClayers);
1553  }
1554 
1555  return layername;
1556 }
1557 
1558 std::unique_ptr<SiStripBadStrip> SiStripHitEffFromCalibTree::getNewObject() {
1559  //Need this for a Condition DB Writer
1560  //Initialize a return variable
1561  auto obj = std::make_unique<SiStripBadStrip>();
1562 
1565 
1566  for (; rIter != rIterEnd; ++rIter) {
1568  quality_->getDataVectorBegin() + rIter->iend);
1569  if (!obj->put(rIter->detid, range))
1570  edm::LogError("SiStripHitEffFromCalibTree")
1571  << "[SiStripHitEffFromCalibTree::getNewObject] detid already exists" << std::endl;
1572  }
1573 
1574  return obj;
1575 }
1576 
1578  int i, int component, SiStripQuality::BadComponent& BC, std::stringstream ssV[4][19], int NBadComponent[4][19][4]) {
1579  int napv = detInfo_.getNumberOfApvsAndStripLength(BC.detid).first;
1580 
1581  ssV[i][component] << "\n\t\t " << BC.detid << " \t " << BC.BadModule << " \t " << ((BC.BadFibers) & 0x1) << " ";
1582  if (napv == 4)
1583  ssV[i][component] << "x " << ((BC.BadFibers >> 1) & 0x1);
1584 
1585  if (napv == 6)
1586  ssV[i][component] << ((BC.BadFibers >> 1) & 0x1) << " " << ((BC.BadFibers >> 2) & 0x1);
1587  ssV[i][component] << " \t " << ((BC.BadApvs) & 0x1) << " " << ((BC.BadApvs >> 1) & 0x1) << " ";
1588  if (napv == 4)
1589  ssV[i][component] << "x x " << ((BC.BadApvs >> 2) & 0x1) << " " << ((BC.BadApvs >> 3) & 0x1);
1590  if (napv == 6)
1591  ssV[i][component] << ((BC.BadApvs >> 2) & 0x1) << " " << ((BC.BadApvs >> 3) & 0x1) << " "
1592  << ((BC.BadApvs >> 4) & 0x1) << " " << ((BC.BadApvs >> 5) & 0x1) << " ";
1593 
1594  if (BC.BadApvs) {
1595  NBadComponent[i][0][2] += ((BC.BadApvs >> 5) & 0x1) + ((BC.BadApvs >> 4) & 0x1) + ((BC.BadApvs >> 3) & 0x1) +
1596  ((BC.BadApvs >> 2) & 0x1) + ((BC.BadApvs >> 1) & 0x1) + ((BC.BadApvs) & 0x1);
1597  NBadComponent[i][component][2] += ((BC.BadApvs >> 5) & 0x1) + ((BC.BadApvs >> 4) & 0x1) +
1598  ((BC.BadApvs >> 3) & 0x1) + ((BC.BadApvs >> 2) & 0x1) +
1599  ((BC.BadApvs >> 1) & 0x1) + ((BC.BadApvs) & 0x1);
1600  }
1601  if (BC.BadFibers) {
1602  NBadComponent[i][0][1] += ((BC.BadFibers >> 2) & 0x1) + ((BC.BadFibers >> 1) & 0x1) + ((BC.BadFibers) & 0x1);
1603  NBadComponent[i][component][1] +=
1604  ((BC.BadFibers >> 2) & 0x1) + ((BC.BadFibers >> 1) & 0x1) + ((BC.BadFibers) & 0x1);
1605  }
1606  if (BC.BadModule) {
1607  NBadComponent[i][0][0]++;
1608  NBadComponent[i][component][0]++;
1609  }
1610 }
1611 
map< unsigned int, double > BadModules
unsigned short range
static const std::string kSharedResource
Definition: TFileService.h:76
Definition: BitonicSort.h:7
map< unsigned int, vector< int > > layertotal_perBx
virtual int nstrips() const =0
void setBadComponents(int i, int component, SiStripQuality::BadComponent &BC, std::stringstream ssV[4][19], int NBadComponent[4][19][4])
ContainerIterator getDataVectorBegin() const
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::unique_ptr< SiStripBadStrip > getNewObject() override
#define LOGPRINT
def all(container)
workaround iterator generators for ROOT classes
Definition: cmstools.py:25
std::string fullPath() const
Definition: FileInPath.cc:161
map< unsigned int, vector< int > > layerfound_perBx
static constexpr auto TID
Definition: SiStripDetId.h:38
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
Registry::const_iterator RegistryIterator
map< pair< unsigned int, unsigned int >, array< double, 3 > > eventInfos
Log< level::Error, false > LogError
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:31
const std::vector< BadComponent > & getBadComponentList() const
T getUntrackedParameter(std::string const &, T const &) const
constexpr std::array< uint8_t, layerIndexSize< TrackerTraits > > layer
char const * label
string quality
def overlay(hists, ytitle, header, addon)
Definition: compare.py:122
edm::Service< TFileService > fs
void save(bool print_total=true, float minval=0., float maxval=0., std::string s="svgmap.svg", int width=1500, int height=800)
Definition: TrackerMap.cc:811
void compact(uint32_t detid, std::vector< unsigned int > &)
virtual const StripTopology & specificTopology() const
Returns a reference to the strip proxy topology.
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
RegistryIterator getRegistryVectorEnd() const
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
SiStripDetInfo read(std::string filePath)
void fillBadComponents()
static constexpr auto TOB
Definition: SiStripDetId.h:39
void computeEff(vector< TH1F *> &vhfound, vector< TH1F *> &vhtotal, string name)
void fillc(int idmod, int RGBcode)
Definition: TrackerMap.h:135
unsigned int id
Detector identifier class for the strip tracker.
Definition: SiStripDetId.h:18
Definition: DetId.h:17
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > tkGeomToken_
void setBadComponents(int i, int component, const SiStripQuality::BadComponent &BC, int NBadComponent[4][19][4])
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
const std::pair< unsigned short, double > getNumberOfApvsAndStripLength(uint32_t detId) const
static constexpr auto TIB
Definition: SiStripDetId.h:37
fixed size matrix
HLT enums.
void algoAnalyze(const edm::Event &e, const edm::EventSetup &c) override
double a
Definition: hdecay.h:119
std::pair< ContainerIterator, ContainerIterator > Range
data decode(const unsigned int &value) const
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
static constexpr char const *const kDefaultFile
bool put(const uint32_t &detID, const InputVector &vect)
#define str(s)
virtual float width() const =0
RegistryIterator getRegistryVectorBegin() const
SiStripHitEffFromCalibTree(const edm::ParameterSet &)
void fill(int layer, int ring, int nmod, float x)
Definition: TrackerMap.cc:3289
static constexpr auto TEC
Definition: SiStripDetId.h:40
map< unsigned int, pair< unsigned int, unsigned int > > modCounter[23]
const Bounds & bounds() const
Definition: Surface.h:87