BOSS 7.0.3
BESIII Offline Software System
Loading...
Searching...
No Matches
EmcRecParameter.cxx
Go to the documentation of this file.
1//
2// Parameters for Emc Reconstruction
3//
4// No Parameter is allowed to be hard coded into code!
5//
6// Created by Zhe Wang, May 31, 2004
7//
8#include "EmcRec/EmcRecParameter.h"
9#include "TGraph2DErrors.h"
10#include <fstream>
11#include <sstream>
12#include <assert.h>
13#include <stdlib.h>
14
15//Initialize static data member
16EmcRecParameter* EmcRecParameter::fpInstance=0;
17pthread_mutex_t EmcRecParameter::m_pthread_lock = PTHREAD_MUTEX_INITIALIZER;
18
19// Constructors and destructors
20EmcRecParameter::EmcRecParameter()
21{
22 string paraPath = getenv("EMCRECROOT");
23 if(paraPath==""){} //cout<<"EmcRec environment not set!";
24 string paraPath1(paraPath);
25 string paraPath2(paraPath);
26 string paraPath3(paraPath);
27 string paraPath4(paraPath);
28 string paraPath5(paraPath);
29 string paraPath6(paraPath);
30 string paraPath7(paraPath);
31 string paraPath8(paraPath);
32 string paraPath9(paraPath);
33 string paraPath10(paraPath);
34 string paraPath11(paraPath);
35 string paraPath12(paraPath);
36 string paraPath13(paraPath);
37 string paraPath14(paraPath);
38 string paraPath15(paraPath);
39 string paraPath16(paraPath);
40 string paraPath17(paraPath);
41 string paraPath18(paraPath);
42 string paraPath19(paraPath);
43 string paraPath20(paraPath);
44 string paraPath21(paraPath);
45 string paraPath22(paraPath);
46 string paraPath23(paraPath);
47 string paraPath24(paraPath);
48 string paraPath25(paraPath);
49 string paraPath26(paraPath);
50 string paraPath27(paraPath);
51 string paraPath28(paraPath);
52 string paraPath29(paraPath);
53 paraPath += "/share/EmcRecPara.dat";
54 //cout<<paraPath<<endl;
55 ifstream in;
56 in.open(paraPath.c_str());
57 assert(in);
58
59 const int maxCharOfOneLine=255;
60 char temp[maxCharOfOneLine];
61 int inputNo=0;
62 while(in.peek()!=EOF) {
63 in.getline(temp,maxCharOfOneLine);
64 if(temp[0]=='#') continue;
65 inputNo++;
66 switch(inputNo) {
67 case 1:
68 istringstream(temp)>>fElectronicsNoiseLevel>>fEThresholdSeed>>fEThresholdCluster>>fLogPosOffset;
69 break;
70 case 2:
71 istringstream(temp)>>fMoliereRadius>>fLateralProfile;
72 break;
73 case 3:
74 istringstream(temp)>>eCorr[0]>>eCorr[1]>>eCorr[2]>>eCorr[3];
75 break;
76 case 4:
77 istringstream(temp)>>sigE[0]>>sigE[1]>>sigE[2]
78 >>sigTheta[0]>>sigTheta[1]>>sigPhi[0]>>sigPhi[1];
79 break;
80 case 5:
81 istringstream(temp)>>hitNb[0]>>hitNb[1]>>hitNb[2];
82 break;
83 case 6:
84 istringstream(temp)>>elecBias[0]>>elecBias[1]>>elecBias[2]
85 >>elecBias[3]>>elecBias[4];
86 break;
87 case 7:
88 istringstream(temp)>>smCut[0]>>smCut[1]>>smCut[2]>>smCut[3];
89 break;
90 default:
91 break;
92 }
93 }
94 in.close();
95
96 paraPath1 += "/share/Peak1.843_10.12calib.dat";
97 ifstream in1;
98 in1.open(paraPath1.c_str());
99 assert(in1);
100 int ntheta;
101 double sigma,sigmaerr,peakerr;
102 for(int i=0;i<56;i++) {
103 in1>>ntheta>>sigma>>sigmaerr>>peak[i]>>peakerr;
104 }
105 in1.close();
106
107 // Read energy correction parameters from PhotonCor/McCor
108 paraPath2 += "/share/evset.txt";
109 ifstream in2;
110 in2.open(paraPath2.c_str());
111 assert(in2);
112 double energy,thetaid,peak1,peakerr1,res,reserr;
113
114 dt = new TGraph2DErrors();
115 dtErr = new TGraph2DErrors();
116 for(int i=0;i<560;i++){
117 in2>>energy;
118 in2>>thetaid;
119 in2>>peak1;
120 in2>>peakerr1;
121 in2>>res;
122 in2>>reserr;
123 dt->SetPoint(i,energy,thetaid,peak1);
124 dt->SetPointError(i,0,0,peakerr1);
125 dtErr->SetPoint(i,energy,thetaid,res);
126 dtErr->SetPointError(i,0,0,reserr);
127
128 if(i<28) e25min[int(thetaid)]=energy;
129 if(i>=560-28) e25max[int(thetaid)]=energy;
130
131 }
132 in2.close();
133
134// Position correction parameters
135 paraPath3 += "/share/BarrLogThetaPara.dat";
136 ifstream in3;
137 in3.open(paraPath3.c_str());
138 assert(in3);
139 for(int i=0;i<66;i++){
140 for(int j=0;j<5;j++){
141 in3>>barrLogThetaPara[i][j];
142 }
143 }
144 in3.close();
145
146 paraPath4 += "/share/BarrLogPhiPara.dat";
147 ifstream in4;
148 in4.open(paraPath4.c_str());
149 assert(in4);
150 for(int i=0;i<66;i++){
151 for(int j=0;j<5;j++){
152 in4>>barrLogPhiPara[i][j];
153 }
154 }
155 in4.close();
156
157 paraPath5 += "/share/BarrLinThetaPara.dat";
158 ifstream in5;
159 in5.open(paraPath5.c_str());
160 assert(in5);
161 for(int i=0;i<66;i++){
162 for(int j=0;j<5;j++){
163 in5>>barrLinThetaPara[i][j];
164 }
165 }
166 in5.close();
167
168 paraPath6 += "/share/BarrLinPhiPara.dat";
169 ifstream in6;
170 in6.open(paraPath6.c_str());
171 assert(in6);
172 for(int i=0;i<3;i++){
173 for(int j=0;j<5;j++){
174 in6>>barrLinPhiPara[i][j];
175 }
176 }
177 in6.close();
178
179
180 paraPath7 += "/share/BarrShLogThetaPara.dat";
181 ifstream in7;
182 in7.open(paraPath7.c_str());
183 assert(in7);
184 for(int i=0;i<66;i++){
185 for(int j=0;j<5;j++){
186 in7>>barrShLogThetaPara[i][j];
187 }
188 }
189 in7.close();
190
191 paraPath8 += "/share/BarrShLogPhiPara.dat";
192 ifstream in8;
193 in8.open(paraPath8.c_str());
194 assert(in8);
195 for(int i=0;i<3;i++){
196 for(int j=0;j<5;j++){
197 in8>>barrShLogPhiPara[i][j];
198 }
199 }
200 in8.close();
201
202 paraPath9 += "/share/BarrShLinThetaPara.dat";
203 ifstream in9;
204 in9.open(paraPath9.c_str());
205 assert(in9);
206 for(int i=0;i<66;i++){
207 for(int j=0;j<5;j++){
208 in9>>barrShLinThetaPara[i][j];
209 }
210 }
211 in9.close();
212
213 paraPath10 += "/share/BarrShLinPhiPara.dat";
214 ifstream in10;
215 in10.open(paraPath10.c_str());
216 assert(in10);
217 for(int i=0;i<3;i++){
218 for(int j=0;j<5;j++){
219 in10>>barrShLinPhiPara[i][j];
220 }
221 }
222 in10.close();
223
224
225 paraPath11 += "/share/EastLogThetaPara.dat";
226 ifstream in11;
227 in11.open(paraPath11.c_str());
228 assert(in11);
229 for(int i=0;i<18;i++){
230 for(int j=0;j<5;j++){
231 in11>>eastLogThetaPara[i][j];
232 }
233 }
234 in11.close();
235
236 paraPath12 += "/share/WestLogThetaPara.dat";
237 ifstream in12;
238 in12.open(paraPath12.c_str());
239 assert(in12);
240 for(int i=0;i<18;i++){
241 for(int j=0;j<5;j++){
242 in12>>westLogThetaPara[i][j];
243 }
244 }
245 in12.close();
246
247 paraPath13 += "/share/EastLinThetaPara.dat";
248 ifstream in13;
249 in13.open(paraPath13.c_str());
250 assert(in13);
251 for(int i=0;i<6;i++){
252 for(int j=0;j<5;j++){
253 in13>>eastLinThetaPara[i][j];
254 }
255 }
256 in13.close();
257
258 paraPath14 += "/share/WestLinThetaPara.dat";
259 ifstream in14;
260 in14.open(paraPath14.c_str());
261 assert(in14);
262 for(int i=0;i<6;i++){
263 for(int j=0;j<5;j++){
264 in14>>westLinThetaPara[i][j];
265 }
266 }
267 in14.close();
268
269 paraPath15 += "/share/BarrDataLogThetaPara.dat";
270 ifstream in15;
271 in15.open(paraPath15.c_str());
272 assert(in15);
273 for(int i=0;i<22;i++){
274 for(int j=0;j<5;j++){
275 in15>>barrDataLogThetaPara[i][j];
276 }
277 }
278 in15.close();
279
280 paraPath16 += "/share/EastDataLogThetaPara.dat";
281 ifstream in16;
282 in16.open(paraPath16.c_str());
283 assert(in16);
284 for(int i=0;i<6;i++){
285 for(int j=0;j<5;j++){
286 in16>>eastDataLogThetaPara[i][j];
287 }
288 }
289 in16.close();
290
291 paraPath17 += "/share/WestDataLogThetaPara.dat";
292 ifstream in17;
293 in17.open(paraPath17.c_str());
294 assert(in17);
295 for(int i=0;i<6;i++){
296 for(int j=0;j<5;j++){
297 in17>>westDataLogThetaPara[i][j];
298 }
299 }
300 in17.close();
301
302
303 paraPath18 += "/share/EastLogPhiPara.dat";
304 ifstream in18;
305 in18.open(paraPath18.c_str());
306 assert(in18);
307 for(int i=0;i<3;i++){
308 for(int j=0;j<5;j++){
309 in18>>eastLogPhiPara[i][j];
310 }
311 }
312 in18.close();
313
314 paraPath19 += "/share/WestLogPhiPara.dat";
315 ifstream in19;
316 in19.open(paraPath19.c_str());
317 assert(in19);
318 for(int i=0;i<3;i++){
319 for(int j=0;j<5;j++){
320 in19>>westLogPhiPara[i][j];
321 }
322 }
323 in19.close();
324
325 paraPath20 += "/share/EastLinPhiPara.dat";
326 ifstream in20;
327 in20.open(paraPath20.c_str());
328 assert(in20);
329 for(int i=0;i<1;i++){
330 for(int j=0;j<5;j++){
331 in20>>eastLinPhiPara[i][j];
332 }
333 }
334 in20.close();
335
336 paraPath21 += "/share/WestLinPhiPara.dat";
337 ifstream in21;
338 in21.open(paraPath21.c_str());
339 assert(in21);
340 for(int i=0;i<1;i++){
341 for(int j=0;j<5;j++){
342 in21>>westLinPhiPara[i][j];
343 }
344 }
345 in21.close();
346
347 paraPath22 += "/share/BarrLoglinThetaPara.dat";
348 ifstream in22;
349 in22.open(paraPath22.c_str());
350 assert(in22);
351 for(int i=0;i<22;i++){
352 for(int j=0;j<5;j++){
353 in22>>barrLoglinThetaPara[i][j];
354 }
355 }
356 in22.close();
357
358 paraPath23 += "/share/BarrLoglinPhiPara.dat";
359 ifstream in23;
360 in23.open(paraPath23.c_str());
361 assert(in23);
362 for(int i=0;i<1;i++){
363 for(int j=0;j<5;j++){
364 in23>>barrLoglinPhiPara[i][j];
365 }
366 }
367 in23.close();
368
369
370 int ith,iph;
371 double dth,dtherr,sig,sigerr;
372
373 paraPath24 += "/share/PosCorDataBarr.conf";
374 ifstream in24;
375 in24.open(paraPath24.c_str());
376 assert(in24);
377
378 for(int i=0;i<5280;i++){
379
380 in24>>iph>>ith>>dth>>dtherr>>sig>>sigerr;
381 barrPosDataCorPara[ith][iph]=dth;
382
383 }
384 in24.close();
385
386 paraPath25 += "/share/PosCorDataWest.conf";
387 ifstream in25;
388 in25.open(paraPath25.c_str());
389 assert(in25);
390 for(int i=0;i<480;i++){
391
392 in25>>ith>>iph>>dth>>dtherr>>sig>>sigerr;
393 westPosDataCorPara[ith][iph]=dth;
394
395 }
396 in25.close();
397
398 paraPath26 += "/share/PosCorDataEast.conf";
399 ifstream in26;
400 in26.open(paraPath26.c_str());
401 assert(in26);
402 for(int i=0;i<480;i++){
403
404 in26>>ith>>iph>>dth>>dtherr>>sig>>sigerr;
405 eastPosDataCorPara[ith][iph]=dth;
406
407 }
408 in26.close();
409
410 ////////////////////MCposcor
411 paraPath27 += "/share/PosCorMCBarr.conf";
412 ifstream in27;
413 in27.open(paraPath27.c_str());
414 assert(in27);
415
416 for(int i=0;i<5280;i++){
417
418 in27>>iph>>ith>>dth>>dtherr>>sig>>sigerr;
419 barrPosMCCorPara[ith][iph]=dth;
420
421 }
422 in27.close();
423
424 paraPath28 += "/share/PosCorMCWest.conf";
425 ifstream in28;
426 in28.open(paraPath28.c_str());
427 assert(in28);
428 for(int i=0;i<480;i++){
429
430 in28>>ith>>iph>>dth>>dtherr>>sig>>sigerr;
431 westPosMCCorPara[ith][iph]=dth;
432
433 }
434 in28.close();
435
436 paraPath29 += "/share/PosCorMCEast.conf";
437 ifstream in29;
438 in29.open(paraPath29.c_str());
439 assert(in29);
440 for(int i=0;i<480;i++){
441
442 in29>>ith>>iph>>dth>>dtherr>>sig>>sigerr;
443 eastPosMCCorPara[ith][iph]=dth;
444
445 }
446 in29.close();
447
448
449}
450
451
452EmcRecParameter::~EmcRecParameter()
453{
454 // cout<<"deconstructed"<<endl;
455 delete dt;
456 delete dtErr;
457}
458
459// static method
460//Access to an instance
462{
463 if(!Exist()) {
464 fpInstance=new EmcRecParameter;
465 }
466 return *fpInstance;
467}
468
470{
471 return fpInstance!=0;
472}
473
475{
476 if(Exist()) {
477 delete fpInstance;
478 fpInstance=0;
479 }
480}
481
482//access to each parameter
484{
485 return fElectronicsNoiseLevel;
486}
487
489{
490 return fEThresholdSeed;
491}
492
494{
495 return fEThresholdCluster;
496}
497
499{
500 return fLogPosOffset;
501}
502
504{
505 return fTimeMin;
506}
507
509{
510 return fTimeMax;
511}
512
513
515{
516 return fMethodMode;
517}
518
520{
521 return fPosCorr;
522}
523
525{
526 return fDataMode;
527}
529{
530 return fElecSaturation;
531}
532
534{
535 return fMoliereRadius;
536}
537
539{
540 return fLateralProfile;
541}
542
543double EmcRecParameter::ECorr(int n) const
544{
545 return eCorr[n];
546}
547
548double EmcRecParameter::SigE(int n) const
549{
550 return sigE[n];
551}
552
554{
555 return sigTheta[n];
556}
557
558double EmcRecParameter::SigPhi(int n) const
559{
560 return sigPhi[n];
561}
562
563double EmcRecParameter::HitNb(int n) const
564{
565 return hitNb[n];
566}
567
569{
570 return elecBias[n];
571}
572
573double EmcRecParameter::SmCut(int n) const
574{
575 return smCut[n];
576}
577
578double EmcRecParameter::Peak(int n) const
579{
580 return peak[n];
581}
582
583double EmcRecParameter::BarrLogThetaPara(int n , int m) const
584{
585 return barrLogThetaPara[n][m];
586}
587
588
589
590double EmcRecParameter::BarrLogPhiPara(int n ,int m) const
591{
592 return barrLogPhiPara[n][m];
593}
594
595
597{
598 return barrLoglinThetaPara[n][m];
599}
600
601
602
603double EmcRecParameter::BarrLoglinPhiPara(int n ,int m) const
604{
605 return barrLoglinPhiPara[n][m];
606}
607
608
609
610double EmcRecParameter::BarrLinThetaPara(int n , int m) const
611{
612 return barrLinThetaPara[n][m];
613}
614
615double EmcRecParameter::BarrLinPhiPara(int n ,int m) const
616{
617 return barrLinPhiPara[n][m];
618}
619
620double EmcRecParameter::BarrShLogThetaPara(int n , int m) const
621{
622 return barrShLogThetaPara[n][m];
623}
624
625double EmcRecParameter::BarrShLogPhiPara(int n ,int m) const
626{
627 return barrShLogPhiPara[n][m];
628}
629
630double EmcRecParameter::BarrShLinThetaPara(int n , int m) const
631{
632 return barrShLinThetaPara[n][m];
633}
634
635double EmcRecParameter::BarrShLinPhiPara(int n ,int m) const
636{
637 return barrShLinPhiPara[n][m];
638}
639
640
641double EmcRecParameter::EastLogThetaPara(int n ,int m) const
642{
643 return eastLogThetaPara[n][m];
644}
645
646double EmcRecParameter::WestLogThetaPara(int n ,int m) const
647{
648 return westLogThetaPara[n][m];
649}
650
651double EmcRecParameter::EastLogPhiPara(int n ,int m) const
652{
653 return eastLogPhiPara[n][m];
654}
655
656double EmcRecParameter::WestLogPhiPara(int n ,int m) const
657{
658 return westLogPhiPara[n][m];
659}
660
661double EmcRecParameter::EastLinPhiPara(int n ,int m) const
662{
663 return eastLinPhiPara[n][m];
664}
665
666double EmcRecParameter::WestLinPhiPara(int n ,int m) const
667{
668 return westLinPhiPara[n][m];
669}
670
671
672double EmcRecParameter::EastLinThetaPara(int n ,int m) const
673{
674 return eastLinThetaPara[n][m];
675}
676
677double EmcRecParameter::WestLinThetaPara(int n ,int m) const
678{
679 return westLinThetaPara[n][m];
680}
681
683{
684 return barrDataLogThetaPara[n][m];
685}
686
687double EmcRecParameter::BarrPosDataCor(int ntheta, int nphi) const
688{
689 return barrPosDataCorPara[ntheta][nphi];
690}
691
692double EmcRecParameter::WestPosDataCor(int ntheta, int nphi) const
693{
694 return westPosDataCorPara[ntheta][nphi];
695}
696
697double EmcRecParameter::EastPosDataCor(int ntheta, int nphi) const
698{
699 return eastPosDataCorPara[ntheta][nphi];
700}
701
702double EmcRecParameter::BarrPosMCCor(int ntheta, int nphi) const
703{
704 return barrPosMCCorPara[ntheta][nphi];
705}
706
707double EmcRecParameter::WestPosMCCor(int ntheta, int nphi) const
708{
709 return westPosMCCorPara[ntheta][nphi];
710}
711
712double EmcRecParameter::EastPosMCCor(int ntheta, int nphi) const
713{
714 return eastPosMCCorPara[ntheta][nphi];
715}
716
717
718
720{
721 return eastDataLogThetaPara[n][m];
722}
723
725{
726 return westDataLogThetaPara[n][m];
727}
728
729
730
731
732void EmcRecParameter::SetPositionMode(std::vector<std::string>& mode)
733{
734 if(mode.size()==2) {
735 positionMode1=mode[0];
736 positionMode2=mode[1];
737 }
738}
739
740//The following function is copied from PhotonCor/McCor
741double EmcRecParameter::ECorrMC(double eg, double theid) const
742{
743 double Energy5x5=eg;
744 if(eg<E25min(int(theid))) eg=E25min(int(theid));
745 if(eg>E25max(int(theid))) eg=E25max(int(theid))-0.001;
746 if(theid<=0)theid=0.001;
747 if(theid>=27)theid=26.999;
748 Float_t einter = eg + 0.00001;
749 Float_t tinter = theid+0.0001;
750 double ecor=dt->Interpolate(einter,tinter);
751 if(!(ecor))return Energy5x5;
752 if(ecor<0.5)return Energy5x5;
753 double EnergyCor=Energy5x5/ecor;
754 return EnergyCor;
755}
756
757// Get energy error
758double EmcRecParameter::ErrMC(double eg, double theid) const
759{
760
761 if(eg<E25min(int(theid))) eg=E25min(int(theid));
762 if(eg>E25max(int(theid))) eg=E25max(int(theid))-0.001;
763 if(theid<=0)theid=0.001;
764 if(theid>=27)theid=26.999;
765 Float_t einter = eg + 0.00001;
766 Float_t tinter = theid+0.0001;
767 double err=dtErr->Interpolate(einter,tinter);
768 return err;
769}
770
771double EmcRecParameter::E25min(int n) const
772{
773 return e25min[n];
774}
775double EmcRecParameter::E25max(int n) const
776{
777 return e25max[n];
778}
const Int_t n
************Class m_ypar INTEGER m_KeyWgt INTEGER m_nphot 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
Definition: KK2f.h:50
double LogPosOffset() const
double ECorr(int n) const
double WestPosMCCor(int ntheta, int nphi) const
double SigE(int n) 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 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 ElectronicsNoiseLevel() const
double E25min(int n) const
double PosCorr() 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 TimeMax() const
double BarrShLogThetaPara(int n, int m) const
double WestLogThetaPara(int n, int m) const
double ElecBias(int n) const
double BarrShLogPhiPara(int n, int m) 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
static void Kill()
double BarrLoglinThetaPara(int n, int m) const
double WestLinThetaPara(int n, int m) const
double MoliereRadius() const
double TimeMin() const
static bool Exist()
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 DataMode() const
double SmCut(int n) const
double SigPhi(int n) const
double Peak(int n) const
double ErrMC(double eg, double theid) const