CMS 3D CMS Logo

HcalPedestalAnalysis.h
Go to the documentation of this file.
1 #ifndef HcalPedestalAnalysis_H
2 #define HcalPedestalAnalysis_H
3 
4 
14 
16 
17 #include "TH1F.h"
18 #include "TF1.h"
19 
20 #include <memory>
21 //#include <iostream>
22 #include <fstream>
23 #include <vector>
24 #include <string>
25 
26 // User switches for HcalPedestalAnalysis to set in cfg are:
27 // nevtsample - number of events per sample in which data will be divided
28 // for stability checks (default: 0 = do not use),
29 // hiSaveflag - flag to save histos of charge per cap-id (default: 0),
30 // pedValflag - pedestal validation flag:
31 // 0 - write out current raw constants (default)
32 // 1 - write out validated constants
33 
34 class HcalDbService;
35 class TFile;
36 
38 
39 public:
40 
45 
46  void setup(const std::string& m_outputFileROOT);
47 
48  void SampleAnalysis();
49 
50  void setTopology(const HcalTopology* htopo) {fTopology = htopo;}
51 
52  int done(const HcalPedestals* fInputPedestals,
53  const HcalPedestalWidths* fInputWidths,
54  HcalPedestals* fOutputPedestals,
55  HcalPedestalWidths* fOutputWidths);
56 
58  const HODigiCollection& ho,
59  const HFDigiCollection& hf,
60  const HcalDbService& cond);
61 
62 // pedestal validation: HcalPedVal=-1 means not validated,
63 // 0 everything OK,
64 // N>0 : mod(N,100000) drifts + width changes
65 // int(N/100000) missing channels
66  static int HcalPedVal(int nstat[4], const HcalPedestals* fRefPedestals,
72 
73 protected:
74 
75 
76 private:
77  //###
78  //# PEDBUNCH is used in map<HcalDetId,map<int, PEDBUNCH > > PEDTRENDS;
79  //# For each HcalDetId (channel) a map<int, PEDBUNCH> is associated;
80  //# int is cap-id (1-4);
81  //# PEDBUNCH is a pair - first element is the main
82  //# histo with the pedestal distribution and second one is another pair;
83  //# this pair contains map<int, std::vector<double> > as a first element;
84  //# int is cap-id, and vector contains some useful variables;
85  //# the second element is a vector of histos (pointers);
86  //# for the "trend" analysis the main histo (with pedestals) is reset every
87  //# nevt_ped events and info is put in the other part of the PEDBUNCH;
88  //# so at the end we have the trends for the variables in concern
89  //# which are written in THE vector<TH1F*>;
90  //###
91  typedef std::pair<TH1F*,std::pair<std::map<int, std::vector<double> >,std::vector<TH1F*> > > PEDBUNCH;
92 
93  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);
94 
95  void GetPedConst(std::map<HcalDetId,std::map<int, PEDBUNCH > > &toolT, TH1F* PedMeans, TH1F* PedWidths);
96 
97  void Trendings(std::map<HcalDetId,std::map<int, PEDBUNCH > > &toolT, TH1F* Chi2, TH1F* CapidAverage, TH1F* CapidChi2);
98 
99  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);
100 
101  TFile* m_file;
102 
106  std::ofstream m_logFile;
108  int m_endTS;
114 
117  struct{
118  std::map<HcalDetId,std::map<int, PEDBUNCH > > PEDTRENDS;
119  TH1F* ALLPEDS;
120  TH1F* PEDRMS;
121  TH1F* PEDMEAN;
122  TH1F* CHI2;
124  TH1F* CAPID_CHI2;
125  } hbHists, hfHists, hoHists;
126  std::map<HcalDetId,std::map<int, PEDBUNCH > >::iterator _meot;
133  int evt;
134  int sample;
135  int evt_curr;
136  float m_stat[4];
137  std::vector<bool> state;
139 // flag to make gaussian fits to charge dists
140  static const int fitflag=0;
141 };
142 
143 #endif
HcalPedestals * fRawPedestals
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)
HcalPedestalAnalysis(const edm::ParameterSet &ps)
Constructor.
std::pair< TH1F *, std::pair< std::map< int, std::vector< double > >, std::vector< TH1F * > > > PEDBUNCH
const HcalTopology * fTopology
struct HcalPedestalAnalysis::@57 hoHists
std::map< HcalDetId, std::map< int, PEDBUNCH > > PEDTRENDS
std::vector< bool > state
const HcalPedestalWidths * fRefPedestalWidths
void setTopology(const HcalTopology *htopo)
void processEvent(const HBHEDigiCollection &hbhe, const HODigiCollection &ho, const HFDigiCollection &hf, const HcalDbService &cond)
const HcalQIECoder * m_coder
~HcalPedestalAnalysis()
Destructor.
int done(const HcalPedestals *fInputPedestals, const HcalPedestalWidths *fInputWidths, HcalPedestals *fOutputPedestals, HcalPedestalWidths *fOutputWidths)
const HcalQIEShape * m_shape
void GetPedConst(std::map< HcalDetId, std::map< int, PEDBUNCH > > &toolT, TH1F *PedMeans, TH1F *PedWidths)
void setup(const std::string &m_outputFileROOT)
HcalPedestals * fValPedestals
std::map< HcalDetId, std::map< int, PEDBUNCH > >::iterator _meot
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)
Definition: plugin.cc:24
const HcalPedestals * fRefPedestals
HcalPedestalWidths * fValPedestalWidths
Definition: Chi2.h:15
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