8#include "EmcRec/EmcRecParameter.h"
9#include "TGraph2DErrors.h"
17pthread_mutex_t EmcRecParameter::m_pthread_lock = PTHREAD_MUTEX_INITIALIZER;
20EmcRecParameter::EmcRecParameter() {
21 string paraPath = getenv(
"EMCRECROOT" );
22 if ( paraPath ==
"" ) {}
23 string paraPath1( paraPath );
24 string paraPath2( paraPath );
25 string paraPath3( paraPath );
26 string paraPath4( paraPath );
27 string paraPath3_1( paraPath );
28 string paraPath4_1( paraPath );
29 string paraPath5( paraPath );
30 string paraPath6( paraPath );
31 string paraPath7( paraPath );
32 string paraPath8( paraPath );
33 string paraPath9( paraPath );
34 string paraPath10( paraPath );
35 string paraPath11( paraPath );
36 string paraPath12( paraPath );
37 string paraPath11_1( paraPath );
38 string paraPath12_1( paraPath );
39 string paraPath13( paraPath );
40 string paraPath14( paraPath );
41 string paraPath15( paraPath );
42 string paraPath16( paraPath );
43 string paraPath17( paraPath );
44 string paraPath18( paraPath );
45 string paraPath19( paraPath );
46 string paraPath18_1( paraPath );
47 string paraPath19_1( paraPath );
48 string paraPath20( paraPath );
49 string paraPath21( paraPath );
50 string paraPath22( paraPath );
51 string paraPath23( paraPath );
52 string paraPath24( paraPath );
53 string paraPath25( paraPath );
54 string paraPath26( paraPath );
55 string paraPath27( paraPath );
56 string paraPath28( paraPath );
57 string paraPath29( paraPath );
58 paraPath +=
"/share/EmcRecPara.dat";
61 in.open( paraPath.c_str() );
64 const int maxCharOfOneLine = 255;
65 char temp[maxCharOfOneLine];
67 while ( in.peek() != EOF )
69 in.getline( temp, maxCharOfOneLine );
70 if ( temp[0] ==
'#' )
continue;
75 istringstream( temp ) >> fElectronicsNoiseLevel >> fEThresholdSeed >>
76 fEThresholdCluster >> fLogPosOffset;
78 case 2: istringstream( temp ) >> fMoliereRadius >> fLateralProfile;
break;
79 case 3: istringstream( temp ) >> eCorr[0] >> eCorr[1] >> eCorr[2] >> eCorr[3];
break;
81 istringstream( temp ) >> sigE[0] >> sigE[1] >> sigE[2] >> sigTheta[0] >> sigTheta[1] >>
82 sigPhi[0] >> sigPhi[1];
84 case 5: istringstream( temp ) >> hitNb[0] >> hitNb[1] >> hitNb[2];
break;
86 istringstream( temp ) >> elecBias[0] >> elecBias[1] >> elecBias[2] >> elecBias[3] >>
89 case 7: istringstream( temp ) >> smCut[0] >> smCut[1] >> smCut[2] >> smCut[3];
break;
95 paraPath1 +=
"/share/Peak1.843_10.12calib.dat";
97 in1.open( paraPath1.c_str() );
100 double sigma, sigmaerr, peakerr;
101 for (
int i = 0; i < 56; i++ ) { in1 >> ntheta >> sigma >> sigmaerr >> peak[i] >> peakerr; }
105 paraPath2 +=
"/share/evset.txt";
107 in2.open( paraPath2.c_str() );
109 double energy, thetaid, peak1, peakerr1, res, reserr;
111 dt =
new TGraph2DErrors();
112 dtErr =
new TGraph2DErrors();
113 for (
int i = 0; i < 560; i++ )
121 dt->SetPoint( i,
energy, thetaid, peak1 );
122 dt->SetPointError( i, 0, 0, peakerr1 );
123 dtErr->SetPoint( i,
energy, thetaid, res );
124 dtErr->SetPointError( i, 0, 0, reserr );
132 paraPath3_1 +=
"/share/BarrLogShMaxThetaPara.dat";
134 in3_1.open( paraPath3_1.c_str() );
136 for (
int i = 0; i < 132; i++ )
138 for (
int j = 0; j < 5; j++ ) { in3_1 >> barrLogShMaxThetaPara[i][j]; }
142 paraPath4_1 +=
"/share/BarrLogShMaxPhiPara.dat";
144 in4_1.open( paraPath4_1.c_str() );
146 for (
int i = 0; i < 132; i++ )
148 for (
int j = 0; j < 5; j++ ) { in4_1 >> barrLogShMaxPhiPara[i][j]; }
152 paraPath11_1 +=
"/share/EastLogShMaxThetaPara.dat";
154 in11_1.open( paraPath11_1.c_str() );
156 for (
int i = 0; i < 18; i++ )
158 for (
int j = 0; j < 5; j++ ) { in11_1 >> eastLogShMaxThetaPara[i][j]; }
162 paraPath12_1 +=
"/share/WestLogShMaxThetaPara.dat";
164 in12_1.open( paraPath12_1.c_str() );
166 for (
int i = 0; i < 18; i++ )
168 for (
int j = 0; j < 5; j++ ) { in12_1 >> westLogShMaxThetaPara[i][j]; }
172 paraPath18_1 +=
"/share/EastLogShMaxPhiPara.dat";
174 in18_1.open( paraPath18_1.c_str() );
176 for (
int i = 0; i < 3; i++ )
178 for (
int j = 0; j < 5; j++ ) { in18_1 >> eastLogShMaxPhiPara[i][j]; }
182 paraPath19_1 +=
"/share/WestLogShMaxPhiPara.dat";
184 in19_1.open( paraPath19_1.c_str() );
186 for (
int i = 0; i < 3; i++ )
188 for (
int j = 0; j < 5; j++ ) { in19_1 >> westLogShMaxPhiPara[i][j]; }
193 paraPath3 +=
"/share/BarrLogThetaPara.dat";
195 in3.open( paraPath3.c_str() );
197 for (
int i = 0; i < 66; i++ )
199 for (
int j = 0; j < 5; j++ ) { in3 >> barrLogThetaPara[i][j]; }
203 paraPath4 +=
"/share/BarrLogPhiPara.dat";
205 in4.open( paraPath4.c_str() );
207 for (
int i = 0; i < 66; i++ )
209 for (
int j = 0; j < 5; j++ ) { in4 >> barrLogPhiPara[i][j]; }
213 paraPath5 +=
"/share/BarrLinThetaPara.dat";
215 in5.open( paraPath5.c_str() );
217 for (
int i = 0; i < 66; i++ )
219 for (
int j = 0; j < 5; j++ ) { in5 >> barrLinThetaPara[i][j]; }
223 paraPath6 +=
"/share/BarrLinPhiPara.dat";
225 in6.open( paraPath6.c_str() );
227 for (
int i = 0; i < 3; i++ )
229 for (
int j = 0; j < 5; j++ ) { in6 >> barrLinPhiPara[i][j]; }
257 paraPath9 +=
"/share/BarrShLinThetaPara.dat";
259 in9.open( paraPath9.c_str() );
261 for (
int i = 0; i < 66; i++ )
263 for (
int j = 0; j < 5; j++ ) { in9 >> barrShLinThetaPara[i][j]; }
267 paraPath10 +=
"/share/BarrShLinPhiPara.dat";
269 in10.open( paraPath10.c_str() );
271 for (
int i = 0; i < 3; i++ )
273 for (
int j = 0; j < 5; j++ ) { in10 >> barrShLinPhiPara[i][j]; }
277 paraPath11 +=
"/share/EastLogThetaPara.dat";
279 in11.open( paraPath11.c_str() );
281 for (
int i = 0; i < 18; i++ )
283 for (
int j = 0; j < 5; j++ ) { in11 >> eastLogThetaPara[i][j]; }
287 paraPath12 +=
"/share/WestLogThetaPara.dat";
289 in12.open( paraPath12.c_str() );
291 for (
int i = 0; i < 18; i++ )
293 for (
int j = 0; j < 5; j++ ) { in12 >> westLogThetaPara[i][j]; }
297 paraPath13 +=
"/share/EastLinThetaPara.dat";
299 in13.open( paraPath13.c_str() );
301 for (
int i = 0; i < 6; i++ )
303 for (
int j = 0; j < 5; j++ ) { in13 >> eastLinThetaPara[i][j]; }
307 paraPath14 +=
"/share/WestLinThetaPara.dat";
309 in14.open( paraPath14.c_str() );
311 for (
int i = 0; i < 6; i++ )
313 for (
int j = 0; j < 5; j++ ) { in14 >> westLinThetaPara[i][j]; }
317 paraPath15 +=
"/share/BarrDataLogThetaPara.dat";
319 in15.open( paraPath15.c_str() );
321 for (
int i = 0; i < 22; i++ )
323 for (
int j = 0; j < 5; j++ ) { in15 >> barrDataLogThetaPara[i][j]; }
327 paraPath16 +=
"/share/EastDataLogThetaPara.dat";
329 in16.open( paraPath16.c_str() );
331 for (
int i = 0; i < 6; i++ )
333 for (
int j = 0; j < 5; j++ ) { in16 >> eastDataLogThetaPara[i][j]; }
337 paraPath17 +=
"/share/WestDataLogThetaPara.dat";
339 in17.open( paraPath17.c_str() );
341 for (
int i = 0; i < 6; i++ )
343 for (
int j = 0; j < 5; j++ ) { in17 >> westDataLogThetaPara[i][j]; }
347 paraPath18 +=
"/share/EastLogPhiPara.dat";
349 in18.open( paraPath18.c_str() );
351 for (
int i = 0; i < 3; i++ )
353 for (
int j = 0; j < 5; j++ ) { in18 >> eastLogPhiPara[i][j]; }
357 paraPath19 +=
"/share/WestLogPhiPara.dat";
359 in19.open( paraPath19.c_str() );
361 for (
int i = 0; i < 3; i++ )
363 for (
int j = 0; j < 5; j++ ) { in19 >> westLogPhiPara[i][j]; }
367 paraPath20 +=
"/share/EastLinPhiPara.dat";
369 in20.open( paraPath20.c_str() );
371 for (
int i = 0; i < 1; i++ )
373 for (
int j = 0; j < 5; j++ ) { in20 >> eastLinPhiPara[i][j]; }
377 paraPath21 +=
"/share/WestLinPhiPara.dat";
379 in21.open( paraPath21.c_str() );
381 for (
int i = 0; i < 1; i++ )
383 for (
int j = 0; j < 5; j++ ) { in21 >> westLinPhiPara[i][j]; }
387 paraPath22 +=
"/share/BarrLoglinThetaPara.dat";
389 in22.open( paraPath22.c_str() );
391 for (
int i = 0; i < 22; i++ )
393 for (
int j = 0; j < 5; j++ ) { in22 >> barrLoglinThetaPara[i][j]; }
397 paraPath23 +=
"/share/BarrLoglinPhiPara.dat";
399 in23.open( paraPath23.c_str() );
401 for (
int i = 0; i < 1; i++ )
403 for (
int j = 0; j < 5; j++ ) { in23 >> barrLoglinPhiPara[i][j]; }
408 double dth, dtherr, sig, sigerr;
410 paraPath24 +=
"/share/PosCorDataBarr.conf";
412 in24.open( paraPath24.c_str() );
415 for (
int i = 0; i < 5280; i++ )
418 in24 >> iph >> ith >> dth >> dtherr >> sig >> sigerr;
419 barrPosDataCorPara[ith][iph] = dth;
423 paraPath25 +=
"/share/PosCorDataWest.conf";
425 in25.open( paraPath25.c_str() );
427 for (
int i = 0; i < 480; i++ )
430 in25 >> ith >> iph >> dth >> dtherr >> sig >> sigerr;
431 westPosDataCorPara[ith][iph] = dth;
435 paraPath26 +=
"/share/PosCorDataEast.conf";
437 in26.open( paraPath26.c_str() );
439 for (
int i = 0; i < 480; i++ )
442 in26 >> ith >> iph >> dth >> dtherr >> sig >> sigerr;
443 eastPosDataCorPara[ith][iph] = dth;
448 paraPath27 +=
"/share/PosCorMCBarr.conf";
450 in27.open( paraPath27.c_str() );
453 for (
int i = 0; i < 5280; i++ )
456 in27 >> iph >> ith >> dth >> dtherr >> sig >> sigerr;
457 barrPosMCCorPara[ith][iph] = dth;
461 paraPath28 +=
"/share/PosCorMCWest.conf";
463 in28.open( paraPath28.c_str() );
465 for (
int i = 0; i < 480; i++ )
468 in28 >> ith >> iph >> dth >> dtherr >> sig >> sigerr;
469 westPosMCCorPara[ith][iph] = dth;
473 paraPath29 +=
"/share/PosCorMCEast.conf";
475 in29.open( paraPath29.c_str() );
477 for (
int i = 0; i < 480; i++ )
480 in29 >> ith >> iph >> dth >> dtherr >> sig >> sigerr;
481 eastPosMCCorPara[ith][iph] = dth;
486EmcRecParameter::~EmcRecParameter() {
495 if ( !
Exist() ) { fpInstance =
new EmcRecParameter; }
550 return barrLogThetaPara[
n][m];
556 return barrLoglinThetaPara[
n][m];
560 return barrLoglinPhiPara[
n][m];
564 return barrLinThetaPara[
n][m];
570 return barrLogShMaxThetaPara[
n][m];
574 return barrLogShMaxPhiPara[
n][m];
578 return barrShLinThetaPara[
n][m];
582 return barrShLinPhiPara[
n][m];
586 return eastLogThetaPara[
n][m];
590 return westLogThetaPara[
n][m];
598 return eastLogShMaxThetaPara[
n][m];
602 return westLogShMaxThetaPara[
n][m];
606 return eastLogShMaxPhiPara[
n][m];
610 return westLogShMaxPhiPara[
n][m];
618 return eastLinThetaPara[
n][m];
622 return westLinThetaPara[
n][m];
626 return barrDataLogThetaPara[
n][m];
630 return barrPosDataCorPara[ntheta][nphi];
634 return westPosDataCorPara[ntheta][nphi];
638 return eastPosDataCorPara[ntheta][nphi];
642 return barrPosMCCorPara[ntheta][nphi];
646 return westPosMCCorPara[ntheta][nphi];
650 return eastPosMCCorPara[ntheta][nphi];
654 return eastDataLogThetaPara[
n][m];
658 return westDataLogThetaPara[
n][m];
662 if ( mode.size() == 2 )
664 positionMode1 = mode[0];
665 positionMode2 = mode[1];
671 double Energy5x5 = eg;
672 if ( eg <
E25min(
int( theid ) ) ) eg =
E25min(
int( theid ) );
673 if ( eg >
E25max(
int( theid ) ) ) eg =
E25max(
int( theid ) ) - 0.001;
674 if ( theid <= 0 ) theid = 0.001;
675 if ( theid >= 27 ) theid = 26.999;
676 Float_t einter = eg + 0.00001;
677 Float_t tinter = theid + 0.0001;
678 double ecor = dt->Interpolate( einter, tinter );
679 if ( !( ecor ) )
return Energy5x5;
680 if ( ecor < 0.5 )
return Energy5x5;
681 double EnergyCor = Energy5x5 / ecor;
688 if ( eg <
E25min(
int( theid ) ) ) eg =
E25min(
int( theid ) );
689 if ( eg >
E25max(
int( theid ) ) ) eg =
E25max(
int( theid ) ) - 0.001;
690 if ( theid <= 0 ) theid = 0.001;
691 if ( theid >= 27 ) theid = 26.999;
692 Float_t einter = eg + 0.00001;
693 Float_t tinter = theid + 0.0001;
694 double err = dtErr->Interpolate( einter, tinter );
************Class m_ypar INTEGER m_KeyWgt INTEGER m_KeyIHVP INTEGER m_KeyGPS INTEGER m_IsBeamPolarized INTEGER m_EvtGenInterface DOUBLE PRECISION m_Emin DOUBLE PRECISION m_sphot DOUBLE PRECISION m_Xenph DOUBLE PRECISION m_q2 DOUBLE PRECISION m_PolBeam2 DOUBLE PRECISION m_xErrPb *COMMON c_KK2f $ !CMS energy average $ !Spin Polarization vector first beam $ !Spin Polarization vector second beam $ !Beam energy spread[GeV] $ !minimum hadronization energy[GeV] $ !input READ never touch them !$ !debug facility $ !maximum weight $ !inverse alfaQED $ !minimum real photon energy
double LogPosOffset() const
double WestLogShMaxPhiPara(int n, int m) const
double ECorr(int n) const
double BarrLogShMaxPhiPara(int n, int m) const
double WestPosMCCor(int ntheta, int nphi) const
double BarrPosMCCor(int ntheta, int nphi) const
void SetPositionMode(std::vector< std::string > &mode)
double ECorrMC(double eg, double theid) const
static EmcRecParameter & GetInstance()
double EastDataLogThetaPara(int n, int m) const
double EastLogShMaxPhiPara(int n, int m) const
double EastPosMCCor(int ntheta, int nphi) const
double WestDataLogThetaPara(int n, int m) const
double EastLinThetaPara(int n, int m) const
double EastPosDataCor(int ntheta, int nphi) const
double EastLinPhiPara(int n, int m) const
double EThresholdCluster() const
double EThresholdSeed() const
double WestPosDataCor(int ntheta, int nphi) const
double BarrLogPhiPara(int n, int m) const
double BarrDataLogThetaPara(int n, int m) const
double HitNb(int n) const
double EastLogShMaxThetaPara(int n, int m) const
double ElectronicsNoiseLevel() const
double E25min(int n) const
double BarrShLinPhiPara(int n, int m) const
double LateralProfile() const
double E25max(int n) const
double MethodMode() const
double SigTheta(int n) const
double WestLogShMaxThetaPara(int n, int m) const
double WestLogThetaPara(int n, int m) const
double ElecBias(int n) const
double BarrShLinThetaPara(int n, int m) const
int ElecSaturation() const
double BarrPosDataCor(int ntheta, int nphi) const
double BarrLogThetaPara(int n, int m) const
double BarrLoglinThetaPara(int n, int m) const
double WestLinThetaPara(int n, int m) const
double MoliereRadius() const
double WestLogPhiPara(int n, int m) const
double BarrLinPhiPara(int n, int m) const
double BarrLinThetaPara(int n, int m) const
double EastLogPhiPara(int n, int m) const
double EastLogThetaPara(int n, int m) const
double BarrLoglinPhiPara(int n, int m) const
double WestLinPhiPara(int n, int m) const
double SmCut(int n) const
double SigPhi(int n) const
double BarrLogShMaxThetaPara(int n, int m) const
double ErrMC(double eg, double theid) const