-
Notifications
You must be signed in to change notification settings - Fork 37
/
SBSSimDecoder.h
283 lines (251 loc) · 8.52 KB
/
SBSSimDecoder.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
#ifndef __SBSSimDecoder_h
#define __SBSSimDecoder_h
/////////////////////////////////////////////////////////////////////
//
// SBSSimDecoder
//
/////////////////////////////////////////////////////////////////////
#include "SimDecoder.h"
//#include "TSBSSimEvent.h"
#include "ha_compiledata.h"
#include "SBSSimFile.h"//needed for SBSSimEvent
#include "TH1D.h"
//#include "digsim_tree.h"
#include "THaApparatus.h"
#include <cassert>
#include <map>
#include <stdint.h>
class THaDetMap;
class SBSSimSADCEncoder; // For decoding simulation GEMs
//class TDetInfo;
//-----------------------------------------------------------------------------
// SBS digitized simulation decoder class
class SBSSimDecoder : public Podd::SimDecoder {
public:
//constructor may be inputed a data file to input some of the paramaters used by SimDecoder
//NB: if the second file path does not select a valid file, default parameters will be used.
// MANDATORY
SBSSimDecoder();
virtual ~SBSSimDecoder();
#if ANALYZER_VERSION_CODE >= 67072 // ANALYZER_VERSION(1,6,0)
virtual Int_t LoadEvent( const UInt_t* evbuffer );
#else
virtual Int_t LoadEvent( const Int_t* evbuffer );
#endif
virtual void Clear( Option_t* opt="" );
virtual Int_t DefineVariables( THaAnalysisObject::EMode mode =
THaAnalysisObject::kDefine );
virtual Int_t Init();
// Workaround for fubar THaEvData
#if ANALYZER_VERSION_CODE >= 67072 // ANALYZER_VERSION(1,6,0)
static Int_t GetMAXSLOT() { return Decoder::MAXSLOT; }
#else
static Int_t GetMAXSLOT() { return MAXSLOT; }
#endif
//Needs to be public
struct detchaninfo{
uint crate;
uint slot;
uint chan;
detchaninfo(int cr = 0, int sl = 0, int ch = 0) ://, int apv = 0) :
crate(cr), slot(sl), chan(ch)//, apvnum(apv)
{}
virtual ~detchaninfo(){};
};
//strips have their own struc this way we can add as many parameters as we see fit
struct gemstripinfo{
uint crate;
uint slot;
uint apvnum;
//uint chan_lo;
//uint chan_hi;
//uint axis;
gemstripinfo(int cr = 0, int sl = 0, int apv = 0) :
//, int ch_lo = 0, int ch_hi = 0, int ax) :
crate(cr), slot(sl), apvnum(apv)
//, chan_lo(ch_lo), chan_hi(ch_hi), axis(ax)
{}
virtual ~gemstripinfo(){};
};
//Utilities
// a bit dumb, I know, but I don't know another way
//void SetTree(TTree *t);
//Setup all detectors for an apparatus
//void SetDetMapParam(const std::string detname, int cps, int spc, int fs, int fc);
protected:
// MANDATORY
// Event-by-event data
#if ANALYZER_VERSION_CODE >= 67072 // ANALYZER_VERSION(1,6,0)
Int_t DoLoadEvent( const UInt_t* evbuffer );
#else
Int_t DoLoadEvent( const Int_t* evbuffer );
#endif
//Utilities
//typedef std::map<Int_t,Int_t> PMTMap_t;
// Event-by-event data
//PMTMap_t fPMTMap; //! Map ROCKey -> index of corresponding PMT
// retrive chanperslot, slotpercrate, etc...
/*
Int_t RetrieveDetMapParam(const char* detname,
int& crateperslot, int& slotpercrate,
int& firstcrate, int& firstslot);
*/
bool fIsInit;
void SetDetectors();
Int_t AddDetector(std::string detname, TDatime date);
Int_t ReadDetectorDB(std::string detname, TDatime date);
Int_t LoadDetector( std::map<Decoder::THaSlotData*, std::vector<UInt_t> > &map,
const std::string& detname,
const SBSSimEvent* simev);
void CheckForEnabledDetectors();
//void CheckForDetector(const char *detname, short id);
SBSSimSADCEncoder *fDecoderMPD;//FIXME: a bit of a kludge...
bool fCheckedForEnabledDetectors;
std::vector<std::string> fDetectors;
//bool fTreeIsSet;
//digsim_tree* fTree;
//std::map<std::string, UInt_t> fNChanDet;
//std::map<std::string, UInt_t> fChanMapStartDet;
//std::map<std::string, std::map<UInt_t, detchaninfo> > fInvDetMap;
std::map<std::string, std::vector<detchaninfo> > fInvDetMap;
std::map<std::string, std::vector<std::vector<gemstripinfo>> > fInvGEMDetMap;
//std::map<std::string, std::vector<std::vector<gemstripinfo>> > fInvGEMDetMap;
//std::map<std::string, std::vector<detchaninfo> > fInvDetMap_secondary;
//std::map<std::string, std::vector< std::vector<UShort_t> > > fChanMapDet;
/*
// again, probably dumb...
std::map<std::string, uint> fChansPerSlotDetMap;
std::map<std::string, uint> fSlotsPerCrateDetMap;
std::map<std::string, uint> fFirstSlotDetMap;
std::map<std::string, uint> fFirstCrateDetMap;
*/
void ChanToROC( const std::string& detname, Int_t h_chan,
Int_t &crate, Int_t &slot, UShort_t &chan ) const;
int APVnum( const std::string& detname, Int_t mod, Int_t h_chan,
Int_t &crate, Int_t &slot, UShort_t &chan ) const;
// TODO: function(s) that load(s) the MC track hit
// simc variables
Double_t fSigma_simc;
Double_t fWeight_simc;
Double_t fQ2_simc;
Double_t fXbj_simc;
Double_t fNu_simc;
Double_t fW_simc;
Double_t fEpsilon_simc;
Double_t fEbeam_simc;
Double_t fEp_simc;
Double_t fEtheta_simc;
Double_t fEphi_simc;
Double_t fEPx_simc;
Double_t fEPy_simc;
Double_t fEPz_simc;
Int_t fFnucl_simc;
Double_t fNp_simc;
Double_t fNtheta_simc;
Double_t fNphi_simc;
Double_t fNPx_simc;
Double_t fNPy_simc;
Double_t fNPz_simc;
Double_t fVx_simc;
Double_t fVy_simc;
Double_t fVz_simc;
Double_t fVeE_simc;
Double_t fVetheta_simc;
// g4sbs variables
Double_t fSigma;
Double_t fOmega;
Double_t fEPx;
Double_t fEPy;
Double_t fEPz;
Double_t fNPx;
Double_t fNPy;
Double_t fNPz;
Double_t fVx;
Double_t fVy;
Double_t fVz;
Double_t fEp;
Double_t fNp;
Int_t fNucl;
Int_t fFnucl;
Int_t fNBBtracks;
std::vector<Int_t> fBBtrack_Nhits;
std::vector<Int_t> fBBtrack_TID;
std::vector<Int_t> fBBtrack_PID;
std::vector<Int_t> fBBtrack_MID;
std::vector<Double_t> fBBtrack_P;
std::vector<Double_t> fBBtrack_X;
std::vector<Double_t> fBBtrack_Y;
std::vector<Double_t> fBBtrack_dX;
std::vector<Double_t> fBBtrack_dY;
Int_t fNBBGEMhits;
std::vector<Int_t> fBBGEMhit_plane;
std::vector<Int_t> fBBGEMhit_TID;
std::vector<Int_t> fBBGEMhit_PID;
std::vector<Int_t> fBBGEMhit_MID;
std::vector<Double_t> fBBGEMhit_edep;
std::vector<Double_t> fBBGEMhit_x;
std::vector<Double_t> fBBGEMhit_y;
Double_t fBBPS_esum;
Double_t fBBSH_esum;
//PTrack & SDTrack indices
//SD: GEM, Hodo, PS, SH, HCAL
std::vector<Int_t> fBBGEMhit_ptridx;
std::vector<Int_t> fBBGEMhit_sdtridx;
std::vector<Int_t> fBBGEMtrack_ptridx;
std::vector<Int_t> fBBGEMtrack_sdtridx;
std::vector<Int_t> fBBHODOhit_ptridx;
std::vector<Int_t> fBBHODOhit_sdtridx;
std::vector<Int_t> fBBPSTF1hit_ptridx;
std::vector<Int_t> fBBPSTF1hit_sdtridx;
std::vector<Int_t> fBBSHTF1hit_ptridx;
std::vector<Int_t> fBBSHTF1hit_sdtridx;
std::vector<Int_t> fHCALhit_ptridx;
std::vector<Int_t> fHCALhit_sdtridx;
//PTrack & SDTrack branches
Int_t fPTrack_ntracks;
std::vector<Int_t> fPTrack_TID;
std::vector<Int_t> fPTrack_PID;
std::vector<Double_t> fPTrack_posx;
std::vector<Double_t> fPTrack_posy;
std::vector<Double_t> fPTrack_posz;
std::vector<Double_t> fPTrack_momx;
std::vector<Double_t> fPTrack_momy;
std::vector<Double_t> fPTrack_momz;
std::vector<Double_t> fPTrack_polx;
std::vector<Double_t> fPTrack_poly;
std::vector<Double_t> fPTrack_polz;
std::vector<Double_t> fPTrack_Etot;
std::vector<Double_t> fPTrack_T;
Double_t fSDTrack_ntracks;
std::vector<Int_t> fSDTrack_TID;
std::vector<Int_t> fSDTrack_MID;
std::vector<Int_t> fSDTrack_PID;
std::vector<Double_t> fSDTrack_posx;
std::vector<Double_t> fSDTrack_posy;
std::vector<Double_t> fSDTrack_posz;
std::vector<Double_t> fSDTrack_momx;
std::vector<Double_t> fSDTrack_momy;
std::vector<Double_t> fSDTrack_momz;
std::vector<Double_t> fSDTrack_polx;
std::vector<Double_t> fSDTrack_poly;
std::vector<Double_t> fSDTrack_polz;
std::vector<Double_t> fSDTrack_Etot;
std::vector<Double_t> fSDTrack_T;
std::vector<Double_t> fSDTrack_vx;
std::vector<Double_t> fSDTrack_vy;
std::vector<Double_t> fSDTrack_vz;
std::vector<Double_t> fSDTrack_vnx;
std::vector<Double_t> fSDTrack_vny;
std::vector<Double_t> fSDTrack_vnz;
std::vector<Double_t> fSDTrack_vEkin;
//TH1D* h1_sizeHCal;
//TH1D* h1_sizeGEMs;
//Int_t ChanFromROC( std::string detname, Int_t crate, Int_t slot, Int_t chan ) const;
/*
// void PMTtoROC( Int_t s_plane, Int_t s_sector, Int_t s_proj, Int_t s_chan,
// Int_t& crate, Int_t& slot, Int_t& chan ) const;
// Int_t MakeROCKey( Int_t crate, Int_t slot, Int_t chan ) const;
*/
ClassDef(SBSSimDecoder,1) // Decoder for simulated SoLID spectrometer data
};
#endif