BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
KalFitAlg Class Reference

#include <KalFitAlg.h>

Inheritance diagram for KalFitAlg:

Public Member Functions

Main member functions
 KalFitAlg (const std::string &name, ISvcLocator *pSvcLocator)
 constructor
 ~KalFitAlg (void)
 destructor
StatusCode initialize ()
 initialize
StatusCode execute ()
 event function
StatusCode finalize ()
StatusCode beginRun ()
void hist_def (void)
 hist definition
void clean (void)
Set up the description of the Mdc
void set_Mdc (void)
 Set up the wires, layers and superlayers...
void setMaterial_Mdc (void)
 Initialize the material for Mdc.
void setCylinder_Mdc (void)
 Initialize the cylinders (walls and cathodes) for Mdc.
void setDchisqCut (void)
void setCalibSvc_init (void)
 initialize for the services
void setGeomSvc_init (void)
void setMagneticFieldSvc_init (void)
void getEventStarTime (void)

Kalman filter method related member functions

int usage_
int choice_
int pathl_
int wsag_
 flag to take account the wire sag into account
int back_
 flag to perform smoothing
int eventno
int Tds_back_no
double pT_
 value of the pT cut for backward filter
int lead_
 leading mass assumption
int mhyp_
double pe_cut_
 value of the momentum cut to decide refit
double pmu_cut_
double ppi_cut_
double pk_cut_
double pp_cut_
double pt_cut_
double theta_cut_
int muls_
int loss_
int lr_
int activeonly_
int tofflag_
int tof_hyp_
int enhance_
 flag to enhance the error matrix at the inner hit of Mdc (cosmic)
double fac_h1_
double fac_h2_
double fac_h3_
double fac_h4_
double fac_h5_
double matrixg_
double gain1_
double gain2_
double gain3_
double gain4_
double gain5_
int steplev_
int numfcor_
int numf_
int inner_steps_
int outer_steps_
int numf_in_
int numf_out_
int fitnocut_
int drifttime_choice_
int i_back_
 mass assumption for backward filter (if <0 means use leading mass)
int i_front_
int debug_
 Debug flag for the track finder part.
int debug_kft_
int ntuple_
 Fill ntuples of KalFit.
string matfile_
string cylfile_
double dchi2cutf_
double dchi2cuts_
double dchi2cut_mid1_
double dchi2cut_mid2_
double dchi2cut_inner_
double dchi2cut_outer_
double dchi2cut_layid2_
double dchi2cut_layid3_
double fstrag_
 factor of energy loss straggling for electron
int resolution_
int iqual_front_ [5]
int iqual_back_
int tprop_
 propagation correction
int eventNo
int m_usevtxdb
int m_csmflag
double m_dangcut
double m_dphicut
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)
void init_matrix (MdcRec_trk &trk, HepSymMatrix &Ea)
void init_matrix (int k, MdcRec_trk &trk, HepSymMatrix &Ea)
void start_seed (KalFitTrack &track, int lead_, int way, MdcRec_trk &trk)
void smoother_anal (KalFitTrack &trk, int way)
 Kalman filter (smoothing or backward part).
void smoother_calib (KalFitTrack &trk, int way)
void innerwall (KalFitTrack &trk, int l_mass, int way)
 Take the inner walls (eloss and mult scat) into account.
void fillTds (MdcRec_trk &TrasanTRK, KalFitTrack &track, RecMdcKalTrack *trk, int l_mass)
 with results got at the inner Mdc hit
void fillTds_lead (MdcRec_trk &TrasanTRK, KalFitTrack &track, RecMdcKalTrack *trk, int l_mass)
void fillTds_back (KalFitTrack &track, RecMdcKalTrack *trk, MdcRec_trk &TrasanTRK, int l_mass)
 with results got at the outer Mdc hit
void fillTds_back (KalFitTrack &track, RecMdcKalTrack *trk, MdcRec_trk &TrasanTRK, int l_mass, RecMdcKalHelixSegCol *segcol)
void fillTds_back (KalFitTrack &track, RecMdcKalTrack *trk, MdcRec_trk &TrasanTRK, int l_mass, RecMdcKalHelixSegCol *segcol, int smoothflag)
 for smoother process
void fillTds_ip (MdcRec_trk &TrasanTRK, KalFitTrack &track, RecMdcKalTrack *trk, int l_mass)
 with results got at (0,0,0)
void sameas (RecMdcKalTrack *trk, int l_mass, int imain)
 complete the RecMdcKalTrackCol
void complete_track (MdcRec_trk &TrasanTRK, MdcRec_trk_add &TrasanTRK_add, KalFitTrack &track_lead, RecMdcKalTrack *kaltrk, RecMdcKalTrackCol *kalcol, RecMdcKalHelixSegCol *segcol, int flagsmooth)
void complete_track (MdcRec_trk &TrasanTRK, MdcRec_trk_add &TrasanTRK_add, KalFitTrack &track_lead, RecMdcKalTrack *kaltrk, RecMdcKalTrackCol *kalcol, RecMdcKalHelixSegCol *segcol)
void kalman_fitting_anal (void)
void kalman_fitting_calib (void)
void kalman_fitting_csmalign (void)
void kalman_fitting_MdcxReco_Csmc_Sew (void)
void clearTables ()
int getWallMdcNumber (const HepPoint3D &point)
void extToAnyPoint (KalFitTrack &trk, const HepPoint3D &point)
void setBesFromGdml (void)

Detailed Description

Definition at line 56 of file KalFitAlg.h.

Constructor & Destructor Documentation

◆ KalFitAlg()

KalFitAlg::KalFitAlg ( const std::string & name,
ISvcLocator * pSvcLocator )

constructor

Constructor.

Definition at line 76 of file KalFitAlg.cxx.

77 : Algorithm( name, pSvcLocator )
78 , m_mdcCalibFunSvc_( 0 )
79 , m_MFSvc_( 0 )
80 , _wire( 0 )
81 , _layer( 0 )
82 , _superLayer( 0 )
83 , pathl_( 1 )
84 , wsag_( 4 )
85 , back_( 1 )
86 , pT_( 0.0 )
87 , lead_( 2 )
88 , mhyp_( 31 )
89 , pe_cut_( 2.0 )
90 , pmu_cut_( 2.0 )
91 , ppi_cut_( 2.0 )
92 , pk_cut_( 2.0 )
93 , pp_cut_( 2.0 )
94 , muls_( 1 )
95 , loss_( 1 )
96 , enhance_( 0 )
98 , choice_( 0 )
99 , fac_h1_( 1 )
100 , fac_h2_( 1 )
101 , fac_h3_( 1 )
102 , fac_h4_( 1 )
103 , fac_h5_( 1 )
104 , i_back_( -1 )
105 , debug_kft_( 0 )
106 , debug_( 0 )
107 , ntuple_( 0 )
108 , eventno( -1 )
109 , Tds_back_no( 0 )
110 , m_nt1( 0 )
111 , m_nt2( 0 )
112 , m_nt3( 0 )
113 , m_nt4( 0 )
114 , m_nt5( 0 )
115 , iqual_back_( 1 )
116 , tprop_( 1 )
117 , dchi2cut_inner_( 0 )
118 , dchi2cut_outer_( 0 )
119 , dchi2cut_mid1_( 0 )
120 , dchi2cut_mid2_( 0 )
121 , dchi2cut_layid2_( 0 )
122 , dchi2cut_layid3_( 0 )
123 , m_usevtxdb( 0 )
124 , m_dangcut( 10 )
125 , m_dphicut( 10 )
126 , nTotalTrks( 0 ) {
127 declareProperty( "dchi2cut_layid2", dchi2cut_layid2_ = 10 );
128 declareProperty( "dchi2cut_layid3", dchi2cut_layid3_ = 10 );
129 declareProperty( "dchi2cut_inner", dchi2cut_inner_ = 10 );
130 declareProperty( "dchi2cut_mid1", dchi2cut_mid1_ = 10 );
131 declareProperty( "dchi2cut_mid2", dchi2cut_mid2_ = 10 );
132 declareProperty( "dchi2cut_outer", dchi2cut_outer_ = 10 );
133 declareProperty( "gain1", gain1_ = 1. );
134 declareProperty( "gain2", gain2_ = 1. );
135 declareProperty( "gain3", gain3_ = 1. );
136 declareProperty( "gain4", gain4_ = 1. );
137 declareProperty( "gain5", gain5_ = 1. );
138 declareProperty( "fitnocut", fitnocut_ = 5 );
139 declareProperty( "inner_steps", inner_steps_ = 3 );
140 declareProperty( "outer_steps", outer_steps_ = 3 );
141 declareProperty( "choice", choice_ = 0 );
142 declareProperty( "numfcor", numfcor_ = 0 );
143 declareProperty( "numf", numf_ = 0 );
144 declareProperty( "steplev", steplev_ = 2 );
145 declareProperty( "usage", usage_ = 0 );
146 declareProperty( "i_front", i_front_ = 1 );
147 declareProperty( "lead", lead_ = 2 );
148 declareProperty( "muls", muls_ = 1 );
149 declareProperty( "loss", loss_ = 1 );
150 declareProperty( "matrixg", matrixg_ = 100.0 );
151 declareProperty( "lr", lr_ = 1 );
152 declareProperty( "debug_kft", debug_kft_ = 0 );
153 declareProperty( "debug", debug_ = 0 );
154 declareProperty( "ntuple", ntuple_ = 0 );
155 declareProperty( "activeonly", activeonly_ = 0 );
156 declareProperty( "matfile", matfile_ = "geomdc_material.dat" );
157 declareProperty( "cylfile", cylfile_ = "geomdc_cylinder.dat" );
158 declareProperty( "dchi2cutf", dchi2cutf_ = 1000.0 );
159 declareProperty( "dchi2cuts", dchi2cuts_ = 1000.0 );
160 declareProperty( "pt", pT_ = 0.0 );
161 declareProperty( "pe_cut", pe_cut_ = 2.0 );
162 declareProperty( "pmu_cut", pmu_cut_ = 2.0 );
163 declareProperty( "ppi_cut", ppi_cut_ = 2.0 );
164 declareProperty( "pk_cut", pk_cut_ = 2.0 );
165 declareProperty( "pp_cut", pp_cut_ = 2.0 );
166 declareProperty( "wsag", wsag_ = 4 );
167 declareProperty( "back", back_ = 1 );
168 declareProperty( "i_back", i_back_ = 1 );
169 declareProperty( "tofflag", tofflag_ = 1 );
170 declareProperty( "tof_hyp", tof_hyp_ = 1 );
171 declareProperty( "resolution", resolution_ = 1 );
172 declareProperty( "fstrag", fstrag_ = 0.9 );
173 declareProperty( "drifttime_choice", drifttime_choice_ = 0 );
174 declareProperty( "tprop", tprop_ = 1 );
175 declareProperty( "pt_cut", pt_cut_ = 0.2 );
176 declareProperty( "theta_cut", theta_cut_ = 0.8 );
177 declareProperty( "usevtxdb", m_usevtxdb = 0 );
178 declareProperty( "cosmicflag", m_csmflag = 0 );
179 declareProperty( "dangcut", m_dangcut = 10. );
180 declareProperty( "dphicut", m_dphicut = 10. );
181
182 for ( int i = 0; i < 5; i++ ) nFailedTrks[i] = 0;
183}
double pe_cut_
value of the momentum cut to decide refit
Definition KalFitAlg.h:182
int debug_kft_
Definition KalFitAlg.h:207
double gain1_
Definition KalFitAlg.h:192
double dchi2cut_mid1_
Definition KalFitAlg.h:215
double fstrag_
factor of energy loss straggling for electron
Definition KalFitAlg.h:219
double pmu_cut_
Definition KalFitAlg.h:182
double fac_h4_
Definition KalFitAlg.h:190
double m_dangcut
Definition KalFitAlg.h:229
double theta_cut_
Definition KalFitAlg.h:183
double pt_cut_
Definition KalFitAlg.h:183
int back_
flag to perform smoothing
Definition KalFitAlg.h:170
double gain3_
Definition KalFitAlg.h:192
int numfcor_
Definition KalFitAlg.h:194
int outer_steps_
Definition KalFitAlg.h:197
int eventno
Definition KalFitAlg.h:172
double gain5_
Definition KalFitAlg.h:192
double dchi2cutf_
Definition KalFitAlg.h:213
int tof_hyp_
Definition KalFitAlg.h:187
double pp_cut_
Definition KalFitAlg.h:182
int iqual_back_
Definition KalFitAlg.h:222
int i_back_
mass assumption for backward filter (if <0 means use leading mass)
Definition KalFitAlg.h:204
int wsag_
flag to take account the wire sag into account
Definition KalFitAlg.h:168
double fac_h3_
Definition KalFitAlg.h:190
double dchi2cut_mid2_
Definition KalFitAlg.h:215
int tofflag_
Definition KalFitAlg.h:187
string matfile_
Definition KalFitAlg.h:211
double fac_h1_
Definition KalFitAlg.h:190
double m_dphicut
Definition KalFitAlg.h:229
double fac_h2_
Definition KalFitAlg.h:190
int fitnocut_
Definition KalFitAlg.h:200
int debug_
Debug flag for the track finder part.
Definition KalFitAlg.h:207
string cylfile_
Definition KalFitAlg.h:211
double dchi2cut_layid2_
Definition KalFitAlg.h:215
int i_front_
Definition KalFitAlg.h:205
int m_usevtxdb
Definition KalFitAlg.h:227
int tprop_
propagation correction
Definition KalFitAlg.h:225
double dchi2cut_layid3_
Definition KalFitAlg.h:216
double fac_h5_
Definition KalFitAlg.h:190
int choice_
Definition KalFitAlg.h:164
int drifttime_choice_
Definition KalFitAlg.h:202
int m_csmflag
Definition KalFitAlg.h:228
double dchi2cut_outer_
Definition KalFitAlg.h:215
int enhance_
flag to enhance the error matrix at the inner hit of Mdc (cosmic)
Definition KalFitAlg.h:189
double gain2_
Definition KalFitAlg.h:192
int inner_steps_
Definition KalFitAlg.h:196
int lead_
leading mass assumption
Definition KalFitAlg.h:178
int resolution_
Definition KalFitAlg.h:221
double dchi2cuts_
Definition KalFitAlg.h:213
int Tds_back_no
Definition KalFitAlg.h:174
double pk_cut_
Definition KalFitAlg.h:182
double pT_
value of the pT cut for backward filter
Definition KalFitAlg.h:176
int steplev_
Definition KalFitAlg.h:193
double matrixg_
Definition KalFitAlg.h:190
double gain4_
Definition KalFitAlg.h:192
int ntuple_
Fill ntuples of KalFit.
Definition KalFitAlg.h:209
double ppi_cut_
Definition KalFitAlg.h:182
double dchi2cut_inner_
Definition KalFitAlg.h:215
int activeonly_
Definition KalFitAlg.h:187

Referenced by KalFitAlg().

◆ ~KalFitAlg()

KalFitAlg::~KalFitAlg ( void )

destructor

Definition at line 186 of file KalFitAlg.cxx.

186 {
187 MsgStream log( msgSvc(), name() );
188 log << MSG::INFO << " Start cleaning, delete Mdc geometry objects" << endmsg;
189 clean();
190 log << MSG::INFO << "End cleaning " << endmsg;
191}
IMessageSvc * msgSvc()
void clean(void)

Member Function Documentation

◆ beginRun()

StatusCode KalFitAlg::beginRun ( )

Definition at line 329 of file KalFitAlg.cxx.

329 {
330 MsgStream log( msgSvc(), name() );
331 log << MSG::INFO << "in beginRun()" << endmsg;
332 log << MSG::INFO << "Present Parameters: muls: " << muls_ << " loss: "
333 << " activeonly " << activeonly_ << endmsg;
334
335 // initialize the MdcGeomSvc
337 // Wires, Layers and SuperLayers of Mdc :
338 set_Mdc();
339
340 IBesMagFieldSvc* IMFSvc;
341 StatusCode sc = service( "MagneticFieldSvc", IMFSvc );
342 if ( sc != StatusCode::SUCCESS )
343 { log << MSG::ERROR << "Unable to open Magnetic field service" << endmsg; }
344
345 // Nominal magnetic field :
347 {
348 KalFitTrack::Bznom_ = ( IMFSvc->getReferField() ) * 10000; // unit is KGauss
350
351 if ( 4 == debug_ )
352 {
353 std::cout << " beginRun, referField from MagneticFieldSvc:"
354 << ( IMFSvc->getReferField() ) * 10000 << std::endl;
355 std::cout << " magnetic field: " << KalFitTrack::Bznom_ << std::endl;
356 }
357 }
358
359 return StatusCode::SUCCESS;
360}
virtual double getReferField()=0
void setGeomSvc_init(void)
void set_Mdc(void)
Set up the wires, layers and superlayers...

Referenced by execute().

◆ clean()

void KalFitAlg::clean ( void )

delete C++ objects, necessary to clean before begin_run or inside destructor

Definition at line 193 of file KalFitAlg.cxx.

193 {
194 // delete all Mdc objects :
195 _BesKalmanFitWalls.clear();
196 _BesKalmanFitMaterials.clear();
197 if ( _wire ) free( _wire );
198 if ( _layer ) free( _layer );
199 if ( _superLayer ) free( _superLayer );
200}

Referenced by initialize(), and ~KalFitAlg().

◆ clearTables()

void KalFitAlg::clearTables ( )

Definition at line 6059 of file KalFitAlg.cxx.

6059 {
6060
6061 if ( debug_ == 4 ) cout << "Begining to clear Tables ...." << endl;
6062 vector<MdcRec_trk>* mdcMgr = MdcRecTrkCol::getMdcRecTrkCol();
6063 vector<MdcRec_trk_add>* mdc_addMgr = MdcRecTrkAddCol::getMdcRecTrkAddCol();
6064 vector<MdcRec_wirhit>* whMgr = MdcRecWirhitCol::getMdcRecWirhitCol();
6065 vector<MdcRec_trk>::iterator tit = mdcMgr->begin();
6066 for ( ; tit != mdcMgr->end(); tit++ )
6067 {
6068 vector<MdcRec_wirhit*>::iterator vit = tit->hitcol.begin();
6069 for ( ; vit != tit->hitcol.end(); vit++ ) { delete ( *vit ); }
6070 }
6071
6072 mdcMgr->clear();
6073 mdc_addMgr->clear();
6074 whMgr->clear();
6075
6076 // delete mdcMgr;
6077 // delete mdc_addMgr;
6078 // delete whMgr;
6079 // mdcMgr = 0;
6080 // mdc_addMgr = 0;
6081 // whMgr = 0;
6082}
static vector< MdcRec_trk_add > * getMdcRecTrkAddCol(void)
static vector< MdcRec_trk > * getMdcRecTrkCol(void)
static vector< MdcRec_wirhit > * getMdcRecWirhitCol(void)

Referenced by execute().

◆ complete_track() [1/2]

void KalFitAlg::complete_track ( MdcRec_trk & TrasanTRK,
MdcRec_trk_add & TrasanTRK_add,
KalFitTrack & track_lead,
RecMdcKalTrack * kaltrk,
RecMdcKalTrackCol * kalcol,
RecMdcKalHelixSegCol * segcol )

fill tds with results got at (0,0,0)

Definition at line 5642 of file KalFitAlg.cxx.

5644 {
5645 static int nmass = KalFitTrack::nmass();
5646 int way( 1 );
5647 MsgStream log( msgSvc(), name() );
5648 KalFitTrack track_first( track_lead );
5649 KalFitTrack track_ip( track_lead );
5650
5651 if ( debug_ == 4 )
5652 {
5653 cout << "track_first pivot " << track_first.pivot() << " helix " << track_first.a()
5654 << endl;
5655 }
5656 if ( usage_ == 1 ) innerwall( track_ip, lead_, way );
5657 // Fill Tds
5658 fillTds_ip( TrasanTRK, track_ip, kaltrk, lead_ );
5659
5660 if ( debug_ == 4 )
5661 {
5662 cout << "after inner wall, track_ip pivot " << track_first.pivot() << " helix "
5663 << track_first.a() << endl;
5664 }
5665
5666 fillTds_lead( TrasanTRK, track_first, kaltrk, lead_ );
5667
5668 // Refit for different mass assumptions :
5669 double pp = track_lead.momentum().mag();
5670
5671 // w if (!KalFitDSSD::cosmic_)
5672 if ( !( i_front_ < 0 ) )
5673 {
5674
5675 for ( int l_mass = 0, flg = 1; l_mass < nmass; l_mass++, flg <<= 1 )
5676 {
5677
5678 if ( !( mhyp_ & flg ) ) continue;
5679 if ( l_mass == lead_ ) continue;
5680
5681 // Check the mom. to decide of the refit with this mass assumption
5682 if ( ( lead_ != 0 && l_mass == 0 && pp > pe_cut_ ) ||
5683 ( lead_ != 1 && l_mass == 1 && pp > pmu_cut_ ) ||
5684 ( lead_ != 2 && l_mass == 2 && pp > ppi_cut_ ) ||
5685 ( lead_ != 3 && l_mass == 3 && pp > pk_cut_ ) ||
5686 ( lead_ != 4 && l_mass == 4 && pp > pp_cut_ ) )
5687 continue;
5688
5689 if ( debug_ == 4 ) { cout << "complete_track..REFIT ASSUMPION " << l_mass << endl; }
5690
5691 // Initialisation :
5692 double chiSq = 0;
5693 int nhits = 0;
5694
5695 // Initialisation : (x, a, ea)
5696 HepPoint3D x_trasan( TrasanTRK.pivot[0], TrasanTRK.pivot[1], TrasanTRK.pivot[2] );
5697
5698 HepVector a_trasan( 5 );
5699 for ( int i = 0; i < 5; i++ ) { a_trasan[i] = TrasanTRK.helix[i]; }
5700
5701 HepSymMatrix ea_trasan( 5 );
5702 for ( int i = 0, k = 0; i < 5; i++ )
5703 {
5704 for ( int j = 0; j <= i; j++ )
5705 {
5706 ea_trasan[i][j] = matrixg_ * TrasanTRK.error[k++];
5707 ea_trasan[j][i] = ea_trasan[i][j];
5708 }
5709 }
5710
5711 KalFitTrack track( x_trasan, a_trasan, ea_trasan, l_mass, chiSq, nhits );
5712 track.HitsMdc( track_lead.HitsMdc() );
5713
5714 double fiTerm = TrasanTRK.fiTerm;
5715 track.pivot( track.x( fiTerm ) );
5716
5717 HepSymMatrix Eakal( 5, 0 );
5718
5719 double costheta =
5720 track_lead.a()[4] / sqrt( 1.0 + track_lead.a()[4] * track_lead.a()[4] );
5721 if ( ( 1.0 / fabs( track_lead.a()[2] ) < pt_cut_ ) && ( fabs( costheta ) > theta_cut_ ) )
5722 { choice_ = 6; }
5723
5724 init_matrix( choice_, TrasanTRK, Eakal );
5725
5726 filter_fwd_calib( track, l_mass, way, Eakal );
5727
5728 KalFitTrack track_z( track );
5729 /// fill tds with results got at (0,0,0)
5730 innerwall( track_z, l_mass, way );
5731 fillTds_ip( TrasanTRK, track_z, kaltrk, l_mass );
5732 // Fill tds
5733 fillTds( TrasanTRK, track, kaltrk, l_mass );
5734 }
5735 } // end of if (!(i_front<0))
5736
5737 // Refit with an enhancement of the error matrix at Mdc level :
5738
5739 if ( enhance_ )
5740 {
5741 HepPoint3D x_first( 0, 0, 0 );
5742 HepVector a_first( kaltrk->getFHelix() );
5743 HepSymMatrix ea_first( kaltrk->getFError() );
5744 HepVector fac( 5 );
5745 fac[0] = fac_h1_;
5746 fac[1] = fac_h2_;
5747 fac[2] = fac_h3_;
5748 fac[3] = fac_h4_;
5749 fac[4] = fac_h5_;
5750
5751 for ( int i = 0; i < 5; i++ )
5752 for ( int j = 0; j <= i; j++ ) ea_first[i][j] = fac[i] * fac[j] * ea_first[i][j];
5753 KalFitTrack track( x_first, a_first, ea_first, 2, 0, 0 );
5754 }
5755
5756 // Backward filter
5757 // Attention, the initial error matrix of track_back is the error matrix
5758 // that after filter_fwd_calib(...) course of track_lead. So one thing need
5759 // more consideration that how to chose the inital error matrix of this smoother,
5760 // to put it by hand or use the error matrix after filter_fwd_calib. I think
5761 // it should be to refer R.G.Brown's book.
5762
5763 KalFitTrack track_back( track_lead );
5764
5765 // track_back(track);
5766
5767 if ( debug_ == 4 )
5768 {
5769 cout << " Backward fitting flag:" << back_ << endl;
5770 cout << "track_back pivot " << track_back.pivot() << " track_lead kappa "
5771 << track_lead.a()[2] << endl;
5772 }
5773
5774 if ( back_ && track_lead.a()[2] != 0 && 1 / fabs( track_lead.a()[2] ) > pT_ )
5775 {
5776 track_back.HitsMdc( track_lead.HitsMdc() );
5777
5779 {
5780
5781 double p_kaon( 0 ), p_proton( 0 );
5782
5783 if ( !( kaltrk->getStat( 0, 3 ) ) )
5784 {
5785 p_kaon = 1 / fabs( kaltrk->getZHelixK()[2] ) *
5786 sqrt( 1 + kaltrk->getZHelixK()[4] * kaltrk->getZHelixK()[4] );
5787 track_back.p_kaon( p_kaon );
5788 }
5789 else
5790 {
5791 p_kaon =
5792 1 / fabs( track_back.a()[2] ) * sqrt( 1 + track_back.a()[4] * track_back.a()[4] );
5793 track_back.p_kaon( p_kaon );
5794 }
5795 if ( !( kaltrk->getStat( 0, 4 ) ) )
5796 {
5797 p_proton = 1 / fabs( kaltrk->getZHelixP()[2] ) *
5798 sqrt( 1 + kaltrk->getZHelixP()[4] * kaltrk->getZHelixP()[4] );
5799 track_back.p_proton( p_proton );
5800 }
5801 else
5802 {
5803 p_proton =
5804 1 / fabs( track_back.a()[2] ) * sqrt( 1 + track_back.a()[4] * track_back.a()[4] );
5805 track_back.p_proton( p_proton );
5806 }
5807 }
5808
5809 if ( !( i_back_ < 0 ) )
5810 {
5811 for ( int l_mass = 0; l_mass < nmass; l_mass++ )
5812 {
5813 KalFitTrack track_seed( track_back );
5814 track_seed.chgmass( l_mass );
5815 smoother_calib( track_seed, -way );
5816 // fill TDS for backward filter :
5817 fillTds_back( track_seed, kaltrk, TrasanTRK, l_mass, segcol );
5818 }
5819 }
5820 else
5821 {
5822
5823 smoother_calib( track_back, -way );
5824 // fill TDS for backward filter , for leading particle hypothesis :
5825 fillTds_back( track_back, kaltrk, TrasanTRK, lead_, segcol );
5826 // fillTds_helixsegs(track_back,TrasanTRK);
5827 }
5828 }
5829
5830 /*
5831 // Take care of the pointers (use lead. hyp results by default)
5832 for(int pid = 0; pid < nmass;
5833 pid++) {
5834 if (pid == lead_) continue;
5835 if (kaltrk->getStat(1,pid))
5836 sameas(kaltrk, pid, lead_);
5837 }
5838 */
5839
5840 // check: before register into TDS
5841
5842 log << MSG::DEBUG << "registered MDC Kalmantrack:"
5843 << "Track Id: " << kaltrk->getTrackId() << " Mass of the fit: " << kaltrk->getMass( 2 )
5844 << endmsg << "Length of the track: " << kaltrk->getLength( 2 )
5845 << " Tof of the track: " << kaltrk->getTof( 2 ) << endmsg
5846 << "Chisq of the fit: " << kaltrk->getChisq( 0, 2 ) << " " << kaltrk->getChisq( 1, 2 )
5847 << endmsg << "Ndf of the fit: " << kaltrk->getNdf( 0, 2 ) << " "
5848 << kaltrk->getNdf( 1, 2 ) << endmsg << "Helix " << kaltrk->getZHelix()[2] << endmsg;
5849
5850 kalcol->push_back( kaltrk );
5851 track_lead.HitsMdc().clear();
5852 track_back.HelixSegs().clear();
5853 // ??ATTENTION!! should track_back.HelixSegs() be cleared ??
5854}
HepGeom::Point3D< double > HepPoint3D
Definition KalFitAlg.h:50
void filter_fwd_calib(KalFitTrack &trk, int l_mass, int way, HepSymMatrix &Eakal)
void fillTds_lead(MdcRec_trk &TrasanTRK, KalFitTrack &track, RecMdcKalTrack *trk, int l_mass)
void fillTds_ip(MdcRec_trk &TrasanTRK, KalFitTrack &track, RecMdcKalTrack *trk, int l_mass)
with results got at (0,0,0)
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.
void smoother_calib(KalFitTrack &trk, int way)
void init_matrix(MdcRec_trk &trk, HepSymMatrix &Ea)
void fillTds_back(KalFitTrack &track, RecMdcKalTrack *trk, MdcRec_trk &TrasanTRK, int l_mass)
with results got at the outer Mdc hit
static int nmass(void)
void HitsMdc(vector< KalFitHitMdc > &lh)
Hep3Vector momentum(double dPhi=0.) const
returns momentum vector after rotating angle dPhi in phi direction.
const HepVector & a(void) const
returns helix parameters.

◆ complete_track() [2/2]

void KalFitAlg::complete_track ( MdcRec_trk & TrasanTRK,
MdcRec_trk_add & TrasanTRK_add,
KalFitTrack & track_lead,
RecMdcKalTrack * kaltrk,
RecMdcKalTrackCol * kalcol,
RecMdcKalHelixSegCol * segcol,
int flagsmooth )

fill tds with results got at (0,0,0)

Definition at line 5452 of file KalFitAlg.cxx.

5455 {
5456 static int nmass = KalFitTrack::nmass();
5457 int way( 1 );
5458 MsgStream log( msgSvc(), name() );
5459 KalFitTrack track_first( track_lead );
5460 KalFitTrack track_ip( track_lead );
5461 innerwall( track_ip, lead_, way );
5462 // Fill Tds
5463 fillTds_ip( TrasanTRK, track_ip, kaltrk, lead_ );
5464 // std::cout<<"track_first nster"<<track_first.nster()<<std::endl;
5465
5466 fillTds_lead( TrasanTRK, track_first, kaltrk, lead_ );
5467 // Refit for different mass assumptions :
5468 double pp = track_lead.momentum().mag();
5469
5470 if ( !( i_front_ < 0 ) )
5471 {
5472
5473 for ( int l_mass = 0, flg = 1; l_mass < nmass; l_mass++, flg <<= 1 )
5474 {
5475
5476 if ( !( mhyp_ & flg ) ) continue;
5477 if ( l_mass == lead_ ) continue;
5478
5479 // Check the mom. to decide of the refit with this mass assumption
5480 if ( ( lead_ != 0 && l_mass == 0 && pp > pe_cut_ ) ||
5481 ( lead_ != 1 && l_mass == 1 && pp > pmu_cut_ ) ||
5482 ( lead_ != 2 && l_mass == 2 && pp > ppi_cut_ ) ||
5483 ( lead_ != 3 && l_mass == 3 && pp > pk_cut_ ) ||
5484 ( lead_ != 4 && l_mass == 4 && pp > pp_cut_ ) )
5485 continue;
5486 if ( debug_ == 4 ) cout << "complete_track..REFIT ASSUMPION " << l_mass << endl;
5487 // Initialisation :
5488 double chiSq = 0;
5489 int nhits = 0;
5490
5491 // Initialisation : (x, a, ea)
5492 HepPoint3D x_trasan( TrasanTRK.pivot[0], TrasanTRK.pivot[1], TrasanTRK.pivot[2] );
5493 HepVector a_trasan( 5 );
5494 for ( int i = 0; i < 5; i++ ) a_trasan[i] = TrasanTRK.helix[i];
5495
5496 HepSymMatrix ea_trasan( 5 );
5497 for ( int i = 0, k = 0; i < 5; i++ )
5498 {
5499 for ( int j = 0; j <= i; j++ )
5500 {
5501 ea_trasan[i][j] = matrixg_ * TrasanTRK.error[k++];
5502 ea_trasan[j][i] = ea_trasan[i][j];
5503 }
5504 }
5505
5506 KalFitTrack track( x_trasan, a_trasan, ea_trasan, l_mass, chiSq, nhits );
5507 track.HitsMdc( track_lead.HitsMdc() );
5508 double fiTerm = TrasanTRK.fiTerm;
5509 track.pivot( track.x( fiTerm ) );
5510 HepSymMatrix Eakal( 5, 0 );
5511
5512 double costheta = track.a()[4] / sqrt( 1.0 + track.a()[4] * track.a()[4] );
5513 if ( ( 1.0 / fabs( track.a()[2] ) < pt_cut_ ) && ( fabs( costheta ) > theta_cut_ ) )
5514 { choice_ = 6; }
5515
5516 init_matrix( choice_, TrasanTRK, Eakal );
5517 filter_fwd_anal( track, l_mass, way, Eakal );
5518 KalFitTrack track_z( track );
5519 /// fill tds with results got at (0,0,0)
5520 innerwall( track_z, l_mass, way );
5521 fillTds_ip( TrasanTRK, track_z, kaltrk, l_mass );
5522 // Fill tds
5523 fillTds( TrasanTRK, track, kaltrk, l_mass );
5524 }
5525 } // end of //end of if (!(i_front<0))
5526
5527 // Refit with an enhancement of the error matrix at Mdc level :
5528 if ( enhance_ )
5529 {
5530
5531 HepPoint3D x_first( 0, 0, 0 );
5532 HepVector a_first( kaltrk->getFHelix() );
5533 HepSymMatrix ea_first( kaltrk->getFError() );
5534 HepVector fac( 5 );
5535 fac[0] = fac_h1_;
5536 fac[1] = fac_h2_;
5537 fac[2] = fac_h3_;
5538 fac[3] = fac_h4_;
5539 fac[4] = fac_h5_;
5540 for ( int i = 0; i < 5; i++ )
5541 for ( int j = 0; j <= i; j++ ) ea_first[i][j] = fac[i] * fac[j] * ea_first[i][j];
5542 KalFitTrack track( x_first, a_first, ea_first, 2, 0, 0 );
5543 }
5544
5545 // Backward filter :
5546 KalFitTrack track_back( track_lead );
5547 if ( debug_ == 4 )
5548 {
5549 cout << " Backward fitting flag:" << back_ << endl;
5550 cout << "track_back pivot " << track_back.pivot() << " track_lead kappa "
5551 << track_lead.a()[2] << endl;
5552 }
5553
5554 if ( back_ && track_lead.a()[2] != 0 && 1 / fabs( track_lead.a()[2] ) > pT_ )
5555 {
5556 track_back.HitsMdc( track_lead.HitsMdc() );
5557
5559 {
5560 double p_kaon( 0 ), p_proton( 0 );
5561 if ( !( kaltrk->getStat( 0, 3 ) ) )
5562 {
5563 p_kaon = 1 / fabs( kaltrk->getZHelixK()[2] ) *
5564 sqrt( 1 + kaltrk->getZHelixK()[4] * kaltrk->getZHelixK()[4] );
5565 track_back.p_kaon( p_kaon );
5566 }
5567 else
5568 {
5569 p_kaon =
5570 1 / fabs( track_back.a()[2] ) * sqrt( 1 + track_back.a()[4] * track_back.a()[4] );
5571 track_back.p_kaon( p_kaon );
5572 }
5573 if ( !( kaltrk->getStat( 0, 4 ) ) )
5574 {
5575 p_proton = 1 / fabs( kaltrk->getZHelixP()[2] ) *
5576 sqrt( 1 + kaltrk->getZHelixP()[4] * kaltrk->getZHelixP()[4] );
5577 track_back.p_proton( p_proton );
5578 }
5579 else
5580 {
5581 p_proton =
5582 1 / fabs( track_back.a()[2] ) * sqrt( 1 + track_back.a()[4] * track_back.a()[4] );
5583 track_back.p_proton( p_proton );
5584 }
5585 }
5586
5587 if ( !( i_back_ < 0 ) )
5588 {
5589 // cout<<" *** in smoothing process ***"<<endl;
5590 for ( int l_mass = 0; l_mass < nmass; l_mass++ )
5591 {
5592 // cout<<" --- in hypothesis "<<l_mass<<" :"<<endl;
5593 KalFitTrack track_seed( track_back );
5594 track_seed.chgmass( l_mass );
5595 /*cout<<"---------------"<<endl;//wangll
5596 cout<<"smooth track "<<l_mass<<endl;//wangll
5597 cout<<" pivot :"<<track_seed.pivot()<<endl;//wangll
5598 cout<<" helix :"<<track_seed.a()<<endl;//wangll
5599 */
5600 smoother_anal( track_seed, -way );
5601 // if( usage_ == 1) smoother_calib(track_seed, -way);
5602 // cout<<"fillTds_back 1"<<endl;
5603 // fill TDS for backward filter :
5604 fillTds_back( track_seed, kaltrk, TrasanTRK, l_mass, segcol, 1 );
5605 // cout<<"nHits: "<<kaltrk->getVecHelixSegs().size()<<endl;
5606 }
5607 }
5608 else
5609 {
5610 smoother_anal( track_back, -way );
5611 // smoother_calib(track_back, -way);
5612 // smoother(track_back, -way);
5613 // fill TDS for backward filter :
5614 // cout<<"fillTds_back 2"<<endl;
5615 fillTds_back( track_back, kaltrk, TrasanTRK, lead_, segcol, 1 );
5616 }
5617 }
5618 /*
5619 // Take care of the pointers (use lead. hyp results by default)
5620 for(int pid = 0; pid < nmass;
5621 pid++) {
5622 if (pid == lead_) continue;
5623 if (kaltrk->getStat(1,pid))
5624 sameas(kaltrk, pid, lead_);
5625 }
5626 */
5627
5628 // check: before register into TDS
5629
5630 log << MSG::DEBUG << "registered MDC Kalmantrack:"
5631 << "Track Id: " << kaltrk->getTrackId() << " Mass of the fit: " << kaltrk->getMass( 2 )
5632 << endmsg << "Length of the track: " << kaltrk->getLength( 2 )
5633 << " Tof of the track: " << kaltrk->getTof( 2 ) << endmsg
5634 << "Chisq of the fit: " << kaltrk->getChisq( 0, 2 ) << " " << kaltrk->getChisq( 1, 2 )
5635 << endmsg << "Ndf of the fit: " << kaltrk->getNdf( 0, 2 ) << " "
5636 << kaltrk->getNdf( 1, 2 ) << endmsg << "Helix " << kaltrk->getZHelix()[2] << endmsg;
5637
5638 kalcol->push_back( kaltrk );
5639 track_lead.HitsMdc().clear();
5640}
void filter_fwd_anal(KalFitTrack &trk, int l_mass, int way, HepSymMatrix &Eakal)
Kalman filter (forward) in Mdc.
void smoother_anal(KalFitTrack &trk, int way)
Kalman filter (smoothing or backward part).

Referenced by kalman_fitting_anal(), kalman_fitting_calib(), kalman_fitting_csmalign(), and kalman_fitting_MdcxReco_Csmc_Sew().

◆ execute()

StatusCode KalFitAlg::execute ( )

event function

Definition at line 667 of file KalFitAlg.cxx.

667 {
668 if ( !m_beginRun )
669 {
670 StatusCode sc = beginRun();
671 if ( sc.isFailure() )
672 {
673 error() << "beginRun failed" << endmsg;
674 return StatusCode::FAILURE;
675 }
676 m_beginRun = true;
677 }
678
679 MsgStream log( msgSvc(), name() );
680 log << MSG::INFO << "in execute()" << endmsg;
681 // std::cout<<"begin to deal with EVENT ..."<<(++eventno)<<std::endl;
682 for ( int i = 0; i < 5; i++ ) iqual_front_[i] = 1;
683 iqual_back_ = 1;
684
685 /*
686 MdcID mdcId;
687 SmartDataPtr<RecMdcKalTrackCol> recmdckaltrkCol(eventSvc(),"/Event/Recon/RecMdcKalTrackCol");
688 SmartDataPtr<RecMdcKalHelixSegCol> recSegCol(eventSvc(),"/Event/Recon/RecMdcKalHelixSegCol");
689 if(recmdckaltrkCol) {
690 cout<<"------------------------ new event ---------------------"<<endl;
691 cout<<"recmdckaltrkCol->size()="<<recmdckaltrkCol->size()<<endl;
692 cout<<"recSegCol.size()="<<recSegCol->size()<<endl;
693 cout<<"--------------------------------------------------------"<<endl;
694 RecMdcKalTrack::setPidType(RecMdcKalTrack::electron);
695 RecMdcKalTrackCol::iterator KalTrk= recmdckaltrkCol->begin();
696 int i_trk=0;
697 for(;KalTrk !=recmdckaltrkCol->end();KalTrk++){
698 cout<<"*** track "<<i_trk++<<" ***"<<endl;
699 HelixSegRefVec gothelixsegs = (*KalTrk)->getVecHelixSegs();
700 for(int i=0;i<5;i++) cout<<"pid "<<i<<"
701 nSegs="<<((*KalTrk)->getVecHelixSegs(i)).size()<<endl; HelixSegRefVec::iterator iter_hit =
702 gothelixsegs.begin(); if(iter_hit == gothelixsegs.end())cout<<"iter_hit ==
703 gothelixsegs.end()"<<endl; int nhitofthistrk=0; for( ; iter_hit != gothelixsegs.end();
704 iter_hit++){ nhitofthistrk++;
705 //cout<<"layerId: "<<(*iter_hit)->getLayerId()<<endl;
706 //cout<<"Identifier: "<<(*iter_hit)->getMdcId()<<endl;
707 //cout<<"layerId: "<<mdcId.layer((*iter_hit)->getMdcId())<<endl;
708 //cout<<"getDT: "<<(*iter_hit)->getDT()<<endl;
709 }
710 iter_hit=gothelixsegs.begin();
711 //for(int m=0; m<nhitofthistrk/5;m++){
712 // identifier = (*iter_hit) -> getMdcId();
713 //}
714 cout<<"nhitofthistrk="<<nhitofthistrk<<endl;
715 }
716 }
717 else cout<<"did not find /Event/Recon/RecMdcKalTrackCol"<<endl;
718 */
719
720 ///
721 IBesMagFieldSvc* IMFSvc;
722 StatusCode sc = service( "MagneticFieldSvc", IMFSvc );
723 if ( sc != StatusCode::SUCCESS )
724 { log << MSG::ERROR << "Unable to open Magnetic field service" << endmsg; }
725
726 // Nominal magnetic field :
728 {
729 KalFitTrack::Bznom_ = ( IMFSvc->getReferField() ) * 10000; // unit is KGauss
731
732 if ( 4 == debug_ )
733 {
734 std::cout << " execute, referField from MagneticFieldSvc: "
735 << ( IMFSvc->getReferField() ) * 10000 << std::endl;
736 std::cout << " magnetic field: " << KalFitTrack::Bznom_ << std::endl;
737 }
738 }
739
741
742 IDataProviderSvc* evtSvc = NULL;
743 Gaudi::svcLocator()->service( "EventDataSvc", evtSvc );
744 if ( evtSvc ) { log << MSG::INFO << "makeTds:event Svc has been found" << endmsg; }
745 else
746 {
747 log << MSG::FATAL << "makeTds:Could not find eventSvc" << endmsg;
748 return StatusCode::SUCCESS;
749 }
750
751 StatusCode kalsc;
752 IDataManagerSvc* dataManSvc;
753 dataManSvc = dynamic_cast<IDataManagerSvc*>( evtSvc );
754 DataObject* aKalTrackCol;
755 evtSvc->findObject( "/Event/Recon/RecMdcKalTrackCol", aKalTrackCol );
756 if ( aKalTrackCol )
757 {
758 dataManSvc->clearSubTree( "/Event/Recon/RecMdcKalTrackCol" );
759 evtSvc->unregisterObject( "/Event/Recon/RecMdcKalTrackCol" );
760 }
761
762 kalsc = evtSvc->registerObject( "/Event/Recon/RecMdcKalTrackCol", kalcol );
763 if ( kalsc.isFailure() )
764 {
765 log << MSG::FATAL << "Could not register RecMdcKalTrack" << endmsg;
766 return StatusCode::SUCCESS;
767 }
768 log << MSG::INFO << "RecMdcKalTrackCol registered successfully!" << endmsg;
769
770 DataObject* aKalHelixSegCol;
771 evtSvc->findObject( "/Event/Recon/RecMdcKalHelixSegCol", aKalHelixSegCol );
772 if ( aKalHelixSegCol )
773 {
774 dataManSvc->clearSubTree( "/Event/Recon/RecMdcKalHelixSegCol" );
775 evtSvc->unregisterObject( "/Event/Recon/RecMdcKalHelixSegCol" );
776 }
778 kalsc = evtSvc->registerObject( "/Event/Recon/RecMdcKalHelixSegCol", helixsegcol );
779 if ( kalsc.isFailure() )
780 {
781 log << MSG::FATAL << "Could not register RecMdcKalHelixSeg" << endmsg;
782 return StatusCode::SUCCESS;
783 }
784 log << MSG::INFO << "RecMdcKalHelixSegCol register successfully!" << endmsg;
785
786 /*IMdcGeomSvc* geosvc;
787 StatusCode sc = service("MdcGeomSvc", geosvc);
788 if (sc == StatusCode::SUCCESS) {
789 } else {
790 return sc;
791 }*/
792
793 IMdcGeomSvc* const geosvc = imdcGeomSvc_;
794 if ( !geosvc )
795 { std::cout << "ERROR OCCUR when dynamic_cast in KalFitAlg::execute ...!!" << std::endl; }
796
797 SmartDataPtr<Event::EventHeader> eventHeader( eventSvc(), "/Event/EventHeader" );
798 if ( !eventHeader )
799 {
800 log << MSG::WARNING << "Could not find Event Header" << endmsg;
801 return StatusCode::FAILURE;
802 }
803 int eventNo = eventHeader->eventNumber();
804 int runNo = eventHeader->runNumber();
805 if ( runNo > 0 ) wsag_ = 4;
806 else wsag_ = 0;
807
808 double t0 = 0.;
809 SmartDataPtr<RecEsTimeCol> estimeCol( eventSvc(), "/Event/Recon/RecEsTimeCol" );
810 if ( estimeCol && estimeCol->size() )
811 {
812 RecEsTimeCol::iterator iter_evt = estimeCol->begin();
813 t0 = ( *iter_evt )->getTest();
814 // t0Stat = (*iter_evt)->getStat();
815 }
816 else
817 {
818 log << MSG::WARNING << "Could not find EvTimeCol" << endmsg;
819 return StatusCode::SUCCESS;
820 }
821
822 if ( debug_ == 4 )
823 { std::cout << "in KalFitAlg , we get the event start time = " << t0 << std::endl; }
824 KalFitTrack::setT0( t0 );
825
826 SmartDataPtr<MdcDigiCol> mdcDigiCol( evtSvc, "/Event/Digi/MdcDigiCol" );
827 if ( sc != StatusCode::SUCCESS )
828 {
829 log << MSG::FATAL << "Could not find MdcDigiCol!" << endmsg;
830 return StatusCode::SUCCESS;
831 }
832 KalFitTrack::setMdcDigiCol( mdcDigiCol );
833
834 // register RecMdcTrack and MdcRecHit collection
835
836 if ( ( ntuple_ & 16 ) && ( ntuple_ & 1 ) )
837 {
838 // McTruth infor,Retrieve MC track truth
839 // bool mcstat = true;
840 // more research needed ...
841
842 m_evtid = eventHeader->eventNumber();
843 bool mcstat = true;
844
845 SmartDataPtr<McParticleCol> mcPartCol( eventSvc(), "/Event/MC/McParticleCol" );
846 if ( !mcPartCol )
847 {
848 log << MSG::WARNING << "Could not find McParticle" << endmsg;
849 mcstat = false;
850 }
851
852 if ( mcstat )
853 {
854 McParticleCol::iterator i_mcTrk = mcPartCol->begin();
855 for ( ; i_mcTrk != mcPartCol->end(); i_mcTrk++ )
856 {
857 if ( !( *i_mcTrk )->primaryParticle() ) continue;
858 const HepLorentzVector& mom( ( *i_mcTrk )->initialFourMomentum() );
859 const HepLorentzVector& pos = ( *i_mcTrk )->initialPosition();
860 log << MSG::DEBUG << "MCINFO:particleId=" << ( *i_mcTrk )->particleProperty()
861 << " theta=" << mom.theta() << " phi=" << mom.phi() << " px=" << mom.px()
862 << " py=" << mom.py() << " pz=" << mom.pz() << endmsg;
863 double charge = 0.0;
864 int pid = ( *i_mcTrk )->particleProperty();
865 if ( pid > 0 ) { charge = m_particleTable->particle( pid )->charge(); }
866 else if ( pid < 0 )
867 {
868 charge = m_particleTable->particle( -pid )->charge();
869 charge *= -1;
870 }
871 else { log << MSG::WARNING << "wrong particle id, please check data" << endmsg; }
872 HepPoint3D pos2( pos.x(), pos.y(), pos.z() );
873 Hep3Vector mom2( mom.px(), mom.py(), mom.pz() );
874
875 Helix mchelix( pos2, mom2, charge );
876 log << MSG::DEBUG << "charge of the track " << charge << endmsg;
877 if ( debug_ == 4 ) cout << "helix: " << mchelix.a() << endl;
878 mchelix.pivot( HepPoint3D( 0, 0, 0 ) );
879 for ( int j = 0; j < 5; j++ ) { m_mchelix[j] = mchelix.a()[j]; }
880 m_mcpid = pid;
881 m_mcptot = sqrt( 1 + pow( m_mchelix[4], 2 ) ) / m_mchelix[2];
882 }
883 }
884 }
885
886 Identifier mdcid;
887
888 // retrieve RecMdcTrackCol from TDS
889 SmartDataPtr<RecMdcTrackCol> newtrkCol( eventSvc(), "/Event/Recon/RecMdcTrackCol" );
890 if ( !newtrkCol )
891 {
892 log << MSG::FATAL << "Could not find RecMdcTrackCol" << endmsg;
893 return ( StatusCode::SUCCESS );
894 }
895 log << MSG::INFO << "Begin to make MdcRecTrkCol and MdcRecWirhitCol" << endmsg;
896
897 vector<MdcRec_trk>* mtrk_mgr = MdcRecTrkCol::getMdcRecTrkCol();
898 mtrk_mgr->clear();
899 vector<MdcRec_trk_add>* mtrkadd_mgr = MdcRecTrkAddCol::getMdcRecTrkAddCol();
900 mtrkadd_mgr->clear();
901 vector<MdcRec_wirhit>* mhit_mgr = MdcRecWirhitCol::getMdcRecWirhitCol();
902 mhit_mgr->clear();
903
904 double trkx1 = 0., trkx2 = 0., trky1 = 0., trky2 = 0., trkz1 = 0., trkz2 = 0., trkthe1 = 0., trkthe2 = 0., trkphi1 = 0., trkphi2 = 0., trkp1 = 0.,
905 trkp2 = 0., trkr1 = 0., trkr2 = 0., trkkap1 = 0., trkkap2 = 0., trktanl1 = 0., trktanl2 = 0.; // add initialize 25-05-15
906 Hep3Vector csmp3[2];
907 double csmphi[2];
908 int status_temp = 0;
909 RecMdcTrackCol::iterator iter_trk = newtrkCol->begin();
910 for ( int kj = 1; iter_trk != newtrkCol->end(); iter_trk++, kj++ )
911 {
912 if ( kj < 3 )
913 {
914 csmp3[kj - 1] = ( *iter_trk )->p3();
915 csmphi[kj - 1] = ( *iter_trk )->phi();
916 }
917
918 if ( ntuple_ & 2 )
919 {
920 // check trackcol, track level
921 for ( int j = 0, ij = 0; j < 5; j++ )
922 {
923 m_trkhelix[j] = ( *iter_trk )->helix()[j];
924 if ( ntuple_ & 32 )
925 {
926 for ( int k = 0; k <= j; k++, ij++ ) { m_trkerror[ij] = ( *iter_trk )->err()[j][k]; }
927 }
928 }
929
930 m_trkptot = sqrt( 1 + pow( m_trkhelix[4], 2 ) ) / m_trkhelix[2];
931
932 if ( ntuple_ & 32 )
933 {
934 m_trksigp =
935 sqrt( pow( ( m_trkptot / m_trkhelix[2] ), 2 ) * m_trkerror[5] +
936 pow( ( m_trkhelix[4] / m_trkptot ), 2 ) * pow( ( 1 / m_trkhelix[2] ), 4 ) *
937 m_trkerror[14] -
938 2 * m_trkhelix[4] * m_trkerror[12] * pow( ( 1 / m_trkhelix[2] ), 3 ) );
939 }
940 m_trkndf = ( *iter_trk )->ndof();
941 m_trkchisq = ( *iter_trk )->chi2();
942
943 if ( debug_ == 4 ) cout << "Ea from RecMdcTrackCol..." << ( *iter_trk )->err() << endl;
944
945 StatusCode sc3 = m_nt3->write();
946 if ( sc3.isFailure() ) cout << "Ntuple3 filling failed!" << endl;
947 }
948
949 // end of track level check and prepare evt check
950 if ( ntuple_ & 4 )
951 {
952 /*
953 if(kj == 1) {
954 trkphi1 = (*iter_trk)->getFi0();
955 trkr1 = (*iter_trk)->getDr();
956 trkz1 = (*iter_trk)->getDz();
957 trkkap1 = (*iter_trk)->getCpa();
958 trktanl1 = (*iter_trk)->getTanl();
959 trkx1 = trkr1*cos(trkphi1);
960 trky1 = trkr1*sin(trkphi1);
961 trkp1 = sqrt(1+trktanl1*trktanl1)/trkkap1;
962 trkthe1 = M_PI/2-atan(trktanl1);
963 } else if(kj == 2) {
964 trkphi2 = (*iter_trk)->getFi0();
965 trkr2 = (*iter_trk)->getDr();
966 trkz2 = (*iter_trk)->getDz();
967 trkkap2 = (*iter_trk)->getCpa();
968 trktanl2 = (*iter_trk)->getTanl();
969 trkx2 = trkr2*cos(trkphi2);
970 trky2 = trkr2*sin(trkphi2);
971 trkp2 = sqrt(1+trktanl2*trktanl2)/trkkap1;
972 trkthe2 = M_PI/2-atan(trktanl2);
973 }
974 */
975 }
976 // end prepare
977
978 log << MSG::DEBUG << "retrieved MDC tracks:"
979 << " Nhits " << ( *iter_trk )->getNhits() << " Nster " << ( *iter_trk )->nster()
980 << endmsg;
981 // so ,use this to get the hits vector belong to this track ...
982 HitRefVec gothits = ( *iter_trk )->getVecHits();
983
984 MdcRec_trk* rectrk = new MdcRec_trk;
985
986 rectrk->id = ( *iter_trk )->trackId();
987 rectrk->chiSq = ( *iter_trk )->chi2();
988 rectrk->ndf = ( *iter_trk )->ndof();
989 rectrk->fiTerm = ( *iter_trk )->getFiTerm();
990 rectrk->nhits = ( *iter_trk )->getNhits();
991 rectrk->nster = ( *iter_trk )->nster();
992 rectrk->nclus = 0;
993 rectrk->stat = ( *iter_trk )->stat();
994 status_temp = ( *iter_trk )->stat();
995 MdcRec_trk_add* trkadd = new MdcRec_trk_add;
996 trkadd->id = ( *iter_trk )->trackId();
997 trkadd->quality = 0;
998 trkadd->kind = 1;
999 trkadd->decision = 0;
1000 trkadd->body = rectrk;
1001 rectrk->add = trkadd;
1002
1003 for ( int i = 0; i < 5; i++ )
1004 {
1005 rectrk->helix[i] = ( *iter_trk )->helix()[i];
1006 if ( i < 3 ) rectrk->pivot[i] = ( *iter_trk )->getPivot()[i];
1007 for ( int j = 1; j < i + 2; j++ )
1008 { rectrk->error[i * ( i + 1 ) / 2 + j - 1] = ( *iter_trk )->err()( i + 1, j ); }
1009 }
1010
1011 std::sort( gothits.begin(), gothits.end(), order_rechits );
1012
1013 HitRefVec::iterator it_gothit = gothits.begin();
1014 for ( ; it_gothit != gothits.end(); it_gothit++ )
1015 {
1016
1017 if ( ( *it_gothit )->getStat() != 1 )
1018 {
1019 if ( activeonly_ )
1020 {
1021 log << MSG::WARNING << "this hit is not used in helix fitting!" << endmsg;
1022 continue;
1023 }
1024 }
1025
1026 log << MSG::DEBUG << "retrieved hits in MDC tracks:"
1027 << " hits DDL " << ( *it_gothit )->getDriftDistLeft() << " hits DDR "
1028 << ( *it_gothit )->getDriftDistRight() << " error DDL "
1029 << ( *it_gothit )->getErrDriftDistLeft() << " error DDR "
1030 << ( *it_gothit )->getErrDriftDistRight() << " id of hit "
1031 << ( *it_gothit )->getId() << " track id of hit " << ( *it_gothit )->getTrkId()
1032 << " hits ADC " << ( *it_gothit )->getAdc() << endmsg;
1033
1034 MdcRec_wirhit* whit = new MdcRec_wirhit;
1035 whit->id = ( *it_gothit )->getId();
1036 whit->ddl = ( *it_gothit )->getDriftDistLeft();
1037 whit->ddr = ( *it_gothit )->getDriftDistRight();
1038 whit->erddl = ( *it_gothit )->getErrDriftDistLeft();
1039 whit->erddr = ( *it_gothit )->getErrDriftDistRight();
1040 whit->pChiSq = ( *it_gothit )->getChisqAdd();
1041 whit->lr = ( *it_gothit )->getFlagLR();
1042 whit->stat = ( *it_gothit )->getStat();
1043 mdcid = ( *it_gothit )->getMdcId();
1044 int layid = MdcID::layer( mdcid );
1045 int localwid = MdcID::wire( mdcid );
1046 int w0id = geosvc->Layer( layid )->Wirst();
1047 int wid = w0id + localwid;
1048 log << MSG::INFO << "lr from PR: " << whit->lr << " layerId = " << layid
1049 << " wireId = " << localwid << endmsg;
1050
1051 const MdcGeoWire* const wirgeo = geosvc->Wire( wid );
1052
1053 // std::cout<<"the track id of *it_gothit... "<<(*it_gothit)->getTrackId()<<std::endl;
1054 whit->rechitptr = *it_gothit;
1055 whit->geo = wirgeo;
1056 whit->dat = 0;
1057 whit->trk = rectrk;
1058 whit->tdc = ( *it_gothit )->getTdc();
1059 whit->adc = ( *it_gothit )->getAdc();
1060 rectrk->hitcol.push_back( whit );
1061 mhit_mgr->push_back( *whit );
1062 }
1063 mtrk_mgr->push_back( *rectrk );
1064 mtrkadd_mgr->push_back( *trkadd );
1065
1066 delete rectrk;
1067 delete trkadd;
1068 }
1069
1070 // check trkcol: evt level
1071 if ( ntuple_ & 4 )
1072 {
1073 m_trkdelx = trkx1 - trkx2;
1074 m_trkdely = trky1 - trky2;
1075 m_trkdelz = trkz1 - trkz2;
1076 m_trkdelthe = trkthe1 + trkthe2;
1077 m_trkdelphi = trkphi1 - trkphi2;
1078 m_trkdelp = trkp1 - trkp2;
1079 StatusCode sc4 = m_nt4->write();
1080 if ( sc4.isFailure() ) cout << "Ntuple4 filling failed!" << endl;
1081 }
1082
1083 if ( debug_ == 4 )
1084 {
1085 std::cout << "before refit,ntrk,nhits,nadd..." << mtrk_mgr->size() << "********"
1086 << mhit_mgr->size() << "****" << mtrkadd_mgr->size() << endl;
1087 }
1088 // Actual fitter procedure :
1089
1090 if ( usage_ == 0 ) kalman_fitting_anal();
1091 if ( usage_ == 1 ) kalman_fitting_calib();
1092 double mdang = 180.0 - csmp3[0].angle( csmp3[1].unit() ) * 180.0 / M_PI;
1093 double mdphi = 180.0 - fabs( csmphi[0] - csmphi[1] ) * 180.0 / M_PI;
1094 // std::cout<<"before refit,ntrk,nhits,nadd..."<<mtrk_mgr->size()<<" , "<<mhit_mgr->size()<<"
1095 // ,
1096 // "<<mtrkadd_mgr->size()<<endl;
1097 if ( usage_ == 2 && ( mtrk_mgr->size() ) == 2 && fabs( mdang ) < m_dangcut &&
1098 fabs( mdphi ) < m_dphicut )
1100 if ( usage_ == 3 && ( mtrk_mgr->size() ) == 1 && status_temp == -1 )
1102
1103 log << MSG::DEBUG << "after kalman_fitting(),but in execute...." << endmsg;
1104 clearTables();
1105
1106 ///*
1107 // --- test for songxy
1108 MdcID mdcId;
1109 SmartDataPtr<RecMdcKalTrackCol> recmdckaltrkCol( eventSvc(),
1110 "/Event/Recon/RecMdcKalTrackCol" );
1111 // cout<<"------------------------ new event ---------------------"<<endl;
1112 // cout<<"recmdckaltrkCol->size()="<<recmdckaltrkCol->size()<<endl;
1113 // cout<<"--------------------------------------------------------"<<endl;
1115 RecMdcKalTrackCol::iterator KalTrk = recmdckaltrkCol->begin();
1116 int i_trk = 0;
1117 for ( ; KalTrk != recmdckaltrkCol->end(); KalTrk++ )
1118 {
1119 // cout<<"*** track "<<i_trk++<<" ***"<<endl;
1120 for ( int hypo = 0; hypo < 5; hypo++ )
1121 {
1122 if ( ( *KalTrk )->getStat( 0, hypo ) == 1 ) nFailedTrks[hypo]++;
1123 }
1124 HelixSegRefVec gothelixsegs = ( *KalTrk )->getVecHelixSegs();
1125 HelixSegRefVec::iterator iter_hit = gothelixsegs.begin();
1126 // if(iter_hit == gothelixsegs.end())cout<<"iter_hit == gothelixsegs.end()"<<endl;
1127 int nhitofthistrk = 0;
1128 for ( ; iter_hit != gothelixsegs.end(); iter_hit++ )
1129 {
1130 nhitofthistrk++;
1131 // cout<<"layerId: "<<(*iter_hit)->getLayerId()<<endl;
1132 // cout<<"Identifier: "<<(*iter_hit)->getMdcId()<<endl;
1133 // cout<<"layerId: "<<mdcId.layer((*iter_hit)->getMdcId())<<endl;
1134 // cout<<"getDT: "<<(*iter_hit)->getDT()<<endl;
1135 }
1136 iter_hit = gothelixsegs.begin();
1137 // for(int m=0; m<nhitofthistrk/5;m++){
1138 // identifier = (*iter_hit) -> getMdcId();
1139 // }
1140 }
1141 // */
1142
1143 // --- test for getStat(2, pid)
1144 /*
1145 SmartDataPtr<RecMdcKalTrackCol>
1146 recmdckaltrkCol(eventSvc(),"/Event/Recon/RecMdcKalTrackCol"); SmartDataPtr<RecMdcTrackCol>
1147 mdcTrkCol(eventSvc(),"/Event/Recon/RecMdcTrackCol");
1148 //RecMdcKalTrack::setPidType(RecMdcKalTrack::electron);
1149 RecMdcKalTrackCol::iterator KalTrk= recmdckaltrkCol->begin();
1150 int i_trk=0;
1151 for(RecMdcTrackCol::iterator mdcTrk = mdcTrkCol->begin(); KalTrk !=recmdckaltrkCol->end();
1152 KalTrk++, mdcTrk++){ cout<<"*** track "<<i_trk++<<" ***"<<endl; cout<<"trackId mdc:
1153 "<<(*mdcTrk)->trackId()<<endl; cout<<"trackId kal: "<<(*KalTrk)->trackId()<<endl; bool
1154 KalIsValid = true; for(int i_pid=0; i_pid<5; i_pid++) { cout<<"pid "<<i_pid<<" state 0 :
1155 "<<(*KalTrk)->getStat(0, i_pid)<<endl; cout<<"pid "<<i_pid<<" state 1 :
1156 "<<(*KalTrk)->getStat(1, i_pid)<<endl; if((*KalTrk)->getStat(0, i_pid)==1) { KalIsValid =
1157 false; switch(i_pid) { case 0: RecMdcKalTrack::setPidType(RecMdcKalTrack::electron); break;
1158 case 1: RecMdcKalTrack::setPidType(RecMdcKalTrack::muon);
1159 break;
1160 case 2: RecMdcKalTrack::setPidType(RecMdcKalTrack::pion);
1161 break;
1162 case 3: RecMdcKalTrack::setPidType(RecMdcKalTrack::kaon);
1163 break;
1164 case 4: RecMdcKalTrack::setPidType(RecMdcKalTrack::proton);
1165 break;
1166 }
1167 cout<<"Helix Kal: "<<(*KalTrk)->helix()<<endl;
1168 cout<<"Helix Kal err: "<<(*KalTrk)->err()<<endl;
1169 }
1170 }
1171 if(!KalIsValid) {
1172 cout<<"Helix Mdc: "<<(*mdcTrk)->helix()<<endl;
1173 cout<<"Helix Mdc err: "<<(*mdcTrk)->err()<<endl;
1174 }
1175 }
1176 */
1177
1178 return StatusCode::SUCCESS;
1179}
int runNo
Definition DQA_TO_DB.cxx:13
*******INTEGER m_nBinMax INTEGER m_NdiMax !No of bins in histogram for cell exploration division $ !Last vertex $ !Last active cell $ !Last cell in buffer $ !No of sampling when dividing cell $ !No of function total $ !Flag for random ceel for $ !Flag for type of for WtMax $ !Flag which decides whether vertices are included in the sampling $ entire domain is hyp !Maximum effective eevents per saves r n generator level $ !Flag for chat level in !Latex Output unit
Definition FoamA.h:90
ObjectVector< RecMdcKalHelixSeg > RecMdcKalHelixSegCol
SmartRefVector< RecMdcKalHelixSeg > HelixSegRefVec
#define M_PI
Definition TConstant.h:4
virtual const MdcGeoLayer *const Layer(unsigned id)=0
virtual const MdcGeoWire *const Wire(unsigned id)=0
StatusCode beginRun()
int iqual_front_[5]
Definition KalFitAlg.h:222
void kalman_fitting_MdcxReco_Csmc_Sew(void)
void kalman_fitting_calib(void)
void kalman_fitting_anal(void)
int eventNo
Definition KalFitAlg.h:226
void kalman_fitting_csmalign(void)
void clearTables()
static void setMdcDigiCol(MdcDigiCol *digicol)
static void setT0(double t0)
static int layer(const Identifier &id)
Values of different levels (failure returns 0).
Definition MdcID.cxx:47
static int wire(const Identifier &id)
Definition MdcID.cxx:52

◆ extToAnyPoint()

void KalFitAlg::extToAnyPoint ( KalFitTrack & trk,
const HepPoint3D & point )

◆ fillTds()

void KalFitAlg::fillTds ( MdcRec_trk & TrasanTRK,
KalFitTrack & track,
RecMdcKalTrack * trk,
int l_mass )

with results got at the inner Mdc hit

Definition at line 1182 of file KalFitAlg.cxx.

1183 {
1184
1185 HepPoint3D IP( 0, 0, 0 );
1186 track.pivot( IP );
1187 // Fit quality
1188 int iqual( 1 );
1189 int trasster = TrasanTRK.nster, trakster = track.nster(),
1190 trasax( TrasanTRK.nhits - trasster ), trakax( track.nchits() - trakster );
1191 if ( TrasanTRK.nhits - track.nchits() > fitnocut_ || TrasanTRK.helix[2] * track.a()[2] < 0 )
1192 iqual = 0;
1193
1194 if ( debug_ == 4 )
1195 {
1196 cout << "trasster trakster trasax trakax TrasK trackK iqual" << endl
1197 << trasster << " " << trakster << " " << trasax << " " << trakax
1198 << " " << TrasanTRK.helix[2] << " " << track.a()[2] << " " << iqual << endl;
1199 cout << "FillTds> track.chiSq..." << track.chiSq() << " nchits " << track.nchits()
1200 << " nster " << track.nster() << " iqual " << iqual << " track.Ea " << track.Ea()
1201 << endl;
1202
1203 cout << "fillTds>.....track.Ea[2][2] " << track.Ea()[2][2] << endl;
1204 cout << " TRASAN stereo = " << trasster << " and KalFitTrack = " << trakster << std::endl;
1205 cout << " TRASAN axial = " << trasax << " and KalFitTrack = " << trakax << std::endl;
1206
1207 if ( !iqual )
1208 {
1209 cout << "...there is a problem during fit !! " << std::endl;
1210 if ( trasster - trakster > 5 )
1211 cout << " because stereo " << trasster - trakster << std::endl;
1212 if ( trasax - trakax > 5 ) cout << " because axial " << std::endl;
1213 if ( TrasanTRK.helix[2] * track.a()[2] < 0 ) cout << " because kappa sign " << std::endl;
1214 }
1215 }
1216 // Protection : if any problem, we keep the original information !!!!
1217 if ( track.nchits() > 5 && track.nster() > 1 && track.nchits() - track.nster() > 2 &&
1218 track.chiSq() > 0 && track.Ea()[0][0] > 0 && track.Ea()[1][1] > 0 &&
1219 track.Ea()[2][2] > 0 && track.Ea()[3][3] > 0 && track.Ea()[4][4] > 0 && iqual )
1220 {
1221 if ( debug_ == 4 ) cout << "fillTds>.....going on " << endl;
1222 trk->setStat( 0, 0, l_mass );
1223 trk->setMass( track.mass(), l_mass );
1224
1225 // chisq & ndf
1226 trk->setChisq( track.chiSq(), 0, l_mass );
1227 trk->setNdf( track.nchits() - 5, 0, l_mass );
1228 trk->setNhits( track.nchits(), l_mass );
1229
1230 trk->setFHelix( track.a(), l_mass );
1231 trk->setFError( track.Ea(), l_mass );
1232 }
1233 else
1234 {
1235
1236 if ( debug_ ) cout << "ALARM: FillTds Not refit with KalFilter!!!" << endl;
1237 // NOT refit with Kalman filter :
1238 trk->setStat( 1, 0, l_mass );
1239 trk->setMass( KalFitTrack::mass( l_mass ), l_mass );
1240 // chisq & ndf (0 : filter ; 1 : smoother;)
1241 trk->setChisq( TrasanTRK.chiSq, 0, l_mass );
1242 trk->setNdf( TrasanTRK.nhits - 5, 0, l_mass );
1243 // nhits
1244 trk->setNhits( TrasanTRK.nhits, l_mass );
1245 double a_trasan[5], ea_trasan[15];
1246 for ( int i = 0; i < 5; i++ ) { a_trasan[i] = TrasanTRK.helix[i]; }
1247 for ( int j = 0; j < 15; j++ ) { ea_trasan[j] = TrasanTRK.error[j]; }
1248 trk->setFHelix( a_trasan, l_mass );
1249 trk->setFError( ea_trasan, l_mass );
1250 }
1251}
void setFHelix(const HepVector &fhelix, const int pid)
void setChisq(double chisq, int i, int pid)
void setFError(const HepSymMatrix &ferror, const int pid)
const HepSymMatrix & Ea(void) const
returns error matrix.
const HepPoint3D & pivot(void) const
returns pivot position.

Referenced by complete_track(), and complete_track().

◆ fillTds_back() [1/3]

void KalFitAlg::fillTds_back ( KalFitTrack & track,
RecMdcKalTrack * trk,
MdcRec_trk & TrasanTRK,
int l_mass )

with results got at the outer Mdc hit

right???

Definition at line 1488 of file KalFitAlg.cxx.

1489 {
1490
1491 HepPoint3D IP( 0, 0, 0 );
1492 // track.pivot(IP);
1493
1494 // Fit quality
1495 int iqual( 1 );
1496
1497 if ( ( trk->getNdf( 0, l_mass ) ) - ( track.ndf_back() - 5 ) > 5 ) iqual = 0;
1498
1499 if ( debug_ == 4 )
1500 cout << "fillTds_back> mass " << trk->getMass( 2 ) << " ndf[0] " << trk->getNdf( 0, 2 )
1501 << endl;
1502 if ( debug_ == 4 )
1503 cout << "ndf_back " << track.ndf_back() << " chi2_back " << track.chiSq_back() << endl;
1504
1505 if ( track.ndf_back() > 5 && track.chiSq_back() > 0 && track.Ea()[0][0] > 0 &&
1506 track.Ea()[1][1] > 0 && track.Ea()[2][2] > 0 && track.Ea()[3][3] > 0 &&
1507 track.Ea()[4][4] > 0 && fabs( track.a()[0] ) < DBL_MAX &&
1508 fabs( track.a()[1] ) < DBL_MAX && fabs( track.a()[2] ) < DBL_MAX &&
1509 fabs( track.a()[3] ) < DBL_MAX && fabs( track.a()[4] ) < DBL_MAX && iqual )
1510 {
1511
1512 // chisq ( for backward filter)
1513
1514 trk->setStat( 0, 1, l_mass );
1515 trk->setChisq( track.chiSq_back(), 1, l_mass );
1516 trk->setNdf( track.ndf_back() - 5, 1, l_mass );
1517 trk->setLength( track.pathip(), l_mass );
1518 if ( debug_ == 4 )
1519 cout << "l_mass " << l_mass << " path set as " << track.pathip() << endl;
1520 trk->setTof( track.tof(), l_mass );
1521
1523 {
1524 if ( l_mass == 3 ) trk->setTof( track.tof_kaon(), l_mass );
1525 if ( l_mass == 4 ) trk->setTof( track.tof_proton(), l_mass );
1526 }
1527
1528 // Path length in each MDC layer :
1529 if ( pathl_ )
1530 for ( int i = 0; i < 43; i++ ) { trk->setPathl( track.pathl()[i], i ); }
1531
1532 trk->setLHelix( track.a(), l_mass );
1533 trk->setLError( track.Ea(), l_mass );
1534 trk->setLPivot( track.pivot(), l_mass );
1535
1536 trk->setLPoint( track.point_last(), l_mass );
1537 trk->setPathSM( track.getPathSM(), l_mass );
1538 trk->setTof( track.getTofSM(), l_mass );
1539 trk->setFiTerm( track.getFiTerm(), l_mass );
1540
1541 if ( 4 == debug_ )
1542 {
1543 std::cout << " last pivot: " << trk->getLPivot( 0 ) << std::endl;
1544 std::cout << " pathl in SM: " << trk->getPathSM( 0 ) << std::endl;
1545 std::cout << " fiTerm: " << trk->getFiTerm( 0 ) << std::endl;
1546 std::cout << " last point: " << trk->getLPoint( 0 ) << std::endl;
1547 }
1548 }
1549 else
1550 {
1551 if ( debug_ ) cout << "ALARM: FillTds_back Not refit with KalFilter!!!" << endl;
1552 // NOT refit with Kalman filter :
1553 trk->setStat( 1, 1, l_mass );
1554 HepPoint3D piv( TrasanTRK.pivot[0], TrasanTRK.pivot[1], TrasanTRK.pivot[2] );
1555
1556 HepVector a( 5 );
1557 for ( int i = 0; i < 5; i++ ) a[i] = TrasanTRK.helix[i];
1558
1559 HepSymMatrix ea( 5 );
1560 for ( int i = 0, k = 0; i < 5; i++ )
1561 {
1562 for ( int j = 0; j <= i; j++ )
1563 {
1564 ea[i][j] = matrixg_ * TrasanTRK.error[k++];
1565 ea[j][i] = ea[i][j];
1566 }
1567 }
1568
1569 KalFitTrack track_rep( piv, a, ea, lead_, TrasanTRK.chiSq, TrasanTRK.nhits );
1570 double fiTerm = TrasanTRK.fiTerm;
1571
1572 double fi0 = track_rep.phi0();
1573 HepPoint3D xc( track_rep.kappa() / fabs( track_rep.kappa() ) * track_rep.center() );
1574 double x = xc.x();
1575 double y = xc.y();
1576 double phi_x;
1577 if ( fabs( x ) > 1.0e-10 )
1578 {
1579 phi_x = atan2( y, x );
1580 if ( phi_x < 0 ) phi_x += 2 * M_PI;
1581 }
1582 else { phi_x = ( y > 0 ) ? M_PI_4 : 3.0 * M_PI_4; }
1583 if ( debug_ == 4 )
1584 cout << "fiterm " << fiTerm << " fi0 " << fi0 << " phi_x " << phi_x << endl;
1585 double dphi = fabs( fiTerm + fi0 - phi_x );
1586 if ( dphi >= 2 * M_PI ) dphi -= 2 * M_PI;
1587 double tanl = track_rep.tanl();
1588 double cosl_inv = sqrt( tanl * tanl + 1.0 );
1589 if ( debug_ == 4 )
1590 {
1591 cout << "tanl= " << tanl << " radius " << track_rep.radius() << " dphi " << dphi << endl;
1592 cout << " cosl_inv " << cosl_inv << " radius_numf " << track_rep.radius_numf()
1593 << endl;
1594 }
1595 double track_len( fabs( track_rep.radius() * dphi * cosl_inv ) );
1596 double light_speed( 29.9792458 ); // light speed in cm/nsec
1597 double pt( 1.0 / track_rep.kappa() );
1598 double p( pt * sqrt( 1.0 + tanl * tanl ) );
1599
1600 // chisq (2 : for backward filter)
1601 trk->setStat( 1, 1, l_mass );
1602 trk->setChisq( TrasanTRK.chiSq, 1, l_mass );
1603 if ( debug_ == 4 )
1604 {
1605 std::cout << ".....fillTds_back...chiSq..." << TrasanTRK.chiSq << endl;
1606 std::cout << "...track_len..." << track_len << " ndf[1] " << trk->getNdf( 0, l_mass )
1607 << endl;
1608 }
1609 trk->setNdf( TrasanTRK.nhits - 5, 1, l_mass );
1610 trk->setLength( track_len, l_mass );
1611 double mass_over_p( KalFitTrack::mass( l_mass ) / p );
1612 double beta( 1.0 / sqrt( 1.0 + mass_over_p * mass_over_p ) );
1613 trk->setTof( track_len / ( light_speed * beta ), l_mass );
1614
1615 track_rep.pivot( IP );
1616
1617 trk->setLHelix( track_rep.a(), l_mass );
1618 trk->setLError( track_rep.Ea(), l_mass );
1619 trk->setLPivot( track.pivot(), l_mass );
1620
1621 /// right???
1622 trk->setLPoint( track.point_last(), l_mass );
1623 trk->setPathSM( track.getPathSM(), l_mass );
1624 trk->setTof( track.getTofSM(), l_mass );
1625 trk->setFiTerm( track.getFiTerm(), l_mass );
1626 }
1627
1628 // test--------
1629 if ( debug_ == 4 )
1630 {
1631
1632 std::cout << " last point: " << trk->getLPoint( 0 ) << std::endl;
1633 std::cout << " pathl in SM: " << trk->getPathSM( 0 ) << std::endl;
1634 std::cout << " fiTerm: " << trk->getFiTerm( 0 ) << std::endl;
1635
1636 cout << "Now let us see results after smoothering at IP:........." << endl;
1637 cout << " dr = " << track.a()[0] << ", Er_dr = " << sqrt( track.Ea()[0][0] ) << std::endl;
1638 cout << " phi0 = " << track.a()[1] << ", Er_phi0 = " << sqrt( track.Ea()[1][1] )
1639 << std::endl;
1640 cout << " PT = " << 1 / track.a()[2] << ", Er_kappa = " << sqrt( track.Ea()[2][2] )
1641 << std::endl;
1642 cout << " dz = " << track.a()[3] << ", Er_dz = " << sqrt( track.Ea()[3][3] ) << std::endl;
1643 cout << " tanl = " << track.a()[4] << ", Er_tanl = " << sqrt( track.Ea()[4][4] )
1644 << std::endl;
1645 cout << " Ea = " << track.Ea() << endl;
1646 }
1647 // test end ----------
1648}
Double_t x[10]
#define DBL_MAX
Definition KalFitAlg.h:13
void point_last(const HepPoint3D &point)
set and give out the last point of the track
void tof(double path)
Update the tof estimation.
void setLError(const HepSymMatrix &error, const int pid)

Referenced by complete_track(), and complete_track().

◆ fillTds_back() [2/3]

void KalFitAlg::fillTds_back ( KalFitTrack & track,
RecMdcKalTrack * trk,
MdcRec_trk & TrasanTRK,
int l_mass,
RecMdcKalHelixSegCol * segcol )

right???

Definition at line 1650 of file KalFitAlg.cxx.

1651 {
1652
1653 HepPoint3D IP( 0, 0, 0 );
1654
1655 // attention the pivot problem of the HelixSeg ... ???
1656 track.pivot( IP );
1657 // Fit quality
1658 // int iqual(1);
1659 // if ((trk->getNdf(0,2))-(track.ndf_back()-5)>5)
1660 // form getNdf(0,2) to getNdf(0,1) for muon hypothesis
1661
1662 if ( ( trk->getNdf( 0, l_mass ) ) - ( track.ndf_back() - 5 ) > 5 ) { iqual_back_ = 0; }
1663 if ( usage_ > 1 )
1664 {
1665 for ( int i = 0; i < 5; i++ ) iqual_front_[i] = 1;
1666 iqual_back_ = 1;
1667 }
1668 if ( debug_ == 4 )
1669 {
1670 std::cout << "fillTds_back> mass " << trk->getMass( 2 ) << " ndf[0][l_mass] "
1671 << trk->getNdf( 0, l_mass ) << endl;
1672 std::cout << "ndf_back " << track.ndf_back() << " chi2_back " << track.chiSq_back()
1673 << endl;
1674 std::cout << "track.ndf_back(), track.chiSq_back(), track.Ea()[5][5], track.a()[5], "
1675 "iqual_front_, iqual_back_: "
1676 << track.ndf_back() << " , " << track.chiSq_back() << " , " << track.Ea()
1677 << " , " << track.a() << " , " << iqual_front_[l_mass] << " , " << iqual_back_
1678 << std::endl;
1679 }
1680
1681 if ( track.ndf_back() > 5 && track.chiSq_back() > 0 && track.Ea()[0][0] > 0 &&
1682 track.Ea()[1][1] > 0 && track.Ea()[2][2] > 0 && track.Ea()[3][3] > 0 &&
1683 track.Ea()[4][4] > 0 && fabs( track.a()[0] ) < DBL_MAX &&
1684 fabs( track.a()[1] ) < DBL_MAX && fabs( track.a()[2] ) < DBL_MAX &&
1685 fabs( track.a()[3] ) < DBL_MAX && fabs( track.a()[4] ) < DBL_MAX &&
1686 iqual_front_[l_mass] && iqual_back_ )
1687 {
1688
1689 // chisq ( for backward filter)
1690 // std::cout<<"begin to fillTds_back track no. : "<<(++Tds_back_no)<<std::endl;
1691
1692 HelixSegRefVec helixsegrefvec;
1693 for ( vector<KalFitHelixSeg>::iterator it = track.HelixSegs().begin();
1694 it != track.HelixSegs().end(); it++ )
1695 {
1696
1697 // std::cout<<" alpha of KalFitHelixSeg: "<<it->alpha()<<std::endl;
1698 // std::cout<<" doca1 of KalFitHelixSeg:
1699 // "<<(it->approach(*(it->HitMdc()),false))<<std::endl;
1700
1701 it->pivot( IP );
1702
1703 // std::cout<<" doca2 of KalFitHelixSeg:
1704 // "<<(it->approach(*(it->HitMdc()),false))<<std::endl;
1705
1706 RecMdcKalHelixSeg* helixseg = new RecMdcKalHelixSeg;
1707 helixseg->setResIncl( it->residual_include() );
1708 helixseg->setResExcl( it->residual_exclude() );
1709 if ( debug_ == 4 )
1710 { std::cout << "helixseg->Res_inc ..." << helixseg->getResIncl() << std::endl; }
1711 helixseg->setDrIncl( it->a_include()[0] );
1712 helixseg->setFi0Incl( it->a_include()[1] );
1713 helixseg->setCpaIncl( it->a_include()[2] );
1714 helixseg->setDzIncl( it->a_include()[3] );
1715 helixseg->setTanlIncl( it->a_include()[4] );
1716
1717 helixseg->setDrExcl( it->a_exclude()[0] );
1718 helixseg->setFi0Excl( it->a_exclude()[1] );
1719 helixseg->setCpaExcl( it->a_exclude()[2] );
1720 helixseg->setDzExcl( it->a_exclude()[3] );
1721 helixseg->setTanlExcl( it->a_exclude()[4] );
1722
1723 helixseg->setHelixIncl( it->a_include() );
1724 helixseg->setErrorIncl( it->Ea_include() );
1725
1726 // Helix temp(IP, it->a(), it->Ea());
1727
1728 // std::cout<<" doca3 of KalFitHelixSeg:
1729 // "<<(temp.approach(*(it->HitMdc()),false))<<std::endl;
1730
1731 helixseg->setHelixExcl( it->a_exclude() );
1732 helixseg->setErrorExcl( it->Ea_exclude() );
1733 helixseg->setLayerId( it->layer() );
1734
1735 if ( debug_ == 4 )
1736 {
1737 std::cout << "KalFitHelixSeg track id .." << it->HitMdc()->rechitptr()->getTrkId()
1738 << std::endl;
1739 std::cout << "helixseg a: " << it->a() << std::endl;
1740 std::cout << "helixseg a_excl: " << helixseg->getHelixExcl() << std::endl;
1741 std::cout << "helixseg a_incl: " << helixseg->getHelixIncl() << std::endl;
1742
1743 std::cout << "helixseg Ea: " << it->Ea() << std::endl;
1744 std::cout << "helixseg Ea_excl: " << helixseg->getErrorExcl() << std::endl;
1745 std::cout << "helixseg Ea_incl: " << helixseg->getErrorIncl() << std::endl;
1746
1747 std::cout << "helixseg layer: " << it->layer() << std::endl;
1748 }
1749
1750 helixseg->setTrackId( it->HitMdc()->rechitptr()->getTrkId() );
1751 helixseg->setMdcId( it->HitMdc()->rechitptr()->getMdcId() );
1752 helixseg->setFlagLR( it->HitMdc()->LR() );
1753 helixseg->setTdc( it->HitMdc()->rechitptr()->getTdc() );
1754 helixseg->setAdc( it->HitMdc()->rechitptr()->getAdc() );
1755 helixseg->setZhit( it->HitMdc()->rechitptr()->getZhit() );
1756 helixseg->setTof( it->tof() );
1757 helixseg->setDocaIncl( it->doca_include() );
1758 helixseg->setDocaExcl( it->doca_exclude() );
1759 helixseg->setDD( it->dd() );
1760 helixseg->setEntra( it->HitMdc()->rechitptr()->getEntra() );
1761 helixseg->setDT( it->dt() );
1762 segcol->push_back( helixseg );
1763 SmartRef<RecMdcKalHelixSeg> refhelixseg( helixseg );
1764 helixsegrefvec.push_back( refhelixseg );
1765
1766 if ( ntuple_ & 8 )
1767 {
1768 m_docaInc = helixseg->getDocaIncl();
1769 m_docaExc = helixseg->getDocaExcl();
1770 m_residualInc = helixseg->getResIncl();
1771 m_residualExc = helixseg->getResExcl();
1772 m_dd = helixseg->getDD();
1773 m_lr = helixseg->getFlagLR();
1774 m_tdrift = helixseg->getDT();
1775 m_layerid = helixseg->getLayerId();
1776 m_yposition = it->HitMdc()->wire().fwd().y();
1777 m_eventNo = eventNo;
1778 StatusCode sc6 = m_nt6->write();
1779 if ( sc6.isFailure() ) cout << "Ntuple6 helixseg filling failed!" << endl;
1780 }
1781 }
1782
1783 trk->setVecHelixSegs( helixsegrefvec, l_mass );
1784 if ( debug_ == 4 )
1785 {
1786 std::cout << "trk->getVecHelixSegs size..." << ( trk->getVecHelixSegs() ).size()
1787 << std::endl;
1788 }
1789 trk->setStat( 0, 1, l_mass );
1790 trk->setChisq( track.chiSq_back(), 1, l_mass );
1791 trk->setNdf( track.ndf_back() - 5, 1, l_mass );
1792 // add setNhits ,maybe some problem
1793 trk->setNhits( track.ndf_back(), l_mass );
1794 if ( !( track.ndf_back() == track.HelixSegs().size() ) )
1795 { std::cout << "THEY ARE NOT EQUALL!!!" << std::endl; }
1796 trk->setLength( track.pathip(), l_mass );
1797 if ( debug_ == 4 )
1798 { std::cout << "l_mass " << l_mass << " path set as " << track.pathip() << endl; }
1799 trk->setTof( track.tof(), l_mass );
1801 {
1802 if ( l_mass == 3 ) trk->setTof( track.tof_kaon(), l_mass );
1803 if ( l_mass == 4 ) trk->setTof( track.tof_proton(), l_mass );
1804 }
1805 // Path length in each MDC layer :
1806 if ( pathl_ )
1807 for ( int i = 0; i < 43; i++ ) { trk->setPathl( track.pathl()[i], i ); }
1808 trk->setLHelix( track.a(), l_mass );
1809 trk->setLError( track.Ea(), l_mass );
1810 trk->setLPivot( track.pivot(), l_mass );
1811
1812 trk->setLPoint( track.point_last(), l_mass );
1813 trk->setPathSM( track.getPathSM(), l_mass );
1814 trk->setTof( track.getTofSM(), l_mass );
1815 trk->setFiTerm( track.getFiTerm(), l_mass );
1816 double a_trasan[5], ea_trasan[15];
1817 for ( int i = 0; i < 5; i++ ) { a_trasan[i] = TrasanTRK.helix[i]; }
1818 for ( int j = 0; j < 15; j++ ) { ea_trasan[j] = TrasanTRK.helix[j]; }
1819 trk->setTHelix( a_trasan );
1820 trk->setTError( ea_trasan );
1821
1822 if ( 4 == debug_ )
1823 {
1824 std::cout << " last pivot: " << trk->getLPivot( 0 ) << std::endl;
1825 std::cout << " pathl in SM: " << trk->getPathSM( 0 ) << std::endl;
1826 std::cout << " fiTerm: " << trk->getFiTerm( 0 ) << std::endl;
1827 std::cout << " last point: " << trk->getLPoint( 0 ) << std::endl;
1828 }
1829 }
1830 else
1831 {
1832
1833 if ( debug_ ) cout << "ALARM: FillTds_back Not refit with KalFilter!!!" << endl;
1834 // NOT refit with Kalman filter :
1835 trk->setStat( 1, 1, l_mass );
1836
1837 HepPoint3D piv( TrasanTRK.pivot[0], TrasanTRK.pivot[1], TrasanTRK.pivot[2] );
1838
1839 HepVector a( 5 );
1840 for ( int i = 0; i < 5; i++ ) a[i] = TrasanTRK.helix[i];
1841
1842 HepSymMatrix ea( 5 );
1843 for ( int i = 0, k = 0; i < 5; i++ )
1844 {
1845 for ( int j = 0; j <= i; j++ )
1846 {
1847 ea[i][j] = matrixg_ * TrasanTRK.error[k++];
1848 ea[j][i] = ea[i][j];
1849 }
1850 }
1851
1852 KalFitTrack track_rep( piv, a, ea, lead_, TrasanTRK.chiSq, TrasanTRK.nhits );
1853 double fiTerm = TrasanTRK.fiTerm;
1854
1855 double fi0 = track_rep.phi0();
1856 HepPoint3D xc( track_rep.kappa() / fabs( track_rep.kappa() ) * track_rep.center() );
1857 double x = xc.x();
1858 double y = xc.y();
1859 double phi_x;
1860 if ( fabs( x ) > 1.0e-10 )
1861 {
1862 phi_x = atan2( y, x );
1863 if ( phi_x < 0 ) phi_x += 2 * M_PI;
1864 }
1865 else { phi_x = ( y > 0 ) ? M_PI_4 : 3.0 * M_PI_4; }
1866 if ( debug_ == 4 )
1867 cout << "fiterm " << fiTerm << " fi0 " << fi0 << " phi_x " << phi_x << endl;
1868 double dphi = fabs( fiTerm + fi0 - phi_x );
1869 if ( dphi >= 2 * M_PI ) dphi -= 2 * M_PI;
1870 double tanl = track_rep.tanl();
1871 double cosl_inv = sqrt( tanl * tanl + 1.0 );
1872 if ( debug_ == 4 )
1873 {
1874 cout << "tanl= " << tanl << " radius " << track_rep.radius() << " dphi " << dphi << endl;
1875 cout << " cosl_inv " << cosl_inv << " radius_numf " << track_rep.radius_numf()
1876 << endl;
1877 }
1878 double track_len( fabs( track_rep.radius() * dphi * cosl_inv ) );
1879 double light_speed( 29.9792458 ); // light speed in cm/nsec
1880 double pt( 1.0 / track_rep.kappa() );
1881 double p( pt * sqrt( 1.0 + tanl * tanl ) );
1882
1883 // chisq (2 : for backward filter)
1884
1885 trk->setStat( 1, 1, l_mass );
1886 trk->setChisq( TrasanTRK.chiSq, 1, l_mass );
1887 if ( debug_ == 4 )
1888 {
1889 std::cout << ".....fillTds_back...chiSq..." << TrasanTRK.chiSq << std::endl;
1890 std::cout << "...track_len..." << track_len << " ndf[1] " << trk->getNdf( 0, l_mass )
1891 << std::endl;
1892 }
1893 trk->setNdf( TrasanTRK.nhits - 5, 1, l_mass );
1894 trk->setLength( track_len, l_mass );
1895 double mass_over_p( KalFitTrack::mass( l_mass ) / p );
1896 double beta( 1.0 / sqrt( 1.0 + mass_over_p * mass_over_p ) );
1897 trk->setTof( track_len / ( light_speed * beta ), l_mass );
1898
1899 track_rep.pivot( IP );
1900
1901 trk->setLHelix( track_rep.a(), l_mass );
1902 trk->setLError( track_rep.Ea(), l_mass );
1903 trk->setLPivot( track.pivot(), l_mass );
1904
1905 /// right???
1906 trk->setLPoint( track.point_last(), l_mass );
1907 trk->setPathSM( track.getPathSM(), l_mass );
1908 trk->setTof( track.getTofSM(), l_mass );
1909 trk->setFiTerm( track.getFiTerm(), l_mass );
1910 trk->setTHelix( track_rep.a() );
1911 trk->setTError( track_rep.Ea() );
1912 }
1913
1914 // test--------
1915 if ( debug_ == 4 )
1916 {
1917 cout << "Now let us see results after smoothering at IP:........." << endl;
1918 cout << " dr = " << track.a()[0] << ", Er_dr = " << sqrt( track.Ea()[0][0] ) << std::endl;
1919 cout << " phi0 = " << track.a()[1] << ", Er_phi0 = " << sqrt( track.Ea()[1][1] )
1920 << std::endl;
1921 cout << " PT = " << 1 / track.a()[2] << ", Er_kappa = " << sqrt( track.Ea()[2][2] )
1922 << std::endl;
1923 cout << " dz = " << track.a()[3] << ", Er_dz = " << sqrt( track.Ea()[3][3] ) << std::endl;
1924 cout << " tanl = " << track.a()[4] << ", Er_tanl = " << sqrt( track.Ea()[4][4] )
1925 << std::endl;
1926 cout << " Ea = " << track.Ea() << endl;
1927 }
1928 // test end ----------
1929}
void HelixSegs(vector< KalFitHelixSeg > &vs)
HelixSegRefVec getVecHelixSegs(int pid=-1) const
void setVecHelixSegs(const HelixSegRefVec &vechelixsegs, int pid=-1)

◆ fillTds_back() [3/3]

void KalFitAlg::fillTds_back ( KalFitTrack & track,
RecMdcKalTrack * trk,
MdcRec_trk & TrasanTRK,
int l_mass,
RecMdcKalHelixSegCol * segcol,
int smoothflag )

for smoother process

right???

Definition at line 1931 of file KalFitAlg.cxx.

1932 {
1933
1934 HepPoint3D IP( 0, 0, 0 );
1935
1936 // attention the pivot problem of the HelixSeg ... ???
1937 // track.pivot(IP);
1938 // Fit quality
1939 // int iqual(1);
1940 // if ((trk->getNdf(0,2))-(track.ndf_back()-5)>5)
1941 // form getNdf(0,2) to getNdf(0,1) for muon hypothesis
1942
1943 iqual_back_ = 1;
1944 if ( ( trk->getNdf( 0, l_mass ) ) - ( track.ndf_back() - 5 ) > 5 ) { iqual_back_ = 0; }
1945
1946 if ( debug_ == 4 )
1947 {
1948 std::cout << "fillTds_back> mass " << trk->getMass( 2 ) << " ndf[0][l_mass] "
1949 << trk->getNdf( 0, l_mass ) << endl;
1950 std::cout << "ndf_back " << track.ndf_back() << " chi2_back " << track.chiSq_back()
1951 << endl;
1952 }
1953
1954 if ( track.ndf_back() > 5 && track.chiSq_back() > 0 && track.Ea()[0][0] > 0 &&
1955 track.Ea()[1][1] > 0 && track.Ea()[2][2] > 0 && track.Ea()[3][3] > 0 &&
1956 track.Ea()[4][4] > 0 && fabs( track.a()[0] ) < DBL_MAX &&
1957 fabs( track.a()[1] ) < DBL_MAX && fabs( track.a()[2] ) < DBL_MAX &&
1958 fabs( track.a()[3] ) < DBL_MAX && fabs( track.a()[4] ) < DBL_MAX &&
1959 iqual_front_[l_mass] && iqual_back_ )
1960 {
1961
1962 // chisq ( for backward filter)
1963 // std::cout<<"begin to fillTds_back track no. : "<<(++Tds_back_no)<<std::endl;
1964
1965 HelixSegRefVec helixsegrefvec;
1966 for ( vector<KalFitHelixSeg>::iterator it = track.HelixSegs().begin();
1967 it != track.HelixSegs().end(); it++ )
1968 {
1969
1970 // std::cout<<" alpha of KalFitHelixSeg: "<<it->alpha()<<std::endl;
1971 // std::cout<<" doca1 of KalFitHelixSeg:
1972 // "<<(it->approach(*(it->HitMdc()),false))<<std::endl;
1973
1974 it->pivot( IP );
1975
1976 // std::cout<<" doca2 of KalFitHelixSeg:
1977 // "<<(it->approach(*(it->HitMdc()),false))<<std::endl;
1978
1979 RecMdcKalHelixSeg* helixseg = new RecMdcKalHelixSeg;
1980 helixseg->setResIncl( it->residual_include() );
1981 helixseg->setResExcl( it->residual_exclude() );
1982 if ( debug_ == 4 )
1983 { std::cout << "helixseg->Res_inc ..." << helixseg->getResIncl() << std::endl; }
1984 // helixseg->setDrIncl(it->a_include()[0]);
1985 // helixseg->setFi0Incl(it->a_include()[1]);
1986 // helixseg->setCpaIncl(it->a_include()[2]);
1987 // helixseg->setDzIncl(it->a_include()[3]);
1988 // helixseg->setTanlIncl(it->a_include()[4]);
1989 //
1990 //
1991 // helixseg->setDrExcl(it->a_exclude()[0]);
1992 // helixseg->setFi0Excl(it->a_exclude()[1]);
1993 // helixseg->setCpaExcl(it->a_exclude()[2]);
1994 // helixseg->setDzExcl(it->a_exclude()[3]);
1995 // helixseg->setTanlExcl(it->a_exclude()[4]);
1996
1997 helixseg->setHelixIncl( it->a_include() );
1998 // helixseg->setErrorIncl(it->Ea_include());
1999
2000 // Helix temp(IP, it->a(), it->Ea());
2001
2002 // std::cout<<" doca3 of KalFitHelixSeg:
2003 // "<<(temp.approach(*(it->HitMdc()),false))<<std::endl;
2004
2005 helixseg->setHelixExcl( it->a_exclude() );
2006 // helixseg->setErrorExcl(it->Ea_exclude());
2007 // helixseg->setLayerId(it->layer());
2008
2009 if ( debug_ == 4 )
2010 {
2011 std::cout << "KalFitHelixSeg track id .." << it->HitMdc()->rechitptr()->getTrkId()
2012 << std::endl;
2013 std::cout << "helixseg a: " << it->a() << std::endl;
2014 std::cout << "helixseg a_excl: " << helixseg->getHelixExcl() << std::endl;
2015 std::cout << "helixseg a_incl: " << helixseg->getHelixIncl() << std::endl;
2016
2017 std::cout << "helixseg Ea: " << it->Ea() << std::endl;
2018 std::cout << "helixseg Ea_excl: " << helixseg->getErrorExcl() << std::endl;
2019 std::cout << "helixseg Ea_incl: " << helixseg->getErrorIncl() << std::endl;
2020
2021 std::cout << "helixseg layer: " << it->layer() << std::endl;
2022 }
2023
2024 helixseg->setTrackId( it->HitMdc()->rechitptr()->getTrkId() );
2025 helixseg->setMdcId( it->HitMdc()->rechitptr()->getMdcId() );
2026 helixseg->setFlagLR( it->HitMdc()->LR() );
2027 helixseg->setTdc( it->HitMdc()->rechitptr()->getTdc() );
2028 helixseg->setAdc( it->HitMdc()->rechitptr()->getAdc() );
2029 helixseg->setZhit( it->HitMdc()->rechitptr()->getZhit() );
2030 helixseg->setTof( it->tof() );
2031 helixseg->setDocaIncl( it->doca_include() );
2032 helixseg->setDocaExcl( it->doca_exclude() );
2033 helixseg->setDD( it->dd() );
2034 helixseg->setEntra( it->HitMdc()->rechitptr()->getEntra() );
2035 helixseg->setDT( it->dt() );
2036 // cout<<"setDT( "<<it->dt()<<" )"<<endl;
2037 segcol->push_back( helixseg );
2038 SmartRef<RecMdcKalHelixSeg> refhelixseg( helixseg );
2039 helixsegrefvec.push_back( refhelixseg );
2040 if ( ntuple_ & 8 )
2041 {
2042 m_docaInc = helixseg->getDocaIncl();
2043 m_docaExc = helixseg->getDocaExcl();
2044 m_residualInc = helixseg->getResIncl();
2045 m_residualExc = helixseg->getResExcl();
2046 m_dd = helixseg->getDD();
2047 m_lr = helixseg->getFlagLR();
2048 m_tdrift = helixseg->getDT();
2049 m_layerid = helixseg->getLayerId();
2050 m_yposition = it->HitMdc()->wire().fwd().y();
2051 m_eventNo = eventNo;
2052 StatusCode sc6 = m_nt6->write();
2053 if ( sc6.isFailure() ) cout << "Ntuple6 helixseg filling failed!" << endl;
2054 }
2055 }
2056
2057 trk->setVecHelixSegs( helixsegrefvec, l_mass );
2058 // cout<<"setVecHelixSegs with Kalman hits"<<endl;
2059 if ( debug_ == 4 )
2060 {
2061 std::cout << "trk->getVecHelixSegs size..." << ( trk->getVecHelixSegs() ).size()
2062 << std::endl;
2063 }
2064 trk->setStat( 0, 1, l_mass );
2065 trk->setChisq( track.chiSq_back(), 1, l_mass );
2066 trk->setNdf( track.ndf_back() - 5, 1, l_mass );
2067 // add setNhits ,maybe some problem
2068 trk->setNhits( track.ndf_back(), l_mass );
2069 if ( !( track.ndf_back() == track.HelixSegs().size() ) )
2070 { std::cout << "THEY ARE NOT EQUALL!!!" << std::endl; }
2071 trk->setLength( track.pathip(), l_mass );
2072 if ( debug_ == 4 )
2073 { std::cout << "l_mass " << l_mass << " path set as " << track.pathip() << endl; }
2074 trk->setTof( track.tof(), l_mass );
2076 {
2077 if ( l_mass == 3 ) trk->setTof( track.tof_kaon(), l_mass );
2078 if ( l_mass == 4 ) trk->setTof( track.tof_proton(), l_mass );
2079 }
2080 // Path length in each MDC layer :
2081 if ( pathl_ )
2082 for ( int i = 0; i < 43; i++ ) { trk->setPathl( track.pathl()[i], i ); }
2083 trk->setLHelix( track.a(), l_mass );
2084 trk->setLError( track.Ea(), l_mass );
2085 trk->setLPivot( track.pivot(), l_mass );
2086
2087 trk->setLPoint( track.point_last(), l_mass );
2088 trk->setPathSM( track.getPathSM(), l_mass );
2089 trk->setTof( track.getTofSM(), l_mass );
2090 trk->setFiTerm( track.getFiTerm(), l_mass );
2091 double a_trasan[5], ea_trasan[15];
2092 for ( int i = 0; i < 5; i++ ) { a_trasan[i] = TrasanTRK.helix[i]; }
2093 for ( int j = 0; j < 15; j++ ) { ea_trasan[j] = TrasanTRK.helix[j]; }
2094 trk->setTHelix( a_trasan );
2095 trk->setTError( ea_trasan );
2096
2097 if ( 4 == debug_ )
2098 {
2099 std::cout << " last pivot: " << trk->getLPivot( 0 ) << std::endl;
2100 std::cout << " pathl in SM: " << trk->getPathSM( 0 ) << std::endl;
2101 std::cout << " fiTerm: " << trk->getFiTerm( 0 ) << std::endl;
2102 std::cout << " last point: " << trk->getLPoint( 0 ) << std::endl;
2103 }
2104 }
2105 else
2106 {
2107
2108 if ( debug_ ) cout << "ALARM: FillTds_back Not refit with KalFilter!!!" << endl;
2109 // NOT refit with Kalman filter :
2110 trk->setStat( 1, 1, l_mass );
2111
2112 HepPoint3D piv( TrasanTRK.pivot[0], TrasanTRK.pivot[1], TrasanTRK.pivot[2] );
2113
2114 HepVector a( 5 );
2115 for ( int i = 0; i < 5; i++ ) a[i] = TrasanTRK.helix[i];
2116
2117 HepSymMatrix ea( 5 );
2118 for ( int i = 0, k = 0; i < 5; i++ )
2119 {
2120 for ( int j = 0; j <= i; j++ )
2121 {
2122 ea[i][j] = matrixg_ * TrasanTRK.error[k++];
2123 ea[j][i] = ea[i][j];
2124 }
2125 }
2126
2127 KalFitTrack track_rep( piv, a, ea, lead_, TrasanTRK.chiSq, TrasanTRK.nhits );
2128 double fiTerm = TrasanTRK.fiTerm;
2129
2130 double fi0 = track_rep.phi0();
2131 HepPoint3D xc( track_rep.kappa() / fabs( track_rep.kappa() ) * track_rep.center() );
2132 double x = xc.x();
2133 double y = xc.y();
2134 double phi_x;
2135 if ( fabs( x ) > 1.0e-10 )
2136 {
2137 phi_x = atan2( y, x );
2138 if ( phi_x < 0 ) phi_x += 2 * M_PI;
2139 }
2140 else { phi_x = ( y > 0 ) ? M_PI_4 : 3.0 * M_PI_4; }
2141 if ( debug_ == 4 )
2142 cout << "fiterm " << fiTerm << " fi0 " << fi0 << " phi_x " << phi_x << endl;
2143 double dphi = fabs( fiTerm + fi0 - phi_x );
2144 if ( dphi >= 2 * M_PI ) dphi -= 2 * M_PI;
2145 double tanl = track_rep.tanl();
2146 double cosl_inv = sqrt( tanl * tanl + 1.0 );
2147 if ( debug_ == 4 )
2148 {
2149 cout << "tanl= " << tanl << " radius " << track_rep.radius() << " dphi " << dphi << endl;
2150 cout << " cosl_inv " << cosl_inv << " radius_numf " << track_rep.radius_numf()
2151 << endl;
2152 }
2153 // double track_len(fabs( track_rep.radius() * dphi * cosl_inv ));
2154 double track_len( fabs( track_rep.radius() * fiTerm * cosl_inv ) ); // 2010-11-26 added by
2155 // wangll
2156 // cout<<"track radius : "<<track_rep.radius()<<" "<<track.radius()<<endl;
2157 double light_speed( 29.9792458 ); // light speed in cm/nsec
2158 double pt( 1.0 / track_rep.kappa() );
2159 double p( pt * sqrt( 1.0 + tanl * tanl ) );
2160
2161 // chisq (2 : for backward filter)
2162
2163 trk->setStat( 1, 1, l_mass );
2164 trk->setChisq( TrasanTRK.chiSq, 1, l_mass );
2165 if ( debug_ == 4 )
2166 {
2167 std::cout << ".....fillTds_back...chiSq..." << TrasanTRK.chiSq << std::endl;
2168 std::cout << "...track_len..." << track_len << " ndf[1] " << trk->getNdf( 0, l_mass )
2169 << std::endl;
2170 }
2171 trk->setNdf( TrasanTRK.nhits - 5, 1, l_mass );
2172 trk->setLength( track_len, l_mass );
2173 double mass_over_p( KalFitTrack::mass( l_mass ) / p );
2174 double beta( 1.0 / sqrt( 1.0 + mass_over_p * mass_over_p ) );
2175 trk->setTof( track_len / ( light_speed * beta ), l_mass );
2176
2177 // track_rep.pivot(IP);
2178 HepPoint3D LPiovt = track_rep.x( fiTerm );
2179 track_rep.pivot( LPiovt );
2180
2181 trk->setLHelix( track_rep.a(), l_mass );
2182 trk->setLError( track_rep.Ea(), l_mass );
2183 // trk->setLPivot(track.pivot(),l_mass); // commented 2010-09-02
2184 // trk->setLPivot(IP, l_mass); // add 2010-09-02
2185 trk->setLPivot( LPiovt, l_mass ); // add 2010-11-25
2186
2187 /// right???
2188 trk->setLPoint( track.point_last(), l_mass );
2189 // trk->setPathSM(track.getPathSM(),l_mass);// commented 2010-11-25 by wangll
2190 trk->setPathSM( track_len, l_mass ); // added 2010-11-25 by wangll
2191 // trk->setTof(track.getTofSM(),l_mass);// commented 2010-11-25 by wangll
2192 // trk->setFiTerm(track.getFiTerm(),l_mass); // commented 2010-11-25 by wangll
2193 trk->setFiTerm( fiTerm, l_mass ); // added by wangll 2010-11-25
2194 trk->setTHelix( track_rep.a() );
2195 trk->setTError( track_rep.Ea() );
2196
2197 /*
2198 // --- check track id by wangll 2010-08-15
2199 if(l_mass==lead_) {
2200 //cout<<" ----- bad smooth track -----"<<endl;
2201 //cout<<"l_mass = "<<l_mass<<endl;
2202 int trkId = trk->trackId();
2203 //
2204 // cout<<"track id = "<<trkId<<endl;
2205 // cout<<"THelix: "<<trk->getTHelix()<<endl;
2206 // cout<<"FHelix: "<<trk->getFHelix()<<endl;
2207 // cout<<"size of VecHelixSegs: "<<trk->getVecHelixSegs().size()<<endl;
2208 //
2209 SmartDataPtr<RecMdcTrackCol> mdcTrkCol(eventSvc(),"/Event/Recon/RecMdcTrackCol");
2210 //int nMdcTrk = mdcTrkCol.size();
2211 //cout<<"number of Mdc Tracks: "<<nMdcTrk<<endl;
2212 RecMdcTrackCol::iterator iter_mdcTrk = mdcTrkCol->begin();
2213 bool findMdcTrk = false;
2214 for(; iter_mdcTrk != mdcTrkCol->end(); iter_mdcTrk++) {
2215 if(trkId==(*iter_mdcTrk)->trackId()) {
2216 findMdcTrk = true;
2217 break;
2218 }
2219 }
2220 if(findMdcTrk) {
2221 HitRefVec mdcVecHits = (*iter_mdcTrk)->getVecHits();
2222 int nHits = mdcVecHits.size();
2223 //cout<<"number of Mdc Hits: "<<nHits<<endl;
2224 HelixSegRefVec helixsegrefvec;
2225 HitRefVec::iterator iter_mdcHit = mdcVecHits.begin();
2226 for(int iii=0; iter_mdcHit!=mdcVecHits.end(); iter_mdcHit++,iii++) {
2227 RecMdcKalHelixSeg* helixseg = new RecMdcKalHelixSeg;
2228 //cout<<"hit "<<iii<<endl;
2229 //cout<<"getMdcId: "<<(*iter_mdcHit)->getMdcId()<<endl;
2230 //cout<<"getAdc: "<<(*iter_mdcHit)->getAdc()<<endl;
2231 //cout<<"getTdc: "<<(*iter_mdcHit)->getTdc()<<endl;
2232 //cout<<"getDriftT: "<<(*iter_mdcHit)->getDriftT()<<endl;
2233 //cout<<"getZhit: "<<(*iter_mdcHit)->getZhit()<<endl;
2234 //cout<<"getFlagLR: "<<(*iter_mdcHit)->getFlagLR()<<endl;
2235 //cout<<"getDriftDistLeft:
2236 "<<(*iter_mdcHit)->getDriftDistLeft()<<endl;
2237 //cout<<"getDriftDistRight:
2238 "<<(*iter_mdcHit)->getDriftDistRight()<<endl;
2239 //cout<<"getDoca: "<<(*iter_mdcHit)->getDoca()<<endl;
2240 //cout<<"getEntra: "<<(*iter_mdcHit)->getEntra()<<endl;
2241 //
2242 helixseg->setMdcId((*iter_mdcHit)->getMdcId());
2243 helixseg->setAdc((*iter_mdcHit)->getAdc());
2244 helixseg->setTdc((*iter_mdcHit)->getTdc());
2245 helixseg->setZhit((*iter_mdcHit)->getZhit());
2246 helixseg->setFlagLR((*iter_mdcHit)->getFlagLR());
2247 if((*iter_mdcHit)->getFlagLR()==0)
2248 helixseg->setDD((*iter_mdcHit)->getDriftDistLeft()); if((*iter_mdcHit)->getFlagLR()==1)
2249 helixseg->setDD((*iter_mdcHit)->getDriftDistRight());
2250 helixseg->setDocaIncl((*iter_mdcHit)->getDoca());
2251 helixseg->setEntra((*iter_mdcHit)->getEntra());
2252 helixseg->setDT((*iter_mdcHit)->getDriftT());
2253 segcol->push_back(helixseg);
2254 SmartRef<RecMdcKalHelixSeg> refhelixseg(helixseg);
2255 helixsegrefvec.push_back(refhelixseg);
2256 }
2257 trk->setVecHelixSegs(helixsegrefvec);
2258 cout<<"setVecHelixSegs with Mdc hits"<<endl;
2259 }
2260 else cout<<"not find the Mdc Track!";
2261 //cout<<"size of VecHelixSegs: "<<trk->getVecHelixSegs().size()<<endl;
2262 }
2263 */
2264 }
2265
2266 // test--------
2267 if ( debug_ == 4 )
2268 {
2269 cout << "Now let us see results after smoothering at IP:........." << endl;
2270 cout << " dr = " << track.a()[0] << ", Er_dr = " << sqrt( track.Ea()[0][0] ) << std::endl;
2271 cout << " phi0 = " << track.a()[1] << ", Er_phi0 = " << sqrt( track.Ea()[1][1] )
2272 << std::endl;
2273 cout << " PT = " << 1 / track.a()[2] << ", Er_kappa = " << sqrt( track.Ea()[2][2] )
2274 << std::endl;
2275 cout << " dz = " << track.a()[3] << ", Er_dz = " << sqrt( track.Ea()[3][3] ) << std::endl;
2276 cout << " tanl = " << track.a()[4] << ", Er_tanl = " << sqrt( track.Ea()[4][4] )
2277 << std::endl;
2278 cout << " Ea = " << track.Ea() << endl;
2279 }
2280 // test end ----------
2281}

◆ fillTds_ip()

void KalFitAlg::fillTds_ip ( MdcRec_trk & TrasanTRK,
KalFitTrack & track,
RecMdcKalTrack * trk,
int l_mass )

with results got at (0,0,0)

Definition at line 1339 of file KalFitAlg.cxx.

1340 {
1341 HepPoint3D IP( 0, 0, 0 );
1342 track.pivot( IP );
1343
1344 if ( debug_ == 4 && l_mass == lead_ )
1345 {
1346 cout << "fillTds_IP>......" << endl;
1347 cout << " dr = " << track.a()[0] << ", Er_dr = " << sqrt( track.Ea()[0][0] ) << std::endl;
1348 cout << " phi0 = " << track.a()[1] << ", Er_phi0 = " << sqrt( track.Ea()[1][1] )
1349 << std::endl;
1350 cout << " PT = " << 1 / track.a()[2] << ", Er_kappa =" << sqrt( track.Ea()[2][2] )
1351 << std::endl;
1352 cout << " dz = " << track.a()[3] << ", Er_dz = " << sqrt( track.Ea()[3][3] ) << std::endl;
1353 cout << " tanl = " << track.a()[4] << ", Er_tanl = " << sqrt( track.Ea()[4][4] )
1354 << std::endl;
1355 }
1356
1357 if ( TrasanTRK.nhits - track.nchits() > fitnocut_ || TrasanTRK.helix[2] * track.a()[2] < 0 )
1358 iqual_front_[l_mass] = 0;
1359
1360 if ( track.nchits() > 5 && track.nster() > 1 && track.nchits() - track.nster() > 2 &&
1361 track.chiSq() > 0 && track.Ea()[0][0] > 0 && track.Ea()[1][1] > 0 &&
1362 track.Ea()[2][2] > 0 && track.Ea()[3][3] > 0 && track.Ea()[4][4] > 0 &&
1363 iqual_front_[l_mass] )
1364 {
1365
1366 // fill track information
1367 double dr = track.a()[0];
1368 double phi0 = track.a()[1];
1369 double kappa = track.a()[2];
1370 double dz = track.a()[3];
1371 double tanl = track.a()[4];
1372 int nLayer = track.nLayerUsed();
1373 trk->setNlayer( nLayer, l_mass );
1374
1375 // vertex of the track
1376 double vx = dr * cos( phi0 );
1377 double vy = dr * sin( phi0 );
1378 double vz = dz;
1379
1380 // see Belle note148 for the formulas
1381 // initial momentum of the track
1382 if ( 0 == kappa ) kappa = 10e-10;
1383 double px = -sin( phi0 ) / fabs( kappa );
1384 double py = cos( phi0 ) / fabs( kappa );
1385 double pz = tanl / fabs( kappa );
1386
1387 trk->setX( vx, l_mass );
1388 trk->setY( vy, l_mass );
1389 trk->setZ( vz, l_mass );
1390 trk->setPx( px, l_mass );
1391 trk->setPy( py, l_mass );
1392 trk->setPz( pz, l_mass );
1393
1394 const HepPoint3D poca( dr * cos( phi0 ), dr * sin( phi0 ), dz );
1395 trk->setPoca( poca, l_mass );
1396
1397 trk->setZHelix( track.a(), l_mass );
1398 trk->setZError( track.Ea(), l_mass );
1399
1400 // set charge
1401 int charge = 0;
1402 if ( kappa > 0.0000000001 ) charge = 1;
1403 else if ( kappa < -0.0000000001 ) charge = -1;
1404 trk->setCharge( charge, l_mass );
1405
1406 // set theta
1407 double ptot = sqrt( px * px + py * py + pz * pz );
1408 trk->setTheta( acos( pz / ptot ), l_mass );
1409 }
1410
1411 else
1412 {
1413 // cout<<"copy Mdc Helix in fillTds_ip()"<<endl;
1414
1415 // fill track information
1416 double dr = TrasanTRK.helix[0];
1417 double phi0 = TrasanTRK.helix[1];
1418 double kappa = TrasanTRK.helix[2];
1419 double dz = TrasanTRK.helix[3];
1420 double tanl = TrasanTRK.helix[4];
1421
1422 double vx = dr * cos( phi0 );
1423 double vy = dr * sin( phi0 );
1424 double vz = dz;
1425
1426 if ( 0 == kappa ) kappa = 10e-10;
1427 double px = -sin( phi0 ) / fabs( kappa );
1428 double py = cos( phi0 ) / fabs( kappa );
1429 double pz = tanl / fabs( kappa );
1430
1431 trk->setX( vx, l_mass );
1432 trk->setY( vy, l_mass );
1433 trk->setZ( vz, l_mass );
1434
1435 trk->setPx( px, l_mass );
1436 trk->setPy( py, l_mass );
1437 trk->setPz( pz, l_mass );
1438
1439 const HepPoint3D poca( dr * cos( phi0 ), dr * sin( phi0 ), dz );
1440
1441 trk->setPoca( poca, l_mass );
1442 // trk->setZHelix(TrasanTRK.helix,l_mass);
1443 // trk->setZError(TrasanTRK.error,l_mass);
1444 double a_trasan[5], ea_trasan[15];
1445 for ( int i = 0; i < 5; i++ ) { a_trasan[i] = TrasanTRK.helix[i]; }
1446 for ( int j = 0; j < 15; j++ ) { ea_trasan[j] = TrasanTRK.error[j]; }
1447 trk->setZHelix( a_trasan, l_mass );
1448 trk->setZError( ea_trasan, l_mass );
1449
1450 // set charge
1451 int charge = 0;
1452 if ( kappa > 0.0000000001 ) charge = 1;
1453 else if ( kappa < -0.0000000001 ) charge = -1;
1454 trk->setCharge( charge, l_mass );
1455
1456 // set theta
1457 double ptot = sqrt( px * px + py * py + pz * pz );
1458 trk->setTheta( acos( pz / ptot ), l_mass );
1459
1460 // cout<<"MdcRec_trk: ID = "<<TrasanTRK.id<<endl;
1461
1462 SmartDataPtr<RecMdcTrackCol> mdcTrkCol( eventSvc(), "/Event/Recon/RecMdcTrackCol" );
1463 // int nMdcTrk = mdcTrkCol.size();
1464 // cout<<"number of Mdc Tracks: "<<nMdcTrk<<endl;
1465 RecMdcTrackCol::iterator iter_mdcTrk = mdcTrkCol->begin();
1466 bool findMdcTrk = false;
1467 for ( ; iter_mdcTrk != mdcTrkCol->end(); iter_mdcTrk++ )
1468 {
1469 if ( TrasanTRK.id == ( *iter_mdcTrk )->trackId() )
1470 {
1471 findMdcTrk = true;
1472 break;
1473 }
1474 }
1475 int nLayer = ( *iter_mdcTrk )->nlayer();
1476 trk->setNlayer( nLayer, l_mass );
1477 }
1478
1479 if ( 4 == debug_ )
1480 {
1482 std::cout << "px: " << trk->px() << " py: " << trk->py() << " pz: " << trk->pz()
1483 << std::endl;
1484 std::cout << "vx: " << trk->x() << " vy: " << trk->y() << " vz: " << trk->z() << std::endl;
1485 }
1486}
void setY(const double y, const int pid)
void setPz(const double pz, const int pid)
void setZError(const HepSymMatrix &error, const int pid)
void setX(const double x, const int pid)
void setPoca(const HepPoint3D &poca, const int pid)
void setPx(const double px, const int pid)
void setZ(const double z, const int pid)
void setTheta(const double theta, const int pid)
void setPy(const double py, const int pid)
void setZHelix(const HepVector &helix, const int pid)
void setCharge(const int charge, const int pid)

Referenced by complete_track(), and complete_track().

◆ fillTds_lead()

void KalFitAlg::fillTds_lead ( MdcRec_trk & TrasanTRK,
KalFitTrack & track,
RecMdcKalTrack * trk,
int l_mass )

Definition at line 1254 of file KalFitAlg.cxx.

1255 {
1256
1257 HepPoint3D IP( 0, 0, 0 );
1258 track.pivot( IP );
1259 // Fit quality
1260 // int iqual(1);
1261 int trasster = TrasanTRK.nster, trakster = track.nster(),
1262 trasax( TrasanTRK.nhits - trasster ), trakax( track.nchits() - trakster );
1263 if ( TrasanTRK.nhits - track.nchits() > fitnocut_ || TrasanTRK.helix[2] * track.a()[2] < 0 )
1264 iqual_front_[l_mass] = 0;
1265 if ( debug_ == 4 )
1266 {
1267
1268 cout << "Nhit from PR " << TrasanTRK.nhits << " nhit " << track.nchits() << endl;
1269 cout << "trasster trakster trasax trakax TrasK trackK iqual" << endl
1270 << trasster << " " << trakster << " " << trasax << " " << trakax
1271 << " " << TrasanTRK.helix[2] << " " << track.a()[2] << " "
1272 << iqual_front_[l_mass] << endl;
1273 cout << "FillTds_lead> track.chiSq..." << track.chiSq() << " nchits " << track.nchits()
1274 << " nster " << track.nster() << " iqual_front_[l_mass] " << iqual_front_[l_mass]
1275 << " track.Ea " << track.Ea() << endl;
1276
1277 cout << " TRASAN stereo = " << trasster << " and KalFitTrack = " << trakster << std::endl;
1278 cout << " TRASAN axial = " << trasax << " and KalFitTrack = " << trakax << std::endl;
1279
1280 if ( !iqual_front_[l_mass] )
1281 {
1282 cout << "...there is a problem during fit !! " << std::endl;
1283 if ( trasster - trakster > 5 )
1284 cout << " because stereo " << trasster - trakster << std::endl;
1285 if ( trasax - trakax > 5 ) cout << " because axial " << std::endl;
1286 if ( TrasanTRK.helix[2] * track.a()[2] < 0 ) cout << " because kappa sign " << std::endl;
1287 }
1288 }
1289 // Protection : if any problem, we keep the original information !!!!
1290 if ( track.nchits() > 5 && track.nster() > 1 && track.nchits() - track.nster() > 2 &&
1291 track.chiSq() > 0 && track.Ea()[0][0] > 0 && track.Ea()[1][1] > 0 &&
1292 track.Ea()[2][2] > 0 && track.Ea()[3][3] > 0 && track.Ea()[4][4] > 0 &&
1293 iqual_front_[l_mass] )
1294 {
1295
1296 trk->setStat( 0, 0, l_mass );
1297 trk->setMass( track.mass(), l_mass );
1298 trk->setChisq( track.chiSq(), 0, l_mass );
1299 trk->setNdf( track.nchits() - 5, 0, l_mass );
1300 trk->setNhits( track.nchits(), l_mass );
1301 // trkid
1302 trk->setTrackId( TrasanTRK.id );
1303
1304 if ( debug_ == 4 ) cout << " trasan id...1 " << TrasanTRK.id << endl;
1305
1306 trk->setFHelix( track.a(), l_mass );
1307 trk->setFError( track.Ea(), l_mass );
1308 }
1309 else
1310 {
1311
1312 // cout<<"copy Mdc Helix in fillTds_lead()"<<endl;
1313
1314 if ( debug_ ) cout << "ALARM: FillTds_forMdc Not refit with KalFilter!!!" << endl;
1315 // NOT refit with Kalman filter :
1316 trk->setStat( 1, 0, l_mass );
1317 trk->setMass( KalFitTrack::mass( l_mass ), l_mass );
1318
1319 // chisq & ndf
1320 trk->setChisq( TrasanTRK.chiSq, 0, l_mass );
1321 trk->setNdf( TrasanTRK.nhits - 5, 0, l_mass );
1322 // trkid
1323 trk->setTrackId( TrasanTRK.id );
1324
1325 if ( debug_ == 4 ) cout << " trasan id...2 " << TrasanTRK.id << endl;
1326
1327 // nhits
1328 trk->setNhits( TrasanTRK.nhits, l_mass );
1329 double a_trasan[5], ea_trasan[15];
1330 for ( int i = 0; i < 5; i++ ) { a_trasan[i] = TrasanTRK.helix[i]; }
1331 for ( int j = 0; j < 15; j++ ) { ea_trasan[j] = TrasanTRK.error[j]; }
1332 trk->setFHelix( a_trasan, l_mass );
1333 trk->setFError( ea_trasan, l_mass );
1334 // trk->setFHelix(TrasanTRK.helix,l_mass);
1335 // trk->setFError(TrasanTRK.error,l_mass);
1336 }
1337}

Referenced by complete_track(), and complete_track().

◆ filter_fwd_anal()

void KalFitAlg::filter_fwd_anal ( KalFitTrack & trk,
int l_mass,
int way,
HepSymMatrix & Eakal )

Kalman filter (forward) in Mdc.

get the doca from another other independent method

Definition at line 2657 of file KalFitAlg.cxx.

2658 {
2659
2660 // cout<<"**********************"<<endl;//wangll
2661 // cout<<"filter pid type "<<l_mass<<endl;//wangll
2662 // retrieve Mdc geometry information
2663
2664 IMdcGeomSvc* geomsvc;
2665 StatusCode sc = Gaudi::svcLocator()->service( "MdcGeomSvc", geomsvc );
2666 if ( sc == StatusCode::FAILURE ) cout << "GeoSvc failing!!!!!!!SC=" << sc << endl;
2667
2668 Hep3Vector x0inner( track.pivot() );
2669 HepVector pos_old( 3, 0 );
2670 double r0kal_prec( 0 );
2671 int nhits_read( 0 );
2672 int nhit = track.HitsMdc().size();
2673 if ( debug_ == 4 ) cout << "filter_fwd..........111 nhit=" << nhit << endl;
2674 for ( int i = 0; i < nhit; i++ )
2675 {
2676 KalFitHitMdc& HitMdc = track.HitMdc( i );
2677 // veto on some hits :
2678 if ( HitMdc.chi2() < 0 ) continue;
2679 const KalFitWire& Wire = HitMdc.wire();
2680 int layerf = Wire.layer().layerId();
2681
2682 // std::cout<<"in layer: "<<layerf<<std::endl;
2683
2684 int wireid = Wire.geoID();
2685 nhits_read++;
2686 HepPoint3D fwd( Wire.fwd() );
2687 HepPoint3D bck( Wire.bck() );
2688 Hep3Vector wire = (CLHEP::Hep3Vector)fwd - (CLHEP::Hep3Vector)bck;
2689 Helix work = *(Helix*)&track;
2690 work.ignoreErrorMatrix();
2691 work.pivot( ( fwd + bck ) * .5 );
2692
2693 // std::cout<<" (fwd + bck) * .5: "<<(fwd + bck)*.5<<std::endl;
2694 // std::cout<<" track.x(0): "<<track.x(0)<<std::endl;
2695 // std::cout<<" work.x(0): "<<work.x(0)<<std::endl;
2696 // std::cout<<" bck: "<<bck<<std::endl;
2697
2698 HepPoint3D x0kal = ( work.x( 0 ).z() - bck.z() ) / wire.z() * wire + bck;
2699
2700 if ( 4 == debug_ ) std::cout << " x0kal before sag: " << x0kal << std::endl;
2701
2702 // Modification to take account of the wire sag :
2703 /*
2704 if (wsag_==1) {
2705 double A(1.2402E-6);
2706 if (nhits_read != 1 && r0kal_prec > RMW && x0kal.perp() < RMW)
2707 A = 8.5265E-7;
2708 HepPoint3D x0kal_up(x0kal);
2709 double length = sqrt(wire.x()*wire.x()+wire.z()*wire.z());
2710 double zp = (x0kal.z() - bck.z())*length/wire.z();
2711
2712 x0kal_up.setX(wire.x()*(x0kal.z()-bck.z())/wire.z()+bck.x());
2713 x0kal_up.setY((A*(zp-length)+wire.y()/length)*zp+bck.y());
2714 double slopex = wire.x()/wire.z();
2715 double slopey = (A*(2*zp-length)*length+wire.y())/wire.z();
2716
2717 x0kal = x0kal_up;
2718 wire.setX(slopex);
2719 wire.setY(slopey);
2720 wire.setZ(1);
2721
2722 } else if (wsag_ == 2 || wsag_ == 3){
2723 double slopex = wire.x()/wire.z();
2724 double slopey(0), zinit(x0kal.z());
2725 double pos[3], yb_sag(0), yf_sag(0);
2726 int wire_ID = Wire.geoID();
2727 if (wsag_ == 2)
2728 calcdc_sag2_(&wire_ID, &zinit, pos, &slopey, &yb_sag, &yf_sag);
2729
2730 else
2731 calcdc_sag3_(&wire_ID, &zinit, pos, &slopey, &yb_sag, &yf_sag);
2732
2733 wire.setX(slopex);
2734 wire.setY(slopey);
2735 wire.setZ(1);
2736 x0kal.setX(pos[0]);
2737 x0kal.setY(pos[1]);
2738 } else
2739 */
2740
2741 if ( wsag_ == 4 )
2742 {
2743 Hep3Vector result;
2744 const MdcGeoWire* geowire = geomsvc->Wire( wireid );
2745 double tension = geowire->Tension();
2746 // std::cout<<" tension: "<<tension<<std::endl;
2747 double zinit( x0kal.z() ), lzx( Wire.lzx() );
2748 // double A(Wire.Acoef());
2749 double A = 47.35E-6 / tension;
2750 double Zp = ( zinit - bck.z() ) * lzx / wire.z();
2751
2752 if ( 4 == debug_ )
2753 {
2754 std::cout << " sag in filter_fwd_anal: " << std::endl;
2755 std::cout << " x0kal.x(): " << std::setprecision( 10 ) << x0kal.x() << std::endl;
2756 std::cout << "zinit: " << zinit << " bck.z(): " << bck.z() << std::endl;
2757 std::cout << " wire.x()*(zinit-bck.z())/wire.z(): " << std::setprecision( 10 )
2758 << ( wire.x() * ( zinit - bck.z() ) / wire.z() ) << std::endl;
2759 std::cout << "bck.x(): " << std::setprecision( 10 ) << bck.x() << std::endl;
2760 std::cout << " wire.x()*(zinit-bck.z())/wire.z() + bck.x(): "
2761 << std::setprecision( 10 )
2762 << ( wire.x() * ( zinit - bck.z() ) / wire.z() + bck.x() ) << std::endl;
2763 }
2764
2765 result.setX( wire.x() * ( zinit - bck.z() ) / wire.z() + bck.x() );
2766 result.setY( ( A * ( Zp - lzx ) + wire.y() / lzx ) * Zp + bck.y() );
2767 result.setZ( ( A * ( 2 * Zp - lzx ) * lzx + wire.y() ) / wire.z() );
2768
2769 wire.setX( wire.x() / wire.z() );
2770 wire.setY( result.z() );
2771 wire.setZ( 1 );
2772 x0kal.setX( result.x() );
2773 x0kal.setY( result.y() );
2774 }
2775
2776 if ( 4 == debug_ ) std::cout << " x0kal after sag: " << x0kal << std::endl;
2777
2778 // If x0kal is after the inner wall and x0kal_prec before :
2779 double r0kal = x0kal.perp();
2780
2781 // change PIVOT :
2782 double pathl( 0 );
2783
2784 track.pivot_numf( x0kal, pathl );
2785
2786 if ( nhits_read == 1 ) { track.Ea( Eakal ); }
2787 else
2788 {
2789 if ( KalFitElement::muls() ) track.msgasmdc( pathl, way );
2790 if ( KalFitElement::loss() ) track.eloss( pathl, _BesKalmanFitMaterials[0], way );
2791 }
2792
2793 double dtracknew = 0.;
2794 double dtrack = 0.;
2795 double dtdc = 0.;
2796 // Add info hit wire :
2797 if ( fabs( track.kappa() ) > 0 && fabs( track.kappa() ) < 1000.0 &&
2798 fabs( track.tanl() ) < 7.02 )
2799 {
2800 Hep3Vector meas = track.momentum( 0 ).cross( wire ).unit();
2801 double diff_chi2 = track.chiSq();
2802 Hep3Vector IP( 0, 0, 0 );
2803 Helix work_bef = *(Helix*)&track;
2804 work_bef.ignoreErrorMatrix();
2805 work_bef.pivot( IP );
2806 int inext( -1 );
2807 if ( i + 1 < nhit )
2808 for ( unsigned k = i + 1; k < nhit; k++ )
2809 if ( !( track.HitMdc( k ).chi2() < 0 ) )
2810 {
2811 inext = (signed)k;
2812 break;
2813 }
2814 double dchi2 = -1.0;
2815
2816 double chi2 = track.update_hits( HitMdc, inext, meas, way, dchi2, dtrack, dtracknew,
2817 dtdc, m_csmflag );
2818
2819 /// get the doca from another other independent method
2820
2821 /*
2822 std::cout<<" step0: "<<std::endl;
2823 KalFitTrack temp2(track);
2824 std::cout<<" step1: "<<std::endl;
2825
2826 Helix temp3(track.pivot(),track.a(),track.Ea());
2827 Helix temp4(track.pivot(),track.a(),track.Ea());
2828
2829 std::cout<<" step2: "<<std::endl;
2830 double doca25 = temp2.approach(HitMdc, false);
2831 std::cout<<" step3: "<<std::endl;
2832
2833 temp2.pivot(IP);
2834 std::cout<<" a2: "<<temp2.a()<<std::endl;
2835
2836 std::cout<<" step4: "<<std::endl;
2837
2838 double doca26 = temp3.approach(HitMdc, false);
2839 std::cout<<" another doca2.6: "<<doca26<<std::endl;
2840
2841 temp3.pivot(IP);
2842 std::cout<<" a3: "<<temp3.a()<<std::endl;
2843
2844 temp4.bFieldZ(-10);
2845 temp4.pivot(IP);
2846 std::cout<<" a4: "<<temp4.a()<<std::endl;
2847
2848 std::cout<<" step5: "<<std::endl;
2849
2850 double doca1 = track.approach(HitMdc, false);
2851 double doca2 = temp2.approach(HitMdc, false);
2852 double doca3 = temp3.approach(HitMdc, false);
2853 double doca4 = temp4.approach(HitMdc, false);
2854
2855 std::cout<<" dtrack: "<<dtrack<<std::endl;
2856 std::cout<<" another doca1: "<<doca1<<std::endl;
2857 std::cout<<" another doca2: "<<doca2<<std::endl;
2858 std::cout<<" another doca2.5: "<<doca25<<std::endl;
2859 std::cout<<" another doca3: "<<doca3<<std::endl;
2860 std::cout<<" another doca4: "<<doca4<<std::endl;
2861 */
2862
2863 if ( dchi2 < 0 ) { std::cout << " ... ERROR OF dchi2... " << std::endl; }
2864
2865 if ( ntuple_ & 8 )
2866 {
2867 m_dchi2 = dchi2;
2868 m_masshyp = l_mass;
2869 m_residest = dtrack - dtdc;
2870 m_residnew = dtracknew - dtdc;
2871 m_layer = Wire.layer().layerId();
2872 Helix worktemp = *(Helix*)&track;
2873 m_anal_dr = worktemp.a()[0];
2874 m_anal_phi0 = worktemp.a()[1];
2875 m_anal_kappa = worktemp.a()[2];
2876 m_anal_dz = worktemp.a()[3];
2877 m_anal_tanl = worktemp.a()[4];
2878 m_anal_ea_dr = worktemp.Ea()[0][0];
2879 m_anal_ea_phi0 = worktemp.Ea()[1][1];
2880 m_anal_ea_kappa = worktemp.Ea()[2][2];
2881 m_anal_ea_dz = worktemp.Ea()[3][3];
2882 m_anal_ea_tanl = worktemp.Ea()[4][4];
2883 StatusCode sc5 = m_nt5->write();
2884 if ( sc5.isFailure() ) cout << "Ntuple5 filling failed!" << endl;
2885 }
2886 Helix work_aft = *(Helix*)&track;
2887 work_aft.ignoreErrorMatrix();
2888 work_aft.pivot( IP );
2889 diff_chi2 = chi2 - diff_chi2;
2890 HitMdc.chi2( diff_chi2 );
2891 }
2892 r0kal_prec = r0kal;
2893 }
2894}
static int muls(void)
static int loss(void)
HepPoint3D x(double dPhi=0.) const
returns position after rotating angle dPhi in phi direction.

Referenced by complete_track(), kalman_fitting_anal(), and start_seed().

◆ filter_fwd_calib()

void KalFitAlg::filter_fwd_calib ( KalFitTrack & trk,
int l_mass,
int way,
HepSymMatrix & Eakal )

Definition at line 2896 of file KalFitAlg.cxx.

2897 {
2898
2899 // retrieve Mdc geometry information
2900 IMdcGeomSvc* geomsvc;
2901 StatusCode sc = Gaudi::svcLocator()->service( "MdcGeomSvc", geomsvc );
2902 if ( sc == StatusCode::FAILURE ) cout << "GeoSvc failing!!!!!!!SC=" << sc << endl;
2903
2904 if ( debug_ == 4 )
2905 {
2906 std::cout << "filter_fwd_calib starting ...the inital error Matirx is " << track.Ea()
2907 << std::endl;
2908 }
2909 Hep3Vector x0inner( track.pivot() );
2910 HepVector pos_old( 3, 0 );
2911 double r0kal_prec( 0 );
2912 int nhits_read( 0 );
2913
2914 unsigned int nhit = track.HitsMdc().size();
2915 if ( debug_ == 4 ) cout << "filter_fwd..........111 nhit=" << nhit << endl;
2916 for ( unsigned i = 0; i < nhit; i++ )
2917 {
2918
2919 KalFitHitMdc& HitMdc = track.HitMdc( i );
2920 if ( debug_ == 4 ) cout << "filter_fwd...........222 chi2=" << HitMdc.chi2() << endl;
2921 // veto on some hits :
2922 if ( HitMdc.chi2() < 0 ) continue;
2923 const KalFitWire& Wire = HitMdc.wire();
2924
2925 int wireid = Wire.geoID();
2926 nhits_read++;
2927
2928 // if (nhits_read == 1) track.Ea(Eakal);
2929 HepPoint3D fwd( Wire.fwd() );
2930 HepPoint3D bck( Wire.bck() );
2931 Hep3Vector wire = (CLHEP::Hep3Vector)fwd - (CLHEP::Hep3Vector)bck;
2932 Helix work = *(Helix*)&track;
2933 work.ignoreErrorMatrix();
2934 work.pivot( ( fwd + bck ) * .5 );
2935 HepPoint3D x0kal = ( work.x( 0 ).z() - bck.z() ) / wire.z() * wire + bck;
2936
2937 if ( 4 == debug_ ) std::cout << " x0kal before sag: " << x0kal << std::endl;
2938
2939 if ( wsag_ == 4 )
2940 {
2941 Hep3Vector result;
2942 const MdcGeoWire* geowire = geomsvc->Wire( wireid );
2943 double tension = geowire->Tension();
2944 // std::cout<<" tension: "<<tension<<std::endl;
2945 double zinit( x0kal.z() ), lzx( Wire.lzx() );
2946 // double A(Wire.Acoef());
2947 double A = 47.35E-6 / tension;
2948 double Zp = ( zinit - bck.z() ) * lzx / wire.z();
2949
2950 if ( 4 == debug_ )
2951 {
2952
2953 std::cout << " sag in filter_fwd_calib: " << std::endl;
2954 std::cout << " x0kal.x(): " << std::setprecision( 10 ) << x0kal.x() << std::endl;
2955 std::cout << " wire.x()*(zinit-bck.z())/wire.z(): " << std::setprecision( 10 )
2956 << ( wire.x() * ( zinit - bck.z() ) / wire.z() ) << std::endl;
2957 std::cout << "bck.x(): " << std::setprecision( 10 ) << bck.x() << std::endl;
2958 std::cout << " wire.x()*(zinit-bck.z())/wire.z() + bck.x(): "
2959 << std::setprecision( 10 )
2960 << ( wire.x() * ( zinit - bck.z() ) / wire.z() + bck.x() ) << std::endl;
2961 }
2962
2963 result.setX( wire.x() * ( zinit - bck.z() ) / wire.z() + bck.x() );
2964 result.setY( ( A * ( Zp - lzx ) + wire.y() / lzx ) * Zp + bck.y() );
2965 result.setZ( ( A * ( 2 * Zp - lzx ) * lzx + wire.y() ) / wire.z() );
2966 wire.setX( wire.x() / wire.z() );
2967 wire.setY( result.z() );
2968 wire.setZ( 1 );
2969 x0kal.setX( result.x() );
2970 x0kal.setY( result.y() );
2971 }
2972
2973 if ( 4 == debug_ ) std::cout << " x0kal after sag: " << x0kal << std::endl;
2974
2975 // If x0kal is after the inner wall and x0kal_prec before :
2976 double r0kal = x0kal.perp();
2977
2978 // change PIVOT :
2979 double pathl( 0 );
2980
2981 // std::cout<<" track a3: "<<track.a()<<std::endl;
2982 // std::cout<<" track p3: "<<sqrt(1.0+track.a()[4]*track.a()[4])/track.a()[2]<<std::endl;
2983
2984 if ( debug_ == 4 )
2985 cout << "*** move from " << track.pivot() << " ( Kappa = " << track.a()[2] << ")"
2986 << endl;
2987 track.pivot_numf( x0kal, pathl ); // see the code , the error matrix has been changed in
2988 // this function ..
2989
2990 // std::cout<<" track a4: "<<track.a()<<std::endl;
2991 // std::cout<<" track p4: "<<sqrt(1.0+track.a()[4]*track.a()[4])/track.a()[2]<<std::endl;
2992
2993 if ( debug_ == 4 )
2994 cout << "*** to " << track.pivot() << " ( Kappa = " << track.a()[2] << ")" << std::endl;
2995
2996 if ( nhits_read == 1 )
2997 {
2998 track.Ea( Eakal );
2999 if ( debug_ == 4 ) cout << "filter_fwd::Ea = " << track.Ea() << endl;
3000 }
3001 else
3002 {
3003 if ( KalFitElement::muls() ) track.msgasmdc( pathl, way );
3004 if ( KalFitElement::loss() ) track.eloss( pathl, _BesKalmanFitMaterials[0], way );
3005 }
3006
3007 // std::cout<<" track a5: "<<track.a()<<std::endl;
3008 // std::cout<<" track p5: "<<sqrt(1.0+track.a()[4]*track.a()[4])/track.a()[2]<<std::endl;
3009
3010 // Add info hit wire :
3011 if ( fabs( track.kappa() ) > 0 && fabs( track.kappa() ) < 1000.0 &&
3012 fabs( track.tanl() ) < 7.02 )
3013 {
3014 Hep3Vector meas = track.momentum( 0 ).cross( wire ).unit();
3015
3016 double diff_chi2 = track.chiSq();
3017
3018 Hep3Vector IP( 0, 0, 0 );
3019 Helix work_bef = *(Helix*)&track;
3020 work_bef.ignoreErrorMatrix();
3021 work_bef.pivot( IP );
3022 int inext( -1 );
3023 if ( i + 1 < nhit )
3024 for ( unsigned k = i + 1; k < nhit; k++ )
3025 if ( !( track.HitMdc( k ).chi2() < 0 ) )
3026 {
3027 inext = (signed)k;
3028 break;
3029 }
3030 double dchi2 = -1.0;
3031
3032 if ( debug_ == 4 )
3033 {
3034 std::cout << "the value of x0kal is " << x0kal << std::endl;
3035 std::cout << "the value of track.pivot() is " << track.pivot() << std::endl;
3036 }
3037
3038 HepVector Va( 5, 0 );
3039 HepSymMatrix Ma( 5, 0 );
3040 KalFitHelixSeg HelixSeg( &HitMdc, x0kal, Va, Ma );
3041
3042 if ( debug_ == 4 )
3043 {
3044 std::cout << "HelixSeg.Ea_pre_fwd() ..." << HelixSeg.Ea_pre_fwd() << std::endl;
3045 std::cout << "HelixSeg.a_pre_fwd() ..." << HelixSeg.a_pre_fwd() << std::endl;
3046 std::cout << "HelixSeg.Ea_filt_fwd() ..." << HelixSeg.Ea_filt_fwd() << std::endl;
3047 }
3048
3049 // std::cout<<" track a1: "<<track.a()<<std::endl;
3050 // std::cout<<" track p1: "<<sqrt(1.0+track.a()[4]*track.a()[4])/track.a()[2]<<std::endl;
3051
3052 double chi2 = 0.;
3053 if ( usage_ > 1 )
3054 chi2 = track.update_hits_csmalign( HelixSeg, inext, meas, way, dchi2, m_csmflag );
3055 else chi2 = track.update_hits( HelixSeg, inext, meas, way, dchi2, m_csmflag );
3056
3057 // std::cout<<" track a2: "<<track.a()<<std::endl;
3058 // std::cout<<" track p2: "<<sqrt(1.0+track.a()[4]*track.a()[4])/track.a()[2]<<std::endl;
3059
3060 if ( debug_ == 4 )
3061 cout << "layer, cell, dchi2,chi2, a, p: " << HitMdc.wire().layer().layerId() << " , "
3062 << HitMdc.wire().localId() << " , " << dchi2 << " , " << chi2 << " , "
3063 << track.a() << " , " << sqrt( 1.0 + track.a()[4] * track.a()[4] ) / track.a()[2]
3064 << endl;
3065
3066 if ( debug_ == 4 )
3067 cout << "****inext***" << inext << " !!!! dchi2= " << dchi2 << " chisq= " << chi2
3068 << endl;
3069
3070 if ( ntuple_ & 8 )
3071 {
3072 m_dchi2 = dchi2;
3073 m_masshyp = l_mass;
3074 StatusCode sc5 = m_nt5->write();
3075 if ( sc5.isFailure() ) cout << "Ntuple5 filling failed!" << endl;
3076 }
3077
3078 Helix work_aft = *(Helix*)&track;
3079 work_aft.ignoreErrorMatrix();
3080 work_aft.pivot( IP );
3081 diff_chi2 = chi2 - diff_chi2;
3082 HitMdc.chi2( diff_chi2 );
3083
3084 if ( debug_ == 4 )
3085 {
3086
3087 cout << " -> after include meas = " << meas << " at R = " << track.pivot().perp()
3088 << std::endl;
3089 cout << " chi2 = " << chi2 << ", diff_chi2 = " << diff_chi2
3090 << ", LR = " << HitMdc.LR() << ", stereo = " << HitMdc.wire().stereo()
3091 << ", layer = " << HitMdc.wire().layer().layerId() << std::endl;
3092 cout << "filter_fwd..........HitMdc.chi2... " << HitMdc.chi2() << endl;
3093 }
3094
3095 if ( dchi2 > 0.0 && ( way != 999 ) ) { track.HelixSegs().push_back( HelixSeg ); }
3096 }
3097 r0kal_prec = r0kal;
3098 }
3099}

Referenced by complete_track(), kalman_fitting_calib(), kalman_fitting_csmalign(), kalman_fitting_MdcxReco_Csmc_Sew(), and start_seed().

◆ finalize()

StatusCode KalFitAlg::finalize ( )

Definition at line 312 of file KalFitAlg.cxx.

312 {
313 MsgStream log( msgSvc(), name() );
314 log << MSG::DEBUG << "KalFitAlg:: nTotalTrks = " << nTotalTrks << endmsg;
315 log << MSG::DEBUG << " e: " << nFailedTrks[0] << " failed, "
316 << nTotalTrks - nFailedTrks[0] << " successed" << endmsg;
317 log << MSG::DEBUG << " mu: " << nFailedTrks[1] << " failed, "
318 << nTotalTrks - nFailedTrks[1] << " successed" << endmsg;
319 log << MSG::DEBUG << " pi: " << nFailedTrks[2] << " failed, "
320 << nTotalTrks - nFailedTrks[2] << " successed" << endmsg;
321 log << MSG::DEBUG << " K: " << nFailedTrks[3] << " failed, "
322 << nTotalTrks - nFailedTrks[3] << " successed" << endmsg;
323 log << MSG::DEBUG << " p: " << nFailedTrks[4] << " failed, "
324 << nTotalTrks - nFailedTrks[4] << " successed" << endmsg;
325 return StatusCode::SUCCESS;
326}

◆ getEventStarTime()

void KalFitAlg::getEventStarTime ( void )

◆ getWallMdcNumber()

int KalFitAlg::getWallMdcNumber ( const HepPoint3D & point)

◆ hist_def()

void KalFitAlg::hist_def ( void )

hist definition

Definition at line 363 of file KalFitAlg.cxx.

363 {
364 if ( ntuple_ & 1 )
365 {
366 NTuplePtr nt1( ntupleSvc(), "FILE104/n101" );
367 StatusCode status;
368 if ( nt1 ) m_nt1 = nt1;
369 else
370 {
371 m_nt1 = ntupleSvc()->book( "FILE104/n101", CLID_ColumnWiseTuple, "KalFit" );
372 if ( m_nt1 )
373 {
374
375 status = m_nt1->addItem( "trackid", m_trackid );
376 status = m_nt1->addItem( "stat", 5, 2, m_stat );
377 status = m_nt1->addItem( "ndf", 5, 2, m_ndf );
378 status = m_nt1->addItem( "chisq", 5, 2, m_chisq );
379 status = m_nt1->addItem( "length", 5, m_length );
380 status = m_nt1->addItem( "tof", 5, m_tof );
381 status = m_nt1->addItem( "nhits", 5, m_nhits );
382 status = m_nt1->addItem( "zhelix", 5, m_zhelix );
383 status = m_nt1->addItem( "zhelixe", 5, m_zhelixe );
384 status = m_nt1->addItem( "zhelixmu", 5, m_zhelixmu );
385 status = m_nt1->addItem( "zhelixk", 5, m_zhelixk );
386 status = m_nt1->addItem( "zhelixp", 5, m_zhelixp );
387 status = m_nt1->addItem( "zptot", m_zptot );
388 status = m_nt1->addItem( "zptote", m_zptote );
389 status = m_nt1->addItem( "zptotmu", m_zptotmu );
390 status = m_nt1->addItem( "zptotk", m_zptotk );
391 status = m_nt1->addItem( "zptotp", m_zptotp );
392
393 status = m_nt1->addItem( "zpt", m_zpt );
394 status = m_nt1->addItem( "zpte", m_zpte );
395 status = m_nt1->addItem( "zptmu", m_zptmu );
396 status = m_nt1->addItem( "zptk", m_zptk );
397 status = m_nt1->addItem( "zptp", m_zptp );
398
399 status = m_nt1->addItem( "fptot", m_fptot );
400 status = m_nt1->addItem( "fptote", m_fptote );
401 status = m_nt1->addItem( "fptotmu", m_fptotmu );
402 status = m_nt1->addItem( "fptotk", m_fptotk );
403 status = m_nt1->addItem( "fptotp", m_fptotp );
404 status = m_nt1->addItem( "fpt", m_fpt );
405 status = m_nt1->addItem( "fpte", m_fpte );
406 status = m_nt1->addItem( "fptmu", m_fptmu );
407 status = m_nt1->addItem( "fptk", m_fptk );
408 status = m_nt1->addItem( "fptp", m_fptp );
409
410 status = m_nt1->addItem( "lptot", m_lptot );
411 status = m_nt1->addItem( "lptote", m_lptote );
412 status = m_nt1->addItem( "lptotmu", m_lptotmu );
413 status = m_nt1->addItem( "lptotk", m_lptotk );
414 status = m_nt1->addItem( "lptotp", m_lptotp );
415 status = m_nt1->addItem( "lpt", m_lpt );
416 status = m_nt1->addItem( "lpte", m_lpte );
417 status = m_nt1->addItem( "lptmu", m_lptmu );
418 status = m_nt1->addItem( "lptk", m_lptk );
419 status = m_nt1->addItem( "lptp", m_lptp );
420
421 status = m_nt1->addItem( "zsigp", m_zsigp );
422 status = m_nt1->addItem( "zsigpe", m_zsigpe );
423 status = m_nt1->addItem( "zsigpmu", m_zsigpmu );
424 status = m_nt1->addItem( "zsigpk", m_zsigpk );
425 status = m_nt1->addItem( "zsigpp", m_zsigpp );
426 status = m_nt1->addItem( "fhelix", 5, m_fhelix );
427 status = m_nt1->addItem( "fhelixe", 5, m_fhelixe );
428 status = m_nt1->addItem( "fhelixmu", 5, m_fhelixmu );
429 status = m_nt1->addItem( "fhelixk", 5, m_fhelixk );
430 status = m_nt1->addItem( "fhelixp", 5, m_fhelixp );
431 status = m_nt1->addItem( "lhelix", 5, m_lhelix );
432 status = m_nt1->addItem( "lhelixe", 5, m_lhelixe );
433 status = m_nt1->addItem( "lhelixmu", 5, m_lhelixmu );
434 status = m_nt1->addItem( "lhelixk", 5, m_lhelixk );
435 status = m_nt1->addItem( "lhelixp", 5, m_lhelixp );
436 if ( ntuple_ & 32 )
437 {
438 status = m_nt1->addItem( "zerror", 15, m_zerror );
439 status = m_nt1->addItem( "zerrore", 15, m_zerrore );
440 status = m_nt1->addItem( "zerrormu", 15, m_zerrormu );
441 status = m_nt1->addItem( "zerrork", 15, m_zerrork );
442 status = m_nt1->addItem( "zerrorp", 15, m_zerrorp );
443 status = m_nt1->addItem( "ferror", 15, m_ferror );
444 status = m_nt1->addItem( "ferrore", 15, m_ferrore );
445 status = m_nt1->addItem( "ferrormu", 15, m_ferrormu );
446 status = m_nt1->addItem( "ferrork", 15, m_ferrork );
447 status = m_nt1->addItem( "ferrorp", 15, m_ferrorp );
448 status = m_nt1->addItem( "lerror", 15, m_lerror );
449 status = m_nt1->addItem( "lerrore", 15, m_lerrore );
450 status = m_nt1->addItem( "lerrormu", 15, m_lerrormu );
451 status = m_nt1->addItem( "lerrork", 15, m_lerrork );
452 status = m_nt1->addItem( "lerrorp", 15, m_lerrorp );
453 }
454 if ( ( ntuple_ & 16 ) && ( ntuple_ & 1 ) )
455 {
456 status = m_nt1->addItem( "evtid", m_evtid );
457 status = m_nt1->addItem( "mchelix", 5, m_mchelix );
458 status = m_nt1->addItem( "mcptot", m_mcptot );
459 status = m_nt1->addItem( "mcpid", m_mcpid );
460 }
461 if ( status.isFailure() ) cout << "Ntuple1 add item failed!" << endl;
462 }
463 }
464 }
465
466 if ( ntuple_ & 4 )
467 {
468 NTuplePtr nt2( ntupleSvc(), "FILE104/n102" );
469 StatusCode status2;
470 if ( nt2 ) m_nt2 = nt2;
471 else
472 {
473 m_nt2 = ntupleSvc()->book( "FILE104/n102", CLID_ColumnWiseTuple, "KalFitComp" );
474 if ( m_nt2 )
475 {
476 status2 = m_nt2->addItem( "delx", m_delx );
477 status2 = m_nt2->addItem( "dely", m_dely );
478 status2 = m_nt2->addItem( "delz", m_delz );
479 status2 = m_nt2->addItem( "delthe", m_delthe );
480 status2 = m_nt2->addItem( "delphi", m_delphi );
481 status2 = m_nt2->addItem( "delp", m_delp );
482 status2 = m_nt2->addItem( "delpx", m_delpx );
483 status2 = m_nt2->addItem( "delpy", m_delpy );
484 status2 = m_nt2->addItem( "delpz", m_delpz );
485
486 if ( status2.isFailure() ) cout << "Ntuple2 add item failed!" << endl;
487 }
488 }
489 }
490
491 if ( ntuple_ & 2 )
492 {
493 NTuplePtr nt3( ntupleSvc(), "FILE104/n103" );
494 StatusCode status3;
495 if ( nt3 ) m_nt3 = nt3;
496 else
497 {
498 m_nt3 = ntupleSvc()->book( "FILE104/n103", CLID_ColumnWiseTuple, "PatRec" );
499 if ( m_nt3 )
500 {
501 status3 = m_nt3->addItem( "trkhelix", 5, m_trkhelix );
502 status3 = m_nt3->addItem( "trkptot", m_trkptot );
503 if ( ntuple_ & 32 )
504 {
505 status3 = m_nt3->addItem( "trkerror", 15, m_trkerror );
506 status3 = m_nt3->addItem( "trksigp", m_trksigp );
507 }
508 status3 = m_nt3->addItem( "trkndf", m_trkndf );
509 status3 = m_nt3->addItem( "trkchisq", m_trkchisq );
510 if ( status3.isFailure() ) cout << "Ntuple3 add item failed!" << endl;
511 }
512 }
513 }
514
515 if ( ntuple_ & 4 )
516 {
517 NTuplePtr nt4( ntupleSvc(), "FILE104/n104" );
518 StatusCode status4;
519 if ( nt4 ) m_nt4 = nt4;
520 else
521 {
522 m_nt4 = ntupleSvc()->book( "FILE104/n104", CLID_ColumnWiseTuple, "PatRecComp" );
523 if ( m_nt4 )
524 {
525 status4 = m_nt4->addItem( "trkdelx", m_trkdelx );
526 status4 = m_nt4->addItem( "trkdely", m_trkdely );
527 status4 = m_nt4->addItem( "trkdelz", m_trkdelz );
528 status4 = m_nt4->addItem( "trkdelthe", m_trkdelthe );
529 status4 = m_nt4->addItem( "trkdelphi", m_trkdelphi );
530 status4 = m_nt4->addItem( "trkdelp", m_trkdelp );
531 if ( status4.isFailure() ) cout << "Ntuple4 add item failed!" << endl;
532 }
533 }
534 }
535 if ( ntuple_ & 8 )
536 {
537 NTuplePtr nt5( ntupleSvc(), "FILE104/n105" );
538 StatusCode status5;
539 if ( nt5 ) m_nt5 = nt5;
540 else
541 {
542 m_nt5 = ntupleSvc()->book( "FILE104/n105", CLID_ColumnWiseTuple, "KalFitdChisq" );
543 if ( m_nt5 )
544 {
545 status5 = m_nt5->addItem( "dchi2", m_dchi2 );
546 status5 = m_nt5->addItem( "masshyp", m_masshyp );
547 status5 = m_nt5->addItem( "residual_estim", m_residest );
548 status5 = m_nt5->addItem( "residual", m_residnew );
549 status5 = m_nt5->addItem( "layer", m_layer );
550 status5 = m_nt5->addItem( "kaldr", m_anal_dr );
551 status5 = m_nt5->addItem( "kalphi0", m_anal_phi0 );
552 status5 = m_nt5->addItem( "kalkappa", m_anal_kappa );
553 status5 = m_nt5->addItem( "kaldz", m_anal_dz );
554 status5 = m_nt5->addItem( "kaltanl", m_anal_tanl );
555 status5 = m_nt5->addItem( "dr_ea", m_anal_ea_dr );
556 status5 = m_nt5->addItem( "phi0_ea", m_anal_ea_phi0 );
557 status5 = m_nt5->addItem( "kappa_ea", m_anal_ea_kappa );
558 status5 = m_nt5->addItem( "dz_ea", m_anal_ea_dz );
559 status5 = m_nt5->addItem( "tanl_ea", m_anal_ea_tanl );
560 if ( status5.isFailure() ) cout << "Ntuple5 add item failed!" << endl;
561 }
562 }
563 NTuplePtr nt6( ntupleSvc(), "FILE104/n106" );
564 StatusCode status6;
565 if ( nt6 ) m_nt6 = nt6;
566 else
567 {
568 m_nt6 = ntupleSvc()->book( "FILE104/n106", CLID_ColumnWiseTuple, "kal seg" );
569 if ( m_nt6 )
570 {
571 status6 = m_nt6->addItem( "docaInc", m_docaInc );
572 status6 = m_nt6->addItem( "docaExc", m_docaExc );
573 status6 = m_nt6->addItem( "tdr", m_tdrift );
574 status6 = m_nt6->addItem( "layerid", m_layerid );
575 status6 = m_nt6->addItem( "event", m_eventNo );
576 status6 = m_nt6->addItem( "residualInc", m_residualInc );
577 status6 = m_nt6->addItem( "residualExc", m_residualExc );
578 status6 = m_nt6->addItem( "lr", m_lr );
579 status6 = m_nt6->addItem( "dd", m_dd );
580 status6 = m_nt6->addItem( "y", m_yposition );
581
582 if ( status6.isFailure() ) cout << "Ntuple6 add item failed!" << endl;
583 }
584 }
585 }
586}
INTupleSvc * ntupleSvc()

Referenced by initialize().

◆ init_matrix() [1/2]

void KalFitAlg::init_matrix ( int k,
MdcRec_trk & trk,
HepSymMatrix & Ea )

Definition at line 5869 of file KalFitAlg.cxx.

5869 {
5870 if ( 0 == k )
5871 {
5872 for ( int i = 0; i < 5; i++ )
5873 {
5874 for ( int j = 1; j < i + 2; j++ )
5875 {
5876 Eakal( i + 1, j ) = matrixg_ * ( trk.error[i * ( i + 1 ) / 2 + j - 1] );
5877 Eakal( j, i + 1 ) = Eakal( i + 1, j );
5878 }
5879 Eakal( 1, 1 ) = Eakal( 1, 1 ) * gain1_;
5880 Eakal( 2, 2 ) = Eakal( 2, 2 ) * gain2_;
5881 Eakal( 3, 3 ) = Eakal( 3, 3 ) * gain3_;
5882 Eakal( 4, 4 ) = Eakal( 4, 4 ) * gain4_;
5883 Eakal( 5, 5 ) = Eakal( 5, 5 ) * gain5_;
5884 }
5885 }
5886 // HepSymMatrix ea_temp(5);
5887 // for(int i = 0, k = 0; i < 5; i++) {
5888 // for(int j = 0; j <= i; j++) {
5889 // ea_temp[i][j] = matrixg_*trk.error[k++];
5890 // ea_temp[j][i] = ea_temp[i][j];
5891 // }
5892 // }
5893
5894 if ( 1 == k )
5895 {
5896 Eakal( 1, 1 ) = .2;
5897 Eakal( 2, 2 ) = .001;
5898 Eakal( 3, 3 ) = 1.0;
5899 Eakal( 4, 4 ) = 10.0;
5900 Eakal( 5, 5 ) = 0.002;
5901 }
5902
5903 if ( 2 == k )
5904 {
5905 Eakal( 1, 1 ) = .2;
5906 Eakal( 2, 2 ) = 0.1;
5907 Eakal( 3, 3 ) = 1.0;
5908 Eakal( 4, 4 ) = 25.0;
5909 Eakal( 5, 5 ) = 0.10;
5910 }
5911
5912 if ( 3 == k )
5913 {
5914 Eakal( 1, 1 ) = .2;
5915 Eakal( 2, 2 ) = .001;
5916 Eakal( 3, 3 ) = 1.0;
5917 Eakal( 4, 4 ) = 25.0;
5918 Eakal( 5, 5 ) = 0.10;
5919 }
5920
5921 if ( 4 == k )
5922 {
5923 Eakal( 1, 1 ) = .2;
5924 Eakal( 2, 2 ) = .01;
5925 Eakal( 3, 3 ) = 0.01;
5926 Eakal( 4, 4 ) = 1.;
5927 Eakal( 5, 5 ) = .01;
5928 }
5929
5930 if ( 5 == k )
5931 {
5932 Eakal( 1, 1 ) = 2.;
5933 Eakal( 2, 2 ) = 0.1;
5934 Eakal( 3, 3 ) = 1.;
5935 Eakal( 4, 4 ) = 20.;
5936 Eakal( 5, 5 ) = 0.1;
5937 }
5938
5939 if ( 6 == k )
5940 {
5941 Eakal( 1, 1 ) = 0.01;
5942 Eakal( 2, 2 ) = 0.01;
5943 Eakal( 3, 3 ) = 0.01;
5944 Eakal( 4, 4 ) = 100.;
5945 Eakal( 5, 5 ) = 0.5;
5946 }
5947
5948 if ( k != 0 )
5949 {
5950 Eakal( 3, 3 ) = 0.2;
5951 Eakal( 1, 1 ) = 1;
5952 Eakal( 4, 4 ) = 1;
5953 }
5954
5955 if ( debug_ == 4 ) cout << "initialised Eakal.. " << Eakal << endl;
5956}

◆ init_matrix() [2/2]

void KalFitAlg::init_matrix ( MdcRec_trk & trk,
HepSymMatrix & Ea )

Definition at line 5856 of file KalFitAlg.cxx.

5856 {
5857 for ( int i = 0; i < 5; i++ )
5858 {
5859 for ( int j = 1; j < i + 2; j++ )
5860 {
5861 Eakal( i + 1, j ) = matrixg_ * ( trk.error[i * ( i + 1 ) / 2 + j - 1] );
5862 Eakal( j, i + 1 ) = Eakal( i + 1, j );
5863 }
5864 }
5865
5866 if ( debug_ == 4 ) cout << "initialised Ea.. " << Eakal << endl;
5867}

Referenced by complete_track(), complete_track(), kalman_fitting_anal(), kalman_fitting_calib(), kalman_fitting_csmalign(), kalman_fitting_MdcxReco_Csmc_Sew(), and start_seed().

◆ initialize()

StatusCode KalFitAlg::initialize ( )

initialize

Definition at line 203 of file KalFitAlg.cxx.

203 {
204 MsgStream log( msgSvc(), name() );
205 log << MSG::INFO << "in initize()"
206 << "KalFit> Initialization for current run " << endmsg;
207 log << MSG::INFO << "Present Parameters: muls: " << muls_ << " loss: " << loss_
208 << " matrixg " << matrixg_ << " lr " << lr_ << " debug " << debug_ << " ntuple "
209 << ntuple_ << " activeonly " << activeonly_ << endmsg;
210
225
226 setDchisqCut();
227 // Delete properly the geometry objects if already existing
228 clean();
229 log << MSG::INFO << ".....building Mdc " << endmsg;
230
231 // Set objects and material properties for Mdc detector :
232 // setMaterial_Mdc();
233 // setCylinder_Mdc();
234
236 // initialize the MdcCalibFunSvc
238 //
239 // // initialize the MdcGeomSvc
240 // setGeomSvc_init();
241 // getEventStarTime();
242 // // Wires, Layers and SuperLayers of Mdc :
243 // set_Mdc();
244 // define histograms and Ntuples
245 hist_def();
246
247 IBesMagFieldSvc* IMFSvc;
248 StatusCode sc = service( "MagneticFieldSvc", IMFSvc );
249 if ( sc != StatusCode::SUCCESS )
250 { log << MSG::ERROR << "Unable to open Magnetic field service" << endmsg; }
252
253 // Nominal magnetic field :
255 {
256 KalFitTrack::Bznom_ = ( IMFSvc->getReferField() ) * 10000; // unit is KGauss
258
259 if ( 4 == debug_ )
260 {
261 std::cout << " initialize, referField from MagneticFieldSvc: "
262 << ( IMFSvc->getReferField() ) * 10000 << std::endl;
263 std::cout << " magnetic field: " << KalFitTrack::Bznom_ << std::endl;
264 }
265 }
266
267 // Print out of the status of the flags :
268 if ( ntuple_ ) log << MSG::INFO << " ntuple out, the option is " << ntuple_ << endmsg;
269 if ( debug_ > 0 )
270 {
271 cout << "KalFitAlg> DEBUG open,Here is the important Parameters :\n";
272 cout << " Leading particule with mass hyp = " << lead_ << std::endl;
273 cout << " mhyp = " << mhyp_ << std::endl;
274 cout << "===== Effects taking into account : " << std::endl;
275 cout << " - multiple scattering = " << muls_ << std::endl;
276 cout << " - energy loss = " << loss_ << std::endl;
277 if ( KalFitTrack::strag_ ) cout << " - straggling for the energy loss " << std::endl;
278 cout << " - nominal Bz value = " << KalFitTrack::Bznom_ << std::endl;
279
280 if ( KalFitTrack::numf_ > 19 )
281 cout << " - non uniform magnetic field treatment " << KalFitTrack::numf_ << std::endl;
282 cout << " - wire sag correction = " << wsag_ << std::endl;
283 cout << " - Tof correction = " << KalFitTrack::Tof_correc_ << std::endl;
284 cout << " - chi2 cut for each hit = " << KalFitTrack::chi2_hitf_ << std::endl
285 << " is applied after " << KalFitTrack::nmdc_hit2_ << " hits included " << std::endl;
286
287 if ( back_ ) { cout << " Backward filter is on with a pT cut value = " << pT_ << endl; }
288 if ( debug_ == 4 ) cout << " pathl = " << pathl_ << std::endl;
289
290 if ( KalFitTrack::LR_ == 1 ) cout << " Decision L/R from MdcRecHit " << std::endl;
291 }
292
298 // Get the Particle Properties Service
299 IPartPropSvc* p_PartPropSvc;
300 static const bool CREATEIFNOTTHERE( true );
301 StatusCode PartPropStatus = service( "PartPropSvc", p_PartPropSvc, CREATEIFNOTTHERE );
302 if ( !PartPropStatus.isSuccess() || 0 == p_PartPropSvc )
303 {
304 log << MSG::WARNING << " Could not initialize Particle Properties Service" << endmsg;
305 return StatusCode::SUCCESS;
306 }
307 m_particleTable = p_PartPropSvc->PDT();
308
309 return StatusCode::SUCCESS;
310}
void setCalibSvc_init(void)
initialize for the services
void setBesFromGdml(void)
void setDchisqCut(void)
void hist_def(void)
hist definition
static int lead(void)
Magnetic field map.
static int back(void)
static double factor_strag_
factor of energy loss straggling for electron
static int numf_
Flag for treatment of non-uniform mag field.
static int tprop_
for signal propagation correction
static int resol(void)
static void LR(int x)
static int numf(void)
static void setMagneticFieldSvc(IBesMagFieldSvc *)
static int LR_
Use L/R decision from MdcRecHit information :
static int strag_
Flag to take account of energy loss straggling :

◆ innerwall()

void KalFitAlg::innerwall ( KalFitTrack & trk,
int l_mass,
int way )

Take the inner walls (eloss and mult scat) into account.

Definition at line 3102 of file KalFitAlg.cxx.

3102 {
3103
3104 if ( debug_ == 4 ) cout << "innerwall....." << endl;
3105 for ( int i = 0; i < _BesKalmanFitWalls.size(); i++ )
3106 {
3107 _BesKalmanFitWalls[i].updateTrack( track, way );
3108 if ( debug_ == 4 ) cout << "Wall " << i << " update the track!(filter)" << endl;
3109 }
3110}

Referenced by complete_track(), and complete_track().

◆ kalman_fitting_anal()

void KalFitAlg::kalman_fitting_anal ( void )

very low momentum and very big costheta angle, use special initial error matrix

chose different initial error matrix

Definition at line 3116 of file KalFitAlg.cxx.

3116 {
3117
3118 // cout<<"kalman_fitting_anal deal with a new event"<<endl;//wangll
3119
3120 MsgStream log( msgSvc(), name() );
3121 double Pt_threshold( 0.3 );
3122 Hep3Vector IP( 0, 0, 0 );
3123 vector<MdcRec_trk>* mdcMgr = MdcRecTrkCol::getMdcRecTrkCol();
3124 vector<MdcRec_trk_add>* mdc_addMgr = MdcRecTrkAddCol::getMdcRecTrkAddCol();
3125 vector<MdcRec_wirhit>* whMgr = MdcRecWirhitCol::getMdcRecWirhitCol();
3126
3127 // Table Manager
3128 if ( !&whMgr ) return;
3129
3130 // Get reduced chi**2 of Mdc track :
3131 int ntrk = mdcMgr->size();
3132 double* rPt = new double[ntrk];
3133 int* rOM = new int[ntrk];
3134 unsigned int* order = new unsigned int[ntrk];
3135 unsigned int* rCont = new unsigned int[ntrk];
3136 unsigned int* rGen = new unsigned int[ntrk];
3137
3138 int index = 0;
3139 for ( vector<MdcRec_trk>::iterator it = mdcMgr->begin(), end = mdcMgr->end(); it != end;
3140 it++ )
3141 {
3142 // Pt
3143 rPt[index] = 0;
3144 if ( it->helix[2] ) rPt[index] = 1 / fabs( it->helix[2] );
3145 if ( debug_ == 4 ) cout << "rPt...[ " << index << " ]...." << rPt[index] << endl;
3146 if ( rPt[index] < 0 ) rPt[index] = DBL_MAX;
3147 // Outermost layer
3148 std::vector<MdcRec_wirhit*> pt = it->hitcol;
3149 if ( debug_ == 4 ) cout << "ppt size: " << pt.size() << endl;
3150 int outermost( -1 );
3151 for ( vector<MdcRec_wirhit*>::iterator ii = pt.end() - 1; ii != pt.begin() - 1; ii-- )
3152 {
3153 int lyr( ( *ii )->geo->Lyr()->Id() );
3154 if ( outermost < lyr ) outermost = lyr;
3155 if ( debug_ == 4 ) cout << "outmost: " << outermost << " lyr: " << lyr << endl;
3156 }
3157 rOM[index] = outermost;
3158 order[index] = index;
3159 ++index;
3160 }
3161
3162 // Sort Mdc tracks by Pt
3163 for ( int j, k = ntrk - 1; k >= 0; k = j )
3164 {
3165 j = -1;
3166 for ( int i = 1; i <= k; i++ )
3167 if ( rPt[i - 1] < rPt[i] )
3168 {
3169 j = i - 1;
3170 std::swap( order[i], order[j] );
3171 std::swap( rPt[i], rPt[j] );
3172 std::swap( rOM[i], rOM[j] );
3173 std::swap( rCont[i], rCont[j] );
3174 std::swap( rGen[i], rGen[j] );
3175 }
3176 }
3177 delete[] rPt;
3178
3179 //
3180 int newcount( 0 );
3181 // check whether Recon already registered
3182 DataObject* aReconEvent;
3183 eventSvc()->findObject( "/Event/Recon", aReconEvent );
3184 if ( !aReconEvent )
3185 {
3186 // register ReconEvent Data Object to TDS;
3187 ReconEvent* recevt = new ReconEvent;
3188 StatusCode sc = eventSvc()->registerObject( "/Event/Recon", recevt );
3189 if ( sc != StatusCode::SUCCESS )
3190 {
3191 log << MSG::FATAL << "Could not register ReconEvent" << endmsg;
3192 return;
3193 }
3194 }
3195
3198 // make RecMdcKalTrackCol
3199 log << MSG::INFO << "beginning to make RecMdcKalTrackCol" << endmsg;
3200 // Loop over tracks given by trasan :
3201 for ( int l = 0; l < ntrk; l++ )
3202 {
3203
3204 // cout<<"----------------"<<endl;//wangll
3205 // cout<<"track "<<l<<" : "<<endl;//wangll
3206
3207 nTotalTrks++;
3208
3209 for ( int i = 0; i < 5; i++ ) iqual_front_[i] = 1; // wangll 2010-11-01
3210
3211 // m_timer[3]->start();
3212 MdcRec_trk& TrasanTRK = *( mdcMgr->begin() + order[l] );
3213 MdcRec_trk_add& TrasanTRK_add = *( mdc_addMgr->begin() + order[l] );
3214
3215 // Reject the ones with quality != 0
3216 int trasqual = TrasanTRK_add.quality;
3217 if ( debug_ == 4 ) cout << "kalman_fitting>trasqual... " << trasqual << endl;
3218 if ( trasqual ) continue;
3219
3220 newcount++;
3221 if ( debug_ == 4 ) cout << "******* KalFit NUMBER : " << newcount << std::endl;
3222
3223 // What kind of KalFit ?
3224 int type( 0 );
3225 if ( ( TrasanTRK_add.decision & 32 ) == 32 || ( TrasanTRK_add.decision & 64 ) == 64 )
3226 type = 1;
3227
3228 // Initialisation : (x, a, ea)
3229 HepPoint3D x( TrasanTRK.pivot[0], TrasanTRK.pivot[1], TrasanTRK.pivot[2] );
3230
3231 HepVector a( 5 );
3232 for ( int i = 0; i < 5; i++ ) a[i] = TrasanTRK.helix[i];
3233
3234 HepSymMatrix ea( 5 );
3235 for ( int i = 0, k = 0; i < 5; i++ )
3236 {
3237 for ( int j = 0; j <= i; j++ )
3238 {
3239 ea[i][j] = matrixg_ * TrasanTRK.error[k++];
3240 ea[j][i] = ea[i][j];
3241 }
3242 }
3243 double fiTerm = TrasanTRK.fiTerm;
3244 int way( 1 );
3245 // Prepare the track found :
3246 KalFitTrack track_lead = KalFitTrack( x, a, ea, lead_, 0, 0 );
3247
3248 track_lead.bFieldZ( KalFitTrack::Bznom_ );
3249
3250 // Mdc Hits
3251 int inlyr( 999 ), outlyr( -1 );
3252 int* rStat = new int[43];
3253 for ( int irStat = 0; irStat < 43; ++irStat ) rStat[irStat] = 0;
3254 std::vector<MdcRec_wirhit*> pt = TrasanTRK.hitcol;
3255 int hit_in( 0 );
3256 if ( debug_ == 4 ) cout << "*********Pt size****" << pt.size() << endl;
3257 // Number of hits/layer
3258 int Num[43] = { 0 };
3259 for ( vector<MdcRec_wirhit*>::iterator ii = pt.end() - 1; ii != pt.begin() - 1; ii-- )
3260 { Num[( *ii )->geo->Lyr()->Id()]++; }
3261 int hit_asso( 0 );
3262 for ( vector<MdcRec_wirhit*>::iterator ii = pt.end() - 1; ii != pt.begin() - 1; ii-- )
3263 {
3264 hit_asso++;
3265 if ( Num[( *ii )->geo->Lyr()->Id()] > 3 )
3266 {
3267 if ( debug_ > 0 )
3268 cout << "WARNING: I found " << Num[( *ii )->geo->Lyr()->Id()]
3269 << " hits in the layer " << ( *ii )->geo->Lyr()->Id() << std::endl;
3270 continue;
3271 }
3272 // if(ii!=pt.end()-1){
3273 // int layer_before=(*(ii+1))->geo->Lyr()->Id();
3274 // if(layer_before == (*ii)->geo->Lyr()->Id()){
3275 // MdcRec_wirhit * rechit_before = *(ii+1);
3276 // if((*rechit_before).rechitptr->getDriftT()>450 ||
3277 //(**ii).rechitptr->getDriftT()>450.){
3278 // if((*rechit_before).tdc < (**ii).tdc) continue; else
3279 // if(track_lead.HitsMdc().size()>0
3280 //&& rStat[layer_before]){
3281 // track_lead.HitsMdc().pop_back();
3282 // }
3283 // }
3284 // }
3285 // }
3286
3287 hit_in++;
3288 MdcRec_wirhit& rechit = **ii;
3289 double dist[2] = { rechit.ddl, rechit.ddr };
3290 double erdist[2] = { rechit.erddl, rechit.erddr };
3291 const MdcGeoWire* geo = rechit.geo;
3292
3293 int lr_decision( 0 );
3294 if ( KalFitTrack::LR_ == 1 )
3295 {
3296 if ( rechit.lr == 2 || rechit.lr == 0 ) lr_decision = -1;
3297 // if (rechit.lr==0) lr_decision=-1;
3298 else if ( rechit.lr == 1 ) lr_decision = 1;
3299 }
3300
3301 int ind( geo->Lyr()->Id() );
3302
3303 // ATTENTION HERE!!!
3304 track_lead.appendHitsMdc( KalFitHitMdc( rechit.id, lr_decision, rechit.tdc, dist, erdist,
3305 _wire + ( geo->Id() ), rechit.rechitptr ) );
3306 // inner/outer layer :
3307 rStat[ind]++;
3308 if ( inlyr > ind ) inlyr = ind;
3309 if ( outlyr < ind ) outlyr = ind;
3310 }
3311 if ( debug_ == 4 ) cout << "**** NUMBER OF Mdc HITS (TRASAN) = " << hit_asso << std::endl;
3312
3313 // Empty layers :
3314 int empty_between( 0 ), empty( 0 );
3315 for ( int i = inlyr; i <= outlyr; i++ )
3316 if ( !rStat[i] ) empty_between++;
3317 empty = empty_between + inlyr + ( 42 - outlyr );
3318 delete[] rStat;
3319
3320 // RMK high momentum track under study, probably not neeeded...
3321 track_lead.order_wirhit( 1 );
3322 // track_lead.order_hits();
3323
3324 for ( std::vector<KalFitHitMdc>::iterator it_hit = track_lead.HitsMdc().begin();
3325 it_hit != track_lead.HitsMdc().end(); it_hit++ )
3326 {
3327 // std::cout<<" the id of this hits after sorting in PatRec is
3328 // "<<it_hit->id()<<std::endl; std::cout<<" the layerid of the hit is
3329 // "<<it_hit->wire().layer().layerId()<<std::endl; std::cout<<" the cellid of this wire
3330 // is "<<it_hit->wire().localId()<<std::endl;
3331 }
3332
3333 track_lead.type( type );
3334 unsigned int nhit = track_lead.HitsMdc().size();
3335 if ( !nhit && debug_ == 4 )
3336 {
3337 cout << " ATTENTION TRACK WITH ONLY HITS " << nhit << std::endl;
3338 continue;
3339 }
3340
3341 // Initialisation :
3342 double KalFitst( 0 ), KalFitax( 0 ), KalFitschi2( 0 );
3343 // Move to the outer hit :
3344
3345 Hep3Vector outer_pivot( track_lead.x( fiTerm ) );
3346
3347 track_lead.pivot( outer_pivot );
3348
3349 track_lead.bFieldZ( KalFitTrack::Bznom_ );
3350 // attention best_chi2 reinitialize !!!
3351 if ( nhit >= 3 && !KalFitTrack::LR_ ) start_seed( track_lead, lead_, way, TrasanTRK );
3352 HepSymMatrix Eakal( 5, 0 );
3353
3354 /// very low momentum and very big costheta angle, use special initial error matrix
3355 double costheta = track_lead.a()[4] / sqrt( 1.0 + track_lead.a()[4] * track_lead.a()[4] );
3356 if ( ( 1.0 / fabs( track_lead.a()[2] ) < pt_cut_ ) && ( fabs( costheta ) > theta_cut_ ) )
3357 { choice_ = 6; }
3358
3359 /// chose different initial error matrix
3360 init_matrix( choice_, TrasanTRK, Eakal );
3361
3362 if ( debug_ == 4 )
3363 {
3364 cout << "from Mdc Pattern Recognition: " << std::endl;
3365 HepPoint3D IP( 0, 0, 0 );
3366 Helix work( track_lead.pivot(), track_lead.a(), track_lead.Ea() );
3367 work.pivot( IP );
3368 cout << " dr = " << work.a()[0] << ", Er_dr = " << sqrt( work.Ea()[0][0] ) << std::endl;
3369 cout << " phi0 = " << work.a()[1] << ", Er_phi0 = " << sqrt( work.Ea()[1][1] )
3370 << std::endl;
3371 cout << " PT = " << 1 / work.a()[2] << ", Er_kappa = " << sqrt( work.Ea()[2][2] )
3372 << std::endl;
3373 cout << " dz = " << work.a()[3] << ", Er_dz = " << sqrt( work.Ea()[3][3] ) << std::endl;
3374 cout << " tanl = " << work.a()[4] << ", Er_tanl = " << sqrt( work.Ea()[4][4] )
3375 << std::endl;
3376 }
3377
3378 filter_fwd_anal( track_lead, lead_, way, Eakal );
3379
3380 // std::cout<<" step3, track_lead.Ea: "<<track_lead.Ea()<<std::endl;
3381 track_lead.update_forMdc();
3382
3383 HepPoint3D IP( 0, 0, 0 );
3384 if ( debug_ == 4 )
3385 {
3386 cout << " Mdc FIRST KALMAN FIT " << std::endl;
3387 Helix work( track_lead.pivot(), track_lead.a(), track_lead.Ea() );
3388 work.pivot( IP );
3389 cout << " dr = " << work.a()[0] << ", Er_dr = " << sqrt( work.Ea()[0][0] ) << std::endl;
3390 cout << " phi0 = " << work.a()[1] << ", Er_phi0 = " << sqrt( work.Ea()[1][1] )
3391 << std::endl;
3392 cout << " PT = " << 1 / work.a()[2] << ", Er_kappa = " << sqrt( work.Ea()[2][2] )
3393 << std::endl;
3394 cout << " dz = " << work.a()[3] << ", Er_dz = " << sqrt( work.Ea()[3][3] ) << std::endl;
3395 cout << " tanl = " << work.a()[4] << ", Er_tanl = " << sqrt( work.Ea()[4][4] )
3396 << std::endl;
3397 }
3398
3399 // fill TDS
3400 RecMdcKalTrack* kaltrk = new RecMdcKalTrack;
3401 // Complete the track (other mass assumption, backward) and
3402 complete_track( TrasanTRK, TrasanTRK_add, track_lead, kaltrk, kalcol, segcol, 1 );
3403 }
3404
3405 IDataProviderSvc* eventSvc = NULL;
3406 Gaudi::svcLocator()->service( "EventDataSvc", eventSvc );
3407 if ( eventSvc ) { log << MSG::INFO << "makeTds:event Svc has been found" << endmsg; }
3408 else
3409 {
3410 log << MSG::FATAL << "makeTds:Could not find eventSvc" << endmsg;
3411 return;
3412 }
3413
3414 StatusCode kalsc;
3415 IDataManagerSvc* dataManSvc;
3416 dataManSvc = dynamic_cast<IDataManagerSvc*>( eventSvc );
3417 DataObject* aKalTrackCol;
3418 eventSvc->findObject( "/Event/Recon/RecMdcKalTrackCol", aKalTrackCol );
3419 if ( aKalTrackCol )
3420 {
3421 dataManSvc->clearSubTree( "/Event/Recon/RecMdcKalTrackCol" );
3422 eventSvc->unregisterObject( "/Event/Recon/RecMdcKalTrackCol" );
3423 }
3424
3425 kalsc = eventSvc->registerObject( "/Event/Recon/RecMdcKalTrackCol", kalcol );
3426 if ( kalsc.isFailure() )
3427 {
3428 log << MSG::FATAL << "Could not register RecMdcKalTrack" << endmsg;
3429 return;
3430 }
3431 log << MSG::INFO << "RecMdcKalTrackCol registered successfully!" << endmsg;
3432
3433 StatusCode segsc;
3434 // check whether the RecMdcKalHelixSegCol has been already registered
3435 DataObject* aRecKalSegEvent;
3436 eventSvc->findObject( "/Event/Recon/RecMdcKalHelixSegCol", aRecKalSegEvent );
3437 if ( aRecKalSegEvent )
3438 {
3439 // then unregister RecMdcKalHelixSegCol
3440 segsc = eventSvc->unregisterObject( "/Event/Recon/RecMdcKalHelixSegCol" );
3441 if ( segsc != StatusCode::SUCCESS )
3442 {
3443 log << MSG::FATAL << "Could not unregister RecMdcKalHelixSegCol collection" << endmsg;
3444 return;
3445 }
3446 }
3447
3448 segsc = eventSvc->registerObject( "/Event/Recon/RecMdcKalHelixSegCol", segcol );
3449 if ( segsc.isFailure() )
3450 {
3451 log << MSG::FATAL << "Could not register RecMdcKalHelixSeg" << endmsg;
3452 return;
3453 }
3454 log << MSG::INFO << "RecMdcKalHelixSegCol registered successfully!" << endmsg;
3455
3456 double x1( 0. ), x2( 0. ), y1( 0. ), y2( 0. ), z1( 0. ), z2( 0. ), the1( 0. ), the2( 0. ),
3457 phi1( 0. ), phi2( 0. ), p1( 0. ), p2( 0. );
3458 double r1( 0. ), r2( 0. ), kap1( 999. ), kap2( 999. ), tanl1( 0 ), tanl2( 0. );
3459 double px1( 0. ), px2( 0. ), py1( 0. ), py2( 0. ), pz1( 0. ), pz2( 0. ), charge1( 0. ),
3460 charge2( 0. );
3461
3462 // check the result:RecMdcKalTrackCol
3463 SmartDataPtr<RecMdcKalTrackCol> kaltrkCol( eventSvc, "/Event/Recon/RecMdcKalTrackCol" );
3464 if ( !kaltrkCol )
3465 {
3466 log << MSG::FATAL << "Could not find RecMdcKalTrackCol" << endmsg;
3467 return;
3468 }
3469 log << MSG::INFO << "Begin to check RecMdcKalTrackCol" << endmsg;
3470 RecMdcKalTrackCol::iterator iter_trk = kaltrkCol->begin();
3471 for ( int jj = 1; iter_trk != kaltrkCol->end(); iter_trk++, jj++ )
3472 {
3473 log << MSG::DEBUG << "retrieved MDC Kalmantrack:"
3474 << "Track Id: " << ( *iter_trk )->getTrackId()
3475 << " Mass of the fit: " << ( *iter_trk )->getMass( 2 ) << endmsg
3476 << " Length of the track: " << ( *iter_trk )->getLength( 2 )
3477 << " Tof of the track: " << ( *iter_trk )->getTof( 2 ) << endmsg
3478 << " Chisq of the fit: " << ( *iter_trk )->getChisq( 0, 2 ) << " "
3479 << ( *iter_trk )->getChisq( 1, 2 ) << endmsg
3480 << "Ndf of the fit: " << ( *iter_trk )->getNdf( 0, 2 ) << " "
3481 << ( *iter_trk )->getNdf( 1, 2 ) << endmsg << "Kappa " << ( *iter_trk )->getZHelix()[2]
3482 << endmsg;
3483 for ( int i = 0; i < 43; i++ )
3484 {
3485 log << MSG::DEBUG << "retrieved pathl[" << i << "]= " << ( *iter_trk )->getPathl( i )
3486 << endmsg;
3487 }
3488
3489 if ( ntuple_ & 1 )
3490 {
3491 m_trackid = ( *iter_trk )->getTrackId();
3492
3493 for ( int jj = 0, iii = 0; jj < 5; jj++ )
3494 {
3495
3496 m_length[jj] = ( *iter_trk )->getLength( jj );
3497 m_tof[jj] = ( *iter_trk )->getTof( jj );
3498 m_nhits[jj] = ( *iter_trk )->getNhits( jj );
3499 m_zhelix[jj] = ( *iter_trk )->getZHelix()[jj];
3500 m_zhelixe[jj] = ( *iter_trk )->getZHelixE()[jj];
3501 m_zhelixmu[jj] = ( *iter_trk )->getZHelixMu()[jj];
3502 m_zhelixk[jj] = ( *iter_trk )->getZHelixK()[jj];
3503 m_zhelixp[jj] = ( *iter_trk )->getZHelixP()[jj];
3504 m_fhelix[jj] = ( *iter_trk )->getFHelix()[jj];
3505 m_fhelixe[jj] = ( *iter_trk )->getFHelixE()[jj];
3506 m_fhelixmu[jj] = ( *iter_trk )->getFHelixMu()[jj];
3507 m_fhelixk[jj] = ( *iter_trk )->getFHelixK()[jj];
3508 m_fhelixp[jj] = ( *iter_trk )->getFHelixP()[jj];
3509 m_lhelix[jj] = ( *iter_trk )->getLHelix()[jj];
3510 m_lhelixe[jj] = ( *iter_trk )->getLHelixE()[jj];
3511 m_lhelixmu[jj] = ( *iter_trk )->getLHelixMu()[jj];
3512 m_lhelixk[jj] = ( *iter_trk )->getLHelixK()[jj];
3513 m_lhelixp[jj] = ( *iter_trk )->getLHelixP()[jj];
3514
3515 if ( ntuple_ & 32 )
3516 {
3517 for ( int kk = 0; kk <= jj; kk++, iii++ )
3518 {
3519 m_zerror[iii] = ( *iter_trk )->getZError()[jj][kk];
3520 m_zerrore[iii] = ( *iter_trk )->getZErrorE()[jj][kk];
3521 m_zerrormu[iii] = ( *iter_trk )->getZErrorMu()[jj][kk];
3522 m_zerrork[iii] = ( *iter_trk )->getZErrorK()[jj][kk];
3523 m_zerrorp[iii] = ( *iter_trk )->getZErrorP()[jj][kk];
3524 m_ferror[iii] = ( *iter_trk )->getFError()[jj][kk];
3525 m_ferrore[iii] = ( *iter_trk )->getFErrorE()[jj][kk];
3526 m_ferrormu[iii] = ( *iter_trk )->getFErrorMu()[jj][kk];
3527 m_ferrork[iii] = ( *iter_trk )->getFErrorK()[jj][kk];
3528 m_ferrorp[iii] = ( *iter_trk )->getFErrorP()[jj][kk];
3529 m_lerror[iii] = ( *iter_trk )->getLError()[jj][kk];
3530 m_lerrore[iii] = ( *iter_trk )->getLErrorE()[jj][kk];
3531 m_lerrormu[iii] = ( *iter_trk )->getLErrorMu()[jj][kk];
3532 m_lerrork[iii] = ( *iter_trk )->getLErrorK()[jj][kk];
3533 m_lerrorp[iii] = ( *iter_trk )->getLErrorP()[jj][kk];
3534 }
3535 }
3536 }
3537
3538 // // the following logic may seem peculiar, but it IS the case(for BOSS5.0 and
3539 // BOSS5.1) m_chisq[0][0] = (*iter_trk)->getChisq(0,0); m_chisq[0][1] =
3540 // (*iter_trk)->getChisq(0,1); m_chisq[1][0] = (*iter_trk)->getChisq(0,2);
3541 // m_chisq[1][1] = (*iter_trk)->getChisq(0,3);
3542 // m_chisq[2][0] = (*iter_trk)->getChisq(0,4);
3543 // m_chisq[2][1] = (*iter_trk)->getChisq(1,0);
3544 // m_chisq[3][0] = (*iter_trk)->getChisq(1,1);
3545 // m_chisq[3][1] = (*iter_trk)->getChisq(1,2);
3546 // m_chisq[4][0] = (*iter_trk)->getChisq(1,3);
3547 // m_chisq[4][1] = (*iter_trk)->getChisq(1,4);
3548
3549 // m_ndf[0][0] = (*iter_trk)->getNdf(0,0);
3550 // m_ndf[0][1] = (*iter_trk)->getNdf(0,1);
3551 // m_ndf[1][0] = (*iter_trk)->getNdf(0,2);
3552 // m_ndf[1][1] = (*iter_trk)->getNdf(0,3);
3553 // m_ndf[2][0] = (*iter_trk)->getNdf(0,4);
3554 // m_ndf[2][1] = (*iter_trk)->getNdf(1,0);
3555 // m_ndf[3][0] = (*iter_trk)->getNdf(1,1);
3556 // m_ndf[3][1] = (*iter_trk)->getNdf(1,2);
3557 // m_ndf[4][0] = (*iter_trk)->getNdf(1,3);
3558 // m_ndf[4][1] = (*iter_trk)->getNdf(1,4);
3559
3560 // m_stat[0][0] = (*iter_trk)->getStat(0,0);
3561 // m_stat[0][1] = (*iter_trk)->getStat(0,1);
3562 // m_stat[1][0] = (*iter_trk)->getStat(0,2);
3563 // m_stat[1][1] = (*iter_trk)->getStat(0,3);
3564 // m_stat[2][0] = (*iter_trk)->getStat(0,4);
3565 // m_stat[2][1] = (*iter_trk)->getStat(1,0);
3566 // m_stat[3][0] = (*iter_trk)->getStat(1,1);
3567 // m_stat[3][1] = (*iter_trk)->getStat(1,2);
3568 // m_stat[4][0] = (*iter_trk)->getStat(1,3);
3569 // m_stat[4][1] = (*iter_trk)->getStat(1,4);
3570
3571 // RootConversion changed in BOSS6.0, so use thefollowing:
3572 m_chisq[0][0] = ( *iter_trk )->getChisq( 0, 0 );
3573 m_chisq[1][0] = ( *iter_trk )->getChisq( 0, 1 );
3574 m_chisq[2][0] = ( *iter_trk )->getChisq( 0, 2 );
3575 m_chisq[3][0] = ( *iter_trk )->getChisq( 0, 3 );
3576 m_chisq[4][0] = ( *iter_trk )->getChisq( 0, 4 );
3577 m_chisq[0][1] = ( *iter_trk )->getChisq( 1, 0 );
3578 m_chisq[1][1] = ( *iter_trk )->getChisq( 1, 1 );
3579 m_chisq[2][1] = ( *iter_trk )->getChisq( 1, 2 );
3580 m_chisq[3][1] = ( *iter_trk )->getChisq( 1, 3 );
3581 m_chisq[4][1] = ( *iter_trk )->getChisq( 1, 4 );
3582
3583 m_ndf[0][0] = ( *iter_trk )->getNdf( 0, 0 );
3584 m_ndf[1][0] = ( *iter_trk )->getNdf( 0, 1 );
3585 m_ndf[2][0] = ( *iter_trk )->getNdf( 0, 2 );
3586 m_ndf[3][0] = ( *iter_trk )->getNdf( 0, 3 );
3587 m_ndf[4][0] = ( *iter_trk )->getNdf( 0, 4 );
3588 m_ndf[0][1] = ( *iter_trk )->getNdf( 1, 0 );
3589 m_ndf[1][1] = ( *iter_trk )->getNdf( 1, 1 );
3590 m_ndf[2][1] = ( *iter_trk )->getNdf( 1, 2 );
3591 m_ndf[3][1] = ( *iter_trk )->getNdf( 1, 3 );
3592 m_ndf[4][1] = ( *iter_trk )->getNdf( 1, 4 );
3593
3594 m_stat[0][0] = ( *iter_trk )->getStat( 0, 0 );
3595 m_stat[1][0] = ( *iter_trk )->getStat( 0, 1 );
3596 m_stat[2][0] = ( *iter_trk )->getStat( 0, 2 );
3597 m_stat[3][0] = ( *iter_trk )->getStat( 0, 3 );
3598 m_stat[4][0] = ( *iter_trk )->getStat( 0, 4 );
3599 m_stat[0][1] = ( *iter_trk )->getStat( 1, 0 );
3600 m_stat[1][1] = ( *iter_trk )->getStat( 1, 1 );
3601 m_stat[2][1] = ( *iter_trk )->getStat( 1, 2 );
3602 m_stat[3][1] = ( *iter_trk )->getStat( 1, 3 );
3603 m_stat[4][1] = ( *iter_trk )->getStat( 1, 4 );
3604
3605 m_fptot = sqrt( 1 + pow( m_fhelix[4], 2 ) ) / m_fhelix[2];
3606 m_fptote = sqrt( 1 + pow( m_fhelixe[4], 2 ) ) / m_fhelixe[2];
3607 m_fptotmu = sqrt( 1 + pow( m_fhelixmu[4], 2 ) ) / m_fhelixmu[2];
3608 m_fptotk = sqrt( 1 + pow( m_fhelixk[4], 2 ) ) / m_fhelixk[2];
3609 m_fptotp = sqrt( 1 + pow( m_fhelixp[4], 2 ) ) / m_fhelixp[2];
3610
3611 m_lptot = sqrt( 1 + pow( m_lhelix[4], 2 ) ) / m_lhelix[2];
3612 m_lptote = sqrt( 1 + pow( m_lhelixe[4], 2 ) ) / m_lhelixe[2];
3613 m_lptotmu = sqrt( 1 + pow( m_lhelixmu[4], 2 ) ) / m_lhelixmu[2];
3614 m_lptotk = sqrt( 1 + pow( m_lhelixk[4], 2 ) ) / m_lhelixk[2];
3615 m_lptotp = sqrt( 1 + pow( m_lhelixp[4], 2 ) ) / m_lhelixp[2];
3616
3617 m_lpt = 1 / m_lhelix[2];
3618 m_lpte = 1 / m_lhelixe[2];
3619 m_lptmu = 1 / m_lhelixmu[2];
3620 m_lptk = 1 / m_lhelixk[2];
3621 m_lptp = 1 / m_lhelixp[2];
3622
3623 m_fpt = 1 / m_fhelix[2];
3624 m_fpte = 1 / m_fhelixe[2];
3625 m_fptmu = 1 / m_fhelixmu[2];
3626 m_fptk = 1 / m_fhelixk[2];
3627 m_fptp = 1 / m_fhelixp[2];
3628
3629 if ( debug_ >= 3 )
3630 {
3631 std::cout << " " << std::endl;
3632 std::cout << "in file Kalman_fitting_anal ,the m_fpt is .." << m_fpt << std::endl;
3633 std::cout << "in file Kalman_fitting_anal ,the m_fpte is .." << m_fpte << std::endl;
3634 std::cout << "in file Kalman_fitting_anal ,the m_fptmu is .." << m_fptmu << std::endl;
3635 std::cout << "in file Kalman_fitting_anal ,the m_fptk is .." << m_fptk << std::endl;
3636 std::cout << "in file Kalman_fitting_anal ,the m_fptp is .." << m_fptp << std::endl;
3637 }
3638
3639 m_zpt = 1 / m_zhelix[2];
3640 m_zpte = 1 / m_zhelixe[2];
3641 m_zptmu = 1 / m_zhelixmu[2];
3642 m_zptk = 1 / m_zhelixk[2];
3643 m_zptp = 1 / m_zhelixp[2];
3644
3645 if ( debug_ >= 3 )
3646 {
3647 std::cout << "in file Kalman_fitting_anal ,the m_zpt is .." << m_zpt << std::endl;
3648 std::cout << "in file Kalman_fitting_anal ,the m_zpte is .." << m_zpte << std::endl;
3649 std::cout << "in file Kalman_fitting_anal ,the m_zptmu is .." << m_zptmu << std::endl;
3650 std::cout << "in file Kalman_fitting_anal ,the m_zptk is .." << m_zptk << std::endl;
3651 std::cout << "in file Kalman_fitting_anal ,the m_zptp is .." << m_zptp << std::endl;
3652 }
3653 m_zptot = sqrt( 1 + pow( m_zhelix[4], 2 ) ) / m_zhelix[2];
3654 m_zptote = sqrt( 1 + pow( m_zhelixe[4], 2 ) ) / m_zhelixe[2];
3655 m_zptotmu = sqrt( 1 + pow( m_zhelixmu[4], 2 ) ) / m_zhelixmu[2];
3656 m_zptotk = sqrt( 1 + pow( m_zhelixk[4], 2 ) ) / m_zhelixk[2];
3657 m_zptotp = sqrt( 1 + pow( m_zhelixp[4], 2 ) ) / m_zhelixp[2];
3658
3659 if ( debug_ >= 3 )
3660 {
3661 std::cout << "in file Kalman_fitting_anal ,the m_zptot is .." << m_zptot << std::endl;
3662 std::cout << "in file Kalman_fitting_anal ,the m_zptote is .." << m_zptote
3663 << std::endl;
3664 std::cout << "in file Kalman_fitting_anal ,the m_zptotmu is .." << m_zptotmu
3665 << std::endl;
3666 std::cout << "in file Kalman_fitting_anal ,the m_zptotk is .." << m_zptotk
3667 << std::endl;
3668 std::cout << "in file Kalman_fitting_anal ,the m_zptotp is .." << m_zptotp
3669 << std::endl;
3670 }
3671
3672 if ( ntuple_ & 32 )
3673 {
3674 m_zsigp = sqrt( pow( ( m_zptot / m_zhelix[2] ), 2 ) * m_zerror[5] +
3675 pow( ( m_zhelix[4] / m_zptot ), 2 ) * pow( ( 1 / m_zhelix[2] ), 4 ) *
3676 m_zerror[14] -
3677 2 * m_zhelix[4] * m_zerror[12] * pow( ( 1 / m_zhelix[2] ), 3 ) );
3678 m_zsigpe = sqrt( pow( ( m_zptote / m_zhelixe[2] ), 2 ) * m_zerrore[5] +
3679 pow( ( m_zhelixe[4] / m_zptote ), 2 ) *
3680 pow( ( 1 / m_zhelixe[2] ), 4 ) * m_zerrore[14] -
3681 2 * m_zhelixe[4] * m_zerrore[12] * pow( ( 1 / m_zhelixe[2] ), 3 ) );
3682 m_zsigpmu =
3683 sqrt( pow( ( m_zptotmu / m_zhelixmu[2] ), 2 ) * m_zerrormu[5] +
3684 pow( ( m_zhelixmu[4] / m_zptotmu ), 2 ) * pow( ( 1 / m_zhelixmu[2] ), 4 ) *
3685 m_zerrormu[14] -
3686 2 * m_zhelixmu[4] * m_zerrormu[12] * pow( ( 1 / m_zhelixmu[2] ), 3 ) );
3687 m_zsigpk = sqrt( pow( ( m_zptotk / m_zhelixk[2] ), 2 ) * m_zerrork[5] +
3688 pow( ( m_zhelixk[4] / m_zptotk ), 2 ) *
3689 pow( ( 1 / m_zhelixk[2] ), 4 ) * m_zerrork[14] -
3690 2 * m_zhelixk[4] * m_zerrork[12] * pow( ( 1 / m_zhelixk[2] ), 3 ) );
3691 m_zsigpp = sqrt( pow( ( m_zptotp / m_zhelixp[2] ), 2 ) * m_zerrorp[5] +
3692 pow( ( m_zhelixp[4] / m_zptotp ), 2 ) *
3693 pow( ( 1 / m_zhelixp[2] ), 4 ) * m_zerrorp[14] -
3694 2 * m_zhelixp[4] * m_zerrorp[12] * pow( ( 1 / m_zhelixp[2] ), 3 ) );
3695 }
3696
3697 StatusCode sc1 = m_nt1->write();
3698 if ( sc1.isFailure() ) cout << "Ntuple1 filling failed!" << endl;
3699 }
3700
3701 if ( ntuple_ & 4 )
3702 {
3703 if ( jj == 1 )
3704 {
3705 phi1 = ( *iter_trk )->getFFi0();
3706 r1 = ( *iter_trk )->getFDr();
3707 z1 = ( *iter_trk )->getFDz();
3708 kap1 = ( *iter_trk )->getFCpa();
3709 tanl1 = ( *iter_trk )->getFTanl();
3710 charge1 = kap1 / fabs( kap1 );
3711 x1 = r1 * cos( phi1 );
3712 y1 = r1 * sin( phi1 );
3713 p1 = sqrt( 1 + tanl1 * tanl1 ) / kap1;
3714 the1 = M_PI / 2 - atan( tanl1 );
3715 px1 = -sin( phi1 ) / fabs( kap1 );
3716 py1 = cos( phi1 ) / fabs( kap1 );
3717 pz1 = tanl1 / fabs( kap1 );
3718 }
3719 else if ( jj == 2 )
3720 {
3721 phi2 = ( *iter_trk )->getFFi0();
3722 r2 = ( *iter_trk )->getFDr();
3723 z2 = ( *iter_trk )->getFDz();
3724 kap2 = ( *iter_trk )->getFCpa();
3725 tanl2 = ( *iter_trk )->getFTanl();
3726 charge2 = kap2 / fabs( kap2 );
3727 x2 = r1 * cos( phi2 );
3728 y2 = r1 * sin( phi2 );
3729 p2 = sqrt( 1 + tanl2 * tanl2 ) / kap1;
3730 the2 = M_PI / 2 - atan( tanl2 );
3731 px2 = -sin( phi2 ) / fabs( kap2 );
3732 py2 = cos( phi2 ) / fabs( kap2 );
3733 pz2 = tanl2 / fabs( kap2 );
3734 }
3735 }
3736 }
3737 if ( ntuple_ & 4 )
3738 {
3739 m_delx = x1 - x2;
3740 m_dely = y1 - y2;
3741 m_delz = z1 - z2;
3742 m_delthe = the1 + the2;
3743 m_delphi = phi1 - phi2;
3744 m_delp = p1 - p2;
3745 m_delpx = charge1 * fabs( px1 ) + charge2 * fabs( px2 );
3746 m_delpy = charge1 * fabs( py1 ) + charge2 * fabs( py2 );
3747 m_delpz = charge1 * fabs( pz1 ) + charge2 * fabs( pz2 );
3748
3749 StatusCode sc2 = m_nt2->write();
3750 if ( sc2.isFailure() ) cout << "Ntuple2 filling failed!" << endl;
3751 }
3752
3753 delete[] order;
3754 delete[] rCont;
3755 delete[] rGen;
3756 delete[] rOM;
3757
3758 if ( debug_ == 4 ) cout << "Kalfitting finished " << std::endl;
3759}
double p2[4]
double p1[4]
Double_t phi2
Double_t phi1
void complete_track(MdcRec_trk &TrasanTRK, MdcRec_trk_add &TrasanTRK_add, KalFitTrack &track_lead, RecMdcKalTrack *kaltrk, RecMdcKalTrackCol *kalcol, RecMdcKalHelixSegCol *segcol, int flagsmooth)
void start_seed(KalFitTrack &track, int lead_, int way, MdcRec_trk &trk)
void order_wirhit(int index)
void update_forMdc(void)
void appendHitsMdc(KalFitHitMdc h)
Functions for Mdc hits list.
double bFieldZ(double)
sets/returns z componet of the magnetic field.

Referenced by execute().

◆ kalman_fitting_calib()

void KalFitAlg::kalman_fitting_calib ( void )

Definition at line 3761 of file KalFitAlg.cxx.

3761 {
3762
3763 MsgStream log( msgSvc(), name() );
3764 double Pt_threshold( 0.3 );
3765 Hep3Vector IP( 0, 0, 0 );
3766
3767 vector<MdcRec_trk>* mdcMgr = MdcRecTrkCol::getMdcRecTrkCol();
3768 vector<MdcRec_trk_add>* mdc_addMgr = MdcRecTrkAddCol::getMdcRecTrkAddCol();
3769 vector<MdcRec_wirhit>* whMgr = MdcRecWirhitCol::getMdcRecWirhitCol();
3770
3771 // Table Manager
3772 if ( !&whMgr ) return;
3773
3774 // Get reduced chi**2 of Mdc track :
3775 int ntrk = mdcMgr->size();
3776 double* rPt = new double[ntrk];
3777 int* rOM = new int[ntrk];
3778 unsigned int* order = new unsigned int[ntrk];
3779 unsigned int* rCont = new unsigned int[ntrk];
3780 unsigned int* rGen = new unsigned int[ntrk];
3781
3782 int index = 0;
3783 for ( vector<MdcRec_trk>::iterator it = mdcMgr->begin(), end = mdcMgr->end(); it != end;
3784 it++ )
3785 {
3786 // Pt
3787 rPt[index] = 0;
3788 if ( it->helix[2] ) rPt[index] = 1 / fabs( it->helix[2] );
3789 if ( debug_ == 4 ) cout << "rPt...[ " << index << " ]...." << rPt[index] << endl;
3790 if ( rPt[index] < 0 ) rPt[index] = DBL_MAX;
3791 // Outermost layer
3792 std::vector<MdcRec_wirhit*> pt = it->hitcol;
3793 if ( debug_ == 4 ) cout << "ppt size: " << pt.size() << endl;
3794 int outermost( -1 );
3795 for ( vector<MdcRec_wirhit*>::iterator ii = pt.end() - 1; ii != pt.begin() - 1; ii-- )
3796 {
3797 int lyr( ( *ii )->geo->Lyr()->Id() );
3798 if ( outermost < lyr ) outermost = lyr;
3799 if ( debug_ == 4 ) cout << "outmost: " << outermost << " lyr: " << lyr << endl;
3800 }
3801 rOM[index] = outermost;
3802 order[index] = index;
3803 ++index;
3804 }
3805
3806 // Sort Mdc tracks by Pt
3807 for ( int j, k = ntrk - 1; k >= 0; k = j )
3808 {
3809 j = -1;
3810 for ( int i = 1; i <= k; i++ )
3811 if ( rPt[i - 1] < rPt[i] )
3812 {
3813 j = i - 1;
3814 std::swap( order[i], order[j] );
3815 std::swap( rPt[i], rPt[j] );
3816 std::swap( rOM[i], rOM[j] );
3817 std::swap( rCont[i], rCont[j] );
3818 std::swap( rGen[i], rGen[j] );
3819 }
3820 }
3821 delete[] rPt;
3822 //
3823 int newcount( 0 );
3824 // check whether Recon already registered
3825 DataObject* aReconEvent;
3826 eventSvc()->findObject( "/Event/Recon", aReconEvent );
3827 if ( !aReconEvent )
3828 {
3829 // register ReconEvent Data Object to TDS;
3830 ReconEvent* recevt = new ReconEvent;
3831 StatusCode sc = eventSvc()->registerObject( "/Event/Recon", recevt );
3832 if ( sc != StatusCode::SUCCESS )
3833 {
3834 log << MSG::FATAL << "Could not register ReconEvent" << endmsg;
3835 return;
3836 }
3837 }
3838
3841 // make RecMdcKalTrackCol
3842 log << MSG::INFO << "beginning to make RecMdcKalTrackCol" << endmsg;
3843
3844 // Loop over tracks given by PatRecon :
3845 for ( int l = 0; l < ntrk; l++ )
3846 {
3847 // m_timer[3]->start();
3848 MdcRec_trk& TrasanTRK = *( mdcMgr->begin() + order[l] );
3849 MdcRec_trk_add& TrasanTRK_add = *( mdc_addMgr->begin() + order[l] );
3850
3851 // Reject the ones with quality != 0
3852 int trasqual = TrasanTRK_add.quality;
3853 if ( debug_ == 4 ) cout << "kalman_fitting>trasqual... " << trasqual << endl;
3854 if ( trasqual ) continue;
3855
3856 newcount++;
3857 if ( debug_ == 4 ) cout << "******* KalFit NUMBER : " << newcount << std::endl;
3858
3859 // What kind of KalFit ?
3860 int type( 0 );
3861 if ( ( TrasanTRK_add.decision & 32 ) == 32 || ( TrasanTRK_add.decision & 64 ) == 64 )
3862 type = 1;
3863
3864 // Initialisation : (x, a, ea)
3865 HepPoint3D x( TrasanTRK.pivot[0], TrasanTRK.pivot[1], TrasanTRK.pivot[2] );
3866
3867 HepVector a( 5 );
3868 for ( int i = 0; i < 5; i++ ) a[i] = TrasanTRK.helix[i];
3869
3870 HepSymMatrix ea( 5 );
3871 for ( int i = 0, k = 0; i < 5; i++ )
3872 {
3873 for ( int j = 0; j <= i; j++ )
3874 {
3875 ea[i][j] = matrixg_ * TrasanTRK.error[k++];
3876 ea[j][i] = ea[i][j];
3877 }
3878 }
3879
3881
3882 double fiTerm = TrasanTRK.fiTerm;
3883 int way( 1 );
3884 // Prepare the track found :
3885 KalFitTrack track_lead = KalFitTrack( x, a, ea, lead_, 0, 0 );
3886 track_lead.bFieldZ( KalFitTrack::Bznom_ );
3887 // Mdc Hits
3888 int inlyr( 999 ), outlyr( -1 );
3889 int* rStat = new int[43];
3890 for ( int irStat = 0; irStat < 43; ++irStat ) rStat[irStat] = 0;
3891 std::vector<MdcRec_wirhit*> pt = TrasanTRK.hitcol;
3892 int hit_in( 0 );
3893 if ( debug_ == 4 ) cout << "*********Pt size****" << pt.size() << endl;
3894 // Number of hits/layer
3895 int Num[43] = { 0 };
3896 for ( vector<MdcRec_wirhit*>::iterator ii = pt.end() - 1; ii != pt.begin() - 1; ii-- )
3897 { Num[( *ii )->geo->Lyr()->Id()]++; }
3898
3899 int hit_asso( 0 );
3900 for ( vector<MdcRec_wirhit*>::iterator ii = pt.end() - 1; ii != pt.begin() - 1; ii-- )
3901 {
3902
3903 hit_asso++;
3904 if ( Num[( *ii )->geo->Lyr()->Id()] > 3 )
3905 {
3906 if ( debug_ > 0 )
3907 cout << "WARNING: I found " << Num[( *ii )->geo->Lyr()->Id()]
3908 << " hits in the layer " << ( *ii )->geo->Lyr()->Id() << std::endl;
3909 continue;
3910 }
3911 // if(ii!=pt.end()-1){
3912 // if(42 == (*ii)->geo->Lyr()->Id() && 42 == (*(ii+1))->geo->Lyr()->Id()){
3913 // MdcRec_wirhit * rechit_before = *(ii+1);
3914 // if((*rechit_before).tdc < (**ii).tdc) continue;
3915 // else if(track_lead.HitsMdc().size()>0 && rStat[42]){
3916 // track_lead.HitsMdc().pop_back();
3917 // }
3918 // }
3919 // else{
3920 // int layer_before=(*(ii+1))->geo->Lyr()->Id();
3921 // if(layer_before == (*ii)->geo->Lyr()->Id()){
3922 // MdcRec_wirhit * rechit_before = *(ii+1);
3923 // if((*rechit_before).rechitptr->getDriftT()>450 ||
3924 // (**ii).rechitptr->getDriftT()>450.){ if((*rechit_before).tdc < (**ii).tdc)
3925 // continue; else if(track_lead.HitsMdc().size()>0 &&
3926 // rStat[layer_before]){ track_lead.HitsMdc().pop_back();
3927 // }
3928 // }
3929 // }
3930 // }
3931 // }
3932
3933 hit_in++;
3934 MdcRec_wirhit& rechit = **ii;
3935 double dist[2] = { rechit.ddl, rechit.ddr };
3936 double erdist[2] = { rechit.erddl, rechit.erddr };
3937 const MdcGeoWire* geo = rechit.geo;
3938
3939 int lr_decision( 0 );
3940 if ( KalFitTrack::LR_ == 1 )
3941 {
3942 if ( rechit.lr == 2 || rechit.lr == 0 ) lr_decision = -1;
3943 // if (rechit.lr==0) lr_decision=-1;
3944 else if ( rechit.lr == 1 ) lr_decision = 1;
3945 }
3946
3947 int ind( geo->Lyr()->Id() );
3948 track_lead.appendHitsMdc( KalFitHitMdc( rechit.id, lr_decision, rechit.tdc, dist, erdist,
3949 _wire + ( geo->Id() ), rechit.rechitptr ) );
3950 // inner/outer layer :
3951 rStat[ind]++;
3952 if ( inlyr > ind ) inlyr = ind;
3953 if ( outlyr < ind ) outlyr = ind;
3954 }
3955 if ( debug_ == 4 ) cout << "**** NUMBER OF Mdc HITS (TRASAN) = " << hit_asso << std::endl;
3956
3957 // Empty layers :
3958 int empty_between( 0 ), empty( 0 );
3959 for ( int i = inlyr; i <= outlyr; i++ )
3960 if ( !rStat[i] ) empty_between++;
3961 empty = empty_between + inlyr + ( 42 - outlyr );
3962 delete[] rStat;
3963
3964 // RMK high momentum track under study, probably not neeeded...
3965 track_lead.order_wirhit( 1 );
3966 track_lead.type( type );
3967 unsigned int nhit = track_lead.HitsMdc().size();
3968 if ( !nhit && debug_ == 4 )
3969 {
3970 cout << " ATTENTION TRACK WITH ONLY HITS " << nhit << std::endl;
3971 continue;
3972 }
3973
3974 // Initialisation :
3975 double KalFitst( 0 ), KalFitax( 0 ), KalFitschi2( 0 );
3976 // Move to the outer most hit :
3977 Hep3Vector outer_pivot( track_lead.x( fiTerm ) );
3978
3979 if ( debug_ == 4 )
3980 {
3981 std::cout << "before track_lead.pivot(outer_pivot) ,the error matrix of track_lead is .."
3982 << track_lead.Ea() << std::endl;
3983 }
3984 track_lead.pivot( outer_pivot ); // hi gay, the error matrix is changed in this function!!
3985 track_lead.bFieldZ( KalFitTrack::Bznom_ );
3986 // attention best_chi2 reinitialize !!!
3987 if ( nhit >= 3 && !KalFitTrack::LR_ ) start_seed( track_lead, lead_, way, TrasanTRK );
3988 HepSymMatrix Eakal( 5, 0 );
3989
3990 // init_matrix(TrasanTRK, Eakal);
3991
3992 double costheta = track_lead.a()[4] / sqrt( 1.0 + track_lead.a()[4] * track_lead.a()[4] );
3993 if ( ( 1.0 / fabs( track_lead.a()[2] ) < pt_cut_ ) && ( fabs( costheta ) > theta_cut_ ) )
3994 { choice_ = 6; }
3995
3996 init_matrix( choice_, TrasanTRK, Eakal );
3997
3998 // std::cout<<" Eakal be here: "<<Eakal<<std::endl;
3999
4000 if ( debug_ == 4 )
4001 {
4002 std::cout << "from Mdc Pattern Recognition: " << std::endl;
4003 HepPoint3D IP( 0, 0, 0 );
4004 Helix work( track_lead.pivot(), track_lead.a(), track_lead.Ea() );
4005 work.pivot( IP );
4006 std::cout << " dr = " << work.a()[0] << ", Er_dr = " << sqrt( work.Ea()[0][0] )
4007 << std::endl;
4008 std::cout << " phi0 = " << work.a()[1] << ", Er_phi0 = " << sqrt( work.Ea()[1][1] )
4009 << std::endl;
4010 std::cout << " PT = " << 1 / work.a()[2] << ", Er_kappa = " << sqrt( work.Ea()[2][2] )
4011 << std::endl;
4012 std::cout << " dz = " << work.a()[3] << ", Er_dz = " << sqrt( work.Ea()[3][3] )
4013 << std::endl;
4014 std::cout << " tanl = " << work.a()[4] << ", Er_tanl = " << sqrt( work.Ea()[4][4] )
4015 << std::endl;
4016 }
4017
4018 filter_fwd_calib( track_lead, lead_, way, Eakal );
4019 track_lead.update_forMdc();
4020
4021 HepPoint3D IP( 0, 0, 0 );
4022 if ( debug_ == 4 )
4023 {
4024 cout << " Mdc FIRST KALMAN FIT " << std::endl;
4025 Helix work( track_lead.pivot(), track_lead.a(), track_lead.Ea() );
4026 work.pivot( IP );
4027 cout << " dr = " << work.a()[0] << ", Er_dr = " << sqrt( work.Ea()[0][0] ) << std::endl;
4028 cout << " phi0 = " << work.a()[1] << ", Er_phi0 = " << sqrt( work.Ea()[1][1] )
4029 << std::endl;
4030 cout << " PT = " << 1 / work.a()[2] << ", Er_kappa = " << sqrt( work.Ea()[2][2] )
4031 << std::endl;
4032 cout << " dz = " << work.a()[3] << ", Er_dz = " << sqrt( work.Ea()[3][3] ) << std::endl;
4033 cout << " tanl = " << work.a()[4] << ", Er_tanl = " << sqrt( work.Ea()[4][4] )
4034 << std::endl;
4035 }
4036
4037 // fill TDS
4038 RecMdcKalTrack* kaltrk = new RecMdcKalTrack;
4039
4040 // Complete the track (other mass assumption, backward) and
4041 complete_track( TrasanTRK, TrasanTRK_add, track_lead, kaltrk, kalcol, segcol );
4042 }
4043
4044 StatusCode kalsc;
4045 // check whether the RecMdcKalTrackCol has been already registered
4046 DataObject* aRecKalEvent;
4047 eventSvc()->findObject( "/Event/Recon/RecMdcKalTrackCol", aRecKalEvent );
4048 if ( aRecKalEvent )
4049 {
4050 // then unregister RecMdcKalCol
4051 kalsc = eventSvc()->unregisterObject( "/Event/Recon/RecMdcKalTrackCol" );
4052 if ( kalsc != StatusCode::SUCCESS )
4053 {
4054 log << MSG::FATAL << "Could not unregister RecMdcKalTrack collection" << endmsg;
4055 return;
4056 }
4057 }
4058
4059 kalsc = eventSvc()->registerObject( "/Event/Recon/RecMdcKalTrackCol", kalcol );
4060 if ( kalsc.isFailure() )
4061 {
4062 log << MSG::FATAL << "Could not register RecMdcKalTrack" << endmsg;
4063 return;
4064 }
4065 log << MSG::INFO << "RecMdcKalTrackCol registered successfully!" << endmsg;
4066
4067 StatusCode segsc;
4068 // check whether the RecMdcKalHelixSegCol has been already registered
4069 DataObject* aRecKalSegEvent;
4070 eventSvc()->findObject( "/Event/Recon/RecMdcKalHelixSegCol", aRecKalSegEvent );
4071 if ( aRecKalSegEvent )
4072 {
4073 // then unregister RecMdcKalHelixSegCol
4074 segsc = eventSvc()->unregisterObject( "/Event/Recon/RecMdcKalHelixSegCol" );
4075 if ( segsc != StatusCode::SUCCESS )
4076 {
4077 log << MSG::FATAL << "Could not unregister RecMdcKalHelixSegCol collection" << endmsg;
4078 return;
4079 }
4080 }
4081
4082 segsc = eventSvc()->registerObject( "/Event/Recon/RecMdcKalHelixSegCol", segcol );
4083 if ( segsc.isFailure() )
4084 {
4085 log << MSG::FATAL << "Could not register RecMdcKalHelixSeg" << endmsg;
4086 return;
4087 }
4088 log << MSG::INFO << "RecMdcKalHelixSegCol registered successfully!" << endmsg;
4089
4090 double x1( 0. ), x2( 0. ), y1( 0. ), y2( 0. ), z1( 0. ), z2( 0. ), the1( 0. ), the2( 0. ),
4091 phi1( 0. ), phi2( 0. ), p1( 0. ), p2( 0. );
4092 double r1( 0. ), r2( 0. ), kap1( 999. ), kap2( 999. ), tanl1( 0. ), tanl2( 0. );
4093 // check the result:RecMdcKalTrackCol
4094
4095 SmartDataPtr<RecMdcKalTrackCol> kaltrkCol( eventSvc(), "/Event/Recon/RecMdcKalTrackCol" );
4096 if ( !kaltrkCol )
4097 {
4098 log << MSG::FATAL << "Could not find RecMdcKalTrackCol" << endmsg;
4099 return;
4100 }
4101 log << MSG::INFO << "Begin to check RecMdcKalTrackCol" << endmsg;
4102 RecMdcKalTrackCol::iterator iter_trk = kaltrkCol->begin();
4103 for ( int jj = 1; iter_trk != kaltrkCol->end(); iter_trk++, jj++ )
4104 {
4105 log << MSG::DEBUG << "retrieved MDC Kalmantrack:"
4106 << "Track Id: " << ( *iter_trk )->getTrackId()
4107 << " Mass of the fit: " << ( *iter_trk )->getMass( 2 ) << endmsg
4108 << " Length of the track: " << ( *iter_trk )->getLength( 2 )
4109 << " Tof of the track: " << ( *iter_trk )->getTof( 2 ) << endmsg
4110 << " Chisq of the fit: " << ( *iter_trk )->getChisq( 0, 2 ) << " "
4111 << ( *iter_trk )->getChisq( 1, 2 ) << endmsg
4112 << "Ndf of the fit: " << ( *iter_trk )->getNdf( 0, 1 ) << " "
4113 << ( *iter_trk )->getNdf( 1, 2 ) << endmsg << "Kappa " << ( *iter_trk )->getZHelix()[2]
4114 << endmsg;
4115
4116 HelixSegRefVec gothelixsegs = ( *iter_trk )->getVecHelixSegs();
4117 if ( debug_ == 4 )
4118 { std::cout << "the size of gothelixsegs ..." << gothelixsegs.size() << std::endl; }
4119
4120 HelixSegRefVec::iterator it_gothelixseg = gothelixsegs.begin();
4121 for ( ; it_gothelixseg != gothelixsegs.end(); it_gothelixseg++ )
4122 {
4123 if ( debug_ == 4 )
4124 {
4125 std::cout << "the layerId of this helixseg is ..." << ( *it_gothelixseg )->getLayerId()
4126 << std::endl;
4127 std::cout << "the residual of this helixseg exclude the meas hit"
4128 << ( *it_gothelixseg )->getResExcl() << std::endl;
4129 std::cout << "the residual of this helixseg include the meas hit"
4130 << ( *it_gothelixseg )->getResIncl() << std::endl;
4131 std::cout << "the track id of the helixseg is ..." << ( *it_gothelixseg )->getTrackId()
4132 << std::endl;
4133 std::cout << "the tof of the helixseg is ..." << ( *it_gothelixseg )->getTof()
4134 << std::endl;
4135 std::cout << "the Zhit of the helixseg is ..." << ( *it_gothelixseg )->getZhit()
4136 << std::endl;
4137 }
4138 }
4139 for ( int i = 0; i < 43; i++ )
4140 {
4141 log << MSG::DEBUG << "retrieved pathl[" << i << "]= " << ( *iter_trk )->getPathl( i )
4142 << endmsg;
4143 }
4144
4145 if ( ntuple_ & 1 )
4146 {
4147 m_trackid = ( *iter_trk )->getTrackId();
4148 for ( int jj = 0, iii = 0; jj < 5; jj++ )
4149 {
4150 m_length[jj] = ( *iter_trk )->getLength( jj );
4151 m_tof[jj] = ( *iter_trk )->getTof( jj );
4152 m_nhits[jj] = ( *iter_trk )->getNhits( jj );
4153 m_zhelix[jj] = ( *iter_trk )->getZHelix()[jj];
4154 m_zhelixe[jj] = ( *iter_trk )->getZHelixE()[jj];
4155 m_zhelixmu[jj] = ( *iter_trk )->getZHelixMu()[jj];
4156 m_zhelixk[jj] = ( *iter_trk )->getZHelixK()[jj];
4157 m_zhelixp[jj] = ( *iter_trk )->getZHelixP()[jj];
4158 m_fhelix[jj] = ( *iter_trk )->getFHelix()[jj];
4159 m_fhelixe[jj] = ( *iter_trk )->getFHelixE()[jj];
4160 m_fhelixmu[jj] = ( *iter_trk )->getFHelixMu()[jj];
4161 m_fhelixk[jj] = ( *iter_trk )->getFHelixK()[jj];
4162 m_fhelixp[jj] = ( *iter_trk )->getFHelixP()[jj];
4163 m_lhelix[jj] = ( *iter_trk )->getLHelix()[jj];
4164 m_lhelixe[jj] = ( *iter_trk )->getLHelixE()[jj];
4165 m_lhelixmu[jj] = ( *iter_trk )->getLHelixMu()[jj];
4166 m_lhelixk[jj] = ( *iter_trk )->getLHelixK()[jj];
4167 m_lhelixp[jj] = ( *iter_trk )->getLHelixP()[jj];
4168 if ( ntuple_ & 32 )
4169 {
4170 for ( int kk = 0; kk <= jj; kk++, iii++ )
4171 {
4172 m_zerror[iii] = ( *iter_trk )->getZError()[jj][kk];
4173 m_zerrore[iii] = ( *iter_trk )->getZErrorE()[jj][kk];
4174 m_zerrormu[iii] = ( *iter_trk )->getZErrorMu()[jj][kk];
4175 m_zerrork[iii] = ( *iter_trk )->getZErrorK()[jj][kk];
4176 m_zerrorp[iii] = ( *iter_trk )->getZErrorP()[jj][kk];
4177 m_ferror[iii] = ( *iter_trk )->getFError()[jj][kk];
4178 m_ferrore[iii] = ( *iter_trk )->getFErrorE()[jj][kk];
4179 m_ferrormu[iii] = ( *iter_trk )->getFErrorMu()[jj][kk];
4180 m_ferrork[iii] = ( *iter_trk )->getFErrorK()[jj][kk];
4181 m_ferrorp[iii] = ( *iter_trk )->getFErrorP()[jj][kk];
4182 m_lerror[iii] = ( *iter_trk )->getLError()[jj][kk];
4183 m_lerrore[iii] = ( *iter_trk )->getLErrorE()[jj][kk];
4184 m_lerrormu[iii] = ( *iter_trk )->getLErrorMu()[jj][kk];
4185 m_lerrork[iii] = ( *iter_trk )->getLErrorK()[jj][kk];
4186 m_lerrorp[iii] = ( *iter_trk )->getLErrorP()[jj][kk];
4187 }
4188 }
4189 }
4190
4191 // // the following logic may seem peculiar, but it IS the case(for BOSS5.0 and
4192 // BOSS5.1) m_chisq[0][0] = (*iter_trk)->getChisq(0,0); m_chisq[0][1] =
4193 // (*iter_trk)->getChisq(0,1); m_chisq[1][0] = (*iter_trk)->getChisq(0,2);
4194 // m_chisq[1][1] = (*iter_trk)->getChisq(0,3);
4195 // m_chisq[2][0] = (*iter_trk)->getChisq(0,4);
4196 // m_chisq[2][1] = (*iter_trk)->getChisq(1,0);
4197 // m_chisq[3][0] = (*iter_trk)->getChisq(1,1);
4198 // m_chisq[3][1] = (*iter_trk)->getChisq(1,2);
4199 // m_chisq[4][0] = (*iter_trk)->getChisq(1,3);
4200 // m_chisq[4][1] = (*iter_trk)->getChisq(1,4);
4201
4202 // m_ndf[0][0] = (*iter_trk)->getNdf(0,0);
4203 // m_ndf[0][1] = (*iter_trk)->getNdf(0,1);
4204 // m_ndf[1][0] = (*iter_trk)->getNdf(0,2);
4205 // m_ndf[1][1] = (*iter_trk)->getNdf(0,3);
4206 // m_ndf[2][0] = (*iter_trk)->getNdf(0,4);
4207 // m_ndf[2][1] = (*iter_trk)->getNdf(1,0);
4208 // m_ndf[3][0] = (*iter_trk)->getNdf(1,1);
4209 // m_ndf[3][1] = (*iter_trk)->getNdf(1,2);
4210 // m_ndf[4][0] = (*iter_trk)->getNdf(1,3);
4211 // m_ndf[4][1] = (*iter_trk)->getNdf(1,4);
4212
4213 // m_stat[0][0] = (*iter_trk)->getStat(0,0);
4214 // m_stat[0][1] = (*iter_trk)->getStat(0,1);
4215 // m_stat[1][0] = (*iter_trk)->getStat(0,2);
4216 // m_stat[1][1] = (*iter_trk)->getStat(0,3);
4217 // m_stat[2][0] = (*iter_trk)->getStat(0,4);
4218 // m_stat[2][1] = (*iter_trk)->getStat(1,0);
4219 // m_stat[3][0] = (*iter_trk)->getStat(1,1);
4220 // m_stat[3][1] = (*iter_trk)->getStat(1,2);
4221 // m_stat[4][0] = (*iter_trk)->getStat(1,3);
4222 // m_stat[4][1] = (*iter_trk)->getStat(1,4);
4223
4224 // RootConversion changed in BOSS6.0, so use thefollowing:
4225 m_chisq[0][0] = ( *iter_trk )->getChisq( 0, 0 );
4226 m_chisq[1][0] = ( *iter_trk )->getChisq( 0, 1 );
4227 m_chisq[2][0] = ( *iter_trk )->getChisq( 0, 2 );
4228 m_chisq[3][0] = ( *iter_trk )->getChisq( 0, 3 );
4229 m_chisq[4][0] = ( *iter_trk )->getChisq( 0, 4 );
4230 m_chisq[0][1] = ( *iter_trk )->getChisq( 1, 0 );
4231 m_chisq[1][1] = ( *iter_trk )->getChisq( 1, 1 );
4232 m_chisq[2][1] = ( *iter_trk )->getChisq( 1, 2 );
4233 m_chisq[3][1] = ( *iter_trk )->getChisq( 1, 3 );
4234 m_chisq[4][1] = ( *iter_trk )->getChisq( 1, 4 );
4235
4236 m_ndf[0][0] = ( *iter_trk )->getNdf( 0, 0 );
4237 m_ndf[1][0] = ( *iter_trk )->getNdf( 0, 1 );
4238 m_ndf[2][0] = ( *iter_trk )->getNdf( 0, 2 );
4239 m_ndf[3][0] = ( *iter_trk )->getNdf( 0, 3 );
4240 m_ndf[4][0] = ( *iter_trk )->getNdf( 0, 4 );
4241 m_ndf[0][1] = ( *iter_trk )->getNdf( 1, 0 );
4242 m_ndf[1][1] = ( *iter_trk )->getNdf( 1, 1 );
4243 m_ndf[2][1] = ( *iter_trk )->getNdf( 1, 2 );
4244 m_ndf[3][1] = ( *iter_trk )->getNdf( 1, 3 );
4245 m_ndf[4][1] = ( *iter_trk )->getNdf( 1, 4 );
4246
4247 m_stat[0][0] = ( *iter_trk )->getStat( 0, 0 );
4248 m_stat[1][0] = ( *iter_trk )->getStat( 0, 1 );
4249 m_stat[2][0] = ( *iter_trk )->getStat( 0, 2 );
4250 m_stat[3][0] = ( *iter_trk )->getStat( 0, 3 );
4251 m_stat[4][0] = ( *iter_trk )->getStat( 0, 4 );
4252 m_stat[0][1] = ( *iter_trk )->getStat( 1, 0 );
4253 m_stat[1][1] = ( *iter_trk )->getStat( 1, 1 );
4254 m_stat[2][1] = ( *iter_trk )->getStat( 1, 2 );
4255 m_stat[3][1] = ( *iter_trk )->getStat( 1, 3 );
4256 m_stat[4][1] = ( *iter_trk )->getStat( 1, 4 );
4257
4258 m_fptot = sqrt( 1 + pow( m_fhelix[4], 2 ) ) / m_fhelix[2];
4259 m_fptote = sqrt( 1 + pow( m_fhelixe[4], 2 ) ) / m_fhelixe[2];
4260 m_fptotmu = sqrt( 1 + pow( m_fhelixmu[4], 2 ) ) / m_fhelixmu[2];
4261 m_fptotk = sqrt( 1 + pow( m_fhelixk[4], 2 ) ) / m_fhelixk[2];
4262 m_fptotp = sqrt( 1 + pow( m_fhelixp[4], 2 ) ) / m_fhelixp[2];
4263
4264 m_zpt = 1 / m_zhelix[2];
4265 m_zpte = 1 / m_zhelixe[2];
4266 m_zptmu = 1 / m_zhelixmu[2];
4267 m_zptk = 1 / m_zhelixk[2];
4268 m_zptp = 1 / m_zhelixp[2];
4269
4270 m_fpt = 1 / m_fhelix[2];
4271 m_fpte = 1 / m_fhelixe[2];
4272 m_fptmu = 1 / m_fhelixmu[2];
4273 m_fptk = 1 / m_fhelixk[2];
4274 m_fptp = 1 / m_fhelixp[2];
4275
4276 m_lpt = 1 / m_lhelix[2];
4277 m_lpte = 1 / m_lhelixe[2];
4278 m_lptmu = 1 / m_lhelixmu[2];
4279 m_lptk = 1 / m_lhelixk[2];
4280 m_lptp = 1 / m_lhelixp[2];
4281
4282 m_lptot = sqrt( 1 + pow( m_lhelix[4], 2 ) ) / m_lhelix[2];
4283 m_lptote = sqrt( 1 + pow( m_lhelixe[4], 2 ) ) / m_lhelixe[2];
4284 m_lptotmu = sqrt( 1 + pow( m_lhelixmu[4], 2 ) ) / m_lhelixmu[2];
4285 m_lptotk = sqrt( 1 + pow( m_lhelixk[4], 2 ) ) / m_lhelixk[2];
4286 m_lptotp = sqrt( 1 + pow( m_lhelixp[4], 2 ) ) / m_lhelixp[2];
4287
4288 m_zptot = sqrt( 1 + pow( m_zhelix[4], 2 ) ) / m_zhelix[2];
4289 m_zptote = sqrt( 1 + pow( m_zhelixe[4], 2 ) ) / m_zhelixe[2];
4290 m_zptotmu = sqrt( 1 + pow( m_zhelixmu[4], 2 ) ) / m_zhelixmu[2];
4291 m_zptotk = sqrt( 1 + pow( m_zhelixk[4], 2 ) ) / m_zhelixk[2];
4292 m_zptotp = sqrt( 1 + pow( m_zhelixp[4], 2 ) ) / m_zhelixp[2];
4293 if ( ntuple_ & 32 )
4294 {
4295 m_zsigp = sqrt( pow( ( m_zptot / m_zhelix[2] ), 2 ) * m_zerror[5] +
4296 pow( ( m_zhelix[4] / m_zptot ), 2 ) * pow( ( 1 / m_zhelix[2] ), 4 ) *
4297 m_zerror[14] -
4298 2 * m_zhelix[4] * m_zerror[12] * pow( ( 1 / m_zhelix[2] ), 3 ) );
4299 m_zsigpe = sqrt( pow( ( m_zptote / m_zhelixe[2] ), 2 ) * m_zerrore[5] +
4300 pow( ( m_zhelixe[4] / m_zptote ), 2 ) *
4301 pow( ( 1 / m_zhelixe[2] ), 4 ) * m_zerrore[14] -
4302 2 * m_zhelixe[4] * m_zerrore[12] * pow( ( 1 / m_zhelixe[2] ), 3 ) );
4303 m_zsigpmu =
4304 sqrt( pow( ( m_zptotmu / m_zhelixmu[2] ), 2 ) * m_zerrormu[5] +
4305 pow( ( m_zhelixmu[4] / m_zptotmu ), 2 ) * pow( ( 1 / m_zhelixmu[2] ), 4 ) *
4306 m_zerrormu[14] -
4307 2 * m_zhelixmu[4] * m_zerrormu[12] * pow( ( 1 / m_zhelixmu[2] ), 3 ) );
4308 m_zsigpk = sqrt( pow( ( m_zptotk / m_zhelixk[2] ), 2 ) * m_zerrork[5] +
4309 pow( ( m_zhelixk[4] / m_zptotk ), 2 ) *
4310 pow( ( 1 / m_zhelixk[2] ), 4 ) * m_zerrork[14] -
4311 2 * m_zhelixk[4] * m_zerrork[12] * pow( ( 1 / m_zhelixk[2] ), 3 ) );
4312 m_zsigpp = sqrt( pow( ( m_zptotp / m_zhelixp[2] ), 2 ) * m_zerrorp[5] +
4313 pow( ( m_zhelixp[4] / m_zptotp ), 2 ) *
4314 pow( ( 1 / m_zhelixp[2] ), 4 ) * m_zerrorp[14] -
4315 2 * m_zhelixp[4] * m_zerrorp[12] * pow( ( 1 / m_zhelixp[2] ), 3 ) );
4316 }
4317
4318 StatusCode sc1 = m_nt1->write();
4319 if ( sc1.isFailure() ) cout << "Ntuple1 filling failed!" << endl;
4320 }
4321
4322 if ( ntuple_ & 4 )
4323 {
4324 if ( jj == 1 )
4325 {
4326 phi1 = ( *iter_trk )->getFFi0();
4327 r1 = ( *iter_trk )->getFDr();
4328 z1 = ( *iter_trk )->getFDz();
4329 kap1 = ( *iter_trk )->getFCpa();
4330 tanl1 = ( *iter_trk )->getFTanl();
4331 x1 = r1 * cos( phi1 );
4332 y1 = r1 * sin( phi1 );
4333 p1 = sqrt( 1 + tanl1 * tanl1 ) / kap1;
4334 the1 = M_PI / 2 - atan( tanl1 );
4335 }
4336 else if ( jj == 2 )
4337 {
4338 phi2 = ( *iter_trk )->getFFi0();
4339 r2 = ( *iter_trk )->getFDr();
4340 z2 = ( *iter_trk )->getFDz();
4341 kap2 = ( *iter_trk )->getFCpa();
4342 tanl2 = ( *iter_trk )->getFTanl();
4343 x2 = r1 * cos( phi2 );
4344 y2 = r1 * sin( phi2 );
4345 p2 = sqrt( 1 + tanl2 * tanl2 ) / kap1;
4346 the2 = M_PI / 2 - atan( tanl2 );
4347 }
4348 }
4349 }
4350 if ( ntuple_ & 4 )
4351 {
4352 m_delx = x1 - x2;
4353 m_dely = y1 - y2;
4354 m_delz = z1 - z2;
4355 m_delthe = the1 + the2;
4356 m_delphi = phi1 - phi2;
4357 m_delp = p1 - p2;
4358 StatusCode sc2 = m_nt2->write();
4359 if ( sc2.isFailure() ) cout << "Ntuple2 filling failed!" << endl;
4360 }
4361 delete[] order;
4362 delete[] rCont;
4363 delete[] rGen;
4364 delete[] rOM;
4365
4366 if ( debug_ == 4 ) cout << "Kalfitting finished " << std::endl;
4367}
static void setInitMatrix(HepSymMatrix m)

Referenced by execute().

◆ kalman_fitting_csmalign()

void KalFitAlg::kalman_fitting_csmalign ( void )

Definition at line 4873 of file KalFitAlg.cxx.

4873 {
4874
4875 MsgStream log( msgSvc(), name() );
4876 double Pt_threshold( 0.3 );
4877 Hep3Vector IP( 0, 0, 0 );
4878
4879 vector<MdcRec_trk>* mdcMgr = MdcRecTrkCol::getMdcRecTrkCol();
4880 vector<MdcRec_trk_add>* mdc_addMgr = MdcRecTrkAddCol::getMdcRecTrkAddCol();
4881 vector<MdcRec_wirhit>* whMgr = MdcRecWirhitCol::getMdcRecWirhitCol();
4882
4883 // Table Manager
4884 if ( !&whMgr ) return;
4885
4886 // Get reduced chi**2 of Mdc track :
4887 int ntrk = mdcMgr->size();
4888 // cout<<"ntrk: "<<ntrk<<endl;
4889
4890 int nhits = whMgr->size();
4891 // cout<<"nhits: "<<nhits<<endl;
4892
4893 double* rY = new double[ntrk];
4894 double* rfiTerm = new double[ntrk];
4895 double* rPt = new double[ntrk];
4896 int* rOM = new int[ntrk];
4897 unsigned int* order = new unsigned int[ntrk];
4898 unsigned int* rCont = new unsigned int[ntrk];
4899 unsigned int* rGen = new unsigned int[ntrk];
4900
4901 int index = 0;
4902 Hep3Vector csmp3[2];
4903 for ( vector<MdcRec_trk>::iterator it = mdcMgr->begin(), end = mdcMgr->end(); it != end;
4904 it++ )
4905 {
4906 // order by phi term
4907 rfiTerm[index] = it->fiTerm;
4908 // cout<<"fiTerm: "<<rfiTerm[index]<<endl;
4909 // Pt
4910 rPt[index] = 0;
4911 if ( it->helix[2] ) rPt[index] = 1 / fabs( it->helix[2] );
4912 if ( debug_ == 4 ) cout << "rPt...[ " << index << " ]...." << rPt[index] << endl;
4913 if ( rPt[index] < 0 ) rPt[index] = DBL_MAX;
4914 // Outermost layer
4915 std::vector<MdcRec_wirhit*> pt = it->hitcol;
4916 if ( debug_ == 4 ) cout << "ppt size: " << pt.size() << endl;
4917 int outermost( -1 );
4918 for ( vector<MdcRec_wirhit*>::iterator ii = pt.end() - 1; ii != pt.begin() - 1; ii-- )
4919 {
4920 int lyr( ( *ii )->geo->Lyr()->Id() );
4921 if ( outermost < lyr )
4922 {
4923 outermost = lyr;
4924 rY[index] = ( *ii )->geo->Forward().y();
4925 }
4926 if ( debug_ == 4 ) cout << "outmost: " << outermost << " lyr: " << lyr << endl;
4927 }
4928 rOM[index] = outermost;
4929 order[index] = index;
4930 ++index;
4931 }
4932
4933 // Sort Mdc tracks by fiTerm
4934 for ( int j, k = ntrk - 1; k >= 0; k = j )
4935 {
4936 j = -1;
4937 for ( int i = 1; i <= k; i++ )
4938 if ( rY[i - 1] < rY[i] )
4939 {
4940 j = i - 1;
4941 std::swap( order[i], order[j] );
4942 std::swap( rY[i], rY[j] );
4943 std::swap( rOM[i], rOM[j] );
4944 std::swap( rCont[i], rCont[j] );
4945 std::swap( rGen[i], rGen[j] );
4946 }
4947 }
4948 delete[] rPt;
4949 delete[] rY;
4950 delete[] rfiTerm;
4951 //
4952 int newcount( 0 );
4953 // check whether Recon already registered
4954 DataObject* aReconEvent;
4955 eventSvc()->findObject( "/Event/Recon", aReconEvent );
4956 if ( !aReconEvent )
4957 {
4958 // register ReconEvent Data Object to TDS;
4959 ReconEvent* recevt = new ReconEvent;
4960 StatusCode sc = eventSvc()->registerObject( "/Event/Recon", recevt );
4961 if ( sc != StatusCode::SUCCESS )
4962 {
4963 log << MSG::FATAL << "Could not register ReconEvent" << endmsg;
4964 return;
4965 }
4966 }
4967
4970 // make RecMdcKalTrackCol
4971 log << MSG::INFO << "beginning to make RecMdcKalTrackCol" << endmsg;
4972
4973 // m_timer[3]->start();
4974 // MdcRec_trk& TrasanTRK;
4975 // MdcRec_trk_add& TrasanTRK_add;
4976
4977 // for(int l = 0; l < ntrk; l++) {
4978 MdcRec_trk& TrasanTRK = *( mdcMgr->begin() + order[1] );
4979 MdcRec_trk_add& TrasanTRK_add = *( mdc_addMgr->begin() + order[1] );
4980 // Reject the ones with quality != 0
4981 // int trasqual = TrasanTRK_add.quality;
4982 // if(debug_ == 4) cout<<"kalman_fitting>trasqual... "<<trasqual<<endl;
4983 // if (trasqual) continue;
4984
4985 newcount++;
4986 if ( debug_ == 4 ) cout << "******* KalFit NUMBER : " << newcount << std::endl;
4987
4988 // What kind of KalFit ?
4989 int type( 0 );
4990 if ( ( TrasanTRK_add.decision & 32 ) == 32 || ( TrasanTRK_add.decision & 64 ) == 64 )
4991 type = 1;
4992
4993 // Initialisation : (x, a, ea)
4994 HepPoint3D x( TrasanTRK.pivot[0], TrasanTRK.pivot[1], TrasanTRK.pivot[2] );
4995
4996 HepVector a( 5 );
4997 for ( int i = 0; i < 5; i++ ) a[i] = TrasanTRK.helix[i];
4998
4999 HepSymMatrix ea( 5 );
5000 for ( int i = 0, k = 0; i < 5; i++ )
5001 {
5002 for ( int j = 0; j <= i; j++ )
5003 {
5004 ea[i][j] = matrixg_ * TrasanTRK.error[k++];
5005 ea[j][i] = ea[i][j];
5006 }
5007 }
5008
5010
5011 double fiTerm = TrasanTRK.fiTerm;
5012 int way( 1 );
5013 // Prepare the track found :
5014 KalFitTrack track_lead = KalFitTrack( x, a, ea, lead_, 0, 0 );
5015 track_lead.bFieldZ( KalFitTrack::Bznom_ );
5016
5017 int hit_asso( 0 );
5018 for ( int l = 0; l < ntrk; l++ )
5019 {
5020 MdcRec_trk& TrasanTRK1 = *( mdcMgr->begin() + order[l] );
5021 MdcRec_trk_add& TrasanTRK_add1 = *( mdc_addMgr->begin() + order[l] );
5022 // Reject the ones with quality != 0
5023 int trasqual = TrasanTRK_add1.quality;
5024 if ( debug_ == 4 ) cout << "kalman_fitting>trasqual... " << trasqual << endl;
5025 if ( trasqual ) continue;
5026 // Mdc Hits
5027 int inlyr( 999 ), outlyr( -1 );
5028 int* rStat = new int[43];
5029 for ( int irStat = 0; irStat < 43; ++irStat ) rStat[irStat] = 0;
5030 std::vector<MdcRec_wirhit*> pt = TrasanTRK1.hitcol;
5031 int hit_in( 0 );
5032 if ( debug_ == 4 ) cout << "*********Pt size****" << pt.size() << endl;
5033 // Number of hits/layer
5034 int Num[43] = { 0 };
5035 for ( vector<MdcRec_wirhit*>::iterator ii = pt.end() - 1; ii != pt.begin() - 1; ii-- )
5036 { Num[( *ii )->geo->Lyr()->Id()]++; }
5037
5038 for ( vector<MdcRec_wirhit*>::iterator ii = pt.end() - 1; ii != pt.begin() - 1; ii-- )
5039 {
5040
5041 hit_asso++;
5042 if ( Num[( *ii )->geo->Lyr()->Id()] > 3 )
5043 {
5044 if ( debug_ > 0 )
5045 cout << "WARNING: I found " << Num[( *ii )->geo->Lyr()->Id()]
5046 << " hits in the layer " << ( *ii )->geo->Lyr()->Id() << std::endl;
5047 continue;
5048 }
5049
5050 hit_in++;
5051 MdcRec_wirhit& rechit = **ii;
5052 double dist[2] = { rechit.ddl, rechit.ddr };
5053 double erdist[2] = { rechit.erddl, rechit.erddr };
5054 const MdcGeoWire* geo = rechit.geo;
5055
5056 int lr_decision( 0 );
5057 if ( KalFitTrack::LR_ == 1 )
5058 {
5059 if ( rechit.lr == 2 || rechit.lr == 0 ) lr_decision = -1;
5060 // if (rechit.lr==0) lr_decision=-1;
5061 else if ( rechit.lr == 1 ) lr_decision = 1;
5062 }
5063
5064 int ind( geo->Lyr()->Id() );
5065 track_lead.appendHitsMdc( KalFitHitMdc( rechit.id, lr_decision, rechit.tdc, dist, erdist,
5066 _wire + ( geo->Id() ), rechit.rechitptr ) );
5067 // inner/outer layer :
5068 rStat[ind]++;
5069 if ( inlyr > ind ) inlyr = ind;
5070 if ( outlyr < ind ) outlyr = ind;
5071 }
5072 // Empty layers :
5073 int empty_between( 0 ), empty( 0 );
5074 for ( int i = inlyr; i <= outlyr; i++ )
5075 if ( !rStat[i] ) empty_between++;
5076 empty = empty_between + inlyr + ( 42 - outlyr );
5077 delete[] rStat;
5078 }
5079 if ( debug_ == 4 ) cout << "**** NUMBER OF Mdc HITS (TRASAN) = " << hit_asso << std::endl;
5080
5081 // RMK high momentum track under study, probably not neeeded...
5082 track_lead.order_wirhit( 0 );
5083 track_lead.type( type );
5084 unsigned int nhit = track_lead.HitsMdc().size();
5085 if ( nhit < 70 )
5086 {
5087 cout << " ATTENTION TRACK WITH ONLY HITS " << nhit << std::endl;
5088 return;
5089 }
5090
5091 // Initialisation :
5092 double KalFitst( 0 ), KalFitax( 0 ), KalFitschi2( 0 );
5093 // Move to the outer most hit :
5094 Hep3Vector outer_pivot( track_lead.x( fiTerm ) );
5095
5096 if ( debug_ == 4 )
5097 {
5098 std::cout << "before track_lead.pivot(outer_pivot) ,the error matrix of track_lead is .."
5099 << track_lead.Ea() << std::endl;
5100 }
5101 track_lead.pivot( outer_pivot ); // hi gay, the error matrix is changed in this function!!
5102 track_lead.bFieldZ( KalFitTrack::Bznom_ );
5103 // attention best_chi2 reinitialize !!!
5104 if ( nhit >= 3 && !KalFitTrack::LR_ ) start_seed( track_lead, lead_, way, TrasanTRK );
5105 HepSymMatrix Eakal( 5, 0 );
5106
5107 // init_matrix(TrasanTRK, Eakal);
5108
5109 double costheta = track_lead.a()[4] / sqrt( 1.0 + track_lead.a()[4] * track_lead.a()[4] );
5110 if ( ( 1.0 / fabs( track_lead.a()[2] ) < pt_cut_ ) && ( fabs( costheta ) > theta_cut_ ) )
5111 { choice_ = 6; }
5112
5113 init_matrix( choice_, TrasanTRK, Eakal );
5114
5115 // std::cout<<" Eakal be here: "<<Eakal<<std::endl;
5116
5117 if ( debug_ == 4 )
5118 {
5119 std::cout << "from Mdc Pattern Recognition: " << std::endl;
5120 // HepPoint3D IP(0,0,0);
5121 Helix work( track_lead.pivot(), track_lead.a(), track_lead.Ea() );
5122 work.pivot( IP );
5123 std::cout << " dr = " << work.a()[0] << ", Er_dr = " << sqrt( work.Ea()[0][0] )
5124 << std::endl;
5125 std::cout << " phi0 = " << work.a()[1] << ", Er_phi0 = " << sqrt( work.Ea()[1][1] )
5126 << std::endl;
5127 std::cout << " PT = " << 1 / work.a()[2] << ", Er_kappa = " << sqrt( work.Ea()[2][2] )
5128 << std::endl;
5129 std::cout << " dz = " << work.a()[3] << ", Er_dz = " << sqrt( work.Ea()[3][3] )
5130 << std::endl;
5131 std::cout << " tanl = " << work.a()[4] << ", Er_tanl = " << sqrt( work.Ea()[4][4] )
5132 << std::endl;
5133 }
5134 filter_fwd_calib( track_lead, lead_, way, Eakal );
5135 track_lead.update_forMdc();
5136
5137 // HepPoint3D IP(0,0,0);
5138 if ( debug_ == 4 )
5139 {
5140 cout << " Mdc FIRST KALMAN FIT " << std::endl;
5141 Helix work1( track_lead.pivot(), track_lead.a(), track_lead.Ea() );
5142 work1.pivot( IP );
5143 cout << " dr = " << work1.a()[0] << ", Er_dr = " << sqrt( work1.Ea()[0][0] ) << std::endl;
5144 cout << " phi0 = " << work1.a()[1] << ", Er_phi0 = " << sqrt( work1.Ea()[1][1] )
5145 << std::endl;
5146 cout << " PT = " << 1 / work1.a()[2] << ", Er_kappa = " << sqrt( work1.Ea()[2][2] )
5147 << std::endl;
5148 cout << " dz = " << work1.a()[3] << ", Er_dz = " << sqrt( work1.Ea()[3][3] ) << std::endl;
5149 cout << " tanl = " << work1.a()[4] << ", Er_tanl = " << sqrt( work1.Ea()[4][4] )
5150 << std::endl;
5151 }
5152
5153 // fill TDS
5154 RecMdcKalTrack* kaltrk = new RecMdcKalTrack;
5155
5156 // Complete the track (other mass assumption, backward) and
5157 complete_track( TrasanTRK, TrasanTRK_add, track_lead, kaltrk, kalcol, segcol );
5158 // }
5159
5160 StatusCode kalsc;
5161 // check whether the RecMdcKalTrackCol has been already registered
5162 DataObject* aRecKalEvent;
5163 eventSvc()->findObject( "/Event/Recon/RecMdcKalTrackCol", aRecKalEvent );
5164 if ( aRecKalEvent )
5165 {
5166 // then unregister RecMdcKalCol
5167 kalsc = eventSvc()->unregisterObject( "/Event/Recon/RecMdcKalTrackCol" );
5168 if ( kalsc != StatusCode::SUCCESS )
5169 {
5170 log << MSG::FATAL << "Could not unregister RecMdcKalTrack collection" << endmsg;
5171 return;
5172 }
5173 }
5174
5175 kalsc = eventSvc()->registerObject( "/Event/Recon/RecMdcKalTrackCol", kalcol );
5176 if ( kalsc.isFailure() )
5177 {
5178 log << MSG::FATAL << "Could not register RecMdcKalTrack" << endmsg;
5179 return;
5180 }
5181 log << MSG::INFO << "RecMdcKalTrackCol registered successfully!" << endmsg;
5182
5183 StatusCode segsc;
5184 // check whether the RecMdcKalHelixSegCol has been already registered
5185 DataObject* aRecKalSegEvent;
5186 eventSvc()->findObject( "/Event/Recon/RecMdcKalHelixSegCol", aRecKalSegEvent );
5187 if ( aRecKalSegEvent )
5188 {
5189 // then unregister RecMdcKalHelixSegCol
5190 segsc = eventSvc()->unregisterObject( "/Event/Recon/RecMdcKalHelixSegCol" );
5191 if ( segsc != StatusCode::SUCCESS )
5192 {
5193 log << MSG::FATAL << "Could not unregister RecMdcKalHelixSegCol collection" << endmsg;
5194 return;
5195 }
5196 }
5197
5198 segsc = eventSvc()->registerObject( "/Event/Recon/RecMdcKalHelixSegCol", segcol );
5199 if ( segsc.isFailure() )
5200 {
5201 log << MSG::FATAL << "Could not register RecMdcKalHelixSeg" << endmsg;
5202 return;
5203 }
5204 log << MSG::INFO << "RecMdcKalHelixSegCol registered successfully!" << endmsg;
5205
5206 double x1( 0. ), x2( 0. ), y1( 0. ), y2( 0. ), z1( 0. ), z2( 0. ), the1( 0. ), the2( 0. ),
5207 phi1( 0. ), phi2( 0. ), p1( 0. ), p2( 0. );
5208 double r1( 0. ), r2( 0. ), kap1( 999. ), kap2( 999. ), tanl1( 0. ), tanl2( 0. );
5209 // check the result:RecMdcKalTrackCol
5210
5211 SmartDataPtr<RecMdcKalTrackCol> kaltrkCol( eventSvc(), "/Event/Recon/RecMdcKalTrackCol" );
5212 if ( !kaltrkCol )
5213 {
5214 log << MSG::FATAL << "Could not find RecMdcKalTrackCol" << endmsg;
5215 return;
5216 }
5217 log << MSG::INFO << "Begin to check RecMdcKalTrackCol" << endmsg;
5218 RecMdcKalTrackCol::iterator iter_trk = kaltrkCol->begin();
5219 for ( int jj = 1; iter_trk != kaltrkCol->end(); iter_trk++, jj++ )
5220 {
5221 log << MSG::DEBUG << "retrieved MDC Kalmantrack:"
5222 << "Track Id: " << ( *iter_trk )->getTrackId()
5223 << " Mass of the fit: " << ( *iter_trk )->getMass( 2 ) << endmsg
5224 << " Length of the track: " << ( *iter_trk )->getLength( 2 )
5225 << " Tof of the track: " << ( *iter_trk )->getTof( 2 ) << endmsg
5226 << " Chisq of the fit: " << ( *iter_trk )->getChisq( 0, 2 ) << " "
5227 << ( *iter_trk )->getChisq( 1, 2 ) << endmsg
5228 << "Ndf of the fit: " << ( *iter_trk )->getNdf( 0, 1 ) << " "
5229 << ( *iter_trk )->getNdf( 1, 2 ) << endmsg << "Kappa " << ( *iter_trk )->getZHelix()[2]
5230 << "zhelixmu " << ( *iter_trk )->getZHelixMu() << endmsg;
5231
5232 HelixSegRefVec gothelixsegs = ( *iter_trk )->getVecHelixSegs();
5233 if ( debug_ == 4 )
5234 { std::cout << "the size of gothelixsegs ..." << gothelixsegs.size() << std::endl; }
5235
5236 HelixSegRefVec::iterator it_gothelixseg = gothelixsegs.begin();
5237 for ( ; it_gothelixseg != gothelixsegs.end(); it_gothelixseg++ )
5238 {
5239 if ( debug_ == 4 )
5240 {
5241 std::cout << "the layerId of this helixseg is ..." << ( *it_gothelixseg )->getLayerId()
5242 << std::endl;
5243 std::cout << "the residual of this helixseg exclude the meas hit"
5244 << ( *it_gothelixseg )->getResExcl() << std::endl;
5245 std::cout << "the residual of this helixseg include the meas hit"
5246 << ( *it_gothelixseg )->getResIncl() << std::endl;
5247 std::cout << "the track id of the helixseg is ..." << ( *it_gothelixseg )->getTrackId()
5248 << std::endl;
5249 std::cout << "the tof of the helixseg is ..." << ( *it_gothelixseg )->getTof()
5250 << std::endl;
5251 std::cout << "the Zhit of the helixseg is ..." << ( *it_gothelixseg )->getZhit()
5252 << std::endl;
5253 }
5254 }
5255 for ( int i = 0; i < 43; i++ )
5256 {
5257 log << MSG::DEBUG << "retrieved pathl[" << i << "]= " << ( *iter_trk )->getPathl( i )
5258 << endmsg;
5259 }
5260
5261 if ( ntuple_ & 1 )
5262 {
5263 m_trackid = ( *iter_trk )->getTrackId();
5264 for ( int jj = 0, iii = 0; jj < 5; jj++ )
5265 {
5266 m_length[jj] = ( *iter_trk )->getLength( jj );
5267 m_tof[jj] = ( *iter_trk )->getTof( jj );
5268 m_nhits[jj] = ( *iter_trk )->getNhits( jj );
5269 m_zhelix[jj] = ( *iter_trk )->getZHelix()[jj];
5270 m_zhelixe[jj] = ( *iter_trk )->getZHelixE()[jj];
5271 m_zhelixmu[jj] = ( *iter_trk )->getZHelixMu()[jj];
5272 m_zhelixk[jj] = ( *iter_trk )->getZHelixK()[jj];
5273 m_zhelixp[jj] = ( *iter_trk )->getZHelixP()[jj];
5274 m_fhelix[jj] = ( *iter_trk )->getFHelix()[jj];
5275 m_fhelixe[jj] = ( *iter_trk )->getFHelixE()[jj];
5276 m_fhelixmu[jj] = ( *iter_trk )->getFHelixMu()[jj];
5277 m_fhelixk[jj] = ( *iter_trk )->getFHelixK()[jj];
5278 m_fhelixp[jj] = ( *iter_trk )->getFHelixP()[jj];
5279 m_lhelix[jj] = ( *iter_trk )->getLHelix()[jj];
5280 m_lhelixe[jj] = ( *iter_trk )->getLHelixE()[jj];
5281 m_lhelixmu[jj] = ( *iter_trk )->getLHelixMu()[jj];
5282 m_lhelixk[jj] = ( *iter_trk )->getLHelixK()[jj];
5283 m_lhelixp[jj] = ( *iter_trk )->getLHelixP()[jj];
5284 if ( ntuple_ & 32 )
5285 {
5286 for ( int kk = 0; kk <= jj; kk++, iii++ )
5287 {
5288 m_zerror[iii] = ( *iter_trk )->getZError()[jj][kk];
5289 m_zerrore[iii] = ( *iter_trk )->getZErrorE()[jj][kk];
5290 m_zerrormu[iii] = ( *iter_trk )->getZErrorMu()[jj][kk];
5291 m_zerrork[iii] = ( *iter_trk )->getZErrorK()[jj][kk];
5292 m_zerrorp[iii] = ( *iter_trk )->getZErrorP()[jj][kk];
5293 m_ferror[iii] = ( *iter_trk )->getFError()[jj][kk];
5294 m_ferrore[iii] = ( *iter_trk )->getFErrorE()[jj][kk];
5295 m_ferrormu[iii] = ( *iter_trk )->getFErrorMu()[jj][kk];
5296 m_ferrork[iii] = ( *iter_trk )->getFErrorK()[jj][kk];
5297 m_ferrorp[iii] = ( *iter_trk )->getFErrorP()[jj][kk];
5298 m_lerror[iii] = ( *iter_trk )->getLError()[jj][kk];
5299 m_lerrore[iii] = ( *iter_trk )->getLErrorE()[jj][kk];
5300 m_lerrormu[iii] = ( *iter_trk )->getLErrorMu()[jj][kk];
5301 m_lerrork[iii] = ( *iter_trk )->getLErrorK()[jj][kk];
5302 m_lerrorp[iii] = ( *iter_trk )->getLErrorP()[jj][kk];
5303 }
5304 }
5305 }
5306
5307 // RootConversion changed in BOSS6.0, so use thefollowing:
5308 m_chisq[0][0] = ( *iter_trk )->getChisq( 0, 0 );
5309 m_chisq[1][0] = ( *iter_trk )->getChisq( 0, 1 );
5310 m_chisq[2][0] = ( *iter_trk )->getChisq( 0, 2 );
5311 m_chisq[3][0] = ( *iter_trk )->getChisq( 0, 3 );
5312 m_chisq[4][0] = ( *iter_trk )->getChisq( 0, 4 );
5313 m_chisq[0][1] = ( *iter_trk )->getChisq( 1, 0 );
5314 m_chisq[1][1] = ( *iter_trk )->getChisq( 1, 1 );
5315 m_chisq[2][1] = ( *iter_trk )->getChisq( 1, 2 );
5316 m_chisq[3][1] = ( *iter_trk )->getChisq( 1, 3 );
5317 m_chisq[4][1] = ( *iter_trk )->getChisq( 1, 4 );
5318
5319 m_ndf[0][0] = ( *iter_trk )->getNdf( 0, 0 );
5320 m_ndf[1][0] = ( *iter_trk )->getNdf( 0, 1 );
5321 m_ndf[2][0] = ( *iter_trk )->getNdf( 0, 2 );
5322 m_ndf[3][0] = ( *iter_trk )->getNdf( 0, 3 );
5323 m_ndf[4][0] = ( *iter_trk )->getNdf( 0, 4 );
5324 m_ndf[0][1] = ( *iter_trk )->getNdf( 1, 0 );
5325 m_ndf[1][1] = ( *iter_trk )->getNdf( 1, 1 );
5326 m_ndf[2][1] = ( *iter_trk )->getNdf( 1, 2 );
5327 m_ndf[3][1] = ( *iter_trk )->getNdf( 1, 3 );
5328 m_ndf[4][1] = ( *iter_trk )->getNdf( 1, 4 );
5329
5330 m_stat[0][0] = ( *iter_trk )->getStat( 0, 0 );
5331 m_stat[1][0] = ( *iter_trk )->getStat( 0, 1 );
5332 m_stat[2][0] = ( *iter_trk )->getStat( 0, 2 );
5333 m_stat[3][0] = ( *iter_trk )->getStat( 0, 3 );
5334 m_stat[4][0] = ( *iter_trk )->getStat( 0, 4 );
5335 m_stat[0][1] = ( *iter_trk )->getStat( 1, 0 );
5336 m_stat[1][1] = ( *iter_trk )->getStat( 1, 1 );
5337 m_stat[2][1] = ( *iter_trk )->getStat( 1, 2 );
5338 m_stat[3][1] = ( *iter_trk )->getStat( 1, 3 );
5339 m_stat[4][1] = ( *iter_trk )->getStat( 1, 4 );
5340
5341 m_fptot = sqrt( 1 + pow( m_fhelix[4], 2 ) ) / m_fhelix[2];
5342 m_fptote = sqrt( 1 + pow( m_fhelixe[4], 2 ) ) / m_fhelixe[2];
5343 m_fptotmu = sqrt( 1 + pow( m_fhelixmu[4], 2 ) ) / m_fhelixmu[2];
5344 m_fptotk = sqrt( 1 + pow( m_fhelixk[4], 2 ) ) / m_fhelixk[2];
5345 m_fptotp = sqrt( 1 + pow( m_fhelixp[4], 2 ) ) / m_fhelixp[2];
5346
5347 m_zpt = 1 / m_zhelix[2];
5348 m_zpte = 1 / m_zhelixe[2];
5349 m_zptmu = 1 / m_zhelixmu[2];
5350 m_zptk = 1 / m_zhelixk[2];
5351 m_zptp = 1 / m_zhelixp[2];
5352
5353 m_fpt = 1 / m_fhelix[2];
5354 m_fpte = 1 / m_fhelixe[2];
5355 m_fptmu = 1 / m_fhelixmu[2];
5356 m_fptk = 1 / m_fhelixk[2];
5357 m_fptp = 1 / m_fhelixp[2];
5358
5359 m_lpt = 1 / m_lhelix[2];
5360 m_lpte = 1 / m_lhelixe[2];
5361 m_lptmu = 1 / m_lhelixmu[2];
5362 m_lptk = 1 / m_lhelixk[2];
5363 m_lptp = 1 / m_lhelixp[2];
5364
5365 m_lptot = sqrt( 1 + pow( m_lhelix[4], 2 ) ) / m_lhelix[2];
5366 m_lptote = sqrt( 1 + pow( m_lhelixe[4], 2 ) ) / m_lhelixe[2];
5367 m_lptotmu = sqrt( 1 + pow( m_lhelixmu[4], 2 ) ) / m_lhelixmu[2];
5368 m_lptotk = sqrt( 1 + pow( m_lhelixk[4], 2 ) ) / m_lhelixk[2];
5369 m_lptotp = sqrt( 1 + pow( m_lhelixp[4], 2 ) ) / m_lhelixp[2];
5370
5371 m_zptot = sqrt( 1 + pow( m_zhelix[4], 2 ) ) / m_zhelix[2];
5372 m_zptote = sqrt( 1 + pow( m_zhelixe[4], 2 ) ) / m_zhelixe[2];
5373 m_zptotmu = sqrt( 1 + pow( m_zhelixmu[4], 2 ) ) / m_zhelixmu[2];
5374 m_zptotk = sqrt( 1 + pow( m_zhelixk[4], 2 ) ) / m_zhelixk[2];
5375 m_zptotp = sqrt( 1 + pow( m_zhelixp[4], 2 ) ) / m_zhelixp[2];
5376 if ( ntuple_ & 32 )
5377 {
5378 m_zsigp = sqrt( pow( ( m_zptot / m_zhelix[2] ), 2 ) * m_zerror[5] +
5379 pow( ( m_zhelix[4] / m_zptot ), 2 ) * pow( ( 1 / m_zhelix[2] ), 4 ) *
5380 m_zerror[14] -
5381 2 * m_zhelix[4] * m_zerror[12] * pow( ( 1 / m_zhelix[2] ), 3 ) );
5382 m_zsigpe = sqrt( pow( ( m_zptote / m_zhelixe[2] ), 2 ) * m_zerrore[5] +
5383 pow( ( m_zhelixe[4] / m_zptote ), 2 ) *
5384 pow( ( 1 / m_zhelixe[2] ), 4 ) * m_zerrore[14] -
5385 2 * m_zhelixe[4] * m_zerrore[12] * pow( ( 1 / m_zhelixe[2] ), 3 ) );
5386 m_zsigpmu =
5387 sqrt( pow( ( m_zptotmu / m_zhelixmu[2] ), 2 ) * m_zerrormu[5] +
5388 pow( ( m_zhelixmu[4] / m_zptotmu ), 2 ) * pow( ( 1 / m_zhelixmu[2] ), 4 ) *
5389 m_zerrormu[14] -
5390 2 * m_zhelixmu[4] * m_zerrormu[12] * pow( ( 1 / m_zhelixmu[2] ), 3 ) );
5391 m_zsigpk = sqrt( pow( ( m_zptotk / m_zhelixk[2] ), 2 ) * m_zerrork[5] +
5392 pow( ( m_zhelixk[4] / m_zptotk ), 2 ) *
5393 pow( ( 1 / m_zhelixk[2] ), 4 ) * m_zerrork[14] -
5394 2 * m_zhelixk[4] * m_zerrork[12] * pow( ( 1 / m_zhelixk[2] ), 3 ) );
5395 m_zsigpp = sqrt( pow( ( m_zptotp / m_zhelixp[2] ), 2 ) * m_zerrorp[5] +
5396 pow( ( m_zhelixp[4] / m_zptotp ), 2 ) *
5397 pow( ( 1 / m_zhelixp[2] ), 4 ) * m_zerrorp[14] -
5398 2 * m_zhelixp[4] * m_zerrorp[12] * pow( ( 1 / m_zhelixp[2] ), 3 ) );
5399 }
5400
5401 StatusCode sc1 = m_nt1->write();
5402 if ( sc1.isFailure() ) cout << "Ntuple1 filling failed!" << endl;
5403 }
5404
5405 if ( ntuple_ & 4 )
5406 {
5407 if ( jj == 1 )
5408 {
5409 phi1 = ( *iter_trk )->getFFi0();
5410 r1 = ( *iter_trk )->getFDr();
5411 z1 = ( *iter_trk )->getFDz();
5412 kap1 = ( *iter_trk )->getFCpa();
5413 tanl1 = ( *iter_trk )->getFTanl();
5414 x1 = r1 * cos( phi1 );
5415 y1 = r1 * sin( phi1 );
5416 p1 = sqrt( 1 + tanl1 * tanl1 ) / kap1;
5417 the1 = M_PI / 2 - atan( tanl1 );
5418 }
5419 else if ( jj == 2 )
5420 {
5421 phi2 = ( *iter_trk )->getFFi0();
5422 r2 = ( *iter_trk )->getFDr();
5423 z2 = ( *iter_trk )->getFDz();
5424 kap2 = ( *iter_trk )->getFCpa();
5425 tanl2 = ( *iter_trk )->getFTanl();
5426 x2 = r1 * cos( phi2 );
5427 y2 = r1 * sin( phi2 );
5428 p2 = sqrt( 1 + tanl2 * tanl2 ) / kap1;
5429 the2 = M_PI / 2 - atan( tanl2 );
5430 }
5431 }
5432 }
5433 if ( ntuple_ & 4 )
5434 {
5435 m_delx = x1 - x2;
5436 m_dely = y1 - y2;
5437 m_delz = z1 - z2;
5438 m_delthe = the1 + the2;
5439 m_delphi = phi1 - phi2;
5440 m_delp = p1 - p2;
5441 StatusCode sc2 = m_nt2->write();
5442 if ( sc2.isFailure() ) cout << "Ntuple2 filling failed!" << endl;
5443 }
5444 delete[] order;
5445 delete[] rCont;
5446 delete[] rGen;
5447 delete[] rOM;
5448
5449 if ( debug_ == 4 ) cout << "Kalfitting finished " << std::endl;
5450}

Referenced by execute().

◆ kalman_fitting_MdcxReco_Csmc_Sew()

void KalFitAlg::kalman_fitting_MdcxReco_Csmc_Sew ( void )

Definition at line 4370 of file KalFitAlg.cxx.

4370 {
4371
4372 MsgStream log( msgSvc(), name() );
4373 double Pt_threshold( 0.3 );
4374 Hep3Vector IP( 0, 0, 0 );
4375
4376 vector<MdcRec_trk>* mdcMgr = MdcRecTrkCol::getMdcRecTrkCol();
4377 vector<MdcRec_trk_add>* mdc_addMgr = MdcRecTrkAddCol::getMdcRecTrkAddCol();
4378 vector<MdcRec_wirhit>* whMgr = MdcRecWirhitCol::getMdcRecWirhitCol();
4379
4380 // Table Manager
4381 if ( !&whMgr ) return;
4382
4383 // Get reduced chi**2 of Mdc track :
4384 int ntrk = mdcMgr->size();
4385 // cout<<"ntrk: "<<ntrk<<endl;
4386
4387 int nhits = whMgr->size();
4388 // cout<<"nhits: "<<nhits<<endl;
4389
4390 // check whether Recon already registered
4391 DataObject* aReconEvent;
4392 eventSvc()->findObject( "/Event/Recon", aReconEvent );
4393 if ( !aReconEvent )
4394 {
4395 // register ReconEvent Data Object to TDS;
4396 ReconEvent* recevt = new ReconEvent;
4397 StatusCode sc = eventSvc()->registerObject( "/Event/Recon", recevt );
4398 if ( sc != StatusCode::SUCCESS )
4399 {
4400 log << MSG::FATAL << "Could not register ReconEvent" << endmsg;
4401 return;
4402 }
4403 }
4404
4407 // make RecMdcKalTrackCol
4408 log << MSG::INFO << "beginning to make RecMdcKalTrackCol" << endmsg;
4409
4410 MdcRec_trk& TrasanTRK = *( mdcMgr->begin() );
4411 MdcRec_trk_add& TrasanTRK_add = *( mdc_addMgr->begin() );
4412 // Reject the ones with quality != 0
4413 // int trasqual = TrasanTRK_add.quality;
4414 // if(debug_ == 4) cout<<"kalman_fitting>trasqual... "<<trasqual<<endl;
4415 // if (trasqual) continue;
4416
4417 // What kind of KalFit ?
4418 int type( 0 );
4419 if ( ( TrasanTRK_add.decision & 32 ) == 32 || ( TrasanTRK_add.decision & 64 ) == 64 )
4420 type = 1;
4421
4422 // Initialisation : (x, a, ea)
4423 HepPoint3D x( TrasanTRK.pivot[0], TrasanTRK.pivot[1], TrasanTRK.pivot[2] );
4424
4425 HepVector a( 5 );
4426 for ( int i = 0; i < 5; i++ ) a[i] = TrasanTRK.helix[i];
4427
4428 HepSymMatrix ea( 5 );
4429 for ( int i = 0, k = 0; i < 5; i++ )
4430 {
4431 for ( int j = 0; j <= i; j++ )
4432 {
4433 ea[i][j] = matrixg_ * TrasanTRK.error[k++];
4434 ea[j][i] = ea[i][j];
4435 }
4436 }
4437
4439
4440 double fiTerm = TrasanTRK.fiTerm;
4441 int way( 1 );
4442 // Prepare the track found :
4443 KalFitTrack track_lead = KalFitTrack( x, a, ea, lead_, 0, 0 );
4444 track_lead.bFieldZ( KalFitTrack::Bznom_ );
4445
4446 int hit_asso( 0 );
4447 // Reject the ones with quality != 0
4448 int trasqual = TrasanTRK_add.quality;
4449 if ( debug_ == 4 ) cout << "kalman_fitting>trasqual... " << trasqual << endl;
4450 if ( trasqual ) return;
4451 // Mdc Hits
4452 int inlyr( 999 ), outlyr( -1 );
4453 int* rStat = new int[43];
4454 for ( int irStat = 0; irStat < 43; ++irStat ) rStat[irStat] = 0;
4455 std::vector<MdcRec_wirhit*> pt = TrasanTRK.hitcol;
4456 int hit_in( 0 );
4457 if ( debug_ == 4 ) cout << "*********Pt size****" << pt.size() << endl;
4458 // Number of hits/layer
4459 int Num[43] = { 0 };
4460 for ( vector<MdcRec_wirhit*>::iterator ii = pt.end() - 1; ii != pt.begin() - 1; ii-- )
4461 { Num[( *ii )->geo->Lyr()->Id()]++; }
4462
4463 for ( vector<MdcRec_wirhit*>::iterator ii = pt.end() - 1; ii != pt.begin() - 1; ii-- )
4464 {
4465
4466 hit_asso++;
4467 if ( Num[( *ii )->geo->Lyr()->Id()] > 3 )
4468 {
4469 if ( debug_ > 0 )
4470 cout << "WARNING: I found " << Num[( *ii )->geo->Lyr()->Id()] << " hits in the layer "
4471 << ( *ii )->geo->Lyr()->Id() << std::endl;
4472 continue;
4473 }
4474
4475 hit_in++;
4476 MdcRec_wirhit& rechit = **ii;
4477 double dist[2] = { rechit.ddl, rechit.ddr };
4478 double erdist[2] = { rechit.erddl, rechit.erddr };
4479 const MdcGeoWire* geo = rechit.geo;
4480
4481 int lr_decision( 0 );
4482 if ( KalFitTrack::LR_ == 1 )
4483 {
4484 if ( rechit.lr == 2 || rechit.lr == 0 ) lr_decision = -1;
4485 // if (rechit.lr==0) lr_decision=-1;
4486 else if ( rechit.lr == 1 ) lr_decision = 1;
4487 }
4488
4489 int ind( geo->Lyr()->Id() );
4490 track_lead.appendHitsMdc( KalFitHitMdc( rechit.id, lr_decision, rechit.tdc, dist, erdist,
4491 _wire + ( geo->Id() ), rechit.rechitptr ) );
4492 // inner/outer layer :
4493 rStat[ind]++;
4494 if ( inlyr > ind ) inlyr = ind;
4495 if ( outlyr < ind ) outlyr = ind;
4496 }
4497 // Empty layers :
4498 int empty_between( 0 ), empty( 0 );
4499 for ( int i = inlyr; i <= outlyr; i++ )
4500 if ( !rStat[i] ) empty_between++;
4501 empty = empty_between + inlyr + ( 42 - outlyr );
4502 delete[] rStat;
4503
4504 if ( debug_ == 4 ) cout << "**** NUMBER OF Mdc HITS (TRASAN) = " << hit_asso << std::endl;
4505
4506 // RMK high momentum track under study, probably not neeeded...
4507 track_lead.order_wirhit( 0 );
4508 track_lead.type( type );
4509 unsigned int nhit = track_lead.HitsMdc().size();
4510 if ( nhit < 70 )
4511 {
4512 cout << " ATTENTION TRACK WITH ONLY HITS " << nhit << std::endl;
4513 return;
4514 }
4515
4516 // Initialisation :
4517 double KalFitst( 0 ), KalFitax( 0 ), KalFitschi2( 0 );
4518 // Move to the outer most hit :
4519 Hep3Vector outer_pivot( track_lead.x( fiTerm ) );
4520
4521 if ( debug_ == 4 )
4522 {
4523 std::cout << "before track_lead.pivot(outer_pivot) ,the error matrix of track_lead is .."
4524 << track_lead.Ea() << std::endl;
4525 }
4526 track_lead.pivot( outer_pivot ); // hi gay, the error matrix is changed in this function!!
4527 track_lead.bFieldZ( KalFitTrack::Bznom_ );
4528 // attention best_chi2 reinitialize !!!
4529 if ( nhit >= 3 && !KalFitTrack::LR_ ) start_seed( track_lead, lead_, way, TrasanTRK );
4530 HepSymMatrix Eakal( 5, 0 );
4531
4532 // init_matrix(TrasanTRK, Eakal);
4533
4534 double costheta = track_lead.a()[4] / sqrt( 1.0 + track_lead.a()[4] * track_lead.a()[4] );
4535 if ( ( 1.0 / fabs( track_lead.a()[2] ) < pt_cut_ ) && ( fabs( costheta ) > theta_cut_ ) )
4536 { choice_ = 6; }
4537
4538 init_matrix( choice_, TrasanTRK, Eakal );
4539
4540 // std::cout<<" Eakal be here: "<<Eakal<<std::endl;
4541
4542 if ( debug_ == 4 )
4543 {
4544 std::cout << "from Mdc Pattern Recognition: " << std::endl;
4545 // HepPoint3D IP(0,0,0);
4546 Helix work( track_lead.pivot(), track_lead.a(), track_lead.Ea() );
4547 work.pivot( IP );
4548 std::cout << " dr = " << work.a()[0] << ", Er_dr = " << sqrt( work.Ea()[0][0] )
4549 << std::endl;
4550 std::cout << " phi0 = " << work.a()[1] << ", Er_phi0 = " << sqrt( work.Ea()[1][1] )
4551 << std::endl;
4552 std::cout << " PT = " << 1 / work.a()[2] << ", Er_kappa = " << sqrt( work.Ea()[2][2] )
4553 << std::endl;
4554 std::cout << " dz = " << work.a()[3] << ", Er_dz = " << sqrt( work.Ea()[3][3] )
4555 << std::endl;
4556 std::cout << " tanl = " << work.a()[4] << ", Er_tanl = " << sqrt( work.Ea()[4][4] )
4557 << std::endl;
4558 }
4559 filter_fwd_calib( track_lead, lead_, way, Eakal );
4560 track_lead.update_forMdc();
4561
4562 // HepPoint3D IP(0,0,0);
4563 if ( debug_ == 4 )
4564 {
4565 cout << " Mdc FIRST KALMAN FIT " << std::endl;
4566 Helix work1( track_lead.pivot(), track_lead.a(), track_lead.Ea() );
4567 work1.pivot( IP );
4568 cout << " dr = " << work1.a()[0] << ", Er_dr = " << sqrt( work1.Ea()[0][0] ) << std::endl;
4569 cout << " phi0 = " << work1.a()[1] << ", Er_phi0 = " << sqrt( work1.Ea()[1][1] )
4570 << std::endl;
4571 cout << " PT = " << 1 / work1.a()[2] << ", Er_kappa = " << sqrt( work1.Ea()[2][2] )
4572 << std::endl;
4573 cout << " dz = " << work1.a()[3] << ", Er_dz = " << sqrt( work1.Ea()[3][3] ) << std::endl;
4574 cout << " tanl = " << work1.a()[4] << ", Er_tanl = " << sqrt( work1.Ea()[4][4] )
4575 << std::endl;
4576 }
4577
4578 // fill TDS
4579 RecMdcKalTrack* kaltrk = new RecMdcKalTrack;
4580
4581 // Complete the track (other mass assumption, backward) and
4582 complete_track( TrasanTRK, TrasanTRK_add, track_lead, kaltrk, kalcol, segcol );
4583
4584 StatusCode kalsc;
4585 // check whether the RecMdcKalTrackCol has been already registered
4586 DataObject* aRecKalEvent;
4587 eventSvc()->findObject( "/Event/Recon/RecMdcKalTrackCol", aRecKalEvent );
4588 if ( aRecKalEvent )
4589 {
4590 // then unregister RecMdcKalCol
4591 kalsc = eventSvc()->unregisterObject( "/Event/Recon/RecMdcKalTrackCol" );
4592 if ( kalsc != StatusCode::SUCCESS )
4593 {
4594 log << MSG::FATAL << "Could not unregister RecMdcKalTrack collection" << endmsg;
4595 return;
4596 }
4597 }
4598
4599 kalsc = eventSvc()->registerObject( "/Event/Recon/RecMdcKalTrackCol", kalcol );
4600 if ( kalsc.isFailure() )
4601 {
4602 log << MSG::FATAL << "Could not register RecMdcKalTrack" << endmsg;
4603 return;
4604 }
4605 log << MSG::INFO << "RecMdcKalTrackCol registered successfully!" << endmsg;
4606
4607 StatusCode segsc;
4608 // check whether the RecMdcKalHelixSegCol has been already registered
4609 DataObject* aRecKalSegEvent;
4610 eventSvc()->findObject( "/Event/Recon/RecMdcKalHelixSegCol", aRecKalSegEvent );
4611 if ( aRecKalSegEvent )
4612 {
4613 // then unregister RecMdcKalHelixSegCol
4614 segsc = eventSvc()->unregisterObject( "/Event/Recon/RecMdcKalHelixSegCol" );
4615 if ( segsc != StatusCode::SUCCESS )
4616 {
4617 log << MSG::FATAL << "Could not unregister RecMdcKalHelixSegCol collection" << endmsg;
4618 return;
4619 }
4620 }
4621
4622 segsc = eventSvc()->registerObject( "/Event/Recon/RecMdcKalHelixSegCol", segcol );
4623 if ( segsc.isFailure() )
4624 {
4625 log << MSG::FATAL << "Could not register RecMdcKalHelixSeg" << endmsg;
4626 return;
4627 }
4628 log << MSG::INFO << "RecMdcKalHelixSegCol registered successfully!" << endmsg;
4629
4630 double x1( 0. ), x2( 0. ), y1( 0. ), y2( 0. ), z1( 0. ), z2( 0. ), the1( 0. ), the2( 0. ),
4631 phi1( 0. ), phi2( 0. ), p1( 0. ), p2( 0. );
4632 double r1( 0. ), r2( 0. ), kap1( 999. ), kap2( 999. ), tanl1( 0. ), tanl2( 0. );
4633 // check the result:RecMdcKalTrackCol
4634
4635 SmartDataPtr<RecMdcKalTrackCol> kaltrkCol( eventSvc(), "/Event/Recon/RecMdcKalTrackCol" );
4636 if ( !kaltrkCol )
4637 {
4638 log << MSG::FATAL << "Could not find RecMdcKalTrackCol" << endmsg;
4639 return;
4640 }
4641 log << MSG::INFO << "Begin to check RecMdcKalTrackCol" << endmsg;
4642 RecMdcKalTrackCol::iterator iter_trk = kaltrkCol->begin();
4643 for ( int jj = 1; iter_trk != kaltrkCol->end(); iter_trk++, jj++ )
4644 {
4645 log << MSG::DEBUG << "retrieved MDC Kalmantrack:"
4646 << "Track Id: " << ( *iter_trk )->getTrackId()
4647 << " Mass of the fit: " << ( *iter_trk )->getMass( 2 ) << endmsg
4648 << " Length of the track: " << ( *iter_trk )->getLength( 2 )
4649 << " Tof of the track: " << ( *iter_trk )->getTof( 2 ) << endmsg
4650 << " Chisq of the fit: " << ( *iter_trk )->getChisq( 0, 2 ) << " "
4651 << ( *iter_trk )->getChisq( 1, 2 ) << endmsg
4652 << "Ndf of the fit: " << ( *iter_trk )->getNdf( 0, 1 ) << " "
4653 << ( *iter_trk )->getNdf( 1, 2 ) << endmsg << "Kappa " << ( *iter_trk )->getZHelix()[2]
4654 << "zhelixmu " << ( *iter_trk )->getZHelixMu() << endmsg;
4655
4656 HelixSegRefVec gothelixsegs = ( *iter_trk )->getVecHelixSegs();
4657 if ( debug_ == 4 )
4658 { std::cout << "the size of gothelixsegs ..." << gothelixsegs.size() << std::endl; }
4659
4660 HelixSegRefVec::iterator it_gothelixseg = gothelixsegs.begin();
4661 for ( ; it_gothelixseg != gothelixsegs.end(); it_gothelixseg++ )
4662 {
4663 if ( debug_ == 4 )
4664 {
4665 std::cout << "the layerId of this helixseg is ..." << ( *it_gothelixseg )->getLayerId()
4666 << std::endl;
4667 std::cout << "the residual of this helixseg exclude the meas hit"
4668 << ( *it_gothelixseg )->getResExcl() << std::endl;
4669 std::cout << "the residual of this helixseg include the meas hit"
4670 << ( *it_gothelixseg )->getResIncl() << std::endl;
4671 std::cout << "the track id of the helixseg is ..." << ( *it_gothelixseg )->getTrackId()
4672 << std::endl;
4673 std::cout << "the tof of the helixseg is ..." << ( *it_gothelixseg )->getTof()
4674 << std::endl;
4675 std::cout << "the Zhit of the helixseg is ..." << ( *it_gothelixseg )->getZhit()
4676 << std::endl;
4677 }
4678 }
4679 for ( int i = 0; i < 43; i++ )
4680 {
4681 log << MSG::DEBUG << "retrieved pathl[" << i << "]= " << ( *iter_trk )->getPathl( i )
4682 << endmsg;
4683 }
4684
4685 if ( ntuple_ & 1 )
4686 {
4687 m_trackid = ( *iter_trk )->getTrackId();
4688 for ( int jj = 0, iii = 0; jj < 5; jj++ )
4689 {
4690 m_length[jj] = ( *iter_trk )->getLength( jj );
4691 m_tof[jj] = ( *iter_trk )->getTof( jj );
4692 m_nhits[jj] = ( *iter_trk )->getNhits( jj );
4693 m_zhelix[jj] = ( *iter_trk )->getZHelix()[jj];
4694 m_zhelixe[jj] = ( *iter_trk )->getZHelixE()[jj];
4695 m_zhelixmu[jj] = ( *iter_trk )->getZHelixMu()[jj];
4696 m_zhelixk[jj] = ( *iter_trk )->getZHelixK()[jj];
4697 m_zhelixp[jj] = ( *iter_trk )->getZHelixP()[jj];
4698 m_fhelix[jj] = ( *iter_trk )->getFHelix()[jj];
4699 m_fhelixe[jj] = ( *iter_trk )->getFHelixE()[jj];
4700 m_fhelixmu[jj] = ( *iter_trk )->getFHelixMu()[jj];
4701 m_fhelixk[jj] = ( *iter_trk )->getFHelixK()[jj];
4702 m_fhelixp[jj] = ( *iter_trk )->getFHelixP()[jj];
4703 m_lhelix[jj] = ( *iter_trk )->getLHelix()[jj];
4704 m_lhelixe[jj] = ( *iter_trk )->getLHelixE()[jj];
4705 m_lhelixmu[jj] = ( *iter_trk )->getLHelixMu()[jj];
4706 m_lhelixk[jj] = ( *iter_trk )->getLHelixK()[jj];
4707 m_lhelixp[jj] = ( *iter_trk )->getLHelixP()[jj];
4708 if ( ntuple_ & 32 )
4709 {
4710 for ( int kk = 0; kk <= jj; kk++, iii++ )
4711 {
4712 m_zerror[iii] = ( *iter_trk )->getZError()[jj][kk];
4713 m_zerrore[iii] = ( *iter_trk )->getZErrorE()[jj][kk];
4714 m_zerrormu[iii] = ( *iter_trk )->getZErrorMu()[jj][kk];
4715 m_zerrork[iii] = ( *iter_trk )->getZErrorK()[jj][kk];
4716 m_zerrorp[iii] = ( *iter_trk )->getZErrorP()[jj][kk];
4717 m_ferror[iii] = ( *iter_trk )->getFError()[jj][kk];
4718 m_ferrore[iii] = ( *iter_trk )->getFErrorE()[jj][kk];
4719 m_ferrormu[iii] = ( *iter_trk )->getFErrorMu()[jj][kk];
4720 m_ferrork[iii] = ( *iter_trk )->getFErrorK()[jj][kk];
4721 m_ferrorp[iii] = ( *iter_trk )->getFErrorP()[jj][kk];
4722 m_lerror[iii] = ( *iter_trk )->getLError()[jj][kk];
4723 m_lerrore[iii] = ( *iter_trk )->getLErrorE()[jj][kk];
4724 m_lerrormu[iii] = ( *iter_trk )->getLErrorMu()[jj][kk];
4725 m_lerrork[iii] = ( *iter_trk )->getLErrorK()[jj][kk];
4726 m_lerrorp[iii] = ( *iter_trk )->getLErrorP()[jj][kk];
4727 }
4728 }
4729 }
4730
4731 // RootConversion changed in BOSS6.0, so use thefollowing:
4732 m_chisq[0][0] = ( *iter_trk )->getChisq( 0, 0 );
4733 m_chisq[1][0] = ( *iter_trk )->getChisq( 0, 1 );
4734 m_chisq[2][0] = ( *iter_trk )->getChisq( 0, 2 );
4735 m_chisq[3][0] = ( *iter_trk )->getChisq( 0, 3 );
4736 m_chisq[4][0] = ( *iter_trk )->getChisq( 0, 4 );
4737 m_chisq[0][1] = ( *iter_trk )->getChisq( 1, 0 );
4738 m_chisq[1][1] = ( *iter_trk )->getChisq( 1, 1 );
4739 m_chisq[2][1] = ( *iter_trk )->getChisq( 1, 2 );
4740 m_chisq[3][1] = ( *iter_trk )->getChisq( 1, 3 );
4741 m_chisq[4][1] = ( *iter_trk )->getChisq( 1, 4 );
4742
4743 m_ndf[0][0] = ( *iter_trk )->getNdf( 0, 0 );
4744 m_ndf[1][0] = ( *iter_trk )->getNdf( 0, 1 );
4745 m_ndf[2][0] = ( *iter_trk )->getNdf( 0, 2 );
4746 m_ndf[3][0] = ( *iter_trk )->getNdf( 0, 3 );
4747 m_ndf[4][0] = ( *iter_trk )->getNdf( 0, 4 );
4748 m_ndf[0][1] = ( *iter_trk )->getNdf( 1, 0 );
4749 m_ndf[1][1] = ( *iter_trk )->getNdf( 1, 1 );
4750 m_ndf[2][1] = ( *iter_trk )->getNdf( 1, 2 );
4751 m_ndf[3][1] = ( *iter_trk )->getNdf( 1, 3 );
4752 m_ndf[4][1] = ( *iter_trk )->getNdf( 1, 4 );
4753
4754 m_stat[0][0] = ( *iter_trk )->getStat( 0, 0 );
4755 m_stat[1][0] = ( *iter_trk )->getStat( 0, 1 );
4756 m_stat[2][0] = ( *iter_trk )->getStat( 0, 2 );
4757 m_stat[3][0] = ( *iter_trk )->getStat( 0, 3 );
4758 m_stat[4][0] = ( *iter_trk )->getStat( 0, 4 );
4759 m_stat[0][1] = ( *iter_trk )->getStat( 1, 0 );
4760 m_stat[1][1] = ( *iter_trk )->getStat( 1, 1 );
4761 m_stat[2][1] = ( *iter_trk )->getStat( 1, 2 );
4762 m_stat[3][1] = ( *iter_trk )->getStat( 1, 3 );
4763 m_stat[4][1] = ( *iter_trk )->getStat( 1, 4 );
4764
4765 m_fptot = sqrt( 1 + pow( m_fhelix[4], 2 ) ) / m_fhelix[2];
4766 m_fptote = sqrt( 1 + pow( m_fhelixe[4], 2 ) ) / m_fhelixe[2];
4767 m_fptotmu = sqrt( 1 + pow( m_fhelixmu[4], 2 ) ) / m_fhelixmu[2];
4768 m_fptotk = sqrt( 1 + pow( m_fhelixk[4], 2 ) ) / m_fhelixk[2];
4769 m_fptotp = sqrt( 1 + pow( m_fhelixp[4], 2 ) ) / m_fhelixp[2];
4770
4771 m_zpt = 1 / m_zhelix[2];
4772 m_zpte = 1 / m_zhelixe[2];
4773 m_zptmu = 1 / m_zhelixmu[2];
4774 m_zptk = 1 / m_zhelixk[2];
4775 m_zptp = 1 / m_zhelixp[2];
4776
4777 m_fpt = 1 / m_fhelix[2];
4778 m_fpte = 1 / m_fhelixe[2];
4779 m_fptmu = 1 / m_fhelixmu[2];
4780 m_fptk = 1 / m_fhelixk[2];
4781 m_fptp = 1 / m_fhelixp[2];
4782
4783 m_lpt = 1 / m_lhelix[2];
4784 m_lpte = 1 / m_lhelixe[2];
4785 m_lptmu = 1 / m_lhelixmu[2];
4786 m_lptk = 1 / m_lhelixk[2];
4787 m_lptp = 1 / m_lhelixp[2];
4788
4789 m_lptot = sqrt( 1 + pow( m_lhelix[4], 2 ) ) / m_lhelix[2];
4790 m_lptote = sqrt( 1 + pow( m_lhelixe[4], 2 ) ) / m_lhelixe[2];
4791 m_lptotmu = sqrt( 1 + pow( m_lhelixmu[4], 2 ) ) / m_lhelixmu[2];
4792 m_lptotk = sqrt( 1 + pow( m_lhelixk[4], 2 ) ) / m_lhelixk[2];
4793 m_lptotp = sqrt( 1 + pow( m_lhelixp[4], 2 ) ) / m_lhelixp[2];
4794
4795 m_zptot = sqrt( 1 + pow( m_zhelix[4], 2 ) ) / m_zhelix[2];
4796 m_zptote = sqrt( 1 + pow( m_zhelixe[4], 2 ) ) / m_zhelixe[2];
4797 m_zptotmu = sqrt( 1 + pow( m_zhelixmu[4], 2 ) ) / m_zhelixmu[2];
4798 m_zptotk = sqrt( 1 + pow( m_zhelixk[4], 2 ) ) / m_zhelixk[2];
4799 m_zptotp = sqrt( 1 + pow( m_zhelixp[4], 2 ) ) / m_zhelixp[2];
4800 if ( ntuple_ & 32 )
4801 {
4802 m_zsigp = sqrt( pow( ( m_zptot / m_zhelix[2] ), 2 ) * m_zerror[5] +
4803 pow( ( m_zhelix[4] / m_zptot ), 2 ) * pow( ( 1 / m_zhelix[2] ), 4 ) *
4804 m_zerror[14] -
4805 2 * m_zhelix[4] * m_zerror[12] * pow( ( 1 / m_zhelix[2] ), 3 ) );
4806 m_zsigpe = sqrt( pow( ( m_zptote / m_zhelixe[2] ), 2 ) * m_zerrore[5] +
4807 pow( ( m_zhelixe[4] / m_zptote ), 2 ) *
4808 pow( ( 1 / m_zhelixe[2] ), 4 ) * m_zerrore[14] -
4809 2 * m_zhelixe[4] * m_zerrore[12] * pow( ( 1 / m_zhelixe[2] ), 3 ) );
4810 m_zsigpmu =
4811 sqrt( pow( ( m_zptotmu / m_zhelixmu[2] ), 2 ) * m_zerrormu[5] +
4812 pow( ( m_zhelixmu[4] / m_zptotmu ), 2 ) * pow( ( 1 / m_zhelixmu[2] ), 4 ) *
4813 m_zerrormu[14] -
4814 2 * m_zhelixmu[4] * m_zerrormu[12] * pow( ( 1 / m_zhelixmu[2] ), 3 ) );
4815 m_zsigpk = sqrt( pow( ( m_zptotk / m_zhelixk[2] ), 2 ) * m_zerrork[5] +
4816 pow( ( m_zhelixk[4] / m_zptotk ), 2 ) *
4817 pow( ( 1 / m_zhelixk[2] ), 4 ) * m_zerrork[14] -
4818 2 * m_zhelixk[4] * m_zerrork[12] * pow( ( 1 / m_zhelixk[2] ), 3 ) );
4819 m_zsigpp = sqrt( pow( ( m_zptotp / m_zhelixp[2] ), 2 ) * m_zerrorp[5] +
4820 pow( ( m_zhelixp[4] / m_zptotp ), 2 ) *
4821 pow( ( 1 / m_zhelixp[2] ), 4 ) * m_zerrorp[14] -
4822 2 * m_zhelixp[4] * m_zerrorp[12] * pow( ( 1 / m_zhelixp[2] ), 3 ) );
4823 }
4824
4825 StatusCode sc1 = m_nt1->write();
4826 if ( sc1.isFailure() ) cout << "Ntuple1 filling failed!" << endl;
4827 }
4828
4829 if ( ntuple_ & 4 )
4830 {
4831 if ( jj == 1 )
4832 {
4833 phi1 = ( *iter_trk )->getFFi0();
4834 r1 = ( *iter_trk )->getFDr();
4835 z1 = ( *iter_trk )->getFDz();
4836 kap1 = ( *iter_trk )->getFCpa();
4837 tanl1 = ( *iter_trk )->getFTanl();
4838 x1 = r1 * cos( phi1 );
4839 y1 = r1 * sin( phi1 );
4840 p1 = sqrt( 1 + tanl1 * tanl1 ) / kap1;
4841 the1 = M_PI / 2 - atan( tanl1 );
4842 }
4843 else if ( jj == 2 )
4844 {
4845 phi2 = ( *iter_trk )->getFFi0();
4846 r2 = ( *iter_trk )->getFDr();
4847 z2 = ( *iter_trk )->getFDz();
4848 kap2 = ( *iter_trk )->getFCpa();
4849 tanl2 = ( *iter_trk )->getFTanl();
4850 x2 = r1 * cos( phi2 );
4851 y2 = r1 * sin( phi2 );
4852 p2 = sqrt( 1 + tanl2 * tanl2 ) / kap1;
4853 the2 = M_PI / 2 - atan( tanl2 );
4854 }
4855 }
4856 }
4857 if ( ntuple_ & 4 )
4858 {
4859 m_delx = x1 - x2;
4860 m_dely = y1 - y2;
4861 m_delz = z1 - z2;
4862 m_delthe = the1 + the2;
4863 m_delphi = phi1 - phi2;
4864 m_delp = p1 - p2;
4865 StatusCode sc2 = m_nt2->write();
4866 if ( sc2.isFailure() ) cout << "Ntuple2 filling failed!" << endl;
4867 }
4868
4869 if ( debug_ == 4 ) cout << "Kalfitting finished " << std::endl;
4870}

Referenced by execute().

◆ sameas()

void KalFitAlg::sameas ( RecMdcKalTrack * trk,
int l_mass,
int imain )

complete the RecMdcKalTrackCol

Definition at line 2285 of file KalFitAlg.cxx.

2285 {
2286 // note: for this function,only imain==lead(2) considered
2287 // std::cout<<"BEGINNING THE sameas() function ..."<<std::endl;
2288 trk->setMass( trk->getMass( imain ), l_mass );
2289 trk->setLength( trk->getLength( imain ), l_mass );
2290 trk->setTof( trk->getTof( imain ), l_mass );
2291 trk->setNhits( trk->getNhits( imain ), l_mass );
2292
2293 for ( int jj = 0; jj < 2; jj++ )
2294 {
2295 trk->setStat( trk->getStat( jj, imain ), jj, l_mass );
2296 trk->setChisq( trk->getChisq( jj, l_mass ), jj, l_mass );
2297 trk->setNdf( trk->getChisq( jj, l_mass ), jj, l_mass );
2298 }
2299 trk->setLHelix( trk->getFHelix(), l_mass );
2300 trk->setLError( trk->getFError(), l_mass );
2301}

◆ set_Mdc()

void KalFitAlg::set_Mdc ( void )

Set up the wires, layers and superlayers...

Definition at line 108 of file KalFitAlg2.cxx.

108 {
109 IMdcGeomSvc* mdcGeomSvc = imdcGeomSvc_;
110 if ( !mdcGeomSvc )
111 { std::cout << "ERROR OCCUR when dynamic_cast in KalFitAlg2.cxx ..!!" << std::endl; }
112
113 if ( debug_ == 4 ) { cout << "KalFitAlg:: MDC initialisation " << std::endl; }
114 _wire = NULL;
115 _layer = NULL;
116 _superLayer = NULL;
117
118 const int Nwire = mdcGeomSvc->getWireSize();
119 const int Nlyr = mdcGeomSvc->getLayerSize();
120 const int Nsup = mdcGeomSvc->getSuperLayerSize();
121
122 if ( !Nwire || !Nlyr || !Nsup )
123 {
124 cout << ".....MdcGeom Objects are missing !! " << std::endl;
125 exit( -1 );
126 }
127
128 if ( !_wire ) _wire = (KalFitWire*)malloc( ( Nwire + 1 ) * sizeof( KalFitWire ) );
129 if ( !_layer ) _layer = (KalFitLayer_Mdc*)malloc( Nlyr * sizeof( KalFitLayer_Mdc ) );
130 if ( !_superLayer )
131 _superLayer = (KalFitSuper_Mdc*)malloc( Nsup * sizeof( KalFitSuper_Mdc ) );
132
133 if ( !_wire || !_layer || !_superLayer )
134 {
135 std::cerr << "KalFitAlg::Cannot allocate geometries" << std::endl;
136 std::cerr << "JOB will stop" << std::endl;
137 exit( -1 );
138 }
139
140 int superLayerID = 0;
141 int layerID = 0;
142 int localLayerID = 0;
143 int localWireID = 0;
144 int localID = 0;
145 int wireID;
146
147 MdcGeoLayer* layer_back = NULL;
148 MdcGeoSuper* superLayer_back = NULL;
149 int k = 0;
150 int Nlayer[12];
151 int Nlocal[12];
152 int NlocalWireID[43];
153
154 for ( wireID = 0; wireID <= Nwire; wireID++ )
155 {
156 MdcGeoLayer* layer = ( wireID == Nwire ) ? NULL : mdcGeomSvc->Wire( wireID )->Lyr();
157 if ( layer != layer_back )
158 {
159 layer_back = layer;
160 MdcGeoSuper* superLayer =
161 ( wireID == Nwire ) ? NULL : mdcGeomSvc->Layer( layerID )->Sup();
162 if ( superLayer != superLayer_back )
163 {
164 superLayer_back = superLayer;
165 Nlayer[k] = localLayerID;
166 Nlocal[k] = localID;
167 localLayerID = 0;
168 k++;
169 }
170 NlocalWireID[layerID] = localWireID;
171 localID = 0;
172 localWireID = 0;
173 layerID++;
174 localLayerID++;
175 }
176 localID++;
177 localWireID++;
178 }
179
180 superLayerID = -1;
181 layerID = -1;
182 localLayerID = 0;
183 localID = 0;
184 layer_back = NULL;
185 superLayer_back = NULL;
186 for ( wireID = 0; wireID < Nwire; wireID++ )
187 {
188 MdcGeoLayer* layer = ( wireID == Nwire ) ? NULL : mdcGeomSvc->Wire( wireID )->Lyr();
189 if ( layer != layer_back )
190 {
191 layer_back = layer;
192 MdcGeoSuper* superLayer =
193 ( wireID == Nwire ) ? NULL : mdcGeomSvc->Layer( layerID + 1 )->Sup();
194 if ( superLayer != superLayer_back )
195 {
196 superLayer_back = superLayer;
197 // initialize super-layer
198 superLayerID++;
199 new ( _superLayer + superLayerID )
200 KalFitSuper_Mdc( wireID, Nlocal[superLayerID + 1], layerID + 1,
201 Nlayer[superLayerID + 1], superLayerID );
202 localLayerID = 0;
203 }
204 // initialize layer
205 layerID++;
206 double slantWithSymbol = ( mdcGeomSvc->Layer( layerID )->Slant() ) *
207 ( mdcGeomSvc->Layer( layerID )->Sup()->Type() );
208 new ( _layer + layerID ) KalFitLayer_Mdc(
209 _superLayer[superLayerID], 0.1 * layer->Radius(),
210 ( layer->Slant() ) * ( layer->Sup()->Type() ), 0.1 * ( layer->Length() / 2 ),
211 0.1 * ( -layer->Length() / 2 ), layer->Offset(), layerID, localLayerID++ );
212 localID = 0;
213 }
214 // initialize wire
215
216 const MdcGeoWire* wire = ( wireID == Nwire ) ? NULL : mdcGeomSvc->Wire( wireID );
217 HepPoint3D fwd( 0.1 * wire->Backward() );
218 HepPoint3D bck( 0.1 * wire->Forward() );
219
220 if ( superLayerID == 2 || superLayerID == 3 || superLayerID == 4 || superLayerID == 9 ||
221 superLayerID == 10 )
222 { // axial wire
223 new ( _wire + wireID )
224 KalFitWire( localID++, _layer[layerID], fwd, bck, _wire + Nwire, wire->Id(), 0 );
225 }
226 else
227 { // stereo wire
228 new ( _wire + wireID )
229 KalFitWire( localID++, _layer[layerID], fwd, bck, _wire + Nwire, wire->Id(), 1 );
230 }
231 }
232
233 // make virtual wire object for the pointer of boundary's neighbor
234 new ( _wire + Nwire ) KalFitWire();
235
236 if ( debug_ == 4 ) cout << "MDC geometry reading done" << std::endl;
237
238 return;
239}
virtual const int getLayerSize()=0
virtual const int getWireSize()=0
virtual const int getSuperLayerSize()=0

Referenced by beginRun().

◆ setBesFromGdml()

void KalFitAlg::setBesFromGdml ( void )

mdcgas

inner wall shield fiml1 Al by wangll 2012-09-07

inner wall CarbonFiber by wll 2012-09-06

inner wall shield film0 Al by wangll 2012-09-07

air

outer beryllium pipe

cooling oil

inner beryllium pipe

gold

now construct the cylinders

film1 of the innerwall of inner drift chamber

innerwall of inner drift chamber

film0 of the innerwall of inner drift chamber

outer air, be attention the calculation of the radius and thick of the air cylinder is special

outer Beryllium layer

oil layer

inner Beryllium layer

gold layer

Definition at line 9 of file KalFitReadGdml.cxx.

9 {
10
11 int i( 0 );
12 double Z( 0. ), A( 0. ), Ionization( 0. ), Density( 0. ), Radlen( 0. );
13
14 G4LogicalVolume* logicalMdc = 0;
15 MdcG4Geo* aMdcG4Geo = new MdcG4Geo();
16 logicalMdc = aMdcG4Geo->GetTopVolume();
17
18 /// mdcgas
19 G4Material* mdcMaterial = logicalMdc->GetMaterial();
20
21 for ( i = 0; i < mdcMaterial->GetElementVector()->size(); i++ )
22 {
23 Z += ( mdcMaterial->GetElement( i )->GetZ() ) * ( mdcMaterial->GetFractionVector()[i] );
24 A += ( mdcMaterial->GetElement( i )->GetA() ) * ( mdcMaterial->GetFractionVector()[i] );
25 }
26 Ionization = mdcMaterial->GetIonisation()->GetMeanExcitationEnergy();
27 Density = mdcMaterial->GetDensity() / ( g / cm3 );
28 Radlen = mdcMaterial->GetRadlen();
29 std::cout << "mdcgas: Z: " << Z << " A: " << ( A / ( g / mole ) )
30 << " Ionization: " << ( Ionization / eV ) << " Density: " << Density
31 << " Radlen: " << Radlen << std::endl;
32 KalFitMaterial FitMdcMaterial( Z, A / g / mole, Ionization / eV, Density, Radlen / 10. );
33 _BesKalmanFitMaterials.push_back( FitMdcMaterial );
34 KalFitTrack::mdcGasRadlen_ = Radlen / 10.;
35
36 /// inner wall shield fiml1 Al by wangll 2012-09-07
37 G4LogicalVolume* innerWallFilm1Volume = const_cast<G4LogicalVolume*>(
38 GDMLProcessor::GetInstance()->GetLogicalVolume( "LogicalMdcInnerFilm1" ) );
39 G4Material* innerWallFilm1Material = innerWallFilm1Volume->GetMaterial();
40 G4Tubs* innerwallFilm1Tub = dynamic_cast<G4Tubs*>( innerWallFilm1Volume->GetSolid() );
41
42 Z = 0.;
43 A = 0.;
44 for ( i = 0; i < innerWallFilm1Material->GetElementVector()->size(); i++ )
45 {
46 Z += ( innerWallFilm1Material->GetElement( i )->GetZ() ) *
47 ( innerWallFilm1Material->GetFractionVector()[i] );
48 A += ( innerWallFilm1Material->GetElement( i )->GetA() ) *
49 ( innerWallFilm1Material->GetFractionVector()[i] );
50 }
51
52 Ionization = innerWallFilm1Material->GetIonisation()->GetMeanExcitationEnergy();
53 Density = innerWallFilm1Material->GetDensity() / ( g / cm3 );
54 Radlen = innerWallFilm1Material->GetRadlen();
55 std::cout << "Mdc innerwall Film1, Al: Z: " << Z << " A: " << ( A / ( g / mole ) )
56 << " Ionization: " << ( Ionization / eV ) << " Density: " << Density
57 << " Radlen: " << Radlen << std::endl;
58 KalFitMaterial FitInnerwallFilm1Material( Z, A / g / mole, Ionization / eV, Density,
59 Radlen / 10. );
60 _BesKalmanFitMaterials.push_back( FitInnerwallFilm1Material );
61
62 /// inner wall CarbonFiber by wll 2012-09-06
63 G4LogicalVolume* innerwallVolume = const_cast<G4LogicalVolume*>(
64 GDMLProcessor::GetInstance()->GetLogicalVolume( "logicalMdcSegment2" ) );
65 G4Material* innerwallMaterial = innerwallVolume->GetMaterial();
66 G4Tubs* innerwallTub = dynamic_cast<G4Tubs*>( innerwallVolume->GetSolid() );
67
68 Z = 0.;
69 A = 0.;
70 for ( i = 0; i < innerwallMaterial->GetElementVector()->size(); i++ )
71 {
72 Z += ( innerwallMaterial->GetElement( i )->GetZ() ) *
73 ( innerwallMaterial->GetFractionVector()[i] );
74 A += ( innerwallMaterial->GetElement( i )->GetA() ) *
75 ( innerwallMaterial->GetFractionVector()[i] );
76 }
77
78 Ionization = innerwallMaterial->GetIonisation()->GetMeanExcitationEnergy();
79 Density = innerwallMaterial->GetDensity() / ( g / cm3 );
80 Radlen = innerwallMaterial->GetRadlen();
81 std::cout << "Mdc innerwall, Al: Z: " << Z << " A: " << ( A / ( g / mole ) )
82 << " Ionization: " << ( Ionization / eV ) << " Density: " << Density
83 << " Radlen: " << Radlen << std::endl;
84 KalFitMaterial FitInnerwallMaterial( Z, A / g / mole, Ionization / eV, Density,
85 Radlen / 10. );
86 _BesKalmanFitMaterials.push_back( FitInnerwallMaterial );
87
88 /// inner wall shield film0 Al by wangll 2012-09-07
89 G4LogicalVolume* innerWallFilm0Volume = const_cast<G4LogicalVolume*>(
90 GDMLProcessor::GetInstance()->GetLogicalVolume( "LogicalMdcInnerFilm0" ) );
91 G4Material* innerWallFilm0Material = innerWallFilm0Volume->GetMaterial();
92 G4Tubs* innerwallFilm0Tub = dynamic_cast<G4Tubs*>( innerWallFilm0Volume->GetSolid() );
93
94 Z = 0.;
95 A = 0.;
96 for ( i = 0; i < innerWallFilm0Material->GetElementVector()->size(); i++ )
97 {
98 Z += ( innerWallFilm0Material->GetElement( i )->GetZ() ) *
99 ( innerWallFilm0Material->GetFractionVector()[i] );
100 A += ( innerWallFilm0Material->GetElement( i )->GetA() ) *
101 ( innerWallFilm0Material->GetFractionVector()[i] );
102 }
103
104 Ionization = innerWallFilm0Material->GetIonisation()->GetMeanExcitationEnergy();
105 Density = innerWallFilm0Material->GetDensity() / ( g / cm3 );
106 Radlen = innerWallFilm0Material->GetRadlen();
107 std::cout << "Mdc innerwall Film0, Al: Z: " << Z << " A: " << ( A / ( g / mole ) )
108 << " Ionization: " << ( Ionization / eV ) << " Density: " << Density
109 << " Radlen: " << Radlen << std::endl;
110 KalFitMaterial FitInnerwallFilm0Material( Z, A / g / mole, Ionization / eV, Density,
111 Radlen / 10. );
112 _BesKalmanFitMaterials.push_back( FitInnerwallFilm0Material );
113
114 ///////////////////////////////////////////////////////////////////////////////////////////////////
115 G4LogicalVolume* logicalBes = 0;
116 BesG4Geo* aBesG4Geo = new BesG4Geo();
117 logicalBes = aBesG4Geo->GetTopVolume();
118
119 /// air
120 G4LogicalVolume* logicalAirVolume = const_cast<G4LogicalVolume*>(
121 GDMLProcessor::GetInstance()->GetLogicalVolume( "logicalWorld" ) );
122 G4Material* airMaterial = logicalAirVolume->GetMaterial();
123 Z = 0.;
124 A = 0.;
125 for ( i = 0; i < airMaterial->GetElementVector()->size(); i++ )
126 {
127 Z += ( airMaterial->GetElement( i )->GetZ() ) * ( airMaterial->GetFractionVector()[i] );
128 A += ( airMaterial->GetElement( i )->GetA() ) * ( airMaterial->GetFractionVector()[i] );
129 }
130
131 Ionization = airMaterial->GetIonisation()->GetMeanExcitationEnergy();
132 Density = airMaterial->GetDensity() / ( g / cm3 );
133 Radlen = airMaterial->GetRadlen();
134 std::cout << "air: Z: " << Z << " A: " << ( A / ( g / mole ) )
135 << " Ionization: " << ( Ionization / eV ) << " Density: " << Density
136 << " Radlen: " << Radlen << std::endl;
137 KalFitMaterial FitAirMaterial( Z, A / g / mole, Ionization / eV, Density, Radlen / 10. );
138 _BesKalmanFitMaterials.push_back( FitAirMaterial );
139
140 /// outer beryllium pipe
141 G4LogicalVolume* logicalOuterBeVolume = const_cast<G4LogicalVolume*>(
142 GDMLProcessor::GetInstance()->GetLogicalVolume( "logicalouterBe" ) );
143 G4Material* outerBeMaterial = logicalOuterBeVolume->GetMaterial();
144
145 G4Tubs* outerBeTub = dynamic_cast<G4Tubs*>( logicalOuterBeVolume->GetSolid() );
146 Z = 0.;
147 A = 0.;
148 for ( i = 0; i < outerBeMaterial->GetElementVector()->size(); i++ )
149 {
150 Z += ( outerBeMaterial->GetElement( i )->GetZ() ) *
151 ( outerBeMaterial->GetFractionVector()[i] );
152 A += ( outerBeMaterial->GetElement( i )->GetA() ) *
153 ( outerBeMaterial->GetFractionVector()[i] );
154 }
155 Ionization = outerBeMaterial->GetIonisation()->GetMeanExcitationEnergy();
156 Density = outerBeMaterial->GetDensity() / ( g / cm3 );
157 Radlen = outerBeMaterial->GetRadlen();
158 std::cout << "outer beryllium: Z: " << Z << " A: " << ( A / ( g / mole ) )
159 << " Ionization: " << ( Ionization / eV ) << " Density: " << Density
160 << " Radlen: " << Radlen << std::endl;
161 KalFitMaterial FitOuterBeMaterial( Z, A / g / mole, Ionization / eV, Density, Radlen / 10. );
162 _BesKalmanFitMaterials.push_back( FitOuterBeMaterial );
163
164 /// cooling oil
165 G4LogicalVolume* logicalOilLayerVolume = const_cast<G4LogicalVolume*>(
166 GDMLProcessor::GetInstance()->GetLogicalVolume( "logicaloilLayer" ) );
167 G4Material* oilLayerMaterial = logicalOilLayerVolume->GetMaterial();
168 G4Tubs* oilLayerTub = dynamic_cast<G4Tubs*>( logicalOilLayerVolume->GetSolid() );
169
170 Z = 0.;
171 A = 0.;
172 for ( i = 0; i < oilLayerMaterial->GetElementVector()->size(); i++ )
173 {
174 Z += ( oilLayerMaterial->GetElement( i )->GetZ() ) *
175 ( oilLayerMaterial->GetFractionVector()[i] );
176 A += ( oilLayerMaterial->GetElement( i )->GetA() ) *
177 ( oilLayerMaterial->GetFractionVector()[i] );
178 }
179 Ionization = oilLayerMaterial->GetIonisation()->GetMeanExcitationEnergy();
180 Density = oilLayerMaterial->GetDensity() / ( g / cm3 );
181 Radlen = oilLayerMaterial->GetRadlen();
182 std::cout << "cooling oil: Z: " << Z << " A: " << ( A / ( g / mole ) )
183 << " Ionization: " << ( Ionization / eV ) << " Density: " << Density
184 << " Radlen: " << Radlen << std::endl;
185 KalFitMaterial FitOilLayerMaterial( Z, A / g / mole, Ionization / eV, Density,
186 Radlen / 10. );
187 _BesKalmanFitMaterials.push_back( FitOilLayerMaterial );
188
189 /// inner beryllium pipe
190 G4LogicalVolume* logicalInnerBeVolume = const_cast<G4LogicalVolume*>(
191 GDMLProcessor::GetInstance()->GetLogicalVolume( "logicalinnerBe" ) );
192 G4Material* innerBeMaterial = logicalInnerBeVolume->GetMaterial();
193 G4Tubs* innerBeTub = dynamic_cast<G4Tubs*>( logicalInnerBeVolume->GetSolid() );
194 Z = 0.;
195 A = 0.;
196 for ( i = 0; i < innerBeMaterial->GetElementVector()->size(); i++ )
197 {
198 Z += ( innerBeMaterial->GetElement( i )->GetZ() ) *
199 ( innerBeMaterial->GetFractionVector()[i] );
200 A += ( innerBeMaterial->GetElement( i )->GetA() ) *
201 ( innerBeMaterial->GetFractionVector()[i] );
202 }
203
204 Ionization = innerBeMaterial->GetIonisation()->GetMeanExcitationEnergy();
205 Density = innerBeMaterial->GetDensity() / ( g / cm3 );
206 Radlen = innerBeMaterial->GetRadlen();
207 std::cout << "inner beryllium: Z: " << Z << " A: " << ( A / ( g / mole ) )
208 << " Ionization: " << ( Ionization / eV ) << " Density: " << Density
209 << " Radlen: " << Radlen << std::endl;
210 KalFitMaterial FitInnerBeMaterial( Z, A / g / mole, Ionization / eV, Density, Radlen / 10. );
211 _BesKalmanFitMaterials.push_back( FitInnerBeMaterial );
212
213 /// gold
214 G4LogicalVolume* logicalGoldLayerVolume = const_cast<G4LogicalVolume*>(
215 GDMLProcessor::GetInstance()->GetLogicalVolume( "logicalgoldLayer" ) );
216 G4Material* goldLayerMaterial = logicalGoldLayerVolume->GetMaterial();
217 G4Tubs* goldLayerTub = dynamic_cast<G4Tubs*>( logicalGoldLayerVolume->GetSolid() );
218
219 Z = 0.;
220 A = 0.;
221 for ( i = 0; i < goldLayerMaterial->GetElementVector()->size(); i++ )
222 {
223 Z += ( goldLayerMaterial->GetElement( i )->GetZ() ) *
224 ( goldLayerMaterial->GetFractionVector()[i] );
225 A += ( goldLayerMaterial->GetElement( i )->GetA() ) *
226 ( goldLayerMaterial->GetFractionVector()[i] );
227 }
228 Ionization = goldLayerMaterial->GetIonisation()->GetMeanExcitationEnergy();
229 Density = goldLayerMaterial->GetDensity() / ( g / cm3 );
230 Radlen = goldLayerMaterial->GetRadlen();
231 std::cout << "gold layer: Z: " << Z << " A: " << ( A / ( g / mole ) )
232 << " Ionization: " << ( Ionization / eV ) << " Density: " << Density
233 << " Radlen: " << Radlen << std::endl;
234 KalFitMaterial FitGoldLayerMaterial( Z, A / g / mole, Ionization / eV, Density,
235 Radlen / 10. );
236 _BesKalmanFitMaterials.push_back( FitGoldLayerMaterial );
237
238 /// now construct the cylinders
239 double radius, thick, length, z0;
240
241 /// film1 of the innerwall of inner drift chamber
242 radius = innerwallFilm1Tub->GetInnerRadius() / ( cm );
243 thick =
244 innerwallFilm1Tub->GetOuterRadius() / (cm)-innerwallFilm1Tub->GetInnerRadius() / ( cm );
245 length = 2.0 * innerwallFilm1Tub->GetZHalfLength() / ( cm );
246 z0 = 0.0;
247 std::cout << "innerwallFilm1: "
248 << " radius: " << radius << " thick:" << thick << " length: " << length
249 << std::endl;
250 KalFitCylinder innerwallFilm1Cylinder( &_BesKalmanFitMaterials[1], radius, thick, length,
251 z0 );
252 _BesKalmanFitWalls.push_back( innerwallFilm1Cylinder );
253
254 /// innerwall of inner drift chamber
255 radius = innerwallTub->GetInnerRadius() / ( cm );
256 thick = innerwallTub->GetOuterRadius() / (cm)-innerwallTub->GetInnerRadius() / ( cm );
257 length = 2.0 * innerwallTub->GetZHalfLength() / ( cm );
258 z0 = 0.0;
259 std::cout << "innerwall: "
260 << " radius: " << radius << " thick:" << thick << " length: " << length
261 << std::endl;
262 KalFitCylinder innerwallCylinder( &_BesKalmanFitMaterials[2], radius, thick, length, z0 );
263 _BesKalmanFitWalls.push_back( innerwallCylinder );
264
265 /// film0 of the innerwall of inner drift chamber
266 radius = innerwallFilm0Tub->GetInnerRadius() / ( cm );
267 thick =
268 innerwallFilm0Tub->GetOuterRadius() / (cm)-innerwallFilm0Tub->GetInnerRadius() / ( cm );
269 length = 2.0 * innerwallFilm0Tub->GetZHalfLength() / ( cm );
270 z0 = 0.0;
271 std::cout << "innerwallFilm0: "
272 << " radius: " << radius << " thick:" << thick << " length: " << length
273 << std::endl;
274 KalFitCylinder innerwallFilm0Cylinder( &_BesKalmanFitMaterials[3], radius, thick, length,
275 z0 );
276 _BesKalmanFitWalls.push_back( innerwallFilm0Cylinder );
277
278 /// outer air, be attention the calculation of the radius and thick of the air cylinder is
279 /// special
280 radius = outerBeTub->GetOuterRadius() / ( cm );
281 thick = innerwallFilm0Tub->GetInnerRadius() / ( cm )-outerBeTub->GetOuterRadius() / ( cm );
282 length = 2.0 * innerwallTub->GetZHalfLength() / ( cm );
283 z0 = 0.0;
284 std::cout << "outer air: "
285 << " radius: " << radius << " thick:" << thick << " length: " << length
286 << std::endl;
287 KalFitCylinder outerAirCylinder( &_BesKalmanFitMaterials[4], radius, thick, length, z0 );
288 _BesKalmanFitWalls.push_back( outerAirCylinder );
289
290 /// outer Beryllium layer
291 radius = outerBeTub->GetInnerRadius() / ( cm );
292 thick = outerBeTub->GetOuterRadius() / (cm)-outerBeTub->GetInnerRadius() / ( cm );
293 length = 2.0 * outerBeTub->GetZHalfLength() / ( cm );
294 z0 = 0.0;
295 std::cout << "outer Be: "
296 << " radius: " << radius << " thick:" << thick << " length: " << length
297 << std::endl;
298 KalFitCylinder outerBeCylinder( &_BesKalmanFitMaterials[5], radius, thick, length, z0 );
299 _BesKalmanFitWalls.push_back( outerBeCylinder );
300
301 /// oil layer
302 radius = oilLayerTub->GetInnerRadius() / ( cm );
303 thick = oilLayerTub->GetOuterRadius() / (cm)-oilLayerTub->GetInnerRadius() / ( cm );
304 length = 2.0 * oilLayerTub->GetZHalfLength() / ( cm );
305 z0 = 0.0;
306 std::cout << "oil layer: "
307 << " radius: " << radius << " thick:" << thick << " length: " << length
308 << std::endl;
309 KalFitCylinder oilLayerCylinder( &_BesKalmanFitMaterials[6], radius, thick, length, z0 );
310 _BesKalmanFitWalls.push_back( oilLayerCylinder );
311
312 /// inner Beryllium layer
313 radius = innerBeTub->GetInnerRadius() / ( cm );
314 thick = innerBeTub->GetOuterRadius() / (cm)-innerBeTub->GetInnerRadius() / ( cm );
315 length = 2.0 * innerBeTub->GetZHalfLength() / ( cm );
316 z0 = 0.0;
317 std::cout << "inner Be: "
318 << " radius: " << radius << " thick:" << thick << " length: " << length
319 << std::endl;
320 KalFitCylinder innerBeCylinder( &_BesKalmanFitMaterials[7], radius, thick, length, z0 );
321 _BesKalmanFitWalls.push_back( innerBeCylinder );
322
323 /// gold layer
324 radius = goldLayerTub->GetInnerRadius() / ( cm );
325 thick = goldLayerTub->GetOuterRadius() / (cm)-goldLayerTub->GetInnerRadius() / ( cm );
326 length = 2.0 * goldLayerTub->GetZHalfLength() / ( cm );
327 z0 = 0.0;
328 std::cout << "gold layer: "
329 << " radius: " << radius << " thick:" << thick << " length: " << length
330 << std::endl;
331 KalFitCylinder goldLayerCylinder( &_BesKalmanFitMaterials[8], radius, thick, length, z0 );
332 _BesKalmanFitWalls.push_back( goldLayerCylinder );
333
334 std::cout << "exit from KalFitAlg::setBesFromGdml()" << std::endl;
335}
G4LogicalVolume * GetTopVolume()
Get the top(world) volume;.

Referenced by initialize().

◆ setCalibSvc_init()

void KalFitAlg::setCalibSvc_init ( void )

initialize for the services

Definition at line 241 of file KalFitAlg2.cxx.

241 {
242 MsgStream log( msgSvc(), name() );
243 StatusCode sc = service( "MdcCalibFunSvc", m_mdcCalibFunSvc_ );
244 if ( sc.isFailure() ) { log << MSG::FATAL << "Could not load MdcCalibFunSvc!" << endmsg; }
245 KalFitTrack::setMdcCalibFunSvc( m_mdcCalibFunSvc_ );
246}
static void setMdcCalibFunSvc(const IMdcCalibFunSvc *calibsvc)

Referenced by initialize().

◆ setCylinder_Mdc()

void KalFitAlg::setCylinder_Mdc ( void )

Initialize the cylinders (walls and cathodes) for Mdc.

◆ setDchisqCut()

void KalFitAlg::setDchisqCut ( void )

set dchi2cutf_anal

set dchi2cuts_anal

temporary

set dchi2cutf_calib

temporary

set dchi2cuts_calib

temporary

Definition at line 588 of file KalFitAlg.cxx.

588 {
589 int layid = 0;
590
591 /// set dchi2cutf_anal
592 for ( layid = 0; layid < 2; layid++ )
596 for ( layid = 4; layid < 12; layid++ )
598 for ( layid = 12; layid < 20; layid++ )
600 for ( layid = 20; layid < 43; layid++ )
602
603 /// set dchi2cuts_anal
604 for ( layid = 0; layid < 2; layid++ )
606
609 for ( layid = 4; layid < 12; layid++ )
611 for ( layid = 12; layid < 20; layid++ )
613 for ( layid = 20; layid < 43; layid++ )
615
616 /// temporary
617 // for(layid = 0; layid<43; layid++) {
618 // KalFitTrack::dchi2cuts_anal[layid] = 10.0;
619 // }
620
621 /// set dchi2cutf_calib
622 for ( layid = 0; layid < 2; layid++ )
624
627
628 for ( layid = 4; layid < 12; layid++ )
630
631 for ( layid = 12; layid < 20; layid++ )
633
634 for ( layid = 20; layid < 43; layid++ )
636
637 /// temporary
638 if ( usage_ < 2 )
639 {
640 for ( layid = 0; layid < 43; layid++ ) { KalFitTrack::dchi2cutf_calib[layid] = 10.0; }
641 }
642
643 /// set dchi2cuts_calib
644 for ( layid = 0; layid < 2; layid++ )
646
649
650 for ( layid = 4; layid < 12; layid++ )
652
653 for ( layid = 12; layid < 20; layid++ )
655
656 for ( layid = 20; layid < 43; layid++ )
658
659 /// temporary
660 if ( usage_ < 2 )
661 {
662 for ( layid = 0; layid < 43; layid++ ) { KalFitTrack::dchi2cuts_calib[layid] = 10.0; }
663 }
664}

Referenced by initialize().

◆ setGeomSvc_init()

void KalFitAlg::setGeomSvc_init ( void )

Definition at line 248 of file KalFitAlg2.cxx.

248 {
249 IMdcGeomSvc* imdcGeomSvc;
250 MsgStream log( msgSvc(), name() );
251 StatusCode sc = service( "MdcGeomSvc", imdcGeomSvc );
252 // m_mdcGeomSvc_ = dynamic_cast<MdcGeomSvc*>(imdcGeomSvc);
253 if ( sc.isFailure() ) { log << MSG::FATAL << "Could not load MdcGeomSvc!" << endmsg; }
254 imdcGeomSvc_ = imdcGeomSvc;
255
256 KalFitTrack::setIMdcGeomSvc( imdcGeomSvc );
257}
static void setIMdcGeomSvc(IMdcGeomSvc *igeomsvc)

Referenced by beginRun().

◆ setMagneticFieldSvc_init()

void KalFitAlg::setMagneticFieldSvc_init ( void )

◆ setMaterial_Mdc()

void KalFitAlg::setMaterial_Mdc ( void )

Initialize the material for Mdc.

◆ smoother_anal()

void KalFitAlg::smoother_anal ( KalFitTrack & trk,
int way )

Kalman filter (smoothing or backward part).

be attention to this inital error matrix of smoother, how is track.Ea() in the next sentence when use it?

oh, to be the last hit

calculate the lsat point in MDC

calculate fiTerm

for protection purpose

Definition at line 2303 of file KalFitAlg.cxx.

2303 {
2304 // retrieve Mdc geometry information
2305 IMdcGeomSvc* geomsvc;
2306 StatusCode sc = Gaudi::svcLocator()->service( "MdcGeomSvc", geomsvc );
2307 if ( sc == StatusCode::FAILURE ) cout << "GeoSvc failing!!!!!!!SC=" << sc << endl;
2308
2309 HepPoint3D ip( 0, 0, 0 );
2310 if ( m_usevtxdb == 1 )
2311 {
2312 Hep3Vector xorigin( 0, 0, 0 );
2313 IVertexDbSvc* vtxsvc;
2314 Gaudi::svcLocator()->service( "VertexDbSvc", vtxsvc );
2315 if ( vtxsvc->isVertexValid() )
2316 {
2317 double* dbv = vtxsvc->PrimaryVertex();
2318 double* vv = vtxsvc->SigmaPrimaryVertex();
2319 xorigin.setX( dbv[0] );
2320 xorigin.setY( dbv[1] );
2321 xorigin.setZ( dbv[2] );
2322 }
2323 ip[0] = xorigin[0];
2324 ip[1] = xorigin[1];
2325 ip[2] = xorigin[2];
2326 }
2327
2328 // Estimation of the path length from ip to 1st cylinder
2329
2330 Helix work = *(Helix*)&track;
2331 work.ignoreErrorMatrix();
2332 work.pivot( ip );
2333
2334 double tanl = track.tanl();
2335 double phi_old = work.phi0();
2336 double phi = track.phi0();
2337
2338 if ( fabs( phi - phi_old ) > M_PI )
2339 {
2340 if ( phi > phi_old ) phi -= 2 * M_PI;
2341 else phi_old -= 2 * M_PI;
2342 }
2343
2344 double path_zero = fabs( track.radius() * ( phi_old - phi ) * sqrt( 1 + tanl * tanl ) );
2345 // track.addPathSM(path_zero);
2346
2347 HepSymMatrix Eakal( 5, 0 );
2348 track.pivot( ip );
2349 /// be attention to this inital error matrix of smoother,
2350 /// how is track.Ea() in the next sentence when use it?
2351 Eakal = track.Ea() * matrixg_;
2352 track.Ea( Eakal );
2353
2354 // Mdc part :
2355 unsigned int nhit = track.HitsMdc().size();
2356 int layer_prev = -1;
2357
2358 HepVector pos_old( 3, 0 );
2359 double r0kal_prec( 0 );
2360 int nhits_read( 0 );
2361 for ( unsigned i = 0; i < nhit; i++ )
2362 {
2363 int ihit = ( nhit - 1 ) - i;
2364 KalFitHitMdc& HitMdc = track.HitMdc( ihit );
2365 const KalFitWire& Wire = HitMdc.wire();
2366
2367 int wireid = Wire.geoID();
2368 nhits_read++;
2369
2370 int layer = Wire.layer().layerId();
2371 if ( pathl_ && layer != layer_prev )
2372 {
2373
2374 if ( debug_ == 4 )
2375 cout << "in smoother,layerid " << layer << " layer_prev " << layer_prev
2376 << " pathl_ " << pathl_ << endl;
2377
2378 // track.PathL(Wire.layer().layerId());
2379 layer_prev = layer;
2380 }
2381
2382 HepPoint3D fwd( Wire.fwd() );
2383 HepPoint3D bck( Wire.bck() );
2384 Hep3Vector wire = (CLHEP::Hep3Vector)fwd - (CLHEP::Hep3Vector)bck;
2385 Helix work = *(Helix*)&track;
2386 work.ignoreErrorMatrix();
2387 work.pivot( ( fwd + bck ) * .5 );
2388 HepPoint3D x0kal = ( work.x( 0 ).z() - bck.z() ) / wire.z() * wire + bck;
2389
2390 if ( 4 == debug_ ) std::cout << " x0kal before sag: " << x0kal << std::endl;
2391 if ( wsag_ == 4 )
2392 {
2393 Hep3Vector result;
2394 const MdcGeoWire* geowire = geomsvc->Wire( wireid );
2395 double tension = geowire->Tension();
2396
2397 // std::cout<<" tension: "<<tension<<std::endl;
2398 double zinit( x0kal.z() ), lzx( Wire.lzx() );
2399
2400 // double A(Wire.Acoef());
2401 double A = 47.35E-6 / tension;
2402 double Zp = ( zinit - bck.z() ) * lzx / wire.z();
2403
2404 if ( 4 == debug_ )
2405 {
2406 std::cout << " sag in smoother_anal: " << std::endl;
2407 std::cout << " x0kal.x(): " << std::setprecision( 10 ) << x0kal.x() << std::endl;
2408 std::cout << " wire.x()*(zinit-bck.z())/wire.z(): " << std::setprecision( 10 )
2409 << ( wire.x() * ( zinit - bck.z() ) / wire.z() ) << std::endl;
2410 std::cout << "bck.x(): " << std::setprecision( 10 ) << bck.x() << std::endl;
2411 std::cout << " wire.x()*(zinit-bck.z())/wire.z() + bck.x(): "
2412 << std::setprecision( 10 )
2413 << ( wire.x() * ( zinit - bck.z() ) / wire.z() + bck.x() ) << std::endl;
2414 }
2415
2416 result.setX( wire.x() * ( zinit - bck.z() ) / wire.z() + bck.x() );
2417 result.setY( ( A * ( Zp - lzx ) + wire.y() / lzx ) * Zp + bck.y() );
2418 result.setZ( ( A * ( 2 * Zp - lzx ) * lzx + wire.y() ) / wire.z() );
2419
2420 wire.setX( wire.x() / wire.z() );
2421 wire.setY( result.z() );
2422 wire.setZ( 1 );
2423
2424 x0kal.setX( result.x() );
2425 x0kal.setY( result.y() );
2426 }
2427
2428 if ( 4 == debug_ ) std::cout << " x0kal after sag: " << x0kal << std::endl;
2429
2430 // If x0kal is after the inner wall and x0kal_prec before :
2431 double r0kal = x0kal.perp();
2432 if ( debug_ == 4 )
2433 {
2434 cout << "wire direction " << wire << endl;
2435 cout << "x0kal " << x0kal << endl;
2436 cout << "smoother::r0kal " << r0kal << " r0kal_prec " << r0kal_prec << endl;
2437 }
2438
2439 // change PIVOT :
2440 /*cout<<endl<<"before change pivot: "<<endl;//wangll
2441 cout<<"track.pivot = "<<track.pivot()<<endl;//wangll
2442 cout<<"track.helix = "<<track.a()<<endl;//wangll
2443 */
2444 double pathl( 0 );
2445 track.pivot_numf( x0kal, pathl );
2446 track.addPathSM( pathl );
2447 /*cout<<endl<<"after change pivot: "<<endl;//wangll
2448 cout<<"track.pivot = "<<track.pivot()<<endl;//wangll
2449 cout<<"track.helix = "<<track.a()<<endl;//wangll
2450 */
2451
2452 // calculate the tof time in this layer
2453 double pmag( sqrt( 1.0 + track.a()[4] * track.a()[4] ) / track.a()[2] );
2454 double mass_over_p( track.mass() / pmag );
2455 double beta( 1.0 / sqrt( 1.0 + mass_over_p * mass_over_p ) );
2456 double tofest = pathl / ( 29.9792458 * beta );
2457 track.addTofSM( tofest );
2458
2459 // std::cout<<" in layer: "<<layer<<" pathl: "<<pathl<<" tof: "<<tofest<<std::endl;
2460
2461 if ( KalFitElement::muls() ) track.msgasmdc( pathl, way );
2462 /*cout<<endl<<"after muls: "<<endl;//wangll
2463 cout<<"track.pivot = "<<track.pivot()<<endl;//wangll
2464 cout<<"track.helix = "<<track.a()<<endl;//wangll
2465 */
2466 if ( !( way < 0 && fabs( track.kappa() ) > 1000.0 ) )
2467 {
2468 if ( KalFitElement::loss() ) track.eloss( pathl, _BesKalmanFitMaterials[0], way );
2469 }
2470
2471 // Add info hit wire :
2472 /*cout<<endl<<"after eloss: "<<endl;//wangll
2473 cout<<"track.pivot = "<<track.pivot()<<endl;//wangll
2474 cout<<"track.helix = "<<track.a()<<endl;//wangll
2475 */
2476 if ( fabs( track.kappa() ) > 0 && fabs( track.kappa() ) < 1000.0 &&
2477 fabs( track.tanl() ) < 7.02 )
2478 {
2479 HepVector Va( 5, 0 );
2480 HepSymMatrix Ma( 5, 0 );
2481 KalFitHelixSeg HelixSeg( &HitMdc, x0kal, Va, Ma );
2482
2483 Hep3Vector meas = track.momentum( 0 ).cross( wire ).unit();
2484 double dchi2 = -1;
2485 track.smoother_Mdc( HitMdc, meas, HelixSeg, dchi2, m_csmflag );
2486 if ( dchi2 > 0.0 ) { track.HelixSegs().push_back( HelixSeg ); }
2487 }
2488
2489 /// oh, to be the last hit
2490
2491 if ( i == nhit - 1 )
2492 {
2493
2494 /// calculate the lsat point in MDC
2495 HepPoint3D point;
2496 point.setX( x0kal.x() + track.a()[0] * cos( track.a()[1] ) );
2497 point.setY( x0kal.y() + track.a()[0] * sin( track.a()[1] ) );
2498 point.setZ( x0kal.z() + track.a()[3] );
2499 track.point_last( point );
2500
2501 /// calculate fiTerm
2502 double phi_old = track.a()[1];
2503 KalFitTrack temp( x0kal, track.a(), track.Ea(), 0, 0, 0 );
2504 temp.pivot( ip );
2505 double phi_new = temp.a()[1];
2506 double fi = phi_new - phi_old;
2507 /// for protection purpose
2508 // if(fabs(fi) >= CLHEP::twopi) fi = fmod(fi+2*CLHEP::twopi,CLHEP::twopi);
2509
2510 if ( fabs( fi ) >= CLHEP::twopi ) fi = fmod( fi + 2 * CLHEP::twopi, CLHEP::twopi );
2511
2512 track.fiTerm( fi );
2513 }
2514
2515 if ( debug_ ) cout << "track----7-----" << track.a() << endl;
2516 r0kal_prec = r0kal;
2517 }
2518}
virtual bool isVertexValid()=0
virtual double * SigmaPrimaryVertex()=0
virtual double * PrimaryVertex()=0

Referenced by complete_track().

◆ smoother_calib()

void KalFitAlg::smoother_calib ( KalFitTrack & trk,
int way )

Definition at line 2520 of file KalFitAlg.cxx.

2520 {
2521
2522 // retrieve Mdc geometry information
2523 IMdcGeomSvc* geomsvc;
2524 StatusCode sc = Gaudi::svcLocator()->service( "MdcGeomSvc", geomsvc );
2525 if ( sc == StatusCode::FAILURE ) cout << "GeoSvc failing!!!!!!!SC=" << sc << endl;
2526
2527 HepSymMatrix Eakal( 5, 0 );
2528 // Estimation of the path length from ip to 1st cylinder
2529 HepPoint3D ip( 0, 0, 0 );
2530 track.pivot( ip );
2531 Eakal = track.getInitMatrix();
2532 if ( debug_ == 4 )
2533 { std::cout << "the initial error matrix in smoothing is " << Eakal << std::endl; }
2534 track.Ea( Eakal );
2535
2536 // Mdc part :
2537 unsigned int nseg = track.HelixSegs().size();
2538 int layer_prev = -1;
2539
2540 HepVector pos_old( 3, 0 );
2541 double r0kal_prec( 0 );
2542 int nsegs_read( 0 );
2543 for ( unsigned i = 0; i < nseg; i++ )
2544 {
2545
2546 int flag = 0;
2547 int iseg = ( nseg - 1 ) - i;
2548 KalFitHelixSeg& HelixSeg = track.HelixSeg( iseg );
2549 const KalFitWire& Wire = HelixSeg.HitMdc()->wire();
2550
2551 int wireid = Wire.geoID();
2552 nsegs_read++;
2553
2554 int layer = Wire.layer().layerId();
2555 if ( pathl_ && layer != layer_prev )
2556 {
2557
2558 if ( debug_ == 4 )
2559 cout << "in smoother,layerid " << layer << " layer_prev " << layer_prev
2560 << " pathl_ " << pathl_ << endl;
2561
2562 // track.PathL(Wire.layer().layerId());
2563 layer_prev = layer;
2564 }
2565
2566 HepPoint3D fwd( Wire.fwd() );
2567 HepPoint3D bck( Wire.bck() );
2568 Hep3Vector wire = (CLHEP::Hep3Vector)fwd - (CLHEP::Hep3Vector)bck;
2569 Helix work = *(Helix*)&track;
2570 work.ignoreErrorMatrix();
2571 work.pivot( ( fwd + bck ) * .5 );
2572 HepPoint3D x0kal = ( work.x( 0 ).z() - bck.z() ) / wire.z() * wire + bck;
2573
2574 if ( 4 == debug_ ) std::cout << " x0kal before sag: " << x0kal << std::endl;
2575
2576 if ( wsag_ == 4 )
2577 {
2578
2579 Hep3Vector result;
2580 const MdcGeoWire* geowire = geomsvc->Wire( wireid );
2581 double tension = geowire->Tension();
2582
2583 // std::cout<<" tension: "<<tension<<std::endl;
2584 double zinit( x0kal.z() ), lzx( Wire.lzx() );
2585
2586 // double A(Wire.Acoef());
2587
2588 double A = 47.35E-6 / tension;
2589 double Zp = ( zinit - bck.z() ) * lzx / wire.z();
2590
2591 if ( 4 == debug_ )
2592 {
2593
2594 std::cout << " sag in smoother_calib: " << std::endl;
2595 std::cout << " x0kal.x(): " << std::setprecision( 10 ) << x0kal.x() << std::endl;
2596 std::cout << " wire.x()*(zinit-bck.z())/wire.z(): " << std::setprecision( 10 )
2597 << ( wire.x() * ( zinit - bck.z() ) / wire.z() ) << std::endl;
2598 std::cout << "bck.x(): " << std::setprecision( 10 ) << bck.x() << std::endl;
2599 std::cout << " wire.x()*(zinit-bck.z())/wire.z() + bck.x(): "
2600 << std::setprecision( 10 )
2601 << ( wire.x() * ( zinit - bck.z() ) / wire.z() + bck.x() ) << std::endl;
2602 }
2603
2604 result.setX( wire.x() * ( zinit - bck.z() ) / wire.z() + bck.x() );
2605 result.setY( ( A * ( Zp - lzx ) + wire.y() / lzx ) * Zp + bck.y() );
2606 result.setZ( ( A * ( 2 * Zp - lzx ) * lzx + wire.y() ) / wire.z() );
2607
2608 wire.setX( wire.x() / wire.z() );
2609 wire.setY( result.z() );
2610 wire.setZ( 1 );
2611
2612 x0kal.setX( result.x() );
2613 x0kal.setY( result.y() );
2614 }
2615
2616 if ( 4 == debug_ ) std::cout << " x0kal after sag: " << x0kal << std::endl;
2617
2618 // If x0kal is after the inner wall and x0kal_prec before :
2619 double r0kal = x0kal.perp();
2620 if ( debug_ == 4 )
2621 {
2622 cout << "wire direction " << wire << endl;
2623 cout << "x0kal " << x0kal << endl;
2624 cout << "smoother::r0kal " << r0kal << " r0kal_prec " << r0kal_prec << endl;
2625 }
2626
2627 // change PIVOT :
2628 double pathl( 0 );
2629 track.pivot_numf( x0kal, pathl );
2630
2631 if ( debug_ == 4 )
2632 cout << "track----6-----" << track.a() << " ...path..." << pathl << "momentum"
2633 << track.momentum( 0 ) << endl;
2634 if ( KalFitElement::muls() ) track.msgasmdc( pathl, way );
2635 if ( KalFitElement::loss() ) track.eloss( pathl, _BesKalmanFitMaterials[0], way );
2636
2637 // Add info hit wire :
2638 if ( fabs( track.kappa() ) > 0 && fabs( track.kappa() ) < 1000.0 &&
2639 fabs( track.tanl() ) < 7.02 )
2640 {
2641 // attention to this measure value ,what is the measurement value !!
2642 Hep3Vector meas = track.momentum( 0 ).cross( wire ).unit();
2643
2644 if ( usage_ > 1 ) track.smoother_Mdc_csmalign( HelixSeg, meas, flag, m_csmflag );
2645 else track.smoother_Mdc( HelixSeg, meas, flag, m_csmflag );
2646 // cout<<"layer, cell, track.a: "<<Wire.layer().layerId()<<" , "<<Wire.localId()<<" ,
2647 // "<<track.a()<<endl;
2648 }
2649
2650 if ( debug_ ) cout << "track----7-----" << track.a() << endl;
2651 r0kal_prec = r0kal;
2652 // can this kind of operation be right??
2653 if ( flag == 0 ) { track.HelixSegs().erase( track.HelixSegs().begin() + iseg ); }
2654 }
2655}

Referenced by complete_track().

◆ start_seed()

void KalFitAlg::start_seed ( KalFitTrack & track,
int lead_,
int way,
MdcRec_trk & trk )

Definition at line 5958 of file KalFitAlg.cxx.

5958 {
5959 if ( debug_ == 4 ) cout << "start_seed begin... " << std::endl;
5960 // keep initial helix parameters
5961 Hep3Vector x_init( track.pivot() );
5962 HepSymMatrix Ea_init( 5, 0 );
5963 Ea_init = track.Ea();
5964 HepVector a_init( 5 );
5965 a_init = track.a();
5966
5967 // LR assumption :
5968 unsigned int nhit_included( 10 );
5969 int LR[8][3] = { { 1, 1, 1 }, { 1, 1, -1 }, { 1, -1, 1 }, { 1, -1, -1 },
5970 { -1, 1, 1 }, { -1, 1, -1 }, { -1, -1, 1 }, { -1, -1, -1 } };
5971
5972 unsigned int nhit = track.HitsMdc().size();
5973 double chi2_min( DBL_MAX );
5974 int i_min( -1 );
5975 for ( int ktrial = 0; ktrial < 8; ktrial++ )
5976 {
5977
5978 // Come back to trasan seed :
5979 track.pivot( x_init );
5980 track.a( a_init );
5981 track.Ea( Ea_init );
5982
5983 track.chiSq( 0 );
5984 track.chiSq_back( 0 );
5985 track.nchits( 0 );
5986 track.nster( 0 );
5987 track.ndf_back( 0 );
5988
5989 HepSymMatrix Eakal( 5, 0 );
5990
5991 init_matrix( choice_, TrasanTRK, Eakal );
5992 // initialize the Mdc hits :
5993 for ( unsigned i = 0; i < nhit; i++ )
5994 {
5995 KalFitHitMdc& HitMdc = track.HitMdc( i );
5996 int lr_decision( 0 );
5997 if ( i < 3 ) lr_decision = LR[ktrial][i];
5998 HitMdc.LR( lr_decision );
5999 if ( i < nhit_included ) HitMdc.chi2( 0 );
6000 else HitMdc.chi2( -1 );
6001 }
6002 // Mdc fit the ... first hits :
6003
6004 if ( usage_ == 0 ) filter_fwd_anal( track, lead_, way, Eakal );
6005 way = 999;
6006 if ( usage_ > 0 ) filter_fwd_calib( track, lead_, way, Eakal );
6007
6008 // Check the chi2
6009 if ( debug_ == 4 )
6010 cout << "---- Result for " << ktrial << " case : chi2 = " << track.chiSq()
6011 << ", nhits included = " << track.nchits() << " for nhits available = " << nhit
6012 << std::endl;
6013
6014 if ( track.chiSq() < chi2_min &&
6015 ( track.nchits() == nhit_included || track.nchits() == nhit ) )
6016 {
6017 chi2_min = track.chiSq();
6018 i_min = ktrial;
6019 }
6020 }
6021
6022 // Initialize to the best solution :
6023 if ( debug_ == 4 )
6024 cout << "*** i_min = " << i_min << " with a chi2 = " << chi2_min << std::endl;
6025
6026 for ( unsigned i = 0; i < nhit; i++ )
6027 {
6028 KalFitHitMdc& HitMdc = track.HitMdc( i );
6029 int lr_decision( 0 );
6030 if ( i_min >= 0 && i < 3 ) lr_decision = LR[i_min][i];
6031 HitMdc.LR( lr_decision );
6032 HitMdc.chi2( 0 );
6033 HitMdc.chi2_back( 0 );
6034 }
6035 track.pivot( x_init );
6036 track.a( a_init );
6037 track.Ea( Ea_init );
6038 track.chiSq( 0 );
6039 track.chiSq_back( 0 );
6040 track.nchits( 0 );
6041 track.nster( 0 );
6042 track.ndf_back( 0 );
6043
6044 // For debugging purpose :
6045 if ( debug_ == 4 )
6046 {
6047 for ( unsigned i = 0; i < 3; i++ )
6048 {
6049 KalFitHitMdc& HitMdc = track.HitMdc( i );
6050 cout << " LR(" << i << ") = " << HitMdc.LR() << ", stereo = " << HitMdc.wire().stereo()
6051 << ", layer = " << HitMdc.wire().layer().layerId() << std::endl;
6052 }
6053 }
6054}

Referenced by kalman_fitting_anal(), kalman_fitting_calib(), kalman_fitting_csmalign(), and kalman_fitting_MdcxReco_Csmc_Sew().

Member Data Documentation

◆ activeonly_

int KalFitAlg::activeonly_

Definition at line 187 of file KalFitAlg.h.

Referenced by beginRun(), execute(), initialize(), and KalFitAlg().

◆ back_

int KalFitAlg::back_

flag to perform smoothing

Definition at line 170 of file KalFitAlg.h.

Referenced by complete_track(), complete_track(), initialize(), and KalFitAlg().

◆ choice_

◆ cylfile_

string KalFitAlg::cylfile_

Definition at line 211 of file KalFitAlg.h.

Referenced by KalFitAlg().

◆ dchi2cut_inner_

double KalFitAlg::dchi2cut_inner_

Definition at line 215 of file KalFitAlg.h.

Referenced by KalFitAlg(), and setDchisqCut().

◆ dchi2cut_layid2_

double KalFitAlg::dchi2cut_layid2_

Definition at line 215 of file KalFitAlg.h.

Referenced by KalFitAlg(), and setDchisqCut().

◆ dchi2cut_layid3_

double KalFitAlg::dchi2cut_layid3_

Definition at line 216 of file KalFitAlg.h.

Referenced by KalFitAlg(), and setDchisqCut().

◆ dchi2cut_mid1_

double KalFitAlg::dchi2cut_mid1_

Definition at line 215 of file KalFitAlg.h.

Referenced by KalFitAlg(), and setDchisqCut().

◆ dchi2cut_mid2_

double KalFitAlg::dchi2cut_mid2_

Definition at line 215 of file KalFitAlg.h.

Referenced by KalFitAlg(), and setDchisqCut().

◆ dchi2cut_outer_

double KalFitAlg::dchi2cut_outer_

Definition at line 215 of file KalFitAlg.h.

Referenced by KalFitAlg(), and setDchisqCut().

◆ dchi2cutf_

double KalFitAlg::dchi2cutf_

Definition at line 213 of file KalFitAlg.h.

Referenced by initialize(), and KalFitAlg().

◆ dchi2cuts_

double KalFitAlg::dchi2cuts_

Definition at line 213 of file KalFitAlg.h.

Referenced by initialize(), and KalFitAlg().

◆ debug_

◆ debug_kft_

int KalFitAlg::debug_kft_

Definition at line 207 of file KalFitAlg.h.

Referenced by initialize(), and KalFitAlg().

◆ drifttime_choice_

int KalFitAlg::drifttime_choice_

Definition at line 202 of file KalFitAlg.h.

Referenced by initialize(), and KalFitAlg().

◆ enhance_

int KalFitAlg::enhance_

flag to enhance the error matrix at the inner hit of Mdc (cosmic)

Definition at line 189 of file KalFitAlg.h.

Referenced by complete_track(), complete_track(), and KalFitAlg().

◆ eventNo

int KalFitAlg::eventNo

Definition at line 226 of file KalFitAlg.h.

Referenced by execute(), fillTds_back(), and fillTds_back().

◆ eventno

int KalFitAlg::eventno

Definition at line 172 of file KalFitAlg.h.

Referenced by KalFitAlg().

◆ fac_h1_

double KalFitAlg::fac_h1_

Definition at line 190 of file KalFitAlg.h.

Referenced by complete_track(), complete_track(), and KalFitAlg().

◆ fac_h2_

double KalFitAlg::fac_h2_

Definition at line 190 of file KalFitAlg.h.

Referenced by complete_track(), complete_track(), and KalFitAlg().

◆ fac_h3_

double KalFitAlg::fac_h3_

Definition at line 190 of file KalFitAlg.h.

Referenced by complete_track(), complete_track(), and KalFitAlg().

◆ fac_h4_

double KalFitAlg::fac_h4_

Definition at line 190 of file KalFitAlg.h.

Referenced by complete_track(), complete_track(), and KalFitAlg().

◆ fac_h5_

double KalFitAlg::fac_h5_

Definition at line 190 of file KalFitAlg.h.

Referenced by complete_track(), complete_track(), and KalFitAlg().

◆ fitnocut_

int KalFitAlg::fitnocut_

Definition at line 200 of file KalFitAlg.h.

Referenced by fillTds(), fillTds_ip(), fillTds_lead(), and KalFitAlg().

◆ fstrag_

double KalFitAlg::fstrag_

factor of energy loss straggling for electron

Definition at line 219 of file KalFitAlg.h.

Referenced by initialize(), and KalFitAlg().

◆ gain1_

double KalFitAlg::gain1_

Definition at line 192 of file KalFitAlg.h.

Referenced by init_matrix(), and KalFitAlg().

◆ gain2_

double KalFitAlg::gain2_

Definition at line 192 of file KalFitAlg.h.

Referenced by init_matrix(), and KalFitAlg().

◆ gain3_

double KalFitAlg::gain3_

Definition at line 192 of file KalFitAlg.h.

Referenced by init_matrix(), and KalFitAlg().

◆ gain4_

double KalFitAlg::gain4_

Definition at line 192 of file KalFitAlg.h.

Referenced by init_matrix(), and KalFitAlg().

◆ gain5_

double KalFitAlg::gain5_

Definition at line 192 of file KalFitAlg.h.

Referenced by init_matrix(), and KalFitAlg().

◆ i_back_

int KalFitAlg::i_back_

mass assumption for backward filter (if <0 means use leading mass)

Definition at line 204 of file KalFitAlg.h.

Referenced by complete_track(), complete_track(), and KalFitAlg().

◆ i_front_

int KalFitAlg::i_front_

Definition at line 205 of file KalFitAlg.h.

Referenced by complete_track(), complete_track(), and KalFitAlg().

◆ inner_steps_

int KalFitAlg::inner_steps_

Definition at line 196 of file KalFitAlg.h.

Referenced by initialize(), and KalFitAlg().

◆ iqual_back_

int KalFitAlg::iqual_back_

Definition at line 222 of file KalFitAlg.h.

Referenced by execute(), fillTds_back(), fillTds_back(), and KalFitAlg().

◆ iqual_front_

int KalFitAlg::iqual_front_[5]

◆ lead_

◆ loss_

int KalFitAlg::loss_

Definition at line 187 of file KalFitAlg.h.

Referenced by initialize(), and KalFitAlg().

◆ lr_

int KalFitAlg::lr_

Definition at line 187 of file KalFitAlg.h.

Referenced by initialize(), and KalFitAlg().

◆ m_csmflag

int KalFitAlg::m_csmflag

◆ m_dangcut

double KalFitAlg::m_dangcut

Definition at line 229 of file KalFitAlg.h.

Referenced by execute(), and KalFitAlg().

◆ m_dphicut

double KalFitAlg::m_dphicut

Definition at line 229 of file KalFitAlg.h.

Referenced by execute(), and KalFitAlg().

◆ m_usevtxdb

int KalFitAlg::m_usevtxdb

Definition at line 227 of file KalFitAlg.h.

Referenced by KalFitAlg(), and smoother_anal().

◆ matfile_

string KalFitAlg::matfile_

Definition at line 211 of file KalFitAlg.h.

Referenced by KalFitAlg().

◆ matrixg_

◆ mhyp_

int KalFitAlg::mhyp_

Definition at line 180 of file KalFitAlg.h.

Referenced by complete_track(), complete_track(), initialize(), and KalFitAlg().

◆ muls_

int KalFitAlg::muls_

Flag account to multiple scattering and energy loss, where lr flag from and whether use active hits only

Definition at line 187 of file KalFitAlg.h.

Referenced by beginRun(), initialize(), and KalFitAlg().

◆ ntuple_

◆ numf_

int KalFitAlg::numf_

Definition at line 195 of file KalFitAlg.h.

Referenced by initialize(), and KalFitAlg().

◆ numf_in_

int KalFitAlg::numf_in_

Definition at line 198 of file KalFitAlg.h.

◆ numf_out_

int KalFitAlg::numf_out_

Definition at line 199 of file KalFitAlg.h.

◆ numfcor_

int KalFitAlg::numfcor_

Definition at line 194 of file KalFitAlg.h.

Referenced by initialize(), and KalFitAlg().

◆ outer_steps_

int KalFitAlg::outer_steps_

Definition at line 197 of file KalFitAlg.h.

Referenced by initialize(), and KalFitAlg().

◆ pathl_

int KalFitAlg::pathl_

◆ pe_cut_

double KalFitAlg::pe_cut_

value of the momentum cut to decide refit

Definition at line 182 of file KalFitAlg.h.

Referenced by complete_track(), complete_track(), and KalFitAlg().

◆ pk_cut_

double KalFitAlg::pk_cut_

Definition at line 182 of file KalFitAlg.h.

Referenced by complete_track(), complete_track(), and KalFitAlg().

◆ pmu_cut_

double KalFitAlg::pmu_cut_

Definition at line 182 of file KalFitAlg.h.

Referenced by complete_track(), complete_track(), and KalFitAlg().

◆ pp_cut_

double KalFitAlg::pp_cut_

Definition at line 182 of file KalFitAlg.h.

Referenced by complete_track(), complete_track(), and KalFitAlg().

◆ ppi_cut_

double KalFitAlg::ppi_cut_

Definition at line 182 of file KalFitAlg.h.

Referenced by complete_track(), complete_track(), and KalFitAlg().

◆ pT_

double KalFitAlg::pT_

value of the pT cut for backward filter

Definition at line 176 of file KalFitAlg.h.

Referenced by complete_track(), complete_track(), initialize(), and KalFitAlg().

◆ pt_cut_

◆ resolution_

int KalFitAlg::resolution_

Definition at line 221 of file KalFitAlg.h.

Referenced by initialize(), and KalFitAlg().

◆ steplev_

int KalFitAlg::steplev_

Definition at line 193 of file KalFitAlg.h.

Referenced by initialize(), and KalFitAlg().

◆ Tds_back_no

int KalFitAlg::Tds_back_no

Definition at line 174 of file KalFitAlg.h.

Referenced by KalFitAlg().

◆ theta_cut_

◆ tof_hyp_

int KalFitAlg::tof_hyp_

Definition at line 187 of file KalFitAlg.h.

Referenced by initialize(), and KalFitAlg().

◆ tofflag_

int KalFitAlg::tofflag_

Definition at line 187 of file KalFitAlg.h.

Referenced by initialize(), and KalFitAlg().

◆ tprop_

int KalFitAlg::tprop_

propagation correction

Definition at line 225 of file KalFitAlg.h.

Referenced by initialize(), and KalFitAlg().

◆ usage_

int KalFitAlg::usage_

this usage is used to control the usage of this algorithm ,to be analysis or calibration.

Definition at line 162 of file KalFitAlg.h.

Referenced by complete_track(), execute(), fillTds_back(), filter_fwd_calib(), KalFitAlg(), setDchisqCut(), smoother_calib(), and start_seed().

◆ wsag_

int KalFitAlg::wsag_

flag to take account the wire sag into account

Definition at line 168 of file KalFitAlg.h.

Referenced by execute(), filter_fwd_anal(), filter_fwd_calib(), initialize(), KalFitAlg(), smoother_anal(), and smoother_calib().


The documentation for this class was generated from the following files: