CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  int done(const HcalPedestals* fInputPedestals,
51  const HcalPedestalWidths* fInputWidths,
52  HcalPedestals* fOutputPedestals,
53  HcalPedestalWidths* fOutputWidths);
54 
55  void processEvent(const HBHEDigiCollection& hbhe,
56  const HODigiCollection& ho,
57  const HFDigiCollection& hf,
58  const HcalDbService& cond);
59 
60 // pedestal validation: HcalPedVal=-1 means not validated,
61 // 0 everything OK,
62 // N>0 : mod(N,100000) drifts + width changes
63 // int(N/100000) missing channels
64  static int HcalPedVal(int nstat[4], const HcalPedestals* fRefPedestals,
70 
71 protected:
72 
73 
74 private:
75  //###
76  //# PEDBUNCH is used in map<HcalDetId,map<int, PEDBUNCH > > PEDTRENDS;
77  //# For each HcalDetId (channel) a map<int, PEDBUNCH> is associated;
78  //# int is cap-id (1-4);
79  //# PEDBUNCH is a pair - first element is the main
80  //# histo with the pedestal distribution and second one is another pair;
81  //# this pair contains map<int, std::vector<double> > as a first element;
82  //# int is cap-id, and vector contains some useful variables;
83  //# the second element is a vector of histos (pointers);
84  //# for the "trend" analysis the main histo (with pedestals) is reset every
85  //# nevt_ped events and info is put in the other part of the PEDBUNCH;
86  //# so at the end we have the trends for the variables in concern
87  //# which are written in THE vector<TH1F*>;
88  //###
89  typedef std::pair<TH1F*,std::pair<std::map<int, std::vector<double> >,std::vector<TH1F*> > > PEDBUNCH;
90 
91  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);
92 
93  void GetPedConst(std::map<HcalDetId,std::map<int, PEDBUNCH > > &toolT, TH1F* PedMeans, TH1F* PedWidths);
94 
95  void Trendings(std::map<HcalDetId,std::map<int, PEDBUNCH > > &toolT, TH1F* Chi2, TH1F* CapidAverage, TH1F* CapidChi2);
96 
97  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);
98 
99  TFile* m_file;
100 
104  std::ofstream m_logFile;
106  int m_endTS;
112 
115  struct{
116  std::map<HcalDetId,std::map<int, PEDBUNCH > > PEDTRENDS;
117  TH1F* ALLPEDS;
118  TH1F* PEDRMS;
119  TH1F* PEDMEAN;
120  TH1F* CHI2;
122  TH1F* CAPID_CHI2;
123  } hbHists, hfHists, hoHists;
124  std::map<HcalDetId,std::map<int, PEDBUNCH > >::iterator _meot;
131  int evt;
132  int sample;
133  int evt_curr;
134  float m_stat[4];
135  std::vector<bool> state;
137 // flag to make gaussian fits to charge dists
138  static const int fitflag=0;
139 };
140 
141 #endif
struct HcalPedestalAnalysis::@52 hfHists
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.
struct HcalPedestalAnalysis::@52 hbHists
std::pair< TH1F *, std::pair< std::map< int, std::vector< double > >, std::vector< TH1F * > > > PEDBUNCH
std::map< HcalDetId, std::map< int, PEDBUNCH > > PEDTRENDS
std::vector< bool > state
const HcalPedestalWidths * fRefPedestalWidths
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)
struct HcalPedestalAnalysis::@52 hoHists
HcalPedestals * fValPedestals
std::map< HcalDetId, std::map< int, PEDBUNCH > >::iterator _meot
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 HcalPedestals * fRefPedestals
HcalPedestalWidths * fValPedestalWidths
Definition: Chi2.h:17
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)