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