StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StETofHitMaker.h
1 /***************************************************************************
2  *
3  * $Id: StETofHitMaker.h,v 1.6 2021/01/29 15:08:31 weidenkaff Exp $
4  *
5  * Author: Philipp Weidenkaff & Florian Seck, April 2018
6  ***************************************************************************
7  *
8  * Description: StETofHitMaker - class to read the eTofCollection from
9  * StEvent and combine digis on both sides of each read-out strip into a hit.
10  * The hits on each strip are further merger into clusters.
11  * The eTOF collection is filled with hits and written to StEvent.
12  *
13  ***************************************************************************
14  *
15  * $Log: StETofHitMaker.h,v $
16  * Revision 1.6 2021/01/29 15:08:31 weidenkaff
17  * fixed memory leak in StEtofHitMaker.cxx by adding a delete to merged hits
18  *
19  * Revision 1.5 2020/01/16 03:39:39 fseck
20  * add possibility to calculate VPD start time
21  *
22  * Revision 1.4 2019/12/10 15:58:29 fseck
23  * ignore digis in dead time software-wise + possibility to correct clock jumps based on hit position via setting a flag
24  *
25  * Revision 1.3 2019/03/25 01:08:21 fseck
26  * added cyclic mean calculation function for average hit time
27  *
28  * Revision 1.2 2019/03/08 19:03:35 fseck
29  * moved QA histograms for clustered hits into separate function
30  *
31  * Revision 1.1 2019/02/19 19:52:28 jeromel
32  * Reviewed code provided by F.Seck
33  *
34  *
35  ***************************************************************************/
36 #ifndef STETOFHITMAKER_H
37 #define STETOFHITMAKER_H
38 
39 #include <string>
40 #include <vector>
41 #include <map>
42 
43 #include "StMaker.h"
44 #include "StThreeVectorD.hh"
45 
46 class TH1;
47 
48 class StEvent;
49 class StMuDst;
50 
51 class StETofDigi;
52 class StMuETofDigi;
53 
54 class StETofHit;
55 class StMuETofHit;
56 
57 class StETofGeometry;
58 
59 
60 class StETofHitMaker: public StMaker {
61 public:
62  StETofHitMaker( const char* name = "etofHit" ); // default constructor
63 
64  ~StETofHitMaker();
65 
66 
67  Int_t Init();
68  Int_t InitRun( Int_t );
69  Int_t FinishRun( Int_t );
70  Int_t Finish();
71  Int_t Make();
72 
73 
74  void processStEvent();
75  void processMuDst();
76 
78  void setFileNameHitParam( const char* fileName );
79  void setFileNameSignalVelocity( const char* fileName );
80  void setFileNameModMatrix( const char* fileName );
81  void setFileNameAlignParam( const char* fileName );
82 
83  void setGet4MinTime( const double minTime );
84  void setSoftwareDeadTime( const double& deadTime );
85  void setDoClockJumpShift( const bool doShift );
86  void setDoDoubleClockJumpShift( const bool doDoubleShift );
87 
88  void setIsSim( const bool isSim ); // for simulated digis
89  void setDoQA( const bool doQA );
90  void setDebug( const bool debug );
91  void setDoAfterPulseCorr( const bool apcorr );
92 
93  void updateClockJumpMap( const std::map< int, int >& clockJumpDir );
94 
95  void modifyHit(int modMode, double& localX, double& localY, double& time);
96 
97 private:
98  // internal subfunctions ----------------------------------------------------------------------
99  void bookHistograms();
100  void setHistFileName();
101  void writeHistograms();
102 
103  void clearHits( const bool isMuDst ); // clear hits from StEvent / MuDst in afterburner mode
104  void clearStorage();
105 
106  bool fillStorage( StETofDigi* aDigi, unsigned int index ); // sorts digis into vectors by detector
107  bool fillStorage( StMuETofDigi* aDigi, unsigned int index ); // sorts digis into vectors by detector
108 
109  void matchSides(); // matches digis on opposing sides to form single strip hits
110 
111  void mergeClusters( const bool isMuDst ); // merges hits to clusters across multiple strips
112 
113  void assignAssociatedHits( const bool isMuDst ); // write associated hits into digis
114 
115  double startTime();
116  void startTimeVpd( double& startTime, double& vertexVz );
117 
118  void fillUnclusteredHitQA( const double& tstart, const bool isMuDst );
119 
120  void fillHitQA( const bool isMuDst, const double& tstart );
121  void updateCyclicRunningMean( const double& value, double& mean, int& count, const double& range );
122 
123  unsigned int detectorToKey( const unsigned int detectorId );
124 
125  // internal containers ------------------------------------------------------------------------
126  StEvent* mEvent;
127  StMuDst* mMuDst;
128  StETofGeometry* mETofGeom; // pointer to the ETof geometry utility class
129 
130 
131  std::string mFileNameHitParam; // name of parameter file for hit parameters
132  std::string mFileNameSignalVelocity; // name of parameter file for signal velocity
133  std::string mFileNameModMatrix; // name of parameter file for hit modification on counter level
134  std::string mFileNameAlignParam; // name of parameter file for counter alignment in geometry
135 
136  // store digis ordered by detectorstrip for side-matching
137  std::map< UInt_t, std::vector< StETofDigi* > > mStoreDigi; // key: strip index, value: vector of digis
138 
139  // link between mStorStDigi and StETofCollection->digis()
140  std::map< StETofDigi*, UInt_t > mMapDigiIndex;
141 
142  // store hit ordered by detector for merging.
143  std::map< UInt_t, std::vector< StETofHit* > > mStoreHit; // key: detector index, value: vector of hits
144 
145  // link between hits and constituent digis
146  std::map< StETofHit*, std::vector< UInt_t > > mMapHitDigiIndices;
147 
148  // map between hit index in MuDsts and constituent digis
149  std::map< UInt_t, std::vector< UInt_t > > mMapHitIndexDigiIndices;
150 
151  // parameters ---------------------------------------------------------------------------------
152  Double_t mMaxYPos; // maximum absolute Y Pos for side matching
153  Double_t mMergingRadius; // maximum XYT radius[ns] for cluster merging
154 
155  std::map< UInt_t, Double_t > mSigVel; // signal velocities in each detector
156 
157  Double_t mSoftwareDeadTime; // dead time introduced in software to reject after pulses on the same channel
158  Bool_t mDoClockJumpShift; // correct for clock jumps on one side
159  Bool_t mDoDoubleClockJumpShift; // correct for clock jumps on both sides
160 
161  std::map< Int_t, Int_t > mClockJumpDirection; // stores direction of clock jump for time correction
162 
163  std::map< Int_t, int > mModMatrix; // stores mode of modification for hits on striplevel (flip)
164 
165  float mGet4doublejumpTmin; // cutoff for double jump correction
166  std::map< Int_t, bool > mGet4doublejumpFlag; // get4 jumpflag
167  std::map< Int_t, std::vector < float > > mGet4doublejumpTimes; // get4 time of last n hits
168 
169 
170  // histograms for QA --------------------------------------------------------
171  Bool_t mIsSim;
172  Bool_t mDoQA;
173  Bool_t mDebug;
174  Bool_t mApCorr;
175 
176  std::string mHistFileName;
177  std::map< std::string, TH1* > mHistograms;
178 
179  std::vector< Bool_t > mCounterActive;
180 
181  virtual const Char_t *GetCVS() const { static const char cvs[]="Tag $Name: $Id: built " __DATE__ " " __TIME__ ; return cvs; }
182 
183  ClassDef( StETofHitMaker, 0 )
184 };
185 
186 
187 inline void StETofHitMaker::setFileNameHitParam( const char* fileName ) { mFileNameHitParam = fileName; }
188 inline void StETofHitMaker::setFileNameSignalVelocity( const char* fileName ) { mFileNameSignalVelocity = fileName; }
189 inline void StETofHitMaker::setFileNameModMatrix( const char* fileName ) { mFileNameModMatrix = fileName; }
190 inline void StETofHitMaker::setFileNameAlignParam( const char* fileName ) { mFileNameAlignParam = fileName; }
191 
192 
193 inline void StETofHitMaker::setGet4MinTime( const double minTime ) { mGet4doublejumpTmin = minTime; }
194 inline void StETofHitMaker::setSoftwareDeadTime( const double& deadTime ) { mSoftwareDeadTime = deadTime; }
195 inline void StETofHitMaker::setDoClockJumpShift( const bool doShift ) { mDoClockJumpShift = doShift; }
196 inline void StETofHitMaker::setDoDoubleClockJumpShift( const bool doDoubleShift ) { mDoDoubleClockJumpShift = doDoubleShift; }
197 
198 inline void StETofHitMaker::setIsSim( const bool isSim ) { mIsSim = isSim; }
199 inline void StETofHitMaker::setDoQA( const bool doQA ) { mDoQA = doQA; }
200 inline void StETofHitMaker::setDebug( const bool debug ) { mDebug = debug; }
201 inline void StETofHitMaker::setDoAfterPulseCorr( const bool apcorr ) { mApCorr = apcorr; }
202 
203 #endif
void setFileNameHitParam(const char *fileName)
read hit building parameters from file