CMS 3D CMS Logo

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