CMS 3D CMS Logo

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