CMS 3D CMS Logo

SiStripBadStrip_PayloadInspector.cc
Go to the documentation of this file.
1 
10 
14 
15 // the data format of the condition to be inspected
20 
22 
23 // needed for the tracker map
25 
26 // auxilliary functions
29 
32 
33 
34 #include <memory>
35 #include <sstream>
36 #include <iostream>
37 
38 // include ROOT
39 #include "TH2F.h"
40 #include "TLegend.h"
41 #include "TCanvas.h"
42 #include "TLine.h"
43 #include "TStyle.h"
44 #include "TLatex.h"
45 #include "TPave.h"
46 #include "TPaveStats.h"
47 
48 namespace {
49 
50  /************************************************
51  test class
52  *************************************************/
53 
54  class SiStripBadStripTest : public cond::payloadInspector::Histogram1D<SiStripBadStrip> {
55 
56  public:
57  SiStripBadStripTest() : cond::payloadInspector::Histogram1D<SiStripBadStrip>("SiStrip Bad Strip test",
58  "SiStrip Bad Strip test", 10,0.0,10.0){
59  Base::setSingleIov( true );
60  }
61 
62  bool fill( const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs ) override{
63  for ( auto const & iov: iovs) {
64  std::shared_ptr<SiStripBadStrip> payload = Base::fetchPayload( std::get<1>(iov) );
65  if( payload.get() ){
66 
67  fillWithValue(1.);
68 
69  std::stringstream ss;
70  ss << "Summary of bad strips:" << std::endl;
71 
72  //payload->printDebug(ss);
73  //payload->printSummary(ss);
74  //std::cout<<ss.str()<<std::endl;
75 
76  std::vector<uint32_t> detid;
77  payload->getDetIds(detid);
78 
79  for (const auto & d : detid) {
80  SiStripBadStrip::Range range=payload->getRange(d);
81  for( std::vector<unsigned int>::const_iterator badStrip = range.first;badStrip != range.second; ++badStrip ) {
82  ss << "DetId="<< d << " Strip=" << payload->decode(*badStrip).firstStrip <<":"<< payload->decode(*badStrip).range << " flag="<< payload->decode(*badStrip).flag << std::endl;
83  }
84  }
85 
86  std::cout<<ss.str()<<std::endl;
87 
88  }// payload
89  }// iovs
90  return true;
91  }// fill
92  };
93 
94  /************************************************
95  TrackerMap of SiStripBadStrip (bad strip per detid)
96  *************************************************/
97  class SiStripBadModuleTrackerMap : public cond::payloadInspector::PlotImage<SiStripBadStrip> {
98  public:
99  SiStripBadModuleTrackerMap() : cond::payloadInspector::PlotImage<SiStripBadStrip>( "Tracker Map of SiStrip Bad Strips" ){
100  setSingleIov( true );
101  }
102 
103  bool fill( const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs ) override{
104  auto iov = iovs.front();
105  std::shared_ptr<SiStripBadStrip> payload = fetchPayload( std::get<1>(iov) );
106 
107  std::string titleMap = "Module with at least a bad Strip (payload : "+std::get<1>(iov)+")";
108 
109  std::unique_ptr<TrackerMap> tmap = std::unique_ptr<TrackerMap>(new TrackerMap("SiStripBadStrips"));
110  tmap->setTitle(titleMap);
111  tmap->setPalette(1);
112 
113  std::vector<uint32_t> detid;
114  payload->getDetIds(detid);
115 
116  for (const auto & d : detid) {
117  tmap->fill(d,1.);
118  } // loop over detIds
119 
120  //=========================
121 
122  std::string fileName(m_imageFileName);
123  tmap->save(true,0,1.,fileName);
124 
125  return true;
126  }
127  };
128 
129  /************************************************
130  TrackerMap of SiStripBadStrip (bad strips fraction)
131  *************************************************/
132  class SiStripBadStripFractionTrackerMap : public cond::payloadInspector::PlotImage<SiStripBadStrip> {
133  public:
134  SiStripBadStripFractionTrackerMap() : cond::payloadInspector::PlotImage<SiStripBadStrip>( "Tracker Map of SiStrip Bad Components fraction" ){
135  setSingleIov( true );
136  }
137 
138  bool fill( const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs ) override{
139  auto iov = iovs.front();
140  std::shared_ptr<SiStripBadStrip> payload = fetchPayload( std::get<1>(iov) );
141 
142  edm::FileInPath fp_ = edm::FileInPath("CalibTracker/SiStripCommon/data/SiStripDetInfo.dat");
144 
145  std::string titleMap = "Fraction of bad Strips per module (payload : "+std::get<1>(iov)+")";
146 
147  std::unique_ptr<TrackerMap> tmap = std::unique_ptr<TrackerMap>(new TrackerMap("SiStripBadStrips"));
148  tmap->setTitle(titleMap);
149  tmap->setPalette(1);
150 
151  std::vector<uint32_t> detid;
152  payload->getDetIds(detid);
153 
154  std::map<uint32_t,int> badStripsPerDetId;
155 
156  for (const auto & d : detid) {
157  SiStripBadStrip::Range range=payload->getRange(d);
158  for( std::vector<unsigned int>::const_iterator badStrip = range.first;badStrip != range.second; ++badStrip ) {
159  badStripsPerDetId[d]+= payload->decode(*badStrip).range;
160  //ss << "DetId="<< d << " Strip=" << payload->decode(*badStrip).firstStrip <<":"<< payload->decode(*badStrip).range << " flag="<< payload->decode(*badStrip).flag << std::endl;
161  }
162  float fraction = badStripsPerDetId[d]/(128.*reader->getNumberOfApvsAndStripLength(d).first);
163  tmap->fill(d,fraction);
164  } // loop over detIds
165 
166  //=========================
167 
168  std::pair<float,float> extrema = tmap->getAutomaticRange();
169 
170  std::string fileName(m_imageFileName);
171 
172  // protect against uniform values across the map (bad components fractions are defined positive)
173  if (extrema.first!=extrema.second){
174  tmap->save(true,0,0,fileName);
175  } else {
176  tmap->save(true,extrema.first*0.95,extrema.first*1.05,fileName);
177  }
178 
179  delete reader;
180  return true;
181  }
182  };
183 
184  /************************************************
185  time history histogram of bad components fraction
186  *************************************************/
187 
188  class SiStripBadStripFractionByRun : public cond::payloadInspector::HistoryPlot<SiStripBadStrip,float> {
189  public:
190  SiStripBadStripFractionByRun() : cond::payloadInspector::HistoryPlot<SiStripBadStrip,float>( "SiStrip Bad Strip fraction per run","Bad Strip fraction [%]"){}
191  ~SiStripBadStripFractionByRun() override = default;
192 
193  float getFromPayload( SiStripBadStrip& payload ) override{
194 
195  edm::FileInPath fp_ = edm::FileInPath("CalibTracker/SiStripCommon/data/SiStripDetInfo.dat");
197 
198  std::vector<uint32_t> detid;
199  payload.getDetIds(detid);
200 
201  std::map<uint32_t,int> badStripsPerDetId;
202 
203  for (const auto & d : detid) {
204  SiStripBadStrip::Range range=payload.getRange(d);
205  int badStrips(0);
206  for( std::vector<unsigned int>::const_iterator badStrip = range.first;badStrip != range.second; ++badStrip ) {
207  badStrips+= payload.decode(*badStrip).range;
208  }
209  badStripsPerDetId[d] = badStrips;
210  } // loop over detIds
211 
212  float numerator(0.),denominator(0.);
213  std::vector<uint32_t> all_detids=reader->getAllDetIds();
214  for (const auto & det : all_detids) {
215  denominator+=128.*reader->getNumberOfApvsAndStripLength(det).first;
216  if(badStripsPerDetId.count(det)!=0) numerator+= badStripsPerDetId[det];
217  }
218 
219  delete reader;
220  return (numerator/denominator)*100.;
221 
222  } // payload
223  };
224 
225  /************************************************
226  time history histogram of bad components fraction (TIB)
227  *************************************************/
228 
229  class SiStripBadStripTIBFractionByRun : public cond::payloadInspector::HistoryPlot<SiStripBadStrip,float> {
230  public:
231  SiStripBadStripTIBFractionByRun() : cond::payloadInspector::HistoryPlot<SiStripBadStrip,float>( "SiStrip Inner Barrel Bad Strip fraction per run","TIB Bad Strip fraction [%]"){}
232  ~SiStripBadStripTIBFractionByRun() override = default;
233 
234  float getFromPayload( SiStripBadStrip& payload ) override{
235 
236  edm::FileInPath fp_ = edm::FileInPath("CalibTracker/SiStripCommon/data/SiStripDetInfo.dat");
238 
239  std::vector<uint32_t> detid;
240  payload.getDetIds(detid);
241 
242  std::map<uint32_t,int> badStripsPerDetId;
243 
244  for (const auto & d : detid) {
245  SiStripBadStrip::Range range=payload.getRange(d);
246  int badStrips(0);
247  for( std::vector<unsigned int>::const_iterator badStrip = range.first;badStrip != range.second; ++badStrip ) {
248  badStrips+= payload.decode(*badStrip).range;
249  }
250  badStripsPerDetId[d] = badStrips;
251  } // loop over detIds
252 
253  float numerator(0.),denominator(0.);
254  std::vector<uint32_t> all_detids=reader->getAllDetIds();
255  for (const auto & det : all_detids) {
256  int subid = DetId(det).subdetId();
257  if(subid != StripSubdetector::TIB) continue;
258  denominator+=128.*reader->getNumberOfApvsAndStripLength(det).first;
259  if(badStripsPerDetId.count(det)!=0) numerator+= badStripsPerDetId[det];
260  }
261 
262  delete reader;
263  return (numerator/denominator)*100.;
264 
265  } // payload
266  };
267 
268  /************************************************
269  time history histogram of bad components fraction (TOB)
270  *************************************************/
271 
272  class SiStripBadStripTOBFractionByRun : public cond::payloadInspector::HistoryPlot<SiStripBadStrip,float> {
273  public:
274  SiStripBadStripTOBFractionByRun() : cond::payloadInspector::HistoryPlot<SiStripBadStrip,float>( "SiStrip Outer Barrel Bad Strip fraction per run","TOB Bad Strip fraction [%]"){}
275  ~SiStripBadStripTOBFractionByRun() override = default;
276 
277  float getFromPayload( SiStripBadStrip& payload ) override{
278 
279  edm::FileInPath fp_ = edm::FileInPath("CalibTracker/SiStripCommon/data/SiStripDetInfo.dat");
281 
282  std::vector<uint32_t> detid;
283  payload.getDetIds(detid);
284 
285  std::map<uint32_t,int> badStripsPerDetId;
286 
287  for (const auto & d : detid) {
288  SiStripBadStrip::Range range=payload.getRange(d);
289  int badStrips(0);
290  for( std::vector<unsigned int>::const_iterator badStrip = range.first;badStrip != range.second; ++badStrip ) {
291  badStrips+= payload.decode(*badStrip).range;
292  }
293  badStripsPerDetId[d] = badStrips;
294  } // loop over detIds
295 
296  float numerator(0.),denominator(0.);
297  std::vector<uint32_t> all_detids=reader->getAllDetIds();
298  for (const auto & det : all_detids) {
299  int subid = DetId(det).subdetId();
300  if(subid != StripSubdetector::TOB) continue;
301  denominator+=128.*reader->getNumberOfApvsAndStripLength(det).first;
302  if(badStripsPerDetId.count(det)!=0) numerator+= badStripsPerDetId[det];
303  }
304 
305  delete reader;
306  return (numerator/denominator)*100.;
307 
308  } // payload
309  };
310 
311  /************************************************
312  time history histogram of bad components fraction (TID)
313  *************************************************/
314 
315  class SiStripBadStripTIDFractionByRun : public cond::payloadInspector::HistoryPlot<SiStripBadStrip,float> {
316  public:
317  SiStripBadStripTIDFractionByRun() : cond::payloadInspector::HistoryPlot<SiStripBadStrip,float>( "SiStrip Inner Disks Bad Strip fraction per run","TID Bad Strip fraction [%]"){}
318  ~SiStripBadStripTIDFractionByRun() override = default;
319 
320  float getFromPayload( SiStripBadStrip& payload ) override{
321 
322  edm::FileInPath fp_ = edm::FileInPath("CalibTracker/SiStripCommon/data/SiStripDetInfo.dat");
324 
325  std::vector<uint32_t> detid;
326  payload.getDetIds(detid);
327 
328  std::map<uint32_t,int> badStripsPerDetId;
329 
330  for (const auto & d : detid) {
331  SiStripBadStrip::Range range=payload.getRange(d);
332  int badStrips(0);
333  for( std::vector<unsigned int>::const_iterator badStrip = range.first;badStrip != range.second; ++badStrip ) {
334  badStrips+= payload.decode(*badStrip).range;
335  }
336  badStripsPerDetId[d] = badStrips;
337  } // loop over detIds
338 
339  float numerator(0.),denominator(0.);
340  std::vector<uint32_t> all_detids=reader->getAllDetIds();
341  for (const auto & det : all_detids) {
342  int subid = DetId(det).subdetId();
343  if(subid != StripSubdetector::TID) continue;
344  denominator+=128.*reader->getNumberOfApvsAndStripLength(det).first;
345  if(badStripsPerDetId.count(det)!=0) numerator+= badStripsPerDetId[det];
346  }
347 
348  delete reader;
349  return (numerator/denominator)*100.;
350 
351  } // payload
352  };
353 
354  /************************************************
355  time history histogram of bad components fraction (TEC)
356  *************************************************/
357 
358  class SiStripBadStripTECFractionByRun : public cond::payloadInspector::HistoryPlot<SiStripBadStrip,float> {
359  public:
360  SiStripBadStripTECFractionByRun() : cond::payloadInspector::HistoryPlot<SiStripBadStrip,float>( "SiStrip Endcaps Bad Strip fraction per run","TEC Bad Strip fraction [%]"){}
361  ~SiStripBadStripTECFractionByRun() override = default;
362 
363  float getFromPayload( SiStripBadStrip& payload ) override{
364 
365  edm::FileInPath fp_ = edm::FileInPath("CalibTracker/SiStripCommon/data/SiStripDetInfo.dat");
367 
368  std::vector<uint32_t> detid;
369  payload.getDetIds(detid);
370 
371  std::map<uint32_t,int> badStripsPerDetId;
372 
373  for (const auto & d : detid) {
374  SiStripBadStrip::Range range=payload.getRange(d);
375  int badStrips(0);
376  for( std::vector<unsigned int>::const_iterator badStrip = range.first;badStrip != range.second; ++badStrip ) {
377  badStrips+= payload.decode(*badStrip).range;
378  }
379  badStripsPerDetId[d] = badStrips;
380  } // loop over detIds
381 
382  float numerator(0.),denominator(0.);
383  std::vector<uint32_t> all_detids=reader->getAllDetIds();
384  for (const auto & det : all_detids) {
385  int subid = DetId(det).subdetId();
386  if(subid != StripSubdetector::TEC) continue;
387  denominator+=128.*reader->getNumberOfApvsAndStripLength(det).first;
388  if(badStripsPerDetId.count(det)!=0) numerator+= badStripsPerDetId[det];
389  }
390 
391  delete reader;
392  return (numerator/denominator)*100.;
393 
394  } // payload
395  };
396 
397  /************************************************
398  Plot BadStrip by region
399  *************************************************/
400 
401  class SiStripBadStripByRegion : public cond::payloadInspector::PlotImage<SiStripBadStrip> {
402  public:
403  SiStripBadStripByRegion() : cond::payloadInspector::PlotImage<SiStripBadStrip>( "SiStrip BadStrip By Region" ),
404  m_trackerTopo{StandaloneTrackerTopology::fromTrackerParametersXMLFile(edm::FileInPath("Geometry/TrackerCommonData/data/trackerParameters.xml").fullPath())}
405  {
406  setSingleIov( true );
407  }
408 
409  bool fill( const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs ) override{
410  auto iov = iovs.front();
411  std::shared_ptr<SiStripBadStrip> payload = fetchPayload( std::get<1>(iov) );
412 
413  std::vector<uint32_t> detid;
414  payload->getDetIds(detid);
415 
416  SiStripDetSummary summaryBadStrips{&m_trackerTopo};
417  int totalBadStrips =0;
418 
419  for (const auto & d : detid) {
420  SiStripBadStrip::Range range=payload->getRange(d);
421  int badStrips(0);
422  for( std::vector<unsigned int>::const_iterator badStrip = range.first;badStrip != range.second; ++badStrip ) {
423  badStrips+= payload->decode(*badStrip).range;
424  }
425  totalBadStrips+=badStrips;
426  summaryBadStrips.add(d,badStrips);
427  }
428  std::map<unsigned int, SiStripDetSummary::Values> mapBadStrips = summaryBadStrips.getCounts();
429 
430  //=========================
431 
432  TCanvas canvas("BadStrip Region summary","SiStripBadStrip region summary",1200,1000);
433  canvas.cd();
434  auto h_BadStrips = std::unique_ptr<TH1F>(new TH1F("BadStripsbyRegion","SiStrip Bad Strip summary by region;; n. bad strips",mapBadStrips.size(),0.,mapBadStrips.size()));
435  h_BadStrips->SetStats(false);
436 
437  canvas.SetBottomMargin(0.18);
438  canvas.SetLeftMargin(0.12);
439  canvas.SetRightMargin(0.05);
440  canvas.Modified();
441 
442  std::vector<int> boundaries;
443  unsigned int iBin=0;
444 
446  std::string currentDetector;
447 
448  for (const auto &element : mapBadStrips){
449  iBin++;
450  int countBadStrips = (element.second.mean);
451 
452  if(currentDetector.empty()) currentDetector="TIB";
453 
454  switch ((element.first)/1000)
455  {
456  case 1:
457  detector = "TIB";
458  break;
459  case 2:
460  detector = "TOB";
461  break;
462  case 3:
463  detector = "TEC";
464  break;
465  case 4:
466  detector = "TID";
467  break;
468  }
469 
470  h_BadStrips->SetBinContent(iBin,countBadStrips);
471  h_BadStrips->GetXaxis()->SetBinLabel(iBin,SiStripPI::regionType(element.first).second);
472  h_BadStrips->GetXaxis()->LabelsOption("v");
473 
474  if(detector!=currentDetector) {
475  boundaries.push_back(iBin);
476  currentDetector=detector;
477  }
478  }
479 
480  h_BadStrips->SetMarkerStyle(21);
481  h_BadStrips->SetMarkerSize(1);
482  h_BadStrips->SetLineColor(kBlue);
483  h_BadStrips->SetLineStyle(9);
484  h_BadStrips->SetMarkerColor(kBlue);
485  h_BadStrips->GetYaxis()->SetRangeUser(0.,h_BadStrips->GetMaximum()*1.30);
486  h_BadStrips->GetYaxis()->SetTitleOffset(1.7);
487  h_BadStrips->Draw("HISTsame");
488  h_BadStrips->Draw("TEXTsame");
489 
490  canvas.Update();
491  canvas.cd();
492 
493  TLine l[boundaries.size()];
494  unsigned int i=0;
495  for (const auto & line : boundaries){
496  l[i] = TLine(h_BadStrips->GetBinLowEdge(line),canvas.cd()->GetUymin(),h_BadStrips->GetBinLowEdge(line),canvas.cd()->GetUymax());
497  l[i].SetLineWidth(1);
498  l[i].SetLineStyle(9);
499  l[i].SetLineColor(2);
500  l[i].Draw("same");
501  i++;
502  }
503 
504  TLegend legend = TLegend(0.52,0.82,0.95,0.9);
505  legend.SetHeader((std::get<1>(iov)).c_str(),"C"); // option "C" allows to center the header
506  legend.AddEntry(h_BadStrips.get(),("IOV: "+std::to_string(std::get<0>(iov))+"| n. of bad strips:"+std::to_string(totalBadStrips)).c_str(),"PL");
507  legend.SetTextSize(0.025);
508  legend.Draw("same");
509 
510  std::string fileName(m_imageFileName);
511  canvas.SaveAs(fileName.c_str());
512 
513  return true;
514  }
515  private:
516  TrackerTopology m_trackerTopo;
517  };
518 
519 
520  /************************************************
521  Plot BadStrip by region comparison
522  *************************************************/
523 
524  class SiStripBadStripByRegionComparison : public cond::payloadInspector::PlotImage<SiStripBadStrip> {
525  public:
526  SiStripBadStripByRegionComparison() : cond::payloadInspector::PlotImage<SiStripBadStrip>( "SiStrip BadStrip By Region Comparison" ),
527  m_trackerTopo{StandaloneTrackerTopology::fromTrackerParametersXMLFile(edm::FileInPath("Geometry/TrackerCommonData/data/trackerParameters.xml").fullPath())}
528  {
529  setSingleIov( false );
530  }
531 
532  bool fill( const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs ) override{
533 
534  std::vector<std::tuple<cond::Time_t,cond::Hash> > sorted_iovs = iovs;
535 
536  // make absolute sure the IOVs are sortd by since
537  std::sort(begin(sorted_iovs), end(sorted_iovs), [](auto const &t1, auto const &t2) {
538  return std::get<0>(t1) < std::get<0>(t2);
539  });
540 
541  auto firstiov = sorted_iovs.front();
542  auto lastiov = sorted_iovs.back();
543 
544  std::shared_ptr<SiStripBadStrip> last_payload = fetchPayload( std::get<1>(lastiov) );
545  std::shared_ptr<SiStripBadStrip> first_payload = fetchPayload( std::get<1>(firstiov) );
546 
547  std::string lastIOVsince = std::to_string(std::get<0>(lastiov));
548  std::string firstIOVsince = std::to_string(std::get<0>(firstiov));
549 
550  // last payload
551  std::vector<uint32_t> detid;
552  last_payload->getDetIds(detid);
553 
554  SiStripDetSummary summaryLastBadStrips{&m_trackerTopo};
555  int totalLastBadStrips =0;
556 
557  for (const auto & d : detid) {
558  SiStripBadStrip::Range range=last_payload->getRange(d);
559  int badStrips(0);
560  for( std::vector<unsigned int>::const_iterator badStrip = range.first;badStrip != range.second; ++badStrip ) {
561  badStrips+=last_payload->decode(*badStrip).range;
562  }
563  totalLastBadStrips+=badStrips;
564  summaryLastBadStrips.add(d,badStrips);
565  }
566  std::map<unsigned int, SiStripDetSummary::Values> mapLastBadStrips = summaryLastBadStrips.getCounts();
567 
568  // first payload
569  // needs to be cleared to avoid bias using only detIds of last payload
570  detid.clear();
571  first_payload->getDetIds(detid);
572 
573  SiStripDetSummary summaryFirstBadStrips{&m_trackerTopo};
574  int totalFirstBadStrips =0;
575 
576  for (const auto & d : detid) {
577  SiStripBadStrip::Range range=first_payload->getRange(d);
578  int badStrips(0);
579  for( std::vector<unsigned int>::const_iterator badStrip = range.first;badStrip != range.second; ++badStrip ) {
580  badStrips+=first_payload->decode(*badStrip).range;
581  }
582  totalFirstBadStrips+=badStrips;
583  summaryFirstBadStrips.add(d,badStrips);
584  }
585  std::map<unsigned int, SiStripDetSummary::Values> mapFirstBadStrips = summaryFirstBadStrips.getCounts();
586 
587  //=========================
588 
589  TCanvas canvas("BadStrip Partion summary","SiStripBadStrip region summary",1200,1000);
590  canvas.cd();
591 
592  auto h_LastBadStrips = std::unique_ptr<TH1F>(new TH1F("BadStripsbyRegion1","SiStrip Bad Strip summary by region;; n. bad strips",mapLastBadStrips.size(),0.,mapLastBadStrips.size()));
593  h_LastBadStrips->SetStats(false);
594 
595  auto h_FirstBadStrips = std::unique_ptr<TH1F>(new TH1F("BadStripsbyRegion2","SiStrip Bad Strip summary by region;; n. bad strips",mapFirstBadStrips.size(),0.,mapFirstBadStrips.size()));
596  h_FirstBadStrips->SetStats(false);
597 
598  canvas.SetBottomMargin(0.18);
599  canvas.SetLeftMargin(0.12);
600  canvas.SetRightMargin(0.05);
601  canvas.Modified();
602 
603  std::vector<int> boundaries;
604  unsigned int iBin=0;
605 
607  std::string currentDetector;
608 
609  for (const auto &element : mapLastBadStrips){
610  iBin++;
611  int countBadStrips = (element.second.mean);
612 
613  if(currentDetector.empty()) currentDetector="TIB";
614 
615  switch ((element.first)/1000)
616  {
617  case 1:
618  detector = "TIB";
619  break;
620  case 2:
621  detector = "TOB";
622  break;
623  case 3:
624  detector = "TEC";
625  break;
626  case 4:
627  detector = "TID";
628  break;
629  }
630 
631  h_LastBadStrips->SetBinContent(iBin,countBadStrips);
632  h_LastBadStrips->GetXaxis()->SetBinLabel(iBin,SiStripPI::regionType(element.first).second);
633  h_LastBadStrips->GetXaxis()->LabelsOption("v");
634 
635  if(detector!=currentDetector) {
636  boundaries.push_back(iBin);
637  currentDetector=detector;
638  }
639  }
640 
641  // reset the count
642  iBin=0;
643 
644  for (const auto &element : mapFirstBadStrips){
645  iBin++;
646  int countBadStrips = (element.second.mean);
647 
648  h_FirstBadStrips->SetBinContent(iBin,countBadStrips);
649  h_FirstBadStrips->GetXaxis()->SetBinLabel(iBin,SiStripPI::regionType(element.first).second);
650  h_FirstBadStrips->GetXaxis()->LabelsOption("v");
651 
652  }
653 
654  auto extrema = SiStripPI::getExtrema(h_FirstBadStrips.get(),h_LastBadStrips.get());
655  h_LastBadStrips->GetYaxis()->SetRangeUser(extrema.first,extrema.second);
656 
657  h_LastBadStrips->SetMarkerStyle(21);
658  h_LastBadStrips->SetMarkerSize(1);
659  h_LastBadStrips->SetLineColor(kBlue);
660  h_LastBadStrips->SetFillColor(kBlue);
661  h_LastBadStrips->SetLineStyle(9);
662  h_LastBadStrips->SetMarkerColor(kBlue);
663  h_LastBadStrips->GetYaxis()->SetRangeUser(0.,h_LastBadStrips->GetMaximum()*1.30);
664  h_LastBadStrips->GetYaxis()->SetTitleOffset(1.7);
665 
666  h_LastBadStrips->SetBarWidth(0.45);
667  h_LastBadStrips->SetBarOffset(0.1);
668  h_LastBadStrips->Draw("bar2");
669  h_LastBadStrips->Draw("TEXTsame");
670 
671  h_FirstBadStrips->SetMarkerStyle(20);
672  h_FirstBadStrips->SetMarkerSize(1);
673  h_FirstBadStrips->SetFillColor(kRed);
674  h_FirstBadStrips->SetLineColor(kRed);
675  h_FirstBadStrips->SetLineStyle(1);
676  h_FirstBadStrips->SetMarkerColor(kRed);
677  h_FirstBadStrips->GetYaxis()->SetTitleOffset(1.7);
678 
679  h_FirstBadStrips->SetBarWidth(0.4);
680  h_FirstBadStrips->SetBarOffset(0.55);
681 
682  h_FirstBadStrips->Draw("bar2same");
683  h_FirstBadStrips->Draw("TEXT45same");
684 
685  canvas.Update();
686  canvas.cd();
687 
688  TLine l[boundaries.size()];
689  unsigned int i=0;
690  for (const auto & line : boundaries){
691  l[i] = TLine(h_LastBadStrips->GetBinLowEdge(line),canvas.cd()->GetUymin(),h_LastBadStrips->GetBinLowEdge(line),canvas.cd()->GetUymax());
692  l[i].SetLineWidth(1);
693  l[i].SetLineStyle(9);
694  l[i].SetLineColor(kMagenta);
695  l[i].Draw("same");
696  i++;
697  }
698 
699  TLegend legend = TLegend(0.52,0.82,0.95,0.9);
700  legend.SetHeader("Bad Components comparison","C"); // option "C" allows to center the header
701  legend.AddEntry(h_LastBadStrips.get(),("IOV: "+std::to_string(std::get<0>(lastiov))+"| n. of bad strips:"+std::to_string(totalLastBadStrips)).c_str(),"PL");
702  legend.AddEntry(h_FirstBadStrips.get(),("IOV: "+std::to_string(std::get<0>(firstiov))+"| n. of bad strips:"+std::to_string(totalFirstBadStrips)).c_str(),"PL");
703  legend.SetTextSize(0.025);
704  legend.Draw("same");
705 
706  std::string fileName(m_imageFileName);
707  canvas.SaveAs(fileName.c_str());
708 
709  return true;
710  }
711  private:
712  TrackerTopology m_trackerTopo;
713  };
714 
715  /************************************************
716  TrackerMap of SiStripBadStrip (bad strips fraction difference)
717  *************************************************/
718  class SiStripBadStripFractionComparisonTrackerMap : public cond::payloadInspector::PlotImage<SiStripBadStrip> {
719  public:
720  SiStripBadStripFractionComparisonTrackerMap() : cond::payloadInspector::PlotImage<SiStripBadStrip>( "Tracker Map of SiStrip bad strip fraction difference" ){
721  setSingleIov( false );
722  }
723 
724  bool fill( const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs ) override{
725 
726  std::vector<std::tuple<cond::Time_t,cond::Hash> > sorted_iovs = iovs;
727 
728  // make absolute sure the IOVs are sortd by since
729  std::sort(begin(sorted_iovs), end(sorted_iovs), [](auto const &t1, auto const &t2) {
730  return std::get<0>(t1) < std::get<0>(t2);
731  });
732 
733  auto firstiov = sorted_iovs.front();
734  auto lastiov = sorted_iovs.back();
735 
736  std::shared_ptr<SiStripBadStrip> last_payload = fetchPayload( std::get<1>(lastiov) );
737  std::shared_ptr<SiStripBadStrip> first_payload = fetchPayload( std::get<1>(firstiov) );
738 
739  std::string lastIOVsince = std::to_string(std::get<0>(lastiov));
740  std::string firstIOVsince = std::to_string(std::get<0>(firstiov));
741 
742  edm::FileInPath fp_ = edm::FileInPath("CalibTracker/SiStripCommon/data/SiStripDetInfo.dat");
744 
745  std::string titleMap = "#Delta fraction of bad Strips per module (IOV:"+lastIOVsince+" - IOV:"+firstIOVsince+")";
746 
747  std::unique_ptr<TrackerMap> tmap = std::unique_ptr<TrackerMap>(new TrackerMap("SiStripBadStrips"));
748  tmap->setTitle(titleMap);
749  tmap->setPalette(1);
750 
751  std::vector<uint32_t> detid1;
752  last_payload->getDetIds(detid1);
753 
754  std::map<uint32_t,float> FirstFractionPerDetId;
755  std::map<uint32_t,float> LastFractionPerDetId;
756 
757  for (const auto & d : detid1) {
758  SiStripBadStrip::Range range=last_payload->getRange(d);
759  for( std::vector<unsigned int>::const_iterator badStrip = range.first;badStrip != range.second; ++badStrip ) {
760  LastFractionPerDetId[d]+= last_payload->decode(*badStrip).range;
761  }
762  // normalize to the number of strips per module
763  LastFractionPerDetId[d]/=(128.*reader->getNumberOfApvsAndStripLength(d).first);
764  } // loop over detIds
765 
766  std::vector<uint32_t> detid2;
767  first_payload->getDetIds(detid2);
768 
769  //std::cout << "Size 2: " << detid1.size() << "| Size 1: "<< detid2.size() << std::endl;
770 
771  for (const auto & d : detid2) {
772  SiStripBadStrip::Range range=first_payload->getRange(d);
773  for( std::vector<unsigned int>::const_iterator badStrip = range.first;badStrip != range.second; ++badStrip ) {
774  FirstFractionPerDetId[d]+= first_payload->decode(*badStrip).range;
775  }
776  // normalize to the number of strips per module
777  FirstFractionPerDetId[d]/=(128.*reader->getNumberOfApvsAndStripLength(d).first);
778  } // loop over detIds
779 
780  std::vector<uint32_t> allDetIds = reader->getAllDetIds();
781 
782  int countLastButNotFirst(0);
783  int countFirstButNotLast(0);
784  int countBoth(0);
785 
786  for (const auto & d: allDetIds ){
787  if( LastFractionPerDetId.find(d) != LastFractionPerDetId.end() &&
788  FirstFractionPerDetId.find(d) == FirstFractionPerDetId.end() ) {
789 
790  tmap->fill(d,LastFractionPerDetId[d]);
791  countLastButNotFirst++;
792  }
793  else if ( LastFractionPerDetId.find(d) == LastFractionPerDetId.end() &&
794  FirstFractionPerDetId.find(d) != FirstFractionPerDetId.end() ) {
795 
796  tmap->fill(d,-FirstFractionPerDetId[d]);
797  countFirstButNotLast++;
798  }
799  else if ( LastFractionPerDetId.find(d) != LastFractionPerDetId.end() &&
800  FirstFractionPerDetId.find(d) != FirstFractionPerDetId.end() ) {
801 
802  float delta = (LastFractionPerDetId[d] - FirstFractionPerDetId[d]);
803  if (delta!=0.){
804  tmap->fill(d,delta);
805  }
806  countBoth++;
807  }
808  }
809 
810  /*
811  std::cout<<"In 2 but not in 1:"<< countLastButNotFirst << std::endl;
812  std::cout<<"In 1 but not in 2:"<< countFirstButNotLast << std::endl;
813  std::cout<<"In both:"<< countBoth << std::endl;
814  */
815 
816  //=========================
817 
818  std::string fileName(m_imageFileName);
819  tmap->save(true,0,0,fileName);
820 
821  delete reader;
822  return true;
823  }
824  };
825 
826  /************************************************
827  Plot BadStrip Quality analysis
828  *************************************************/
829 
830  class SiStripBadStripQualityAnalysis : public cond::payloadInspector::PlotImage<SiStripBadStrip> {
831  public:
832  SiStripBadStripQualityAnalysis() : cond::payloadInspector::PlotImage<SiStripBadStrip>( "SiStrip BadStrip Quality Analysis" ),
833  m_trackerTopo{StandaloneTrackerTopology::fromTrackerParametersXMLFile(edm::FileInPath("Geometry/TrackerCommonData/data/trackerParameters.xml").fullPath())}
834  {
835  setSingleIov( true );
836  }
837 
838  bool fill( const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs ) override{
839  auto iov = iovs.front();
840  std::shared_ptr<SiStripBadStrip> payload = fetchPayload( std::get<1>(iov) );
841 
842  SiStripQuality* siStripQuality_ = new SiStripQuality();
843  siStripQuality_->add(payload.get());
844  siStripQuality_->cleanUp();
845  siStripQuality_->fillBadComponents();
846 
847  // store global info
848 
849  //k: 0=BadModule, 1=BadFiber, 2=BadApv, 3=BadStrips
850  int NTkBadComponent[4] = {0};
851 
852  //legend: NBadComponent[i][j][k]= SubSystem i, layer/disk/wheel j, BadModule/Fiber/Apv k
853  // i: 0=TIB, 1=TID, 2=TOB, 3=TEC
854  // k: 0=BadModule, 1=BadFiber, 2=BadApv, 3=BadStrips
855  int NBadComponent[4][19][4] = {{{0}}};
856 
857  // call the filler
858  SiStripPI::fillBCArrays(siStripQuality_,NTkBadComponent,NBadComponent,m_trackerTopo);
859 
860  //&&&&&&&&&&&&&&&&&&
861  // printout
862  //&&&&&&&&&&&&&&&&&&
863 
864  std::stringstream ss;
865  ss.str("");
866  ss << "\n-----------------\nGlobal Info\n-----------------";
867  ss << "\nBadComponent \t Modules \tFibers \tApvs\tStrips\n----------------------------------------------------------------";
868  ss << "\nTracker:\t\t"<<NTkBadComponent[0]<<"\t"<<NTkBadComponent[1]<<"\t"<<NTkBadComponent[2]<<"\t"<<NTkBadComponent[3];
869  ss<< "\n";
870  ss << "\nTIB:\t\t\t"<<NBadComponent[0][0][0]<<"\t"<<NBadComponent[0][0][1]<<"\t"<<NBadComponent[0][0][2]<<"\t"<<NBadComponent[0][0][3];
871  ss << "\nTID:\t\t\t"<<NBadComponent[1][0][0]<<"\t"<<NBadComponent[1][0][1]<<"\t"<<NBadComponent[1][0][2]<<"\t"<<NBadComponent[1][0][3];
872  ss << "\nTOB:\t\t\t"<<NBadComponent[2][0][0]<<"\t"<<NBadComponent[2][0][1]<<"\t"<<NBadComponent[2][0][2]<<"\t"<<NBadComponent[2][0][3];
873  ss << "\nTEC:\t\t\t"<<NBadComponent[3][0][0]<<"\t"<<NBadComponent[3][0][1]<<"\t"<<NBadComponent[3][0][2]<<"\t"<<NBadComponent[3][0][3];
874  ss << "\n";
875 
876  for (int i=1;i<5;++i)
877  ss << "\nTIB Layer " << i << " :\t\t"<<NBadComponent[0][i][0]<<"\t"<<NBadComponent[0][i][1]<<"\t"<<NBadComponent[0][i][2]<<"\t"<<NBadComponent[0][i][3];
878  ss << "\n";
879  for (int i=1;i<4;++i)
880  ss << "\nTID+ Disk " << i << " :\t\t"<<NBadComponent[1][i][0]<<"\t"<<NBadComponent[1][i][1]<<"\t"<<NBadComponent[1][i][2]<<"\t"<<NBadComponent[1][i][3];
881  for (int i=4;i<7;++i)
882  ss << "\nTID- Disk " << i-3 << " :\t\t"<<NBadComponent[1][i][0]<<"\t"<<NBadComponent[1][i][1]<<"\t"<<NBadComponent[1][i][2]<<"\t"<<NBadComponent[1][i][3];
883  ss << "\n";
884  for (int i=1;i<7;++i)
885  ss << "\nTOB Layer " << i << " :\t\t"<<NBadComponent[2][i][0]<<"\t"<<NBadComponent[2][i][1]<<"\t"<<NBadComponent[2][i][2]<<"\t"<<NBadComponent[2][i][3];
886  ss << "\n";
887  for (int i=1;i<10;++i)
888  ss << "\nTEC+ Disk " << i << " :\t\t"<<NBadComponent[3][i][0]<<"\t"<<NBadComponent[3][i][1]<<"\t"<<NBadComponent[3][i][2]<<"\t"<<NBadComponent[3][i][3];
889  for (int i=10;i<19;++i)
890  ss << "\nTEC- Disk " << i-9 << " :\t\t"<<NBadComponent[3][i][0]<<"\t"<<NBadComponent[3][i][1]<<"\t"<<NBadComponent[3][i][2]<<"\t"<<NBadComponent[3][i][3];
891  ss<< "\n";
892 
893  edm::LogInfo("SiStripBadStrip_PayloadInspector") << ss.str() << std::endl;
894  //std::cout<< ss.str() << std::endl;
895 
896  auto masterTable = std::unique_ptr<TH2I>(new TH2I("table","",4,0.,4.,39,0.,39.));
897 
898  std::string labelsX[4]={"Bad Modules","Bad Fibers","Bad APVs","Bad Strips"};
899  std::string labelsY[40]={"Tracker","TIB","TID","TOB","TEC","TIB Layer 1","TIB Layer 2","TIB Layer 3","TIB Layer 4","TID+ Disk 1","TID+ Disk 2","TID+ Disk 3","TID- Disk 1","TID- Disk 2","TID- Disk 3","TOB Layer 1","TOB Layer 2","TOB Layer 3","TOB Layer 4","TOB Layer 5","TOB Layer 6","TEC+ Disk 1","TEC+ Disk 2","TEC+ Disk 3","TEC+ Disk 4","TEC+ Disk 5","TEC+ Disk 6","TEC+ Disk 7","TEC+ Disk 8","TEC+ Disk 9","TEC- Disk 1","TEC- Disk 2","TEC- Disk 3","TEC- Disk 4","TEC- Disk 5","TEC- Disk 6","TEC- Disk 7","TEC- Disk 8","TEC- Disk 9"};
900 
901  for(int iX=0;iX<=3;iX++){
902  masterTable->GetXaxis()->SetBinLabel(iX+1,labelsX[iX].c_str());
903  }
904 
905  for(int iY=39;iY>=1;iY--){
906  masterTable->GetYaxis()->SetBinLabel(iY,labelsY[39-iY].c_str());
907  }
908 
909  // 0 1 2 3
910  int layerBoundaries[4] = {4,6,6,18};
911  std::vector<int> boundaries;
912  boundaries.push_back(39);
913  boundaries.push_back(35);
914 
915  int cursor=0;
916  int layerIndex=0;
917  for(int iY=39;iY>=1;iY--){
918  for(int iX=0;iX<=3;iX++){
919  if(iY==39){
920  masterTable->SetBinContent(iX+1,iY,NTkBadComponent[iX]);
921  } else if (iY>=35){
922  masterTable->SetBinContent(iX+1,iY,NBadComponent[(39-iY)-1][0][iX]);
923  } else {
924  if(iX==0) layerIndex++;
925  //std::cout<<"iY:"<<iY << " cursor: " <<cursor << " layerIndex: " << layerIndex << " layer check: "<< layerBoundaries[cursor] <<std::endl;
926  masterTable->SetBinContent(iX+1,iY,NBadComponent[cursor][layerIndex][iX]);
927  }
928  }
929  if(layerIndex==layerBoundaries[cursor]){
930  // bring on the subdet counter and reset the layer count
931  cursor++;
932  layerIndex=0;
933  boundaries.push_back(iY);
934  }
935  }
936 
937  TCanvas canv("canv","canv",800,800);
938  canv.cd();
939 
940  canv.SetTopMargin(0.05);
941  canv.SetBottomMargin(0.07);
942  canv.SetLeftMargin(0.18);
943  canv.SetRightMargin(0.05);
944 
945  masterTable->GetYaxis()->SetLabelSize(0.04);
946  masterTable->GetXaxis()->SetLabelSize(0.05);
947 
948  masterTable->SetStats(false);
949  canv.SetGrid();
950 
951  masterTable->Draw("text");
952 
953  canv.Update();
954  canv.cd();
955 
956  TLine l[boundaries.size()];
957  unsigned int i=0;
958  for (const auto & line : boundaries){
959  l[i] = TLine(canv.cd()->GetUxmin(),masterTable->GetYaxis()->GetBinLowEdge(line),canv.cd()->GetUxmax(),masterTable->GetYaxis()->GetBinLowEdge(line));
960  l[i].SetLineWidth(2);
961  l[i].SetLineStyle(9);
962  l[i].SetLineColor(kMagenta);
963  l[i].Draw("same");
964  i++;
965  }
966 
967  canv.cd();
968  TLatex title;
969  title.SetTextSize(0.027);
970  title.SetTextColor(kBlue);
971  title.DrawLatexNDC(0.12,0.97,("IOV: "+std::to_string(std::get<0>(iov))+"| "+std::get<1>(iov)).c_str());
972  std::string fileName(m_imageFileName);
973  canv.SaveAs(fileName.c_str());
974 
975  delete siStripQuality_;
976  return true;
977  }
978  private:
979  TrackerTopology m_trackerTopo;
980  };
981 
982  /************************************************
983  Plot BadStrip Quality Comparison
984  *************************************************/
985 
986  class SiStripBadStripQualityComparison : public cond::payloadInspector::PlotImage<SiStripBadStrip> {
987  public:
988  SiStripBadStripQualityComparison() : cond::payloadInspector::PlotImage<SiStripBadStrip>( "SiStrip BadStrip Quality Comparison Analysis" ),
989  m_trackerTopo{StandaloneTrackerTopology::fromTrackerParametersXMLFile(edm::FileInPath("Geometry/TrackerCommonData/data/trackerParameters.xml").fullPath())}
990  {
991  setSingleIov( false );
992  }
993 
994  bool fill( const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs ) override{
995 
996  //SiStripPI::setPaletteStyle(SiStripPI::BLUERED);
997  gStyle->SetPalette(kTemperatureMap);
998 
999  std::vector<std::tuple<cond::Time_t,cond::Hash> > sorted_iovs = iovs;
1000 
1001  // make absolute sure the IOVs are sortd by since
1002  std::sort(begin(sorted_iovs), end(sorted_iovs), [](auto const &t1, auto const &t2) {
1003  return std::get<0>(t1) < std::get<0>(t2);
1004  });
1005 
1006  auto firstiov = sorted_iovs.front();
1007  auto lastiov = sorted_iovs.back();
1008 
1009  std::shared_ptr<SiStripBadStrip> last_payload = fetchPayload( std::get<1>(lastiov) );
1010  std::shared_ptr<SiStripBadStrip> first_payload = fetchPayload( std::get<1>(firstiov) );
1011 
1012  std::string lastIOVsince = std::to_string(std::get<0>(lastiov));
1013  std::string firstIOVsince = std::to_string(std::get<0>(firstiov));
1014 
1015  // store global info
1016 
1017  //k: 0=BadModule, 1=BadFiber, 2=BadApv, 3=BadStrips
1018  int f_NTkBadComponent[4] = {0};
1019  int l_NTkBadComponent[4] = {0};
1020 
1021  // for the total
1022  int tot_NTkComponents[4] = {0};
1023 
1024  //legend: NBadComponent[i][j][k]= SubSystem i, layer/disk/wheel j, BadModule/Fiber/Apv k
1025  // i: 0=TIB, 1=TID, 2=TOB, 3=TEC
1026  // k: 0=BadModule, 1=BadFiber, 2=BadApv, 3=BadStrips
1027  int f_NBadComponent[4][19][4] = {{{0}}};
1028  int l_NBadComponent[4][19][4] = {{{0}}};
1029 
1030  // for the total
1031  int totNComponents[4][19][4] = {{{0}}};
1032 
1033  SiStripQuality* f_siStripQuality_ = new SiStripQuality();
1034  f_siStripQuality_->add(first_payload.get());
1035  f_siStripQuality_->cleanUp();
1036  f_siStripQuality_->fillBadComponents();
1037 
1038  // call the filler
1039  SiStripPI::fillBCArrays(f_siStripQuality_,f_NTkBadComponent,f_NBadComponent,m_trackerTopo);
1040 
1041  SiStripQuality* l_siStripQuality_ = new SiStripQuality();
1042  l_siStripQuality_->add(last_payload.get());
1043  l_siStripQuality_->cleanUp();
1044  l_siStripQuality_->fillBadComponents();
1045 
1046  // call the filler
1047  SiStripPI::fillBCArrays(l_siStripQuality_,l_NTkBadComponent,l_NBadComponent,m_trackerTopo);
1048 
1049  // fill the total number of components
1050  SiStripPI::fillTotalComponents(tot_NTkComponents, totNComponents,m_trackerTopo);
1051 
1052  // debug
1053  //SiStripPI::printBCDebug(f_NTkBadComponent,f_NBadComponent);
1054  //SiStripPI::printBCDebug(l_NTkBadComponent,l_NBadComponent);
1055 
1056  //SiStripPI::printBCDebug(tot_NTkComponents,totNComponents);
1057 
1058  // declare histograms
1059  auto masterTable = std::unique_ptr<TH2F>(new TH2F("table","",4,0.,4.,39,0.,39.));
1060  auto masterTableColor = std::unique_ptr<TH2F>(new TH2F("colortable","",4,0.,4.,39,0.,39.));
1061 
1062  std::string labelsX[4]={"Bad Modules","Bad Fibers","Bad APVs","Bad Strips"};
1063  std::string labelsY[40]={"Tracker","TIB","TID","TOB","TEC","TIB Layer 1","TIB Layer 2","TIB Layer 3","TIB Layer 4","TID+ Disk 1","TID+ Disk 2","TID+ Disk 3","TID- Disk 1","TID- Disk 2","TID- Disk 3","TOB Layer 1","TOB Layer 2","TOB Layer 3","TOB Layer 4","TOB Layer 5","TOB Layer 6","TEC+ Disk 1","TEC+ Disk 2","TEC+ Disk 3","TEC+ Disk 4","TEC+ Disk 5","TEC+ Disk 6","TEC+ Disk 7","TEC+ Disk 8","TEC+ Disk 9","TEC- Disk 1","TEC- Disk 2","TEC- Disk 3","TEC- Disk 4","TEC- Disk 5","TEC- Disk 6","TEC- Disk 7","TEC- Disk 8","TEC- Disk 9"};
1064 
1065  for(int iX=0;iX<=3;iX++){
1066  masterTable->GetXaxis()->SetBinLabel(iX+1,labelsX[iX].c_str());
1067  masterTableColor->GetXaxis()->SetBinLabel(iX+1,labelsX[iX].c_str());
1068  }
1069 
1070  for(int iY=39;iY>=1;iY--){
1071  masterTable->GetYaxis()->SetBinLabel(iY,labelsY[39-iY].c_str());
1072  masterTableColor->GetYaxis()->SetBinLabel(iY,labelsY[39-iY].c_str());
1073  }
1074 
1075  // 0 1 2 3
1076  int layerBoundaries[4] = {4,6,6,18};
1077  std::vector<int> boundaries;
1078  boundaries.push_back(39);
1079  boundaries.push_back(35);
1080 
1081  int cursor=0;
1082  int layerIndex=0;
1083  for(int iY=39;iY>=1;iY--){
1084  for(int iX=0;iX<=3;iX++){
1085  if(iY==39){
1086  masterTable->SetBinContent(iX+1,iY,l_NTkBadComponent[iX]-f_NTkBadComponent[iX]);
1087  masterTableColor->SetBinContent(iX+1,iY,100*float(l_NTkBadComponent[iX]-f_NTkBadComponent[iX])/tot_NTkComponents[iX]);
1088  //std::cout<< (l_NTkBadComponent[iX]-f_NTkBadComponent[iX]) << " " << tot_NTkComponents[iX] << " " << float(l_NTkBadComponent[iX]-f_NTkBadComponent[iX])/tot_NTkComponents[iX] << std::endl;
1089  } else if (iY>=35){
1090  masterTable->SetBinContent(iX+1,iY,(l_NBadComponent[(39-iY)-1][0][iX]-f_NBadComponent[(39-iY)-1][0][iX]));
1091  masterTableColor->SetBinContent(iX+1,iY,100*float(l_NBadComponent[(39-iY)-1][0][iX]-f_NBadComponent[(39-iY)-1][0][iX])/totNComponents[(39-iY)-1][0][iX]);
1092  } else {
1093  if(iX==0) layerIndex++;
1094  //std::cout<<"iY:"<<iY << " cursor: " <<cursor << " layerIndex: " << layerIndex << " layer check: "<< layerBoundaries[cursor] <<std::endl;
1095  masterTable->SetBinContent(iX+1,iY,(l_NBadComponent[cursor][layerIndex][iX]-f_NBadComponent[cursor][layerIndex][iX]));
1096  masterTableColor->SetBinContent(iX+1,iY,100*float(l_NBadComponent[cursor][layerIndex][iX]-f_NBadComponent[cursor][layerIndex][iX])/totNComponents[cursor][layerIndex][iX]);
1097  }
1098  }
1099  if(layerIndex==layerBoundaries[cursor]){
1100  // bring on the subdet counter and reset the layer count
1101  cursor++;
1102  layerIndex=0;
1103  boundaries.push_back(iY);
1104  }
1105  }
1106 
1107  TCanvas canv("canv","canv",1000,800);
1108  canv.cd();
1109 
1110  canv.SetTopMargin(0.05);
1111  canv.SetBottomMargin(0.07);
1112  canv.SetLeftMargin(0.13);
1113  canv.SetRightMargin(0.16);
1114 
1115  masterTable->SetStats(false);
1116  masterTableColor->SetStats(false);
1117  canv.SetGrid();
1118 
1119  masterTable->SetMarkerColor(kBlack);
1120  masterTable->SetMarkerSize(1.5);
1121 
1122  float extremum = std::abs(masterTableColor->GetMaximum()) > std::abs(masterTableColor->GetMinimum()) ? std::abs(masterTableColor->GetMaximum()) : std::abs(masterTableColor->GetMinimum());
1123  //masterTableColor->Draw("text");
1124  masterTableColor->GetZaxis()->SetRangeUser(-extremum,extremum);
1125  masterTableColor->GetZaxis()->SetTitle("percent change [%]");
1126  masterTableColor->GetZaxis()->CenterTitle(true);
1127  masterTableColor->GetZaxis()->SetTitleSize(0.05);
1128 
1129  masterTableColor->GetYaxis()->SetLabelSize(0.04);
1130  masterTableColor->GetXaxis()->SetLabelSize(0.06);
1131 
1132  masterTable->GetYaxis()->SetLabelSize(0.04);
1133  masterTable->GetXaxis()->SetLabelSize(0.06);
1134 
1135  masterTableColor->Draw("COLZ");
1136  masterTable->Draw("textsame");
1137 
1138  canv.Update();
1139  canv.cd();
1140 
1141  TLine l[boundaries.size()];
1142  unsigned int i=0;
1143  for (const auto & line : boundaries){
1144  l[i] = TLine(canv.cd()->GetUxmin(),masterTable->GetYaxis()->GetBinLowEdge(line),canv.cd()->GetUxmax(),masterTable->GetYaxis()->GetBinLowEdge(line));
1145  l[i].SetLineWidth(2);
1146  l[i].SetLineStyle(9);
1147  l[i].SetLineColor(kMagenta);
1148  l[i].Draw("same");
1149  i++;
1150  }
1151 
1152  canv.cd();
1153  TLatex title;
1154  title.SetTextSize(0.045);
1155  title.SetTextColor(kBlue);
1156  title.DrawLatexNDC(0.33,0.96,("#DeltaIOV: "+std::to_string(std::get<0>(lastiov))+" - "+std::to_string(std::get<0>(firstiov))).c_str());
1157  std::string fileName(m_imageFileName);
1158  canv.SaveAs(fileName.c_str());
1159 
1160  delete f_siStripQuality_;
1161  delete l_siStripQuality_;
1162 
1163  return true;
1164  }
1165  private:
1166  TrackerTopology m_trackerTopo;
1167  };
1168 
1169 } // close namespace
1170 
1171 // Register the classes as boost python plugin
1173  PAYLOAD_INSPECTOR_CLASS(SiStripBadStripTest);
1174  PAYLOAD_INSPECTOR_CLASS(SiStripBadModuleTrackerMap);
1175  PAYLOAD_INSPECTOR_CLASS(SiStripBadStripFractionTrackerMap);
1176  PAYLOAD_INSPECTOR_CLASS(SiStripBadStripFractionByRun);
1177  PAYLOAD_INSPECTOR_CLASS(SiStripBadStripTIBFractionByRun);
1178  PAYLOAD_INSPECTOR_CLASS(SiStripBadStripTOBFractionByRun);
1179  PAYLOAD_INSPECTOR_CLASS(SiStripBadStripTIDFractionByRun);
1180  PAYLOAD_INSPECTOR_CLASS(SiStripBadStripTECFractionByRun);
1181  PAYLOAD_INSPECTOR_CLASS(SiStripBadStripByRegion);
1182  PAYLOAD_INSPECTOR_CLASS(SiStripBadStripByRegionComparison);
1183  PAYLOAD_INSPECTOR_CLASS(SiStripBadStripFractionComparisonTrackerMap);
1184  PAYLOAD_INSPECTOR_CLASS(SiStripBadStripQualityAnalysis);
1185  PAYLOAD_INSPECTOR_CLASS(SiStripBadStripQualityComparison);
1186 }
unsigned short range
dbl * delta
Definition: mlp_gen.cc:36
bool cleanUp(bool force=false)
void getDetIds(std::vector< uint32_t > &DetIds_) const
void add(const uint32_t &, const SiStripBadStrip::Range &)
const std::pair< unsigned short, double > getNumberOfApvsAndStripLength(uint32_t detId) const
void fillBCArrays(const SiStripQuality *siStripQuality_, int NTkBadComponent[4], int NBadComponent[4][19][4], const TrackerTopology m_trackerTopo)
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
const std::vector< uint32_t > & getAllDetIds() const
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:41
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::pair< float, float > getExtrema(TH1 *h1, TH1 *h2)
#define end
Definition: vmac.h:39
void fillWithValue(float value, float weight=1)
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)
void fillBadComponents()
std::pair< int, const char * > regionType(int index)
Definition: DetId.h:18
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)
void fillTotalComponents(int NTkComponents[4], int NComponents[4][19][4], const TrackerTopology m_trackerTopo)
Definition: plugin.cc:24
#define begin
Definition: vmac.h:32
const Range getRange(const uint32_t detID) const
std::pair< ContainerIterator, ContainerIterator > Range
bool fill(const std::vector< std::tuple< cond::Time_t, cond::Hash > > &iovs) override
TrackerTopology fromTrackerParametersXMLFile(const std::string &xmlFileName)
def canvas(sub, attr)
Definition: svgfig.py:482
std::string fullPath() const
Definition: FileInPath.cc:163
data decode(const unsigned int &value) const