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 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 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 91 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, edm::ParameterSet::getUntrackedParameter(), hbHists, hfHists, hoHists, i, relval_steps::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 (0),
19  fRawPedestals (0),
21  fValPedestals (0),
23  fTopology(0)
24 {
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 
64 // m_logFile.open("HcalPedestalAnalysis.log");
65 
66  hbHists.ALLPEDS = new TH1F("HBHE All Pedestals","HBHE All Peds",10,0,9);
67  hbHists.PEDRMS= new TH1F("HBHE All Pedestal Widths","HBHE All Pedestal RMS",100,0,3);
68  hbHists.PEDMEAN= new TH1F("HBHE All Pedestal Means","HBHE All Pedestal Means",100,0,9);
69  hbHists.CHI2= new TH1F("HBHE Chi2/ndf for whole range Gauss fit","HBHE Chi2/ndf Gauss",200,0.,50.);
70 
71  hoHists.ALLPEDS = new TH1F("HO All Pedestals","HO All Peds",10,0,9);
72  hoHists.PEDRMS= new TH1F("HO All Pedestal Widths","HO All Pedestal RMS",100,0,3);
73  hoHists.PEDMEAN= new TH1F("HO All Pedestal Means","HO All Pedestal Means",100,0,9);
74  hoHists.CHI2= new TH1F("HO Chi2/ndf for whole range Gauss fit","HO Chi2/ndf Gauss",200,0.,50.);
75 
76  hfHists.ALLPEDS = new TH1F("HF All Pedestals","HF All Peds",10,0,9);
77  hfHists.PEDRMS= new TH1F("HF All Pedestal Widths","HF All Pedestal RMS",100,0,3);
78  hfHists.PEDMEAN= new TH1F("HF All Pedestal Means","HF All Pedestal Means",100,0,9);
79  hfHists.CHI2= new TH1F("HF Chi2/ndf for whole range Gauss fit","HF Chi2/ndf Gauss",200,0.,50.);
80 }
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
HcalPedestals * fRawPedestals
const HcalTopology * fTopology
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 83 of file HcalPedestalAnalysis.cc.

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

83  {
84 
85  for(_meot=hbHists.PEDTRENDS.begin(); _meot!=hbHists.PEDTRENDS.end(); _meot++){
86  for(int i=0; i<16; i++) _meot->second[i].first->Delete();
87  }
88  for(_meot=hoHists.PEDTRENDS.begin(); _meot!=hoHists.PEDTRENDS.end(); _meot++){
89  for(int i=0; i<16; i++) _meot->second[i].first->Delete();
90  }
91  for(_meot=hfHists.PEDTRENDS.begin(); _meot!=hfHists.PEDTRENDS.end(); _meot++){
92  for(int i=0; i<16; i++) _meot->second[i].first->Delete();
93  }
94  hbHists.ALLPEDS->Delete();
95  hbHists.PEDRMS->Delete();
96  hbHists.PEDMEAN->Delete();
97  hbHists.CHI2->Delete();
98 
99  hoHists.ALLPEDS->Delete();
100  hoHists.PEDRMS->Delete();
101  hoHists.PEDMEAN->Delete();
102  hoHists.CHI2->Delete();
103 
104  hfHists.ALLPEDS->Delete();
105  hfHists.PEDRMS->Delete();
106  hfHists.PEDMEAN->Delete();
107  hfHists.CHI2->Delete();
108 }
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 317 of file HcalPedestalAnalysis.cc.

References _meot, and HcalQIESample::adc().

Referenced by processEvent().

317  {
318 
319 // this function is due to be called for every channel
320 
321  _meot = toolT.find(detid);
322  map<int,PEDBUNCH> _mei = _meot->second;
323  _mei[16].first->Fill(qie4.adc()+qie5.adc()-1.);
324  _mei[17].first->Fill(qie4.adc()+qie5.adc()-qie2.adc()-qie3.adc());
325  _mei[18].first->Fill(qie4.adc()+qie5.adc()-(qie0.adc()+qie1.adc()+qie2.adc()+qie3.adc())/2.);
326 }
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 504 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().

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

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

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

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

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

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

Referenced by done(), and processEvent().

329  {
330  // it is called every m_nevtsample events (a sample) and the end of run
331  char PedSampleNum[20];
332 
333 // Compute pedestal constants for each HBHE, HO, HF
334  sprintf(PedSampleNum,"HB_Sample%d",sample);
335  m_file->cd();
336  m_file->mkdir(PedSampleNum);
337  m_file->cd(PedSampleNum);
338  GetPedConst(hbHists.PEDTRENDS,hbHists.PEDMEAN,hbHists.PEDRMS);
339  sprintf(PedSampleNum,"HO_Sample%d",sample);
340  m_file->cd();
341  m_file->mkdir(PedSampleNum);
342  m_file->cd(PedSampleNum);
343  GetPedConst(hoHists.PEDTRENDS,hoHists.PEDMEAN,hoHists.PEDRMS);
344  sprintf(PedSampleNum,"HF_Sample%d",sample);
345  m_file->cd();
346  m_file->mkdir(PedSampleNum);
347  m_file->cd(PedSampleNum);
348  GetPedConst(hfHists.PEDTRENDS,hfHists.PEDMEAN,hfHists.PEDRMS);
349 }
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::setTopology ( const HcalTopology htopo)
inline

Definition at line 50 of file HcalPedestalAnalysis.h.

References fTopology.

50 {fTopology = htopo;}
const HcalTopology * fTopology
void HcalPedestalAnalysis::setup ( const std::string &  m_outputFileROOT)

Definition at line 111 of file HcalPedestalAnalysis.cc.

References m_file.

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

Definition at line 596 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().

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

TH1F* HcalPedestalAnalysis::CAPID_AVERAGE

Definition at line 123 of file HcalPedestalAnalysis.h.

TH1F* HcalPedestalAnalysis::CAPID_CHI2

Definition at line 124 of file HcalPedestalAnalysis.h.

TH1F* HcalPedestalAnalysis::CHI2

Definition at line 122 of file HcalPedestalAnalysis.h.

int HcalPedestalAnalysis::evt
private

Definition at line 133 of file HcalPedestalAnalysis.h.

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

int HcalPedestalAnalysis::evt_curr
private

Definition at line 135 of file HcalPedestalAnalysis.h.

Referenced by processEvent().

const int HcalPedestalAnalysis::fitflag =0
staticprivate

Definition at line 140 of file HcalPedestalAnalysis.h.

Referenced by GetPedConst().

HcalPedestals* HcalPedestalAnalysis::fRawPedestals
private

Definition at line 129 of file HcalPedestalAnalysis.h.

Referenced by done(), and GetPedConst().

HcalPedestalWidths* HcalPedestalAnalysis::fRawPedestalWidths
private

Definition at line 130 of file HcalPedestalAnalysis.h.

Referenced by done(), and GetPedConst().

const HcalPedestals* HcalPedestalAnalysis::fRefPedestals
private

Definition at line 127 of file HcalPedestalAnalysis.h.

Referenced by done().

const HcalPedestalWidths* HcalPedestalAnalysis::fRefPedestalWidths
private

Definition at line 128 of file HcalPedestalAnalysis.h.

Referenced by done().

const HcalTopology* HcalPedestalAnalysis::fTopology
private

Definition at line 138 of file HcalPedestalAnalysis.h.

Referenced by done(), and setTopology().

HcalPedestals* HcalPedestalAnalysis::fValPedestals
private

Definition at line 131 of file HcalPedestalAnalysis.h.

Referenced by done().

HcalPedestalWidths* HcalPedestalAnalysis::fValPedestalWidths
private

Definition at line 132 of file HcalPedestalAnalysis.h.

Referenced by done().

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

Definition at line 113 of file HcalPedestalAnalysis.h.

Referenced by done(), and HcalPedestalAnalysis().

const HcalQIECoder* HcalPedestalAnalysis::m_coder
private

Definition at line 116 of file HcalPedestalAnalysis.h.

Referenced by HcalPedestalAnalysis(), and processEvent().

int HcalPedestalAnalysis::m_endTS
private

Definition at line 108 of file HcalPedestalAnalysis.h.

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

TFile* HcalPedestalAnalysis::m_file
private

Definition at line 101 of file HcalPedestalAnalysis.h.

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

int HcalPedestalAnalysis::m_hiSaveflag
private

Definition at line 111 of file HcalPedestalAnalysis.h.

Referenced by GetPedConst(), and HcalPedestalAnalysis().

std::ofstream HcalPedestalAnalysis::m_logFile
private

Definition at line 106 of file HcalPedestalAnalysis.h.

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

Definition at line 104 of file HcalPedestalAnalysis.h.

Referenced by HcalPedestalAnalysis().

std::string HcalPedestalAnalysis::m_outputFileROOT
private

Definition at line 103 of file HcalPedestalAnalysis.h.

Referenced by done(), and HcalPedestalAnalysis().

std::string HcalPedestalAnalysis::m_outputFileWidth
private

Definition at line 105 of file HcalPedestalAnalysis.h.

Referenced by HcalPedestalAnalysis().

int HcalPedestalAnalysis::m_pedsinADC
private

Definition at line 110 of file HcalPedestalAnalysis.h.

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

int HcalPedestalAnalysis::m_pedValflag
private

Definition at line 112 of file HcalPedestalAnalysis.h.

Referenced by done(), and HcalPedestalAnalysis().

const HcalQIEShape* HcalPedestalAnalysis::m_shape
private

Definition at line 115 of file HcalPedestalAnalysis.h.

Referenced by HcalPedestalAnalysis(), and processEvent().

int HcalPedestalAnalysis::m_startTS
private

Definition at line 107 of file HcalPedestalAnalysis.h.

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

float HcalPedestalAnalysis::m_stat[4]
private

Definition at line 136 of file HcalPedestalAnalysis.h.

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

TH1F* HcalPedestalAnalysis::PEDMEAN

Definition at line 121 of file HcalPedestalAnalysis.h.

TH1F* HcalPedestalAnalysis::PEDRMS

Definition at line 120 of file HcalPedestalAnalysis.h.

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

Definition at line 118 of file HcalPedestalAnalysis.h.

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

Definition at line 137 of file HcalPedestalAnalysis.h.

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