1 #include "StRHICfRecoEnergy.h"
3 StRHICfRecoEnergy::StRHICfRecoEnergy()
8 StRHICfRecoEnergy::~StRHICfRecoEnergy()
10 for(
int it=0; it<kRHICfNtower; it++){
11 delete mLeakOutTableNeutron[it];
12 mLeakOutTableNeutron[it] =
nullptr;
13 for(
int ip=0; ip<kRHICfNplate; ip++){
14 delete mLeakInTablePhoton[it][ip];
15 delete mLeakOutTablePhoton[it][ip];
16 mLeakInTablePhoton[it][ip] =
nullptr;
17 mLeakOutTablePhoton[it][ip] =
nullptr;
22 void StRHICfRecoEnergy::init()
25 std::fill(mRecoHitNum, mRecoHitNum+kRHICfNtower, -999);
27 memset(mPlateE, 0,
sizeof(mPlateE));
28 memset(mPlateECorr, 0,
sizeof(mPlateECorr));
29 memset(mOverlap, 0,
sizeof(mOverlap));
30 memset(mRecoHitPos, 0,
sizeof(mRecoHitPos));
31 memset(mSumEnergy, 0,
sizeof(mSumEnergy));
32 memset(mResultEnergy, 0,
sizeof(mResultEnergy));
33 memset(mEnergyRatio, 0,
sizeof(mEnergyRatio));
34 memset(mMultiHitPos, 0,
sizeof(mMultiHitPos));
35 memset(mMultiPeakHeight, 0,
sizeof(mMultiPeakHeight));
38 bool StRHICfRecoEnergy::calculate()
40 for(
int it=0; it<kRHICfNtower; it++){
41 mSumEnergy[it][0] = getSumEnergy(it, 0, 15, mPlateE[it]);
42 mSumEnergy[it][1] = getSumEnergy(it, 1, 11, mPlateE[it]);
43 double mParticleEnergy = 0.;
44 recoPhotonEnergySimple(it, mParticleEnergy);
46 if(mParticleEnergy < mEnergyThreshold){setResultHitNum(it, 0);}
50 if(getResultHitNum(0)>0 && getResultHitNum(1)>0){
51 recoPhotonEnergyDouble();
53 for(
int it=0; it<2; it++){
54 if(mResultEnergy[it][kRHICfPhoton] < mEnergyThreshold){setResultHitNum(it, 0);}
59 if(getResultHitNum(0)>0 && getResultHitNum(1)==0){
61 recoPhotonEnergySingle(0);
63 if(getResultHitNum(0)==0 && getResultHitNum(1)>0){
65 recoPhotonEnergySingle(1);
69 for(
int it=0; it<kRHICfNtower; it++){
70 if(getResultHitNum(it) == 0){
continue;}
74 std::cout <<
"StRHICfRecoEnergy::calculate() -- Done" << std::endl;
78 void StRHICfRecoEnergy::setRunType(
int runType){mRunType = runType;}
80 void StRHICfRecoEnergy::setPlateEnergy(
int tower,
int layer,
double val){mPlateE[tower][layer] = val;}
82 void StRHICfRecoEnergy::setResultHitPos(
int tower,
int xy,
double val){mRecoHitPos[tower][xy] = val;}
84 void StRHICfRecoEnergy::setResultHitNum(
int tower,
int val){mRecoHitNum[tower] = val;}
86 void StRHICfRecoEnergy::setMultiHitPos(
int tower,
int layer,
int xy,
int order,
double val){mMultiHitPos[tower][layer][xy][order] = val;}
88 void StRHICfRecoEnergy::setMultiPeakHeight(
int tower,
int layer,
int xy,
int order,
double val){mMultiPeakHeight[tower][layer][xy][order] = val;}
90 void StRHICfRecoEnergy::setOverlap(
int tower,
int xy,
bool val){mOverlap[tower][xy] = val;}
92 void StRHICfRecoEnergy::setLeakageInTable(
int tower,
int layer, TH2D* table){mLeakInTablePhoton[tower][layer] = table;}
94 void StRHICfRecoEnergy::setLeakageOutTablePhoton(
int tower,
int layer, TH2D* table){mLeakOutTablePhoton[tower][layer] = table;}
96 void StRHICfRecoEnergy::setLeakageOutTableNeutron(
int tower, TH2D* table){mLeakOutTableNeutron[tower] = table;}
98 int StRHICfRecoEnergy::getResultHitNum(
int tower){
return mRecoHitNum[tower];}
100 double StRHICfRecoEnergy::getPlateSumEnergy(
int tower,
bool all){
101 if(all){
return mSumEnergy[tower][0];}
102 else{
return mSumEnergy[tower][1];}
106 double StRHICfRecoEnergy::getResultEnergy(
int tower,
int particle){
return mResultEnergy[tower][particle];}
108 double StRHICfRecoEnergy::getEnergyRatio(
int tower,
int order){
return mEnergyRatio[tower][order];}
110 void StRHICfRecoEnergy::recoPhotonEnergySimple(
int tower,
double& energy)
112 double posX = mRecoHitPos[tower][0];
113 double posY = mRecoHitPos[tower][1];
114 double caliSumEnergy = 0.;
116 for(
int ip=1; ip<=11; ip++){
117 double efficiency = getLeakageOutPhoton(tower, ip, posX, posY);
118 if(efficiency<0.1 || efficiency>2.){
120 double gsobarSize = checkGSOBarSize(tower);
121 double edgeSize = (ip<12 ? 1.0 : 2.0);
123 if(posX < edgeSize){posX = edgeSize;}
124 if(posX > gsobarSize-edgeSize){posX = gsobarSize-edgeSize;}
125 if(posY < edgeSize){posY = edgeSize;}
126 if(posY > gsobarSize-edgeSize){posY = gsobarSize-edgeSize;}
128 efficiency = getLeakageOutPhoton(tower, ip, posX, posY);
130 caliSumEnergy += mPlateE[tower][ip]/efficiency;
132 energy = getPhotonEnergyConvert(tower, caliSumEnergy);
135 void StRHICfRecoEnergy::recoPhotonEnergySingle(
int tower)
137 for(
int it=0; it<kRHICfNtower; it++){
139 mSumEnergy[it][0] = getSumEnergy(it, 0, 15, mPlateECorr[it]);
140 mSumEnergy[it][1] = getSumEnergy(it, 1, 11, mPlateECorr[it]);
141 mResultEnergy[it][kRHICfPhoton] = getPhotonEnergyConvert(it, mSumEnergy[it][1]);
144 mSumEnergy[it][0] = getSumEnergy(it, 0, 15, mPlateE[it]);
145 mSumEnergy[it][1] = 0.;
146 mResultEnergy[it][kRHICfPhoton] = getPhotonEnergyConvert(it, mSumEnergy[it][1]);
151 void StRHICfRecoEnergy::recoPhotonEnergyDouble()
153 double mLeakInEffi[kRHICfNtower][kRHICfNplate];
154 double mLeakOutEffi[kRHICfNtower][kRHICfNplate];
156 memset(mLeakInEffi, 0,
sizeof(mLeakInEffi));
157 memset(mLeakOutEffi, 0,
sizeof(mLeakOutEffi));
159 for(
int it=0; it<kRHICfNtower; it++){
160 double posX = mRecoHitPos[it][0];
161 double posY = mRecoHitPos[it][1];
162 double gsobarSize = checkGSOBarSize(it);
164 if(posX < 0.){posX = 0.1;}
165 if(posY < 0.){posY = 0.1;}
166 if(posX > gsobarSize){posX = gsobarSize-0.1;}
167 if(posY > gsobarSize){posY = gsobarSize-0.1;}
169 for(
int ip=0; ip<kRHICfNplate; ip++){
170 mLeakOutEffi[it][ip] = getLeakageOutPhoton(it, ip, posX, posY);
171 mLeakInEffi[it][ip] = getLeakageInPhoton(it, ip, posX, posY);
173 if(ip >= 11){mLeakOutEffi[it][ip] = mLeakOutEffi[it][10];}
174 if(ip >= 9){mLeakInEffi[it][ip] = mLeakInEffi[it][8];}
178 for(
int ip=0; ip<kRHICfNplate; ip++){
179 double leakInFactor = mLeakInEffi[1][ip] * mLeakInEffi[0][ip] - 1.;
180 mPlateECorr[0][ip] = ((mLeakInEffi[1][ip] * mPlateE[1][ip] - mPlateE[0][ip]) / leakInFactor) / mLeakOutEffi[0][ip];
181 mPlateECorr[1][ip] = ((mLeakInEffi[0][ip] * mPlateE[0][ip] - mPlateE[1][ip]) / leakInFactor) / mLeakOutEffi[1][ip];
184 for(
int it=0; it<kRHICfNtower; it++){
185 mSumEnergy[it][0] = getSumEnergy(it, 0, 15, mPlateECorr[it]);
186 mSumEnergy[it][1] = getSumEnergy(it, 1, 11, mPlateECorr[it]);
187 mResultEnergy[it][kRHICfPhoton] = getPhotonEnergyConvert(it, mSumEnergy[it][1]);
191 void StRHICfRecoEnergy::recoHadronEnergy(
int tower)
193 double posX = mRecoHitPos[tower][0];
194 double posY = mRecoHitPos[tower][1];
195 double efficiency = getLeakageOutNeutron(tower, posX, posY);
196 double sumEnergy = getSumEnergy(tower, 0, 15, mPlateE[tower]);
197 double sumECorr = sumEnergy/efficiency;
198 mResultEnergy[tower][kRHICfHadron] = getHadronEnergyConvert(tower, sumECorr);
201 void StRHICfRecoEnergy::correctLightYield()
203 for(
int it=0; it<kRHICfNtower; it++){
205 if(getResultHitNum(it)==1){
206 double posX = mRecoHitPos[it][0];
207 double posY = mRecoHitPos[it][1];
208 getCalibrationEnergy(it, posX, posY);
212 if(getResultHitNum(it) > 1){
213 double posX1 = mMultiHitPos[it][0][0][0];
214 double posY1 = mMultiHitPos[it][0][1][0];
215 double posX2 = mMultiHitPos[it][0][0][1];
216 double posY2 = mMultiHitPos[it][0][1][1];
217 double firstRatio = 0.;
218 double secondRatio = 0.;
220 if(!mOverlap[it][0]){firstRatio += mMultiPeakHeight[it][0][0][0];}
221 if(!mOverlap[it][1]){firstRatio += mMultiPeakHeight[it][0][1][0];}
222 if(!mOverlap[it][0]){firstRatio += mMultiPeakHeight[it][1][0][0];}
223 if(!mOverlap[it][1]){firstRatio += mMultiPeakHeight[it][1][1][0];}
224 if(!mOverlap[it][0]){secondRatio += mMultiPeakHeight[it][0][0][1];}
225 if(!mOverlap[it][1]){secondRatio += mMultiPeakHeight[it][0][1][1];}
226 if(!mOverlap[it][0]){secondRatio += mMultiPeakHeight[it][1][0][1];}
227 if(!mOverlap[it][1]){secondRatio += mMultiPeakHeight[it][1][1][1];}
229 mEnergyRatio[it][0] = firstRatio/(firstRatio + secondRatio);
230 mEnergyRatio[it][1] = 1. - mEnergyRatio[it][0];
232 getCalibrationEnergy(it, posX1, posY1, posX2, posY2, mEnergyRatio[it][0], mEnergyRatio[it][1]);
237 void StRHICfRecoEnergy::getCalibrationEnergy(
int tower,
double posX1,
double posY1,
double posX2,
double posY2,
double firstRatio,
double secondRatio)
239 for(
int ip=0; ip<kRHICfNplate; ip++){
240 double efficiency1 = getLeakageOutPhoton(tower, ip, posX1, posY1);
241 double efficiency2 = getLeakageOutPhoton(tower, ip, posX2, posY2);
243 if(efficiency1 < 0.1 || efficiency1 > 2.){
244 double gsobarSize = checkGSOBarSize(tower);
245 double edgeSize = (ip<12 ? 1.0 : 2.0);
247 if(posX1 < edgeSize){posX1 = edgeSize;}
248 if(posX1 > gsobarSize-edgeSize){posX1 = gsobarSize-edgeSize;}
249 if(posY1 < edgeSize){posY1 = edgeSize;}
250 if(posY1 > gsobarSize-edgeSize){posY1 = gsobarSize-edgeSize;}
252 efficiency1 = getLeakageOutPhoton(tower, ip, posX1, posY1);
254 if(efficiency2 < 0.1 || efficiency2 > 2.){
255 double gsobarSize = checkGSOBarSize(tower);
256 double edgeSize = (ip<12 ? 1.0 : 2.0);
258 if(posX2 < edgeSize){posX2 = edgeSize;}
259 if(posX2 > gsobarSize-edgeSize){posX2 = gsobarSize-edgeSize;}
260 if(posY2 < edgeSize){posY2 = edgeSize;}
261 if(posY2 > gsobarSize-edgeSize){posY2 = gsobarSize-edgeSize;}
263 efficiency2 = getLeakageOutPhoton(tower, ip, posX2, posY2);
266 if(firstRatio <= -100. || secondRatio <= -100.){
267 mPlateECorr[tower][ip] = mPlateE[tower][ip]/efficiency1;
269 if(firstRatio >= 0. || secondRatio >= 0.){
270 double calibFactor = efficiency1*firstRatio + efficiency2*secondRatio;
271 mPlateECorr[tower][ip] = mPlateE[tower][ip]/calibFactor;
276 double StRHICfRecoEnergy::getSumEnergy(
int tower,
int startIdx,
int endIdx,
double* energy)
278 double mSumEnergy = 0.;
279 for(
int ip=startIdx; ip<=endIdx; ip++){
280 if(ip<11){mSumEnergy += energy[ip];}
281 else{mSumEnergy += energy[ip]*2.;}
286 double StRHICfRecoEnergy::getPhotonEnergyConvert(
int tower,
double sumEnergy)
288 if(mRunType==kRHICfTL){
289 if(tower==0)
return 31.1323*sumEnergy+1.42462;
290 if(tower==1)
return 27.3429*sumEnergy+1.11522;
292 if(mRunType==kRHICfTS){
293 if(tower==0)
return 31.1666*sumEnergy+1.39715;
294 if(tower==1)
return 27.3389*sumEnergy+1.12892;
296 if(mRunType==kRHICfTOP){
297 if(tower==0)
return 31.1749*sumEnergy+1.41172;
298 if(tower==1)
return 27.3434*sumEnergy+1.12205;
303 double StRHICfRecoEnergy::getHadronEnergyConvert(
int tower,
double sumEnergy)
305 if(tower==0)
return 87.383*sumEnergy-11.1752;
306 if(tower==1)
return 68.472*sumEnergy-15.0983;
310 double StRHICfRecoEnergy::getLeakageInPhoton(
int tower,
int layer,
double x,
double y)
312 return mLeakInTablePhoton[tower][layer]->Interpolate(x, y);
315 double StRHICfRecoEnergy::getLeakageOutPhoton(
int tower,
int layer,
double x,
double y)
317 return mLeakOutTablePhoton[tower][layer]->Interpolate(x, y);
320 double StRHICfRecoEnergy::getLeakageOutNeutron(
int tower,
double x,
double y)
322 return mLeakOutTableNeutron[tower]->Interpolate(x, y);