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