1 #include "StRHICfPID.h"
3 StRHICfPID::StRHICfPID()
8 void StRHICfPID::init()
10 std::fill(mPID, mPID+kRHICfNtower, -1);
11 std::fill(mPlateSumE, mPlateSumE+kRHICfNtower, 0.);
12 std::fill(mL20, mL20+kRHICfNtower, 0.);
13 std::fill(mL90, mL90+kRHICfNtower, 0.);
14 std::fill(&mPlateE[0][0], &mPlateE[kRHICfNtower-1][kRHICfNplate], 0.);
17 void StRHICfPID::setPlateEnergy(
int tower,
int layer,
float val)
19 mPlateE[tower][layer] = val;
22 int StRHICfPID::getPID(
int tower){
return mPID[tower];}
23 float StRHICfPID::getL20(
int tower){
return mL20[tower];}
24 float StRHICfPID::getL90(
int tower){
return mL90[tower];}
26 bool StRHICfPID::calculate()
28 for(
int it=0; it<kRHICfNtower; it++){
29 for(
int ip=0; ip<mPlateIdxNum; ip++){mPlateSumE[it] += layerSumEnergy(it, ip);}
30 mPlateSumE[it] += mPlateE[it][0];
32 mL20[it] = findRadiationLength(it, mL20Const);
33 mL90[it] = findRadiationLength(it, mL90Const);
35 if(mL90[it] <= 0.15 * mL20[it] + 20){mPID[it] = kRHICfPhoton;}
36 else{mPID[it] = kRHICfHadron;}
39 std::cout <<
"StRHICfPID::calculate() -- Done " << std::endl;
43 float StRHICfPID::checkStep(
int layer)
45 if(layer <= 10){
return 2.;}
49 float StRHICfPID::layerSumEnergy(
int tower,
int layer)
51 float tmpSumE = (mPlateE[tower][layer] + mPlateE[tower][layer+1]) *checkStep(layer) /2.;
55 float StRHICfPID::findRadiationLength(
int tower,
float ratio)
57 float tmpSumE = mPlateSumE[tower]*ratio;
59 tmpSumE -= mPlateE[tower][0];
61 for(
int ip=0; ip<mPlateIdxNum; ip++){
62 float tmpLength = calculateEquation(tower, ip, tmpSumE);
69 length += checkStep(ip);
70 tmpSumE -= layerSumEnergy(tower, ip);
77 float StRHICfPID::calculateEquation(
int tower,
int layer,
float sumE)
80 float constA = (mPlateE[tower][layer+1] - mPlateE[tower][layer])/checkStep(layer);
81 float constB = 2. * mPlateE[tower][layer];
82 float constC = -2. * sumE;
85 if(constB*constB - 4.*constA*constC < 0.){
return -1;}
88 float solA = (-1. *constB - TMath::Sqrt(constB *constB -4. *constA *constC))/(2. *constA);
89 float solB = (-1. *constB + TMath::Sqrt(constB *constB -4. *constA *constC))/(2. *constA);
91 if(solA >= 0. && solA <= checkStep(layer)){
return solA;}
92 if(solB >= 0. && solB <= checkStep(layer)){
return solB;}