BOSS 7.0.1
BESIII Offline Software System
Loading...
Searching...
No Matches
MdcDedxTrk.cxx
Go to the documentation of this file.
1// BesIII MDC dE/dx Reconstruction Module
2// Class: MdcDedxTrk
3// Created by Dayong WANG 2003/11
4
5#include "MdcDedxAlg/MdcDedxTrk.h"
6#include "MdcDedxAlg/MdcDedxCorrection.h"
7
8#include "TGraphErrors.h"
9#include "TGraph.h"
10#include <stdlib.h>
11#include <search.h>
12#include <TMath.h>
13
15{
16 m_trk = 0;
17 m_trk_kal = 0;
18 m_stat = -1;
19 m_trk_id = 0;
20 m_quality = -99;
21 m_charge = 0;
22 m_P = 0;
23 m_theta = 0;
24 m_phi = 0;
25 m_pl_rp = 0;
26 m_nsample = 0;
27
28 m_dEdx = 0;
29 m_truncate = 1;
30 for( unsigned a = 0; a < 5 ; a++ )
31 {
32 dedx_exp[a]=0.0;
33 ex_sigma[a]=0.0;
34 pid_prob[a]=0.0;
35 chi_ex[a]=999.0;
36 }
37
38#ifdef DEBUG
39 std::cout<<"MdcDedxTrk(1) constructed!"<<std::endl;
40#endif
41}
42
44{
45 m_trk = 0;
46 m_trk_kal = 0;
47 m_stat = -1;
48 m_trk_id = 0;
49 m_quality = -99;
50 m_charge = 0;
51 m_P = 0;
52 m_theta = 0;
53 m_phi = 0;
54 m_pl_rp = 0;
55 m_nsample = 0;
56 m_dEdx = 0;
57 m_truncate = 0.7;
58
59 set_ExTrk( trk );
60#ifdef DEBUG
61 std::cout<<"MdcDedxTrk(2) constructed!"<<std::endl;
62#endif
63}
64
66{
67 m_trk = 0;
68 m_trk_kal = 0;
69 m_stat = -1;
70 m_trk_id = 0;
71 m_quality = -99;
72 m_charge = 0;
73 m_P = 0;
74 m_theta = 0;
75 m_phi = 0;
76 m_pl_rp = 0;
77 m_nsample = 0;
78 m_dEdx = 0;
79 m_truncate = 0.7;
80
81 set_ExTrk_Kal( trk_kal, pid );
82#ifdef DEBUG
83 std::cout<<"MdcDedxTrk(2) kal constructed!"<<std::endl;
84#endif
85}
86
88{
89#ifdef DEBUG
90 std::cout<<"MdcDedxTrk destructed!!!"<<std::endl;
91#endif
92}
93
95{
96 for( unsigned a = 0; a < 5 ; a++ )
97 {
98 dedx_exp[a]=0.0;
99 ex_sigma[a]=0.0;
100 pid_prob[a]=0.0;
101 chi_ex[a]=0.0;
102 }
103 m_stat = 1;
104 m_trk = &trk;
105 m_trk_id = trk.trackId();
106 m_quality = trk.stat();
107
108 m_charge = ( trk.helix(2) > 0 )? 1 : -1;
109 float m_Pt = 1.0/fabs( trk.helix(2) );
110 m_P = m_Pt*sqrt(1 + trk.helix(4)*trk.helix(4));
111 m_theta = M_PI_2 - atan( trk.helix(4) );
112 m_phi = ( trk.helix(1) < 3*M_PI_2 )? trk.helix(1)+M_PI_2 : trk.helix(1)-3*M_PI_2;
113 m_nsample = trk.getNhits();
114 m_pl_rp = 1.5;
115 //cout<<"set_ExTrk: "<<trk.helix(0)<<" "<<trk.helix(1)<<" "<<trk.helix(2)<<" "<<trk.helix(3)<<" "<<trk.helix(4)<<endl;
116
117#ifdef DEBUG
118 std::cout<<"MdcDedxTrk::set_ExTrk(&trk)!!!"<<std::endl;
119#endif
120}
121
123{
124 DstMdcKalTrack* dstTrk = &trk_kal;
125 for( unsigned a = 0; a < 5 ; a++ )
126 {
127 dedx_exp[a]=0.0;
128 ex_sigma[a]=0.0;
129 pid_prob[a]=0.0;
130 chi_ex[a]=0.0;
131 }
132 if(pid<0 || pid>4) pid = 2;
133 m_stat = 1;
134 m_trk_kal = &trk_kal;
135 m_trk_id = trk_kal.trackId();
136 m_quality = dstTrk->getStat(pid);
137
138 HepVector kal_helix = dstTrk->getFHelix(pid);
139 m_charge = ( kal_helix[2] > 0 )? 1 : -1;
140 float m_Pt = 1.0/fabs( kal_helix[2] );
141 m_P = m_Pt*sqrt(1 + kal_helix[4]*kal_helix[4]);
142 m_theta = M_PI_2 - atan( kal_helix[4] );
143 m_phi = ( kal_helix[1] < 3*M_PI_2 )? kal_helix[1]+M_PI_2 : kal_helix[1]-3*M_PI_2;
144 m_nsample = trk_kal.getNhits(pid);
145 m_pl_rp = 1.5;
146 //cout<<"set_ExTrk_Kal: "<<kal_helix[0]<<" "<<kal_helix[1]<<" "<<kal_helix[2]<<" "<<kal_helix[3]<<" "<<kal_helix[4]<<endl;
147#ifdef DEBUG
148 std::cout<<"MdcDedxTrk::set_ExTrk_Kal(&trk_kal)!!!"<<std::endl;
149#endif
150}
151
152
153double MdcDedxTrk::cal_dedx( float truncate )
154{
155 m_truncate = truncate;
156 sort(m_phlist.begin(),m_phlist.end());
157 int nsampl = (int)( m_phlist.size()*truncate );
158 double qSum = 0;
159 unsigned int i = 0;
160 for(vector<double>::iterator ql= m_phlist.begin();ql!=m_phlist.end();ql++)
161 {
162 i++;
163 if(i<= nsampl) qSum += (*ql);
164 }
165
166 float trunc=qSum/nsampl;
167 return trunc;
168 std::cout<<"MdcDedxTrk::cal_dedx()!!!"<<std::endl;
169}
170
171double MdcDedxTrk::cal_dedx_bitrunc(float truncate, int alg, int & usedhit )
172{
173 m_truncate = truncate;
174 sort(m_phlist.begin(),m_phlist.end());
175 int nsampl = (int)( m_phlist.size()*truncate );
176 int smpl = (int)(m_phlist.size()*(truncate+0.05));
177 int min_cut = (int)( m_phlist.size()*0.05 + 0.5 );
178 double qSum = 0;
179 unsigned i = 0;
180 for(vector<double>::iterator ql= m_phlist.begin();ql!=m_phlist.end();ql++)
181 {
182 i++;
183 if(i<= smpl && i>=min_cut ) qSum += (*ql);
184 }
185 double trunc=-99;
186 usedhit = smpl-min_cut+1;
187 if(usedhit>0) trunc=qSum/usedhit;
188
189 return trunc;
190 std::cout<<"MdcDedxTrk::cal_dedx()!!!"<<std::endl;
191}
192
193double MdcDedxTrk::cal_dedx_median( float truncate )
194{
195 sort(m_phlist.begin(),m_phlist.end());
196
197 int nsample = m_phlist.size();
198 double median;
199 if( fmod(double(nsample),2.0) ) {
200 median = m_phlist[(nsample-1)/2];
201 } else {
202 median= 0.5*( m_phlist[nsample/2] + m_phlist[nsample/2-1] );
203 }
204 return median;
205}
206
207double MdcDedxTrk::cal_dedx_geometric( float truncate )
208{
209 sort(m_phlist.begin(),m_phlist.end());
210
211 int nsampl = m_phlist.size();
212 double qSum = 1.0;
213 for(vector<double>::iterator ql= m_phlist.begin();ql!=m_phlist.end();ql++){
214 qSum *= (*ql);
215 }
216
217 double trunc = pow(qSum,1/double(nsampl));
218 return trunc;
219 std::cout<<"MdcDedxTrk::cal_dedx()!!!"<<std::endl;
220}
221
223{
224 m_truncate = truncate;
225 sort(m_phlist.begin(),m_phlist.end());
226 int nsampl = (int)( m_phlist.size()*truncate );
227 double qSum = 1.0;
228 unsigned i = 0;
229 for(vector<double>::iterator ql= m_phlist.begin();ql!=m_phlist.end();ql++){
230 i++;
231 if( i<= nsampl )
232 qSum *= (*ql);
233 }
234
235 double trunc = pow(qSum,1/double(nsampl));
236 return trunc;
237
238 std::cout<<"MdcDedxTrk::cal_dedx()!!!"<<std::endl;
239}
240
241double MdcDedxTrk::cal_dedx_harmonic( float truncate )
242{
243 sort(m_phlist.begin(),m_phlist.end());
244
245 int nsampl = m_phlist.size();
246 double qSum = 0;
247 for(vector<double>::iterator ql= m_phlist.begin();ql!=m_phlist.end();ql++){
248 qSum += 1/(*ql);
249 }
250
251 float trunc=nsampl/qSum;
252 return trunc;
253 std::cout<<"MdcDedxTrk::cal_dedx()!!!"<<std::endl;
254}
255
257{
258 m_truncate = truncate;
259 sort(m_phlist.begin(),m_phlist.end());
260 int nsampl = (int)( m_phlist.size()*truncate );
261 double qSum = 0;
262 unsigned i = 0;
263 for(vector<double>::iterator ql= m_phlist.begin();ql!=m_phlist.end();ql++){
264 i++;
265 if( i<= nsampl )
266 qSum += 1/(*ql);
267 }
268
269 float trunc= nsampl/qSum;
270 return trunc;
271 std::cout<<"MdcDedxTrk::cal_dedx()!!!"<<std::endl;
272}
273
275{
276 sort(m_phlist.begin(),m_phlist.end());
277
278 int nsampl = m_phlist.size();
279 double qSum = 0;
280 for(vector<double>::iterator ql= m_phlist.begin();ql!=m_phlist.end();ql++){
281 qSum += 1/sqrt(*ql);
282 }
283
284 float trunc=1/qSum;
285
286 return trunc;
287 std::cout<<"MdcDedxTrk::cal_dedx()!!!"<<std::endl;
288}
289
290
291double MdcDedxTrk::cal_dedx_log( float truncate ,int alg)
292{
293 double qSum = 0;
294 unsigned i = 0;
295 for(vector<double>::iterator ql= m_phlist.begin();ql!=m_phlist.end();ql++){
296 i++;
297 qSum += log(*ql);
298 }
299
300 float trunc=qSum/m_phlist.size();
301 return trunc;
302 std::cout<<"MdcDedxTrk::cal_dedx_log()!!!"<<std::endl;
303}
304
305
306
307void MdcDedxTrk::set_dEdx( int landau, float dEdx, int trkalg, int runflag, int vflag[3] , double t0, vector<double>& DedxCurve_Parameter, vector<double>& DedxSigma_Parameter, MdcDedxCorrection* ex_calib)
308{
309#ifdef DEBUG
310 cout<<"in MdcDedxTrk::set_dEdx() landau: "<<landau<<" dedx: "<<dEdx<<" nsample(): "<<nsample()<<" ph size: "<<m_phlist.size()<<" m_P: "<<m_P<<" theta: "<<m_theta<<" pl-rp: "<<m_pl_rp<<endl;
311#endif
312
313 m_dEdx = dEdx;
314 int dedxhit_use = (int)(m_phlist.size()*m_truncate);
315
316 //some old data with od methods
317 if(runflag ==1 || runflag ==2 )
318 ex_calib->dedx_pid_exp_old( landau, runflag, (float)dEdx, (int)dedxhit_use,
319 (float)m_P, (float)m_theta, (float)t0,(float)m_pl_rp,
320 dedx_exp, ex_sigma, pid_prob, chi_ex);
321 //for 2009 psip data and after
322 else
323 ex_calib->dedx_pid_exp( vflag, (float)dEdx, trkalg,(int)dedxhit_use,
324 (float)m_P, (float)m_theta, (float)t0,(float)m_pl_rp,
325 dedx_exp, ex_sigma, pid_prob, chi_ex, DedxCurve_Parameter, DedxSigma_Parameter);
326
327#ifdef DEBUG
328 std::cout<<"MdcDedxTrk::set_dEdx()!!!"<<std::endl;
329#endif
330}
331
332//---------------------------------------------------------------------------
333double MdcDedxTrk::SpaceChargeCorrec(double m_theta, double mom, int Particle, double dEdx )
334{
335 const int par_cand( 5 );
336 const float Charge_Mass[par_cand] = {0.00051100, 0.10566, 0.13957, 0.4937, 0.93827 };
337 double beta_G;
338 double e_Par[5] = {143.349, 1.7315, 0.192616, 2.90437, 1.08248};
339 double Beta_Gamma[22] ={0.373026, 0.479605, 0.586184, 0.692763, 0.799342, 782.779, 1565.56,
340 2348.34, 17.2727, 18.1245, 1.43297, 2.14946, 12.1803, 13.6132, 6.62515, 10.4109,
341 14.1967, 17.9825, 21.7683, 26.0274, 30.7596, 35.4919 };
342 double K_par[22] ={4.64411e-05, 5.86544e-05, 8.05289e-05, 8.46981e-05, 8.92014e-05, 4.74517e-05,
343 4.51684e-05, 5.32732e-05, 6.12803e-05, 6.14592e-05, 8.08608e-05, 6.73184e-05, 5.46448e-05,
344 6.1377e-05, 6.57385e-05, 7.03053e-05, 6.61171e-05, 6.86824e-05, 6.246e-05, 7.25988e-05,
345 7.11034e-05, 6.24924e-05 };
346 double D_par[22] ={0.0871504, 0.0956379, 0.117193, 0.118647, 0.127203, 0.0566449, 0.0529198,
347 0.0642525, 0.0764562, 0.081341, 0.0952263, 0.0987536, 0.0639901, 0.0845994,0.0777062,
348 0.0823206, 0.0783874, 0.079537, 0.0815792, 0.0849875, 0.0824751,0.0776296 };
349 double DSqr_par[22] = {0.00759519, 0.0091466, 0.0137341, 0.0140772, 0.0161807, 0.00320864,
350 0.00280051, 0.00412839, 0.00584555, 0.00661636, 0.00906805, 0.00975227, 0.00409473,
351 0.00715706, 0.00603826, 0.00677668, 0.00614458, 0.00632613, 0.00665516, 0.00722288,
352 0.00680214, 0.00602635};
353
354 beta_G = mom/Charge_Mass[Particle];
355 if(beta_G <0.3) beta_G =0.3;
356 double bet=beta_G/TMath::Sqrt(beta_G*beta_G+1);
357 double fterm=TMath::Log(e_Par[2]+1/pow(beta_G,e_Par[4]));
358 double fitval=e_Par[0]/pow(bet,e_Par[3])*(e_Par[1]-pow(bet,e_Par[3])-fterm);
359 TGraphErrors *gr1 = new TGraphErrors(22,Beta_Gamma, K_par,0,0);
360 TGraphErrors *gr2 = new TGraphErrors(22,Beta_Gamma, DSqr_par,0,0);
361
362 double par[3];
363 par[0] = fitval;
364 par[1] = gr1->Eval(m_theta);
365 par[2] = gr2->Eval(m_theta);
366 Double_t y = fabs(cos(m_theta));
367 double electron_par[3] ={334.032, 6.20658e-05, 0.00525673};
368 double arg= TMath::Sqrt(y*y+ par[2]);
369 //double cal_factor =par[0]*TMath::Exp(-(par[1]* par[0])/arg);
370 double cal_factor =TMath::Exp(-(par[1]* par[0])/arg);
371 double arg_electron = TMath::Sqrt(y*y + electron_par[2]);
372 //double electron_factor = electron_par[0]*TMath::Exp(-(electron_par[1]* electron_par[0])/arg);
373 double electron_factor = TMath::Exp(-(electron_par[1]* electron_par[0])/arg_electron);
374 //cout<<"cal_factor = "<<cal_factor<<" electron_factor = "<<electron_factor<<endl;
375 double dedx_cal = dEdx/(cal_factor/electron_factor);
376 //double dedx_cal = dEdx/cal_factor;
377 //cout<<"m_theta= "<<m_theta<<" y ="<<y<<" beta_G = "<<beta_G <<" dEdx = "<<dEdx<<" cal dedx = "<<dedx_cal<<endl;
378 delete gr1;
379 delete gr2;
380 return dedx_cal;
381}
double arg(const EvtComplex &c)
Definition: EvtComplex.hh:227
HepMC::GenParticle Particle
double cos(const BesAngle a)
const HepVector & getFHelix(const int pid) const
const HepVector helix() const
......
void dedx_pid_exp_old(int landau, int runflag, float dedx, int Nhit, float mom, float theta, float t0, float lsamp, double dedx_ex[5], double ex_sigma[5], double pid_prob[5], double chi_dedx[5]) const
void dedx_pid_exp(int vflag[3], float dedx, int trkalg, int Nhit, float mom, float theta, float t0, float lsamp, double dedx_ex[5], double ex_sigma[5], double pid_prob[5], double chi_dedx[5], std::vector< double > &DedxCurve_Parameter, std::vector< double > &DedxSigma_Parameter) const
double cal_dedx_geometric_trunc(float)
Definition: MdcDedxTrk.cxx:222
double cal_dedx_bitrunc(float, int, int &)
Definition: MdcDedxTrk.cxx:171
void set_dEdx(int l, float dEdx_meas, int trkalg, int runflag, int vflag[3], double t0, vector< double > &DedxCurve_Parameter, vector< double > &DedxSigma_Parameter, MdcDedxCorrection *)
Definition: MdcDedxTrk.cxx:307
double cal_dedx_harmonic_trunc(float)
Definition: MdcDedxTrk.cxx:256
void set_ExTrk_Kal(RecMdcKalTrack &trk_kal, int pid)
Definition: MdcDedxTrk.cxx:122
void set_ExTrk(RecMdcTrack &trk)
Definition: MdcDedxTrk.cxx:94
double cal_dedx_harmonic(float)
Definition: MdcDedxTrk.cxx:241
double cal_dedx_log(float, int)
Definition: MdcDedxTrk.cxx:291
double cal_dedx(float)
Definition: MdcDedxTrk.cxx:153
double SpaceChargeCorrec(double, double, int, double)
Definition: MdcDedxTrk.cxx:333
double cal_dedx_median(float)
Definition: MdcDedxTrk.cxx:193
double cal_dedx_geometric(float)
Definition: MdcDedxTrk.cxx:207
double cal_dedx_transform(int)
Definition: MdcDedxTrk.cxx:274