StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StRHICfHit.cxx
1 #include "StRHICfHit.h"
2 
3 ClassImp(StRHICfHit)
4 
5 #define RHICF_MAXLAYER_TOWERNUM 2
6 #define RHICF_SINGLE_TOWERNUM 8
7 #define RHICF_MULTI_TOWERNUM 16
8 #define RHICF_MAXLAYER_INDEX(a, b) (2*a+b)
9 #define RHICF_SINGLE_INDEX(a, b, c) (8*a+2*b+c)
10 #define RHICF_MULTI_INDEX(a, b, c, d) (16*a+4*b+2*c+d)
11 
12 StRHICfHit::StRHICfHit()
13 {
14  mIsSaveDataArray = false;
15  clear();
16 }
17 
18 StRHICfHit::~StRHICfHit()
19 {
20 }
21 
22 void StRHICfHit::clear()
23 {
24  memset(mPlateE, 0., sizeof(mPlateE));
25  memset(mGSOBarSmallE, 0., sizeof(mGSOBarSmallE));
26  memset(mGSOBarLargeE, 0., sizeof(mGSOBarLargeE));
27 
28  if(mIsSaveDataArray){
29  mL20 -> Reset();
30  mL90 -> Reset();
31  mGSOMaxLayer -> Reset();
32  mMaxPeakBin -> Reset();
33  mSingleHitNum -> Reset();
34  mSingleHitPos -> Reset();
35  mSinglePeakHeight -> Reset();
36  mSingleChiSquare -> Reset();
37  mMultiHitNum -> Reset();
38  mMultiHitPos -> Reset();
39  mMultiPeakHeight -> Reset();
40  mMultiPeakRaw-> Reset();
41  mMultiEnergySum -> Reset();
42  mMultiChiSquare -> Reset();
43  }
44 }
45 
46 void StRHICfHit::initDataArray()
47 {
48  mIsSaveDataArray = true;
49  mL20 = new TArrayF(RHICF_MAXLAYER_TOWERNUM);
50  mL90 = new TArrayF(RHICF_MAXLAYER_TOWERNUM);
51 
52  mGSOMaxLayer = new TArrayI(2*RHICF_MAXLAYER_TOWERNUM);
53  mMaxPeakBin = new TArrayI(2*RHICF_SINGLE_TOWERNUM);
54 
55  mSingleHitNum = new TArrayI(2*RHICF_SINGLE_TOWERNUM);
56  mSingleHitPos = new TArrayF(2*RHICF_SINGLE_TOWERNUM);
57  mSinglePeakHeight = new TArrayF(2*RHICF_SINGLE_TOWERNUM);
58  mSingleChiSquare = new TArrayF(2*RHICF_SINGLE_TOWERNUM);
59 
60  mMultiHitNum = new TArrayI(RHICF_MAXLAYER_TOWERNUM);
61  mMultiHitPos = new TArrayF(2*RHICF_MULTI_TOWERNUM);
62  mMultiPeakHeight = new TArrayF(2*RHICF_MULTI_TOWERNUM);
63  mMultiPeakRaw = new TArrayF(2*RHICF_MULTI_TOWERNUM);
64  mMultiEnergySum = new TArrayF(2*RHICF_MULTI_TOWERNUM);
65  mMultiChiSquare = new TArrayF(2*RHICF_SINGLE_TOWERNUM);
66 }
67 
68 void StRHICfHit::deleteDataArray()
69 {
70  mIsSaveDataArray = false;
71 
72  delete mL20;
73  delete mL90;
74  delete mGSOMaxLayer;
75  delete mMaxPeakBin;
76  delete mSingleHitNum;
77  delete mSingleHitPos;
78  delete mSinglePeakHeight;
79  delete mSingleChiSquare;
80  delete mMultiHitNum;
81  delete mMultiHitPos;
82  delete mMultiPeakHeight;
83  delete mMultiPeakRaw;
84  delete mMultiEnergySum;
85  delete mMultiChiSquare;
86 
87  mL20 = nullptr;
88  mL90 = nullptr;
89  mGSOMaxLayer = nullptr;
90  mMaxPeakBin = nullptr;
91  mSingleHitNum = nullptr;
92  mSingleHitPos = nullptr;
93  mSinglePeakHeight = nullptr;
94  mSingleChiSquare = nullptr;
95  mMultiHitNum = nullptr;
96  mMultiHitPos = nullptr;
97  mMultiPeakHeight = nullptr;
98  mMultiPeakRaw = nullptr;
99  mMultiEnergySum = nullptr;
100  mMultiChiSquare = nullptr;
101 }
102 
103 Bool_t StRHICfHit::isSaveDataArray(){return mIsSaveDataArray;}
104 
105 void StRHICfHit::setPlateEnergy(Int_t tower, Int_t plate, Float_t val) {mPlateE[tower][plate] = val;}
106 void StRHICfHit::setGSOBarEnergy(Int_t tower, Int_t layer, Int_t xy, Int_t bar, Float_t val)
107 {
108  if(tower==0){mGSOBarSmallE[layer][xy][bar] = val;}
109  if(tower==1){mGSOBarLargeE[layer][xy][bar] = val;}
110 }
111 
112 void StRHICfHit::setL20(Int_t tower, Float_t val){if(mL20){mL20->AddAt(val, tower);}}
113 void StRHICfHit::setL90(Int_t tower, Float_t val){if(mL90){mL90->AddAt(val, tower);}}
114 
115 void StRHICfHit::setGSOMaxLayer(Int_t tower, Int_t order, Int_t val){if(mGSOMaxLayer){mGSOMaxLayer->AddAt(val, RHICF_MAXLAYER_INDEX(tower, order));}}
116 void StRHICfHit::setMaxPeakBin(Int_t tower, Int_t layer, Int_t xy, Int_t val){if(mMaxPeakBin){mMaxPeakBin->AddAt(val, RHICF_SINGLE_INDEX(tower,layer,xy));}}
117 
118 void StRHICfHit::setSingleHitNum(Int_t tower, Int_t layer, Int_t xy, Int_t val){if(mSingleHitNum){mSingleHitNum->AddAt(val, RHICF_SINGLE_INDEX(tower,layer,xy));}}
119 void StRHICfHit::setSingleHitPos(Int_t tower, Int_t layer, Int_t xy, Float_t val){if(mSingleHitPos){mSingleHitPos->AddAt(val, RHICF_SINGLE_INDEX(tower,layer,xy));}}
120 void StRHICfHit::setSinglePeakHeight(Int_t tower, Int_t layer, Int_t xy, Float_t val){if(mSinglePeakHeight){mSinglePeakHeight->AddAt(val, RHICF_SINGLE_INDEX(tower,layer,xy));}}
121 void StRHICfHit::setSingleFitChi2(Int_t tower, Int_t layer, Int_t xy, Float_t val){if(mSingleChiSquare){mSingleChiSquare->AddAt(val, RHICF_SINGLE_INDEX(tower,layer,xy));}}
122 
123 void StRHICfHit::setMultiHitNum(Int_t tower, Int_t val){if(mMultiHitNum){mMultiHitNum->AddAt(val, tower);}}
124 void StRHICfHit::setMultiHitPos(Int_t tower, Int_t layer, Int_t xy, Int_t order, Float_t val){if(mMultiHitPos){mMultiHitPos->AddAt(val, RHICF_MULTI_INDEX(tower,layer,xy,order));}}
125 void StRHICfHit::setMultiPeakHeight(Int_t tower, Int_t layer, Int_t xy, Int_t order, Float_t val){if(mMultiPeakHeight){mMultiPeakHeight->AddAt(val, RHICF_MULTI_INDEX(tower,layer,xy,order));}}
126 void StRHICfHit::setMultiPeakRaw(Int_t tower, Int_t layer, Int_t xy, Int_t order, Float_t val){if(mMultiPeakRaw){mMultiPeakRaw->AddAt(val, RHICF_MULTI_INDEX(tower,layer,xy,order));}}
127 void StRHICfHit::setMultiEnergySum(Int_t tower, Int_t layer, Int_t xy, Int_t order, Float_t val){if(mMultiEnergySum){mMultiEnergySum->AddAt(val, RHICF_MULTI_INDEX(tower,layer,xy,order));}}
128 void StRHICfHit::setMultiFitChi2(Int_t tower, Int_t layer, Int_t xy, Float_t val){if(mMultiChiSquare){mMultiChiSquare->AddAt(val, RHICF_SINGLE_INDEX(tower,layer,xy));}}
129 
130 Float_t StRHICfHit::getPlateEnergy(Int_t tower, Int_t plate){return mPlateE[tower][plate];}
131 Float_t StRHICfHit::getGSOBarEnergy(Int_t tower, Int_t layer, Int_t xy, Int_t bar)
132 {
133  if(tower==0){return mGSOBarSmallE[layer][xy][bar];}
134  if(tower==1){return mGSOBarLargeE[layer][xy][bar];}
135  return 0;
136 }
137 
138 Float_t StRHICfHit::getL20(Int_t tower)
139 {
140  if(mL20){return mL20->At(tower);}
141  return 0.;
142 }
143 
144 Float_t StRHICfHit::getL90(Int_t tower)
145 {
146  if(mL90){return mL90->At(tower);}
147  return 0.;
148 }
149 
150 Int_t StRHICfHit::getGSOMaxLayer(Int_t tower, Int_t order)
151 {
152  if(mGSOMaxLayer){return mGSOMaxLayer->At(RHICF_MAXLAYER_INDEX(tower,order));}
153  return -999;
154 }
155 
156 Int_t StRHICfHit::getMaxPeakBin(Int_t tower, Int_t layer, Int_t xy)
157 {
158  if(mMaxPeakBin){return mMaxPeakBin->At(RHICF_SINGLE_INDEX(tower,layer,xy));}
159  return -999;
160 }
161 
162 Int_t StRHICfHit::getSingleHitNum(Int_t tower, Int_t layer, Int_t xy)
163 {
164  if(mSingleHitNum){return mSingleHitNum->At(RHICF_SINGLE_INDEX(tower,layer,xy));}
165  return -999;
166 }
167 
168 Float_t StRHICfHit::getSingleHitPos(Int_t tower, Int_t layer, Int_t xy)
169 {
170  if(mSingleHitPos){return mSingleHitPos->At(RHICF_SINGLE_INDEX(tower,layer,xy));}
171  return 0.;
172 }
173 
174 Float_t StRHICfHit::getSinglePeakHeight(Int_t tower, Int_t layer, Int_t xy)
175 {
176  if(mSinglePeakHeight){return mSinglePeakHeight->At(RHICF_SINGLE_INDEX(tower,layer,xy));}
177  return 0.;
178 }
179 
180 Float_t StRHICfHit::getSingleFitChi2(Int_t tower, Int_t layer, Int_t xy)
181 {
182  if(mSingleChiSquare){return mSingleChiSquare->At(RHICF_SINGLE_INDEX(tower,layer,xy));}
183  return 0.;
184 }
185 
186 Int_t StRHICfHit::getMultiHitNum(Int_t tower)
187 {
188  if(mMultiHitNum){return mMultiHitNum->At(tower);}
189  return -999;
190 }
191 
192 Float_t StRHICfHit::getMultiHitPos(Int_t tower, Int_t layer, Int_t xy, Int_t order)
193 {
194  if(mMultiHitPos){return mMultiHitPos->At(RHICF_MULTI_INDEX(tower,layer,xy,order));}
195  return 0.;
196 }
197 
198 Float_t StRHICfHit::getMultiPeakHeight(Int_t tower, Int_t layer, Int_t xy, Int_t order)
199 {
200  if(mMultiPeakHeight){return mMultiPeakHeight->At(RHICF_MULTI_INDEX(tower,layer,xy,order));}
201  return 0.;
202 }
203 
204 Float_t StRHICfHit::getMultiPeakRaw(Int_t tower, Int_t layer, Int_t xy, Int_t order)
205 {
206  if(mMultiPeakRaw){return mMultiPeakRaw->At(RHICF_MULTI_INDEX(tower,layer,xy,order));}
207  return 0.;
208 }
209 
210 Float_t StRHICfHit::getMultiEnergySum(Int_t tower, Int_t layer, Int_t xy, Int_t order)
211 {
212  if(mMultiEnergySum){return mMultiEnergySum->At(RHICF_MULTI_INDEX(tower,layer,xy,order));}
213  return 0.;
214 }
215 
216 Float_t StRHICfHit::getMultiFitChi2(Int_t tower, Int_t layer, Int_t xy)
217 {
218  if(mMultiChiSquare){return mMultiChiSquare->At(RHICF_SINGLE_INDEX(tower,layer,xy));}
219  return 0.;
220 }