StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StFstCalibrationMaker.h
1 /***************************************************************************
2 * $Id: StFstCalibrationMaker.h$
3 *
4 * Author: Shenghui Zhang,Oct. 2021
5 ****************************************************************************
6 * Description:
7 * Calculates mean pedestal, rms noise and cm noise by histogram methods,
8 * and produce two data files and several QA plots.
9 ****************************************************************************
10 ****************************************************************************
11 * StFstCalibrationMaker.h,v 1.0
12 * Revision 1.0 2021/10/15 Shenghui Zhang
13 * Initial version
14 ****************************************************************************/
15 
16 #ifndef StFstCalibrationMaker_h
17 #define StFstCalibrationMaker_h
18 
19 #include <string>
20 #include "StMaker.h"
21 #include "StEvent/StFstConsts.h"
22 
23 class StFstDb;
24 class TH2S;
25 
27 public:
28  // constructors
29  StFstCalibrationMaker( const char* name = "fst_calib" );
30  // deconstructor
32 
33  Int_t Init();
34  Int_t InitRun(Int_t runNumber);
35  Int_t Make();
36  Int_t Finish();
37 
38  // modifiers
39  void setTimeBinMask( short mask = 0xFF );
40  void setRunHist(bool flag =false);
41  void setPedCutFlag(bool flag =false);
42  void setPedCut(float pedCut = 3.0);
43 
44  // ped, rms, ran, gain
45  struct pedNoiseData_t {
46  Int_t n;
47  Float_t ped;
48  Float_t rms;
49  Float_t ran;
50 
51  pedNoiseData_t( int nIn=0, float p=0, float r=0, float d=0 ) : n(nIn), ped(p), rms(r), ran{d} { /* */ };
52  };
53  typedef std::vector< pedNoiseData_t > pedNoiseDataVec_t;
54  pedNoiseDataVec_t mPedVec;
55  // cmn
56  struct cmNoiseData_t {
57  Int_t n;
58  Float_t cmn;
59 
60  cmNoiseData_t( int nIn=0, float c=0 ) : n(nIn), cmn(c) { /* */ };
61  };
62  typedef std::vector< cmNoiseData_t > cmNoiseDataVec_t;
63  cmNoiseDataVec_t mCmnVec;
64 
65 protected:
66  // mask for which time bins to save
67  Short_t mTimeBinMask;
68  // whether or not to run Histogram method
69  Bool_t mRunHist;
70  // whether or not put constraints
71  Bool_t mDoPedCut;
72  Float_t mPedCut;
73  //containers for histogram calculation method
74  std::vector< TH1S* > mHistPedVec;
75  std::vector< TH1F* > mHistCmnVec;
76  std::vector< TH1F* > mHistRanVec;
77 
78  //containers for 1st loop's pedestal/rms values
79  std::vector< float > mPedVec1stLoop;
80  std::vector< float > mRmsVec1stLoop;
81  std::vector< float > mRanVec1stLoop;
82 
83  //containers for mathematical calculation mathod
84  std::vector< double > mMathPedVec;
85  std::vector< double > mMathRmsVec;
86  std::vector< int > mMathCouVec;
87 
88  std::vector< double > mMathRanVec;
89  std::vector< double > mMathPedRanVec;
90  std::vector< double > mMathRmsRanVec;
91  std::vector< int > mMathCouRanVec;
92 
93  Int_t evtIdx;
94 
95  // functions that actually do the saving
96  Int_t saveToFile();
97 
98  // has finished
99  Bool_t mHasFinished;
100 
101  // Db
102  StFstDb *mFstDb;
103  // mapping
104  typedef std::vector< int > MappingVec_t; //Channel elec. index, geometry ID
105  MappingVec_t mMappingVec;
106 
107  // for saving to file
108  Bool_t mDoOutput;
109  TH1F *hist_meanPed[kFstNumTimeBins]; // mean pedestal = pedestal histogram -> GetMean()
110  TH1F *hist_rmsPed[kFstNumTimeBins]; // standard deveriation = pedestal histogram -> GetRMS()
111  TH1F *hist_cmNoise[kFstNumTimeBins]; // common mode noise per APV chip
112  TH1F *hist_ranNoise[kFstNumTimeBins]; // standard deveriation = pedestal histogram -> GetRMS()
113  TH1F *hist_sumPed[kFstNumTimeBins]; // summary pedestal over all channels
114  TH1F *hist_sumRms[kFstNumTimeBins]; // summary rms noise over all channels
115  TH1F *hist_sumCmn[kFstNumTimeBins]; // summary common mode noise over all channels
116  TH1F *hist_sumRan[kFstNumTimeBins]; // summary common mode noise over all channels
117  TH2S *hist_adcSpectrum[kFstNumTimeBins]; // ADC spectrum over all channels
118  static const string sectionLabel[72];
119 
120 private:
121 
122  ClassDef(StFstCalibrationMaker,0);
123 };
124 
125 // modifiers
126 inline void StFstCalibrationMaker::setTimeBinMask( short mask ) { mTimeBinMask = mask; };
127 inline void StFstCalibrationMaker::setRunHist(bool flag) { mRunHist = flag; };
128 inline void StFstCalibrationMaker::setPedCutFlag(bool flag) { mDoPedCut = flag; };
129 inline void StFstCalibrationMaker::setPedCut(float pedCut) { mPedCut = pedCut; };
130 /*inline const char *StFstCalibrationMaker::GetCVS() const {
131  static const char cvs[] = "Tag $Name: $ $Id: StFstCalibrationMaker.h,v 1.8 2014/07/29 20:13:30 ypwang Exp $ built "__DATE__" "__TIME__ ;
132  return cvs;
133 }*/
134 #endif