Hall C ROOT/C++ Analyzer (hcana)
THcShower.h
Go to the documentation of this file.
1 #ifndef ROOT_THcShower
2 #define ROOT_THcShower
3 
5 // //
6 // THcShower //
7 // //
9 
10 #include "TClonesArray.h"
11 #include "THaNonTrackingDetector.h"
12 #include "THcHitList.h"
13 #include "THcShowerPlane.h"
14 #include "THcShowerArray.h"
15 #include "THcShowerHit.h"
16 #include "TMath.h"
17 
18 class THcShower : public THaNonTrackingDetector, public THcHitList {
19 
20 public:
21  THcShower( const char* name, const char* description = "",
22  THaApparatus* a = NULL );
23  virtual ~THcShower();
24  virtual void Clear( Option_t* opt="" );
25  virtual Int_t Decode( const THaEvData& );
26  virtual EStatus Init( const TDatime& run_time );
27  virtual Int_t CoarseProcess( TClonesArray& tracks );
28  virtual Int_t FineProcess( TClonesArray& tracks );
29 
31 
32  Int_t GetNHits() const { return fNhits; }
33 
34  Int_t GetNBlocks(Int_t NLayer) const { return fNBlocks[NLayer];}
35 
36  Double_t GetXPos(Int_t NLayer, Int_t NRow) const {
37  return fXPos[NLayer][NRow];
38  }
39 
40  Double_t GetYPos(Int_t NLayer, Int_t Side) const {
41 
42  //Side = 0 for postive (right) side
43  //Side = 1 for negative (left) side
44 
45  return fYPos[2*NLayer+(1-Side)];
46  }
47 
48  Double_t GetZPos(Int_t NLayer) const {return fLayerZPos[NLayer];}
49 
50  Double_t GetBlockThick(Int_t NLayer) {return BlockThick[NLayer];}
51 
52  Int_t GetPedLimit(Int_t NBlock, Int_t NLayer, Int_t Side) {
53  if (Side!=0&&Side!=1) {
54  cout << "*** Wrong Side in GetPedLimit:" << Side << " ***" << endl;
55  return -1;
56  }
57  Int_t nelem = 0;
58  for (Int_t i=0; i<NLayer; i++) nelem += fNBlocks[i];
59  nelem += NBlock;
60  return ( Side == 0 ? fShPosPedLimit[nelem] : fShNegPedLimit[nelem]);
61  }
62 
63  Double_t GetGain(Int_t NBlock, Int_t NLayer, Int_t Side) {
64  if (Side!=0&&Side!=1) {
65  cout << "*** Wrong Side in GetGain:" << Side << " ***" << endl;
66  return -1;
67  }
68  Int_t nelem = 0;
69  for (Int_t i=0; i<NLayer; i++) nelem += fNBlocks[i];
70  nelem += NBlock;
71  return ( Side == 0 ? fPosGain[nelem] : fNegGain[nelem]);
72  }
73 
74  Double_t GetPedDefault(Int_t NBlock, Int_t NLayer, Int_t Side) {
75  if (Side!=0&&Side!=1) {
76  cout << "*** Wrong Side in GetPedDefault:" << Side << " ***" << endl;
77  return -1;
78  }
79  Int_t nelem = 0;
80  for (Int_t i=0; i<NLayer; i++) nelem += fNBlocks[i];
81  nelem += NBlock;
82  return ( Side == 0 ? fPedPosDefault[nelem] : fPedNegDefault[nelem] );
83  }
84 
85  Double_t GetWindowMin(Int_t NBlock, Int_t NLayer, Int_t Side) {
86  if (Side!=0&&Side!=1) {
87  cout << "*** Wrong Side in GetWindowMin:" << Side << " ***" << endl;
88  return -1;
89  }
90  Int_t nelem = 0;
91  for (Int_t i=0; i<NLayer; i++) nelem += fNBlocks[i];
92  nelem += NBlock;
93  return ( Side == 0 ? fPosAdcTimeWindowMin[nelem] : fNegAdcTimeWindowMin[nelem] );
94  }
95 
96  Double_t GetWindowMax(Int_t NBlock, Int_t NLayer, Int_t Side) {
97  if (Side!=0&&Side!=1) {
98  cout << "*** Wrong Side in GetWindowMax:" << Side << " ***" << endl;
99  return -1;
100  }
101  Int_t nelem = 0;
102  for (Int_t i=0; i<NLayer; i++) nelem += fNBlocks[i];
103  nelem += NBlock;
104  return ( Side == 0 ? fPosAdcTimeWindowMax[nelem] : fNegAdcTimeWindowMax[nelem] );
105  }
106 
108  return fADCMode;
109  }
111  return fPosAdcTimeWindowMin;
112  }
114  return fNegAdcTimeWindowMin;
115  }
117  return fPosAdcTimeWindowMax;
118  }
120  return fNegAdcTimeWindowMax;
121  }
123  return fAdcTdcOffset;
124  }
126  return fShMinPeds;
127  }
128 
130  return fNLayers;
131  }
133  return fNBlocks[layer];
134  }
135 
136  //Coordinate correction for HMS single PMT modules.
137  //PMT attached at right (positive) side.
138 
140  return TMath::Exp(y/fAcor)/(1. + y*y/fBcor);
141  }
142 
143  //Coordinate correction for HMS double PMT modules.
144  //
145 
147  if (side!=0&&side!=1) {
148  cout << "THcShower::Ycor : wrong side " << side << endl;
149  return 0.;
150  }
151  Int_t sign = 1 - 2*side;
152  // return (fCcor + sign*y)/(fCcor + sign*y/fDcor);
153  return (fCcor[side] + sign*y)/(fCcor[side] + sign*y/fDcor[side]);
154  }
155 
156  // Coordinate correction for SHMS Preshower modules.
157  //
158 
160 
161  if (side!=0&&side!=1) {
162  cout << "THcShower::YcorPr : wrong side " << side << endl;
163  return 0.;
164  }
165 
166  Float_t cor;
167 
168  // Check if the hit coordinate matches the fired block's side.
169 
170  if ((y < 0. && side == 1) || (y > 0. && side == 0))
171  cor = 1./(1. + TMath::Power(TMath::Abs(y)/fAcor, fBcor));
172  else
173  cor = 1.;
174 
175  return cor;
176  }
177 
178  // Get part of energy deposited in the cluster matched to the given
179  // spectrometer Track, limited by a range of layers.
180 
181  Float_t GetShEnergy(THaTrack*, UInt_t NLayers, UInt_t L0=0);
182 
183  THcShower(); // for ROOT I/O
184 
185 protected:
186 
189  Int_t fADCMode; // != 0 if using FADC
190  // 1 == Use the pulse int - pulse ped
191  // 2 == Use the sample integral - known ped
192  // 3 == Use the sample integral - sample ped
193  static const Int_t kADCStandard=0;
194  static const Int_t kADCDynamicPedestal=1;
195  static const Int_t kADCSampleIntegral=2;
196  static const Int_t kADCSampIntDynPed=3;
204 
205  Int_t fAnalyzePedestals; // Flag for pedestal analysis.
206 
207  Int_t* fShPosPedLimit; // [fNTotBlocks] ADC limits for pedestal calc.-s.
209 
210  Int_t fShMinPeds; // Min.number of events to analyze pedestals.
211 
212  Double_t* fPosGain; // [fNTotBlocks] Gain constants from calibration
214 
215  // Per-event data
216 
217  Int_t fNhits; // Total number of hits
218  Int_t fNclust; // Number of clusters
219  Int_t fNclustTrack; // NUmber of cluster that match best track
220  Int_t fNclustArrayTrack; // NUmber of cluster that match best track
221  Int_t fSizeClustArray; // NUmber of blocks in cluster which matches the best track
222  Int_t fNblockHighEnergy; // NUmber of array block (1-224) that has the highest energy in cluster
223  Double_t fXclustTrack; // X pos of cluster that match best track
224  Double_t fXTrack; // X pos of best track that match cluster
225  Double_t fYclustTrack; // Y pos of cluster that match best track
226  Double_t fYTrack; // Y pos of best track that match cluster
227  Double_t fXclustArrayTrack; // X pos of cluster that match best track
228  Double_t fXTrackArray; // X pos of best track that match cluster
229  Double_t fYclustArrayTrack; // Y pos of cluster that match best track
230  Double_t fYTrackArray; // Y pos of best track that match cluster
231  Int_t fNtracks; // Number of shower tracks, i.e. number of
232  // cluster-to-track association
233  Double_t fEtot; // Total energy
234  Double_t fEtotNorm; // Total energy divided by spec central momentum
235  Double_t fEtrack; // Cluster energy associated to the best track
236  Double_t fEtrackNorm; // Cluster energy divided by momentum for the best track
237  Double_t fEPRtrack; // Preshower part of cluster energy of the best track
238  Double_t fEPRtrackNorm; // Preshower part of cluster energy divided by momentum for the best track
239  Double_t fETotTrackNorm; // Total energy divided by momentum of the best track
240 
241  THcShowerClusterList* fClusterList; // List of hit clusters
242 
243 
244  // Geometrical parameters.
245 
246  char** fLayerNames;
247  UInt_t fNLayers; // Number of layers in the calorimeter
248  UInt_t fNTotLayers; // Number of layers including array
249  UInt_t fHasArray; // If !=0 fly's eye array behind preshower
250  Double_t* fLayerZPos; // Z positions of fronts of layers
251  // Following apply to just sideways readout layers
252  Double_t* BlockThick; // Thickness of blocks
253  UInt_t* fNBlocks; // [fNLayers] number of blocks per layer
254  UInt_t fNTotBlocks; // Total number of shower counter blocks
255  Double_t** fXPos; // [fNLayers] X,Y,Z positions of blocks
258  UInt_t fNegCols; // # of columns with neg. side PMTs only.
259  Double_t fSlop; // Track to cluster vertical slop distance.
260  Int_t fvTest; // fiducial volume test flag for tracking
261  Double_t fvDelta; // Exclusion band width for fiducial volume
262 
263  Double_t fvXmin; // Fiducial volume limits
267 
268  Int_t fdbg_raw_cal; // Shower debug flags
273  Int_t fdbg_init_cal; // No counterpart in engine, added to debug
274  // calorimeter initialization
275 
276  Double_t fAcor; // Coordinate correction constants
278  Double_t fCcor[2]; // for positive ad negative side PMTs
280 
281  THcShowerPlane** fPlanes; // [fNLayers] Shower Plane objects
283 
284  void ClearEvent();
285  void DeleteArrays();
286  virtual Int_t ReadDatabase( const TDatime& date );
287  virtual Int_t DefineVariables( EMode mode = kDefine );
288 
289  void Setup(const char* name, const char* description);
290 
291  // Cluster to track association method.
292  Int_t MatchCluster(THaTrack*, Double_t&, Double_t&);
293 
294  void ClusterHits(THcShowerHitSet& HitSet, THcShowerClusterList* ClusterList);
295 
296  virtual Int_t End(THaRunBase *r = 0);
297 
298  friend class THcShowerPlane; //to access debug flags.
299  friend class THcShowerArray; //to access debug flags.
300 
301  ClassDef(THcShower,0) // Shower counter detector
302 };
303 
305 
306 // Various helper functions to accumulate hit related quantities.
307 
313 
314 // Methods to calculate coordinates and energy depositions for a given cluster.
315 
316 Double_t clX(THcShowerCluster* cluster);
317 Double_t clY(THcShowerCluster* cluster);
318 Double_t clZ(THcShowerCluster* cluster);
319 Double_t clE(THcShowerCluster* cluster);
321 Double_t clEplane(THcShowerCluster* cluster, Int_t iplane, Int_t side);
322 
323 #endif
Int_t fdbg_sparsified_cal
Definition: THcShower.h:270
Double_t * fPosGain
Definition: THcShower.h:212
Int_t GetNLayers()
Definition: THcShower.h:129
Double_t fvXmax
Definition: THcShower.h:264
void DeleteArrays()
Definition: THcShower.cxx:616
UInt_t fNTotBlocks
Definition: THcShower.h:254
Double_t GetBlockThick(Int_t NLayer)
Definition: THcShower.h:50
Double_t fEPRtrackNorm
Definition: THcShower.h:238
Double_t fEPRtrack
Definition: THcShower.h:237
Int_t * fPedPosDefault
Definition: THcShower.h:201
Double_t * GetNegAdcTimeWindowMax()
Definition: THcShower.h:119
Double_t * GetNegAdcTimeWindowMin()
Definition: THcShower.h:113
Double_t fAcor
Definition: THcShower.h:276
Double_t GetWindowMin(Int_t NBlock, Int_t NLayer, Int_t Side)
Definition: THcShower.h:85
Double_t fAdcTdcOffset
Definition: THcShower.h:203
Fly's eye array of shower blocks.
Double_t clY(THcShowerCluster *cluster)
Definition: THcShower.cxx:953
Double_t addX(Double_t x, THcShowerHit *h)
Definition: THcShower.cxx:925
float Float_t
Double_t fXTrackArray
Definition: THcShower.h:228
const char Option_t
virtual void Clear(Option_t *opt="")
Definition: THcShower.cxx:646
Double_t GetYPos(Int_t NLayer, Int_t Side) const
Definition: THcShower.h:40
Double_t addE(Double_t x, THcShowerHit *h)
Definition: THcShower.cxx:921
static const Int_t kADCSampIntDynPed
Definition: THcShower.h:196
Double_t * fNegAdcTimeWindowMax
Definition: THcShower.h:200
Int_t fNclust
Definition: THcShower.h:218
Builds a Hall C ENGINE style list of raw hits from raw data.
Definition: THcHitList.h:27
Double_t * fLayerZPos
Definition: THcShower.h:250
Double_t clEplane(THcShowerCluster *cluster, Int_t iplane, Int_t side)
Definition: THcShower.cxx:996
static const Int_t kADCStandard
Definition: THcShower.h:193
Double_t fETotTrackNorm
Definition: THcShower.h:239
vector< THcShowerCluster * > THcShowerClusterList
Definition: THcShowerHit.h:88
Double_t fEtot
Definition: THcShower.h:233
Float_t Ycor(Double_t y)
Definition: THcShower.h:139
int Int_t
bool Bool_t
Double_t fCcor[2]
Definition: THcShower.h:278
Double_t clE(THcShowerCluster *cluster)
Definition: THcShower.cxx:980
virtual Int_t Decode(const THaEvData &)
Definition: THcShower.cxx:692
Double_t GetNormETot()
Definition: THcShower.cxx:1295
Int_t fADCMode
Definition: THcShower.h:189
Int_t fNtracks
Definition: THcShower.h:231
Double_t * fYPos
Definition: THcShower.h:256
Int_t fdbg_clusters_cal
Definition: THcShower.h:271
Short_t Abs(Short_t d)
Double_t clZ(THcShowerCluster *cluster)
Definition: THcShower.cxx:972
Int_t * fShPosPedLimit
Definition: THcShower.h:207
UInt_t fNegCols
Definition: THcShower.h:258
Double_t fvYmax
Definition: THcShower.h:266
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Double_t ** fXPos
Definition: THcShower.h:255
Double_t GetWindowMax(Int_t NBlock, Int_t NLayer, Int_t Side)
Definition: THcShower.h:96
THcShowerClusterList * fClusterList
Definition: THcShower.h:241
virtual Int_t CoarseProcess(TClonesArray &tracks)
Definition: THcShower.cxx:740
Double_t fEtotNorm
Definition: THcShower.h:234
Double_t GetZPos(Int_t NLayer) const
Definition: THcShower.h:48
Double_t fYclustArrayTrack
Definition: THcShower.h:229
Float_t Ycor(Double_t y, Int_t side)
Definition: THcShower.h:146
Int_t fdbg_init_cal
Definition: THcShower.h:273
Double_t * fPosAdcTimeWindowMax
Definition: THcShower.h:199
Double_t * fNegGain
Definition: THcShower.h:213
Double_t clX(THcShowerCluster *cluster)
Definition: THcShower.cxx:962
Double_t * fZPos
Definition: THcShower.h:257
void ClearEvent()
Double_t fvYmin
Definition: THcShower.h:265
Double_t GetAdcTdcOffset()
Definition: THcShower.h:122
Float_t GetShEnergy(THaTrack *, UInt_t NLayers, UInt_t L0=0)
Definition: THcShower.cxx:1133
Int_t GetNHits() const
Definition: THcShower.h:32
Bool_t * fPresentP
Definition: THcShower.h:187
virtual Int_t DefineVariables(EMode mode=kDefine)
Definition: THcShower.cxx:543
Double_t fDcor[2]
Definition: THcShower.h:279
Double_t * BlockThick
Definition: THcShower.h:252
char ** fLayerNames
Definition: THcShower.h:246
static const Int_t kADCDynamicPedestal
Definition: THcShower.h:194
Double_t fBcor
Definition: THcShower.h:277
Double_t * GetPosAdcTimeWindowMax()
Definition: THcShower.h:116
Int_t GetMinPeds()
Definition: THcShower.h:125
Double_t fvDelta
Definition: THcShower.h:261
Int_t fShMinPeds
Definition: THcShower.h:210
virtual Int_t FineProcess(TClonesArray &tracks)
Definition: THcShower.cxx:1216
Double_t GetGain(Int_t NBlock, Int_t NLayer, Int_t Side)
Definition: THcShower.h:63
Int_t fNclustArrayTrack
Definition: THcShower.h:220
Double_t fYTrack
Definition: THcShower.h:226
Int_t GetADCMode()
Definition: THcShower.h:107
Double_t fvXmin
Definition: THcShower.h:263
auto * a
void Setup(const char *name, const char *description)
Definition: THcShower.cxx:66
UInt_t * fNBlocks
Definition: THcShower.h:253
Int_t GetNBlocks(Int_t layer)
Definition: THcShower.h:132
unsigned int UInt_t
UInt_t fNLayers
Definition: THcShower.h:247
virtual Int_t ReadDatabase(const TDatime &date)
Definition: THcShower.cxx:206
Double_t * GetPosAdcTimeWindowMin()
Definition: THcShower.h:110
Float_t YcorPr(Double_t y, Int_t side)
Definition: THcShower.h:159
Int_t fvTest
Definition: THcShower.h:260
Double_t * fNegAdcTimeWindowMin
Definition: THcShower.h:198
Double_t * fPosAdcTimeWindowMin
Definition: THcShower.h:197
THcShowerHitSet THcShowerCluster
Definition: THcShowerHit.h:81
Double_t clEpr(THcShowerCluster *cluster)
Definition: THcShower.cxx:986
THcShowerArray * fArray
Definition: THcShower.h:282
Double_t Exp(Double_t x)
Double_t fSlop
Definition: THcShower.h:259
Int_t fdbg_tracks_cal
Definition: THcShower.h:272
Int_t fdbg_decoded_cal
Definition: THcShower.h:269
double Double_t
UInt_t fHasArray
Definition: THcShower.h:249
Int_t fSizeClustArray
Definition: THcShower.h:221
virtual Int_t End(THaRunBase *r=0)
Definition: THcShower.cxx:1299
Int_t fEvent
Definition: THcShower.h:188
static const Int_t kADCSampleIntegral
Definition: THcShower.h:195
Double_t fYclustTrack
Definition: THcShower.h:225
Generic segmented shower detector.
Definition: THcShower.h:18
Double_t fEtrackNorm
Definition: THcShower.h:236
Int_t GetPedLimit(Int_t NBlock, Int_t NLayer, Int_t Side)
Definition: THcShower.h:52
One plane of shower blocks with side readout.
UInt_t fNTotLayers
Definition: THcShower.h:248
THcShowerPlane ** fPlanes
Definition: THcShower.h:281
Double_t fXclustTrack
Definition: THcShower.h:223
Int_t fNclustTrack
Definition: THcShower.h:219
set< THcShowerHit * > THcShowerHitSet
Definition: THcShowerHit.h:78
Int_t fdbg_raw_cal
Definition: THcShower.h:268
Double_t GetPedDefault(Int_t NBlock, Int_t NLayer, Int_t Side)
Definition: THcShower.h:74
Int_t * fShNegPedLimit
Definition: THcShower.h:208
Double_t addEpr(Double_t x, THcShowerHit *h)
Definition: THcShower.cxx:937
Int_t fNhits
Definition: THcShower.h:217
Double_t addZ(Double_t x, THcShowerHit *h)
Definition: THcShower.cxx:933
Int_t * fPedNegDefault
Definition: THcShower.h:202
Int_t MatchCluster(THaTrack *, Double_t &, Double_t &)
Definition: THcShower.cxx:1028
Int_t fNblockHighEnergy
Definition: THcShower.h:222
Double_t fYTrackArray
Definition: THcShower.h:230
virtual ~THcShower()
Definition: THcShower.cxx:591
Double_t addY(Double_t x, THcShowerHit *h)
Definition: THcShower.cxx:929
Int_t GetNBlocks(Int_t NLayer) const
Definition: THcShower.h:34
Double_t fXTrack
Definition: THcShower.h:224
Int_t fAnalyzePedestals
Definition: THcShower.h:205
Double_t fXclustArrayTrack
Definition: THcShower.h:227
void ClusterHits(THcShowerHitSet &HitSet, THcShowerClusterList *ClusterList)
Definition: THcShower.cxx:871
Double_t fEtrack
Definition: THcShower.h:235
char name[80]
Double_t GetXPos(Int_t NLayer, Int_t NRow) const
Definition: THcShower.h:36
ClassDef(THcHitList, 0)
virtual EStatus Init(const TDatime &run_time)
Definition: THcShower.cxx:145