CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
CastorPedestalAnalysis.h
Go to the documentation of this file.
1 #ifndef CastorPedestalAnalysis_H
2 #define CastorPedestalAnalysis_H
3 
12 
13 #include "TH1F.h"
14 #include "TF1.h"
15 
16 #include <memory>
17 //#include <iostream>
18 #include <fstream>
19 #include <vector>
20 #include <string>
21 
22 // User switches for CastorPedestalAnalysis to set in cfg are:
23 // nevtsample - number of events per sample in which data will be divided
24 // for stability checks (default: 0 = do not use),
25 // hiSaveflag - flag to save histos of charge per cap-id (default: 0),
26 // pedValflag - pedestal validation flag:
27 // 0 - write out current raw constants (default)
28 // 1 - write out validated constants
29 
30 class CastorPedestals;
32 class CastorDbService;
33 class CastorQIEShape;
34 class CastorQIECoder;
35 class TFile;
37 public:
42 
43  void setup(const std::string& m_outputFileROOT);
44 
45  void SampleAnalysis();
46 
47  int done(const CastorPedestals* fInputPedestals,
48  const CastorPedestalWidths* fInputWidths,
49  CastorPedestals* fOutputPedestals,
50  CastorPedestalWidths* fOutputWidths);
51 
52  void processEvent(const CastorDigiCollection& castor, const CastorDbService& cond);
53 
54  // pedestal validation: CastorPedVal=-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 CastorPedVal(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 CastorDbService& 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  } castorHists;
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;
142 
143  // flag to make gaussian fits to charge dists
144  static const int fitflag = 0;
145 };
146 
147 #endif
std::pair< TH1F *, std::pair< std::map< int, std::vector< double > >, std::vector< TH1F * > > > PEDBUNCH
CastorPedestalWidths * fRawPedestalWidths
const CastorQIECoder * m_coder
std::map< HcalDetId, std::map< int, PEDBUNCH > > PEDTRENDS
static int CastorPedVal(int nstat[4], const CastorPedestals *fRefPedestals, const CastorPedestalWidths *fRefPedestalWidths, CastorPedestals *fRawPedestals, CastorPedestalWidths *fRawPedestalWidths, CastorPedestals *fValPedestals, CastorPedestalWidths *fValPedestalWidths)
void setup(const std::string &m_outputFileROOT)
void processEvent(const CastorDigiCollection &castor, const CastorDbService &cond)
void Trendings(std::map< HcalDetId, std::map< int, PEDBUNCH > > &toolT, TH1F *Chi2, TH1F *CapidAverage, TH1F *CapidChi2)
CastorPedestalWidths * fValPedestalWidths
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::map< HcalDetId, std::map< int, PEDBUNCH > >::iterator _meot
const CastorQIEShape * m_shape
int done(const CastorPedestals *fInputPedestals, const CastorPedestalWidths *fInputWidths, CastorPedestals *fOutputPedestals, CastorPedestalWidths *fOutputWidths)
const CastorPedestalWidths * fRefPedestalWidths
CastorPedestalAnalysis(const edm::ParameterSet &ps)
Constructor.
void GetPedConst(std::map< HcalDetId, std::map< int, PEDBUNCH > > &toolT, TH1F *PedMeans, TH1F *PedWidths)
Definition: Chi2.h:15
struct CastorPedestalAnalysis::@42 castorHists
void per2CapsHists(int flag, int id, const HcalDetId detid, const HcalQIESample &qie1, const HcalQIESample &qie2, std::map< HcalDetId, std::map< int, PEDBUNCH > > &toolT, const CastorDbService &cond)
const CastorPedestals * fRefPedestals