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  std::map< int, std::vector< int > > mGet4PartnerPairMap;
131  std::map< int , int > mGet4DefaultMap;
132 
133  std::string mFileNameHitParam; // name of parameter file for hit parameters
134  std::string mFileNameSignalVelocity; // name of parameter file for signal velocity
135  std::string mFileNameModMatrix; // name of parameter file for hit modification on counter level
136  std::string mFileNameAlignParam; // name of parameter file for counter alignment in geometry
137 
138  // store digis ordered by detectorstrip for side-matching
139  std::map< UInt_t, std::vector< StETofDigi* > > mStoreDigi; // key: strip index, value: vector of digis
140 
141  // link between mStorStDigi and StETofCollection->digis()
142  std::map< StETofDigi*, UInt_t > mMapDigiIndex;
143 
144  // store hit ordered by detector for merging.
145  std::map< UInt_t, std::vector< StETofHit* > > mStoreHit; // key: detector index, value: vector of hits
146 
147  // link between hits and constituent digis
148  std::map< StETofHit*, std::vector< UInt_t > > mMapHitDigiIndices;
149 
150  // map between hit index in MuDsts and constituent digis
151  std::map< UInt_t, std::vector< UInt_t > > mMapHitIndexDigiIndices;
152 
153  // parameters ---------------------------------------------------------------------------------
154  Double_t mMaxYPos; // maximum absolute Y Pos for side matching
155  Double_t mMergingRadius; // maximum XYT radius[ns] for cluster merging
156 
157  std::map< UInt_t, Double_t > mSigVel; // signal velocities in each detector
158 
159  Double_t mSoftwareDeadTime; // dead time introduced in software to reject after pulses on the same channel
160  Bool_t mDoClockJumpShift; // correct for clock jumps on one side
161  Bool_t mDoDoubleClockJumpShift; // correct for clock jumps on both sides
162 
163  std::map< Int_t, Int_t > mClockJumpDirection; // stores direction of clock jump for time correction
164 
165  std::map< Int_t, int > mModMatrix; // stores mode of modification for hits on striplevel (flip)
166 
167  float mGet4doublejumpTmin; // cutoff for double jump correction
168  std::map< Int_t, bool > mGet4doublejumpFlag; // get4 jumpflag
169  std::map< Int_t, std::vector < float > > mGet4doublejumpTimes; // get4 time of last n hits
170 
171 
172  // histograms for QA --------------------------------------------------------
173  Bool_t mIsSim;
174  Bool_t mDoQA;
175  Bool_t mDebug;
176  Bool_t mApCorr;
177 
178  std::string mHistFileName;
179  std::map< std::string, TH1* > mHistograms;
180 
181  std::vector< Bool_t > mCounterActive;
182 
183  virtual const Char_t *GetCVS() const { static const char cvs[]="Tag $Name: $Id: built " __DATE__ " " __TIME__ ; return cvs; }
184 
185  ClassDef( StETofHitMaker, 0 )
186 };
187 
188 
189 inline void StETofHitMaker::setFileNameHitParam( const char* fileName ) { mFileNameHitParam = fileName; }
190 inline void StETofHitMaker::setFileNameSignalVelocity( const char* fileName ) { mFileNameSignalVelocity = fileName; }
191 inline void StETofHitMaker::setFileNameModMatrix( const char* fileName ) { mFileNameModMatrix = fileName; }
192 inline void StETofHitMaker::setFileNameAlignParam( const char* fileName ) { mFileNameAlignParam = fileName; }
193 
194 
195 inline void StETofHitMaker::setGet4MinTime( const double minTime ) { mGet4doublejumpTmin = minTime; }
196 inline void StETofHitMaker::setSoftwareDeadTime( const double& deadTime ) { mSoftwareDeadTime = deadTime; }
197 inline void StETofHitMaker::setDoClockJumpShift( const bool doShift ) { mDoClockJumpShift = doShift; }
198 inline void StETofHitMaker::setDoDoubleClockJumpShift( const bool doDoubleShift ) { mDoDoubleClockJumpShift = doDoubleShift; }
199 
200 inline void StETofHitMaker::setIsSim( const bool isSim ) { mIsSim = isSim; }
201 inline void StETofHitMaker::setDoQA( const bool doQA ) { mDoQA = doQA; }
202 inline void StETofHitMaker::setDebug( const bool debug ) { mDebug = debug; }
203 inline void StETofHitMaker::setDoAfterPulseCorr( const bool apcorr ) { mApCorr = apcorr; }
204 
205 #endif
206 
void setFileNameHitParam(const char *fileName)
read hit building parameters from file