forked from JeffersonLab/SBS-offline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SBSCDet.h
285 lines (221 loc) · 9.53 KB
/
SBSCDet.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
//////////////////////////////////////////////////////////////////////////
//
// SBSCDet
//
// General F1TDC supported scintilator plane detector
//
//////////////////////////////////////////////////////////////////////////
//
// Author : Copy from AGen Lib
// Modify History:
// Jin Huang <mailto:[email protected]> July 2007
// make database file supporting comment
// disable Multi Hit which is for neutron detection
// Jin Huang Sept 2008
// Convert to a detector version of SBSCDet
//
//////////////////////////////////////////////////////////////////////////
#ifndef ROOT_SBSCDet
#define ROOT_SBSCDet
#include "THaNonTrackingDetector.h"
#include "THaNonTrackingDetector.h"
#include "THaApparatus.h"
#include "TClonesArray.h"
//#include "THaNeutronApp.h"
class SBSScintPMT;
class SBSScintHit;
class SBSScintBar;
class SBSAdcHit;
class SBSTdcHit;
class THaNonTrackingDetector;
class SBSScintPartialHit;
class THaTrackProj;
//class THaMultiHit;
//class THaNeutronDetector;
//------------------------------------------------------//
//
// Debug Defines
// place this section below any other head files
//
//------------------------------------------------------//
//
#ifdef DEBUG_LEVEL
#undef DEBUG_LEVEL
#endif
// DEBUG_LEVEL;
// =0 or not define: no debug, full speed
// >=1 enable debug extra warning (suggested setting)
// >=2 above + enable debug assert
// >=3 above + enable debug extra info
// >=4 massive info
// >=5 +decode check
//
#define DEBUG_LEVEL 2
#include "DebugDef.h"
//------------------------------------------------------//
//whether build hit which do not have all tdc and adc hit info
#define BUILD_PARTIAL_HIT 0
//save flat info
#define SAVEFLAT 1
//whether delete hit, whose ypos is 2 times away from the edge of scint bar
#define CUT_ON_YPOS 1
//------------------------------------------------------//
class SBSCDet : public THaNonTrackingDetector {
public:
SBSCDet( const char* name, const char* description,
THaApparatus* apparatus=0);
SBSCDet( );
virtual ~SBSCDet();
virtual Int_t InitOutput( THaOutput* output );
virtual void Clear( Option_t* opt="" );
virtual Int_t Decode( const THaEvData& );
virtual Int_t CoarseProcess( TClonesArray& tracks );
virtual Int_t FineProcess( TClonesArray& tracks );
//Int_t ConstructTracks( TClonesArray * tracks = NULL ) {return 0;}
//function for jump through lines starting with #
char* ReadNumberSignStartComment( FILE* fp, char *buf, const int len );
// alternative reconstructions
Int_t BuildAllBars( TClonesArray& trks ); // original, partial hits etc.
// newer:
Int_t BuildCompleteBars( TClonesArray& trks ); // only complete hits
//Int_t CombineHits( TClonesArray& trks ); // build plane clusters
// Public Get and Set functions for Hit Information
Int_t GetNBars() const { return fBars->GetLast()+1; }
// Per Event
Int_t GetNHits() const { return fHits->GetLast()+1; }
Int_t GetNRefHits() const { return fRefHits->GetLast()+1;}
Int_t GetNLtHits() const { return fLtHits->GetLast()+1; }
Int_t GetNRtHits() const { return fRtHits->GetLast()+1; }
Int_t GetNLaHits() const { return fLaHits->GetLast()+1; }
Int_t GetNRaHits() const { return fRaHits->GetLast()+1; }
Int_t GetNPartHits() const { return fPartHits->GetLast()+1;}
//Int_t GetNCombinedHits() const { return fCombHits->GetLast()+1; }
TClonesArray* GetBars() const {return fBars;}
SBSScintBar* GetBar(Int_t i) const
{return (SBSScintBar*)fBars->At(i);}
TClonesArray* GetHits() const {return fHits;}
SBSScintHit* GetHit(Int_t i) const
{return (SBSScintHit*)fHits->At(i);}
//TClonesArray* GetCombinedHits() const {return fCombHits;}
//THaMultiHit* GetCombHit(Int_t i) const
// {return (THaMultiHit*)fCombHits->At(i);}
TClonesArray* GetRefHits() const {return fRefHits;}
const SBSTdcHit* GetRefHit(Int_t i) const
{return (SBSTdcHit*)fRefHits->At(i);}
TClonesArray* GetLtHits() const {return fLtHits;}
const SBSTdcHit* GetLtHit(Int_t i) const
{return (SBSTdcHit*)fLtHits->At(i);}
TClonesArray* GetRtHits() const {return fRtHits;}
const SBSTdcHit* GetRtHit(Int_t i) const
{return (SBSTdcHit*)fRtHits->At(i);}
TClonesArray* GetLaHits() const {return fLaHits;}
const SBSAdcHit* GetLaHit(Int_t i) const
{return (SBSAdcHit*)fLaHits->At(i);}
TClonesArray* GetRaHits() const {return fRaHits;}
const SBSAdcHit* GetRaHit(Int_t i) const
{return (SBSAdcHit*)fRaHits->At(i);}
// return matching Tdc from bar ptr on side, n'th hit
const SBSTdcHit* GetBarHitT(const char side, const SBSScintBar *const ptr,
const int n=0) const;
// return matching Adc from bar ptr on side, n'th hit
const SBSAdcHit* GetBarHitA(const char side, const SBSScintBar *const ptr,
const int n=0) const;
Int_t GetNRefCh() const { return fRefCh->GetLast()+1; }
TClonesArray* GetRefCh() const { return fRefCh; }
const SBSScintPMT* GetRefCh(Int_t i) const
{ return (SBSScintPMT*)fRefCh->At(i);}
Int_t AreRefChOkay() const { return ( fRefOkay ? 1 : 0 ); }
TClonesArray* GetPartHits() const {return fPartHits;}
const SBSScintPartialHit* GetPartHit(Int_t i) const
{return (SBSScintPartialHit*)fPartHits->At(i);}
Double_t GetMatchRatioTrack() const {return fMatchRatioTrack;}
virtual Int_t FineMatchingHits(TClonesArray& tracks);
Double_t GetMaxADCHitBar() const {return fMaxADCHitBar;}//Hit Bar number with max sqrt(RApedc*LApedc)
Double_t GetMaxEnergyHitBar() const {return fMaxEnergyHitBar;}//Hit Bar number with max sqrt(RE*LE)
Double_t GetMaxADCHit() const {return fMaxADCHit;}//Hit Bar number with max sqrt(RApedc*LApedc)
Double_t GetMaxEnergyHit() const {return fMaxEnergyHit;}//Hit Bar number with max sqrt(RE*LE)
protected:
Bool_t fCoarseProcessed;
Bool_t fFineProcessed;
Int_t GetParameter( FILE* file, const TString tag, Double_t* value );
Int_t GetTable( FILE* file, const TString tag, Double_t* value,
const Int_t maxval, int* first, int* last );
TClonesArray* fBars;
Int_t fNBars;
TClonesArray* fHits; // Hits in paddles
//TClonesArray* fCombHits; // combined hit information for plane
TClonesArray* fRefHits;
TClonesArray* fLaHits;
TClonesArray* fRaHits;
TClonesArray* fLtHits;
TClonesArray* fRtHits;
TClonesArray* fPartHits;
// same for reference channels
TClonesArray* fRefCh; // reference channels for pipeline tdc
Int_t fNRefHits; // Number of refch that were hit
Bool_t fRefOkay;
//Double_t fThreshold; // energy threshhold for a hit to be used
// Per-event data
Int_t fLTNhit; // Number of Left paddles TDC times */
Int_t fRTNhit; // Number of Right paddles TDC times */
Int_t fLANhit; // Number of Left paddles ADC amplitudes */
Int_t fRANhit; // Number of Right paddles ADC amplitudes */
Int_t fNPaddlesHit;
// per-event: index in clonesarray of first hit on bar
Int_t *fLtIndex; //![fNBars] // for left-tdc
Int_t *fRtIndex; //![fNBars] // right-tdc
Int_t *fLaIndex; //![fNBars] // left-adc
Int_t *fRaIndex; //![fNBars] // right-adc
Double_t* fLE; // [fNBars]
Double_t* fRE; // [fNBars]
Double_t* fLrawA; // [fNBars]
Double_t* fRrawA; // [fNBars]
Double_t* fLpedcA; // [fNBars]
Double_t* fRpedcA; // [fNBars]
Double_t fMaxADCHitBar; //Hit Bar number with max sqrt(RApedc*LApedc)
Double_t fMaxEnergyHitBar; //Hit Bar number with max sqrt(RE*LE)
Double_t fMaxADCHit; // max sqrt(RApedc*LApedc)
Double_t fMaxEnergyHit; //max sqrt(RE*LE)
Double_t* fLT; // [fNBars]
Double_t* fRT; // [fNBars]
Int_t* fLTcounter; // [fNBars]
Int_t* fRTcounter; // [fNBars]
Int_t* hitcounter; // [fNBars]
Double_t* Energy; // [fNBars]
Double_t* TDIFF; // [fNBars]
Double_t* TOF; // [fNBars]
Double_t* T_tot; // [fNBars]
Double_t* Yt_pos; // [fNBars]
Double_t* Ya_pos; // [fNBars]
Double_t* Y_pred; // [fNBars]
Double_t* Y_dev; // [fNBars]
Double_t* fAngle; // [fNBars]
//TVector3 fXax;
//when x y distance between hit and track projection is smaller
//than the number below, the hit will be matched to the track
//(the index of hit will be saved to fTrackProj.THaTrackProj.fChannel)
//if there are more than 1 hit in this region, then the nearest one wins
Double_t fTrackAcceptanceDx;
Double_t fTrackAcceptanceDy;
Double_t fMatchRatioTrack;
TClonesArray* fTrackProj; // projection of track onto scintillator plane
// and estimated match to TOF paddle
//event statistic
Int_t fEventCount; //how many event processed
Int_t fErrorReferenceChCount; //how many event got no reference channel
Double_t fErrorReferenceChRateWarningThreshold;
//Threshold of ave. error reference per event that will pop up warnings
Bool_t fTooManyErrRefCh; //flag whether there are too much error reference
void DeleteArrays();
virtual Int_t ReadDatabase( const TDatime& date );
virtual Int_t DefineVariables( EMode mode = kDefine );
virtual Double_t TimeWalkCorrection(
SBSScintPMT* pmt,
Double_t ADC,
Double_t time);
enum ESide { kLeft = 0, kRight = 1 };
SBSCDet& operator=( const SBSCDet& ) {return *this; }
public:
ClassDef(SBSCDet,4) // Describes scintillator plane with F1TDC as a detector
};
#endif