CMS 3D CMS Logo

SiStripHitEffFromCalibTree.cc
Go to the documentation of this file.
1 //Original Author: Christopher Edelmaier
2 // Created: Feb. 11, 2010
3 #include <memory>
4 #include <string>
5 #include <iostream>
6 #include <fstream>
7 #include <sstream>
8 
17 
44 
55 
58 
63 
64 #include "TFile.h"
65 #include "TCanvas.h"
66 #include "TObjString.h"
67 #include "TString.h"
68 #include "TH1F.h"
69 #include "TH2F.h"
70 #include "TProfile.h"
71 #include "TF1.h"
72 #include "TROOT.h"
73 #include "TTree.h"
74 #include "TStyle.h"
75 #include "TLeaf.h"
76 #include "TGaxis.h"
77 #include "TGraphAsymmErrors.h"
78 #include "TLatex.h"
79 #include "TLegend.h"
80 #include "TEfficiency.h"
81 
82 #include <memory>
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;
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 GetLayerName(Long_t k);
119  TString GetLayerSideName(Long_t k);
120  float calcPhi(float x, float y);
121 
126  std::unique_ptr<SiStripBadStrip> getNewObject() override;
127 
128  TTree* CalibTree;
129  vector<string> CalibTreeFilenames;
130  float threshold;
131  unsigned int nModsMin;
132  unsigned int doSummary;
136  float _ResXSig;
140  unsigned int _bunchx;
141  unsigned int _spaceBetweenTrains;
142  bool _useCM;
147  float _tkMapMin;
148  float _effPlotMin;
149  TString _title;
150 
153 
154  unsigned int nTEClayers;
155 
156  TH1F* bxHisto;
158  TH1F* PUHisto;
159 
160  // for association of informations of the hitEff tree and the event infos tree
161  map<pair<unsigned int, unsigned int>, array<double, 3> > eventInfos;
162 
163  vector<hit> hits[23];
164  vector<TH2F*> HotColdMaps;
165  map<unsigned int, pair<unsigned int, unsigned int> > modCounter[23];
171  long layerfound[23];
172  long layertotal[23];
173  map<unsigned int, vector<int> > layerfound_perBx;
174  map<unsigned int, vector<int> > layertotal_perBx;
175  vector<TH1F*> layerfound_vsLumi;
176  vector<TH1F*> layertotal_vsLumi;
177  vector<TH1F*> layerfound_vsPU;
178  vector<TH1F*> layertotal_vsPU;
179  vector<TH1F*> layerfound_vsCM;
180  vector<TH1F*> layertotal_vsCM;
181  int goodlayertotal[35];
182  int goodlayerfound[35];
183  int alllayertotal[35];
184  int alllayerfound[35];
185  map<unsigned int, double> BadModules;
186 };
187 
190  CalibTreeFilenames = conf.getUntrackedParameter<vector<std::string> >("CalibTreeFilenames");
191  threshold = conf.getParameter<double>("Threshold");
192  nModsMin = conf.getParameter<int>("nModsMin");
193  doSummary = conf.getParameter<int>("doSummary");
194  _badModulesFile = conf.getUntrackedParameter<std::string>("BadModulesFile", "");
195  _autoIneffModTagging = conf.getUntrackedParameter<bool>("AutoIneffModTagging", false);
196  _clusterMatchingMethod = conf.getUntrackedParameter<int>("ClusterMatchingMethod", 0);
197  _ResXSig = conf.getUntrackedParameter<double>("ResXSig", -1);
198  _clusterTrajDist = conf.getUntrackedParameter<double>("ClusterTrajDist", 64.0);
199  _stripsApvEdge = conf.getUntrackedParameter<double>("StripsApvEdge", 10.0);
200  _useOnlyHighPurityTracks = conf.getUntrackedParameter<bool>("UseOnlyHighPurityTracks", true);
201  _bunchx = conf.getUntrackedParameter<int>("BunchCrossing", 0);
202  _spaceBetweenTrains = conf.getUntrackedParameter<int>("SpaceBetweenTrains", 25);
203  _useCM = conf.getUntrackedParameter<bool>("UseCommonMode", false);
204  _showEndcapSides = conf.getUntrackedParameter<bool>("ShowEndcapSides", true);
205  _showRings = conf.getUntrackedParameter<bool>("ShowRings", false);
206  _showTOB6TEC9 = conf.getUntrackedParameter<bool>("ShowTOB6TEC9", false);
207  _showOnlyGoodModules = conf.getUntrackedParameter<bool>("ShowOnlyGoodModules", false);
208  _tkMapMin = conf.getUntrackedParameter<double>("TkMapMin", 0.9);
209  _effPlotMin = conf.getUntrackedParameter<double>("EffPlotMin", 0.9);
210  _title = conf.getParameter<std::string>("Title");
214 
215  nTEClayers = 9; // number of wheels
216  if (_showRings)
217  nTEClayers = 7; // number of rings
218 
220 }
221 
223 
225  //I have no idea what goes here
226  //fs->make<TTree>("HitEffHistos","Tree of the inefficient hit histograms");
227 }
228 
230  //Still have no idea what goes here
231 }
232 
234  const auto& tkgeom = c.getData(_tkGeomToken);
235  const auto& tTopo = c.getData(_tTopoToken);
236 
237  // read bad modules to mask
238  ifstream badModules_file;
239  set<uint32_t> badModules_list;
240  if (!_badModulesFile.empty()) {
241  badModules_file.open(_badModulesFile.c_str());
242  uint32_t badmodule_detid;
243  int mods, fiber1, fiber2, fiber3;
244  if (badModules_file.is_open()) {
245  string line;
246  while (getline(badModules_file, line)) {
247  if (badModules_file.eof())
248  continue;
249  stringstream ss(line);
250  ss >> badmodule_detid >> mods >> fiber1 >> fiber2 >> fiber3;
251  if (badmodule_detid != 0 && mods == 1 && (fiber1 == 1 || fiber2 == 1 || fiber3 == 1))
252  badModules_list.insert(badmodule_detid);
253  }
254  badModules_file.close();
255  }
256  }
257  if (!badModules_list.empty())
258  cout << "Remove additionnal bad modules from the analysis: " << endl;
259  set<uint32_t>::iterator itBadMod;
260  for (itBadMod = badModules_list.begin(); itBadMod != badModules_list.end(); ++itBadMod)
261  cout << " " << *itBadMod << endl;
262 
263  // initialze counters and histos
264 
265  bxHisto = fs->make<TH1F>("bx", "bx", 3600, 0, 3600);
266  instLumiHisto = fs->make<TH1F>("instLumi", "inst. lumi.", 250, 0, 25000);
267  PUHisto = fs->make<TH1F>("PU", "PU", 200, 0, 200);
268 
269  for (int l = 0; l < 35; l++) {
270  goodlayertotal[l] = 0;
271  goodlayerfound[l] = 0;
272  alllayertotal[l] = 0;
273  alllayerfound[l] = 0;
274  }
275 
276  TH1F* resolutionPlots[23];
277  for (Long_t ilayer = 0; ilayer < 23; ilayer++) {
278  resolutionPlots[ilayer] =
279  fs->make<TH1F>(Form("resol_layer_%i", (int)(ilayer)), GetLayerName(ilayer), 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)), GetLayerName(ilayer), 100, 0, 25000));
284  layertotal_vsLumi.push_back(
285  fs->make<TH1F>(Form("layertotal_vsLumi_layer_%i", (int)(ilayer)), GetLayerName(ilayer), 100, 0, 25000));
286  layerfound_vsPU.push_back(
287  fs->make<TH1F>(Form("layerfound_vsPU_layer_%i", (int)(ilayer)), GetLayerName(ilayer), 45, 0, 90));
288  layertotal_vsPU.push_back(
289  fs->make<TH1F>(Form("layertotal_vsPU_layer_%i", (int)(ilayer)), GetLayerName(ilayer), 45, 0, 90));
290 
291  if (_useCM) {
292  layerfound_vsCM.push_back(
293  fs->make<TH1F>(Form("layerfound_vsCM_layer_%i", (int)(ilayer)), GetLayerName(ilayer), 20, 0, 400));
294  layertotal_vsCM.push_back(
295  fs->make<TH1F>(Form("layertotal_vsCM_layer_%i", (int)(ilayer)), GetLayerName(ilayer), 20, 0, 400));
296  }
297  layertotal[ilayer] = 0;
298  layerfound[ilayer] = 0;
299  }
300 
302  cout << "A module is bad if efficiency < " << threshold << " and has at least " << nModsMin << " nModsMin." << endl;
303  else
304  cout << "A module is bad if efficiency < the avg in layer - " << threshold << " and has at least " << nModsMin
305  << " nModsMin." << endl;
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  cout << "Loading file: " << CalibTreeFilenames[ifile] << endl;
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  cout << "No event infos tree" << endl;
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  cout << "Found event infos tree" << endl;
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  cout << "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 == 22))
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 <= 22) {
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 <= 22) {
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 
792  cout << "\n-----------------\nNew IOV starting from run " << e.id().run() << " event " << e.id().event()
793  << " lumiBlock " << e.luminosityBlock() << " time " << e.time().value() << "\n-----------------\n";
794  cout << "\n-----------------\nGlobal Info\n-----------------";
795  cout << "\nBadComponent \t Modules \tFibers "
796  "\tApvs\tStrips\n----------------------------------------------------------------";
797  cout << "\nTracker:\t\t" << NTkBadComponent[0] << "\t" << NTkBadComponent[1] << "\t" << NTkBadComponent[2] << "\t"
798  << NTkBadComponent[3];
799  cout << endl;
800  cout << "\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  cout << "\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  cout << "\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  cout << "\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  cout << "\n";
809 
810  for (int i = 1; i < 5; ++i)
811  cout << "\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  cout << "\n";
814  for (int i = 1; i < 4; ++i)
815  cout << "\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  cout << "\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  cout << "\n";
821  for (int i = 1; i < 7; ++i)
822  cout << "\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  cout << "\n";
825  for (int i = 1; i < 10; ++i)
826  cout << "\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  cout << "\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  cout << "\n";
832 
833  cout << "\n----------------------------------------------------------------\n\t\t Detid \tModules Fibers "
834  "Apvs\n----------------------------------------------------------------";
835  for (int i = 1; i < 5; ++i)
836  cout << "\nTIB Layer " << i << " :" << ssV[0][i].str();
837  cout << "\n";
838  for (int i = 1; i < 4; ++i)
839  cout << "\nTID+ Disk " << i << " :" << ssV[1][i].str();
840  for (int i = 4; i < 7; ++i)
841  cout << "\nTID- Disk " << i - 3 << " :" << ssV[1][i].str();
842  cout << "\n";
843  for (int i = 1; i < 7; ++i)
844  cout << "\nTOB Layer " << i << " :" << ssV[2][i].str();
845  cout << "\n";
846  for (int i = 1; i < 10; ++i)
847  cout << "\nTEC+ Disk " << i << " :" << ssV[3][i].str();
848  for (int i = 10; i < 19; ++i)
849  cout << "\nTEC- Disk " << i - 9 << " :" << ssV[3][i].str();
850 
851  // store also bad modules in log file
852  ofstream badModules;
853  badModules.open("BadModules.log");
854  badModules << "\n----------------------------------------------------------------\n\t\t Detid \tModules Fibers "
855  "Apvs\n----------------------------------------------------------------";
856  for (int i = 1; i < 5; ++i)
857  badModules << "\nTIB Layer " << i << " :" << ssV[0][i].str();
858  badModules << "\n";
859  for (int i = 1; i < 4; ++i)
860  badModules << "\nTID+ Disk " << i << " :" << ssV[1][i].str();
861  for (int i = 4; i < 7; ++i)
862  badModules << "\nTID- Disk " << i - 3 << " :" << ssV[1][i].str();
863  badModules << "\n";
864  for (int i = 1; i < 7; ++i)
865  badModules << "\nTOB Layer " << i << " :" << ssV[2][i].str();
866  badModules << "\n";
867  for (int i = 1; i < 10; ++i)
868  badModules << "\nTEC+ Disk " << i << " :" << ssV[3][i].str();
869  for (int i = 10; i < 19; ++i)
870  badModules << "\nTEC- Disk " << i - 9 << " :" << ssV[3][i].str();
871  badModules.close();
872 }
873 
875  cout << "Entering hot cold map generation!\n";
876  TStyle* gStyle = new TStyle("gStyle", "myStyle");
877  gStyle->cd();
878  gStyle->SetPalette(1);
879  gStyle->SetCanvasColor(kWhite);
880  gStyle->SetOptStat(0);
881  //Here we make the hot/cold color maps that we love so very much
882  //Already have access to the data as a private variable
883  //Create all of the histograms in the TFileService
884  TH2F* temph2;
885  for (Long_t maplayer = 1; maplayer <= 22; maplayer++) {
886  //Initialize all of the histograms
887  if (maplayer > 0 && maplayer <= 4) {
888  //We are in the TIB
889  temph2 = fs->make<TH2F>(Form("%s%i", "TIB", (int)(maplayer)), "TIB", 100, -1, 361, 100, -100, 100);
890  temph2->GetXaxis()->SetTitle("Phi");
891  temph2->GetXaxis()->SetBinLabel(1, TString("360"));
892  temph2->GetXaxis()->SetBinLabel(50, TString("180"));
893  temph2->GetXaxis()->SetBinLabel(100, TString("0"));
894  temph2->GetYaxis()->SetTitle("Global Z");
895  temph2->SetOption("colz");
896  HotColdMaps.push_back(temph2);
897  } else if (maplayer > 4 && maplayer <= 10) {
898  //We are in the TOB
899  temph2 = fs->make<TH2F>(Form("%s%i", "TOB", (int)(maplayer - 4)), "TOB", 100, -1, 361, 100, -120, 120);
900  temph2->GetXaxis()->SetTitle("Phi");
901  temph2->GetXaxis()->SetBinLabel(1, TString("360"));
902  temph2->GetXaxis()->SetBinLabel(50, TString("180"));
903  temph2->GetXaxis()->SetBinLabel(100, TString("0"));
904  temph2->GetYaxis()->SetTitle("Global Z");
905  temph2->SetOption("colz");
906  HotColdMaps.push_back(temph2);
907  } else if (maplayer > 10 && maplayer <= 13) {
908  //We are in the TID
909  //Split by +/-
910  temph2 = fs->make<TH2F>(Form("%s%i", "TID-", (int)(maplayer - 10)), "TID-", 100, -100, 100, 100, -100, 100);
911  temph2->GetXaxis()->SetTitle("Global Y");
912  temph2->GetXaxis()->SetBinLabel(1, TString("+Y"));
913  temph2->GetXaxis()->SetBinLabel(50, TString("0"));
914  temph2->GetXaxis()->SetBinLabel(100, TString("-Y"));
915  temph2->GetYaxis()->SetTitle("Global X");
916  temph2->GetYaxis()->SetBinLabel(1, TString("-X"));
917  temph2->GetYaxis()->SetBinLabel(50, TString("0"));
918  temph2->GetYaxis()->SetBinLabel(100, TString("+X"));
919  temph2->SetOption("colz");
920  HotColdMaps.push_back(temph2);
921  temph2 = fs->make<TH2F>(Form("%s%i", "TID+", (int)(maplayer - 10)), "TID+", 100, -100, 100, 100, -100, 100);
922  temph2->GetXaxis()->SetTitle("Global Y");
923  temph2->GetXaxis()->SetBinLabel(1, TString("+Y"));
924  temph2->GetXaxis()->SetBinLabel(50, TString("0"));
925  temph2->GetXaxis()->SetBinLabel(100, TString("-Y"));
926  temph2->GetYaxis()->SetTitle("Global X");
927  temph2->GetYaxis()->SetBinLabel(1, TString("-X"));
928  temph2->GetYaxis()->SetBinLabel(50, TString("0"));
929  temph2->GetYaxis()->SetBinLabel(100, TString("+X"));
930  temph2->SetOption("colz");
931  HotColdMaps.push_back(temph2);
932  } else if (maplayer > 13) {
933  //We are in the TEC
934  //Split by +/-
935  temph2 = fs->make<TH2F>(Form("%s%i", "TEC-", (int)(maplayer - 13)), "TEC-", 100, -120, 120, 100, -120, 120);
936  temph2->GetXaxis()->SetTitle("Global Y");
937  temph2->GetXaxis()->SetBinLabel(1, TString("+Y"));
938  temph2->GetXaxis()->SetBinLabel(50, TString("0"));
939  temph2->GetXaxis()->SetBinLabel(100, TString("-Y"));
940  temph2->GetYaxis()->SetTitle("Global X");
941  temph2->GetYaxis()->SetBinLabel(1, TString("-X"));
942  temph2->GetYaxis()->SetBinLabel(50, TString("0"));
943  temph2->GetYaxis()->SetBinLabel(100, TString("+X"));
944  temph2->SetOption("colz");
945  HotColdMaps.push_back(temph2);
946  temph2 = fs->make<TH2F>(Form("%s%i", "TEC+", (int)(maplayer - 13)), "TEC+", 100, -120, 120, 100, -120, 120);
947  temph2->GetXaxis()->SetTitle("Global Y");
948  temph2->GetXaxis()->SetBinLabel(1, TString("+Y"));
949  temph2->GetXaxis()->SetBinLabel(50, TString("0"));
950  temph2->GetXaxis()->SetBinLabel(100, TString("-Y"));
951  temph2->GetYaxis()->SetTitle("Global X");
952  temph2->GetYaxis()->SetBinLabel(1, TString("-X"));
953  temph2->GetYaxis()->SetBinLabel(50, TString("0"));
954  temph2->GetYaxis()->SetBinLabel(100, TString("+X"));
955  temph2->SetOption("colz");
956  HotColdMaps.push_back(temph2);
957  }
958  }
959  for (Long_t mylayer = 1; mylayer <= 22; mylayer++) {
960  //Determine what kind of plot we want to write out
961  //Loop through the entirety of each layer
962  //Create an array of the histograms
963  vector<hit>::const_iterator iter;
964  for (iter = hits[mylayer].begin(); iter != hits[mylayer].end(); iter++) {
965  //Looping over the particular layer
966  //Fill by 360-x to get the proper location to compare with TKMaps of phi
967  //Also global xy is messed up
968  if (mylayer > 0 && mylayer <= 4) {
969  //We are in the TIB
970  float phi = calcPhi(iter->x, iter->y);
971  HotColdMaps[mylayer - 1]->Fill(360. - phi, iter->z, 1.);
972  } else if (mylayer > 4 && mylayer <= 10) {
973  //We are in the TOB
974  float phi = calcPhi(iter->x, iter->y);
975  HotColdMaps[mylayer - 1]->Fill(360. - phi, iter->z, 1.);
976  } else if (mylayer > 10 && mylayer <= 13) {
977  //We are in the TID
978  //There are 2 different maps here
979  int side = (((iter->id) >> 13) & 0x3);
980  if (side == 1)
981  HotColdMaps[(mylayer - 1) + (mylayer - 11)]->Fill(-iter->y, iter->x, 1.);
982  else if (side == 2)
983  HotColdMaps[(mylayer - 1) + (mylayer - 10)]->Fill(-iter->y, iter->x, 1.);
984  //if(side == 1) HotColdMaps[(mylayer - 1) + (mylayer - 11)]->Fill(iter->x,iter->y,1.);
985  //else if(side == 2) HotColdMaps[(mylayer - 1) + (mylayer - 10)]->Fill(iter->x,iter->y,1.);
986  } else if (mylayer > 13) {
987  //We are in the TEC
988  //There are 2 different maps here
989  int side = (((iter->id) >> 18) & 0x3);
990  if (side == 1)
991  HotColdMaps[(mylayer + 2) + (mylayer - 14)]->Fill(-iter->y, iter->x, 1.);
992  else if (side == 2)
993  HotColdMaps[(mylayer + 2) + (mylayer - 13)]->Fill(-iter->y, iter->x, 1.);
994  //if(side == 1) HotColdMaps[(mylayer + 2) + (mylayer - 14)]->Fill(iter->x,iter->y,1.);
995  //else if(side == 2) HotColdMaps[(mylayer + 2) + (mylayer - 13)]->Fill(iter->x,iter->y,1.);
996  }
997  }
998  }
999  cout << "Finished HotCold Map Generation\n";
1000 }
1001 
1002 void SiStripHitEffFromCalibTree::makeTKMap(bool autoTagging = false) {
1003  cout << "Entering TKMap generation!\n";
1004  tkmap = new TrackerMap(" Detector Inefficiency ");
1005  tkmapbad = new TrackerMap(" Inefficient Modules ");
1006  tkmapeff = new TrackerMap(_title.Data());
1007  tkmapnum = new TrackerMap(" Detector numerator ");
1008  tkmapden = new TrackerMap(" Detector denominator ");
1009 
1010  double myeff, mynum, myden;
1011  double eff_limit = 0;
1012 
1013  for (Long_t i = 1; i <= 22; i++) {
1014  //Loop over every layer, extracting the information from
1015  //the map of the efficiencies
1016  layertotal[i] = 0;
1017  layerfound[i] = 0;
1018  TH1F* hEffInLayer =
1019  fs->make<TH1F>(Form("eff_layer%i", int(i)), Form("Module efficiency in layer %i", int(i)), 201, 0, 1.005);
1020 
1021  map<unsigned int, pair<unsigned int, unsigned int> >::const_iterator ih;
1022  for (ih = modCounter[i].begin(); ih != modCounter[i].end(); ih++) {
1023  //We should be in the layer in question, and looping over all of the modules in said layer
1024  //Generate the list for the TKmap, and the bad module list
1025  mynum = (double)(((*ih).second).second);
1026  myden = (double)(((*ih).second).first);
1027  if (myden > 0)
1028  myeff = mynum / myden;
1029  else
1030  myeff = 0;
1031  hEffInLayer->Fill(myeff);
1032 
1033  if (!autoTagging) {
1034  if ((myden >= nModsMin) && (myeff < threshold)) {
1035  //We have a bad module, put it in the list!
1036  BadModules[(*ih).first] = myeff;
1037  tkmapbad->fillc((*ih).first, 255, 0, 0);
1038  cout << "Layer " << i << " (" << GetLayerName(i) << ") module " << (*ih).first << " efficiency: " << myeff
1039  << " , " << mynum << "/" << myden << endl;
1040  } else {
1041  //Fill the bad list with empty results for every module
1042  tkmapbad->fillc((*ih).first, 255, 255, 255);
1043  }
1044  if (myden < nModsMin) {
1045  cout << "Layer " << i << " (" << GetLayerName(i) << ") module " << (*ih).first << " is under occupancy at "
1046  << myden << endl;
1047  }
1048  }
1049 
1050  //Put any module into the TKMap
1051  tkmap->fill((*ih).first, 1. - myeff);
1052  tkmapeff->fill((*ih).first, myeff);
1053  tkmapnum->fill((*ih).first, mynum);
1054  tkmapden->fill((*ih).first, myden);
1055 
1056  //Add the number of hits in the layer
1057  layertotal[i] += long(myden);
1058  layerfound[i] += long(mynum);
1059  }
1060 
1061  if (autoTagging) {
1062  //Compute threshold to use for each layer
1063  hEffInLayer->GetXaxis()->SetRange(3, hEffInLayer->GetNbinsX() + 1); // Remove from the avg modules below 1%
1064  eff_limit = hEffInLayer->GetMean() - threshold;
1065  cout << "Layer " << i << " threshold for bad modules: " << eff_limit << endl;
1066  hEffInLayer->GetXaxis()->SetRange(1, hEffInLayer->GetNbinsX() + 1);
1067 
1068  for (ih = modCounter[i].begin(); ih != modCounter[i].end(); ih++) {
1069  // Second loop over modules to tag inefficient ones
1070  mynum = (double)(((*ih).second).second);
1071  myden = (double)(((*ih).second).first);
1072  if (myden > 0)
1073  myeff = mynum / myden;
1074  else
1075  myeff = 0;
1076  if ((myden >= nModsMin) && (myeff < eff_limit)) {
1077  //We have a bad module, put it in the list!
1078  BadModules[(*ih).first] = myeff;
1079  tkmapbad->fillc((*ih).first, 255, 0, 0);
1080  cout << "Layer " << i << " (" << GetLayerName(i) << ") module " << (*ih).first << " efficiency: " << myeff
1081  << " , " << mynum << "/" << myden << endl;
1082  } else {
1083  //Fill the bad list with empty results for every module
1084  tkmapbad->fillc((*ih).first, 255, 255, 255);
1085  }
1086  if (myden < nModsMin) {
1087  cout << "Layer " << i << " (" << GetLayerName(i) << ") module " << (*ih).first << " layer " << i
1088  << " is under occupancy at " << myden << endl;
1089  }
1090  }
1091  }
1092  }
1093  tkmap->save(true, 0, 0, "SiStripHitEffTKMap.png");
1094  tkmapbad->save(true, 0, 0, "SiStripHitEffTKMapBad.png");
1095  tkmapeff->save(true, _tkMapMin, 1., "SiStripHitEffTKMapEff.png");
1096  tkmapnum->save(true, 0, 0, "SiStripHitEffTKMapNum.png");
1097  tkmapden->save(true, 0, 0, "SiStripHitEffTKMapDen.png");
1098  cout << "Finished TKMap Generation\n";
1099 }
1100 
1102  //Generate the SQLite file for use in the Database of the bad modules!
1103  cout << "Entering SQLite file generation!\n";
1104  std::vector<unsigned int> BadStripList;
1105  unsigned short NStrips;
1106  unsigned int id1;
1107  std::unique_ptr<SiStripQuality> pQuality = std::make_unique<SiStripQuality>(_detInfo);
1108  //This is the list of the bad strips, use to mask out entire APVs
1109  //Now simply go through the bad hit list and mask out things that
1110  //are bad!
1111  map<unsigned int, double>::const_iterator it;
1112  for (it = BadModules.begin(); it != BadModules.end(); it++) {
1113  //We need to figure out how many strips are in this particular module
1114  //To Mask correctly!
1115  NStrips = _detInfo.getNumberOfApvsAndStripLength((*it).first).first * 128;
1116  cout << "Number of strips module " << (*it).first << " is " << NStrips << endl;
1117  BadStripList.push_back(pQuality->encode(0, NStrips, 0));
1118  //Now compact into a single bad module
1119  id1 = (unsigned int)(*it).first;
1120  cout << "ID1 shoudl match list of modules above " << id1 << endl;
1121  quality_->compact(id1, BadStripList);
1122  SiStripQuality::Range range(BadStripList.begin(), BadStripList.end());
1123  quality_->put(id1, range);
1124  BadStripList.clear();
1125  }
1126  //Fill all the bad components now
1128 }
1129 
1131  //Calculate the statistics by layer
1132  int totalfound = 0;
1133  int totaltotal = 0;
1134  double layereff;
1135  int subdetfound[5];
1136  int subdettotal[5];
1137 
1138  for (Long_t i = 1; i < 5; i++) {
1139  subdetfound[i] = 0;
1140  subdettotal[i] = 0;
1141  }
1142 
1143  for (Long_t i = 1; i <= 22; i++) {
1144  layereff = double(layerfound[i]) / double(layertotal[i]);
1145  cout << "Layer " << i << " (" << GetLayerName(i) << ") has total efficiency " << layereff << " " << layerfound[i]
1146  << "/" << layertotal[i] << endl;
1147  totalfound += layerfound[i];
1148  totaltotal += layertotal[i];
1149  if (i < 5) {
1150  subdetfound[1] += layerfound[i];
1151  subdettotal[1] += layertotal[i];
1152  }
1153  if (i >= 5 && i < 11) {
1154  subdetfound[2] += layerfound[i];
1155  subdettotal[2] += layertotal[i];
1156  }
1157  if (i >= 11 && i < 14) {
1158  subdetfound[3] += layerfound[i];
1159  subdettotal[3] += layertotal[i];
1160  }
1161  if (i >= 14) {
1162  subdetfound[4] += layerfound[i];
1163  subdettotal[4] += layertotal[i];
1164  }
1165  }
1166 
1167  cout << "The total efficiency is " << double(totalfound) / double(totaltotal) << endl;
1168  cout << " TIB: " << double(subdetfound[1]) / subdettotal[1] << " " << subdetfound[1] << "/" << subdettotal[1]
1169  << endl;
1170  cout << " TOB: " << double(subdetfound[2]) / subdettotal[2] << " " << subdetfound[2] << "/" << subdettotal[2]
1171  << endl;
1172  cout << " TID: " << double(subdetfound[3]) / subdettotal[3] << " " << subdetfound[3] << "/" << subdettotal[3]
1173  << endl;
1174  cout << " TEC: " << double(subdetfound[4]) / subdettotal[4] << " " << subdetfound[4] << "/" << subdettotal[4]
1175  << endl;
1176 }
1177 
1179  //setTDRStyle();
1180 
1181  int nLayers = 34;
1182  if (_showRings)
1183  nLayers = 30;
1184  if (!_showEndcapSides) {
1185  if (!_showRings)
1186  nLayers = 22;
1187  else
1188  nLayers = 20;
1189  }
1190 
1191  TH1F* found = fs->make<TH1F>("found", "found", nLayers + 1, 0, nLayers + 1);
1192  TH1F* all = fs->make<TH1F>("all", "all", nLayers + 1, 0, nLayers + 1);
1193  TH1F* found2 = fs->make<TH1F>("found2", "found2", nLayers + 1, 0, nLayers + 1);
1194  TH1F* all2 = fs->make<TH1F>("all2", "all2", nLayers + 1, 0, nLayers + 1);
1195  // first bin only to keep real data off the y axis so set to -1
1196  found->SetBinContent(0, -1);
1197  all->SetBinContent(0, 1);
1198 
1199  // new ROOT version: TGraph::Divide don't handle null or negative values
1200  for (Long_t i = 1; i < nLayers + 2; ++i) {
1201  found->SetBinContent(i, 1e-6);
1202  all->SetBinContent(i, 1);
1203  found2->SetBinContent(i, 1e-6);
1204  all2->SetBinContent(i, 1);
1205  }
1206 
1207  TCanvas* c7 = new TCanvas("c7", " test ", 10, 10, 800, 600);
1208  c7->SetFillColor(0);
1209  c7->SetGrid();
1210 
1211  int nLayers_max = nLayers + 1; // barrel+endcap
1212  if (!_showEndcapSides)
1213  nLayers_max = 11; // barrel
1214  for (Long_t i = 1; i < nLayers_max; ++i) {
1215  cout << "Fill only good modules layer " << i << ": S = " << goodlayerfound[i] << " B = " << goodlayertotal[i]
1216  << endl;
1217  if (goodlayertotal[i] > 5) {
1218  found->SetBinContent(i, goodlayerfound[i]);
1219  all->SetBinContent(i, goodlayertotal[i]);
1220  }
1221 
1222  cout << "Filling all modules layer " << i << ": S = " << alllayerfound[i] << " B = " << alllayertotal[i]
1223  << endl;
1224  if (alllayertotal[i] > 5) {
1225  found2->SetBinContent(i, alllayerfound[i]);
1226  all2->SetBinContent(i, alllayertotal[i]);
1227  }
1228  }
1229 
1230  // endcap - merging sides
1231  if (!_showEndcapSides) {
1232  for (Long_t i = 11; i < 14; ++i) { // TID disks
1233  cout << "Fill only good modules layer " << i << ": S = " << goodlayerfound[i] + goodlayerfound[i + 3]
1234  << " B = " << goodlayertotal[i] + goodlayertotal[i + 3] << endl;
1235  if (goodlayertotal[i] + goodlayertotal[i + 3] > 5) {
1236  found->SetBinContent(i, goodlayerfound[i] + goodlayerfound[i + 3]);
1237  all->SetBinContent(i, goodlayertotal[i] + goodlayertotal[i + 3]);
1238  }
1239  cout << "Filling all modules layer " << i << ": S = " << alllayerfound[i] + alllayerfound[i + 3]
1240  << " B = " << alllayertotal[i] + alllayertotal[i + 3] << endl;
1241  if (alllayertotal[i] + alllayertotal[i + 3] > 5) {
1242  found2->SetBinContent(i, alllayerfound[i] + alllayerfound[i + 3]);
1243  all2->SetBinContent(i, alllayertotal[i] + alllayertotal[i + 3]);
1244  }
1245  }
1246  for (Long_t i = 17; i < 17 + nTEClayers; ++i) { // TEC disks
1247  cout << "Fill only good modules layer " << i - 3
1248  << ": S = " << goodlayerfound[i] + goodlayerfound[i + nTEClayers]
1249  << " B = " << goodlayertotal[i] + goodlayertotal[i + nTEClayers] << endl;
1250  if (goodlayertotal[i] + goodlayertotal[i + nTEClayers] > 5) {
1251  found->SetBinContent(i - 3, goodlayerfound[i] + goodlayerfound[i + nTEClayers]);
1252  all->SetBinContent(i - 3, goodlayertotal[i] + goodlayertotal[i + nTEClayers]);
1253  }
1254  cout << "Filling all modules layer " << i - 3 << ": S = " << alllayerfound[i] + alllayerfound[i + nTEClayers]
1255  << " B = " << alllayertotal[i] + alllayertotal[i + nTEClayers] << endl;
1256  if (alllayertotal[i] + alllayertotal[i + nTEClayers] > 5) {
1257  found2->SetBinContent(i - 3, alllayerfound[i] + alllayerfound[i + nTEClayers]);
1258  all2->SetBinContent(i - 3, alllayertotal[i] + alllayertotal[i + nTEClayers]);
1259  }
1260  }
1261  }
1262 
1263  found->Sumw2();
1264  all->Sumw2();
1265 
1266  found2->Sumw2();
1267  all2->Sumw2();
1268 
1269  TGraphAsymmErrors* gr = fs->make<TGraphAsymmErrors>(nLayers + 1);
1270  gr->SetName("eff_good");
1271  gr->BayesDivide(found, all);
1272 
1273  TGraphAsymmErrors* gr2 = fs->make<TGraphAsymmErrors>(nLayers + 1);
1274  gr2->SetName("eff_all");
1275  gr2->BayesDivide(found2, all2);
1276 
1277  for (int j = 0; j < nLayers + 1; j++) {
1278  gr->SetPointError(j, 0., 0., gr->GetErrorYlow(j), gr->GetErrorYhigh(j));
1279  gr2->SetPointError(j, 0., 0., gr2->GetErrorYlow(j), gr2->GetErrorYhigh(j));
1280  }
1281 
1282  gr->GetXaxis()->SetLimits(0, nLayers);
1283  gr->SetMarkerColor(2);
1284  gr->SetMarkerSize(1.2);
1285  gr->SetLineColor(2);
1286  gr->SetLineWidth(4);
1287  gr->SetMarkerStyle(20);
1288  gr->SetMinimum(_effPlotMin);
1289  gr->SetMaximum(1.001);
1290  gr->GetYaxis()->SetTitle("Efficiency");
1291  gStyle->SetTitleFillColor(0);
1292  gStyle->SetTitleBorderSize(0);
1293  gr->SetTitle(_title);
1294 
1295  gr2->GetXaxis()->SetLimits(0, nLayers);
1296  gr2->SetMarkerColor(1);
1297  gr2->SetMarkerSize(1.2);
1298  gr2->SetLineColor(1);
1299  gr2->SetLineWidth(4);
1300  gr2->SetMarkerStyle(21);
1301  gr2->SetMinimum(_effPlotMin);
1302  gr2->SetMaximum(1.001);
1303  gr2->GetYaxis()->SetTitle("Efficiency");
1304  gr2->SetTitle(_title);
1305 
1306  for (Long_t k = 1; k < nLayers + 1; k++) {
1307  TString label;
1308  if (_showEndcapSides)
1310  else
1311  label = GetLayerName(k);
1312  if (!_showTOB6TEC9) {
1313  if (k == 10)
1314  label = "";
1315  if (!_showRings && k == nLayers)
1316  label = "";
1317  if (!_showRings && _showEndcapSides && k == 25)
1318  label = "";
1319  }
1320  if (!_showRings) {
1321  if (_showEndcapSides) {
1322  gr->GetXaxis()->SetBinLabel(((k + 1) * 100 + 2) / (nLayers)-4, label);
1323  gr2->GetXaxis()->SetBinLabel(((k + 1) * 100 + 2) / (nLayers)-4, label);
1324  } else {
1325  gr->GetXaxis()->SetBinLabel((k + 1) * 100 / (nLayers)-6, label);
1326  gr2->GetXaxis()->SetBinLabel((k + 1) * 100 / (nLayers)-6, label);
1327  }
1328  } else {
1329  if (_showEndcapSides) {
1330  gr->GetXaxis()->SetBinLabel((k + 1) * 100 / (nLayers)-4, label);
1331  gr2->GetXaxis()->SetBinLabel((k + 1) * 100 / (nLayers)-4, label);
1332  } else {
1333  gr->GetXaxis()->SetBinLabel((k + 1) * 100 / (nLayers)-7, label);
1334  gr2->GetXaxis()->SetBinLabel((k + 1) * 100 / (nLayers)-7, label);
1335  }
1336  }
1337  }
1338 
1339  gr->Draw("AP");
1340  gr->GetXaxis()->SetNdivisions(36);
1341 
1342  c7->cd();
1343  TPad* overlay = new TPad("overlay", "", 0, 0, 1, 1);
1344  overlay->SetFillStyle(4000);
1345  overlay->SetFillColor(0);
1346  overlay->SetFrameFillStyle(4000);
1347  overlay->Draw("same");
1348  overlay->cd();
1349  if (!_showOnlyGoodModules)
1350  gr2->Draw("AP");
1351 
1352  TLegend* leg = new TLegend(0.70, 0.27, 0.88, 0.40);
1353  leg->AddEntry(gr, "Good Modules", "p");
1354  if (!_showOnlyGoodModules)
1355  leg->AddEntry(gr2, "All Modules", "p");
1356  leg->SetTextSize(0.020);
1357  leg->SetFillColor(0);
1358  leg->Draw("same");
1359 
1360  c7->SaveAs("Summary.png");
1361 }
1362 
1364  cout << "Computing efficiency vs bx" << endl;
1365 
1366  unsigned int nLayers = 22;
1367  if (_showRings)
1368  nLayers = 20;
1369 
1370  for (unsigned int ilayer = 1; ilayer < nLayers; ilayer++) {
1371  TH1F* hfound = fs->make<TH1F>(Form("foundVsBx_layer%i", ilayer), Form("layer %i", ilayer), 3565, 0, 3565);
1372  TH1F* htotal = fs->make<TH1F>(Form("totalVsBx_layer%i", ilayer), Form("layer %i", ilayer), 3565, 0, 3565);
1373 
1374  for (unsigned int ibx = 0; ibx < 3566; ibx++) {
1375  hfound->SetBinContent(ibx, 1e-6);
1376  htotal->SetBinContent(ibx, 1);
1377  }
1378  map<unsigned int, vector<int> >::iterator iterMapvsBx;
1379  for (iterMapvsBx = layerfound_perBx.begin(); iterMapvsBx != layerfound_perBx.end(); ++iterMapvsBx)
1380  hfound->SetBinContent(iterMapvsBx->first, iterMapvsBx->second[ilayer]);
1381  for (iterMapvsBx = layertotal_perBx.begin(); iterMapvsBx != layertotal_perBx.end(); ++iterMapvsBx)
1382  if (iterMapvsBx->second[ilayer] > 0)
1383  htotal->SetBinContent(iterMapvsBx->first, iterMapvsBx->second[ilayer]);
1384 
1385  hfound->Sumw2();
1386  htotal->Sumw2();
1387 
1388  TGraphAsymmErrors* geff = fs->make<TGraphAsymmErrors>(3564);
1389  geff->SetName(Form("effVsBx_layer%i", ilayer));
1390  geff->SetTitle("Hit Efficiency vs bx - " + GetLayerName(ilayer));
1391  geff->BayesDivide(hfound, htotal);
1392 
1393  //Average over trains
1394  TGraphAsymmErrors* geff_avg = fs->make<TGraphAsymmErrors>();
1395  geff_avg->SetName(Form("effVsBxAvg_layer%i", ilayer));
1396  geff_avg->SetTitle("Hit Efficiency vs bx - " + GetLayerName(ilayer));
1397  geff_avg->SetMarkerStyle(20);
1398  int ibx = 0;
1399  int previous_bx = -80;
1400  int delta_bx = 0;
1401  int nbx = 0;
1402  int found = 0;
1403  int total = 0;
1404  double sum_bx = 0;
1405  int ipt = 0;
1406  float low, up, eff;
1407  int firstbx = 0;
1408  for (iterMapvsBx = layertotal_perBx.begin(); iterMapvsBx != layertotal_perBx.end(); ++iterMapvsBx) {
1409  ibx = iterMapvsBx->first;
1410  delta_bx = ibx - previous_bx;
1411  // consider a new train
1412  if (delta_bx > (int)_spaceBetweenTrains && nbx > 0 && total > 0) {
1413  eff = found / (float)total;
1414  //cout<<"new train "<<ipt<<" "<<sum_bx/nbx<<" "<<eff<<endl;
1415  geff_avg->SetPoint(ipt, sum_bx / nbx, eff);
1416  low = TEfficiency::Bayesian(total, found, .683, 1, 1, false);
1417  up = TEfficiency::Bayesian(total, found, .683, 1, 1, true);
1418  geff_avg->SetPointError(ipt, sum_bx / nbx - firstbx, previous_bx - sum_bx / nbx, eff - low, up - eff);
1419  ipt++;
1420  sum_bx = 0;
1421  found = 0;
1422  total = 0;
1423  nbx = 0;
1424  firstbx = ibx;
1425  }
1426  sum_bx += ibx;
1427  found += hfound->GetBinContent(ibx);
1428  total += htotal->GetBinContent(ibx);
1429  nbx++;
1430 
1431  previous_bx = ibx;
1432  }
1433  //last train
1434  eff = found / (float)total;
1435  //cout<<"new train "<<ipt<<" "<<sum_bx/nbx<<" "<<eff<<endl;
1436  geff_avg->SetPoint(ipt, sum_bx / nbx, eff);
1437  low = TEfficiency::Bayesian(total, found, .683, 1, 1, false);
1438  up = TEfficiency::Bayesian(total, found, .683, 1, 1, true);
1439  geff_avg->SetPointError(ipt, sum_bx / nbx - firstbx, previous_bx - sum_bx / nbx, eff - low, up - eff);
1440  }
1441 }
1442 
1444  TString layername = "";
1445  TString ringlabel = "D";
1446  if (_showRings)
1447  ringlabel = "R";
1448  if (k > 0 && k < 5) {
1449  layername = TString("TIB L") + k;
1450  } else if (k > 4 && k < 11) {
1451  layername = TString("TOB L") + (k - 4);
1452  } else if (k > 10 && k < 14) {
1453  layername = TString("TID ") + ringlabel + (k - 10);
1454  } else if (k > 13 && k < 14 + nTEClayers) {
1455  layername = TString("TEC ") + ringlabel + (k - 13);
1456  }
1457 
1458  return layername;
1459 }
1460 
1461 void SiStripHitEffFromCalibTree::ComputeEff(vector<TH1F*>& vhfound, vector<TH1F*>& vhtotal, string name) {
1462  unsigned int nLayers = 22;
1463  if (_showRings)
1464  nLayers = 20;
1465 
1466  TH1F* hfound;
1467  TH1F* htotal;
1468 
1469  for (unsigned int ilayer = 1; ilayer < nLayers; ilayer++) {
1470  hfound = vhfound[ilayer];
1471  htotal = vhtotal[ilayer];
1472 
1473  hfound->Sumw2();
1474  htotal->Sumw2();
1475 
1476  // new ROOT version: TGraph::Divide don't handle null or negative values
1477  for (Long_t i = 0; i < hfound->GetNbinsX() + 1; ++i) {
1478  if (hfound->GetBinContent(i) == 0)
1479  hfound->SetBinContent(i, 1e-6);
1480  if (htotal->GetBinContent(i) == 0)
1481  htotal->SetBinContent(i, 1);
1482  }
1483 
1484  TGraphAsymmErrors* geff = fs->make<TGraphAsymmErrors>(hfound->GetNbinsX());
1485  geff->SetName(Form("%s_layer%i", name.c_str(), ilayer));
1486  geff->BayesDivide(hfound, htotal);
1487  if (name == "effVsLumi")
1488  geff->SetTitle("Hit Efficiency vs inst. lumi. - " + GetLayerName(ilayer));
1489  if (name == "effVsPU")
1490  geff->SetTitle("Hit Efficiency vs pileup - " + GetLayerName(ilayer));
1491  if (name == "effVsCM")
1492  geff->SetTitle("Hit Efficiency vs common Mode - " + GetLayerName(ilayer));
1493  geff->SetMarkerStyle(20);
1494  }
1495 }
1496 
1498  cout << "Computing efficiency vs lumi" << endl;
1499 
1500  if (instLumiHisto->GetEntries()) // from infos per event
1501  cout << "Avg conditions (avg+/-rms): lumi :" << instLumiHisto->GetMean() << "+/-" << instLumiHisto->GetRMS()
1502  << " pu: " << PUHisto->GetMean() << "+/-" << PUHisto->GetRMS() << endl;
1503 
1504  else { // from infos per hit
1505 
1506  unsigned int nLayers = 22;
1507  if (_showRings)
1508  nLayers = 20;
1509  unsigned int nLayersForAvg = 0;
1510  float layerLumi = 0;
1511  float layerPU = 0;
1512  float avgLumi = 0;
1513  float avgPU = 0;
1514 
1515  cout << "Lumi summary: (avg over trajectory measurements)" << endl;
1516  for (unsigned int ilayer = 1; ilayer < nLayers; ilayer++) {
1517  layerLumi = layertotal_vsLumi[ilayer]->GetMean();
1518  layerPU = layertotal_vsPU[ilayer]->GetMean();
1519  //cout<<" layer "<<ilayer<<" lumi: "<<layerLumi<<" pu: "<<layerPU<<endl;
1520  if (layerLumi != 0 && layerPU != 0) {
1521  avgLumi += layerLumi;
1522  avgPU += layerPU;
1523  nLayersForAvg++;
1524  }
1525  }
1526  avgLumi /= nLayersForAvg;
1527  avgPU /= nLayersForAvg;
1528  cout << "Avg conditions: lumi :" << avgLumi << " pu: " << avgPU << endl;
1529  }
1530 
1533 }
1534 
1536  cout << "Computing efficiency vs CM" << endl;
1538 }
1539 
1541  TString layername = "";
1542  TString ringlabel = "D";
1543  if (_showRings)
1544  ringlabel = "R";
1545  if (k > 0 && k < 5) {
1546  layername = TString("TIB L") + k;
1547  } else if (k > 4 && k < 11) {
1548  layername = TString("TOB L") + (k - 4);
1549  } else if (k > 10 && k < 14) {
1550  layername = TString("TID- ") + ringlabel + (k - 10);
1551  } else if (k > 13 && k < 17) {
1552  layername = TString("TID+ ") + ringlabel + (k - 13);
1553  } else if (k > 16 && k < 17 + nTEClayers) {
1554  layername = TString("TEC- ") + ringlabel + (k - 16);
1555  } else if (k > 16 + nTEClayers) {
1556  layername = TString("TEC+ ") + ringlabel + (k - 16 - nTEClayers);
1557  }
1558 
1559  return layername;
1560 }
1561 
1562 std::unique_ptr<SiStripBadStrip> SiStripHitEffFromCalibTree::getNewObject() {
1563  //Need this for a Condition DB Writer
1564  //Initialize a return variable
1565  auto obj = std::make_unique<SiStripBadStrip>();
1566 
1569 
1570  for (; rIter != rIterEnd; ++rIter) {
1572  quality_->getDataVectorBegin() + rIter->iend);
1573  if (!obj->put(rIter->detid, range))
1574  edm::LogError("SiStripHitEffFromCalibTree")
1575  << "[SiStripHitEffFromCalibTree::getNewObject] detid already exists" << std::endl;
1576  }
1577 
1578  return obj;
1579 }
1580 
1582  float phi = 0;
1583  float Pi = 3.14159;
1584  if ((x >= 0) && (y >= 0))
1585  phi = atan(y / x);
1586  else if ((x >= 0) && (y <= 0))
1587  phi = atan(y / x) + 2 * Pi;
1588  else if ((x <= 0) && (y >= 0))
1589  phi = atan(y / x) + Pi;
1590  else
1591  phi = atan(y / x) + Pi;
1592  phi = phi * 180.0 / Pi;
1593 
1594  return phi;
1595 }
1596 
1598  int i, int component, SiStripQuality::BadComponent& BC, std::stringstream ssV[4][19], int NBadComponent[4][19][4]) {
1599  int napv = _detInfo.getNumberOfApvsAndStripLength(BC.detid).first;
1600 
1601  ssV[i][component] << "\n\t\t " << BC.detid << " \t " << BC.BadModule << " \t " << ((BC.BadFibers) & 0x1) << " ";
1602  if (napv == 4)
1603  ssV[i][component] << "x " << ((BC.BadFibers >> 1) & 0x1);
1604 
1605  if (napv == 6)
1606  ssV[i][component] << ((BC.BadFibers >> 1) & 0x1) << " " << ((BC.BadFibers >> 2) & 0x1);
1607  ssV[i][component] << " \t " << ((BC.BadApvs) & 0x1) << " " << ((BC.BadApvs >> 1) & 0x1) << " ";
1608  if (napv == 4)
1609  ssV[i][component] << "x x " << ((BC.BadApvs >> 2) & 0x1) << " " << ((BC.BadApvs >> 3) & 0x1);
1610  if (napv == 6)
1611  ssV[i][component] << ((BC.BadApvs >> 2) & 0x1) << " " << ((BC.BadApvs >> 3) & 0x1) << " "
1612  << ((BC.BadApvs >> 4) & 0x1) << " " << ((BC.BadApvs >> 5) & 0x1) << " ";
1613 
1614  if (BC.BadApvs) {
1615  NBadComponent[i][0][2] += ((BC.BadApvs >> 5) & 0x1) + ((BC.BadApvs >> 4) & 0x1) + ((BC.BadApvs >> 3) & 0x1) +
1616  ((BC.BadApvs >> 2) & 0x1) + ((BC.BadApvs >> 1) & 0x1) + ((BC.BadApvs) & 0x1);
1617  NBadComponent[i][component][2] += ((BC.BadApvs >> 5) & 0x1) + ((BC.BadApvs >> 4) & 0x1) +
1618  ((BC.BadApvs >> 3) & 0x1) + ((BC.BadApvs >> 2) & 0x1) +
1619  ((BC.BadApvs >> 1) & 0x1) + ((BC.BadApvs) & 0x1);
1620  }
1621  if (BC.BadFibers) {
1622  NBadComponent[i][0][1] += ((BC.BadFibers >> 2) & 0x1) + ((BC.BadFibers >> 1) & 0x1) + ((BC.BadFibers) & 0x1);
1623  NBadComponent[i][component][1] +=
1624  ((BC.BadFibers >> 2) & 0x1) + ((BC.BadFibers >> 1) & 0x1) + ((BC.BadFibers) & 0x1);
1625  }
1626  if (BC.BadModule) {
1627  NBadComponent[i][0][0]++;
1628  NBadComponent[i][component][0]++;
1629  }
1630 }
1631 
cmsHarvester.nevents
nevents
Definition: cmsHarvester.py:3176
TrackExtra.h
SiStripQuality::BadComponent::detid
uint32_t detid
Definition: SiStripQuality.h:35
SiStripHitEffFromCalibTree::layerfound
long layerfound[23]
Definition: SiStripHitEffFromCalibTree.cc:171
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
DDAxes::y
SiStripHitEffFromCalibTree::layerfound_vsCM
vector< TH1F * > layerfound_vsCM
Definition: SiStripHitEffFromCalibTree.cc:179
BeamSpotPI::parameters
parameters
Definition: BeamSpotPayloadInspectorHelper.h:30
Handle.h
electrons_cff.bool
bool
Definition: electrons_cff.py:366
mps_fire.i
i
Definition: mps_fire.py:428
SiStripHitEffFromCalibTree::makeSummary
void makeSummary()
Definition: SiStripHitEffFromCalibTree.cc:1178
Muon.h
SiStripHitEffFromCalibTree::algoBeginJob
void algoBeginJob(const edm::EventSetup &) override
Definition: SiStripHitEffFromCalibTree.cc:224
Bounds::width
virtual float width() const =0
SiStripHitEffFromCalibTree::_stripsApvEdge
float _stripsApvEdge
Definition: SiStripHitEffFromCalibTree.cc:138
TrackingMonitor_cfi.stripCluster
stripCluster
Definition: TrackingMonitor_cfi.py:20
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
SiStripClusterInfo.h
SiStripHitEffFromCalibTree::threshold
float threshold
Definition: SiStripHitEffFromCalibTree.cc:130
TrackerGeometry.h
hit::id
unsigned int id
Definition: SiStripHitEffFromCalibTree.cc:92
SiStripHitEffFromCalibTree::layerfound_perBx
map< unsigned int, vector< int > > layerfound_perBx
Definition: SiStripHitEffFromCalibTree.cc:173
DeDxData.h
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
hit::y
double y
Definition: SiStripHitEffFromCalibTree.cc:90
SiStripHitEffFromCalibTree::instLumiHisto
TH1F * instLumiHisto
Definition: SiStripHitEffFromCalibTree.cc:157
ESHandle.h
SiStripHitEffFromCalibTree::makeHotColdMaps
void makeHotColdMaps()
Definition: SiStripHitEffFromCalibTree.cc:874
AlCaHarvesting_cff.SiStripQuality
SiStripQuality
Definition: AlCaHarvesting_cff.py:233
SiStripHitEffFromCalibTree::_spaceBetweenTrains
unsigned int _spaceBetweenTrains
Definition: SiStripHitEffFromCalibTree.cc:141
SiStripHitEffFromCalibTree::algoAnalyze
void algoAnalyze(const edm::Event &e, const edm::EventSetup &c) override
Definition: SiStripHitEffFromCalibTree.cc:233
edm
HLT enums.
Definition: AlignableModifier.h:19
SiStripHitEffFromCalibTree::_clusterTrajDist
float _clusterTrajDist
Definition: SiStripHitEffFromCalibTree.cc:137
SiStripHitEffFromCalibTree::alllayertotal
int alllayertotal[35]
Definition: SiStripHitEffFromCalibTree.cc:183
TransientRecHitRecord.h
globals_cff.id1
id1
Definition: globals_cff.py:33
gather_cfg.cout
cout
Definition: gather_cfg.py:144
SiStripHitEffFromCalibTree::_tkGeomToken
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > _tkGeomToken
Definition: SiStripHitEffFromCalibTree.cc:151
SiStripHitEffFromCalibTree::doSummary
unsigned int doSummary
Definition: SiStripHitEffFromCalibTree.cc:132
l1GtPatternGenerator_cfi.bx
bx
Definition: l1GtPatternGenerator_cfi.py:18
SiStripHitEffFromCalibTree::algoEndJob
void algoEndJob() override
Definition: SiStripHitEffFromCalibTree.cc:229
SiStripBadStrip::decode
data decode(const unsigned int &value) const
Definition: SiStripBadStrip.h:78
GeomDetType.h
SiStripHitEffFromCalibTree::CalibTree
TTree * CalibTree
Definition: SiStripHitEffFromCalibTree.cc:128
SiStripHitEffFromCalibTree::SetBadComponents
void SetBadComponents(int i, int component, SiStripQuality::BadComponent &BC, std::stringstream ssV[4][19], int NBadComponent[4][19][4])
Definition: SiStripHitEffFromCalibTree.cc:1597
SiStripDetInfoFileReader
Definition: SiStripDetInfoFileReader.h:7
SiStripHitEffFromCalibTree::_autoIneffModTagging
bool _autoIneffModTagging
Definition: SiStripHitEffFromCalibTree.cc:134
SiStripDetId.h
TrackerMap::fill
void fill(int layer, int ring, int nmod, float x)
Definition: TrackerMap.cc:3288
SiStripHitEffFromCalibTree::nTEClayers
unsigned int nTEClayers
Definition: SiStripHitEffFromCalibTree.cc:154
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
EDAnalyzer.h
DDAxes::x
CkfComponentsRecord.h
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:46
SiStripBadStrip::put
bool put(const uint32_t &detID, const InputVector &vect)
Definition: SiStripBadStrip.h:65
SiStripHitEffFromCalibTree::tkmapnum
TrackerMap * tkmapnum
Definition: SiStripHitEffFromCalibTree.cc:169
SiStripHitEffFromCalibTree::tkmapbad
TrackerMap * tkmapbad
Definition: SiStripHitEffFromCalibTree.cc:167
SiStripBadStrip::getDataVectorBegin
ContainerIterator getDataVectorBegin() const
Definition: SiStripBadStrip.h:73
newFWLiteAna.found
found
Definition: newFWLiteAna.py:118
JetPlusTrackCorrections_cff.PU
PU
Definition: JetPlusTrackCorrections_cff.py:32
python.cmstools.all
def all(container)
workaround iterator generators for ROOT classes
Definition: cmstools.py:25
HitEff.h
SiStripDetInfoFileReader::read
SiStripDetInfo read(std::string filePath)
Definition: SiStripDetInfoFileReader.cc:11
SiStripBadStrip
Definition: SiStripBadStrip.h:30
mps_splice.mods
mods
Definition: mps_splice.py:43
quality
const uint32_t *__restrict__ Quality * quality
Definition: CAHitNtupletGeneratorKernelsImpl.h:122
SiStripHitEffFromCalibTree::BadModules
map< unsigned int, double > BadModules
Definition: SiStripHitEffFromCalibTree.cc:185
SiStripHitEffFromCalibTree::_title
TString _title
Definition: SiStripHitEffFromCalibTree.cc:149
hit::x
double x
Definition: SiStripHitEffFromCalibTree.cc:89
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
DetId
Definition: DetId.h:17
edm::FileInPath
Definition: FileInPath.h:61
accept
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:31
GeomDet::surface
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
MakerMacros.h
TrackerTopology.h
SiStripHitEffFromCalibTree::totalStatistics
void totalStatistics()
Definition: SiStripHitEffFromCalibTree.cc:1130
testProducerWithPsetDescEmpty_cfi.x1
x1
Definition: testProducerWithPsetDescEmpty_cfi.py:33
TrackingRecHit.h
SiStripBadStrip::Range
std::pair< ContainerIterator, ContainerIterator > Range
Definition: SiStripBadStrip.h:53
SiStripQuality::getBadComponentList
const std::vector< BadComponent > & getBadComponentList() const
Definition: SiStripQuality.h:114
SiStripHitEffFromCalibTree::getNewObject
std::unique_ptr< SiStripBadStrip > getNewObject() override
Definition: SiStripHitEffFromCalibTree.cc:1562
SiStripDetCabling.h
SiStripBadStrip::getRegistryVectorBegin
RegistryIterator getRegistryVectorBegin() const
Definition: SiStripBadStrip.h:75
TrackerTopologyRcd.h
Track.h
SiStripHitEffFromCalibTree::PUHisto
TH1F * PUHisto
Definition: SiStripHitEffFromCalibTree.cc:158
TrackFwd.h
ConditionDBWriter
Definition: ConditionDBWriter.h:149
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
TrapezoidalPlaneBounds.h
SiStripHitEffFromCalibTree::makeSummaryVsLumi
void makeSummaryVsLumi()
Definition: SiStripHitEffFromCalibTree.cc:1497
Service.h
SiStripHitEffFromCalibTree::modCounter
map< unsigned int, pair< unsigned int, unsigned int > > modCounter[23]
Definition: SiStripHitEffFromCalibTree.cc:165
MuonFwd.h
SiStripQuality::compact
void compact(unsigned int &, std::vector< unsigned int > &)
Definition: SiStripQuality.cc:285
Surface::bounds
const Bounds & bounds() const
Definition: Surface.h:87
compare_using_db.ifile
ifile
Definition: compare_using_db.py:251
mps_fire.end
end
Definition: mps_fire.py:242
DDAxes::z
SiStripDetInfo::getNumberOfApvsAndStripLength
const std::pair< unsigned short, double > getNumberOfApvsAndStripLength(uint32_t detId) const
Definition: SiStripDetInfo.cc:19
str
#define str(s)
Definition: TestProcessor.cc:53
SiStripHitEffFromCalibTree::_clusterMatchingMethod
unsigned int _clusterMatchingMethod
Definition: SiStripHitEffFromCalibTree.cc:135
SiStripHitEffFromCalibTree::calcPhi
float calcPhi(float x, float y)
Definition: SiStripHitEffFromCalibTree.cc:1581
SiStripHitEffFromCalibTree::_showEndcapSides
bool _showEndcapSides
Definition: SiStripHitEffFromCalibTree.cc:143
SiStripDetInfoFileReader.h
TrackerMap
Definition: TrackerMap.h:76
SiStripHitEffFromCalibTree::makeSummaryVsCM
void makeSummaryVsCM()
Definition: SiStripHitEffFromCalibTree.cc:1535
dqmdumpme.k
k
Definition: dqmdumpme.py:60
SiStripHitEffFromCalibTree::makeTKMap
void makeTKMap(bool autoTagging)
Definition: SiStripHitEffFromCalibTree.cc:1002
SiStripDetId::TEC
static constexpr auto TEC
Definition: SiStripDetId.h:40
SiStripQuality::BadComponent::BadFibers
unsigned short BadFibers
Definition: SiStripQuality.h:37
SiStripHitEffFromCalibTree::layertotal_perBx
map< unsigned int, vector< int > > layertotal_perBx
Definition: SiStripHitEffFromCalibTree.cc:174
getGTfromDQMFile.obj
obj
Definition: getGTfromDQMFile.py:32
hit::z
double z
Definition: SiStripHitEffFromCalibTree.cc:91
SiStripHitEffFromCalibTree::layerfound_vsPU
vector< TH1F * > layerfound_vsPU
Definition: SiStripHitEffFromCalibTree.cc:177
phase1PixelTopology::layer
constexpr std::array< uint8_t, layerIndexSize > layer
Definition: phase1PixelTopology.h:99
FileInPath.h
MuonTCMETValueMapProducer_cff.nLayers
nLayers
Definition: MuonTCMETValueMapProducer_cff.py:38
SiStripHitEffFromCalibTree::tkmap
TrackerMap * tkmap
Definition: SiStripHitEffFromCalibTree.cc:166
TFileService.h
SiStripHitEffFromCalibTree::makeSummaryVsBx
void makeSummaryVsBx()
Definition: SiStripHitEffFromCalibTree.cc:1363
cppFunctionSkipper.exception
exception
Definition: cppFunctionSkipper.py:10
SiStripHitEffFromCalibTree::goodlayertotal
int goodlayertotal[35]
Definition: SiStripHitEffFromCalibTree.cc:181
TrackerDigiGeometryRecord.h
edm::ParameterSet
Definition: ParameterSet.h:47
SiStripHitEffFromCalibTree
Definition: SiStripHitEffFromCalibTree.cc:95
a
double a
Definition: hdecay.h:119
SiStripCluster.h
Event.h
SiStripHitEffFromCalibTree::hits
vector< hit > hits[23]
Definition: SiStripHitEffFromCalibTree.cc:163
SiStripHitEffFromCalibTree::_useCM
bool _useCM
Definition: SiStripHitEffFromCalibTree.cc:142
SiStripHitEffFromCalibTree::FileInPath_
edm::FileInPath FileInPath_
Definition: SiStripHitEffFromCalibTree.cc:124
SiStripHitEffFromCalibTree::layertotal_vsCM
vector< TH1F * > layertotal_vsCM
Definition: SiStripHitEffFromCalibTree.cc:180
SiStripHitEffFromCalibTree::bxHisto
TH1F * bxHisto
Definition: SiStripHitEffFromCalibTree.cc:156
SiStripHitEffFromCalibTree::nModsMin
unsigned int nModsMin
Definition: SiStripHitEffFromCalibTree.cc:131
SiStripQuality::BadComponent::BadModule
bool BadModule
Definition: SiStripQuality.h:38
edm::Service< TFileService >
createfilelist.int
int
Definition: createfilelist.py:10
SiStripHitEffFromCalibTree::GetLayerName
TString GetLayerName(Long_t k)
Definition: SiStripHitEffFromCalibTree.cc:1443
SiStripHitEffFromCalibTree::_detInfo
SiStripDetInfo _detInfo
Definition: SiStripHitEffFromCalibTree.cc:123
SiStripHitEffFromCalibTree::fs
edm::Service< TFileService > fs
Definition: SiStripHitEffFromCalibTree.cc:122
compare.overlay
def overlay(hists, ytitle, header, addon)
Definition: compare.py:122
SiStripDetId::TOB
static constexpr auto TOB
Definition: SiStripDetId.h:39
SiStripHitEffFromCalibTree::makeSQLite
void makeSQLite()
Definition: SiStripHitEffFromCalibTree.cc:1101
SiStripQuality::BadComponent::BadApvs
unsigned short BadApvs
Definition: SiStripQuality.h:36
SiStripQuality::fillBadComponents
void fillBadComponents()
Definition: SiStripQuality.cc:490
edm::EventSetup
Definition: EventSetup.h:58
AnalyticalPropagator.h
DetSetVector.h
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
SiStripHitEffFromCalibTree::GetLayerSideName
TString GetLayerSideName(Long_t k)
Definition: SiStripHitEffFromCalibTree.cc:1540
TrapezoidalPlaneBounds
Definition: TrapezoidalPlaneBounds.h:15
muonGEMDigis_cfi.instLumi
instLumi
Definition: muonGEMDigis_cfi.py:10
TFileService::make
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord >
ConditionDBWriter.h
SiStripHitEffFromCalibTree::SiStripHitEffFromCalibTree
SiStripHitEffFromCalibTree(const edm::ParameterSet &)
Definition: SiStripHitEffFromCalibTree.cc:188
StripTopology::nstrips
virtual int nstrips() const =0
SiStripHitEffFromCalibTree::_badModulesFile
string _badModulesFile
Definition: SiStripHitEffFromCalibTree.cc:133
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:204
TrackerMap.h
DDAxes::phi
SiStripDetId::TID
static constexpr auto TID
Definition: SiStripDetId.h:38
nevt
int nevt
Definition: ReggeGribovPartonMCHadronizer.h:66
SiStripHitEffFromCalibTree::_tkMapMin
float _tkMapMin
Definition: SiStripHitEffFromCalibTree.cc:147
SiStripHitEffFromCalibTree::eventInfos
map< pair< unsigned int, unsigned int >, array< double, 3 > > eventInfos
Definition: SiStripHitEffFromCalibTree.cc:161
GeomDet.h
TrackerMap::save
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:810
SiStripHitEffFromCalibTree::alllayerfound
int alllayerfound[35]
Definition: SiStripHitEffFromCalibTree.cc:184
std
Definition: JetResolutionObject.h:76
writedatasetfile.run
run
Definition: writedatasetfile.py:27
SiStripHitEffFromCalibTree::HotColdMaps
vector< TH2F * > HotColdMaps
Definition: SiStripHitEffFromCalibTree.cc:164
SiStripQuality::BadComponent
Definition: SiStripQuality.h:34
SiStripHitEffFromCalibTree::_useOnlyHighPurityTracks
bool _useOnlyHighPurityTracks
Definition: SiStripHitEffFromCalibTree.cc:139
SiStripHitEffFromCalibTree::_effPlotMin
float _effPlotMin
Definition: SiStripHitEffFromCalibTree.cc:148
SiStripHitEffFromCalibTree::_ResXSig
float _ResXSig
Definition: SiStripHitEffFromCalibTree.cc:136
Frameworkfwd.h
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
SiStripDetInfoFileReader::kDefaultFile
constexpr static char const *const kDefaultFile
Definition: SiStripDetInfoFileReader.h:10
genVertex_cff.x
x
Definition: genVertex_cff.py:13
BoundPlane
SiStripQuality.h
muons_cff.highPurity
highPurity
Definition: muons_cff.py:136
detailsBasic3DVector::y
float float y
Definition: extBasic3DVector.h:14
SiStripQualityRcd.h
SiStripDetId::TIB
static constexpr auto TIB
Definition: SiStripDetId.h:37
SiStripHitEffFromCalibTree::_tTopoToken
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > _tTopoToken
Definition: SiStripHitEffFromCalibTree.cc:152
DetLayer.h
GlobalVector.h
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
EventSetup.h
StripClusterParameterEstimator.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
SiStripBadStrip::RegistryIterator
Registry::const_iterator RegistryIterator
Definition: SiStripBadStrip.h:55
dqmMemoryStats.total
total
Definition: dqmMemoryStats.py:152
Pi
const double Pi
Definition: CosmicMuonParameters.h:18
SiStripHitEffFromCalibTree::layertotal_vsPU
vector< TH1F * > layertotal_vsPU
Definition: SiStripHitEffFromCalibTree.cc:178
SiStripHitEffFromCalibTree::layertotal
long layertotal[23]
Definition: SiStripHitEffFromCalibTree.cc:172
SiStripBadStrip::data::range
unsigned short range
Definition: SiStripBadStrip.h:34
edm::EDConsumerBase::esConsumes
auto esConsumes()
Definition: EDConsumerBase.h:206
SiStripHitEffFromCalibTree::ComputeEff
void ComputeEff(vector< TH1F * > &vhfound, vector< TH1F * > &vhtotal, string name)
Definition: SiStripHitEffFromCalibTree.cc:1461
StripGeomDetUnit::specificTopology
virtual const StripTopology & specificTopology() const
Returns a reference to the strip proxy topology.
Definition: StripGeomDetUnit.cc:17
SiStripHitEffFromCalibTree::_bunchx
unsigned int _bunchx
Definition: SiStripHitEffFromCalibTree.cc:140
SiStripDetInfo
Definition: SiStripDetInfo.h:29
SiStripHitEffFromCalibTree::~SiStripHitEffFromCalibTree
~SiStripHitEffFromCalibTree() override
Definition: SiStripHitEffFromCalibTree.cc:222
SiStripDetCablingRcd.h
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
TrajectoryAtInvalidHit.h
SiStripHitEffFromCalibTree::tkmapden
TrackerMap * tkmapden
Definition: SiStripHitEffFromCalibTree.cc:170
SiStripHitEffFromCalibTree::layertotal_vsLumi
vector< TH1F * > layertotal_vsLumi
Definition: SiStripHitEffFromCalibTree.cc:176
ParameterSet.h
SiStripDetId
Detector identifier class for the strip tracker.
Definition: SiStripDetId.h:18
SiStripHitEffFromCalibTree::_showOnlyGoodModules
bool _showOnlyGoodModules
Definition: SiStripHitEffFromCalibTree.cc:146
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:56
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
edm::Event
Definition: Event.h:73
mps_splice.line
line
Definition: mps_splice.py:76
LocalVector.h
SiStripHitEffFromCalibTree::quality_
SiStripQuality * quality_
Definition: SiStripHitEffFromCalibTree.cc:125
edm::Log
Definition: MessageLogger.h:70
reco::component
Definition: component.h:57
SiStripHitEffFromCalibTree::goodlayerfound
int goodlayerfound[35]
Definition: SiStripHitEffFromCalibTree.cc:182
StripTopology
Definition: StripTopology.h:11
GlobalPoint.h
SiStripHitEffFromCalibTree::CalibTreeFilenames
vector< string > CalibTreeFilenames
Definition: SiStripHitEffFromCalibTree.cc:129
StripSubdetector.h
DetSetVectorNew.h
LaserClient_cfi.low
low
Definition: LaserClient_cfi.py:52
label
const char * label
Definition: PFTauDecayModeTools.cc:11
DetIdCollection.h
up
Definition: BitonicSort.h:7
SiStripBadStrip::getRegistryVectorEnd
RegistryIterator getRegistryVectorEnd() const
Definition: SiStripBadStrip.h:76
edm::FileInPath::fullPath
std::string fullPath() const
Definition: FileInPath.cc:161
hit
Definition: SiStripHitEffFromCalibTree.cc:88
SiStripHitEffFromCalibTree::tkmapeff
TrackerMap * tkmapeff
Definition: SiStripHitEffFromCalibTree.cc:168
TrackerMap::fillc
void fillc(int idmod, int RGBcode)
Definition: TrackerMap.h:135
SiStripHitEffFromCalibTree::_showTOB6TEC9
bool _showTOB6TEC9
Definition: SiStripHitEffFromCalibTree.cc:145
MeasurementTracker.h
SiStripHitEffFromCalibTree::layerfound_vsLumi
vector< TH1F * > layerfound_vsLumi
Definition: SiStripHitEffFromCalibTree.cc:175
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
StripGeomDetUnit
Definition: StripGeomDetUnit.h:15
SiStripHitEffFromCalibTree::_showRings
bool _showRings
Definition: SiStripHitEffFromCalibTree.cc:144
SiStripQuality
Definition: SiStripQuality.h:32