CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes
HcalPedestalAnalysis Class Reference

#include <HcalPedestalAnalysis.h>

Public Member Functions

int done (const HcalPedestals *fInputPedestals, const HcalPedestalWidths *fInputWidths, HcalPedestals *fOutputPedestals, HcalPedestalWidths *fOutputWidths)
 
 HcalPedestalAnalysis (const edm::ParameterSet &ps)
 Constructor. More...
 
void processEvent (const HBHEDigiCollection &hbhe, const HODigiCollection &ho, const HFDigiCollection &hf, const HcalDbService &cond)
 
void SampleAnalysis ()
 
void setTopology (const HcalTopology *htopo)
 
void setup (const std::string &m_outputFileROOT)
 
 ~HcalPedestalAnalysis ()
 Destructor. More...
 

Static Public Member Functions

static int HcalPedVal (int nstat[4], const HcalPedestals *fRefPedestals, const HcalPedestalWidths *fRefPedestalWidths, HcalPedestals *fRawPedestals, HcalPedestalWidths *fRawPedestalWidths, HcalPedestals *fValPedestals, HcalPedestalWidths *fValPedestalWidths)
 

Private Types

typedef std::pair< TH1F *, std::pair< std::map< int, std::vector< double > >, std::vector< TH1F * > > > PEDBUNCH
 

Private Member Functions

void AllChanHists (const HcalDetId detid, const HcalQIESample &qie0, const HcalQIESample &qie1, const HcalQIESample &qie2, const HcalQIESample &qie3, const HcalQIESample &qie4, const HcalQIESample &qie5, std::map< HcalDetId, std::map< int, PEDBUNCH > > &toolT)
 
void GetPedConst (std::map< HcalDetId, std::map< int, PEDBUNCH > > &toolT, TH1F *PedMeans, TH1F *PedWidths)
 
void per2CapsHists (int flag, int id, const HcalDetId detid, const HcalQIESample &qie1, const HcalQIESample &qie2, std::map< HcalDetId, std::map< int, PEDBUNCH > > &toolT, const HcalDbService &cond)
 
void Trendings (std::map< HcalDetId, std::map< int, PEDBUNCH > > &toolT, TH1F *Chi2, TH1F *CapidAverage, TH1F *CapidChi2)
 

Private Attributes

std::map< HcalDetId, std::map< int, PEDBUNCH > >::iterator _meot
 
int evt
 
int evt_curr
 
HcalPedestalsfRawPedestals
 
HcalPedestalWidthsfRawPedestalWidths
 
const HcalPedestalsfRefPedestals
 
const HcalPedestalWidthsfRefPedestalWidths
 
const HcalTopologyfTopology
 
HcalPedestalsfValPedestals
 
HcalPedestalWidthsfValPedestalWidths
 
struct {
   TH1F *   ALLPEDS
 
   TH1F *   CAPID_AVERAGE
 
   TH1F *   CAPID_CHI2
 
   TH1F *   CHI2
 
   TH1F *   PEDMEAN
 
   TH1F *   PEDRMS
 
   std::map< HcalDetId, std::map< int, PEDBUNCH > >   PEDTRENDS
 
hbHists
 
struct {
   TH1F *   ALLPEDS
 
   TH1F *   CAPID_AVERAGE
 
   TH1F *   CAPID_CHI2
 
   TH1F *   CHI2
 
   TH1F *   PEDMEAN
 
   TH1F *   PEDRMS
 
   std::map< HcalDetId, std::map< int, PEDBUNCH > >   PEDTRENDS
 
hfHists
 
struct {
   TH1F *   ALLPEDS
 
   TH1F *   CAPID_AVERAGE
 
   TH1F *   CAPID_CHI2
 
   TH1F *   CHI2
 
   TH1F *   PEDMEAN
 
   TH1F *   PEDRMS
 
   std::map< HcalDetId, std::map< int, PEDBUNCH > >   PEDTRENDS
 
hoHists
 
int m_AllPedsOK
 
const HcalQIECoderm_coder
 
int m_endTS
 
TFile * m_file
 
int m_hiSaveflag
 
std::ofstream m_logFile
 
int m_nevtsample
 
std::string m_outputFileMean
 
std::string m_outputFileROOT
 
std::string m_outputFileWidth
 
int m_pedsinADC
 
int m_pedValflag
 
const HcalQIEShapem_shape
 
int m_startTS
 
float m_stat [4]
 
int sample
 
std::vector< bool > state
 

Static Private Attributes

static const int fitflag = 0
 

Detailed Description

Definition at line 31 of file HcalPedestalAnalysis.h.

Member Typedef Documentation

◆ PEDBUNCH

typedef std::pair<TH1F*, std::pair<std::map<int, std::vector<double> >, std::vector<TH1F*> > > HcalPedestalAnalysis::PEDBUNCH
private

Definition at line 82 of file HcalPedestalAnalysis.h.

Constructor & Destructor Documentation

◆ HcalPedestalAnalysis()

HcalPedestalAnalysis::HcalPedestalAnalysis ( const edm::ParameterSet ps)

Constructor.

Definition at line 16 of file HcalPedestalAnalysis.cc.

References gather_cfg::cout, evt, edm::ParameterSet::getUntrackedParameter(), hbHists, hfHists, hoHists, mps_fire::i, dqmdumpme::k, m_AllPedsOK, m_coder, m_endTS, m_file, m_hiSaveflag, m_nevtsample, m_outputFileMean, m_outputFileROOT, m_outputFileWidth, m_pedsinADC, m_pedValflag, m_shape, m_startTS, m_stat, sample, and state.

17  : fRefPedestals(nullptr),
18  fRefPedestalWidths(nullptr),
19  fRawPedestals(nullptr),
20  fRawPedestalWidths(nullptr),
21  fValPedestals(nullptr),
22  fValPedestalWidths(nullptr),
23  fTopology(nullptr) {
24  m_coder = nullptr;
25  m_shape = nullptr;
26  evt = 0;
27  sample = 0;
28  m_file = nullptr;
29  m_AllPedsOK = 0;
30  for (int i = 0; i < 4; i++)
31  m_stat[i] = 0;
32  for (int k = 0; k < 4; k++)
33  state.push_back(true);
34 
35  // user cfg parameters
36  m_outputFileMean = ps.getUntrackedParameter<string>("outputFileMeans", "");
37  if (!m_outputFileMean.empty()) {
38  cout << "Hcal pedestal means will be saved to " << m_outputFileMean.c_str() << endl;
39  }
40  m_outputFileWidth = ps.getUntrackedParameter<string>("outputFileWidths", "");
41  if (!m_outputFileWidth.empty()) {
42  cout << "Hcal pedestal widths will be saved to " << m_outputFileWidth.c_str() << endl;
43  }
44  m_outputFileROOT = ps.getUntrackedParameter<string>("outputFileHist", "");
45  if (!m_outputFileROOT.empty()) {
46  cout << "Hcal pedestal histograms will be saved to " << m_outputFileROOT.c_str() << endl;
47  }
48  m_nevtsample = ps.getUntrackedParameter<int>("nevtsample", 0);
49  // for compatibility with previous versions
50  if (m_nevtsample == 9999999)
51  m_nevtsample = 0;
52  m_pedsinADC = ps.getUntrackedParameter<int>("pedsinADC", 0);
53  m_hiSaveflag = ps.getUntrackedParameter<int>("hiSaveflag", 0);
54  m_pedValflag = ps.getUntrackedParameter<int>("pedValflag", 0);
55  if (m_pedValflag < 0)
56  m_pedValflag = 0;
57  if (m_nevtsample > 0 && m_pedValflag > 0) {
58  cout << "WARNING - incompatible cfg options: nevtsample = " << m_nevtsample << ", pedValflag = " << m_pedValflag
59  << endl;
60  cout << "Setting pedValflag = 0" << endl;
61  m_pedValflag = 0;
62  }
63  if (m_pedValflag > 1)
64  m_pedValflag = 1;
65  m_startTS = ps.getUntrackedParameter<int>("firstTS", 0);
66  if (m_startTS < 0)
67  m_startTS = 0;
68  m_endTS = ps.getUntrackedParameter<int>("lastTS", 9);
69 
70  // m_logFile.open("HcalPedestalAnalysis.log");
71 
72  hbHists.ALLPEDS = new TH1F("HBHE All Pedestals", "HBHE All Peds", 10, 0, 9);
73  hbHists.PEDRMS = new TH1F("HBHE All Pedestal Widths", "HBHE All Pedestal RMS", 100, 0, 3);
74  hbHists.PEDMEAN = new TH1F("HBHE All Pedestal Means", "HBHE All Pedestal Means", 100, 0, 9);
75  hbHists.CHI2 = new TH1F("HBHE Chi2/ndf for whole range Gauss fit", "HBHE Chi2/ndf Gauss", 200, 0., 50.);
76 
77  hoHists.ALLPEDS = new TH1F("HO All Pedestals", "HO All Peds", 10, 0, 9);
78  hoHists.PEDRMS = new TH1F("HO All Pedestal Widths", "HO All Pedestal RMS", 100, 0, 3);
79  hoHists.PEDMEAN = new TH1F("HO All Pedestal Means", "HO All Pedestal Means", 100, 0, 9);
80  hoHists.CHI2 = new TH1F("HO Chi2/ndf for whole range Gauss fit", "HO Chi2/ndf Gauss", 200, 0., 50.);
81 
82  hfHists.ALLPEDS = new TH1F("HF All Pedestals", "HF All Peds", 10, 0, 9);
83  hfHists.PEDRMS = new TH1F("HF All Pedestal Widths", "HF All Pedestal RMS", 100, 0, 3);
84  hfHists.PEDMEAN = new TH1F("HF All Pedestal Means", "HF All Pedestal Means", 100, 0, 9);
85  hfHists.CHI2 = new TH1F("HF Chi2/ndf for whole range Gauss fit", "HF Chi2/ndf Gauss", 200, 0., 50.);
86 }
struct HcalPedestalAnalysis::@60 hfHists
HcalPedestals * fRawPedestals
const HcalTopology * fTopology
std::vector< bool > state
const HcalPedestalWidths * fRefPedestalWidths
const HcalQIECoder * m_coder
T getUntrackedParameter(std::string const &, T const &) const
const HcalQIEShape * m_shape
struct HcalPedestalAnalysis::@60 hoHists
HcalPedestals * fValPedestals
struct HcalPedestalAnalysis::@60 hbHists
const HcalPedestals * fRefPedestals
HcalPedestalWidths * fValPedestalWidths
HcalPedestalWidths * fRawPedestalWidths

◆ ~HcalPedestalAnalysis()

HcalPedestalAnalysis::~HcalPedestalAnalysis ( )

Destructor.

Definition at line 89 of file HcalPedestalAnalysis.cc.

References _meot, hbHists, hfHists, hoHists, and mps_fire::i.

89  {
90  for (_meot = hbHists.PEDTRENDS.begin(); _meot != hbHists.PEDTRENDS.end(); _meot++) {
91  for (int i = 0; i < 16; i++)
92  _meot->second[i].first->Delete();
93  }
94  for (_meot = hoHists.PEDTRENDS.begin(); _meot != hoHists.PEDTRENDS.end(); _meot++) {
95  for (int i = 0; i < 16; i++)
96  _meot->second[i].first->Delete();
97  }
98  for (_meot = hfHists.PEDTRENDS.begin(); _meot != hfHists.PEDTRENDS.end(); _meot++) {
99  for (int i = 0; i < 16; i++)
100  _meot->second[i].first->Delete();
101  }
102  hbHists.ALLPEDS->Delete();
103  hbHists.PEDRMS->Delete();
104  hbHists.PEDMEAN->Delete();
105  hbHists.CHI2->Delete();
106 
107  hoHists.ALLPEDS->Delete();
108  hoHists.PEDRMS->Delete();
109  hoHists.PEDMEAN->Delete();
110  hoHists.CHI2->Delete();
111 
112  hfHists.ALLPEDS->Delete();
113  hfHists.PEDRMS->Delete();
114  hfHists.PEDMEAN->Delete();
115  hfHists.CHI2->Delete();
116 }
struct HcalPedestalAnalysis::@60 hfHists
std::map< HcalDetId, std::map< int, PEDBUNCH > >::iterator _meot
struct HcalPedestalAnalysis::@60 hoHists
struct HcalPedestalAnalysis::@60 hbHists

Member Function Documentation

◆ AllChanHists()

void HcalPedestalAnalysis::AllChanHists ( const HcalDetId  detid,
const HcalQIESample qie0,
const HcalQIESample qie1,
const HcalQIESample qie2,
const HcalQIESample qie3,
const HcalQIESample qie4,
const HcalQIESample qie5,
std::map< HcalDetId, std::map< int, PEDBUNCH > > &  toolT 
)
private

Definition at line 392 of file HcalPedestalAnalysis.cc.

References _meot, and HcalQIESample::adc().

Referenced by processEvent().

399  {
400  // this function is due to be called for every channel
401 
402  _meot = toolT.find(detid);
403  map<int, PEDBUNCH> _mei = _meot->second;
404  _mei[16].first->Fill(qie4.adc() + qie5.adc() - 1.);
405  _mei[17].first->Fill(qie4.adc() + qie5.adc() - qie2.adc() - qie3.adc());
406  _mei[18].first->Fill(qie4.adc() + qie5.adc() - (qie0.adc() + qie1.adc() + qie2.adc() + qie3.adc()) / 2.);
407 }
std::map< HcalDetId, std::map< int, PEDBUNCH > >::iterator _meot
constexpr int adc() const
get the ADC sample
Definition: HcalQIESample.h:43

◆ done()

int HcalPedestalAnalysis::done ( const HcalPedestals fInputPedestals,
const HcalPedestalWidths fInputWidths,
HcalPedestals fOutputPedestals,
HcalPedestalWidths fOutputWidths 
)

Definition at line 591 of file HcalPedestalAnalysis.cc.

References gather_cfg::cout, evt, fRawPedestals, fRawPedestalWidths, fRefPedestals, fRefPedestalWidths, fTopology, fValPedestals, fValPedestalWidths, hbHists, HcalPedVal(), hfHists, hoHists, mps_fire::i, m_AllPedsOK, m_file, m_nevtsample, m_outputFileROOT, m_pedsinADC, m_pedValflag, m_stat, SampleAnalysis(), and Trendings().

594  {
595  int nstat[4];
596 
597  // Pedestal objects
598  // inputs...
599  fRefPedestals = fInputPedestals;
600  fRefPedestalWidths = fInputPedestalWidths;
601 
602  // outputs...
603  if (m_pedValflag > 0) {
604  fValPedestals = fOutputPedestals;
605  fValPedestalWidths = fOutputPedestalWidths;
608  } else {
609  fRawPedestals = fOutputPedestals;
610  fRawPedestalWidths = fOutputPedestalWidths;
613  }
614 
615  // compute pedestal constants
616  if (m_nevtsample < 1)
617  SampleAnalysis();
618  if (m_nevtsample > 0) {
619  if (evt % m_nevtsample != 0)
620  SampleAnalysis();
621  }
622 
623  // trending histos
624  if (m_nevtsample > 0) {
625  m_file->cd();
626  m_file->cd("HB");
627  Trendings(hbHists.PEDTRENDS, hbHists.CHI2, hbHists.CAPID_AVERAGE, hbHists.CAPID_CHI2);
628  m_file->cd();
629  m_file->cd("HO");
630  Trendings(hoHists.PEDTRENDS, hoHists.CHI2, hoHists.CAPID_AVERAGE, hoHists.CAPID_CHI2);
631  m_file->cd();
632  m_file->cd("HF");
633  Trendings(hfHists.PEDTRENDS, hfHists.CHI2, hfHists.CAPID_AVERAGE, hfHists.CAPID_CHI2);
634  }
635 
636  if (m_nevtsample < 1) {
637  // pedestal validation: m_AllPedsOK=-1 means not validated,
638  // 0 everything OK,
639  // N>0 : mod(N,100000) drifts + width changes
640  // int(N/100000) missing channels
641  m_AllPedsOK = -1;
642  if (m_pedValflag > 0) {
643  for (int i = 0; i < 4; i++)
644  nstat[i] = (int)m_stat[i];
645  int NPedErrors = HcalPedVal(nstat,
652  m_AllPedsOK = NPedErrors;
653  }
654  // setting m_AllPedsOK=-2 will inhibit writing pedestals out
655  // if(m_pedValflag==1){
656  // if(evt<100)m_AllPedsOK=-2;
657  // }
658  }
659 
660  // Write other histograms.
661  // HB
662  m_file->cd();
663  m_file->cd("HB");
664  hbHists.ALLPEDS->Write();
665  hbHists.PEDRMS->Write();
666  hbHists.PEDMEAN->Write();
667  // HO
668  m_file->cd();
669  m_file->cd("HO");
670  hoHists.ALLPEDS->Write();
671  hoHists.PEDRMS->Write();
672  hoHists.PEDMEAN->Write();
673  // HF
674  m_file->cd();
675  m_file->cd("HF");
676  hfHists.ALLPEDS->Write();
677  hfHists.PEDRMS->Write();
678  hfHists.PEDMEAN->Write();
679 
680  m_file->Close();
681  cout << "Hcal histograms written to " << m_outputFileROOT.c_str() << endl;
682  return (int)m_AllPedsOK;
683 }
struct HcalPedestalAnalysis::@60 hfHists
HcalPedestals * fRawPedestals
const HcalTopology * fTopology
const HcalPedestalWidths * fRefPedestalWidths
struct HcalPedestalAnalysis::@60 hoHists
HcalPedestals * fValPedestals
struct HcalPedestalAnalysis::@60 hbHists
const HcalPedestals * fRefPedestals
HcalPedestalWidths * fValPedestalWidths
static int HcalPedVal(int nstat[4], const HcalPedestals *fRefPedestals, const HcalPedestalWidths *fRefPedestalWidths, HcalPedestals *fRawPedestals, HcalPedestalWidths *fRawPedestalWidths, HcalPedestals *fValPedestals, HcalPedestalWidths *fValPedestalWidths)
HcalPedestalWidths * fRawPedestalWidths
void Trendings(std::map< HcalDetId, std::map< int, PEDBUNCH > > &toolT, TH1F *Chi2, TH1F *CapidAverage, TH1F *CapidChi2)

◆ GetPedConst()

void HcalPedestalAnalysis::GetPedConst ( std::map< HcalDetId, std::map< int, PEDBUNCH > > &  toolT,
TH1F *  PedMeans,
TH1F *  PedWidths 
)
private

Definition at line 433 of file HcalPedestalAnalysis.cc.

References _meot, HcalCondObjectContainer< Item >::addValues(), HLT_2022v12_cff::cap, hltPixelTracks_cff::chi2, fitflag, fRawPedestals, fRawPedestalWidths, mps_fire::i, B2GTnPMonitor_cfi::item, dqmiolumiharvest::j, m_endTS, m_hiSaveflag, m_nevtsample, m_pedsinADC, m_startTS, m_stat, HcalPedestalWidth::setSigma(), and mathSSE::sqrt().

Referenced by SampleAnalysis().

433  {
434  // Completely rewritten version oct 2006
435  // Compute pedestal constants and fill into HcalPedestals and HcalPedestalWidths objects
436  float cap[4];
437  float sig[4][4];
438  float dcap[4];
439  float dsig[4][4];
440  float chi2[4];
441 
442  for (_meot = toolT.begin(); _meot != toolT.end(); _meot++) {
443  HcalDetId detid = _meot->first;
444 
445  // take mean and width from a Gaussian fit or directly from the histo
446  if (fitflag > 0) {
447  for (int i = 0; i < 4; i++) {
448  TF1* fit = _meot->second[i].first->GetFunction("gaus");
449  chi2[i] = 0;
450  if (fit->GetNDF() != 0)
451  chi2[i] = fit->GetChisquare() / fit->GetNDF();
452  cap[i] = fit->GetParameter(1);
453  sig[i][i] = fit->GetParameter(2);
454  dcap[i] = fit->GetParError(1);
455  dsig[i][i] = fit->GetParError(2);
456  }
457  } else {
458  for (int i = 0; i < 4; i++) {
459  cap[i] = _meot->second[i].first->GetMean();
460  sig[i][i] = _meot->second[i].first->GetRMS();
461  m_stat[i] = 0;
462 
463  for (int j = m_startTS; j < m_endTS + 1; j++) {
464  m_stat[i] += _meot->second[i].first->GetBinContent(j + 1);
465  }
466  dcap[i] = sig[i][i] / sqrt(m_stat[i]);
467  // dsig[i][i] = dcap[i]*sig[i][i]/cap[i];
468  dsig[i][i] = sig[i][i] / sqrt(2. * m_stat[i]);
469  chi2[i] = 0.;
470  }
471  }
472 
473  for (int i = 0; i < 4; i++) {
474  if (m_hiSaveflag > 0) {
475  if (m_pedsinADC)
476  _meot->second[i].first->GetXaxis()->SetTitle("ADC");
477  else
478  _meot->second[i].first->GetXaxis()->SetTitle("Charge, fC");
479  _meot->second[i].first->GetYaxis()->SetTitle("CapID samplings");
480  _meot->second[i].first->Write();
481  }
482  if (m_nevtsample > 0) {
483  _meot->second[i].second.first[0].push_back(cap[i]);
484  _meot->second[i].second.first[1].push_back(dcap[i]);
485  _meot->second[i].second.first[2].push_back(sig[i][i]);
486  _meot->second[i].second.first[3].push_back(dsig[i][i]);
487  _meot->second[i].second.first[4].push_back(chi2[i]);
488  }
489  PedMeans->Fill(cap[i]);
490  PedWidths->Fill(sig[i][i]);
491  }
492 
493  // special histos for Shuichi
494  if (m_hiSaveflag == -100) {
495  for (int i = 16; i < 19; i++) {
496  if (m_pedsinADC)
497  _meot->second[i].first->GetXaxis()->SetTitle("ADC");
498  else
499  _meot->second[i].first->GetXaxis()->SetTitle("Charge, fC");
500  _meot->second[i].first->GetYaxis()->SetTitle("Events");
501  _meot->second[i].first->Write();
502  }
503  }
504 
505  // diagonal sigma is width squared
506  sig[0][0] = sig[0][0] * sig[0][0];
507  sig[1][1] = sig[1][1] * sig[1][1];
508  sig[2][2] = sig[2][2] * sig[2][2];
509  sig[3][3] = sig[3][3] * sig[3][3];
510 
511  // off diagonal sigmas (correlations) are computed from 3 histograms
512  // here we still have all 4*3=12 combinations
513  sig[0][1] = _meot->second[4].first->GetMean() - cap[0] * cap[1];
514  sig[0][2] = _meot->second[8].first->GetMean() - cap[0] * cap[2];
515  sig[1][2] = _meot->second[5].first->GetMean() - cap[1] * cap[2];
516  sig[1][3] = _meot->second[9].first->GetMean() - cap[1] * cap[3];
517  sig[2][3] = _meot->second[6].first->GetMean() - cap[2] * cap[3];
518  sig[0][3] = _meot->second[12].first->GetMean() - cap[0] * cap[3];
519  sig[1][0] = _meot->second[13].first->GetMean() - cap[1] * cap[0];
520  sig[2][0] = _meot->second[10].first->GetMean() - cap[2] * cap[0];
521  sig[2][1] = _meot->second[14].first->GetMean() - cap[2] * cap[1];
522  sig[3][1] = _meot->second[11].first->GetMean() - cap[3] * cap[1];
523  sig[3][2] = _meot->second[15].first->GetMean() - cap[3] * cap[2];
524  sig[3][0] = _meot->second[7].first->GetMean() - cap[3] * cap[0];
525 
526  // there is no proper error calculation for the correlation coefficients
527  for (int i = 0; i < 4; i++) {
528  if (m_nevtsample > 0) {
529  _meot->second[i].second.first[5].push_back(sig[i][(i + 1) % 4]);
530  _meot->second[i].second.first[6].push_back(2 * sig[i][i] * dsig[i][i]);
531  _meot->second[i].second.first[7].push_back(sig[i][(i + 2) % 4]);
532  _meot->second[i].second.first[8].push_back(2 * sig[i][i] * dsig[i][i]);
533  _meot->second[i].second.first[9].push_back(sig[i][(i + 3) % 4]);
534  _meot->second[i].second.first[10].push_back(2 * sig[i][i] * dsig[i][i]);
535  }
536  // save product histos if desired
537  if (m_hiSaveflag > 10) {
538  if (m_pedsinADC)
539  _meot->second[i + 4].first->GetXaxis()->SetTitle("ADC^2");
540  else
541  _meot->second[i + 4].first->GetXaxis()->SetTitle("Charge^2, fC^2");
542  _meot->second[i + 4].first->GetYaxis()->SetTitle("2-CapID samplings");
543  _meot->second[i + 4].first->Write();
544  if (m_pedsinADC)
545  _meot->second[i + 8].first->GetXaxis()->SetTitle("ADC^2");
546  else
547  _meot->second[i + 8].first->GetXaxis()->SetTitle("Charge^2, fC^2");
548  _meot->second[i + 8].first->GetYaxis()->SetTitle("2-CapID samplings");
549  _meot->second[i + 8].first->Write();
550  if (m_pedsinADC)
551  _meot->second[i + 12].first->GetXaxis()->SetTitle("ADC^2");
552  else
553  _meot->second[i + 12].first->GetXaxis()->SetTitle("Charge^2, fC^2");
554  _meot->second[i + 12].first->GetYaxis()->SetTitle("2-CapID samplings");
555  _meot->second[i + 12].first->Write();
556  }
557  }
558 
559  // fill the objects - at this point only close and medium correlations are stored
560  // and the matrix is assumed symmetric
561  if (m_nevtsample < 1) {
562  sig[1][0] = sig[0][1];
563  sig[2][0] = sig[0][2];
564  sig[2][1] = sig[1][2];
565  sig[3][1] = sig[1][3];
566  sig[3][2] = sig[2][3];
567  sig[0][3] = sig[3][0];
568  if (fRawPedestals) {
569  HcalPedestal item(detid, cap[0], cap[1], cap[2], cap[3]);
571  }
572  if (fRawPedestalWidths) {
573  HcalPedestalWidth widthsp(detid);
574  widthsp.setSigma(0, 0, sig[0][0]);
575  widthsp.setSigma(0, 1, sig[0][1]);
576  widthsp.setSigma(0, 2, sig[0][2]);
577  widthsp.setSigma(1, 1, sig[1][1]);
578  widthsp.setSigma(1, 2, sig[1][2]);
579  widthsp.setSigma(1, 3, sig[1][3]);
580  widthsp.setSigma(2, 2, sig[2][2]);
581  widthsp.setSigma(2, 3, sig[2][3]);
582  widthsp.setSigma(3, 3, sig[3][3]);
583  widthsp.setSigma(3, 0, sig[0][3]);
584  fRawPedestalWidths->addValues(widthsp);
585  }
586  }
587  }
588 }
HcalPedestals * fRawPedestals
std::map< HcalDetId, std::map< int, PEDBUNCH > >::iterator _meot
T sqrt(T t)
Definition: SSEVec.h:19
bool addValues(const Item &myItem)
HcalPedestalWidths * fRawPedestalWidths

◆ HcalPedVal()

int HcalPedestalAnalysis::HcalPedVal ( int  nstat[4],
const HcalPedestals fRefPedestals,
const HcalPedestalWidths fRefPedestalWidths,
HcalPedestals fRawPedestals,
HcalPedestalWidths fRawPedestalWidths,
HcalPedestals fValPedestals,
HcalPedestalWidths fValPedestalWidths 
)
static

Definition at line 845 of file HcalPedestalAnalysis.cc.

References HcalCondObjectContainer< Item >::addValues(), EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0::cerr, fRawPedestals, fRawPedestalWidths, fRefPedestals, fRefPedestalWidths, fValPedestals, fValPedestalWidths, HcalCondObjectContainer< Item >::getAllChannels(), HcalPedestalWidth::getSigma(), HcalPedestal::getValue(), HcalCondObjectContainer< Item >::getValues(), HcalForward, mps_fire::i, createfilelist::int, B2GTnPMonitor_cfi::item, HcalPedestalWidth::setSigma(), mathSSE::sqrt(), and ApeEstimator_cff::width.

Referenced by done().

851  {
852  // new version of pedestal validation - it is designed to be as independent of
853  // all the rest as possible - you only need to provide valid pedestal objects
854  // and a vector of statistics per capID to use this as standalone code
855  HcalDetId detid;
856  float RefPedVals[4];
857  float RefPedSigs[4][4];
858  float RawPedVals[4];
859  float RawPedSigs[4][4];
860  map<HcalDetId, bool> isinRaw;
861  map<HcalDetId, bool> isinRef;
862  std::vector<DetId> RefChanns = fRefPedestals->getAllChannels();
863  std::vector<DetId> RawChanns = fRawPedestals->getAllChannels();
864  std::ofstream PedValLog;
865  PedValLog.open("HcalPedVal.log");
866 
867  if (nstat[0] + nstat[1] + nstat[2] + nstat[3] < 2500)
868  PedValLog << "HcalPedVal: warning - low statistics" << std::endl;
869  // find complete list of channels in current data and reference
870  for (int i = 0; i < (int)RawChanns.size(); i++) {
871  isinRef[HcalDetId(RawChanns[i])] = false;
872  }
873  for (int i = 0; i < (int)RefChanns.size(); i++) {
874  detid = HcalDetId(RefChanns[i]);
875  isinRaw[detid] = false;
876  isinRef[detid] = true;
877  }
878  for (int i = 0; i < (int)RawChanns.size(); i++) {
879  detid = HcalDetId(RawChanns[i]);
880  isinRaw[detid] = true;
881  if (isinRef[detid] == false) {
882  PedValLog << "HcalPedVal: channel " << detid << " not found in reference set" << std::endl;
883  std::cerr << "HcalPedVal: channel " << detid << " not found in reference set" << std::endl;
884  }
885  }
886 
887  // main loop over channels
888  int erflag = 0;
889  for (int i = 0; i < (int)RefChanns.size(); i++) {
890  detid = HcalDetId(RefChanns[i]);
891  for (int icap = 0; icap < 4; icap++) {
892  RefPedVals[icap] = fRefPedestals->getValues(detid)->getValue(icap);
893  for (int icap2 = icap; icap2 < 4; icap2++) {
894  RefPedSigs[icap][icap2] = fRefPedestalWidths->getValues(detid)->getSigma(icap, icap2);
895  if (icap2 != icap)
896  RefPedSigs[icap2][icap] = RefPedSigs[icap][icap2];
897  }
898  }
899 
900  // read new raw values
901  if (isinRaw[detid]) {
902  for (int icap = 0; icap < 4; icap++) {
903  RawPedVals[icap] = fRawPedestals->getValues(detid)->getValue(icap);
904  for (int icap2 = icap; icap2 < 4; icap2++) {
905  RawPedSigs[icap][icap2] = fRawPedestalWidths->getValues(detid)->getSigma(icap, icap2);
906  if (icap2 != icap)
907  RawPedSigs[icap2][icap] = RawPedSigs[icap][icap2];
908  }
909  }
910 
911  // first quick check if raw values make sense: if not, the channel is treated like absent
912  for (int icap = 0; icap < 4; icap++) {
913  if (RawPedVals[icap] < 1. || RawPedSigs[icap][icap] < 0.01)
914  isinRaw[detid] = false;
915  for (int icap2 = icap; icap2 < 4; icap2++) {
916  if (fabs(RawPedSigs[icap][icap2] / sqrt(RawPedSigs[icap][icap] * RawPedSigs[icap2][icap2])) > 1.)
917  isinRaw[detid] = false;
918  }
919  }
920  }
921 
922  // check raw values against reference
923  if (isinRaw[detid]) {
924  for (int icap = 0; icap < 4; icap++) {
925  int icap2 = (icap + 1) % 4;
926  float width = sqrt(RawPedSigs[icap][icap]);
927  float erof1 = width / sqrt((float)nstat[icap]);
928  float erof2 = sqrt(erof1 * erof1 + RawPedSigs[icap][icap] / (float)nstat[icap]);
929  float erofwidth = width / sqrt(2. * nstat[icap]);
930  float diffof1 = RawPedVals[icap] - RefPedVals[icap];
931  float diffof2 = RawPedVals[icap] + RawPedVals[icap2] - RefPedVals[icap] - RefPedVals[icap2];
932  float diffofw = width - sqrt(RefPedSigs[icap][icap]);
933 
934  // validation in 2 TS for HB, HE, HO, in 1 TS for HF
935  int nTS = 2;
936  if (detid.subdet() == HcalForward)
937  nTS = 1;
938  if (nTS == 1 && fabs(diffof1) > 0.5 + erof1) {
939  erflag += 1;
940  PedValLog << "HcalPedVal: drift in channel " << detid << " cap " << icap << ": " << RawPedVals[icap] << " - "
941  << RefPedVals[icap] << " = " << diffof1 << std::endl;
942  }
943  if (nTS == 2 && fabs(diffof2) > 0.5 + erof2) {
944  erflag += 1;
945  PedValLog << "HcalPedVal: drift in channel " << detid << " caps " << icap << "+" << icap2 << ": "
946  << RawPedVals[icap] << "+" << RawPedVals[icap2] << " - " << RefPedVals[icap] << "+"
947  << RefPedVals[icap2] << " = " << diffof2 << std::endl;
948  }
949  if (fabs(diffofw) > 0.15 * width + erofwidth) {
950  erflag += 1;
951  PedValLog << "HcalPedVal: width changed in channel " << detid << " cap " << icap << ": " << width << " - "
952  << sqrt(RefPedSigs[icap][icap]) << " = " << diffofw << std::endl;
953  }
954  }
955  }
956 
957  // for disconnected/bad channels restore reference values
958  else {
959  PedValLog << "HcalPedVal: no valid data from channel " << detid << std::endl;
960  erflag += 100000;
961  HcalPedestal item(detid, RefPedVals[0], RefPedVals[1], RefPedVals[2], RefPedVals[3]);
963  HcalPedestalWidth widthsp(detid);
964  for (int icap = 0; icap < 4; icap++) {
965  for (int icap2 = icap; icap2 < 4; icap2++)
966  widthsp.setSigma(icap2, icap, RefPedSigs[icap2][icap]);
967  }
968  fValPedestalWidths->addValues(widthsp);
969  }
970 
971  // end of channel loop
972  }
973 
974  if (erflag == 0)
975  PedValLog << "HcalPedVal: all pedestals checked OK" << std::endl;
976 
977  // now construct the remaining part of the validated objects
978  // if nothing changed outside tolerance, validated set = reference set
979  if (erflag % 100000 == 0) {
980  for (int i = 0; i < (int)RefChanns.size(); i++) {
981  detid = HcalDetId(RefChanns[i]);
982  if (isinRaw[detid]) {
983  HcalPedestalWidth widthsp(detid);
984  for (int icap = 0; icap < 4; icap++) {
985  RefPedVals[icap] = fRefPedestals->getValues(detid)->getValue(icap);
986  for (int icap2 = icap; icap2 < 4; icap2++) {
987  RefPedSigs[icap][icap2] = fRefPedestalWidths->getValues(detid)->getSigma(icap, icap2);
988  if (icap2 != icap)
989  RefPedSigs[icap2][icap] = RefPedSigs[icap][icap2];
990  widthsp.setSigma(icap2, icap, RefPedSigs[icap2][icap]);
991  }
992  }
993  fValPedestalWidths->addValues(widthsp);
994  HcalPedestal item(detid, RefPedVals[0], RefPedVals[1], RefPedVals[2], RefPedVals[3]);
996  }
997  }
998  }
999 
1000  // if anything changed, validated set = raw set + reference for missing/bad channels
1001  else {
1002  for (int i = 0; i < (int)RawChanns.size(); i++) {
1003  detid = HcalDetId(RawChanns[i]);
1004  if (isinRaw[detid]) {
1005  HcalPedestalWidth widthsp(detid);
1006  for (int icap = 0; icap < 4; icap++) {
1007  RawPedVals[icap] = fRawPedestals->getValues(detid)->getValue(icap);
1008  for (int icap2 = icap; icap2 < 4; icap2++) {
1009  RawPedSigs[icap][icap2] = fRawPedestalWidths->getValues(detid)->getSigma(icap, icap2);
1010  if (icap2 != icap)
1011  RawPedSigs[icap2][icap] = RawPedSigs[icap][icap2];
1012  widthsp.setSigma(icap2, icap, RawPedSigs[icap2][icap]);
1013  }
1014  }
1015  fValPedestalWidths->addValues(widthsp);
1016  HcalPedestal item(detid, RawPedVals[0], RawPedVals[1], RawPedVals[2], RawPedVals[3]);
1018  }
1019  }
1020  }
1021  return erflag;
1022 }
HcalPedestals * fRawPedestals
float getValue(int fCapId) const
get value for capId = 0..3
Definition: HcalPedestal.h:20
const HcalPedestalWidths * fRefPedestalWidths
const Item * getValues(DetId fId, bool throwOnFail=true) const
T sqrt(T t)
Definition: SSEVec.h:19
std::vector< DetId > getAllChannels() const
float getSigma(int fCapId1, int fCapId2) const
get correlation element for capId1/2 = 0..3
HcalPedestals * fValPedestals
const HcalPedestals * fRefPedestals
HcalPedestalWidths * fValPedestalWidths
bool addValues(const Item &myItem)
HcalPedestalWidths * fRawPedestalWidths

◆ per2CapsHists()

void HcalPedestalAnalysis::per2CapsHists ( int  flag,
int  id,
const HcalDetId  detid,
const HcalQIESample qie1,
const HcalQIESample qie2,
std::map< HcalDetId, std::map< int, PEDBUNCH > > &  toolT,
const HcalDbService cond 
)
private

Definition at line 243 of file HcalPedestalAnalysis.cc.

References _meot, HcalQIESample::adc(), trigObjTnPSource_cfi::bins, HcalQIESample::capid(), HcalQIECoder::charge(), HcalDetId::depth(), evt, RemoveAddSevLevel::flag, hbHists, hfHists, hoHists, mps_fire::i, HcalDetId::ieta(), edm::eventsetup::heterocontainer::insert(), HcalDetId::iphi(), m_nevtsample, m_pedsinADC, Skims_PA_cff::name, and state.

Referenced by processEvent().

249  {
250  // this function is due to be called for every time slice, it fills either a charge
251  // histo for a single capID (flag=0) or a product histo for two capIDs (flag>0)
252 
253  static const int bins = 10;
254  static const int bins2 = 100;
255  float lo = -0.5;
256  float hi = 9.5;
257  map<int, PEDBUNCH> _mei;
258  static map<HcalDetId, map<int, float> > QieCalibMap;
259  string type = "HBHE";
260 
261  if (id == 0) {
262  if (detid.ieta() < 16)
263  type = "HB";
264  if (detid.ieta() > 16)
265  type = "HE";
266  if (detid.ieta() == 16) {
267  if (detid.depth() < 3)
268  type = "HB";
269  if (detid.depth() == 3)
270  type = "HE";
271  }
272  } else if (id == 1)
273  type = "HO";
274  else if (id == 2)
275  type = "HF";
276 
277  _meot = toolT.find(detid);
278 
279  // if histos for the current channel do not exist, first create them,
280  if (_meot == toolT.end()) {
281  map<int, PEDBUNCH> insert;
282  map<int, float> qiecalib;
283  char name[1024];
284  for (int i = 0; i < 4; i++) {
285  lo = -0.5;
286  // fix from Andy: if you convert to fC and then bin in units of 1, you may 'skip' a bin while
287  // filling, since the ADCs are quantized
288  if (m_pedsinADC)
289  hi = 9.5;
290  else
291  hi = 11.5;
292  sprintf(
293  name, "%s Pedestal, eta=%d phi=%d d=%d cap=%d", type.c_str(), detid.ieta(), detid.iphi(), detid.depth(), i);
294  insert[i].first = new TH1F(name, name, bins, lo, hi);
295  sprintf(name,
296  "%s Product, eta=%d phi=%d d=%d caps=%d*%d",
297  type.c_str(),
298  detid.ieta(),
299  detid.iphi(),
300  detid.depth(),
301  i,
302  (i + 1) % 4);
303  insert[4 + i].first = new TH1F(name, name, bins2, 0., 100.);
304  sprintf(name,
305  "%s Product, eta=%d phi=%d d=%d caps=%d*%d",
306  type.c_str(),
307  detid.ieta(),
308  detid.iphi(),
309  detid.depth(),
310  i,
311  (i + 2) % 4);
312  insert[8 + i].first = new TH1F(name, name, bins2, 0., 100.);
313  sprintf(name,
314  "%s Product, eta=%d phi=%d d=%d caps=%d*%d",
315  type.c_str(),
316  detid.ieta(),
317  detid.iphi(),
318  detid.depth(),
319  i,
320  (i + 3) % 4);
321  insert[12 + i].first = new TH1F(name, name, bins2, 0., 100.);
322  }
323  sprintf(name, "%s Signal in TS 4+5, eta=%d phi=%d d=%d", type.c_str(), detid.ieta(), detid.iphi(), detid.depth());
324  insert[16].first = new TH1F(name, name, 21, -0.5, 20.5);
325  sprintf(
326  name, "%s Signal in TS 4+5-2-3, eta=%d phi=%d d=%d", type.c_str(), detid.ieta(), detid.iphi(), detid.depth());
327  insert[17].first = new TH1F(name, name, 21, -10.5, 10.5);
328  sprintf(name,
329  "%s Signal in TS 4+5-(0+1+2+3)/2., eta=%d phi=%d d=%d",
330  type.c_str(),
331  detid.ieta(),
332  detid.iphi(),
333  detid.depth());
334  insert[18].first = new TH1F(name, name, 21, -10.5, 10.5);
335  toolT[detid] = insert;
336  _meot = toolT.find(detid);
337  // store QIE calibrations in a map for later reuse
338  QieCalibMap[detid] = qiecalib;
339  }
340 
341  _mei = _meot->second;
342 
343  const HcalQIECoder* coder = cond.getHcalCoder(detid);
344  const HcalQIEShape* shape = cond.getHcalShape(coder);
345  float charge1 = coder->charge(*shape, qie1.adc(), qie1.capid());
346  float charge2 = coder->charge(*shape, qie2.adc(), qie2.capid());
347 
348  // fill single capID histo
349  if (flag == 0) {
350  if (m_nevtsample > 0) {
351  if ((evt - 1) % m_nevtsample == 0 && state[qie1.capid()]) {
352  state[qie1.capid()] = false;
353  _mei[qie1.capid()].first->Reset();
354  _mei[qie1.capid() + 4].first->Reset();
355  _mei[qie1.capid() + 8].first->Reset();
356  _mei[qie1.capid() + 12].first->Reset();
357  }
358  }
359  if (qie1.adc() < bins) {
360  if (m_pedsinADC)
361  _mei[qie1.capid()].first->Fill(qie1.adc());
362  else
363  _mei[qie1.capid()].first->Fill(charge1);
364  } else if (qie1.adc() >= bins) {
365  _mei[qie1.capid()].first->AddBinContent(bins + 1, 1);
366  }
367  }
368 
369  // fill 2 capID histo
370  if (flag > 0) {
371  map<int, float> qiecalib = QieCalibMap[detid];
372  //float charge1=(qie1.adc()-qiecalib[qie1.capid()+4])/qiecalib[qie1.capid()];
373  //float charge2=(qie2.adc()-qiecalib[qie2.capid()+4])/qiecalib[qie2.capid()];
374  if (charge1 * charge2 < bins2) {
375  _mei[qie1.capid() + 4 * flag].first->Fill(charge1 * charge2);
376  } else {
377  _mei[qie1.capid() + 4 * flag].first->Fill(bins2);
378  }
379  }
380 
381  if (flag == 0) {
382  if (id == 0)
383  hbHists.ALLPEDS->Fill(qie1.adc());
384  else if (id == 1)
385  hoHists.ALLPEDS->Fill(qie1.adc());
386  else if (id == 2)
387  hfHists.ALLPEDS->Fill(qie1.adc());
388  }
389 }
struct HcalPedestalAnalysis::@60 hfHists
std::vector< bool > state
std::map< HcalDetId, std::map< int, PEDBUNCH > >::iterator _meot
struct HcalPedestalAnalysis::@60 hoHists
Definition: EPCuts.h:4
constexpr int ieta() const
get the cell ieta
Definition: HcalDetId.h:155
bool insert(Storage &iStorage, ItemType *iItem, const IdTag &iIdTag)
Definition: HCMethods.h:50
struct HcalPedestalAnalysis::@60 hbHists
constexpr int capid() const
get the Capacitor id
Definition: HcalQIESample.h:47
Definition: plugin.cc:23
constexpr int adc() const
get the ADC sample
Definition: HcalQIESample.h:43
constexpr int iphi() const
get the cell iphi
Definition: HcalDetId.h:157
float charge(const HcalQIEShape &fShape, unsigned fAdc, unsigned fCapId) const
ADC [0..127] + capid [0..3] -> fC conversion.
Definition: HcalQIECoder.cc:20
constexpr int depth() const
get the tower depth
Definition: HcalDetId.h:164

◆ processEvent()

void HcalPedestalAnalysis::processEvent ( const HBHEDigiCollection hbhe,
const HODigiCollection ho,
const HFDigiCollection hf,
const HcalDbService cond 
)

Definition at line 131 of file HcalPedestalAnalysis.cc.

References AllChanHists(), evt, evt_curr, RemoveAddSevLevel::flag, photonIsolationHIProducer_cfi::hbhe, hbHists, photonIsolationHIProducer_cfi::hf, hfHists, photonIsolationHIProducer_cfi::ho, hoHists, mps_fire::i, HBHEDataFrame::id(), HODataFrame::id(), HFDataFrame::id(), createfilelist::int, dqmiolumiharvest::j, dqmdumpme::k, m_coder, m_endTS, m_nevtsample, m_shape, m_startTS, per2CapsHists(), HFDataFrame::sample(), HBHEDataFrame::sample(), HODataFrame::sample(), sample, SampleAnalysis(), HODataFrame::size(), HBHEDataFrame::size(), HFDataFrame::size(), and state.

134  {
135  evt++;
136  sample = 1;
137  evt_curr = evt;
138  if (m_nevtsample > 0) {
139  sample = (evt - 1) / m_nevtsample + 1;
141  if (evt_curr == 0)
143  }
144 
145  // Get data for every CAPID.
146  // HBHE
147  try {
148  if (hbhe.empty())
149  throw(int) hbhe.size();
150  for (HBHEDigiCollection::const_iterator j = hbhe.begin(); j != hbhe.end(); ++j) {
151  const HBHEDataFrame digi = (const HBHEDataFrame)(*j);
152  m_coder = cond.getHcalCoder(digi.id());
153  m_shape = cond.getHcalShape(m_coder);
154  for (int k = 0; k < (int)state.size(); k++)
155  state[k] = true;
156  // here we loop over pairs of time slices, it is more convenient
157  // in order to extract the correlation matrix
158  for (int i = m_startTS; i < digi.size() && i <= m_endTS; i++) {
159  for (int flag = 0; flag < 4; flag++) {
160  if (i + flag < digi.size() && i + flag <= m_endTS) {
161  per2CapsHists(flag, 0, digi.id(), digi.sample(i), digi.sample(i + flag), hbHists.PEDTRENDS, cond);
162  }
163  }
164  }
165  if (m_startTS == 0 && m_endTS > 4) {
166  AllChanHists(digi.id(),
167  digi.sample(0),
168  digi.sample(1),
169  digi.sample(2),
170  digi.sample(3),
171  digi.sample(4),
172  digi.sample(5),
173  hbHists.PEDTRENDS);
174  }
175  }
176  } catch (int i) {
177  // m_logFile<< "Event with " << i<<" HBHE Digis passed." << std::endl;
178  }
179  // HO
180  try {
181  if (ho.empty())
182  throw(int) ho.size();
183  for (HODigiCollection::const_iterator j = ho.begin(); j != ho.end(); ++j) {
184  const HODataFrame digi = (const HODataFrame)(*j);
185  m_coder = cond.getHcalCoder(digi.id());
186  for (int i = m_startTS; i < digi.size() && i <= m_endTS; i++) {
187  for (int flag = 0; flag < 4; flag++) {
188  if (i + flag < digi.size() && i + flag <= m_endTS) {
189  per2CapsHists(flag, 1, digi.id(), digi.sample(i), digi.sample(i + flag), hoHists.PEDTRENDS, cond);
190  }
191  }
192  }
193  if (m_startTS == 0 && m_endTS > 4) {
194  AllChanHists(digi.id(),
195  digi.sample(0),
196  digi.sample(1),
197  digi.sample(2),
198  digi.sample(3),
199  digi.sample(4),
200  digi.sample(5),
201  hoHists.PEDTRENDS);
202  }
203  }
204  } catch (int i) {
205  // m_logFile << "Event with " << i<<" HO Digis passed." << std::endl;
206  }
207  // HF
208  try {
209  if (hf.empty())
210  throw(int) hf.size();
211  for (HFDigiCollection::const_iterator j = hf.begin(); j != hf.end(); ++j) {
212  const HFDataFrame digi = (const HFDataFrame)(*j);
213  m_coder = cond.getHcalCoder(digi.id());
214  for (int i = m_startTS; i < digi.size() && i <= m_endTS; i++) {
215  for (int flag = 0; flag < 4; flag++) {
216  if (i + flag < digi.size() && i + flag <= m_endTS) {
217  per2CapsHists(flag, 2, digi.id(), digi.sample(i), digi.sample(i + flag), hfHists.PEDTRENDS, cond);
218  }
219  }
220  }
221  if (m_startTS == 0 && m_endTS > 4) {
222  AllChanHists(digi.id(),
223  digi.sample(0),
224  digi.sample(1),
225  digi.sample(2),
226  digi.sample(3),
227  digi.sample(4),
228  digi.sample(5),
229  hfHists.PEDTRENDS);
230  }
231  }
232  } catch (int i) {
233  // m_logFile << "Event with " << i<<" HF Digis passed." << std::endl;
234  }
235  // Call the function every m_nevtsample events
236  if (m_nevtsample > 0) {
237  if (evt % m_nevtsample == 0)
238  SampleAnalysis();
239  }
240 }
struct HcalPedestalAnalysis::@60 hfHists
constexpr HcalDetId const & id() const
Definition: HFDataFrame.h:23
constexpr const HcalQIESample & sample(int i) const
access a sample
Definition: HODataFrame.h:40
constexpr HcalQIESample const & sample(int i) const
access a sample
Definition: HBHEDataFrame.h:40
void per2CapsHists(int flag, int id, const HcalDetId detid, const HcalQIESample &qie1, const HcalQIESample &qie2, std::map< HcalDetId, std::map< int, PEDBUNCH > > &toolT, const HcalDbService &cond)
std::vector< T >::const_iterator const_iterator
std::vector< bool > state
const HcalQIECoder * m_coder
constexpr HcalQIESample const & sample(int i) const
access a sample
Definition: HFDataFrame.h:40
const HcalQIEShape * m_shape
struct HcalPedestalAnalysis::@60 hoHists
constexpr int size() const
total number of samples in the digi
Definition: HFDataFrame.h:27
constexpr const HcalDetId & id() const
Definition: HBHEDataFrame.h:23
struct HcalPedestalAnalysis::@60 hbHists
void AllChanHists(const HcalDetId detid, const HcalQIESample &qie0, const HcalQIESample &qie1, const HcalQIESample &qie2, const HcalQIESample &qie3, const HcalQIESample &qie4, const HcalQIESample &qie5, std::map< HcalDetId, std::map< int, PEDBUNCH > > &toolT)
constexpr int size() const
total number of samples in the digi
Definition: HODataFrame.h:27
Definition: plugin.cc:23
constexpr int size() const
total number of samples in the digi
Definition: HBHEDataFrame.h:27
constexpr HcalDetId const & id() const
Definition: HODataFrame.h:23

◆ SampleAnalysis()

void HcalPedestalAnalysis::SampleAnalysis ( )

Definition at line 410 of file HcalPedestalAnalysis.cc.

References GetPedConst(), hbHists, hfHists, hoHists, m_file, and sample.

Referenced by done(), and processEvent().

410  {
411  // it is called every m_nevtsample events (a sample) and the end of run
412  char PedSampleNum[20];
413 
414  // Compute pedestal constants for each HBHE, HO, HF
415  sprintf(PedSampleNum, "HB_Sample%d", sample);
416  m_file->cd();
417  m_file->mkdir(PedSampleNum);
418  m_file->cd(PedSampleNum);
419  GetPedConst(hbHists.PEDTRENDS, hbHists.PEDMEAN, hbHists.PEDRMS);
420  sprintf(PedSampleNum, "HO_Sample%d", sample);
421  m_file->cd();
422  m_file->mkdir(PedSampleNum);
423  m_file->cd(PedSampleNum);
424  GetPedConst(hoHists.PEDTRENDS, hoHists.PEDMEAN, hoHists.PEDRMS);
425  sprintf(PedSampleNum, "HF_Sample%d", sample);
426  m_file->cd();
427  m_file->mkdir(PedSampleNum);
428  m_file->cd(PedSampleNum);
429  GetPedConst(hfHists.PEDTRENDS, hfHists.PEDMEAN, hfHists.PEDRMS);
430 }
struct HcalPedestalAnalysis::@60 hfHists
void GetPedConst(std::map< HcalDetId, std::map< int, PEDBUNCH > > &toolT, TH1F *PedMeans, TH1F *PedWidths)
struct HcalPedestalAnalysis::@60 hoHists
struct HcalPedestalAnalysis::@60 hbHists

◆ setTopology()

void HcalPedestalAnalysis::setTopology ( const HcalTopology htopo)
inline

Definition at line 42 of file HcalPedestalAnalysis.h.

References fTopology.

42 { fTopology = htopo; }
const HcalTopology * fTopology

◆ setup()

void HcalPedestalAnalysis::setup ( const std::string &  m_outputFileROOT)

Definition at line 119 of file HcalPedestalAnalysis.cc.

References m_file, and m_outputFileROOT.

Referenced by o2olib.O2OTool::execute().

119  {
120  // open the histogram file, create directories within
121  m_file = new TFile(m_outputFileROOT.c_str(), "RECREATE");
122  m_file->mkdir("HB");
123  m_file->cd();
124  m_file->mkdir("HO");
125  m_file->cd();
126  m_file->mkdir("HF");
127  m_file->cd();
128 }

◆ Trendings()

void HcalPedestalAnalysis::Trendings ( std::map< HcalDetId, std::map< int, PEDBUNCH > > &  toolT,
TH1F *  Chi2,
TH1F *  CapidAverage,
TH1F *  CapidChi2 
)
private

Definition at line 686 of file HcalPedestalAnalysis.cc.

References _meot, trigObjTnPSource_cfi::bins, HcalDetId::depth(), dqmMemoryStats::float, mps_fire::i, HcalDetId::ieta(), HcalDetId::iphi(), dqmiolumiharvest::j, m_nevtsample, Skims_PA_cff::name, sample, and findQualityFiles::size.

Referenced by done().

689  {
690  // check stability of pedestal constants in a single long run
691 
692  map<int, std::vector<double> > AverageValues;
693 
694  for (_meot = toolT.begin(); _meot != toolT.end(); _meot++) {
695  for (int i = 0; i < 4; i++) {
696  char name[1024];
697  HcalDetId detid = _meot->first;
698  sprintf(name, "Pedestal trend, eta=%d phi=%d d=%d cap=%d", detid.ieta(), detid.iphi(), detid.depth(), i);
699  int bins = _meot->second[i].second.first[0].size();
700  float lo = 0.5;
701  float hi = (float)bins + 0.5;
702  _meot->second[i].second.second.push_back(new TH1F(name, name, bins, lo, hi));
703  sprintf(name, "Width trend, eta=%d phi=%d d=%d cap=%d", detid.ieta(), detid.iphi(), detid.depth(), i);
704  bins = _meot->second[i].second.first[2].size();
705  hi = (float)bins + 0.5;
706  _meot->second[i].second.second.push_back(new TH1F(name, name, bins, lo, hi));
707  sprintf(name,
708  "Correlation trend, eta=%d phi=%d d=%d caps=%d*%d",
709  detid.ieta(),
710  detid.iphi(),
711  detid.depth(),
712  i,
713  (i + 1) % 4);
714  bins = _meot->second[i].second.first[5].size();
715  hi = (float)bins + 0.5;
716  _meot->second[i].second.second.push_back(new TH1F(name, name, bins, lo, hi));
717  /* sprintf(name,"Correlation trend, eta=%d phi=%d d=%d caps=%d*%d",detid.ieta(),detid.iphi(),detid.depth(),i,(i+2)%4);
718  bins = _meot->second[i].second.first[7].size();
719  hi = (float)bins+0.5;
720  _meot->second[i].second.second.push_back(new TH1F(name,name,bins,lo,hi));
721  sprintf(name,"Correlation trend, eta=%d phi=%d d=%d caps=%d*%d",detid.ieta(),detid.iphi(),detid.depth(),i,(i+3)%4);
722  bins = _meot->second[i].second.first[9].size();
723  hi = (float)bins+0.5;
724  _meot->second[i].second.second.push_back(new TH1F(name,name,bins,lo,hi)); */
725 
726  std::vector<double>::iterator sample_it;
727  // Pedestal mean - put content and errors
728  int j = 0;
729  for (sample_it = _meot->second[i].second.first[0].begin(); sample_it != _meot->second[i].second.first[0].end();
730  ++sample_it) {
731  _meot->second[i].second.second[0]->SetBinContent(++j, *sample_it);
732  }
733  j = 0;
734  for (sample_it = _meot->second[i].second.first[1].begin(); sample_it != _meot->second[i].second.first[1].end();
735  ++sample_it) {
736  _meot->second[i].second.second[0]->SetBinError(++j, *sample_it);
737  }
738  // fit with a constant - extract parameters
739  _meot->second[i].second.second[0]->Fit("pol0", "Q");
740  TF1* fit = _meot->second[i].second.second[0]->GetFunction("pol0");
741  AverageValues[0].push_back(fit->GetParameter(0));
742  AverageValues[1].push_back(fit->GetParError(0));
743  if (sample > 1)
744  AverageValues[2].push_back(fit->GetChisquare() / fit->GetNDF());
745  else
746  AverageValues[2].push_back(fit->GetChisquare());
747  sprintf(name, "Sample (%d events)", m_nevtsample);
748  _meot->second[i].second.second[0]->GetXaxis()->SetTitle(name);
749  _meot->second[i].second.second[0]->GetYaxis()->SetTitle("Pedestal value");
750  _meot->second[i].second.second[0]->Write();
751  // Pedestal width - put content and errors
752  j = 0;
753  for (sample_it = _meot->second[i].second.first[2].begin(); sample_it != _meot->second[i].second.first[2].end();
754  ++sample_it) {
755  _meot->second[i].second.second[1]->SetBinContent(++j, *sample_it);
756  }
757  j = 0;
758  for (sample_it = _meot->second[i].second.first[3].begin(); sample_it != _meot->second[i].second.first[3].end();
759  ++sample_it) {
760  _meot->second[i].second.second[1]->SetBinError(++j, *sample_it);
761  }
762  _meot->second[i].second.second[1]->GetXaxis()->SetTitle(name);
763  _meot->second[i].second.second[1]->GetYaxis()->SetTitle("Pedestal width");
764  _meot->second[i].second.second[1]->Write();
765  // Correlation coeffs - put contents and errors
766  j = 0;
767  for (sample_it = _meot->second[i].second.first[5].begin(); sample_it != _meot->second[i].second.first[5].end();
768  ++sample_it) {
769  _meot->second[i].second.second[2]->SetBinContent(++j, *sample_it);
770  }
771  j = 0;
772  for (sample_it = _meot->second[i].second.first[6].begin(); sample_it != _meot->second[i].second.first[6].end();
773  ++sample_it) {
774  _meot->second[i].second.second[2]->SetBinError(++j, *sample_it);
775  }
776  _meot->second[i].second.second[2]->GetXaxis()->SetTitle(name);
777  _meot->second[i].second.second[2]->GetYaxis()->SetTitle("Close correlation");
778  _meot->second[i].second.second[2]->Write();
779  /* j=0;
780  for(sample_it=_meot->second[i].second.first[7].begin();
781  sample_it!=_meot->second[i].second.first[7].end();sample_it++){
782  _meot->second[i].second.second[3]->SetBinContent(++j,*sample_it);
783  }
784  j=0;
785  for(sample_it=_meot->second[i].second.first[8].begin();
786  sample_it!=_meot->second[i].second.first[8].end();sample_it++){
787  _meot->second[i].second.second[3]->SetBinError(++j,*sample_it);
788  }
789  _meot->second[i].second.second[3]->GetXaxis()->SetTitle(name);
790  _meot->second[i].second.second[3]->GetYaxis()->SetTitle("Intermediate correlation");
791  _meot->second[i].second.second[3]->Write();
792  j=0;
793  for(sample_it=_meot->second[i].second.first[9].begin();
794  sample_it!=_meot->second[i].second.first[9].end();sample_it++){
795  _meot->second[i].second.second[4]->SetBinContent(++j,*sample_it);
796  }
797  j=0;
798  for(sample_it=_meot->second[i].second.first[10].begin();
799  sample_it!=_meot->second[i].second.first[10].end();sample_it++){
800  _meot->second[i].second.second[4]->SetBinError(++j,*sample_it);
801  }
802  _meot->second[i].second.second[4]->GetXaxis()->SetTitle(name);
803  _meot->second[i].second.second[4]->GetYaxis()->SetTitle("Distant correlation");
804  _meot->second[i].second.second[4]->Write(); */
805  // chi2
806  for (sample_it = _meot->second[i].second.first[4].begin(); sample_it != _meot->second[i].second.first[4].end();
807  ++sample_it) {
808  Chi2->Fill(*sample_it);
809  }
810  }
811  }
812  CapidAverage = new TH1F("Constant fit: Pedestal Values",
813  "Constant fit: Pedestal Values",
814  AverageValues[0].size(),
815  0.,
816  AverageValues[0].size());
817  std::vector<double>::iterator sample_it;
818  int j = 0;
819  for (sample_it = AverageValues[0].begin(); sample_it != AverageValues[0].end(); ++sample_it) {
820  CapidAverage->SetBinContent(++j, *sample_it);
821  }
822  j = 0;
823  for (sample_it = AverageValues[1].begin(); sample_it != AverageValues[1].end(); ++sample_it) {
824  CapidAverage->SetBinError(++j, *sample_it);
825  }
826  CapidChi2 = new TH1F(
827  "Constant fit: Chi2/ndf", "Constant fit: Chi2/ndf", AverageValues[2].size(), 0., AverageValues[2].size());
828  j = 0;
829  for (sample_it = AverageValues[2].begin(); sample_it != AverageValues[2].end(); ++sample_it) {
830  CapidChi2->SetBinContent(++j, *sample_it);
831  //CapidChi2->SetBinError(++j,0);
832  }
833  Chi2->GetXaxis()->SetTitle("Chi2/ndf");
834  Chi2->GetYaxis()->SetTitle("50 x [(16+2) x 4 x 4] `events`");
835  Chi2->Write();
836  CapidAverage->GetYaxis()->SetTitle("Pedestal value");
837  CapidAverage->GetXaxis()->SetTitle("(16+2) x 4 x 4 `events`");
838  CapidAverage->Write();
839  CapidChi2->GetYaxis()->SetTitle("Chi2/ndf");
840  CapidChi2->GetXaxis()->SetTitle("(16+2) x 4 x 4 `events`");
841  CapidChi2->Write();
842 }
size
Write out results.
std::map< HcalDetId, std::map< int, PEDBUNCH > >::iterator _meot
Definition: EPCuts.h:4
constexpr int ieta() const
get the cell ieta
Definition: HcalDetId.h:155
Definition: Chi2.h:15
constexpr int iphi() const
get the cell iphi
Definition: HcalDetId.h:157
constexpr int depth() const
get the tower depth
Definition: HcalDetId.h:164

Member Data Documentation

◆ _meot

std::map<HcalDetId, std::map<int, PEDBUNCH> >::iterator HcalPedestalAnalysis::_meot
private

◆ ALLPEDS

TH1F* HcalPedestalAnalysis::ALLPEDS

Definition at line 123 of file HcalPedestalAnalysis.h.

◆ CAPID_AVERAGE

TH1F* HcalPedestalAnalysis::CAPID_AVERAGE

Definition at line 127 of file HcalPedestalAnalysis.h.

◆ CAPID_CHI2

TH1F* HcalPedestalAnalysis::CAPID_CHI2

Definition at line 128 of file HcalPedestalAnalysis.h.

◆ CHI2

TH1F* HcalPedestalAnalysis::CHI2

Definition at line 126 of file HcalPedestalAnalysis.h.

◆ evt

int HcalPedestalAnalysis::evt
private

Definition at line 137 of file HcalPedestalAnalysis.h.

Referenced by done(), HcalPedestalAnalysis(), per2CapsHists(), and processEvent().

◆ evt_curr

int HcalPedestalAnalysis::evt_curr
private

Definition at line 139 of file HcalPedestalAnalysis.h.

Referenced by processEvent().

◆ fitflag

const int HcalPedestalAnalysis::fitflag = 0
staticprivate

Definition at line 144 of file HcalPedestalAnalysis.h.

Referenced by GetPedConst().

◆ fRawPedestals

HcalPedestals* HcalPedestalAnalysis::fRawPedestals
private

Definition at line 133 of file HcalPedestalAnalysis.h.

Referenced by done(), GetPedConst(), and HcalPedVal().

◆ fRawPedestalWidths

HcalPedestalWidths* HcalPedestalAnalysis::fRawPedestalWidths
private

Definition at line 134 of file HcalPedestalAnalysis.h.

Referenced by done(), GetPedConst(), and HcalPedVal().

◆ fRefPedestals

const HcalPedestals* HcalPedestalAnalysis::fRefPedestals
private

Definition at line 131 of file HcalPedestalAnalysis.h.

Referenced by done(), and HcalPedVal().

◆ fRefPedestalWidths

const HcalPedestalWidths* HcalPedestalAnalysis::fRefPedestalWidths
private

Definition at line 132 of file HcalPedestalAnalysis.h.

Referenced by done(), and HcalPedVal().

◆ fTopology

const HcalTopology* HcalPedestalAnalysis::fTopology
private

Definition at line 142 of file HcalPedestalAnalysis.h.

Referenced by done(), and setTopology().

◆ fValPedestals

HcalPedestals* HcalPedestalAnalysis::fValPedestals
private

Definition at line 135 of file HcalPedestalAnalysis.h.

Referenced by done(), and HcalPedVal().

◆ fValPedestalWidths

HcalPedestalWidths* HcalPedestalAnalysis::fValPedestalWidths
private

Definition at line 136 of file HcalPedestalAnalysis.h.

Referenced by done(), and HcalPedVal().

◆ hbHists

struct { ... } HcalPedestalAnalysis::hbHists

◆ hfHists

struct { ... } HcalPedestalAnalysis::hfHists

◆ hoHists

struct { ... } HcalPedestalAnalysis::hoHists

◆ m_AllPedsOK

int HcalPedestalAnalysis::m_AllPedsOK
private

Definition at line 117 of file HcalPedestalAnalysis.h.

Referenced by done(), and HcalPedestalAnalysis().

◆ m_coder

const HcalQIECoder* HcalPedestalAnalysis::m_coder
private

Definition at line 120 of file HcalPedestalAnalysis.h.

Referenced by HcalPedestalAnalysis(), and processEvent().

◆ m_endTS

int HcalPedestalAnalysis::m_endTS
private

Definition at line 112 of file HcalPedestalAnalysis.h.

Referenced by GetPedConst(), HcalPedestalAnalysis(), and processEvent().

◆ m_file

TFile* HcalPedestalAnalysis::m_file
private

Definition at line 105 of file HcalPedestalAnalysis.h.

Referenced by done(), HcalPedestalAnalysis(), SampleAnalysis(), and setup().

◆ m_hiSaveflag

int HcalPedestalAnalysis::m_hiSaveflag
private

Definition at line 115 of file HcalPedestalAnalysis.h.

Referenced by GetPedConst(), and HcalPedestalAnalysis().

◆ m_logFile

std::ofstream HcalPedestalAnalysis::m_logFile
private

Definition at line 110 of file HcalPedestalAnalysis.h.

◆ m_nevtsample

int HcalPedestalAnalysis::m_nevtsample
private

◆ m_outputFileMean

std::string HcalPedestalAnalysis::m_outputFileMean
private

Definition at line 108 of file HcalPedestalAnalysis.h.

Referenced by HcalPedestalAnalysis().

◆ m_outputFileROOT

std::string HcalPedestalAnalysis::m_outputFileROOT
private

Definition at line 107 of file HcalPedestalAnalysis.h.

Referenced by done(), HcalPedestalAnalysis(), and setup().

◆ m_outputFileWidth

std::string HcalPedestalAnalysis::m_outputFileWidth
private

Definition at line 109 of file HcalPedestalAnalysis.h.

Referenced by HcalPedestalAnalysis().

◆ m_pedsinADC

int HcalPedestalAnalysis::m_pedsinADC
private

Definition at line 114 of file HcalPedestalAnalysis.h.

Referenced by done(), GetPedConst(), HcalPedestalAnalysis(), and per2CapsHists().

◆ m_pedValflag

int HcalPedestalAnalysis::m_pedValflag
private

Definition at line 116 of file HcalPedestalAnalysis.h.

Referenced by done(), and HcalPedestalAnalysis().

◆ m_shape

const HcalQIEShape* HcalPedestalAnalysis::m_shape
private

Definition at line 119 of file HcalPedestalAnalysis.h.

Referenced by HcalPedestalAnalysis(), and processEvent().

◆ m_startTS

int HcalPedestalAnalysis::m_startTS
private

Definition at line 111 of file HcalPedestalAnalysis.h.

Referenced by GetPedConst(), HcalPedestalAnalysis(), and processEvent().

◆ m_stat

float HcalPedestalAnalysis::m_stat[4]
private

Definition at line 140 of file HcalPedestalAnalysis.h.

Referenced by done(), GetPedConst(), and HcalPedestalAnalysis().

◆ PEDMEAN

TH1F* HcalPedestalAnalysis::PEDMEAN

Definition at line 125 of file HcalPedestalAnalysis.h.

◆ PEDRMS

TH1F* HcalPedestalAnalysis::PEDRMS

Definition at line 124 of file HcalPedestalAnalysis.h.

◆ PEDTRENDS

std::map<HcalDetId, std::map<int, PEDBUNCH> > HcalPedestalAnalysis::PEDTRENDS

Definition at line 122 of file HcalPedestalAnalysis.h.

◆ sample

int HcalPedestalAnalysis::sample
private

◆ state

std::vector<bool> HcalPedestalAnalysis::state
private