StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StVpdCalibMaker.h
1 /*******************************************************************
2  *
3  * $Id: StVpdCalibMaker.h,v 1.9 2021/05/29 23:57:19 geurts Exp $
4  *
5  *******************************************************************/
14 /*****************************************************************
15  *
16  * $Log: StVpdCalibMaker.h,v $
17  * Revision 1.9 2021/05/29 23:57:19 geurts
18  * Updates to improve pp and pA handling - by Bassam Aboona (TAMU)
19  *
20  * Revision 1.8 2017/03/02 18:26:50 jeromel
21  * Updates to StVpdCalibMaker after review - changes by jdb, nl
22  *
23  * Revision 1.7 2014/08/06 11:43:52 jeromel
24  * Suffix on literals need to be space (later gcc compiler makes it an error) - first wave of fixes
25  *
26  * Revision 1.6 2011/02/23 20:00:52 geurts
27  * Change MaxBin for ToT arrays from 60 to 128 (in agreement with the IDL definition of vpdTotCorr)
28  * Move the log message that informs the user about the start-timing mode outside the tube loop ... no need to see the same message 38 times.
29  *
30  * Revision 1.5 2011/01/07 21:28:51 geurts
31  * Allow user to "force" VPD-start or startless mode, regardless of dbase setting
32  *
33  * Revision 1.4 2010/05/12 22:46:51 geurts
34  * Startless BTOF self-calibration method (Xin)
35  *
36  * Revision 1.3 2010/05/06 22:37:41 geurts
37  * Remove slower hits (outliers) in VPD timing calculations (Xin Dong)
38  *
39  * Revision 1.2 2009/11/09 21:26:02 geurts
40  * basic doxygen added
41  *
42  * Revision 1.1 2009/11/09 20:55:54 geurts
43  * first release
44  *
45  *
46  *******************************************************************/
47 #ifndef STVPDCALIMAKER_H
48 #define STVPDCALIMAKER_H
49 
50 #include "TMath.h"
51 #include "TF1.h"
52 #include "TH1D.h"
53 #include "TH2D.h"
54 #include "StMaker.h"
55 #include <vector>
56 
57 class StEvent;
58 class StBTofCollection;
60 class StMuDst;
61 
62 class StVpdCalibMaker : public StMaker{
63 public:
64 
66  StVpdCalibMaker(const Char_t* name="vpdCalib");
68  virtual ~StVpdCalibMaker();
69 
70  virtual Int_t Init();
71  virtual Int_t InitRun(Int_t runnumber);
72  // virtual Int_t FinishRun(int);
73  virtual Int_t Make();
74  virtual Int_t Finish();
75 
77  void setCreateHistoFlag(const Bool_t histos=kTRUE);
79  void setHistoFileName(const Char_t* filename);
80 
82  // note: the default value will be changed back to kFALSE
83  void setInitFromFile(const Bool_t initFromFile= kTRUE);
84  void setCalibFilePvpd(const Char_t* filename);
85 
87  void setVPDHitsCut(const Int_t eastVpdCut, const Int_t westVpdCut);
89  void setMuDstIn();
91  void setUseVpdStart(const Bool_t val=kTRUE);
92 
94  Bool_t useVpdStart() const;
95 
97  void setCutVpdOutliers(const Bool_t val=kTRUE);
98 
99 private:
101  void resetPars();
103  void resetVpd();
105  Bool_t loadVpdData();
107  Bool_t writeVpdData() const;
109  Int_t initParameters(Int_t runnumber);
110 
112  void tsum(const Double_t *tot, const Double_t *time, std::vector<Int_t> qaTruth);
114  void vzVpdFinder();
115 
117  void bookHistograms();
119  void fillHistograms();
121  void writeHistograms() const;
122 
123  static const Double_t VHRBIN2PS; // Very High resolution mode, pico-second per bin
124  // 1000*25/1024 (ps/chn)
125  static const Double_t HRBIN2PS; // High resolution mode, pico-second per bin
126  // 97.65625= 1000*100/1024 (ps/chn)
127  static const Double_t TMAX; // tdc limit
128  static const Double_t VZDIFFCUT; // VzVpd - VzProj cut
129  static const Double_t TDIFFCUT; // fabs(time - ave(others)) > cut, remove this hit
130  static const Double_t FracTruncated; // fraction of truncation in mean calculation
131 
132  enum{
133  NTDIG = 8, // 8 per tray in Run 8++
134  NVPD = 19, // 19 tubes at each side
135  MaxVpdVz = 20,
136  NTray = 120, // 120 BTof trays
137  WestVpdTrayId = 121,
138  EastVpdTrayId = 122,
139  NBinMax = 128, // 128 max bins for T-Tot, T-Z correction
140  };
141 
142  Bool_t mValidCalibPar;
143 
144  Int_t mVPDEastHitsCut;
145  Int_t mVPDWestHitsCut;
146 
147  Double_t mVPDTotEdge[2*NVPD][NBinMax];
148  Double_t mVPDTotCorr[2*NVPD][NBinMax];
149 
150  Double_t mVPDLeTime[2*NVPD];
151  Double_t mVPDTot[2*NVPD];
152  std::vector<Int_t> mVPD_qaTruth;
153 
154  Int_t mFlag[2*NVPD];
155  Double_t mTSumEast;
156  Double_t mTSumWest;
157  UInt_t mVPDHitPatternEast;
158  UInt_t mVPDHitPatternWest;
159  Int_t mNEast;
160  Int_t mNWest;
161  Double_t mVPDVtxZ[MaxVpdVz];
162  Int_t mNVzVpd;
163 
165  Bool_t mTruncation;
166  StBTofCollection* mBTofColl;
167  StMuDst* mMuDst;
168  Bool_t mMuDstIn;
169 
170  Bool_t mHisto;
171  string mHistoFileName;
172  TH1D* mhEventCounter;
173  TH1D* mhVpd[NVPD*2];
174  TH1D* mhVpdAll;
175  TH2D* mhNVpdHits;
176  TH1D* mmVpdVertexHist;
177 
178  Bool_t mInitFromFile;
179  string mCalibFilePvpd;
180  Bool_t mUseVpdStart;
181  Bool_t mForceTofStart;
182 
183  // Start: bassam
184  Bool_t mCutVpdOutliers;
185  // End: bassam
186 
187  virtual const char *GetCVS() const
188  {static const char cvs[]="Tag $Name: $ $Id: StVpdCalibMaker.h,v 1.9 2021/05/29 23:57:19 geurts Exp $ built " __DATE__ " " __TIME__ ; return cvs;}
189 
190  ClassDef(StVpdCalibMaker,2)
191 };
192 
193 inline void StVpdCalibMaker::setVPDHitsCut(const Int_t ieast, const Int_t iwest) { mVPDEastHitsCut=ieast ; mVPDWestHitsCut=iwest; }
194 inline void StVpdCalibMaker::setMuDstIn() { mMuDstIn = kTRUE; }
195 inline void StVpdCalibMaker::setHistoFileName(const Char_t* filename){mHistoFileName=filename;}
196 inline void StVpdCalibMaker::setCreateHistoFlag(const Bool_t histos){mHisto = histos;}
197 inline void StVpdCalibMaker::setInitFromFile(const Bool_t val) {mInitFromFile = val; }
198 inline void StVpdCalibMaker::setCalibFilePvpd(const Char_t* filename) {mCalibFilePvpd = filename;}
199 inline void StVpdCalibMaker::setUseVpdStart(const Bool_t val) {mUseVpdStart = val; mForceTofStart = kTRUE;}
200 inline Bool_t StVpdCalibMaker::useVpdStart() const { return mUseVpdStart; }
201 
202 // Start: bassam
203 // Setting mCutVpdOutliers = kFALSE allows access to all hits from the VPD
204 inline void StVpdCalibMaker::setCutVpdOutliers(const Bool_t val) {mCutVpdOutliers = val; if(!val) {LOG_INFO << "Default outlier rejection of VPD hits is disabled!" << endm;} ;}
205 // End: bassam
206 #endif
void setVPDHitsCut(const Int_t eastVpdCut, const Int_t westVpdCut)
set the VPD # of hits cut
void setCreateHistoFlag(const Bool_t histos=kTRUE)
enable QA histogram filling
Bool_t useVpdStart() const
function for tofCalibMaker to know whether to use VPD as the start or not
void setCutVpdOutliers(const Bool_t val=kTRUE)
Enable/disable default outlier rejection of VPD hits.
void setUseVpdStart(const Bool_t val=kTRUE)
switch to force whether or not to use the VPD as the start time
virtual ~StVpdCalibMaker()
Destructor.
void setHistoFileName(const Char_t *filename)
set histogram output file name
virtual Int_t Make()
StVpdCalibMaker(const Char_t *name="vpdCalib")
Default constructor.
void setInitFromFile(const Bool_t initFromFile=kTRUE)
read calibration parameters from file
void setMuDstIn()
switch to read in StEvent/MuDst
virtual Int_t Finish()