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
 
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, edm::ParameterSet::getUntrackedParameter(), hbHists, hfHists, hoHists, i, gen::k, m_AllPedsOK, m_endTS, m_file, m_hiSaveflag, m_nevtsample, m_outputFileMean, m_outputFileROOT, m_outputFileWidth, m_pedsinADC, m_pedValflag, m_startTS, m_stat, sample, and state.

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

Destructor.

Definition at line 80 of file HcalPedestalAnalysis.cc.

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

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

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

References _meot, and HcalQIESample::adc().

Referenced by processEvent().

314  {
315 
316 // this function is due to be called for every channel
317 
318  _meot = toolT.find(detid);
319  map<int,PEDBUNCH> _mei = _meot->second;
320  _mei[16].first->Fill(qie4.adc()+qie5.adc()-1.);
321  _mei[17].first->Fill(qie4.adc()+qie5.adc()-qie2.adc()-qie3.adc());
322  _mei[18].first->Fill(qie4.adc()+qie5.adc()-(qie0.adc()+qie1.adc()+qie2.adc()+qie3.adc())/2.);
323 }
int adc() const
get the ADC sample
Definition: HcalQIESample.h:24
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 501 of file HcalPedestalAnalysis.cc.

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

Referenced by HcalPedestalAnalyzer::endJob().

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

Definition at line 349 of file HcalPedestalAnalysis.cc.

References _meot, HcalCondObjectContainer< Item >::addValues(), 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().

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

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

Referenced by done(), and main().

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

References _meot, HcalQIESample::adc(), combineCards::bins, 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().

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

Referenced by HcalPedestalAnalyzer::analyze().

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

Definition at line 326 of file HcalPedestalAnalysis.cc.

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

Referenced by done(), and processEvent().

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

Definition at line 108 of file HcalPedestalAnalysis.cc.

References m_file.

Referenced by BeautifulSoup.Tag::_invert(), and HcalPedestalAnalyzer::HcalPedestalAnalyzer().

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

Definition at line 593 of file HcalPedestalAnalysis.cc.

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

Referenced by done().

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

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 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 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().