CMS 3D CMS Logo

SiStripPedestals_PayloadInspector.cc
Go to the documentation of this file.
1 
12 
13 // the data format of the condition to be inspected
19 
20 // needed for the tracker map
22 
23 // auxilliary functions
26 
29 
30 #include <memory>
31 #include <sstream>
32 #include <iostream>
33 #include <iomanip>
34 
35 // include ROOT
36 #include "TH2F.h"
37 #include "TLegend.h"
38 #include "TCanvas.h"
39 #include "TLine.h"
40 #include "TStyle.h"
41 #include "TLatex.h"
42 #include "TPave.h"
43 #include "TGaxis.h"
44 #include "TPaveStats.h"
45 
46 namespace {
47 
48  /************************************************
49  test class
50  *************************************************/
51 
52  class SiStripPedestalsTest : public cond::payloadInspector::Histogram1D<SiStripPedestals> {
53 
54  public:
55  SiStripPedestalsTest() : cond::payloadInspector::Histogram1D<SiStripPedestals>("SiStrip Pedestals test",
56  "SiStrip Pedestals test", 10,0.0,10.0),
57  m_trackerTopo{StandaloneTrackerTopology::fromTrackerParametersXMLFile(edm::FileInPath("Geometry/TrackerCommonData/data/trackerParameters.xml").fullPath())}
58  {
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<SiStripPedestals> payload = Base::fetchPayload( std::get<1>(iov) );
65  if( payload.get() ){
66 
67  fillWithValue(1.);
68 
69  std::stringstream ss;
70  ss << "Summary of strips pedestals:" << std::endl;
71 
72  //payload->printDebug(ss);
73  payload->printSummary(ss,&m_trackerTopo);
74 
75  std::vector<uint32_t> detid;
76  payload->getDetIds(detid);
77 
78  // for (const auto & d : detid) {
79  // int nstrip=0;
80  // SiStripPedestals::Range range=payload->getRange(d);
81  // for( int it=0; it < (range.second-range.first)*8/10; ++it ){
82  // auto ped = payload->getPed(it,range);
83  // nstrip++;
84  // ss << "DetId="<< d << " Strip=" << nstrip <<": "<< ped << std::endl;
85  // } // end of loop on strips
86  // } // end of loop on detIds
87 
88  std::cout<<ss.str()<<std::endl;
89 
90  }// payload
91  }// iovs
92  return true;
93  }// fill
94  private:
95  TrackerTopology m_trackerTopo;
96  };
97 
98  /************************************************
99  1d histogram of SiStripPedestals of 1 IOV
100  *************************************************/
101 
102  // inherit from one of the predefined plot class: Histogram1D
103  class SiStripPedestalsValue : public cond::payloadInspector::Histogram1D<SiStripPedestals> {
104 
105  public:
106  SiStripPedestalsValue() : cond::payloadInspector::Histogram1D<SiStripPedestals>("SiStrip Pedestals values",
107  "SiStrip Pedestals values", 300,0.0,300.0){
108  Base::setSingleIov( true );
109  }
110 
111  bool fill( const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs ) override{
112  for ( auto const & iov: iovs) {
113  std::shared_ptr<SiStripPedestals> payload = Base::fetchPayload( std::get<1>(iov) );
114  if( payload.get() ){
115 
116  std::vector<uint32_t> detid;
117  payload->getDetIds(detid);
118 
119  for (const auto & d : detid) {
120  SiStripPedestals::Range range=payload->getRange(d);
121  for( int it=0; it < (range.second-range.first)*8/10; ++it ){
122  auto ped = payload->getPed(it,range);
123  //to be used to fill the histogram
124  fillWithValue(ped);
125  }// loop over APVs
126  } // loop over detIds
127  }// payload
128  }// iovs
129  return true;
130  }// fill
131  };
132 
133  /************************************************
134  templated 1d histogram of SiStripPedestals of 1 IOV
135  *************************************************/
136 
137  // inherit from one of the predefined plot class: PlotImage
138  template<SiStripPI::OpMode op_mode_> class SiStripPedestalDistribution : public cond::payloadInspector::PlotImage<SiStripPedestals> {
139 
140  public:
141  SiStripPedestalDistribution() : cond::payloadInspector::PlotImage<SiStripPedestals>("SiStrip Pedestal values"){
142  setSingleIov( true );
143  }
144 
145  bool fill( const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs ) override{
146  auto iov = iovs.front();
147 
148  TGaxis::SetMaxDigits(3);
149  gStyle->SetOptStat("emr");
150 
151  std::shared_ptr<SiStripPedestals> payload = fetchPayload( std::get<1>(iov) );
152 
153  auto mon1D = std::unique_ptr<SiStripPI::Monitor1D>(new SiStripPI::Monitor1D(op_mode_,
154  "Pedestal",
155  Form("#LT Pedestal #GT per %s for IOV [%s];#LTStrip Pedestal per %s#GT [ADC counts];n. %ss",
156  opType(op_mode_).c_str(),std::to_string(std::get<0>(iov)).c_str(),opType(op_mode_).c_str(),opType(op_mode_).c_str())
157  ,300,0.,300.0));
158 
159  unsigned int prev_det=0, prev_apv=0;
160  SiStripPI::Entry epedestal;
161 
162  std::vector<uint32_t> detids;
163  payload->getDetIds(detids);
164 
165  // loop on payload
166  for (const auto & d : detids) {
167  SiStripPedestals::Range range=payload->getRange(d);
168 
169  unsigned int istrip=0;
170 
171  for( int it=0; it < (range.second-range.first)*8/10; ++it ){
172  auto pedestal = payload->getPed(it,range);
173  bool flush = false;
174  switch(op_mode_) {
175  case (SiStripPI::APV_BASED):
176  flush = (prev_det != 0 && prev_apv != istrip/128);
177  break;
179  flush = (prev_det != 0 && prev_det != d);
180  break;
181  case (SiStripPI::STRIP_BASED):
182  flush = (istrip != 0);
183  break;
184  }
185 
186  if(flush){
187  mon1D->Fill(prev_apv,prev_det,epedestal.mean());
188  epedestal.reset();
189  }
190 
191  epedestal.add(std::min<float>(pedestal, 300.));
192  prev_apv = istrip/128;
193  istrip++;
194  }
195  prev_det = d;
196  }
197 
198  //=========================
199  TCanvas canvas("Partion summary","partition summary",1200,1000);
200  canvas.cd();
201  canvas.SetBottomMargin(0.11);
202  canvas.SetTopMargin(0.07);
203  canvas.SetLeftMargin(0.13);
204  canvas.SetRightMargin(0.05);
205  canvas.Modified();
206 
207  auto hist = mon1D->getHist();
209  hist.SetStats(kTRUE);
210  hist.SetFillColorAlpha(kRed,0.35);
211  hist.Draw();
212 
213  canvas.Update();
214 
215  TPaveStats *st = (TPaveStats*)hist.GetListOfFunctions()->FindObject("stats");
216  st->SetLineColor(kRed);
217  st->SetTextColor(kRed);
218  st->SetX1NDC(.75); st->SetX2NDC(.95);
219  st->SetY1NDC(.83); st->SetY2NDC(.93);
220 
221  TLegend legend = TLegend(0.13,0.83,0.43,0.93);
222  legend.SetHeader(Form("SiStrip Pedestal values per %s",opType(op_mode_).c_str()),"C"); // option "C" allows to center the header
223  legend.AddEntry(&hist,("IOV: "+std::to_string(std::get<0>(iov))).c_str(),"F");
224  legend.SetTextSize(0.025);
225  legend.Draw("same");
226 
227  std::string fileName(m_imageFileName);
228  canvas.SaveAs(fileName.c_str());
229 
230  return true;
231 
232  }
233 
235  std::string types[3] = {"Strip","APV","Module"};
236  return types[mode];
237  }
238 
239  };
240 
241  typedef SiStripPedestalDistribution<SiStripPI::STRIP_BASED> SiStripPedestalValuePerStrip;
242  typedef SiStripPedestalDistribution<SiStripPI::APV_BASED> SiStripPedestalValuePerAPV;
243  typedef SiStripPedestalDistribution<SiStripPI::MODULE_BASED> SiStripPedestalValuePerModule;
244 
245  /************************************************
246  template 1d histogram comparison of SiStripPedestals of 1 IOV
247  *************************************************/
248 
249  // inherit from one of the predefined plot class: PlotImage
250  template<SiStripPI::OpMode op_mode_> class SiStripPedestalDistributionComparison : public cond::payloadInspector::PlotImage<SiStripPedestals> {
251 
252  public:
253  SiStripPedestalDistributionComparison() : cond::payloadInspector::PlotImage<SiStripPedestals>("SiStrip Pedestal values comparison"){
254  setSingleIov( false );
255  }
256 
257  bool fill( const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs ) override{
258 
259  std::vector<std::tuple<cond::Time_t,cond::Hash> > sorted_iovs = iovs;
260 
261  // make absolute sure the IOVs are sortd by since
262  std::sort(begin(sorted_iovs), end(sorted_iovs), [](auto const &t1, auto const &t2) {
263  return std::get<0>(t1) < std::get<0>(t2);
264  });
265 
266  auto firstiov = sorted_iovs.front();
267  auto lastiov = sorted_iovs.back();
268 
269  std::shared_ptr<SiStripPedestals> f_payload = fetchPayload( std::get<1>(firstiov) );
270  std::shared_ptr<SiStripPedestals> l_payload = fetchPayload( std::get<1>(lastiov) );
271 
272  auto f_mon = std::unique_ptr<SiStripPI::Monitor1D>(new SiStripPI::Monitor1D(op_mode_,
273  "f_Pedestal",
274  Form("#LT Strip Pedestal #GT per %s for IOV [%s,%s];#LTStrip Pedestal per %s#GT [ADC counts];n. %ss",
275  opType(op_mode_).c_str(),std::to_string(std::get<0>(firstiov)).c_str(),std::to_string(std::get<0>(lastiov)).c_str(),opType(op_mode_).c_str(),opType(op_mode_).c_str())
276  ,300,0.,300.));
277 
278  auto l_mon = std::unique_ptr<SiStripPI::Monitor1D>(new SiStripPI::Monitor1D(op_mode_,
279  "l_Pedestal",
280  Form("#LT Strip Pedestal #GT per %s for IOV [%s,%s];#LTStrip Pedestal per %s#GT [ADC counts];n. %ss",
281  opType(op_mode_).c_str(),std::to_string(std::get<0>(lastiov)).c_str(),std::to_string(std::get<0>(lastiov)).c_str(),opType(op_mode_).c_str(),opType(op_mode_).c_str())
282  ,300,0.,300.));
283 
284  unsigned int prev_det=0, prev_apv=0;
285  SiStripPI::Entry epedestal;
286 
287  std::vector<uint32_t> f_detid;
288  f_payload->getDetIds(f_detid);
289 
290  // loop on first payload
291  for (const auto & d : f_detid) {
292  SiStripPedestals::Range range=f_payload->getRange(d);
293 
294  unsigned int istrip=0;
295  for( int it=0; it < (range.second-range.first)*8/10; ++it ){
296  float pedestal = f_payload->getPed(it,range);
297  //to be used to fill the histogram
298 
299  bool flush = false;
300  switch(op_mode_) {
301  case (SiStripPI::APV_BASED):
302  flush = (prev_det != 0 && prev_apv != istrip/128);
303  break;
305  flush = (prev_det != 0 && prev_det != d);
306  break;
307  case (SiStripPI::STRIP_BASED):
308  flush = (istrip != 0);
309  break;
310  }
311 
312  if(flush){
313  f_mon->Fill(prev_apv,prev_det,epedestal.mean());
314  epedestal.reset();
315  }
316  epedestal.add(std::min<float>(pedestal, 300.));
317  prev_apv = istrip/128;
318  istrip++;
319  }
320  prev_det = d;
321  }
322 
323  prev_det=0, prev_apv=0;
324  epedestal.reset();
325 
326  std::vector<uint32_t> l_detid;
327  l_payload->getDetIds(l_detid);
328 
329  // loop on first payload
330  for (const auto & d : l_detid) {
331  SiStripPedestals::Range range=l_payload->getRange(d);
332 
333  unsigned int istrip=0;
334  for( int it=0; it < (range.second-range.first)*8/10; ++it ){
335  float pedestal = l_payload->getPed(it,range);
336 
337  bool flush = false;
338  switch(op_mode_) {
339  case (SiStripPI::APV_BASED):
340  flush = (prev_det != 0 && prev_apv != istrip/128);
341  break;
343  flush = (prev_det != 0 && prev_det != d);
344  break;
345  case (SiStripPI::STRIP_BASED):
346  flush = (istrip != 0);
347  break;
348  }
349 
350  if(flush){
351  l_mon->Fill(prev_apv,prev_det,epedestal.mean());
352  epedestal.reset();
353  }
354 
355  epedestal.add(std::min<float>(pedestal, 300.));
356  prev_apv = istrip/128;
357  istrip++;
358  }
359  prev_det = d;
360  }
361 
362  auto h_first = f_mon->getHist();
363  h_first.SetStats(kFALSE);
364  auto h_last = l_mon->getHist();
365  h_last.SetStats(kFALSE);
366 
369 
370  h_first.GetYaxis()->CenterTitle(true);
371  h_last.GetYaxis()->CenterTitle(true);
372 
373  h_first.GetXaxis()->CenterTitle(true);
374  h_last.GetXaxis()->CenterTitle(true);
375 
376  h_first.SetLineWidth(2);
377  h_last.SetLineWidth(2);
378 
379  h_first.SetLineColor(kBlack);
380  h_last.SetLineColor(kBlue);
381 
382  //=========================
383  TCanvas canvas("Partion summary","partition summary",1200,1000);
384  canvas.cd();
385  canvas.SetBottomMargin(0.11);
386  canvas.SetLeftMargin(0.13);
387  canvas.SetRightMargin(0.05);
388  canvas.Modified();
389 
390  float theMax = (h_first.GetMaximum() > h_last.GetMaximum()) ? h_first.GetMaximum() : h_last.GetMaximum();
391 
392  h_first.SetMaximum(theMax*1.30);
393  h_last.SetMaximum(theMax*1.30);
394 
395  h_first.Draw();
396  h_last.Draw("same");
397 
398  TLegend legend = TLegend(0.52,0.82,0.95,0.9);
399  legend.SetHeader("SiStrip Pedestal comparison","C"); // option "C" allows to center the header
400  legend.AddEntry(&h_first,("IOV: "+std::to_string(std::get<0>(firstiov))).c_str(),"F");
401  legend.AddEntry(&h_last, ("IOV: "+std::to_string(std::get<0>(lastiov))).c_str(),"F");
402  legend.SetTextSize(0.025);
403  legend.Draw("same");
404 
405  std::string fileName(m_imageFileName);
406  canvas.SaveAs(fileName.c_str());
407 
408  return true;
409 
410  }
411 
413  std::string types[3] = {"Strip","APV","Module"};
414  return types[mode];
415  }
416 
417  };
418 
419  typedef SiStripPedestalDistributionComparison<SiStripPI::STRIP_BASED> SiStripPedestalValueComparisonPerStrip;
420  typedef SiStripPedestalDistributionComparison<SiStripPI::APV_BASED> SiStripPedestalValueComparisonPerAPV;
421  typedef SiStripPedestalDistributionComparison<SiStripPI::MODULE_BASED> SiStripPedestalValueComparisonPerModule;
422 
423 
424  /************************************************
425  1d histogram of fraction of Zero SiStripPedestals of 1 IOV
426  *************************************************/
427 
428  // inherit from one of the predefined plot class: Histogram1D
429  class SiStripZeroPedestalsFraction_TrackerMap : public cond::payloadInspector::PlotImage<SiStripPedestals> {
430 
431  public:
432  SiStripZeroPedestalsFraction_TrackerMap() : cond::payloadInspector::PlotImage<SiStripPedestals> ( "Tracker Map of Zero SiStripPedestals fraction per module" )
433  {
434  setSingleIov( true );
435  }
436 
437  bool fill( const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs ) override {
438  auto iov = iovs.front();
439  std::shared_ptr<SiStripPedestals> payload = fetchPayload( std::get<1>(iov) );
440 
441  edm::FileInPath fp_ = edm::FileInPath("CalibTracker/SiStripCommon/data/SiStripDetInfo.dat");
443 
444  std::string titleMap = "Tracker Map of Zero SiStrip Pedestals fraction per module (payload : "+std::get<1>(iov)+")";
445 
446  std::unique_ptr<TrackerMap> tmap = std::unique_ptr<TrackerMap>(new TrackerMap("SiStripPedestals"));
447  tmap->setTitle(titleMap);
448  tmap->setPalette(1);
449 
450  std::vector<uint32_t> detid;
451  payload->getDetIds(detid);
452 
453  std::map<uint32_t,int> zeropeds_per_detid;
454 
455  for (const auto & d : detid) {
456  int nstrips=0;
457  SiStripPedestals::Range range = payload->getRange(d);
458  for( int it=0; it < (range.second-range.first)*8/10; ++it ){
459  nstrips++;
460  auto ped = payload->getPed(it,range);
461  if(ped==0.) {
462  zeropeds_per_detid[d]+=1;
463  }
464  } // end of loop on strips
465  float fraction = zeropeds_per_detid[d]/(128.*reader->getNumberOfApvsAndStripLength(d).first);
466  if(fraction>0.) {
467  tmap->fill(d,fraction);
468  std::cout<<"detid: "<< d << " (n. APVs="<< reader->getNumberOfApvsAndStripLength(d).first << ") has " << std::setw(4) << zeropeds_per_detid[d] << " zero-pedestals strips (i.e. a fraction:"<< std::setprecision(5) << fraction <<")" << std::endl;
469  }
470  } // end of loop on detids
471 
472  std::string fileName(m_imageFileName);
473  tmap->save(true,0.,0.,fileName);
474 
475  return true;
476  }
477  };
478 
479  /************************************************
480  Tracker Map of SiStrip Pedestals
481  *************************************************/
482 
483  template<SiStripPI::estimator est> class SiStripPedestalsTrackerMap : public cond::payloadInspector::PlotImage<SiStripPedestals> {
484 
485  public:
486  SiStripPedestalsTrackerMap() : cond::payloadInspector::PlotImage<SiStripPedestals> ( "Tracker Map of SiStripPedestals "+estimatorType(est)+" per module" )
487  {
488  setSingleIov( true );
489  }
490 
491  bool fill( const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs ) override {
492  auto iov = iovs.front();
493  std::shared_ptr<SiStripPedestals> payload = fetchPayload( std::get<1>(iov) );
494 
495  std::string titleMap = "Tracker Map of SiStrip Pedestals "+estimatorType(est)+" per module (payload : "+std::get<1>(iov)+")";
496 
497  std::unique_ptr<TrackerMap> tmap = std::unique_ptr<TrackerMap>(new TrackerMap("SiStripPedestals"));
498  tmap->setTitle(titleMap);
499  tmap->setPalette(1);
500 
501  std::vector<uint32_t> detid;
502  payload->getDetIds(detid);
503 
504  std::map<unsigned int,float> info_per_detid;
505 
506  for (const auto & d : detid) {
507  int nstrips=0;
508  double mean(0.),rms(0.),min(10000.), max(0.);
509  SiStripPedestals::Range range = payload->getRange(d);
510  for( int it=0; it < (range.second-range.first)*8/10; ++it ){
511  nstrips++;
512  auto ped = payload->getPed(it,range);
513  mean+=ped;
514  rms+=(ped*ped);
515  if(ped<min) min=ped;
516  if(ped>max) max=ped;
517  } // end of loop on strips
518 
519  mean/=nstrips;
520  if((rms/nstrips-mean*mean)>0.){
521  rms = sqrt(rms/nstrips-mean*mean);
522  } else {
523  rms=0.;
524  }
525 
526  switch(est){
527  case SiStripPI::min:
528  info_per_detid[d]=min;
529  break;
530  case SiStripPI::max:
531  info_per_detid[d]=max;
532  break;
533  case SiStripPI::mean:
534  info_per_detid[d]=mean;
535  break;
536  case SiStripPI::rms:
537  info_per_detid[d]=rms;
538  break;
539  default:
540  edm::LogWarning("LogicError") << "Unknown estimator: " << est;
541  break;
542  }
543  } // end of loop on detids
544 
545  for(const auto & d : detid){
546  tmap->fill(d,info_per_detid[d]);
547  }
548 
549  std::string fileName(m_imageFileName);
550  tmap->save(true,0.,0.,fileName);
551 
552  return true;
553  }
554  };
555 
556  typedef SiStripPedestalsTrackerMap<SiStripPI::min> SiStripPedestalsMin_TrackerMap;
557  typedef SiStripPedestalsTrackerMap<SiStripPI::max> SiStripPedestalsMax_TrackerMap;
558  typedef SiStripPedestalsTrackerMap<SiStripPI::mean> SiStripPedestalsMean_TrackerMap;
559  typedef SiStripPedestalsTrackerMap<SiStripPI::rms> SiStripPedestalsRMS_TrackerMap;
560 
561  /************************************************
562  Tracker Map of SiStrip Pedestals Summaries
563  *************************************************/
564 
565  template<SiStripPI::estimator est> class SiStripPedestalsByRegion : public cond::payloadInspector::PlotImage<SiStripPedestals> {
566  public:
567  SiStripPedestalsByRegion() : cond::payloadInspector::PlotImage<SiStripPedestals>( "SiStrip Pedestals "+estimatorType(est)+" by Region" ),
568  m_trackerTopo{StandaloneTrackerTopology::fromTrackerParametersXMLFile(edm::FileInPath("Geometry/TrackerCommonData/data/trackerParameters.xml").fullPath())}
569  {
570  setSingleIov( true );
571  }
572 
573  bool fill( const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs ) override {
574  auto iov = iovs.front();
575  std::shared_ptr<SiStripPedestals> payload = fetchPayload( std::get<1>(iov) );
576 
577  SiStripDetSummary summaryPedestals{&m_trackerTopo};
578  std::vector<uint32_t> detid;
579  payload->getDetIds(detid);
580 
581  for (const auto & d : detid) {
582  int nstrips=0;
583  double mean(0.),rms(0.),min(10000.), max(0.);
584  SiStripPedestals::Range range = payload->getRange(d);
585  for( int it=0; it < (range.second-range.first)*8/10; ++it ){
586  nstrips++;
587  auto ped = payload->getPed(it,range);
588  mean+=ped;
589  rms+=(ped*ped);
590  if(ped<min) min=ped;
591  if(ped>max) max=ped;
592  } // end of loop on strips
593 
594  mean/=nstrips;
595  if((rms/nstrips-mean*mean)>0.){
596  rms = sqrt(rms/nstrips-mean*mean);
597  } else {
598  rms=0.;
599  }
600 
601  switch(est){
602  case SiStripPI::min:
603  summaryPedestals.add(d,min);
604  break;
605  case SiStripPI::max:
606  summaryPedestals.add(d,max);
607  break;
608  case SiStripPI::mean:
609  summaryPedestals.add(d,mean);
610  break;
611  case SiStripPI::rms:
612  summaryPedestals.add(d,rms);
613  break;
614  default:
615  edm::LogWarning("LogicError") << "Unknown estimator: " << est;
616  break;
617  }
618  } // loop on the detIds
619 
620  std::map<unsigned int, SiStripDetSummary::Values> map = summaryPedestals.getCounts();
621  //=========================
622 
623  TCanvas canvas("Partion summary","partition summary",1200,1000);
624  canvas.cd();
625  auto h1 = std::unique_ptr<TH1F>(new TH1F("byRegion",Form("Average by partition of %s SiStrip Pedestals per module;;average SiStrip Pedestals %s [ADC counts]",estimatorType(est).c_str(),estimatorType(est).c_str()),map.size(),0.,map.size()));
626  h1->SetStats(false);
627  canvas.SetBottomMargin(0.18);
628  canvas.SetLeftMargin(0.17);
629  canvas.SetRightMargin(0.05);
630  canvas.Modified();
631 
632  std::vector<int> boundaries;
633  unsigned int iBin=0;
634 
636  std::string currentDetector;
637 
638  for (const auto &element : map){
639  iBin++;
640  int count = element.second.count;
641  double mean = (element.second.mean)/count;
642  double rms = (element.second.rms)/count - mean*mean;
643 
644  if(rms <= 0)
645  rms = 0;
646  else
647  rms = sqrt(rms);
648 
649  if(currentDetector.empty()) currentDetector="TIB";
650 
651  switch ((element.first)/1000)
652  {
653  case 1:
654  detector = "TIB";
655  break;
656  case 2:
657  detector = "TOB";
658  break;
659  case 3:
660  detector = "TEC";
661  break;
662  case 4:
663  detector = "TID";
664  break;
665  }
666 
667  h1->SetBinContent(iBin,mean);
668  h1->GetXaxis()->SetBinLabel(iBin,SiStripPI::regionType(element.first).second);
669  h1->GetXaxis()->LabelsOption("v");
670 
671  if(detector!=currentDetector) {
672  boundaries.push_back(iBin);
673  currentDetector=detector;
674  }
675  }
676 
677  h1->SetMarkerStyle(20);
678  h1->SetMarkerSize(1);
679  h1->SetMaximum(h1->GetMaximum()*1.1);
680  h1->Draw("HIST");
681  h1->Draw("Psame");
682 
683  canvas.Update();
684 
685  TLine l[boundaries.size()];
686  unsigned int i=0;
687  for (const auto & line : boundaries){
688  l[i] = TLine(h1->GetBinLowEdge(line),canvas.GetUymin(),h1->GetBinLowEdge(line),canvas.GetUymax());
689  l[i].SetLineWidth(1);
690  l[i].SetLineStyle(9);
691  l[i].SetLineColor(2);
692  l[i].Draw("same");
693  i++;
694  }
695 
696  TLegend legend = TLegend(0.52,0.82,0.95,0.9);
697  legend.SetHeader((std::get<1>(iov)).c_str(),"C"); // option "C" allows to center the header
698  legend.AddEntry(h1.get(),("IOV: "+std::to_string(std::get<0>(iov))).c_str(),"PL");
699  legend.SetTextSize(0.025);
700  legend.Draw("same");
701 
702  std::string fileName(m_imageFileName);
703  canvas.SaveAs(fileName.c_str());
704 
705  return true;
706  }
707  private:
708  TrackerTopology m_trackerTopo;
709  };
710 
711 
712  typedef SiStripPedestalsByRegion<SiStripPI::mean> SiStripPedestalsMeanByRegion;
713  typedef SiStripPedestalsByRegion<SiStripPI::min> SiStripPedestalsMinByRegion;
714  typedef SiStripPedestalsByRegion<SiStripPI::max> SiStripPedestalsMaxByRegion;
715  typedef SiStripPedestalsByRegion<SiStripPI::rms> SiStripPedestalsRMSByRegion;
716 
717 } // close namespace
718 
720  PAYLOAD_INSPECTOR_CLASS(SiStripPedestalsTest);
721  PAYLOAD_INSPECTOR_CLASS(SiStripPedestalsValue);
722  PAYLOAD_INSPECTOR_CLASS(SiStripPedestalValuePerStrip);
723  PAYLOAD_INSPECTOR_CLASS(SiStripPedestalValuePerAPV);
724  PAYLOAD_INSPECTOR_CLASS(SiStripPedestalValuePerModule);
725  PAYLOAD_INSPECTOR_CLASS(SiStripPedestalValueComparisonPerStrip);
726  PAYLOAD_INSPECTOR_CLASS(SiStripPedestalValueComparisonPerAPV);
727  PAYLOAD_INSPECTOR_CLASS(SiStripPedestalValueComparisonPerModule);
728  PAYLOAD_INSPECTOR_CLASS(SiStripZeroPedestalsFraction_TrackerMap);
729  PAYLOAD_INSPECTOR_CLASS(SiStripPedestalsMin_TrackerMap);
730  PAYLOAD_INSPECTOR_CLASS(SiStripPedestalsMax_TrackerMap);
731  PAYLOAD_INSPECTOR_CLASS(SiStripPedestalsMean_TrackerMap);
732  PAYLOAD_INSPECTOR_CLASS(SiStripPedestalsRMS_TrackerMap);
733  PAYLOAD_INSPECTOR_CLASS(SiStripPedestalsMeanByRegion);
734  PAYLOAD_INSPECTOR_CLASS(SiStripPedestalsMinByRegion);
735  PAYLOAD_INSPECTOR_CLASS(SiStripPedestalsMaxByRegion);
736  PAYLOAD_INSPECTOR_CLASS(SiStripPedestalsRMSByRegion);
737 }
const std::pair< unsigned short, double > getNumberOfApvsAndStripLength(uint32_t detId) const
std::pair< ContainerIterator, ContainerIterator > Range
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
T sqrt(T t)
Definition: SSEVec.h:18
void makeNicePlotStyle(TH1 *hist)
#define end
Definition: vmac.h:39
void fillWithValue(float value, float weight=1)
T min(T a, T b)
Definition: MathUtil.h:58
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)
std::string estimatorType(SiStripPI::estimator e)
std::pair< int, const char * > regionType(int index)
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)
Definition: plugin.cc:24
#define begin
Definition: vmac.h:32
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