CGEM BOSS 6.6.5.i
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//
9#include "TGraph2DErrors.h"
10#include <fstream>
11#include <sstream>
12#include <assert.h>
13#include <cstdlib>
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 paraPath += "/share/EmcRecPara.dat";
27 //cout<<paraPath<<endl;
28 ifstream in;
29 in.open(paraPath.c_str());
30 assert(in);
31
32 const int maxCharOfOneLine=255;
33 char temp[maxCharOfOneLine];
34 int inputNo=0;
35 while(in.peek()!=EOF) {
36 in.getline(temp,maxCharOfOneLine);
37 if(temp[0]=='#') continue;
38 inputNo++;
39 switch(inputNo) {
40 case 1:
41 istringstream(temp)>>fElectronicsNoiseLevel>>fEThresholdSeed>>fEThresholdCluster>>fLogPosOffset;
42 break;
43 case 2:
44 istringstream(temp)>>fMoliereRadius>>fLateralProfile;
45 break;
46 case 3:
47 istringstream(temp)>>eCorr[0]>>eCorr[1]>>eCorr[2]>>eCorr[3];
48 break;
49 case 4:
50 istringstream(temp)>>sigE[0]>>sigE[1]>>sigE[2]
51 >>sigTheta[0]>>sigTheta[1]>>sigPhi[0]>>sigPhi[1];
52 break;
53 case 5:
54 istringstream(temp)>>hitNb[0]>>hitNb[1]>>hitNb[2];
55 break;
56 case 6:
57 istringstream(temp)>>elecBias[0]>>elecBias[1]>>elecBias[2]
58 >>elecBias[3]>>elecBias[4];
59 break;
60 case 7:
61 istringstream(temp)>>smCut[0]>>smCut[1]>>smCut[2]>>smCut[3];
62 break;
63 default:
64 break;
65 }
66 }
67 in.close();
68
69 paraPath1 += "/share/Peak1.843_10.12calib.dat";
70 ifstream in1;
71 in1.open(paraPath1.c_str());
72 assert(in1);
73 int ntheta;
74 double sigma,sigmaerr,peakerr;
75 for(int i=0;i<56;i++) {
76 in1>>ntheta>>sigma>>sigmaerr>>peak[i]>>peakerr;
77 }
78 in1.close();
79
80 // Read energy correction parameters from PhotonCor/McCor
81 paraPath2 += "/share/evset.txt";
82 ifstream in2;
83 in2.open(paraPath2.c_str());
84 assert(in2);
85 double energy,thetaid,peak1,peakerr1,res,reserr;
86 //double ep[18]={0.03,0.04,0.05,0.075,0.1,0.125,0.15,0.2,0.25,0.3,0.4,0.5,0.75,1.0,1.25,1.5,1.75,2.0};
87 dt = new TGraph2DErrors();
88 dtErr = new TGraph2DErrors();
89 for(int i=0;i<504;i++){
90 in2>>energy;
91 in2>>thetaid;
92 in2>>peak1;
93 in2>>peakerr1;
94 in2>>res;
95 in2>>reserr;
96 dt->SetPoint(i,energy,thetaid,peak1);
97 dt->SetPointError(i,0,0,peakerr1);
98 dtErr->SetPoint(i,energy,thetaid,res);
99 dtErr->SetPointError(i,0,0,reserr);
100 }
101 in2.close();
102
103}
104
105
106EmcRecParameter::~EmcRecParameter()
107{
108 // cout<<"deconstructed"<<endl;
109 delete dt;
110 delete dtErr;
111}
112
113// static method
114//Access to an instance
116{
117 if(!Exist()) {
118 fpInstance=new EmcRecParameter;
119 }
120 return *fpInstance;
121}
122
124{
125 return fpInstance!=0;
126}
127
129{
130 if(Exist()) {
131 delete fpInstance;
132 fpInstance=0;
133 }
134}
135
136//access to each parameter
138{
139 return fElectronicsNoiseLevel;
140}
141
143{
144 return fEThresholdSeed;
145}
146
148{
149 return fEThresholdCluster;
150}
151
153{
154 return fLogPosOffset;
155}
156
158{
159 return fTimeMin;
160}
161
163{
164 return fTimeMax;
165}
166
168{
169 return fMoliereRadius;
170}
171
173{
174 return fLateralProfile;
175}
176
177double EmcRecParameter::ECorr(int n) const
178{
179 return eCorr[n];
180}
181
182double EmcRecParameter::SigE(int n) const
183{
184 return sigE[n];
185}
186
188{
189 return sigTheta[n];
190}
191
192double EmcRecParameter::SigPhi(int n) const
193{
194 return sigPhi[n];
195}
196
197double EmcRecParameter::HitNb(int n) const
198{
199 return hitNb[n];
200}
201
203{
204 return elecBias[n];
205}
206
207double EmcRecParameter::SmCut(int n) const
208{
209 return smCut[n];
210}
211
212double EmcRecParameter::Peak(int n) const
213{
214 return peak[n];
215}
216
217void EmcRecParameter::SetPositionMode(std::vector<std::string>& mode)
218{
219 if(mode.size()==2) {
220 positionMode1=mode[0];
221 positionMode2=mode[1];
222 }
223}
224
225//The following function is copied from PhotonCor/McCor
226double EmcRecParameter::ECorrMC(double eg, double theid) const
227{
228 double Energy5x5=eg;
229 if(eg<0.02)eg=0.02;
230 if(eg>1.74)eg=1.74;
231 if(theid<=0)theid=0.001;
232 if(theid>=27)theid=26.999;
233 Float_t einter = eg + 0.00001;
234 Float_t tinter = theid+0.0001;
235 double ecor=dt->Interpolate(einter,tinter);
236 if(!(ecor))return Energy5x5;
237 if(ecor<0.5)return Energy5x5;
238 double EnergyCor=Energy5x5/ecor;
239 return EnergyCor;
240}
241
242// Get energy error
243double EmcRecParameter::ErrMC(double eg, double theid) const
244{
245 if(eg<0.02)eg=0.02;
246 if(eg>1.74)eg=1.74;
247 if(theid<=0)theid=0.001;
248 if(theid>=27)theid=26.999;
249 Float_t einter = eg + 0.00001;
250 Float_t tinter = theid+0.0001;
251 double err=dtErr->Interpolate(einter,tinter);
252 return err;
253}
float Float_t
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 SigE(int n) const
void SetPositionMode(std::vector< std::string > &mode)
double ECorrMC(double eg, double theid) const
static EmcRecParameter & GetInstance()
double EThresholdCluster() const
double EThresholdSeed() const
double HitNb(int n) const
double ElectronicsNoiseLevel() const
double LateralProfile() const
double SigTheta(int n) const
double TimeMax() const
double ElecBias(int n) const
double MoliereRadius() const
double TimeMin() const
static bool Exist()
double SmCut(int n) const
double SigPhi(int n) const
double Peak(int n) const
double ErrMC(double eg, double theid) const