CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CastorPedestalAnalysis.h
Go to the documentation of this file.
1 #ifndef CastorPedestalAnalysis_H
2 #define CastorPedestalAnalysis_H
3 
14 
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 CastorPedestalAnalysis 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 CastorPedestals;
35 class CastorDbService;
36 class CastorQIEShape;
37 class CastorQIECoder;
38 class TFile;
40 
41 public:
42 
47 
48  void setup(const std::string& m_outputFileROOT);
49 
50  void SampleAnalysis();
51 
52  int done(const CastorPedestals* fInputPedestals,
53  const CastorPedestalWidths* fInputWidths,
54  CastorPedestals* fOutputPedestals,
55  CastorPedestalWidths* fOutputWidths);
56 
57  void processEvent(const CastorDigiCollection& castor,
58  const CastorDbService& cond);
59 
60 // pedestal validation: CastorPedVal=-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 CastorPedVal(int nstat[4], const CastorPedestals* 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 CastorDbService& 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 
101  std::string m_outputFileROOT;
102  std::string m_outputFileMean;
103  std::string m_outputFileWidth;
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  } castorHists;
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;
136 
137 // flag to make gaussian fits to charge dists
138  static const int fitflag=0;
139 };
140 
141 #endif
long int flag
Definition: mlp_lapack.h:47
struct CastorPedestalAnalysis::@35 castorHists
CastorPedestalWidths * fRawPedestalWidths
std::map< HcalDetId, std::map< int, PEDBUNCH > >::iterator _meot
const CastorQIECoder * m_coder
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)
dictionary map
Definition: Association.py:196
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 > > PEDTRENDS
std::pair< TH1F *, std::pair< std::map< int, std::vector< double > >, std::vector< TH1F * > > > PEDBUNCH
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:17
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