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