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  CalibTreeFilenames = conf.getUntrackedParameter<vector<std::string> >("CalibTreeFilenames");
192  threshold = conf.getParameter<double>("Threshold");
193  nModsMin = conf.getParameter<int>("nModsMin");
194  doSummary = conf.getParameter<int>("doSummary");
195  _badModulesFile = conf.getUntrackedParameter<std::string>("BadModulesFile", "");
196  _autoIneffModTagging = conf.getUntrackedParameter<bool>("AutoIneffModTagging", false);
197  _clusterMatchingMethod = conf.getUntrackedParameter<int>("ClusterMatchingMethod", 0);
198  _ResXSig = conf.getUntrackedParameter<double>("ResXSig", -1);
199  _clusterTrajDist = conf.getUntrackedParameter<double>("ClusterTrajDist", 64.0);
200  _stripsApvEdge = conf.getUntrackedParameter<double>("StripsApvEdge", 10.0);
201  _useOnlyHighPurityTracks = conf.getUntrackedParameter<bool>("UseOnlyHighPurityTracks", true);
202  _bunchx = conf.getUntrackedParameter<int>("BunchCrossing", 0);
203  _spaceBetweenTrains = conf.getUntrackedParameter<int>("SpaceBetweenTrains", 25);
204  _useCM = conf.getUntrackedParameter<bool>("UseCommonMode", false);
205  _showEndcapSides = conf.getUntrackedParameter<bool>("ShowEndcapSides", true);
206  _showRings = conf.getUntrackedParameter<bool>("ShowRings", false);
207  _showTOB6TEC9 = conf.getUntrackedParameter<bool>("ShowTOB6TEC9", false);
208  _showOnlyGoodModules = conf.getUntrackedParameter<bool>("ShowOnlyGoodModules", false);
209  _tkMapMin = conf.getUntrackedParameter<double>("TkMapMin", 0.9);
210  _effPlotMin = conf.getUntrackedParameter<double>("EffPlotMin", 0.9);
211  _title = conf.getParameter<std::string>("Title");
215 
216  nTEClayers = 9; // number of wheels
217  if (_showRings)
218  nTEClayers = 7; // number of rings
219 
221 }
222 
224  //I have no idea what goes here
225  //fs->make<TTree>("HitEffHistos","Tree of the inefficient hit histograms");
226 }
227 
229  //Still have no idea what goes here
230 }
231 
233  const auto& tkgeom = c.getData(_tkGeomToken);
234  const auto& tTopo = c.getData(_tTopoToken);
235 
236  // read bad modules to mask
237  ifstream badModules_file;
238  set<uint32_t> badModules_list;
239  if (!_badModulesFile.empty()) {
240  badModules_file.open(_badModulesFile.c_str());
241  uint32_t badmodule_detid;
242  int mods, fiber1, fiber2, fiber3;
243  if (badModules_file.is_open()) {
244  string line;
245  while (getline(badModules_file, line)) {
246  if (badModules_file.eof())
247  continue;
248  stringstream ss(line);
249  ss >> badmodule_detid >> mods >> fiber1 >> fiber2 >> fiber3;
250  if (badmodule_detid != 0 && mods == 1 && (fiber1 == 1 || fiber2 == 1 || fiber3 == 1))
251  badModules_list.insert(badmodule_detid);
252  }
253  badModules_file.close();
254  }
255  }
256  if (!badModules_list.empty())
257  LOGPRINT << "Remove additionnal bad modules from the analysis: ";
258  set<uint32_t>::iterator itBadMod;
259  for (itBadMod = badModules_list.begin(); itBadMod != badModules_list.end(); ++itBadMod)
260  LOGPRINT << " " << *itBadMod;
261 
262  // initialze counters and histos
263 
264  bxHisto = fs->make<TH1F>("bx", "bx", 3600, 0, 3600);
265  instLumiHisto = fs->make<TH1F>("instLumi", "inst. lumi.", 250, 0, 25000);
266  PUHisto = fs->make<TH1F>("PU", "PU", 200, 0, 200);
267 
268  for (int l = 0; l < 35; l++) {
269  goodlayertotal[l] = 0;
270  goodlayerfound[l] = 0;
271  alllayertotal[l] = 0;
272  alllayerfound[l] = 0;
273  }
274 
275  TH1F* resolutionPlots[23];
276  for (Long_t ilayer = 0; ilayer < 23; ilayer++) {
277  std::string lyrName = ::layerName(ilayer, _showRings, nTEClayers);
278 
279  resolutionPlots[ilayer] = fs->make<TH1F>(Form("resol_layer_%i", (int)(ilayer)), lyrName.c_str(), 125, -125, 125);
280  resolutionPlots[ilayer]->GetXaxis()->SetTitle("trajX-clusX [strip unit]");
281 
282  layerfound_vsLumi.push_back(
283  fs->make<TH1F>(Form("layerfound_vsLumi_layer_%i", (int)(ilayer)), lyrName.c_str(), 100, 0, 25000));
284  layertotal_vsLumi.push_back(
285  fs->make<TH1F>(Form("layertotal_vsLumi_layer_%i", (int)(ilayer)), lyrName.c_str(), 100, 0, 25000));
286  layerfound_vsPU.push_back(
287  fs->make<TH1F>(Form("layerfound_vsPU_layer_%i", (int)(ilayer)), lyrName.c_str(), 45, 0, 90));
288  layertotal_vsPU.push_back(
289  fs->make<TH1F>(Form("layertotal_vsPU_layer_%i", (int)(ilayer)), lyrName.c_str(), 45, 0, 90));
290 
291  if (_useCM) {
292  layerfound_vsCM.push_back(
293  fs->make<TH1F>(Form("layerfound_vsCM_layer_%i", (int)(ilayer)), lyrName.c_str(), 20, 0, 400));
294  layertotal_vsCM.push_back(
295  fs->make<TH1F>(Form("layertotal_vsCM_layer_%i", (int)(ilayer)), lyrName.c_str(), 20, 0, 400));
296  }
297  layertotal[ilayer] = 0;
298  layerfound[ilayer] = 0;
299  }
300 
302  LOGPRINT << "A module is bad if efficiency < " << threshold << " and has at least " << nModsMin << " nModsMin.";
303  else
304  LOGPRINT << "A module is bad if the upper limit on the efficiency is < to the avg in the layer - " << threshold
305  << " and has at least " << nModsMin << " nModsMin.";
306 
307  unsigned int run, evt, bx{0};
308  double instLumi, PU;
309 
310  //Open the ROOT Calib Tree
311  for (unsigned int ifile = 0; ifile < CalibTreeFilenames.size(); ifile++) {
312  LOGPRINT << "Loading file: " << CalibTreeFilenames[ifile];
313  TFile* CalibTreeFile = TFile::Open(CalibTreeFilenames[ifile].c_str(), "READ");
314 
315  // Get event infos
316  bool foundEventInfos = false;
317  try {
318  CalibTreeFile->cd("eventInfo");
319  } catch (exception& e) {
320  LOGPRINT << "No event infos tree";
321  }
322  TTree* EventTree = (TTree*)(gDirectory->Get("tree"));
323 
324  TLeaf* runLf;
325  TLeaf* evtLf;
326  TLeaf* BunchLf;
327  TLeaf* InstLumiLf;
328  TLeaf* PULf;
329  if (EventTree) {
330  LOGPRINT << "Found event infos tree";
331 
332  runLf = EventTree->GetLeaf("run");
333  evtLf = EventTree->GetLeaf("event");
334 
335  BunchLf = EventTree->GetLeaf("bx");
336  InstLumiLf = EventTree->GetLeaf("instLumi");
337  PULf = EventTree->GetLeaf("PU");
338 
339  int nevt = EventTree->GetEntries();
340  if (nevt)
341  foundEventInfos = true;
342 
343  for (int j = 0; j < nevt; j++) {
344  EventTree->GetEntry(j);
345  run = runLf->GetValue();
346  evt = evtLf->GetValue();
347  bx = BunchLf->GetValue();
348  instLumi = InstLumiLf->GetValue();
349  PU = PULf->GetValue();
350 
351  bxHisto->Fill(bx);
352  instLumiHisto->Fill(instLumi);
353  PUHisto->Fill(PU);
354 
355  eventInfos[make_pair(run, evt)] = array<double, 3>{{(double)bx, instLumi, PU}};
356  }
357  }
358 
359  // Get hit infos
360  CalibTreeFile->cd("anEff");
361  CalibTree = (TTree*)(gDirectory->Get("traj"));
362 
363  runLf = CalibTree->GetLeaf("run");
364  evtLf = CalibTree->GetLeaf("event");
365  TLeaf* BadLf = CalibTree->GetLeaf("ModIsBad");
366  TLeaf* sistripLf = CalibTree->GetLeaf("SiStripQualBad");
367  TLeaf* idLf = CalibTree->GetLeaf("Id");
368  TLeaf* acceptLf = CalibTree->GetLeaf("withinAcceptance");
369  TLeaf* layerLf = CalibTree->GetLeaf("layer");
370  //TLeaf* nHitsLf = CalibTree->GetLeaf("nHits");
371  TLeaf* highPurityLf = CalibTree->GetLeaf("highPurity");
372  TLeaf* xLf = CalibTree->GetLeaf("TrajGlbX");
373  TLeaf* yLf = CalibTree->GetLeaf("TrajGlbY");
374  TLeaf* zLf = CalibTree->GetLeaf("TrajGlbZ");
375  TLeaf* ResXSigLf = CalibTree->GetLeaf("ResXSig");
376  TLeaf* TrajLocXLf = CalibTree->GetLeaf("TrajLocX");
377  TLeaf* TrajLocYLf = CalibTree->GetLeaf("TrajLocY");
378  TLeaf* ClusterLocXLf = CalibTree->GetLeaf("ClusterLocX");
379  BunchLf = CalibTree->GetLeaf("bunchx");
380  InstLumiLf = CalibTree->GetLeaf("instLumi");
381  PULf = CalibTree->GetLeaf("PU");
382  TLeaf* CMLf = nullptr;
383  if (_useCM)
384  CMLf = CalibTree->GetLeaf("commonMode");
385 
386  int nevents = CalibTree->GetEntries();
387  LOGPRINT << "Successfully loaded analyze function with " << nevents << " events!\n";
388 
389  map<pair<unsigned int, unsigned int>, array<double, 3> >::iterator itEventInfos;
390 
391  //Loop through all of the events
392  for (int j = 0; j < nevents; j++) {
393  CalibTree->GetEntry(j);
394  run = (unsigned int)runLf->GetValue();
395  evt = (unsigned int)evtLf->GetValue();
396  unsigned int isBad = (unsigned int)BadLf->GetValue();
397  unsigned int quality = (unsigned int)sistripLf->GetValue();
398  unsigned int id = (unsigned int)idLf->GetValue();
399  unsigned int accept = (unsigned int)acceptLf->GetValue();
400  unsigned int layer_wheel = (unsigned int)layerLf->GetValue();
401  unsigned int layer = layer_wheel;
402  if (_showRings && layer > 10) { // use rings instead of wheels
403  if (layer < 14)
404  layer = 10 + ((id >> 9) & 0x3); //TID 3 disks and also 3 rings -> use the same container
405  else
406  layer = 13 + ((id >> 5) & 0x7); //TEC
407  }
408  //unsigned int nHits = (unsigned int)nHitsLf->GetValue();
409  bool highPurity = (bool)highPurityLf->GetValue();
410  double x = xLf->GetValue();
411  double y = yLf->GetValue();
412  double z = zLf->GetValue();
413  double resxsig = ResXSigLf->GetValue();
414  double TrajLocX = TrajLocXLf->GetValue();
415  double TrajLocY = TrajLocYLf->GetValue();
416  double ClusterLocX = ClusterLocXLf->GetValue();
417  double TrajLocXMid;
418  double stripTrajMid;
419  double stripCluster;
420  bool badquality = false;
421 
422  instLumi = 0;
423  PU = 0;
424 
425  // if no special tree with event infos, they may be stored in the hit eff tree
426  if (!foundEventInfos) {
427  bx = (unsigned int)BunchLf->GetValue();
428  if (InstLumiLf != nullptr)
429  instLumi = InstLumiLf->GetValue(); // branch not filled by default
430  if (PULf != nullptr)
431  PU = PULf->GetValue(); // branch not filled by default
432  }
433  int CM = -100;
434  if (_useCM)
435  CM = CMLf->GetValue();
436 
437  // Get infos from eventInfos if they exist
438  if (foundEventInfos) {
439  itEventInfos = eventInfos.find(make_pair(run, evt));
440  if (itEventInfos != eventInfos.end()) {
441  bx = itEventInfos->second[0];
442  instLumi = itEventInfos->second[1];
443  PU = itEventInfos->second[2];
444  }
445  }
446 
447  //We have two things we want to do, both an XY color plot, and the efficiency measurement
448  //First, ignore anything that isn't in acceptance and isn't good quality
449 
450  if (_bunchx > 0 && _bunchx != bx)
451  continue;
452 
453  //if(quality == 1 || accept != 1 || nHits < 8) continue;
454  if (accept != 1)
455  continue;
457  continue;
458  if (quality == 1)
459  badquality = true;
460 
461  // don't compute efficiencies in modules from TOB6 and TEC9
462  if (!_showTOB6TEC9 && (layer_wheel == 10 || layer_wheel == SiStripLayers))
463  continue;
464 
465  // don't use bad modules given in the bad module list
466  itBadMod = badModules_list.find(id);
467  if (itBadMod != badModules_list.end())
468  continue;
469 
470  //Now that we have a good event, we need to look at if we expected it or not, and the location
471  //if we didn't
472  //Fill the missing hit information first
473  bool badflag = false;
474 
475  // By default uses the old matching method
476  if (_ResXSig < 0) {
477  if (isBad == 1)
478  badflag = true; // isBad set to false in the tree when resxsig<999.0
479  } else {
480  if (isBad == 1 || resxsig > _ResXSig)
481  badflag = true;
482  }
483 
484  // Conversion of positions in strip unit
485  int nstrips = -9;
486  float Pitch = -9.0;
487 
488  if (resxsig == 1000.0) { // special treatment, no GeomDetUnit associated in some cases when no cluster found
489  Pitch = 0.0205; // maximum
490  nstrips = 768; // maximum
491  stripTrajMid = TrajLocX / Pitch + nstrips / 2.0;
492  stripCluster = ClusterLocX / Pitch + nstrips / 2.0;
493  } else {
494  DetId ClusterDetId(id);
495  const StripGeomDetUnit* stripdet = (const StripGeomDetUnit*)tkgeom.idToDetUnit(ClusterDetId);
496  const StripTopology& Topo = stripdet->specificTopology();
497  nstrips = Topo.nstrips();
498  Pitch = stripdet->surface().bounds().width() / Topo.nstrips();
499  stripTrajMid = TrajLocX / Pitch + nstrips / 2.0; //layer01->10
500  stripCluster = ClusterLocX / Pitch + nstrips / 2.0;
501 
502  // For trapezoidal modules: extrapolation of x trajectory position to the y middle of the module
503  // for correct comparison with cluster position
504  float hbedge = 0;
505  float htedge = 0;
506  float hapoth = 0;
507  if (layer >= 11) {
508  const BoundPlane& plane = stripdet->surface();
509  const TrapezoidalPlaneBounds* trapezoidalBounds(
510  dynamic_cast<const TrapezoidalPlaneBounds*>(&(plane.bounds())));
511  std::array<const float, 4> const& parameters = (*trapezoidalBounds).parameters();
512  hbedge = parameters[0];
513  htedge = parameters[1];
514  hapoth = parameters[3];
515  TrajLocXMid = TrajLocX / (1 + (htedge - hbedge) * TrajLocY / (htedge + hbedge) /
516  hapoth); // radialy extrapolated x loc position at middle
517  stripTrajMid = TrajLocXMid / Pitch + nstrips / 2.0;
518  }
519  }
520 
521  if (!badquality && layer < 23) {
522  if (resxsig != 1000.0)
523  resolutionPlots[layer]->Fill(stripTrajMid - stripCluster);
524  else
525  resolutionPlots[layer]->Fill(1000);
526  }
527 
528  // New matching methods
529  int tapv = -9;
530  int capv = -9;
531  float stripInAPV = 64.;
532 
533  if (_clusterMatchingMethod >= 1) {
534  badflag = false; // reset
535  if (resxsig == 1000.0) { // default value when no cluster found in the module
536  badflag = true; // consider the module inefficient in this case
537  } else {
538  if (_clusterMatchingMethod == 2 ||
539  _clusterMatchingMethod == 4) { // check the distance between cluster and trajectory position
540  if (abs(stripCluster - stripTrajMid) > _clusterTrajDist)
541  badflag = true;
542  }
543  if (_clusterMatchingMethod == 3 ||
545  4) { // cluster and traj have to be in the same APV (don't take edges into accounts)
546  tapv = (int)stripTrajMid / 128;
547  capv = (int)stripCluster / 128;
548  stripInAPV = stripTrajMid - tapv * 128;
549 
550  if (stripInAPV < _stripsApvEdge || stripInAPV > 128 - _stripsApvEdge)
551  continue;
552  if (tapv != capv)
553  badflag = true;
554  }
555  }
556  }
557 
558  if (badflag && !badquality) {
559  hit temphit;
560  temphit.x = x;
561  temphit.y = y;
562  temphit.z = z;
563  temphit.id = id;
564  hits[layer].push_back(temphit);
565  }
566  pair<unsigned int, unsigned int> newgoodpair(1, 1);
567  pair<unsigned int, unsigned int> newbadpair(1, 0);
568  //First, figure out if the module already exists in the map of maps
569  map<unsigned int, pair<unsigned int, unsigned int> >::iterator it = modCounter[layer].find(id);
570  if (!badquality) {
571  if (it == modCounter[layer].end()) {
572  if (badflag)
573  modCounter[layer][id] = newbadpair;
574  else
575  modCounter[layer][id] = newgoodpair;
576  } else {
577  ((*it).second.first)++;
578  if (!badflag)
579  ((*it).second.second)++;
580  }
581 
582  if (layerfound_perBx.find(bx) == layerfound_perBx.end()) {
583  layerfound_perBx[bx] = vector<int>(23, 0);
584  layertotal_perBx[bx] = vector<int>(23, 0);
585  }
586  if (!badflag)
589 
590  if (!badflag)
593  if (!badflag)
594  layerfound_vsPU[layer]->Fill(PU);
595  layertotal_vsPU[layer]->Fill(PU);
596 
597  if (_useCM) {
598  if (!badflag)
599  layerfound_vsCM[layer]->Fill(CM);
600  layertotal_vsCM[layer]->Fill(CM);
601  }
602 
603  //Have to do the decoding for which side to go on (ugh)
604  if (layer <= 10) {
605  if (!badflag)
608  } else if (layer > 10 && layer < 14) {
609  if (((id >> 13) & 0x3) == 1) {
610  if (!badflag)
613  } else if (((id >> 13) & 0x3) == 2) {
614  if (!badflag)
615  goodlayerfound[layer + 3]++;
616  goodlayertotal[layer + 3]++;
617  }
618  } else if (layer > 13 && layer <= SiStripLayers) {
619  if (((id >> 18) & 0x3) == 1) {
620  if (!badflag)
621  goodlayerfound[layer + 3]++;
622  goodlayertotal[layer + 3]++;
623  } else if (((id >> 18) & 0x3) == 2) {
624  if (!badflag)
627  }
628  }
629  }
630  //Do the one where we don't exclude bad modules!
631  if (layer <= 10) {
632  if (!badflag)
633  alllayerfound[layer]++;
634  alllayertotal[layer]++;
635  } else if (layer > 10 && layer < 14) {
636  if (((id >> 13) & 0x3) == 1) {
637  if (!badflag)
638  alllayerfound[layer]++;
639  alllayertotal[layer]++;
640  } else if (((id >> 13) & 0x3) == 2) {
641  if (!badflag)
642  alllayerfound[layer + 3]++;
643  alllayertotal[layer + 3]++;
644  }
645  } else if (layer > 13 && layer <= SiStripLayers) {
646  if (((id >> 18) & 0x3) == 1) {
647  if (!badflag)
648  alllayerfound[layer + 3]++;
649  alllayertotal[layer + 3]++;
650  } else if (((id >> 18) & 0x3) == 2) {
651  if (!badflag)
652  alllayerfound[layer + 3 + nTEClayers]++;
653  alllayertotal[layer + 3 + nTEClayers]++;
654  }
655  }
656  //At this point, both of our maps are loaded with the correct information
657  }
658  } // go to next CalibTreeFile
659 
660  makeHotColdMaps();
662  makeSQLite();
663  totalStatistics();
664  makeSummary();
665  makeSummaryVsBx();
667  if (_useCM)
668  makeSummaryVsCM();
669 
671  //try to write out what's in the quality record
673  int NTkBadComponent[4]; //k: 0=BadModule, 1=BadFiber, 2=BadApv, 3=BadStrips
674  int NBadComponent[4][19][4];
675  //legend: NBadComponent[i][j][k]= SubSystem i, layer/disk/wheel j, BadModule/Fiber/Apv k
676  // i: 0=TIB, 1=TID, 2=TOB, 3=TEC
677  // k: 0=BadModule, 1=BadFiber, 2=BadApv, 3=BadStrips
678  std::stringstream ssV[4][19];
679 
680  for (int i = 0; i < 4; ++i) {
681  NTkBadComponent[i] = 0;
682  for (int j = 0; j < 19; ++j) {
683  ssV[i][j].str("");
684  for (int k = 0; k < 4; ++k)
685  NBadComponent[i][j][k] = 0;
686  }
687  }
688 
689  std::vector<SiStripQuality::BadComponent> BC = quality_->getBadComponentList();
690 
691  for (size_t i = 0; i < BC.size(); ++i) {
692  //&&&&&&&&&&&&&
693  //Full Tk
694  //&&&&&&&&&&&&&
695 
696  if (BC[i].BadModule)
697  NTkBadComponent[0]++;
698  if (BC[i].BadFibers)
699  NTkBadComponent[1] += ((BC[i].BadFibers >> 2) & 0x1) + ((BC[i].BadFibers >> 1) & 0x1) + ((BC[i].BadFibers) & 0x1);
700  if (BC[i].BadApvs)
701  NTkBadComponent[2] += ((BC[i].BadApvs >> 5) & 0x1) + ((BC[i].BadApvs >> 4) & 0x1) + ((BC[i].BadApvs >> 3) & 0x1) +
702  ((BC[i].BadApvs >> 2) & 0x1) + ((BC[i].BadApvs >> 1) & 0x1) + ((BC[i].BadApvs) & 0x1);
703 
704  //&&&&&&&&&&&&&&&&&
705  //Single SubSystem
706  //&&&&&&&&&&&&&&&&&
707 
708  int component;
709  SiStripDetId a(BC[i].detid);
710  if (a.subdetId() == SiStripDetId::TIB) {
711  //&&&&&&&&&&&&&&&&&
712  //TIB
713  //&&&&&&&&&&&&&&&&&
714 
715  component = tTopo.tibLayer(BC[i].detid);
716  SetBadComponents(0, component, BC[i], ssV, NBadComponent);
717 
718  } else if (a.subdetId() == SiStripDetId::TID) {
719  //&&&&&&&&&&&&&&&&&
720  //TID
721  //&&&&&&&&&&&&&&&&&
722 
723  component = tTopo.tidSide(BC[i].detid) == 2 ? tTopo.tidWheel(BC[i].detid) : tTopo.tidWheel(BC[i].detid) + 3;
724  SetBadComponents(1, component, BC[i], ssV, NBadComponent);
725 
726  } else if (a.subdetId() == SiStripDetId::TOB) {
727  //&&&&&&&&&&&&&&&&&
728  //TOB
729  //&&&&&&&&&&&&&&&&&
730 
731  component = tTopo.tobLayer(BC[i].detid);
732  SetBadComponents(2, component, BC[i], ssV, NBadComponent);
733 
734  } else if (a.subdetId() == SiStripDetId::TEC) {
735  //&&&&&&&&&&&&&&&&&
736  //TEC
737  //&&&&&&&&&&&&&&&&&
738 
739  component = tTopo.tecSide(BC[i].detid) == 2 ? tTopo.tecWheel(BC[i].detid) : tTopo.tecWheel(BC[i].detid) + 9;
740  SetBadComponents(3, component, BC[i], ssV, NBadComponent);
741  }
742  }
743 
744  //&&&&&&&&&&&&&&&&&&
745  // Single Strip Info
746  //&&&&&&&&&&&&&&&&&&
747  float percentage = 0;
748 
751 
752  for (SiStripBadStrip::RegistryIterator rp = rbegin; rp != rend; ++rp) {
753  unsigned int detid = rp->detid;
754 
755  int subdet = -999;
756  int component = -999;
757  SiStripDetId a(detid);
758  if (a.subdetId() == 3) {
759  subdet = 0;
760  component = tTopo.tibLayer(detid);
761  } else if (a.subdetId() == 4) {
762  subdet = 1;
763  component = tTopo.tidSide(detid) == 2 ? tTopo.tidWheel(detid) : tTopo.tidWheel(detid) + 3;
764  } else if (a.subdetId() == 5) {
765  subdet = 2;
766  component = tTopo.tobLayer(detid);
767  } else if (a.subdetId() == 6) {
768  subdet = 3;
769  component = tTopo.tecSide(detid) == 2 ? tTopo.tecWheel(detid) : tTopo.tecWheel(detid) + 9;
770  }
771 
772  SiStripQuality::Range sqrange =
774 
775  percentage = 0;
776  for (int it = 0; it < sqrange.second - sqrange.first; it++) {
777  unsigned int range = quality_->decode(*(sqrange.first + it)).range;
778  NTkBadComponent[3] += range;
779  NBadComponent[subdet][0][3] += range;
780  NBadComponent[subdet][component][3] += range;
781  percentage += range;
782  }
783  if (percentage != 0)
784  percentage /= 128. * _detInfo.getNumberOfApvsAndStripLength(detid).first;
785  if (percentage > 1)
786  edm::LogError("SiStripQualityStatistics") << "PROBLEM detid " << detid << " value " << percentage << std::endl;
787  }
788  //&&&&&&&&&&&&&&&&&&
789  // printout
790  //&&&&&&&&&&&&&&&&&&
791  std::ostringstream ss;
792 
793  ss << "\n-----------------\nNew IOV starting from run " << e.id().run() << " event " << e.id().event()
794  << " lumiBlock " << e.luminosityBlock() << " time " << e.time().value() << "\n-----------------\n";
795  ss << "\n-----------------\nGlobal Info\n-----------------";
796  ss << "\nBadComponent \t Modules \tFibers "
797  "\tApvs\tStrips\n----------------------------------------------------------------";
798  ss << "\nTracker:\t\t" << NTkBadComponent[0] << "\t" << NTkBadComponent[1] << "\t" << NTkBadComponent[2] << "\t"
799  << NTkBadComponent[3];
800  ss << "\nTIB:\t\t\t" << NBadComponent[0][0][0] << "\t" << NBadComponent[0][0][1] << "\t" << NBadComponent[0][0][2]
801  << "\t" << NBadComponent[0][0][3];
802  ss << "\nTID:\t\t\t" << NBadComponent[1][0][0] << "\t" << NBadComponent[1][0][1] << "\t" << NBadComponent[1][0][2]
803  << "\t" << NBadComponent[1][0][3];
804  ss << "\nTOB:\t\t\t" << NBadComponent[2][0][0] << "\t" << NBadComponent[2][0][1] << "\t" << NBadComponent[2][0][2]
805  << "\t" << NBadComponent[2][0][3];
806  ss << "\nTEC:\t\t\t" << NBadComponent[3][0][0] << "\t" << NBadComponent[3][0][1] << "\t" << NBadComponent[3][0][2]
807  << "\t" << NBadComponent[3][0][3];
808  ss << "\n";
809 
810  for (int i = 1; i < 5; ++i)
811  ss << "\nTIB Layer " << i << " :\t\t" << NBadComponent[0][i][0] << "\t" << NBadComponent[0][i][1] << "\t"
812  << NBadComponent[0][i][2] << "\t" << NBadComponent[0][i][3];
813  ss << "\n";
814  for (int i = 1; i < 4; ++i)
815  ss << "\nTID+ Disk " << i << " :\t\t" << NBadComponent[1][i][0] << "\t" << NBadComponent[1][i][1] << "\t"
816  << NBadComponent[1][i][2] << "\t" << NBadComponent[1][i][3];
817  for (int i = 4; i < 7; ++i)
818  ss << "\nTID- Disk " << i - 3 << " :\t\t" << NBadComponent[1][i][0] << "\t" << NBadComponent[1][i][1] << "\t"
819  << NBadComponent[1][i][2] << "\t" << NBadComponent[1][i][3];
820  ss << "\n";
821  for (int i = 1; i < 7; ++i)
822  ss << "\nTOB Layer " << i << " :\t\t" << NBadComponent[2][i][0] << "\t" << NBadComponent[2][i][1] << "\t"
823  << NBadComponent[2][i][2] << "\t" << NBadComponent[2][i][3];
824  ss << "\n";
825  for (int i = 1; i < 10; ++i)
826  ss << "\nTEC+ Disk " << i << " :\t\t" << NBadComponent[3][i][0] << "\t" << NBadComponent[3][i][1] << "\t"
827  << NBadComponent[3][i][2] << "\t" << NBadComponent[3][i][3];
828  for (int i = 10; i < 19; ++i)
829  ss << "\nTEC- Disk " << i - 9 << " :\t\t" << NBadComponent[3][i][0] << "\t" << NBadComponent[3][i][1] << "\t"
830  << NBadComponent[3][i][2] << "\t" << NBadComponent[3][i][3];
831  ss << "\n";
832 
833  ss << "\n----------------------------------------------------------------\n\t\t Detid \tModules Fibers "
834  "Apvs\n----------------------------------------------------------------";
835  for (int i = 1; i < 5; ++i)
836  ss << "\nTIB Layer " << i << " :" << ssV[0][i].str();
837  ss << "\n";
838  for (int i = 1; i < 4; ++i)
839  ss << "\nTID+ Disk " << i << " :" << ssV[1][i].str();
840  for (int i = 4; i < 7; ++i)
841  ss << "\nTID- Disk " << i - 3 << " :" << ssV[1][i].str();
842  ss << "\n";
843  for (int i = 1; i < 7; ++i)
844  ss << "\nTOB Layer " << i << " :" << ssV[2][i].str();
845  ss << "\n";
846  for (int i = 1; i < 10; ++i)
847  ss << "\nTEC+ Disk " << i << " :" << ssV[3][i].str();
848  for (int i = 10; i < 19; ++i)
849  ss << "\nTEC- Disk " << i - 9 << " :" << ssV[3][i].str();
850 
851  LOGPRINT << ss.str();
852 
853  // store also bad modules in log file
854  ofstream badModules;
855  badModules.open("BadModules.log");
856  badModules << "\n----------------------------------------------------------------\n\t\t Detid \tModules Fibers "
857  "Apvs\n----------------------------------------------------------------";
858  for (int i = 1; i < 5; ++i)
859  badModules << "\nTIB Layer " << i << " :" << ssV[0][i].str();
860  badModules << "\n";
861  for (int i = 1; i < 4; ++i)
862  badModules << "\nTID+ Disk " << i << " :" << ssV[1][i].str();
863  for (int i = 4; i < 7; ++i)
864  badModules << "\nTID- Disk " << i - 3 << " :" << ssV[1][i].str();
865  badModules << "\n";
866  for (int i = 1; i < 7; ++i)
867  badModules << "\nTOB Layer " << i << " :" << ssV[2][i].str();
868  badModules << "\n";
869  for (int i = 1; i < 10; ++i)
870  badModules << "\nTEC+ Disk " << i << " :" << ssV[3][i].str();
871  for (int i = 10; i < 19; ++i)
872  badModules << "\nTEC- Disk " << i - 9 << " :" << ssV[3][i].str();
873  badModules.close();
874 }
875 
877  LOGPRINT << "Entering hot cold map generation!\n";
878  TStyle* gStyle = new TStyle("gStyle", "myStyle");
879  gStyle->cd();
880  gStyle->SetPalette(1);
881  gStyle->SetCanvasColor(kWhite);
882  gStyle->SetOptStat(0);
883  //Here we make the hot/cold color maps that we love so very much
884  //Already have access to the data as a private variable
885  //Create all of the histograms in the TFileService
886  TH2F* temph2;
887  for (Long_t maplayer = 1; maplayer <= SiStripLayers; maplayer++) {
888  //Initialize all of the histograms
889  if (maplayer > 0 && maplayer <= 4) {
890  //We are in the TIB
891  temph2 = fs->make<TH2F>(Form("%s%i", "TIB", (int)(maplayer)), "TIB", 100, -1, 361, 100, -100, 100);
892  temph2->GetXaxis()->SetTitle("Phi");
893  temph2->GetXaxis()->SetBinLabel(1, TString("360"));
894  temph2->GetXaxis()->SetBinLabel(50, TString("180"));
895  temph2->GetXaxis()->SetBinLabel(100, TString("0"));
896  temph2->GetYaxis()->SetTitle("Global Z");
897  temph2->SetOption("colz");
898  HotColdMaps.push_back(temph2);
899  } else if (maplayer > 4 && maplayer <= 10) {
900  //We are in the TOB
901  temph2 = fs->make<TH2F>(Form("%s%i", "TOB", (int)(maplayer - 4)), "TOB", 100, -1, 361, 100, -120, 120);
902  temph2->GetXaxis()->SetTitle("Phi");
903  temph2->GetXaxis()->SetBinLabel(1, TString("360"));
904  temph2->GetXaxis()->SetBinLabel(50, TString("180"));
905  temph2->GetXaxis()->SetBinLabel(100, TString("0"));
906  temph2->GetYaxis()->SetTitle("Global Z");
907  temph2->SetOption("colz");
908  HotColdMaps.push_back(temph2);
909  } else if (maplayer > 10 && maplayer <= 13) {
910  //We are in the TID
911  //Split by +/-
912  temph2 = fs->make<TH2F>(Form("%s%i", "TID-", (int)(maplayer - 10)), "TID-", 100, -100, 100, 100, -100, 100);
913  temph2->GetXaxis()->SetTitle("Global Y");
914  temph2->GetXaxis()->SetBinLabel(1, TString("+Y"));
915  temph2->GetXaxis()->SetBinLabel(50, TString("0"));
916  temph2->GetXaxis()->SetBinLabel(100, TString("-Y"));
917  temph2->GetYaxis()->SetTitle("Global X");
918  temph2->GetYaxis()->SetBinLabel(1, TString("-X"));
919  temph2->GetYaxis()->SetBinLabel(50, TString("0"));
920  temph2->GetYaxis()->SetBinLabel(100, TString("+X"));
921  temph2->SetOption("colz");
922  HotColdMaps.push_back(temph2);
923  temph2 = fs->make<TH2F>(Form("%s%i", "TID+", (int)(maplayer - 10)), "TID+", 100, -100, 100, 100, -100, 100);
924  temph2->GetXaxis()->SetTitle("Global Y");
925  temph2->GetXaxis()->SetBinLabel(1, TString("+Y"));
926  temph2->GetXaxis()->SetBinLabel(50, TString("0"));
927  temph2->GetXaxis()->SetBinLabel(100, TString("-Y"));
928  temph2->GetYaxis()->SetTitle("Global X");
929  temph2->GetYaxis()->SetBinLabel(1, TString("-X"));
930  temph2->GetYaxis()->SetBinLabel(50, TString("0"));
931  temph2->GetYaxis()->SetBinLabel(100, TString("+X"));
932  temph2->SetOption("colz");
933  HotColdMaps.push_back(temph2);
934  } else if (maplayer > 13) {
935  //We are in the TEC
936  //Split by +/-
937  temph2 = fs->make<TH2F>(Form("%s%i", "TEC-", (int)(maplayer - 13)), "TEC-", 100, -120, 120, 100, -120, 120);
938  temph2->GetXaxis()->SetTitle("Global Y");
939  temph2->GetXaxis()->SetBinLabel(1, TString("+Y"));
940  temph2->GetXaxis()->SetBinLabel(50, TString("0"));
941  temph2->GetXaxis()->SetBinLabel(100, TString("-Y"));
942  temph2->GetYaxis()->SetTitle("Global X");
943  temph2->GetYaxis()->SetBinLabel(1, TString("-X"));
944  temph2->GetYaxis()->SetBinLabel(50, TString("0"));
945  temph2->GetYaxis()->SetBinLabel(100, TString("+X"));
946  temph2->SetOption("colz");
947  HotColdMaps.push_back(temph2);
948  temph2 = fs->make<TH2F>(Form("%s%i", "TEC+", (int)(maplayer - 13)), "TEC+", 100, -120, 120, 100, -120, 120);
949  temph2->GetXaxis()->SetTitle("Global Y");
950  temph2->GetXaxis()->SetBinLabel(1, TString("+Y"));
951  temph2->GetXaxis()->SetBinLabel(50, TString("0"));
952  temph2->GetXaxis()->SetBinLabel(100, TString("-Y"));
953  temph2->GetYaxis()->SetTitle("Global X");
954  temph2->GetYaxis()->SetBinLabel(1, TString("-X"));
955  temph2->GetYaxis()->SetBinLabel(50, TString("0"));
956  temph2->GetYaxis()->SetBinLabel(100, TString("+X"));
957  temph2->SetOption("colz");
958  HotColdMaps.push_back(temph2);
959  }
960  }
961  for (Long_t mylayer = 1; mylayer <= SiStripLayers; mylayer++) {
962  //Determine what kind of plot we want to write out
963  //Loop through the entirety of each layer
964  //Create an array of the histograms
965  vector<hit>::const_iterator iter;
966  for (iter = hits[mylayer].begin(); iter != hits[mylayer].end(); iter++) {
967  //Looping over the particular layer
968  //Fill by 360-x to get the proper location to compare with TKMaps of phi
969  //Also global xy is messed up
970  if (mylayer > 0 && mylayer <= 4) {
971  //We are in the TIB
972  float phi = ::calcPhi(iter->x, iter->y);
973  HotColdMaps[mylayer - 1]->Fill(360. - phi, iter->z, 1.);
974  } else if (mylayer > 4 && mylayer <= 10) {
975  //We are in the TOB
976  float phi = ::calcPhi(iter->x, iter->y);
977  HotColdMaps[mylayer - 1]->Fill(360. - phi, iter->z, 1.);
978  } else if (mylayer > 10 && mylayer <= 13) {
979  //We are in the TID
980  //There are 2 different maps here
981  int side = (((iter->id) >> 13) & 0x3);
982  if (side == 1)
983  HotColdMaps[(mylayer - 1) + (mylayer - 11)]->Fill(-iter->y, iter->x, 1.);
984  else if (side == 2)
985  HotColdMaps[(mylayer - 1) + (mylayer - 10)]->Fill(-iter->y, iter->x, 1.);
986  //if(side == 1) HotColdMaps[(mylayer - 1) + (mylayer - 11)]->Fill(iter->x,iter->y,1.);
987  //else if(side == 2) HotColdMaps[(mylayer - 1) + (mylayer - 10)]->Fill(iter->x,iter->y,1.);
988  } else if (mylayer > 13) {
989  //We are in the TEC
990  //There are 2 different maps here
991  int side = (((iter->id) >> 18) & 0x3);
992  if (side == 1)
993  HotColdMaps[(mylayer + 2) + (mylayer - 14)]->Fill(-iter->y, iter->x, 1.);
994  else if (side == 2)
995  HotColdMaps[(mylayer + 2) + (mylayer - 13)]->Fill(-iter->y, iter->x, 1.);
996  //if(side == 1) HotColdMaps[(mylayer + 2) + (mylayer - 14)]->Fill(iter->x,iter->y,1.);
997  //else if(side == 2) HotColdMaps[(mylayer + 2) + (mylayer - 13)]->Fill(iter->x,iter->y,1.);
998  }
999  }
1000  }
1001  LOGPRINT << "Finished HotCold Map Generation\n";
1002 }
1003 
1004 void SiStripHitEffFromCalibTree::makeTKMap(bool autoTagging = false) {
1005  LOGPRINT << "Entering TKMap generation!\n";
1006  tkmap = new TrackerMap(" Detector Inefficiency ");
1007  tkmapbad = new TrackerMap(" Inefficient Modules ");
1008  tkmapeff = new TrackerMap(_title.Data());
1009  tkmapnum = new TrackerMap(" Detector numerator ");
1010  tkmapden = new TrackerMap(" Detector denominator ");
1011 
1012  double myeff, mynum, myden, myeff_up;
1013  double layer_min_eff = 0;
1014 
1015  for (Long_t i = 1; i <= SiStripLayers; i++) {
1016  //Loop over every layer, extracting the information from
1017  //the map of the efficiencies
1018  layertotal[i] = 0;
1019  layerfound[i] = 0;
1020  TH1F* hEffInLayer =
1021  fs->make<TH1F>(Form("eff_layer%i", int(i)), Form("Module efficiency in layer %i", int(i)), 201, 0, 1.005);
1022 
1023  map<unsigned int, pair<unsigned int, unsigned int> >::const_iterator ih;
1024  for (ih = modCounter[i].begin(); ih != modCounter[i].end(); ih++) {
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 (ih = modCounter[i].begin(); ih != modCounter[i].end(); ih++) {
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  map<unsigned int, double>::const_iterator it;
1125  for (it = BadModules.begin(); it != BadModules.end(); it++) {
1126  //We need to figure out how many strips are in this particular module
1127  //To Mask correctly!
1128  NStrips = _detInfo.getNumberOfApvsAndStripLength((*it).first).first * 128;
1129  LOGPRINT << "Number of strips module " << (*it).first << " is " << NStrips;
1130  BadStripList.push_back(pQuality->encode(0, NStrips, 0));
1131  //Now compact into a single bad module
1132  id1 = (unsigned int)(*it).first;
1133  LOGPRINT << "ID1 shoudl match list of modules above " << id1;
1134  quality_->compact(id1, BadStripList);
1135  SiStripQuality::Range range(BadStripList.begin(), BadStripList.end());
1136  quality_->put(id1, range);
1137  BadStripList.clear();
1138  }
1139  //Fill all the bad components now
1141 }
1142 
1144  //Calculate the statistics by layer
1145  int totalfound = 0;
1146  int totaltotal = 0;
1147  double layereff;
1148  int subdetfound[5];
1149  int subdettotal[5];
1150 
1151  for (Long_t i = 1; i < 5; i++) {
1152  subdetfound[i] = 0;
1153  subdettotal[i] = 0;
1154  }
1155 
1156  for (Long_t i = 1; i <= SiStripLayers; i++) {
1157  layereff = double(layerfound[i]) / double(layertotal[i]);
1158  LOGPRINT << "Layer " << i << " (" << ::layerName(i, _showRings, nTEClayers) << ") has total efficiency " << layereff
1159  << " " << layerfound[i] << "/" << layertotal[i];
1160  totalfound += layerfound[i];
1161  totaltotal += layertotal[i];
1162  if (i < 5) {
1163  subdetfound[1] += layerfound[i];
1164  subdettotal[1] += layertotal[i];
1165  }
1166  if (i >= 5 && i < 11) {
1167  subdetfound[2] += layerfound[i];
1168  subdettotal[2] += layertotal[i];
1169  }
1170  if (i >= 11 && i < 14) {
1171  subdetfound[3] += layerfound[i];
1172  subdettotal[3] += layertotal[i];
1173  }
1174  if (i >= 14) {
1175  subdetfound[4] += layerfound[i];
1176  subdettotal[4] += layertotal[i];
1177  }
1178  }
1179 
1180  LOGPRINT << "The total efficiency is " << double(totalfound) / double(totaltotal);
1181  LOGPRINT << " TIB: " << double(subdetfound[1]) / subdettotal[1] << " " << subdetfound[1] << "/"
1182  << subdettotal[1];
1183  LOGPRINT << " TOB: " << double(subdetfound[2]) / subdettotal[2] << " " << subdetfound[2] << "/"
1184  << subdettotal[2];
1185  LOGPRINT << " TID: " << double(subdetfound[3]) / subdettotal[3] << " " << subdetfound[3] << "/"
1186  << subdettotal[3];
1187  LOGPRINT << " TEC: " << double(subdetfound[4]) / subdettotal[4] << " " << subdetfound[4] << "/"
1188  << subdettotal[4];
1189 }
1190 
1192  //setTDRStyle();
1193 
1194  int nLayers = 34;
1195  if (_showRings)
1196  nLayers = 30;
1197  if (!_showEndcapSides) {
1198  if (!_showRings)
1200  else
1201  nLayers = 20;
1202  }
1203 
1204  TH1F* found = fs->make<TH1F>("found", "found", nLayers + 1, 0, nLayers + 1);
1205  TH1F* all = fs->make<TH1F>("all", "all", nLayers + 1, 0, nLayers + 1);
1206  TH1F* found2 = fs->make<TH1F>("found2", "found2", nLayers + 1, 0, nLayers + 1);
1207  TH1F* all2 = fs->make<TH1F>("all2", "all2", nLayers + 1, 0, nLayers + 1);
1208  // first bin only to keep real data off the y axis so set to -1
1209  found->SetBinContent(0, -1);
1210  all->SetBinContent(0, 1);
1211 
1212  // new ROOT version: TGraph::Divide don't handle null or negative values
1213  for (Long_t i = 1; i < nLayers + 2; ++i) {
1214  found->SetBinContent(i, 1e-6);
1215  all->SetBinContent(i, 1);
1216  found2->SetBinContent(i, 1e-6);
1217  all2->SetBinContent(i, 1);
1218  }
1219 
1220  TCanvas* c7 = new TCanvas("c7", " test ", 10, 10, 800, 600);
1221  c7->SetFillColor(0);
1222  c7->SetGrid();
1223 
1224  int nLayers_max = nLayers + 1; // barrel+endcap
1225  if (!_showEndcapSides)
1226  nLayers_max = 11; // barrel
1227  for (Long_t i = 1; i < nLayers_max; ++i) {
1228  LOGPRINT << "Fill only good modules layer " << i << ": S = " << goodlayerfound[i]
1229  << " B = " << goodlayertotal[i];
1230  if (goodlayertotal[i] > 5) {
1231  found->SetBinContent(i, goodlayerfound[i]);
1232  all->SetBinContent(i, goodlayertotal[i]);
1233  }
1234 
1235  LOGPRINT << "Filling all modules layer " << i << ": S = " << alllayerfound[i] << " B = " << alllayertotal[i];
1236  if (alllayertotal[i] > 5) {
1237  found2->SetBinContent(i, alllayerfound[i]);
1238  all2->SetBinContent(i, alllayertotal[i]);
1239  }
1240  }
1241 
1242  // endcap - merging sides
1243  if (!_showEndcapSides) {
1244  for (Long_t i = 11; i < 14; ++i) { // TID disks
1245  LOGPRINT << "Fill only good modules layer " << i << ": S = " << goodlayerfound[i] + goodlayerfound[i + 3]
1246  << " B = " << goodlayertotal[i] + goodlayertotal[i + 3];
1247  if (goodlayertotal[i] + goodlayertotal[i + 3] > 5) {
1248  found->SetBinContent(i, goodlayerfound[i] + goodlayerfound[i + 3]);
1249  all->SetBinContent(i, goodlayertotal[i] + goodlayertotal[i + 3]);
1250  }
1251  LOGPRINT << "Filling all modules layer " << i << ": S = " << alllayerfound[i] + alllayerfound[i + 3]
1252  << " B = " << alllayertotal[i] + alllayertotal[i + 3];
1253  if (alllayertotal[i] + alllayertotal[i + 3] > 5) {
1254  found2->SetBinContent(i, alllayerfound[i] + alllayerfound[i + 3]);
1255  all2->SetBinContent(i, alllayertotal[i] + alllayertotal[i + 3]);
1256  }
1257  }
1258  for (Long_t i = 17; i < 17 + nTEClayers; ++i) { // TEC disks
1259  LOGPRINT << "Fill only good modules layer " << i - 3
1260  << ": S = " << goodlayerfound[i] + goodlayerfound[i + nTEClayers]
1261  << " B = " << goodlayertotal[i] + goodlayertotal[i + nTEClayers];
1262  if (goodlayertotal[i] + goodlayertotal[i + nTEClayers] > 5) {
1263  found->SetBinContent(i - 3, goodlayerfound[i] + goodlayerfound[i + nTEClayers]);
1264  all->SetBinContent(i - 3, goodlayertotal[i] + goodlayertotal[i + nTEClayers]);
1265  }
1266  LOGPRINT << "Filling all modules layer " << i - 3 << ": S = " << alllayerfound[i] + alllayerfound[i + nTEClayers]
1267  << " B = " << alllayertotal[i] + alllayertotal[i + nTEClayers];
1268  if (alllayertotal[i] + alllayertotal[i + nTEClayers] > 5) {
1269  found2->SetBinContent(i - 3, alllayerfound[i] + alllayerfound[i + nTEClayers]);
1270  all2->SetBinContent(i - 3, alllayertotal[i] + alllayertotal[i + nTEClayers]);
1271  }
1272  }
1273  }
1274 
1275  found->Sumw2();
1276  all->Sumw2();
1277 
1278  found2->Sumw2();
1279  all2->Sumw2();
1280 
1281  TGraphAsymmErrors* gr = fs->make<TGraphAsymmErrors>(nLayers + 1);
1282  gr->SetName("eff_good");
1283  gr->BayesDivide(found, all);
1284 
1285  TGraphAsymmErrors* gr2 = fs->make<TGraphAsymmErrors>(nLayers + 1);
1286  gr2->SetName("eff_all");
1287  gr2->BayesDivide(found2, all2);
1288 
1289  for (int j = 0; j < nLayers + 1; j++) {
1290  gr->SetPointError(j, 0., 0., gr->GetErrorYlow(j), gr->GetErrorYhigh(j));
1291  gr2->SetPointError(j, 0., 0., gr2->GetErrorYlow(j), gr2->GetErrorYhigh(j));
1292  }
1293 
1294  gr->GetXaxis()->SetLimits(0, nLayers);
1295  gr->SetMarkerColor(2);
1296  gr->SetMarkerSize(1.2);
1297  gr->SetLineColor(2);
1298  gr->SetLineWidth(4);
1299  gr->SetMarkerStyle(20);
1300  gr->SetMinimum(_effPlotMin);
1301  gr->SetMaximum(1.001);
1302  gr->GetYaxis()->SetTitle("Efficiency");
1303  gStyle->SetTitleFillColor(0);
1304  gStyle->SetTitleBorderSize(0);
1305  gr->SetTitle(_title);
1306 
1307  gr2->GetXaxis()->SetLimits(0, nLayers);
1308  gr2->SetMarkerColor(1);
1309  gr2->SetMarkerSize(1.2);
1310  gr2->SetLineColor(1);
1311  gr2->SetLineWidth(4);
1312  gr2->SetMarkerStyle(21);
1313  gr2->SetMinimum(_effPlotMin);
1314  gr2->SetMaximum(1.001);
1315  gr2->GetYaxis()->SetTitle("Efficiency");
1316  gr2->SetTitle(_title);
1317 
1318  for (Long_t k = 1; k < nLayers + 1; k++) {
1319  TString label;
1320  if (_showEndcapSides)
1322  else
1324  if (!_showTOB6TEC9) {
1325  if (k == 10)
1326  label = "";
1327  if (!_showRings && k == nLayers)
1328  label = "";
1329  if (!_showRings && _showEndcapSides && k == 25)
1330  label = "";
1331  }
1332  if (!_showRings) {
1333  if (_showEndcapSides) {
1334  gr->GetXaxis()->SetBinLabel(((k + 1) * 100 + 2) / (nLayers)-4, label);
1335  gr2->GetXaxis()->SetBinLabel(((k + 1) * 100 + 2) / (nLayers)-4, label);
1336  } else {
1337  gr->GetXaxis()->SetBinLabel((k + 1) * 100 / (nLayers)-6, label);
1338  gr2->GetXaxis()->SetBinLabel((k + 1) * 100 / (nLayers)-6, label);
1339  }
1340  } else {
1341  if (_showEndcapSides) {
1342  gr->GetXaxis()->SetBinLabel((k + 1) * 100 / (nLayers)-4, label);
1343  gr2->GetXaxis()->SetBinLabel((k + 1) * 100 / (nLayers)-4, label);
1344  } else {
1345  gr->GetXaxis()->SetBinLabel((k + 1) * 100 / (nLayers)-7, label);
1346  gr2->GetXaxis()->SetBinLabel((k + 1) * 100 / (nLayers)-7, label);
1347  }
1348  }
1349  }
1350 
1351  gr->Draw("AP");
1352  gr->GetXaxis()->SetNdivisions(36);
1353 
1354  c7->cd();
1355  TPad* overlay = new TPad("overlay", "", 0, 0, 1, 1);
1356  overlay->SetFillStyle(4000);
1357  overlay->SetFillColor(0);
1358  overlay->SetFrameFillStyle(4000);
1359  overlay->Draw("same");
1360  overlay->cd();
1361  if (!_showOnlyGoodModules)
1362  gr2->Draw("AP");
1363 
1364  TLegend* leg = new TLegend(0.70, 0.27, 0.88, 0.40);
1365  leg->AddEntry(gr, "Good Modules", "p");
1366  if (!_showOnlyGoodModules)
1367  leg->AddEntry(gr2, "All Modules", "p");
1368  leg->SetTextSize(0.020);
1369  leg->SetFillColor(0);
1370  leg->Draw("same");
1371 
1372  c7->SaveAs("Summary.png");
1373 }
1374 
1376  LOGPRINT << "Computing efficiency vs bx";
1377 
1378  unsigned int nLayers = SiStripLayers;
1379  if (_showRings)
1380  nLayers = 20;
1381 
1382  for (unsigned int ilayer = 1; ilayer < nLayers; ilayer++) {
1383  TH1F* hfound = fs->make<TH1F>(Form("foundVsBx_layer%i", ilayer), Form("layer %i", ilayer), 3565, 0, 3565);
1384  TH1F* htotal = fs->make<TH1F>(Form("totalVsBx_layer%i", ilayer), Form("layer %i", ilayer), 3565, 0, 3565);
1385 
1386  for (unsigned int ibx = 0; ibx < 3566; ibx++) {
1387  hfound->SetBinContent(ibx, 1e-6);
1388  htotal->SetBinContent(ibx, 1);
1389  }
1390  map<unsigned int, vector<int> >::iterator iterMapvsBx;
1391  for (iterMapvsBx = layerfound_perBx.begin(); iterMapvsBx != layerfound_perBx.end(); ++iterMapvsBx)
1392  hfound->SetBinContent(iterMapvsBx->first, iterMapvsBx->second[ilayer]);
1393  for (iterMapvsBx = layertotal_perBx.begin(); iterMapvsBx != layertotal_perBx.end(); ++iterMapvsBx)
1394  if (iterMapvsBx->second[ilayer] > 0)
1395  htotal->SetBinContent(iterMapvsBx->first, iterMapvsBx->second[ilayer]);
1396 
1397  hfound->Sumw2();
1398  htotal->Sumw2();
1399 
1400  TGraphAsymmErrors* geff = fs->make<TGraphAsymmErrors>(3564);
1401  geff->SetName(Form("effVsBx_layer%i", ilayer));
1402  geff->SetTitle(fmt::format("Hit Efficiency vs bx - {}", ::layerName(ilayer, _showRings, nTEClayers)).c_str());
1403  geff->BayesDivide(hfound, htotal);
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 (iterMapvsBx = layertotal_perBx.begin(); iterMapvsBx != layertotal_perBx.end(); ++iterMapvsBx) {
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 += hfound->GetBinContent(ibx);
1440  total += htotal->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
Definition: BitonicSort.h:7
map< unsigned int, vector< int > > layertotal_perBx
virtual int nstrips() const =0
ContainerIterator getDataVectorBegin() const
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
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
void SetBadComponents(int i, int component, SiStripQuality::BadComponent &BC, std::stringstream ssV[4][19], int NBadComponent[4][19][4])
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 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 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
void ComputeEff(vector< TH1F *> &vhfound, vector< TH1F *> &vhtotal, string name)
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