CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 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
 
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 37 of file HcalPedestalAnalysis.h.

Member Typedef Documentation

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

Definition at line 89 of file HcalPedestalAnalysis.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 16 of file HcalPedestalAnalysis.cc.

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

Destructor.

Definition at line 85 of file HcalPedestalAnalysis.cc.

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

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

Member Function Documentation

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 319 of file HcalPedestalAnalysis.cc.

References _meot, and HcalQIESample::adc().

Referenced by processEvent().

319  {
320 
321 // this function is due to be called for every channel
322 
323  _meot = toolT.find(detid);
324  map<int,PEDBUNCH> _mei = _meot->second;
325  _mei[16].first->Fill(qie4.adc()+qie5.adc()-1.);
326  _mei[17].first->Fill(qie4.adc()+qie5.adc()-qie2.adc()-qie3.adc());
327  _mei[18].first->Fill(qie4.adc()+qie5.adc()-(qie0.adc()+qie1.adc()+qie2.adc()+qie3.adc())/2.);
328 }
int adc() const
get the ADC sample
Definition: HcalQIESample.h:22
std::map< HcalDetId, std::map< int, PEDBUNCH > >::iterator _meot
int HcalPedestalAnalysis::done ( const HcalPedestals fInputPedestals,
const HcalPedestalWidths fInputWidths,
HcalPedestals fOutputPedestals,
HcalPedestalWidths fOutputWidths 
)

Definition at line 506 of file HcalPedestalAnalysis.cc.

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

510 {
511  int nstat[4];
512 
513 // Pedestal objects
514  // inputs...
515  fRefPedestals = fInputPedestals;
516  fRefPedestalWidths = fInputPedestalWidths;
517 
518  // outputs...
519  if(m_pedValflag>0) {
520  fValPedestals = fOutputPedestals;
521  fValPedestalWidths = fOutputPedestalWidths;
524  }
525  else {
526  fRawPedestals = fOutputPedestals;
527  fRawPedestalWidths = fOutputPedestalWidths;
530  }
531 
532 // compute pedestal constants
534  if(m_nevtsample>0) {
536  }
537 
538 // trending histos
539  if(m_nevtsample>0){
540  m_file->cd();
541  m_file->cd("HB");
542  Trendings(hbHists.PEDTRENDS,hbHists.CHI2,hbHists.CAPID_AVERAGE,hbHists.CAPID_CHI2);
543  m_file->cd();
544  m_file->cd("HO");
545  Trendings(hoHists.PEDTRENDS,hoHists.CHI2,hoHists.CAPID_AVERAGE,hoHists.CAPID_CHI2);
546  m_file->cd();
547  m_file->cd("HF");
548  Trendings(hfHists.PEDTRENDS,hfHists.CHI2,hfHists.CAPID_AVERAGE,hfHists.CAPID_CHI2);
549  }
550 
551  if (m_nevtsample<1) {
552 
553 // pedestal validation: m_AllPedsOK=-1 means not validated,
554 // 0 everything OK,
555 // N>0 : mod(N,100000) drifts + width changes
556 // int(N/100000) missing channels
557  m_AllPedsOK=-1;
558  if(m_pedValflag>0) {
559  for (int i=0; i<4; i++) nstat[i]=(int)m_stat[i];
560  int NPedErrors=HcalPedVal(nstat,fRefPedestals,fRefPedestalWidths,
563  m_AllPedsOK=NPedErrors;
564  }
565 // setting m_AllPedsOK=-2 will inhibit writing pedestals out
566 // if(m_pedValflag==1){
567 // if(evt<100)m_AllPedsOK=-2;
568 // }
569 
570  }
571 
572  // Write other histograms.
573  // HB
574  m_file->cd();
575  m_file->cd("HB");
576  hbHists.ALLPEDS->Write();
577  hbHists.PEDRMS->Write();
578  hbHists.PEDMEAN->Write();
579  // HO
580  m_file->cd();
581  m_file->cd("HO");
582  hoHists.ALLPEDS->Write();
583  hoHists.PEDRMS->Write();
584  hoHists.PEDMEAN->Write();
585  // HF
586  m_file->cd();
587  m_file->cd("HF");
588  hfHists.ALLPEDS->Write();
589  hfHists.PEDRMS->Write();
590  hfHists.PEDMEAN->Write();
591 
592  m_file->Close();
593  cout << "Hcal histograms written to " << m_outputFileROOT.c_str() << endl;
594  return (int)m_AllPedsOK;
595 }
int i
Definition: DBlmapReader.cc:9
HcalPedestals * fRawPedestals
struct HcalPedestalAnalysis::@57 hoHists
const HcalPedestalWidths * fRefPedestalWidths
HcalPedestals * fValPedestals
struct HcalPedestalAnalysis::@57 hfHists
const HcalPedestals * fRefPedestals
tuple cout
Definition: gather_cfg.py:121
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)
struct HcalPedestalAnalysis::@57 hbHists
void HcalPedestalAnalysis::GetPedConst ( std::map< HcalDetId, std::map< int, PEDBUNCH > > &  toolT,
TH1F *  PedMeans,
TH1F *  PedWidths 
)
private

Definition at line 354 of file HcalPedestalAnalysis.cc.

References _meot, HcalCondObjectContainer< Item >::addValues(), cap, cond::rpcobgas::detid, fitflag, fRawPedestals, fRawPedestalWidths, i, j, m_endTS, m_hiSaveflag, m_nevtsample, m_pedsinADC, m_startTS, m_stat, HcalPedestalWidth::setSigma(), and mathSSE::sqrt().

Referenced by SampleAnalysis().

355 {
356 // Completely rewritten version oct 2006
357 // Compute pedestal constants and fill into HcalPedestals and HcalPedestalWidths objects
358  float cap[4]; float sig[4][4]; float dcap[4]; float dsig[4][4]; float chi2[4];
359 
360  for(_meot=toolT.begin(); _meot!=toolT.end(); _meot++){
361  HcalDetId detid = _meot->first;
362 
363 // take mean and width from a Gaussian fit or directly from the histo
364  if(fitflag>0){
365  for (int i=0; i<4; i++) {
366  TF1 *fit = _meot->second[i].first->GetFunction("gaus");
367  chi2[i]=0;
368  if(fit->GetNDF()!=0) chi2[i]=fit->GetChisquare()/fit->GetNDF();
369  cap[i]=fit->GetParameter(1);
370  sig[i][i]=fit->GetParameter(2);
371  dcap[i]=fit->GetParError(1);
372  dsig[i][i]=fit->GetParError(2);
373  }
374  }
375  else{
376  for (int i=0; i<4; i++) {
377  cap[i]=_meot->second[i].first->GetMean();
378  sig[i][i]=_meot->second[i].first->GetRMS();
379  m_stat[i]=0;
380 
381  for(int j=m_startTS; j<m_endTS+1; j++){
382  m_stat[i]+=_meot->second[i].first->GetBinContent(j+1);
383  }
384  dcap[i] = sig[i][i]/sqrt(m_stat[i]);
385 // dsig[i][i] = dcap[i]*sig[i][i]/cap[i];
386  dsig[i][i] = sig[i][i]/sqrt(2.*m_stat[i]);
387  chi2[i]=0.;
388  }
389  }
390 
391  for (int i=0; i<4; i++) {
392  if(m_hiSaveflag>0) {
393  if (m_pedsinADC)
394  _meot->second[i].first->GetXaxis()->SetTitle("ADC");
395  else _meot->second[i].first->GetXaxis()->SetTitle("Charge, fC");
396  _meot->second[i].first->GetYaxis()->SetTitle("CapID samplings");
397  _meot->second[i].first->Write();
398  }
399  if(m_nevtsample>0) {
400  _meot->second[i].second.first[0].push_back(cap[i]);
401  _meot->second[i].second.first[1].push_back(dcap[i]);
402  _meot->second[i].second.first[2].push_back(sig[i][i]);
403  _meot->second[i].second.first[3].push_back(dsig[i][i]);
404  _meot->second[i].second.first[4].push_back(chi2[i]);
405  }
406  PedMeans->Fill(cap[i]);
407  PedWidths->Fill(sig[i][i]);
408  }
409 
410 // special histos for Shuichi
411  if(m_hiSaveflag==-100){
412  for(int i=16; i<19; i++){
413  if (m_pedsinADC)
414  _meot->second[i].first->GetXaxis()->SetTitle("ADC");
415  else _meot->second[i].first->GetXaxis()->SetTitle("Charge, fC");
416  _meot->second[i].first->GetYaxis()->SetTitle("Events");
417  _meot->second[i].first->Write();
418  }
419  }
420 
421 // diagonal sigma is width squared
422  sig[0][0]=sig[0][0]*sig[0][0];
423  sig[1][1]=sig[1][1]*sig[1][1];
424  sig[2][2]=sig[2][2]*sig[2][2];
425  sig[3][3]=sig[3][3]*sig[3][3];
426 
427 // off diagonal sigmas (correlations) are computed from 3 histograms
428 // here we still have all 4*3=12 combinations
429  sig[0][1]= _meot->second[4].first->GetMean()-cap[0]*cap[1];
430  sig[0][2]= _meot->second[8].first->GetMean()-cap[0]*cap[2];
431  sig[1][2]= _meot->second[5].first->GetMean()-cap[1]*cap[2];
432  sig[1][3]= _meot->second[9].first->GetMean()-cap[1]*cap[3];
433  sig[2][3]= _meot->second[6].first->GetMean()-cap[2]*cap[3];
434  sig[0][3]= _meot->second[12].first->GetMean()-cap[0]*cap[3];
435  sig[1][0]= _meot->second[13].first->GetMean()-cap[1]*cap[0];
436  sig[2][0]= _meot->second[10].first->GetMean()-cap[2]*cap[0];
437  sig[2][1]= _meot->second[14].first->GetMean()-cap[2]*cap[1];
438  sig[3][1]= _meot->second[11].first->GetMean()-cap[3]*cap[1];
439  sig[3][2]= _meot->second[15].first->GetMean()-cap[3]*cap[2];
440  sig[3][0]= _meot->second[7].first->GetMean()-cap[3]*cap[0];
441 
442 // there is no proper error calculation for the correlation coefficients
443  for(int i=0; i<4; i++){
444  if(m_nevtsample>0) {
445  _meot->second[i].second.first[5].push_back(sig[i][(i+1)%4]);
446  _meot->second[i].second.first[6].push_back(2*sig[i][i]*dsig[i][i]);
447  _meot->second[i].second.first[7].push_back(sig[i][(i+2)%4]);
448  _meot->second[i].second.first[8].push_back(2*sig[i][i]*dsig[i][i]);
449  _meot->second[i].second.first[9].push_back(sig[i][(i+3)%4]);
450  _meot->second[i].second.first[10].push_back(2*sig[i][i]*dsig[i][i]);
451  }
452 // save product histos if desired
453  if(m_hiSaveflag>10) {
454  if (m_pedsinADC)
455  _meot->second[i+4].first->GetXaxis()->SetTitle("ADC^2");
456  else _meot->second[i+4].first->GetXaxis()->SetTitle("Charge^2, fC^2");
457  _meot->second[i+4].first->GetYaxis()->SetTitle("2-CapID samplings");
458  _meot->second[i+4].first->Write();
459  if (m_pedsinADC)
460  _meot->second[i+8].first->GetXaxis()->SetTitle("ADC^2");
461  else _meot->second[i+8].first->GetXaxis()->SetTitle("Charge^2, fC^2");
462  _meot->second[i+8].first->GetYaxis()->SetTitle("2-CapID samplings");
463  _meot->second[i+8].first->Write();
464  if (m_pedsinADC)
465  _meot->second[i+12].first->GetXaxis()->SetTitle("ADC^2");
466  else _meot->second[i+12].first->GetXaxis()->SetTitle("Charge^2, fC^2");
467  _meot->second[i+12].first->GetYaxis()->SetTitle("2-CapID samplings");
468  _meot->second[i+12].first->Write();
469  }
470  }
471 
472 // fill the objects - at this point only close and medium correlations are stored
473 // and the matrix is assumed symmetric
474  if (m_nevtsample<1) {
475  sig[1][0]=sig[0][1];
476  sig[2][0]=sig[0][2];
477  sig[2][1]=sig[1][2];
478  sig[3][1]=sig[1][3];
479  sig[3][2]=sig[2][3];
480  sig[0][3]=sig[3][0];
481  if (fRawPedestals)
482  {
483  HcalPedestal item(detid,cap[0],cap[1],cap[2],cap[3]);
484  fRawPedestals->addValues(item);
485  }
486  if (fRawPedestalWidths)
487  {
488  HcalPedestalWidth widthsp(detid);
489  widthsp.setSigma(0,0,sig[0][0]);
490  widthsp.setSigma(0,1,sig[0][1]);
491  widthsp.setSigma(0,2,sig[0][2]);
492  widthsp.setSigma(1,1,sig[1][1]);
493  widthsp.setSigma(1,2,sig[1][2]);
494  widthsp.setSigma(1,3,sig[1][3]);
495  widthsp.setSigma(2,2,sig[2][2]);
496  widthsp.setSigma(2,3,sig[2][3]);
497  widthsp.setSigma(3,3,sig[3][3]);
498  widthsp.setSigma(3,0,sig[0][3]);
499  fRawPedestalWidths->addValues(widthsp);
500  }
501  }
502  }
503 }
int i
Definition: DBlmapReader.cc:9
HcalPedestals * fRawPedestals
static const double cap
Definition: HcalTimeSlew.cc:7
T sqrt(T t)
Definition: SSEVec.h:48
int j
Definition: DBlmapReader.cc:9
std::map< HcalDetId, std::map< int, PEDBUNCH > >::iterator _meot
bool addValues(const Item &myItem)
HcalPedestalWidths * fRawPedestalWidths
int HcalPedestalAnalysis::HcalPedVal ( int  nstat[4],
const HcalPedestals fRefPedestals,
const HcalPedestalWidths fRefPedestalWidths,
HcalPedestals fRawPedestals,
HcalPedestalWidths fRawPedestalWidths,
HcalPedestals fValPedestals,
HcalPedestalWidths fValPedestalWidths 
)
static

Definition at line 753 of file HcalPedestalAnalysis.cc.

References HcalCondObjectContainer< Item >::addValues(), ecal_dqm_sourceclient-live_cfg::cerr, cond::rpcobgas::detid, HcalCondObjectContainer< Item >::getAllChannels(), HcalPedestalWidth::getSigma(), HcalPedestal::getValue(), HcalCondObjectContainer< Item >::getValues(), HcalForward, i, HcalPedestalWidth::setSigma(), mathSSE::sqrt(), and create_public_lumi_plots::width.

Referenced by done().

759 {
760 // new version of pedestal validation - it is designed to be as independent of
761 // all the rest as possible - you only need to provide valid pedestal objects
762 // and a vector of statistics per capID to use this as standalone code
764  float RefPedVals[4]; float RefPedSigs[4][4];
765  float RawPedVals[4]; float RawPedSigs[4][4];
766  map<HcalDetId,bool> isinRaw;
767  map<HcalDetId,bool> isinRef;
768  std::vector<DetId> RefChanns=fRefPedestals->getAllChannels();
769  std::vector<DetId> RawChanns=fRawPedestals->getAllChannels();
770  std::ofstream PedValLog;
771  PedValLog.open("HcalPedVal.log");
772 
773  if(nstat[0]+nstat[1]+nstat[2]+nstat[3]<2500) PedValLog<<"HcalPedVal: warning - low statistics"<<std::endl;
774 // find complete list of channels in current data and reference
775  for (int i=0; i<(int)RawChanns.size(); i++){
776  isinRef[HcalDetId(RawChanns[i])]=false;
777  }
778  for (int i=0; i<(int)RefChanns.size(); i++){
779  detid=HcalDetId(RefChanns[i]);
780  isinRaw[detid]=false;
781  isinRef[detid]=true;
782  }
783  for (int i=0; i<(int)RawChanns.size(); i++){
784  detid=HcalDetId(RawChanns[i]);
785  isinRaw[detid]=true;
786  if (isinRef[detid]==false) {
787  PedValLog<<"HcalPedVal: channel "<<detid<<" not found in reference set"<<std::endl;
788  std::cerr<<"HcalPedVal: channel "<<detid<<" not found in reference set"<<std::endl;
789  }
790  }
791 
792 // main loop over channels
793  int erflag=0;
794  for (int i=0; i<(int)RefChanns.size(); i++){
795  detid=HcalDetId(RefChanns[i]);
796  for (int icap=0; icap<4; icap++) {
797  RefPedVals[icap]=fRefPedestals->getValues(detid)->getValue(icap);
798  for (int icap2=icap; icap2<4; icap2++) {
799  RefPedSigs[icap][icap2]=fRefPedestalWidths->getValues(detid)->getSigma(icap,icap2);
800  if(icap2!=icap)RefPedSigs[icap2][icap]=RefPedSigs[icap][icap2];
801  }
802  }
803 
804 // read new raw values
805  if(isinRaw[detid]) {
806  for (int icap=0; icap<4; icap++) {
807  RawPedVals[icap]=fRawPedestals->getValues(detid)->getValue(icap);
808  for (int icap2=icap; icap2<4; icap2++) {
809  RawPedSigs[icap][icap2]=fRawPedestalWidths->getValues(detid)->getSigma(icap,icap2);
810  if(icap2!=icap)RawPedSigs[icap2][icap]=RawPedSigs[icap][icap2];
811  }
812  }
813 
814 // first quick check if raw values make sense: if not, the channel is treated like absent
815  for (int icap=0; icap<4; icap++) {
816  if(RawPedVals[icap]<1. || RawPedSigs[icap][icap]<0.01) isinRaw[detid]=false;
817  for (int icap2=icap; icap2<4; icap2++){
818  if(fabs(RawPedSigs[icap][icap2]/sqrt(RawPedSigs[icap][icap]*RawPedSigs[icap2][icap2]))>1.) isinRaw[detid]=false;
819  }
820  }
821  }
822 
823 // check raw values against reference
824  if(isinRaw[detid]) {
825  for (int icap=0; icap<4; icap++) {
826  int icap2=(icap+1)%4;
827  float width=sqrt(RawPedSigs[icap][icap]);
828  float erof1=width/sqrt((float)nstat[icap]);
829  float erof2=sqrt(erof1*erof1+RawPedSigs[icap][icap]/(float)nstat[icap]);
830  float erofwidth=width/sqrt(2.*nstat[icap]);
831  float diffof1=RawPedVals[icap]-RefPedVals[icap];
832  float diffof2=RawPedVals[icap]+RawPedVals[icap2]-RefPedVals[icap]-RefPedVals[icap2];
833  float diffofw=width-sqrt(RefPedSigs[icap][icap]);
834 
835 // validation in 2 TS for HB, HE, HO, in 1 TS for HF
836  int nTS=2;
837  if(detid.subdet()==HcalForward) nTS=1;
838  if(nTS==1 && fabs(diffof1)>0.5+erof1) {
839  erflag+=1;
840  PedValLog<<"HcalPedVal: drift in channel "<<detid<<" cap "<<icap<<": "<<RawPedVals[icap]<<" - "<<RefPedVals[icap]<<" = "<<diffof1<<std::endl;
841  }
842  if(nTS==2 && fabs(diffof2)>0.5+erof2) {
843  erflag+=1;
844  PedValLog<<"HcalPedVal: drift in channel "<<detid<<" caps "<<icap<<"+"<<icap2<<": "<<RawPedVals[icap]<<"+"<<RawPedVals[icap2]<<" - "<<RefPedVals[icap]<<"+"<<RefPedVals[icap2]<<" = "<<diffof2<<std::endl;
845  }
846  if(fabs(diffofw)>0.15*width+erofwidth) {
847  erflag+=1;
848  PedValLog<<"HcalPedVal: width changed in channel "<<detid<<" cap "<<icap<<": "<<width<<" - "<<sqrt(RefPedSigs[icap][icap])<<" = "<<diffofw<<std::endl;
849  }
850  }
851  }
852 
853 // for disconnected/bad channels restore reference values
854  else {
855  PedValLog<<"HcalPedVal: no valid data from channel "<<detid<<std::endl;
856  erflag+=100000;
857  HcalPedestal item(detid,RefPedVals[0],RefPedVals[1],RefPedVals[2],RefPedVals[3]);
858  fValPedestals->addValues(item);
859  HcalPedestalWidth widthsp(detid);
860  for (int icap=0; icap<4; icap++) {
861  for (int icap2=icap; icap2<4; icap2++) widthsp.setSigma(icap2,icap,RefPedSigs[icap2][icap]);
862  }
863  fValPedestalWidths->addValues(widthsp);
864  }
865 
866 // end of channel loop
867  }
868 
869  if(erflag==0) PedValLog<<"HcalPedVal: all pedestals checked OK"<<std::endl;
870 
871 // now construct the remaining part of the validated objects
872 // if nothing changed outside tolerance, validated set = reference set
873  if(erflag%100000 == 0) {
874  for (int i=0; i<(int)RefChanns.size(); i++){
875  detid=HcalDetId(RefChanns[i]);
876  if (isinRaw[detid]) {
877  HcalPedestalWidth widthsp(detid);
878  for (int icap=0; icap<4; icap++) {
879  RefPedVals[icap]=fRefPedestals->getValues(detid)->getValue(icap);
880  for (int icap2=icap; icap2<4; icap2++) {
881  RefPedSigs[icap][icap2]=fRefPedestalWidths->getValues(detid)->getSigma(icap,icap2);
882  if(icap2!=icap)RefPedSigs[icap2][icap]=RefPedSigs[icap][icap2];
883  widthsp.setSigma(icap2,icap,RefPedSigs[icap2][icap]);
884  }
885  }
886  fValPedestalWidths->addValues(widthsp);
887  HcalPedestal item(detid,RefPedVals[0],RefPedVals[1],RefPedVals[2],RefPedVals[3]);
888  fValPedestals->addValues(item);
889  }
890  }
891  }
892 
893 // if anything changed, validated set = raw set + reference for missing/bad channels
894  else {
895  for (int i=0; i<(int)RawChanns.size(); i++){
896  detid=HcalDetId(RawChanns[i]);
897  if (isinRaw[detid]) {
898  HcalPedestalWidth widthsp(detid);
899  for (int icap=0; icap<4; icap++) {
900  RawPedVals[icap]=fRawPedestals->getValues(detid)->getValue(icap);
901  for (int icap2=icap; icap2<4; icap2++) {
902  RawPedSigs[icap][icap2]=fRawPedestalWidths->getValues(detid)->getSigma(icap,icap2);
903  if(icap2!=icap)RawPedSigs[icap2][icap]=RawPedSigs[icap][icap2];
904  widthsp.setSigma(icap2,icap,RawPedSigs[icap2][icap]);
905  }
906  }
907  fValPedestalWidths->addValues(widthsp);
908  HcalPedestal item(detid,RawPedVals[0],RawPedVals[1],RawPedVals[2],RawPedVals[3]);
909  fValPedestals->addValues(item);
910  }
911  }
912  }
913  return erflag;
914 }
int i
Definition: DBlmapReader.cc:9
float getSigma(int fCapId1, int fCapId2) const
get correlation element for capId1/2 = 0..3
const Item * getValues(DetId fId, bool throwOnFail=true) const
std::vector< DetId > getAllChannels() const
T sqrt(T t)
Definition: SSEVec.h:48
float getValue(int fCapId) const
get value for capId = 0..3
Definition: HcalPedestal.h:21
bool addValues(const Item &myItem)
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 214 of file HcalPedestalAnalysis.cc.

References _meot, HcalQIESample::adc(), HcalQIESample::capid(), HcalQIECoder::charge(), HcalDetId::depth(), cond::rpcobgas::detid, evt, HcalDbService::getHcalCoder(), HcalDbService::getHcalShape(), hbHists, hfHists, hoHists, i, HcalDetId::ieta(), edm::eventsetup::heterocontainer::insert(), HcalDetId::iphi(), m_nevtsample, m_pedsinADC, mergeVDriftHistosByStation::name, and state.

Referenced by processEvent().

214  {
215 
216 // this function is due to be called for every time slice, it fills either a charge
217 // histo for a single capID (flag=0) or a product histo for two capIDs (flag>0)
218 
219  static const int bins=10;
220  static const int bins2=100;
221  float lo=-0.5; float hi=9.5;
222  map<int,PEDBUNCH> _mei;
223  static map<HcalDetId, map<int,float> > QieCalibMap;
224  string type = "HBHE";
225 
226  if(id==0){
227  if(detid.ieta()<16) type = "HB";
228  if(detid.ieta()>16) type = "HE";
229  if(detid.ieta()==16){
230  if(detid.depth()<3) type = "HB";
231  if(detid.depth()==3) type = "HE";
232  }
233  }
234  else if(id==1) type = "HO";
235  else if(id==2) type = "HF";
236 
237  _meot = toolT.find(detid);
238 
239 // if histos for the current channel do not exist, first create them,
240  if (_meot==toolT.end()){
241  map<int,PEDBUNCH> insert;
242  map<int,float> qiecalib;
243  char name[1024];
244  for(int i=0; i<4; i++){
245  lo=-0.5;
246  // fix from Andy: if you convert to fC and then bin in units of 1, you may 'skip' a bin while
247  // filling, since the ADCs are quantized
248  if (m_pedsinADC) hi=9.5;
249  else hi = 11.5;
250  sprintf(name,"%s Pedestal, eta=%d phi=%d d=%d cap=%d",type.c_str(),detid.ieta(),detid.iphi(),detid.depth(),i);
251  insert[i].first = new TH1F(name,name,bins,lo,hi);
252  sprintf(name,"%s Product, eta=%d phi=%d d=%d caps=%d*%d",type.c_str(),detid.ieta(),detid.iphi(),detid.depth(),i,(i+1)%4);
253  insert[4+i].first = new TH1F(name,name,bins2,0.,100.);
254  sprintf(name,"%s Product, eta=%d phi=%d d=%d caps=%d*%d",type.c_str(),detid.ieta(),detid.iphi(),detid.depth(),i,(i+2)%4);
255  insert[8+i].first = new TH1F(name,name,bins2,0.,100.);
256  sprintf(name,"%s Product, eta=%d phi=%d d=%d caps=%d*%d",type.c_str(),detid.ieta(),detid.iphi(),detid.depth(),i,(i+3)%4);
257  insert[12+i].first = new TH1F(name,name,bins2,0.,100.);
258  }
259  sprintf(name,"%s Signal in TS 4+5, eta=%d phi=%d d=%d",type.c_str(),detid.ieta(),detid.iphi(),detid.depth());
260  insert[16].first = new TH1F(name,name,21,-0.5,20.5);
261  sprintf(name,"%s Signal in TS 4+5-2-3, eta=%d phi=%d d=%d",type.c_str(),detid.ieta(),detid.iphi(),detid.depth());
262  insert[17].first = new TH1F(name,name,21,-10.5,10.5);
263  sprintf(name,"%s Signal in TS 4+5-(0+1+2+3)/2., eta=%d phi=%d d=%d",type.c_str(),detid.ieta(),detid.iphi(),detid.depth());
264  insert[18].first = new TH1F(name,name,21,-10.5,10.5);
265  toolT[detid] = insert;
266  _meot = toolT.find(detid);
267 // store QIE calibrations in a map for later reuse
268  QieCalibMap[detid]=qiecalib;
269  }
270 
271  _mei = _meot->second;
272 
273  const HcalQIECoder* coder = cond.getHcalCoder(detid);
274  const HcalQIEShape* shape = cond.getHcalShape(coder);
275  float charge1 = coder->charge(*shape,qie1.adc(),qie1.capid());
276  float charge2 = coder->charge(*shape,qie2.adc(),qie2.capid());
277 
278 // fill single capID histo
279  if(flag==0){
280  if(m_nevtsample>0) {
281  if((evt-1)%m_nevtsample==0 && state[qie1.capid()]){
282  state[qie1.capid()]=false;
283  _mei[qie1.capid()].first->Reset();
284  _mei[qie1.capid()+4].first->Reset();
285  _mei[qie1.capid()+8].first->Reset();
286  _mei[qie1.capid()+12].first->Reset();
287  }
288  }
289  if (qie1.adc()<bins){
290  if (m_pedsinADC) _mei[qie1.capid()].first->Fill(qie1.adc());
291  else _mei[qie1.capid()].first->Fill(charge1);
292  }
293  else if(qie1.adc()>=bins){
294  _mei[qie1.capid()].first->AddBinContent(bins+1,1);
295  }
296  }
297 
298 // fill 2 capID histo
299  if(flag>0){
300  map<int,float> qiecalib = QieCalibMap[detid];
301  //float charge1=(qie1.adc()-qiecalib[qie1.capid()+4])/qiecalib[qie1.capid()];
302  //float charge2=(qie2.adc()-qiecalib[qie2.capid()+4])/qiecalib[qie2.capid()];
303  if (charge1*charge2<bins2){
304  _mei[qie1.capid()+4*flag].first->Fill(charge1*charge2);
305  }
306  else{
307  _mei[qie1.capid()+4*flag].first->Fill(bins2);
308  }
309  }
310 
311  if(flag==0){
312  if(id==0) hbHists.ALLPEDS->Fill(qie1.adc());
313  else if(id==1) hoHists.ALLPEDS->Fill(qie1.adc());
314  else if(id==2) hfHists.ALLPEDS->Fill(qie1.adc());
315  }
316 }
type
Definition: HCALResponse.h:21
int i
Definition: DBlmapReader.cc:9
int adc() const
get the ADC sample
Definition: HcalQIESample.h:22
struct HcalPedestalAnalysis::@57 hoHists
std::vector< bool > state
int depth() const
get the tower depth
Definition: HcalDetId.h:55
int ieta() const
get the cell ieta
Definition: HcalDetId.h:51
bool insert(Storage &iStorage, ItemType *iItem, const IdTag &iIdTag)
Definition: HCMethods.h:49
int iphi() const
get the cell iphi
Definition: HcalDetId.h:53
std::map< HcalDetId, std::map< int, PEDBUNCH > >::iterator _meot
int capid() const
get the Capacitor id
Definition: HcalQIESample.h:26
const HcalQIECoder * getHcalCoder(const HcalGenericDetId &fId) const
struct HcalPedestalAnalysis::@57 hfHists
const HcalQIEShape * getHcalShape(const HcalGenericDetId &fId) const
struct HcalPedestalAnalysis::@57 hbHists
float charge(const HcalQIEShape &fShape, unsigned fAdc, unsigned fCapId) const
ADC [0..127] + capid [0..3] -&gt; fC conversion.
Definition: HcalQIECoder.cc:22
void HcalPedestalAnalysis::processEvent ( const HBHEDigiCollection hbhe,
const HODigiCollection ho,
const HFDigiCollection hf,
const HcalDbService cond 
)

Definition at line 125 of file HcalPedestalAnalysis.cc.

References AllChanHists(), edm::SortedCollection< T, SORT >::begin(), edm::SortedCollection< T, SORT >::end(), evt, evt_curr, HcalDbService::getHcalCoder(), HcalDbService::getHcalShape(), hbHists, hfHists, hoHists, i, HBHEDataFrame::id(), HFDataFrame::id(), HODataFrame::id(), j, relval_steps::k, m_coder, m_endTS, m_nevtsample, m_shape, m_startTS, per2CapsHists(), HBHEDataFrame::sample(), HFDataFrame::sample(), HODataFrame::sample(), sample, SampleAnalysis(), HBHEDataFrame::size(), HFDataFrame::size(), HODataFrame::size(), edm::SortedCollection< T, SORT >::size(), and state.

129 {
130  evt++;
131  sample=1;
132  evt_curr=evt;
133  if(m_nevtsample>0) {
134  sample = (evt-1)/m_nevtsample +1;
137  }
138 
139  // Get data for every CAPID.
140  // HBHE
141  try{
142  if(!hbhe.size()) throw (int)hbhe.size();
143  for (HBHEDigiCollection::const_iterator j=hbhe.begin(); j!=hbhe.end(); j++){
144  const HBHEDataFrame digi = (const HBHEDataFrame)(*j);
145  m_coder = cond.getHcalCoder(digi.id());
146  m_shape = cond.getHcalShape(m_coder);
147  for(int k=0; k<(int)state.size();k++) state[k]=true;
148 // here we loop over pairs of time slices, it is more convenient
149 // in order to extract the correlation matrix
150  for (int i=m_startTS; i<digi.size() && i<=m_endTS; i++) {
151  for(int flag=0; flag<4; flag++){
152  if(i+flag<digi.size() && i+flag<=m_endTS){
153  per2CapsHists(flag,0,digi.id(),digi.sample(i),digi.sample(i+flag),hbHists.PEDTRENDS,cond);
154  }
155  }
156  }
157  if(m_startTS==0 && m_endTS>4){
158  AllChanHists(digi.id(),digi.sample(0),digi.sample(1),digi.sample(2),digi.sample(3),digi.sample(4),digi.sample(5),hbHists.PEDTRENDS);
159  }
160  }
161  }
162  catch (int i ) {
163 // m_logFile<< "Event with " << i<<" HBHE Digis passed." << std::endl;
164  }
165  // HO
166  try{
167  if(!ho.size()) throw (int)ho.size();
168  for (HODigiCollection::const_iterator j=ho.begin(); j!=ho.end(); j++){
169  const HODataFrame digi = (const HODataFrame)(*j);
170  m_coder = cond.getHcalCoder(digi.id());
171  for (int i=m_startTS; i<digi.size() && i<=m_endTS; i++) {
172  for(int flag=0; flag<4; flag++){
173  if(i+flag<digi.size() && i+flag<=m_endTS){
174  per2CapsHists(flag,1,digi.id(),digi.sample(i),digi.sample(i+flag),hoHists.PEDTRENDS,cond);
175  }
176  }
177  }
178  if(m_startTS==0 && m_endTS>4){
179  AllChanHists(digi.id(),digi.sample(0),digi.sample(1),digi.sample(2),digi.sample(3),digi.sample(4),digi.sample(5),hoHists.PEDTRENDS);
180  }
181  }
182  }
183  catch (int i ) {
184 // m_logFile << "Event with " << i<<" HO Digis passed." << std::endl;
185  }
186  // HF
187  try{
188  if(!hf.size()) throw (int)hf.size();
189  for (HFDigiCollection::const_iterator j=hf.begin(); j!=hf.end(); j++){
190  const HFDataFrame digi = (const HFDataFrame)(*j);
191  m_coder = cond.getHcalCoder(digi.id());
192  for (int i=m_startTS; i<digi.size() && i<=m_endTS; i++) {
193  for(int flag=0; flag<4; flag++){
194  if(i+flag<digi.size() && i+flag<=m_endTS){
195  per2CapsHists(flag,2,digi.id(),digi.sample(i),digi.sample(i+flag),hfHists.PEDTRENDS,cond);
196  }
197  }
198  }
199  if(m_startTS==0 && m_endTS>4){
200  AllChanHists(digi.id(),digi.sample(0),digi.sample(1),digi.sample(2),digi.sample(3),digi.sample(4),digi.sample(5),hfHists.PEDTRENDS);
201  }
202  }
203  }
204  catch (int i ) {
205 // m_logFile << "Event with " << i<<" HF Digis passed." << std::endl;
206  }
207  // Call the function every m_nevtsample events
208  if(m_nevtsample>0) {
210  }
211 }
int i
Definition: DBlmapReader.cc:9
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)
int size() const
total number of samples in the digi
Definition: HBHEDataFrame.h:26
std::vector< HBHEDataFrame >::const_iterator const_iterator
struct HcalPedestalAnalysis::@57 hoHists
const HcalQIESample & sample(int i) const
access a sample
Definition: HODataFrame.h:40
std::vector< bool > state
const HcalDetId & id() const
Definition: HODataFrame.h:23
const HcalQIECoder * m_coder
const HcalQIEShape * m_shape
int size() const
total number of samples in the digi
Definition: HODataFrame.h:27
const HcalQIESample & sample(int i) const
access a sample
Definition: HFDataFrame.h:39
int j
Definition: DBlmapReader.cc:9
const_iterator end() const
int size() const
total number of samples in the digi
Definition: HFDataFrame.h:26
const HcalQIESample & sample(int i) const
access a sample
Definition: HBHEDataFrame.h:39
const HcalQIECoder * getHcalCoder(const HcalGenericDetId &fId) const
struct HcalPedestalAnalysis::@57 hfHists
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)
const HcalQIEShape * getHcalShape(const HcalGenericDetId &fId) const
size_type size() const
const HcalDetId & id() const
Definition: HBHEDataFrame.h:22
const HcalDetId & id() const
Definition: HFDataFrame.h:22
struct HcalPedestalAnalysis::@57 hbHists
const_iterator begin() const
void HcalPedestalAnalysis::SampleAnalysis ( )

Definition at line 331 of file HcalPedestalAnalysis.cc.

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

Referenced by done(), and processEvent().

331  {
332  // it is called every m_nevtsample events (a sample) and the end of run
333  char PedSampleNum[20];
334 
335 // Compute pedestal constants for each HBHE, HO, HF
336  sprintf(PedSampleNum,"HB_Sample%d",sample);
337  m_file->cd();
338  m_file->mkdir(PedSampleNum);
339  m_file->cd(PedSampleNum);
340  GetPedConst(hbHists.PEDTRENDS,hbHists.PEDMEAN,hbHists.PEDRMS);
341  sprintf(PedSampleNum,"HO_Sample%d",sample);
342  m_file->cd();
343  m_file->mkdir(PedSampleNum);
344  m_file->cd(PedSampleNum);
345  GetPedConst(hoHists.PEDTRENDS,hoHists.PEDMEAN,hoHists.PEDRMS);
346  sprintf(PedSampleNum,"HF_Sample%d",sample);
347  m_file->cd();
348  m_file->mkdir(PedSampleNum);
349  m_file->cd(PedSampleNum);
350  GetPedConst(hfHists.PEDTRENDS,hfHists.PEDMEAN,hfHists.PEDRMS);
351 }
struct HcalPedestalAnalysis::@57 hoHists
void GetPedConst(std::map< HcalDetId, std::map< int, PEDBUNCH > > &toolT, TH1F *PedMeans, TH1F *PedWidths)
struct HcalPedestalAnalysis::@57 hfHists
struct HcalPedestalAnalysis::@57 hbHists
void HcalPedestalAnalysis::setup ( const std::string &  m_outputFileROOT)

Definition at line 113 of file HcalPedestalAnalysis.cc.

References m_file.

113  {
114  // open the histogram file, create directories within
115  m_file=new TFile(m_outputFileROOT.c_str(),"RECREATE");
116  m_file->mkdir("HB");
117  m_file->cd();
118  m_file->mkdir("HO");
119  m_file->cd();
120  m_file->mkdir("HF");
121  m_file->cd();
122 }
void HcalPedestalAnalysis::Trendings ( std::map< HcalDetId, std::map< int, PEDBUNCH > > &  toolT,
TH1F *  Chi2,
TH1F *  CapidAverage,
TH1F *  CapidChi2 
)
private

Definition at line 598 of file HcalPedestalAnalysis.cc.

References _meot, begin, HcalDetId::depth(), cond::rpcobgas::detid, i, HcalDetId::ieta(), HcalDetId::iphi(), j, m_nevtsample, mergeVDriftHistosByStation::name, sample, and findQualityFiles::size.

Referenced by done().

598  {
599 
600 // check stability of pedestal constants in a single long run
601 
602  map<int, std::vector<double> > AverageValues;
603 
604  for(_meot=toolT.begin(); _meot!=toolT.end(); _meot++){
605  for(int i=0; i<4; i++){
606  char name[1024];
607  HcalDetId detid = _meot->first;
608  sprintf(name,"Pedestal trend, eta=%d phi=%d d=%d cap=%d",detid.ieta(),detid.iphi(),detid.depth(),i);
609  int bins = _meot->second[i].second.first[0].size();
610  float lo =0.5;
611  float hi = (float)bins+0.5;
612  _meot->second[i].second.second.push_back(new TH1F(name,name,bins,lo,hi));
613  sprintf(name,"Width trend, eta=%d phi=%d d=%d cap=%d",detid.ieta(),detid.iphi(),detid.depth(),i);
614  bins = _meot->second[i].second.first[2].size();
615  hi = (float)bins+0.5;
616  _meot->second[i].second.second.push_back(new TH1F(name,name,bins,lo,hi));
617  sprintf(name,"Correlation trend, eta=%d phi=%d d=%d caps=%d*%d",detid.ieta(),detid.iphi(),detid.depth(),i,(i+1)%4);
618  bins = _meot->second[i].second.first[5].size();
619  hi = (float)bins+0.5;
620  _meot->second[i].second.second.push_back(new TH1F(name,name,bins,lo,hi));
621 /* sprintf(name,"Correlation trend, eta=%d phi=%d d=%d caps=%d*%d",detid.ieta(),detid.iphi(),detid.depth(),i,(i+2)%4);
622  bins = _meot->second[i].second.first[7].size();
623  hi = (float)bins+0.5;
624  _meot->second[i].second.second.push_back(new TH1F(name,name,bins,lo,hi));
625  sprintf(name,"Correlation trend, eta=%d phi=%d d=%d caps=%d*%d",detid.ieta(),detid.iphi(),detid.depth(),i,(i+3)%4);
626  bins = _meot->second[i].second.first[9].size();
627  hi = (float)bins+0.5;
628  _meot->second[i].second.second.push_back(new TH1F(name,name,bins,lo,hi)); */
629 
630  std::vector<double>::iterator sample_it;
631  // Pedestal mean - put content and errors
632  int j=0;
633  for(sample_it=_meot->second[i].second.first[0].begin();
634  sample_it!=_meot->second[i].second.first[0].end();sample_it++){
635  _meot->second[i].second.second[0]->SetBinContent(++j,*sample_it);
636  }
637  j=0;
638  for(sample_it=_meot->second[i].second.first[1].begin();
639  sample_it!=_meot->second[i].second.first[1].end();sample_it++){
640  _meot->second[i].second.second[0]->SetBinError(++j,*sample_it);
641  }
642  // fit with a constant - extract parameters
643  _meot->second[i].second.second[0]->Fit("pol0","Q");
644  TF1 *fit = _meot->second[i].second.second[0]->GetFunction("pol0");
645  AverageValues[0].push_back(fit->GetParameter(0));
646  AverageValues[1].push_back(fit->GetParError(0));
647  if(sample>1)
648  AverageValues[2].push_back(fit->GetChisquare()/fit->GetNDF());
649  else
650  AverageValues[2].push_back(fit->GetChisquare());
651  sprintf(name,"Sample (%d events)",m_nevtsample);
652  _meot->second[i].second.second[0]->GetXaxis()->SetTitle(name);
653  _meot->second[i].second.second[0]->GetYaxis()->SetTitle("Pedestal value");
654  _meot->second[i].second.second[0]->Write();
655  // Pedestal width - put content and errors
656  j=0;
657  for(sample_it=_meot->second[i].second.first[2].begin();
658  sample_it!=_meot->second[i].second.first[2].end();sample_it++){
659  _meot->second[i].second.second[1]->SetBinContent(++j,*sample_it);
660  }
661  j=0;
662  for(sample_it=_meot->second[i].second.first[3].begin();
663  sample_it!=_meot->second[i].second.first[3].end();sample_it++){
664  _meot->second[i].second.second[1]->SetBinError(++j,*sample_it);
665  }
666  _meot->second[i].second.second[1]->GetXaxis()->SetTitle(name);
667  _meot->second[i].second.second[1]->GetYaxis()->SetTitle("Pedestal width");
668  _meot->second[i].second.second[1]->Write();
669  // Correlation coeffs - put contents and errors
670  j=0;
671  for(sample_it=_meot->second[i].second.first[5].begin();
672  sample_it!=_meot->second[i].second.first[5].end();sample_it++){
673  _meot->second[i].second.second[2]->SetBinContent(++j,*sample_it);
674  }
675  j=0;
676  for(sample_it=_meot->second[i].second.first[6].begin();
677  sample_it!=_meot->second[i].second.first[6].end();sample_it++){
678  _meot->second[i].second.second[2]->SetBinError(++j,*sample_it);
679  }
680  _meot->second[i].second.second[2]->GetXaxis()->SetTitle(name);
681  _meot->second[i].second.second[2]->GetYaxis()->SetTitle("Close correlation");
682  _meot->second[i].second.second[2]->Write();
683  /* j=0;
684  for(sample_it=_meot->second[i].second.first[7].begin();
685  sample_it!=_meot->second[i].second.first[7].end();sample_it++){
686  _meot->second[i].second.second[3]->SetBinContent(++j,*sample_it);
687  }
688  j=0;
689  for(sample_it=_meot->second[i].second.first[8].begin();
690  sample_it!=_meot->second[i].second.first[8].end();sample_it++){
691  _meot->second[i].second.second[3]->SetBinError(++j,*sample_it);
692  }
693  _meot->second[i].second.second[3]->GetXaxis()->SetTitle(name);
694  _meot->second[i].second.second[3]->GetYaxis()->SetTitle("Intermediate correlation");
695  _meot->second[i].second.second[3]->Write();
696  j=0;
697  for(sample_it=_meot->second[i].second.first[9].begin();
698  sample_it!=_meot->second[i].second.first[9].end();sample_it++){
699  _meot->second[i].second.second[4]->SetBinContent(++j,*sample_it);
700  }
701  j=0;
702  for(sample_it=_meot->second[i].second.first[10].begin();
703  sample_it!=_meot->second[i].second.first[10].end();sample_it++){
704  _meot->second[i].second.second[4]->SetBinError(++j,*sample_it);
705  }
706  _meot->second[i].second.second[4]->GetXaxis()->SetTitle(name);
707  _meot->second[i].second.second[4]->GetYaxis()->SetTitle("Distant correlation");
708  _meot->second[i].second.second[4]->Write(); */
709  // chi2
710  j=0;
711  for(sample_it=_meot->second[i].second.first[4].begin();
712  sample_it!=_meot->second[i].second.first[4].end();sample_it++){
713  Chi2->Fill(*sample_it);
714  }
715  }
716  }
717  CapidAverage= new TH1F("Constant fit: Pedestal Values",
718  "Constant fit: Pedestal Values",
719  AverageValues[0].size(),0.,AverageValues[0].size());
720  std::vector<double>::iterator sample_it;
721  int j=0;
722  for(sample_it=AverageValues[0].begin();
723  sample_it!=AverageValues[0].end();sample_it++){
724  CapidAverage->SetBinContent(++j,*sample_it);
725  }
726  j=0;
727  for(sample_it=AverageValues[1].begin();
728  sample_it!=AverageValues[1].end();sample_it++){
729  CapidAverage->SetBinError(++j,*sample_it);
730  }
731  CapidChi2= new TH1F("Constant fit: Chi2/ndf",
732  "Constant fit: Chi2/ndf",
733  AverageValues[2].size(),0.,AverageValues[2].size());
734  j=0;
735  for(sample_it=AverageValues[2].begin();
736  sample_it!=AverageValues[2].end();sample_it++){
737  CapidChi2->SetBinContent(++j,*sample_it);
738  //CapidChi2->SetBinError(++j,0);
739  }
740  Chi2->GetXaxis()->SetTitle("Chi2/ndf");
741  Chi2->GetYaxis()->SetTitle("50 x [(16+2) x 4 x 4] `events`");
742  Chi2->Write();
743  CapidAverage->GetYaxis()->SetTitle("Pedestal value");
744  CapidAverage->GetXaxis()->SetTitle("(16+2) x 4 x 4 `events`");
745  CapidAverage->Write();
746  CapidChi2->GetYaxis()->SetTitle("Chi2/ndf");
747  CapidChi2->GetXaxis()->SetTitle("(16+2) x 4 x 4 `events`");
748  CapidChi2->Write();
749 
750 }
int i
Definition: DBlmapReader.cc:9
int depth() const
get the tower depth
Definition: HcalDetId.h:55
int ieta() const
get the cell ieta
Definition: HcalDetId.h:51
int j
Definition: DBlmapReader.cc:9
int iphi() const
get the cell iphi
Definition: HcalDetId.h:53
std::map< HcalDetId, std::map< int, PEDBUNCH > >::iterator _meot
#define begin
Definition: vmac.h:30
Definition: Chi2.h:17
tuple size
Write out results.

Member Data Documentation

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

Definition at line 117 of file HcalPedestalAnalysis.h.

TH1F* HcalPedestalAnalysis::CAPID_AVERAGE

Definition at line 121 of file HcalPedestalAnalysis.h.

TH1F* HcalPedestalAnalysis::CAPID_CHI2

Definition at line 122 of file HcalPedestalAnalysis.h.

TH1F* HcalPedestalAnalysis::CHI2

Definition at line 120 of file HcalPedestalAnalysis.h.

int HcalPedestalAnalysis::evt
private

Definition at line 131 of file HcalPedestalAnalysis.h.

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

int HcalPedestalAnalysis::evt_curr
private

Definition at line 133 of file HcalPedestalAnalysis.h.

Referenced by processEvent().

const int HcalPedestalAnalysis::fitflag =0
staticprivate

Definition at line 138 of file HcalPedestalAnalysis.h.

Referenced by GetPedConst().

HcalPedestals* HcalPedestalAnalysis::fRawPedestals
private

Definition at line 127 of file HcalPedestalAnalysis.h.

Referenced by done(), and GetPedConst().

HcalPedestalWidths* HcalPedestalAnalysis::fRawPedestalWidths
private

Definition at line 128 of file HcalPedestalAnalysis.h.

Referenced by done(), and GetPedConst().

const HcalPedestals* HcalPedestalAnalysis::fRefPedestals
private

Definition at line 125 of file HcalPedestalAnalysis.h.

Referenced by done().

const HcalPedestalWidths* HcalPedestalAnalysis::fRefPedestalWidths
private

Definition at line 126 of file HcalPedestalAnalysis.h.

Referenced by done().

HcalTopology* HcalPedestalAnalysis::fTopology
private

Definition at line 136 of file HcalPedestalAnalysis.h.

Referenced by done(), and HcalPedestalAnalysis().

HcalPedestals* HcalPedestalAnalysis::fValPedestals
private

Definition at line 129 of file HcalPedestalAnalysis.h.

Referenced by done().

HcalPedestalWidths* HcalPedestalAnalysis::fValPedestalWidths
private

Definition at line 130 of file HcalPedestalAnalysis.h.

Referenced by done().

struct { ... } HcalPedestalAnalysis::hbHists
struct { ... } HcalPedestalAnalysis::hfHists
struct { ... } HcalPedestalAnalysis::hoHists
int HcalPedestalAnalysis::m_AllPedsOK
private

Definition at line 111 of file HcalPedestalAnalysis.h.

Referenced by done(), and HcalPedestalAnalysis().

const HcalQIECoder* HcalPedestalAnalysis::m_coder
private

Definition at line 114 of file HcalPedestalAnalysis.h.

Referenced by HcalPedestalAnalysis(), and processEvent().

int HcalPedestalAnalysis::m_endTS
private

Definition at line 106 of file HcalPedestalAnalysis.h.

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

TFile* HcalPedestalAnalysis::m_file
private

Definition at line 99 of file HcalPedestalAnalysis.h.

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

int HcalPedestalAnalysis::m_hiSaveflag
private

Definition at line 109 of file HcalPedestalAnalysis.h.

Referenced by GetPedConst(), and HcalPedestalAnalysis().

std::ofstream HcalPedestalAnalysis::m_logFile
private

Definition at line 104 of file HcalPedestalAnalysis.h.

int HcalPedestalAnalysis::m_nevtsample
private
std::string HcalPedestalAnalysis::m_outputFileMean
private

Definition at line 102 of file HcalPedestalAnalysis.h.

Referenced by HcalPedestalAnalysis().

std::string HcalPedestalAnalysis::m_outputFileROOT
private

Definition at line 101 of file HcalPedestalAnalysis.h.

Referenced by done(), and HcalPedestalAnalysis().

std::string HcalPedestalAnalysis::m_outputFileWidth
private

Definition at line 103 of file HcalPedestalAnalysis.h.

Referenced by HcalPedestalAnalysis().

int HcalPedestalAnalysis::m_pedsinADC
private

Definition at line 108 of file HcalPedestalAnalysis.h.

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

int HcalPedestalAnalysis::m_pedValflag
private

Definition at line 110 of file HcalPedestalAnalysis.h.

Referenced by done(), and HcalPedestalAnalysis().

const HcalQIEShape* HcalPedestalAnalysis::m_shape
private

Definition at line 113 of file HcalPedestalAnalysis.h.

Referenced by HcalPedestalAnalysis(), and processEvent().

int HcalPedestalAnalysis::m_startTS
private

Definition at line 105 of file HcalPedestalAnalysis.h.

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

float HcalPedestalAnalysis::m_stat[4]
private

Definition at line 134 of file HcalPedestalAnalysis.h.

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

TH1F* HcalPedestalAnalysis::PEDMEAN

Definition at line 119 of file HcalPedestalAnalysis.h.

TH1F* HcalPedestalAnalysis::PEDRMS

Definition at line 118 of file HcalPedestalAnalysis.h.

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

Definition at line 116 of file HcalPedestalAnalysis.h.

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

Definition at line 135 of file HcalPedestalAnalysis.h.

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