BOSS 7.1.2
BESIII Offline Software System
Loading...
Searching...
No Matches
KalFitAlg.h
Go to the documentation of this file.
1//------------------------------------------------------------------------
2// Description :
3// Main file of the module KalFit in charge of :
4// 1/ Refit of the Mdc tracks using Kalman filter
5// 2/ Backward filter (smoothing)
6// 3/ and also several mass hypothesis, Non unif mag field treatment...
7//
8//------------------------------------------------------------------------
9
10#ifndef _DEFINE_KALFITALG_H_
11#define _DEFINE_KALFITALG_H_
12#ifndef DBL_MAX
13#define DBL_MAX 9999
14#endif
15
16class KalFitTrack;
17class KalFitHitMdc;
18class KalFitHelixSeg;
19class Bfield;
20//class Helix;
21
22#include "GaudiKernel/Algorithm.h"
25#include "GaudiKernel/IMagneticFieldSvc.h"
33#include "MdcTables/MdcTables.h"
34#include "GaudiKernel/NTuple.h"
35#include "AIDA/IHistogram1D.h"
36#include "AIDA/IHistogramFactory.h"
37#include "GaudiKernel/IHistogramSvc.h"
40#include "HepPDT/ParticleDataTable.hh"
41#include <vector>
42//added header files for 6.0.0
43#include "CLHEP/Matrix/Vector.h"
44#include "CLHEP/Matrix/Matrix.h"
45#include "CLHEP/Matrix/SymMatrix.h"
46#include "CLHEP/Vector/ThreeVector.h"
47#include "G4Material.hh"
48#include "G4Tubs.hh"
49
50#ifndef ENABLE_BACKWARDS_COMPATIBILITY
51typedef HepGeom::Point3D <double > HepPoint3D;
52#endif
53
54using namespace std;
55using namespace CLHEP;
56
57
58class KalFitAlg : public Algorithm {
59
60 public:
61 /**@name Main member functions*/
62 //@{
63 /// constructor
64 KalFitAlg(const std::string& name, ISvcLocator* pSvcLocator);
65 /// destructor
66 ~KalFitAlg(void);
67 /// initialize
68 StatusCode initialize();
69 /// event function
70 StatusCode execute();
71 StatusCode finalize();
72 StatusCode beginRun();
73 /// hist definition
74 void hist_def ( void );
75 /// delete C++ objects, necessary to clean before begin_run or inside
76 /// destructor
77 void clean(void);
78 //@}
79 /**@name Set up the description of the Mdc */
80 //@{
81 /// Set up the wires, layers and superlayers...
82 void set_Mdc(void);
83 /// Initialize the material for Mdc
84 void setMaterial_Mdc(void);
85 /// Initialize the cylinders (walls and cathodes) for Mdc
86 void setCylinder_Mdc(void);
87 ///
88 void setDchisqCut(void);
89 /// initialize for the services
90 void setCalibSvc_init(void);
91 void setGeomSvc_init(void);
93 ///
94 void getEventStarTime(void);
95
96 /**@name Kalman filter method related member functions*/
97 //@{
98 /// Kalman filter (forward) in Mdc
99 void filter_fwd_anal(KalFitTrack& trk, int l_mass, int way, HepSymMatrix& Eakal);
100 void filter_fwd_calib(KalFitTrack& trk, int l_mass, int way, HepSymMatrix& Eakal);
101
102 void init_matrix(MdcRec_trk& trk, HepSymMatrix& Ea);
103 void init_matrix(int k, MdcRec_trk& trk, HepSymMatrix& Ea);
104
105 void start_seed(KalFitTrack& track, int lead_, int way, MdcRec_trk& trk);
106
107 /// Kalman filter (smoothing or backward part)
108 void smoother_anal(KalFitTrack& trk, int way);
109 void smoother_calib(KalFitTrack& trk, int way);
110
111 /// Take the inner walls (eloss and mult scat) into account
112 void innerwall(KalFitTrack& trk, int l_mass, int way);
113 //@{
114 /// with results got at the inner Mdc hit
115 void fillTds(MdcRec_trk& TrasanTRK, KalFitTrack& track,
116 RecMdcKalTrack* trk,int l_mass);
117 void fillTds_lead(MdcRec_trk& TrasanTRK, KalFitTrack& track,
118 RecMdcKalTrack* trk, int l_mass);
119 /// with results got at the outer Mdc hit
120 void fillTds_back(KalFitTrack& track, RecMdcKalTrack* trk,
121 MdcRec_trk& TrasanTRK,int l_mass );
122
123 void fillTds_back(KalFitTrack& track, RecMdcKalTrack* trk,
124 MdcRec_trk& TrasanTRK,int l_mass,RecMdcKalHelixSegCol* segcol);
125
126 ///for smoother process
127 void fillTds_back(KalFitTrack& track, RecMdcKalTrack* trk,
128 MdcRec_trk& TrasanTRK,int l_mass,RecMdcKalHelixSegCol* segcol, int smoothflag);
129 /// with results got at (0,0,0)
130 void fillTds_ip(MdcRec_trk& TrasanTRK, KalFitTrack& track,
131 RecMdcKalTrack* trk, int l_mass);
132
133 /// complete the RecMdcKalTrackCol
134 void sameas(RecMdcKalTrack* trk, int l_mass, int imain);
135
136 void complete_track(MdcRec_trk& TrasanTRK,
137 MdcRec_trk_add& TrasanTRK_add,
138 KalFitTrack& track_lead,
139 RecMdcKalTrack* kaltrk,
140 RecMdcKalTrackCol* kalcol,RecMdcKalHelixSegCol* segcol,int flagsmooth);
141
142 void complete_track(MdcRec_trk& TrasanTRK,
143 MdcRec_trk_add& TrasanTRK_add,
144 KalFitTrack& track_lead,
145 RecMdcKalTrack* kaltrk,
147
148 // Careful refit
149 void kalman_fitting_anal(void);
150 void kalman_fitting_calib(void);
151 void kalman_fitting_csmalign(void);
153
154 // clear tables by wangdy
155 void clearTables( );
156
157 ///
158 int getWallMdcNumber(const HepPoint3D& point);
159
160 ///
161 void extToAnyPoint(KalFitTrack& trk, const HepPoint3D& point);
162
163 ///
164 void setBesFromGdml(void);
165
166 /// this usage is used to control the usage of this algorithm ,to be
167 /// analysis or calibration.
169 ///
171 //// flag to calculate path length in each Mdc laye :
173 /// flag to take account the wire sag into account
174 int wsag_;
175 /// flag to perform smoothing
176 int back_;
177
179
181 /// value of the pT cut for backward filter
182 double pT_;
183 /// leading mass assumption
184 int lead_;
185 ///
186 int mhyp_;
187 /// value of the momentum cut to decide refit
190
191
192 /// Flag account to multiple scattering and energy loss,
193 /// where lr flag from and whether use active hits only
195 /// flag to enhance the error matrix at the inner hit of Mdc (cosmic)
198 ///
202 int numf_;
208 ///
210 /// mass assumption for backward filter (if <0 means use leading mass)
213 /// Debug flag for the track finder part
215 /// Fill ntuples of KalFit
217 // dir of files
219 //cut for delta_chi2
221
223
224 /// factor of energy loss straggling for electron
225 double fstrag_;
226 //wire resoltion flag
229
230 /// propagation correction
234 int m_csmflag; //cosmic events flag; for cosmic events tof(y>0) should be minus
235 double m_dangcut, m_dphicut; //for cosmic events cut
236
237 private:
238 std::vector<KalFitCylinder> _BesKalmanFitWalls;
239 std::vector<KalFitMaterial> _BesKalmanFitMaterials;
240 //std::vector<G4Tubs> _BesKalmanFitTubs;
241
242 // --- statistics
243 int nTotalTrks;
244 int nFailedTrks[5];
245
246
247 KalFitWire * _wire;
248 KalFitLayer_Mdc * _layer;
249 KalFitSuper_Mdc * _superLayer;
250 HepPDT::ParticleDataTable* m_particleTable;
251 static const double RIW;
252
253 const MdcCalibFunSvc* m_mdcCalibFunSvc_;
254 const IMagneticFieldSvc* m_MFSvc_;
255 static IMdcGeomSvc* imdcGeomSvc_;
256
257 //sort the rec hits by layer
258 static bool order_rechits(const SmartRef<RecMdcHit>& m1, const SmartRef<RecMdcHit>& m2);
259
260 //ntuples
261 NTuple::Tuple* m_nt1; // KalFit track params
262 NTuple::Tuple* m_nt2; // KalFit 2-prong comparison
263 NTuple::Tuple* m_nt3; // PatRec track params
264 NTuple::Tuple* m_nt4; // PatRec 2-prong comparison
265 NTuple::Tuple* m_nt5; // for hit checking and cut
266 NTuple::Tuple* m_nt6; // for helix seg of calib
267
268 //for nt1
269 NTuple::Item<long> m_trackid,m_evtid;
270 NTuple::Item<double> m_chi2direct,m_prob;
271 NTuple::Matrix<double> m_ndf,m_chisq,m_stat;
272 NTuple::Array<double> m_length,m_tof,m_nhits;
273 NTuple::Item<double> m_zptot,m_zptote,m_zptotmu,m_zptotk,m_zptotp;
274 NTuple::Item<double> m_zpt,m_zpte,m_zptmu,m_zptk,m_zptp;
275 NTuple::Item<double> m_fptot,m_fptote,m_fptotmu,m_fptotk,m_fptotp;
276 NTuple::Item<double> m_fpt,m_fpte,m_fptmu,m_fptk,m_fptp;
277 NTuple::Item<double> m_lptot,m_lptote,m_lptotmu,m_lptotk,m_lptotp;
278 NTuple::Item<double> m_lpt,m_lpte,m_lptmu,m_lptk,m_lptp;
279 NTuple::Item<double> m_zsigp,m_zsigpe,m_zsigpmu,m_zsigpk,m_zsigpp;
280 NTuple::Array<double> m_zhelix,m_zhelixe,m_zhelixmu,m_zhelixk,m_zhelixp;
281 NTuple::Array<double> m_fhelix,m_fhelixe,m_fhelixmu,m_fhelixk,m_fhelixp;
282 NTuple::Array<double> m_lhelix,m_lhelixe,m_lhelixmu,m_lhelixk,m_lhelixp;
283 NTuple::Array<double> m_zerror,m_zerrore,m_zerrormu,m_zerrork,m_zerrorp;
284 NTuple::Array<double> m_ferror,m_ferrore,m_ferrormu,m_ferrork,m_ferrorp;
285 NTuple::Array<double> m_lerror,m_lerrore,m_lerrormu,m_lerrork,m_lerrorp;
286 //for nt1 single track MCTruth
287 NTuple::Array<double> m_mchelix;
288 NTuple::Item<double> m_mcptot;
289 NTuple::Item<long> m_mcpid;
290 //for nt3
291 NTuple::Array<double> m_trkhelix, m_trkerror;
292 NTuple::Item<double> m_trkndf, m_trkchisq, m_trkptot, m_trksigp;
293 //for nt2
294 NTuple::Item<double> m_delx,m_dely,m_delz,m_delthe,m_delphi,m_delp;
295 NTuple::Item<double> m_delpx,m_delpy,m_delpz;
296
297 //for nt4
298 NTuple::Item<double> m_trkdelx,m_trkdely,m_trkdelz;
299 NTuple::Item<double> m_trkdelthe,m_trkdelphi,m_trkdelp;
300 //for nt5
301 NTuple::Item<double> m_dchi2,m_orichi2,m_fitchi2,m_residest, m_residnew,m_anal_dr, m_anal_phi0, m_anal_kappa, m_anal_dz, m_anal_tanl, m_anal_ea_dr, m_anal_ea_phi0, m_anal_ea_kappa, m_anal_ea_dz, m_anal_ea_tanl;
302 NTuple::Item<long> m_masshyp, m_layer;
303 //for nt6
304 NTuple::Item<double> m_docaInc,m_docaExc, m_tdrift;
305 NTuple::Item<long> m_layerid,m_eventNo;
306 NTuple::Item<double> m_residualInc, m_residualExc, m_lr, m_yposition, m_dd;
307
308 NTuple::Item<double> m_dchisq0,m_dchisq1,m_dchisq2,m_dchisq3,m_dchisq4,m_dchisq5,m_dchisq6,m_dchisq7,m_dchisq8,m_dchisq9,m_dchisq10,m_dchisq11,m_dchisq12,m_dchisq13,m_dchisq14,m_dchisq15,m_dchisq16,m_dchisq17,m_dchisq18,m_dchisq19,m_dchisq20,m_dchisq21,m_dchisq22,m_dchisq23,m_dchisq24,m_dchisq25,m_dchisq26,m_dchisq27,m_dchisq28,m_dchisq29,m_dchisq30,m_dchisq31,m_dchisq32,m_dchisq33,m_dchisq34,m_dchisq35,m_dchisq36,m_dchisq37,m_dchisq38,m_dchisq39,m_dchisq40,m_dchisq41,m_dchisq42;
309 NTuple::Item<double> m_dtrack0,m_dtrack1,m_dtrack2,m_dtrack3,m_dtrack4,m_dtrack5,m_dtrack6,m_dtrack7,m_dtrack8,m_dtrack9,m_dtrack10,m_dtrack11,m_dtrack12,m_dtrack13,m_dtrack14,m_dtrack15,m_dtrack16,m_dtrack17,m_dtrack18,m_dtrack19,m_dtrack20,m_dtrack21,m_dtrack22,m_dtrack23,m_dtrack24,m_dtrack25,m_dtrack26,m_dtrack27,m_dtrack28,m_dtrack29,m_dtrack30,m_dtrack31,m_dtrack32,m_dtrack33,m_dtrack34,m_dtrack35,m_dtrack36,m_dtrack37,m_dtrack38,m_dtrack39,m_dtrack40,m_dtrack41,m_dtrack42;
310 NTuple::Item<double> m_dtdc0,m_dtdc1,m_dtdc2,m_dtdc3,m_dtdc4,m_dtdc5,m_dtdc6,m_dtdc7,m_dtdc8,m_dtdc9,m_dtdc10,m_dtdc11,m_dtdc12,m_dtdc13,m_dtdc14,m_dtdc15,m_dtdc16,m_dtdc17,m_dtdc18,m_dtdc19,m_dtdc20,m_dtdc21,m_dtdc22,m_dtdc23,m_dtdc24,m_dtdc25,m_dtdc26,m_dtdc27,m_dtdc28,m_dtdc29,m_dtdc30,m_dtdc31,m_dtdc32,m_dtdc33,m_dtdc34,m_dtdc35,m_dtdc36,m_dtdc37,m_dtdc38,m_dtdc39,m_dtdc40,m_dtdc41,m_dtdc42;
311
312};
313#endif
314
HepGeom::Point3D< double > HepPoint3D
Definition KalFitAlg.h:51
ObjectVector< RecMdcKalHelixSeg > RecMdcKalHelixSegCol
ObjectVector< RecMdcKalTrack > RecMdcKalTrackCol
double pe_cut_
value of the momentum cut to decide refit
Definition KalFitAlg.h:188
int debug_kft_
Definition KalFitAlg.h:214
double gain1_
Definition KalFitAlg.h:199
void filter_fwd_anal(KalFitTrack &trk, int l_mass, int way, HepSymMatrix &Eakal)
Kalman filter (forward) in Mdc.
void filter_fwd_calib(KalFitTrack &trk, int l_mass, int way, HepSymMatrix &Eakal)
double dchi2cut_mid1_
Definition KalFitAlg.h:222
double fstrag_
factor of energy loss straggling for electron
Definition KalFitAlg.h:225
double pmu_cut_
Definition KalFitAlg.h:188
StatusCode beginRun()
double fac_h4_
Definition KalFitAlg.h:197
double m_dangcut
Definition KalFitAlg.h:235
double theta_cut_
Definition KalFitAlg.h:189
double pt_cut_
Definition KalFitAlg.h:189
int back_
flag to perform smoothing
Definition KalFitAlg.h:176
double gain3_
Definition KalFitAlg.h:199
void fillTds_lead(MdcRec_trk &TrasanTRK, KalFitTrack &track, RecMdcKalTrack *trk, int l_mass)
int iqual_front_[5]
Definition KalFitAlg.h:228
int numfcor_
Definition KalFitAlg.h:201
int outer_steps_
Definition KalFitAlg.h:204
int eventno
Definition KalFitAlg.h:178
~KalFitAlg(void)
destructor
double gain5_
Definition KalFitAlg.h:199
double dchi2cutf_
Definition KalFitAlg.h:220
void clean(void)
int tof_hyp_
Definition KalFitAlg.h:194
void kalman_fitting_MdcxReco_Csmc_Sew(void)
double pp_cut_
Definition KalFitAlg.h:188
void setCalibSvc_init(void)
initialize for the services
int numf_in_
Definition KalFitAlg.h:205
void smoother_anal(KalFitTrack &trk, int way)
Kalman filter (smoothing or backward part)
int iqual_back_
Definition KalFitAlg.h:228
int i_back_
mass assumption for backward filter (if <0 means use leading mass)
Definition KalFitAlg.h:211
void complete_track(MdcRec_trk &TrasanTRK, MdcRec_trk_add &TrasanTRK_add, KalFitTrack &track_lead, RecMdcKalTrack *kaltrk, RecMdcKalTrackCol *kalcol, RecMdcKalHelixSegCol *segcol, int flagsmooth)
int wsag_
flag to take account the wire sag into account
Definition KalFitAlg.h:174
double fac_h3_
Definition KalFitAlg.h:197
double dchi2cut_mid2_
Definition KalFitAlg.h:222
void kalman_fitting_calib(void)
void sameas(RecMdcKalTrack *trk, int l_mass, int imain)
complete the RecMdcKalTrackCol
void fillTds_ip(MdcRec_trk &TrasanTRK, KalFitTrack &track, RecMdcKalTrack *trk, int l_mass)
with results got at (0,0,0)
int tofflag_
Definition KalFitAlg.h:194
string matfile_
Definition KalFitAlg.h:218
void fillTds(MdcRec_trk &TrasanTRK, KalFitTrack &track, RecMdcKalTrack *trk, int l_mass)
with results got at the inner Mdc hit
void innerwall(KalFitTrack &trk, int l_mass, int way)
Take the inner walls (eloss and mult scat) into account.
double fac_h1_
Definition KalFitAlg.h:197
double m_dphicut
Definition KalFitAlg.h:235
double fac_h2_
Definition KalFitAlg.h:197
int fitnocut_
Definition KalFitAlg.h:207
int debug_
Debug flag for the track finder part.
Definition KalFitAlg.h:214
string cylfile_
Definition KalFitAlg.h:218
void start_seed(KalFitTrack &track, int lead_, int way, MdcRec_trk &trk)
double dchi2cut_layid2_
Definition KalFitAlg.h:222
void getEventStarTime(void)
void setBesFromGdml(void)
void setGeomSvc_init(void)
KalFitAlg(const std::string &name, ISvcLocator *pSvcLocator)
constructor
Definition KalFitAlg.cxx:85
void kalman_fitting_anal(void)
int i_front_
Definition KalFitAlg.h:212
void setDchisqCut(void)
int m_usevtxdb
Definition KalFitAlg.h:233
int tprop_
propagation correction
Definition KalFitAlg.h:231
double dchi2cut_layid3_
Definition KalFitAlg.h:222
double fac_h5_
Definition KalFitAlg.h:197
int choice_
Definition KalFitAlg.h:170
int getWallMdcNumber(const HepPoint3D &point)
void set_Mdc(void)
Set up the wires, layers and superlayers...
int numf_out_
Definition KalFitAlg.h:206
void setMagneticFieldSvc_init(void)
int drifttime_choice_
Definition KalFitAlg.h:209
int m_csmflag
Definition KalFitAlg.h:234
double dchi2cut_outer_
Definition KalFitAlg.h:222
int eventNo
Definition KalFitAlg.h:232
int enhance_
flag to enhance the error matrix at the inner hit of Mdc (cosmic)
Definition KalFitAlg.h:196
StatusCode execute()
event function
double gain2_
Definition KalFitAlg.h:199
int inner_steps_
Definition KalFitAlg.h:203
int lead_
leading mass assumption
Definition KalFitAlg.h:184
int resolution_
Definition KalFitAlg.h:227
double dchi2cuts_
Definition KalFitAlg.h:220
void smoother_calib(KalFitTrack &trk, int way)
int Tds_back_no
Definition KalFitAlg.h:180
void init_matrix(MdcRec_trk &trk, HepSymMatrix &Ea)
void setCylinder_Mdc(void)
Initialize the cylinders (walls and cathodes) for Mdc.
double pk_cut_
Definition KalFitAlg.h:188
double pT_
value of the pT cut for backward filter
Definition KalFitAlg.h:182
int steplev_
Definition KalFitAlg.h:200
double matrixg_
Definition KalFitAlg.h:197
StatusCode initialize()
initialize
StatusCode finalize()
void kalman_fitting_csmalign(void)
double gain4_
Definition KalFitAlg.h:199
int ntuple_
Fill ntuples of KalFit.
Definition KalFitAlg.h:216
double ppi_cut_
Definition KalFitAlg.h:188
void hist_def(void)
hist definition
void fillTds_back(KalFitTrack &track, RecMdcKalTrack *trk, MdcRec_trk &TrasanTRK, int l_mass)
with results got at the outer Mdc hit
void setMaterial_Mdc(void)
Initialize the material for Mdc.
double dchi2cut_inner_
Definition KalFitAlg.h:222
int activeonly_
Definition KalFitAlg.h:194
void extToAnyPoint(KalFitTrack &trk, const HepPoint3D &point)
void clearTables()
Description of a Hit in Mdc.
Description of a track class (<- Helix.cc)
Definition KalFitTrack.h:35
Description of a Wire class.
Definition KalFitWire.h:46
double * m1
Definition qcdloop1.h:75
double double * m2
Definition qcdloop1.h:75