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