CMS 3D CMS Logo

HcalPedestalAnalysis.h
Go to the documentation of this file.
1 #ifndef HcalPedestalAnalysis_H
2 #define HcalPedestalAnalysis_H
3 
13 
15 
16 #include "TH1F.h"
17 #include "TF1.h"
18 
19 #include <memory>
20 //#include <iostream>
21 #include <fstream>
22 #include <vector>
23 #include <string>
24 
25 // User switches for HcalPedestalAnalysis to set in cfg are:
26 // nevtsample - number of events per sample in which data will be divided
27 // for stability checks (default: 0 = do not use),
28 // hiSaveflag - flag to save histos of charge per cap-id (default: 0),
29 // pedValflag - pedestal validation flag:
30 // 0 - write out current raw constants (default)
31 // 1 - write out validated constants
32 
33 class HcalDbService;
34 class TFile;
35 
37 public:
42 
43  void setup(const std::string& m_outputFileROOT);
44 
45  void SampleAnalysis();
46 
47  void setTopology(const HcalTopology* htopo) { fTopology = htopo; }
48 
49  int done(const HcalPedestals* fInputPedestals,
50  const HcalPedestalWidths* fInputWidths,
51  HcalPedestals* fOutputPedestals,
52  HcalPedestalWidths* fOutputWidths);
53 
55  const HODigiCollection& ho,
56  const HFDigiCollection& hf,
57  const HcalDbService& cond);
58 
59  // pedestal validation: HcalPedVal=-1 means not validated,
60  // 0 everything OK,
61  // N>0 : mod(N,100000) drifts + width changes
62  // int(N/100000) missing channels
63  static int HcalPedVal(int nstat[4],
70 
71 protected:
72 private:
73  //###
74  //# PEDBUNCH is used in map<HcalDetId,map<int, PEDBUNCH > > PEDTRENDS;
75  //# For each HcalDetId (channel) a map<int, PEDBUNCH> is associated;
76  //# int is cap-id (1-4);
77  //# PEDBUNCH is a pair - first element is the main
78  //# histo with the pedestal distribution and second one is another pair;
79  //# this pair contains map<int, std::vector<double> > as a first element;
80  //# int is cap-id, and vector contains some useful variables;
81  //# the second element is a vector of histos (pointers);
82  //# for the "trend" analysis the main histo (with pedestals) is reset every
83  //# nevt_ped events and info is put in the other part of the PEDBUNCH;
84  //# so at the end we have the trends for the variables in concern
85  //# which are written in THE vector<TH1F*>;
86  //###
87  typedef std::pair<TH1F*, std::pair<std::map<int, std::vector<double> >, std::vector<TH1F*> > > PEDBUNCH;
88 
89  void per2CapsHists(int flag,
90  int id,
91  const HcalDetId detid,
92  const HcalQIESample& qie1,
93  const HcalQIESample& qie2,
94  std::map<HcalDetId, std::map<int, PEDBUNCH> >& toolT,
95  const HcalDbService& cond);
96 
97  void GetPedConst(std::map<HcalDetId, std::map<int, PEDBUNCH> >& toolT, TH1F* PedMeans, TH1F* PedWidths);
98 
99  void Trendings(std::map<HcalDetId, std::map<int, PEDBUNCH> >& toolT, TH1F* Chi2, TH1F* CapidAverage, TH1F* CapidChi2);
100 
101  void AllChanHists(const HcalDetId detid,
102  const HcalQIESample& qie0,
103  const HcalQIESample& qie1,
104  const HcalQIESample& qie2,
105  const HcalQIESample& qie3,
106  const HcalQIESample& qie4,
107  const HcalQIESample& qie5,
108  std::map<HcalDetId, std::map<int, PEDBUNCH> >& toolT);
109 
110  TFile* m_file;
111 
115  std::ofstream m_logFile;
117  int m_endTS;
123 
126  struct {
127  std::map<HcalDetId, std::map<int, PEDBUNCH> > PEDTRENDS;
128  TH1F* ALLPEDS;
129  TH1F* PEDRMS;
130  TH1F* PEDMEAN;
131  TH1F* CHI2;
133  TH1F* CAPID_CHI2;
134  } hbHists, hfHists, hoHists;
135  std::map<HcalDetId, std::map<int, PEDBUNCH> >::iterator _meot;
142  int evt;
143  int sample;
144  int evt_curr;
145  float m_stat[4];
146  std::vector<bool> state;
148  // flag to make gaussian fits to charge dists
149  static const int fitflag = 0;
150 };
151 
152 #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.
const HcalTopology * fTopology
struct HcalPedestalAnalysis::@57 hoHists
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)
std::map< HcalDetId, std::map< int, PEDBUNCH > >::iterator _meot
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
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)
std::pair< TH1F *, std::pair< std::map< int, std::vector< double > >, std::vector< TH1F * > > > PEDBUNCH
Definition: plugin.cc:23
const HcalPedestals * fRefPedestals
HcalPedestalWidths * fValPedestalWidths
std::map< HcalDetId, std::map< int, PEDBUNCH > > PEDTRENDS
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