BOSS 7.0.6
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 58 of file KalFitAlg.h.

Constructor & Destructor Documentation

◆ KalFitAlg()

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

constructor

Constructor.

Definition at line 85 of file KalFitAlg.cxx.

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

◆ ~KalFitAlg()

KalFitAlg::~KalFitAlg ( void  )

destructor

Definition at line 159 of file KalFitAlg.cxx.

160{
161 MsgStream log(msgSvc(), name());
162 log << MSG::INFO <<" Start cleaning, delete Mdc geometry objects" << endreq;
163 clean();
164 log << MSG::INFO << "End cleaning " << endreq;
165}
IMessageSvc * msgSvc()
void clean(void)
Definition: KalFitAlg.cxx:167

Member Function Documentation

◆ beginRun()

StatusCode KalFitAlg::beginRun ( )

Definition at line 307 of file KalFitAlg.cxx.

308{
309 MsgStream log(msgSvc(), name());
310 log << MSG::INFO << "in beginRun()" << endreq;
311 log << MSG::INFO << "Present Parameters: muls: " << muls_ <<" loss: "
312 << " activeonly "<< activeonly_ << endreq;
313
314 // initialize the MdcGeomSvc
316 // Wires, Layers and SuperLayers of Mdc :
317 set_Mdc();
318
319 IMagneticFieldSvc* IMFSvc;
320 StatusCode sc = service ("MagneticFieldSvc",IMFSvc);
321 if(sc!=StatusCode::SUCCESS) {
322 log << MSG::ERROR << "Unable to open Magnetic field service"<<endreq;
323 }
324
325 // Nominal magnetic field :
327 KalFitTrack::Bznom_ = (IMFSvc->getReferField())*10000; //unit is KGauss
329
330 if(4 == debug_){
331 std::cout<<" beginRun, referField from MagneticFieldSvc:"<< (IMFSvc->getReferField())*10000 <<std::endl;
332 std::cout<<" magnetic field: "<<KalFitTrack::Bznom_<<std::endl;
333 }
334 }
335
336 return StatusCode::SUCCESS;
337}
virtual double getReferField()=0
void setGeomSvc_init(void)
Definition: KalFitAlg2.cxx:259
void set_Mdc(void)
Set up the wires, layers and superlayers...
Definition: KalFitAlg2.cxx:114
static double Bznom_
Definition: KalFitTrack.h:299
static int numfcor_
NUMF treatment improved.
Definition: KalFitTrack.h:297

◆ clean()

void KalFitAlg::clean ( void  )

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

Definition at line 167 of file KalFitAlg.cxx.

168{
169 // delete all Mdc objects :
170 _BesKalmanFitWalls.clear();
171 _BesKalmanFitMaterials.clear();
172 if(_wire)free(_wire);
173 if(_layer)free(_layer);
174 if(_superLayer)free(_superLayer);
175}

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

◆ clearTables()

void KalFitAlg::clearTables ( )

Definition at line 5943 of file KalFitAlg.cxx.

5943 {
5944
5945 if(debug_ == 4) cout<<"Begining to clear Tables ...."<<endl;
5946 vector<MdcRec_trk>* mdcMgr = MdcRecTrkCol::getMdcRecTrkCol();
5947 vector<MdcRec_trk_add>* mdc_addMgr = MdcRecTrkAddCol::getMdcRecTrkAddCol();
5948 vector<MdcRec_wirhit>* whMgr = MdcRecWirhitCol::getMdcRecWirhitCol();
5949 vector<MdcRec_trk>::iterator tit=mdcMgr->begin();
5950 for( ; tit != mdcMgr->end(); tit++) {
5951 vector<MdcRec_wirhit*>::iterator vit= tit->hitcol.begin() ;
5952 for(; vit != tit->hitcol.end(); vit++) {
5953 delete (*vit);
5954 }
5955 }
5956
5957 mdcMgr->clear();
5958 mdc_addMgr->clear();
5959 whMgr->clear();
5960
5961 // delete mdcMgr;
5962 // delete mdc_addMgr;
5963 // delete whMgr;
5964 // mdcMgr = 0;
5965 // mdc_addMgr = 0;
5966 // whMgr = 0;
5967
5968}
static vector< MdcRec_trk_add > * getMdcRecTrkAddCol(void)
Definition: MdcTables.cxx:356
static vector< MdcRec_trk > * getMdcRecTrkCol(void)
Definition: MdcTables.cxx:185
static vector< MdcRec_wirhit > * getMdcRecWirhitCol(void)
Definition: MdcTables.cxx:169

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 5527 of file KalFitAlg.cxx.

5532{
5533 static int nmass = KalFitTrack::nmass();
5534 int way(1);
5535 MsgStream log(msgSvc(), name());
5536 KalFitTrack track_first(track_lead);
5537 KalFitTrack track_ip(track_lead);
5538
5539 if (debug_ == 4){
5540 cout << "track_first pivot "<<track_first.pivot()<< " helix "<<track_first.a()<<endl;
5541 }
5542 if(usage_==1) innerwall(track_ip, lead_, way);
5543 // Fill Tds
5544 fillTds_ip(TrasanTRK, track_ip, kaltrk, lead_);
5545
5546 if (debug_ == 4) {
5547 cout << "after inner wall, track_ip pivot "<<track_first.pivot()<< " helix "<<track_first.a()<<endl;
5548 }
5549
5550 fillTds_lead(TrasanTRK, track_first, kaltrk, lead_);
5551
5552 // Refit for different mass assumptions :
5553 double pp = track_lead.momentum().mag();
5554
5555 //w if (!KalFitDSSD::cosmic_)
5556 if(!(i_front_<0)){
5557
5558 for(int l_mass = 0, flg = 1; l_mass < nmass;
5559 l_mass++, flg <<= 1) {
5560
5561 if (!(mhyp_ & flg)) continue;
5562 if (l_mass == lead_) continue;
5563
5564 // Check the mom. to decide of the refit with this mass assumption
5565 if ((lead_ != 0 && l_mass==0 && pp > pe_cut_) ||
5566 (lead_ != 1 && l_mass==1 && pp > pmu_cut_) ||
5567 (lead_ != 2 && l_mass==2 && pp > ppi_cut_) ||
5568 (lead_ != 3 && l_mass==3 && pp > pk_cut_) ||
5569 (lead_ != 4 && l_mass==4 && pp > pp_cut_))
5570 continue;
5571
5572 if(debug_ == 4) {
5573 cout<<"complete_track..REFIT ASSUMPION " << l_mass << endl;
5574 }
5575
5576 // Initialisation :
5577 double chiSq = 0;
5578 int nhits = 0;
5579
5580 // Initialisation : (x, a, ea)
5581 HepPoint3D x_trasan(TrasanTRK.pivot[0],
5582 TrasanTRK.pivot[1],
5583 TrasanTRK.pivot[2]);
5584
5585 HepVector a_trasan(5);
5586 for(int i = 0; i < 5; i++){
5587 a_trasan[i] = TrasanTRK.helix[i];
5588 }
5589
5590 HepSymMatrix ea_trasan(5);
5591 for(int i = 0, k = 0; i < 5; i++) {
5592 for(int j = 0; j <= i; j++) {
5593 ea_trasan[i][j] = matrixg_*TrasanTRK.error[k++];
5594 ea_trasan[j][i] = ea_trasan[i][j];
5595 }
5596 }
5597
5598 KalFitTrack track(x_trasan,a_trasan, ea_trasan, l_mass, chiSq, nhits);
5599 track.HitsMdc(track_lead.HitsMdc());
5600
5601 double fiTerm = TrasanTRK.fiTerm;
5602 track.pivot(track.x(fiTerm));
5603
5604 HepSymMatrix Eakal(5,0);
5605
5606 double costheta = track_lead.a()[4] / sqrt(1.0 + track_lead.a()[4]*track_lead.a()[4]);
5607 if( (1.0/fabs(track_lead.a()[2]) < pt_cut_ ) && (fabs(costheta)> theta_cut_) ) {
5608 choice_ = 6;
5609 }
5610
5611 init_matrix(choice_, TrasanTRK, Eakal);
5612
5613 filter_fwd_calib(track, l_mass, way, Eakal);
5614
5615 KalFitTrack track_z(track);
5616 ///fill tds with results got at (0,0,0)
5617 innerwall(track_z, l_mass, way);
5618 fillTds_ip(TrasanTRK, track_z, kaltrk, l_mass);
5619 // Fill tds
5620 fillTds(TrasanTRK, track, kaltrk, l_mass);
5621 }
5622 } //end of if (!(i_front<0))
5623
5624 // Refit with an enhancement of the error matrix at Mdc level :
5625
5626 if (enhance_) {
5627 HepPoint3D x_first(0, 0, 0);
5628 HepVector a_first(kaltrk->getFHelix());
5629 HepSymMatrix ea_first(kaltrk->getFError());
5630 HepVector fac(5);
5631 fac[0]=fac_h1_; fac[1]=fac_h2_; fac[2]=fac_h3_; fac[3]=fac_h4_; fac[4]=fac_h5_;
5632
5633 for(int i = 0; i < 5; i++)
5634 for(int j = 0; j <= i; j++)
5635 ea_first[i][j] = fac[i]*fac[j]*ea_first[i][j];
5636 KalFitTrack track(x_first, a_first, ea_first, 2, 0, 0);
5637 }
5638
5639 // Backward filter
5640 // Attention, the initial error matrix of track_back is the error matrix
5641 // that after filter_fwd_calib(...) course of track_lead. So one thing need
5642 // more consideration that how to chose the inital error matrix of this smoother,
5643 // to put it by hand or use the error matrix after filter_fwd_calib. I think
5644 // it should be to refer R.G.Brown's book.
5645
5646 KalFitTrack track_back(track_lead);
5647
5648 //track_back(track);
5649
5650
5651 if (debug_ == 4) {
5652 cout << " Backward fitting flag:" << back_<< endl;
5653 cout << "track_back pivot " << track_back.pivot()
5654 << " track_lead kappa " << track_lead.a()[2]
5655 <<endl;
5656 }
5657
5658 if (back_ && track_lead.a()[2] != 0 &&
5659 1/fabs(track_lead.a()[2]) > pT_) {
5660 track_back.HitsMdc(track_lead.HitsMdc());
5661
5663
5664 double p_kaon(0), p_proton(0);
5665
5666 if (!(kaltrk->getStat(0,3))) {
5667 p_kaon = 1 / fabs(kaltrk->getZHelixK()[2]) *
5668 sqrt(1 + kaltrk->getZHelixK()[4]*kaltrk->getZHelixK()[4]);
5669 track_back.p_kaon(p_kaon);
5670 } else {
5671 p_kaon = 1 / fabs(track_back.a()[2]) *
5672 sqrt(1 + track_back.a()[4]*track_back.a()[4]);
5673 track_back.p_kaon(p_kaon);
5674 }
5675 if (!(kaltrk->getStat(0,4))) {
5676 p_proton = 1 / fabs(kaltrk->getZHelixP()[2]) *
5677 sqrt(1 + kaltrk->getZHelixP()[4]*kaltrk->getZHelixP()[4]);
5678 track_back.p_proton(p_proton);
5679 } else {
5680 p_proton = 1 / fabs(track_back.a()[2]) *
5681 sqrt(1 + track_back.a()[4]*track_back.a()[4]);
5682 track_back.p_proton(p_proton);
5683 }
5684
5685 }
5686
5687
5688 if (!(i_back_<0)) {
5689 for(int l_mass = 0; l_mass < nmass; l_mass++) {
5690 KalFitTrack track_seed(track_back);
5691 track_seed.chgmass(l_mass);
5692 smoother_calib(track_seed, -way);
5693 // fill TDS for backward filter :
5694 fillTds_back(track_seed, kaltrk, TrasanTRK, l_mass,segcol);
5695 }
5696 } else {
5697
5698 smoother_calib(track_back, -way);
5699 // fill TDS for backward filter , for leading particle hypothesis :
5700 fillTds_back(track_back, kaltrk, TrasanTRK, lead_,segcol);
5701 // fillTds_helixsegs(track_back,TrasanTRK);
5702 }
5703 }
5704
5705 /*
5706 // Take care of the pointers (use lead. hyp results by default)
5707 for(int pid = 0; pid < nmass;
5708 pid++) {
5709 if (pid == lead_) continue;
5710 if (kaltrk->getStat(1,pid))
5711 sameas(kaltrk, pid, lead_);
5712 }
5713 */
5714
5715 //check: before register into TDS
5716
5717 log << MSG::DEBUG << "registered MDC Kalmantrack:"
5718 << "Track Id: " << kaltrk->getTrackId()
5719 << " Mass of the fit: "<< kaltrk->getMass(2)<< endreq
5720 << "Length of the track: "<< kaltrk->getLength(2)
5721 << " Tof of the track: "<< kaltrk->getTof(2) << endreq
5722 << "Chisq of the fit: "<< kaltrk->getChisq(0,2)
5723 <<" "<< kaltrk->getChisq(1,2) << endreq
5724 << "Ndf of the fit: "<< kaltrk->getNdf(0,2)
5725 <<" "<< kaltrk->getNdf(1,2) << endreq
5726 << "Helix " << kaltrk->getZHelix()[2]
5727 <<endreq;
5728
5729 kalcol->push_back(kaltrk);
5730 track_lead.HitsMdc().clear();
5731 track_back.HelixSegs().clear();
5732 // ??ATTENTION!! should track_back.HelixSegs() be cleared ??
5733}
void filter_fwd_calib(KalFitTrack &trk, int l_mass, int way, HepSymMatrix &Eakal)
Definition: KalFitAlg.cxx:2868
void fillTds_lead(MdcRec_trk &TrasanTRK, KalFitTrack &track, RecMdcKalTrack *trk, int l_mass)
Definition: KalFitAlg.cxx:1217
void fillTds_ip(MdcRec_trk &TrasanTRK, KalFitTrack &track, RecMdcKalTrack *trk, int l_mass)
with results got at (0,0,0)
Definition: KalFitAlg.cxx:1309
void fillTds(MdcRec_trk &TrasanTRK, KalFitTrack &track, RecMdcKalTrack *trk, int l_mass)
with results got at the inner Mdc hit
Definition: KalFitAlg.cxx:1139
void innerwall(KalFitTrack &trk, int l_mass, int way)
Take the inner walls (eloss and mult scat) into account.
Definition: KalFitAlg.cxx:3066
void smoother_calib(KalFitTrack &trk, int way)
Definition: KalFitAlg.cxx:2490
void init_matrix(MdcRec_trk &trk, HepSymMatrix &Ea)
Definition: KalFitAlg.cxx:5736
void fillTds_back(KalFitTrack &track, RecMdcKalTrack *trk, MdcRec_trk &TrasanTRK, int l_mass)
with results got at the outer Mdc hit
Definition: KalFitAlg.cxx:1468
Description of a track class (<- Helix.cc)
Definition: KalFitTrack.h:35
static int nmass(void)
static int tofall_
Definition: KalFitTrack.h:314
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.
float helix[5]
Definition: MdcTables.h:403
float fiTerm
Definition: MdcTables.h:408
float pivot[3]
Definition: MdcTables.h:404
float error[15]
Definition: MdcTables.h:405
const HepVector & getZHelix() const
HepVector & getZHelixP()
double getTof(int pid) const
const HepSymMatrix & getFError() const
double getChisq(int i, int pid) const
HepVector & getZHelixK()
const HepVector & getFHelix() const
int getTrackId(void) const
double getMass(int pid) const
int getStat(int i, int pid) const
double getLength(int pid) const
int getNdf(int i, int pid) const
int nhits
float costheta

◆ 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 5343 of file KalFitAlg.cxx.

5348{
5349 static int nmass = KalFitTrack::nmass();
5350 int way(1);
5351 MsgStream log(msgSvc(), name());
5352 KalFitTrack track_first(track_lead);
5353 KalFitTrack track_ip(track_lead);
5354 innerwall(track_ip, lead_, way);
5355 // Fill Tds
5356 fillTds_ip(TrasanTRK, track_ip, kaltrk, lead_);
5357 // std::cout<<"track_first nster"<<track_first.nster()<<std::endl;
5358
5359 fillTds_lead(TrasanTRK, track_first, kaltrk, lead_);
5360 // Refit for different mass assumptions :
5361 double pp = track_lead.momentum().mag();
5362
5363 if(!(i_front_<0)){
5364
5365 for(int l_mass = 0, flg = 1; l_mass < nmass;
5366 l_mass++, flg <<= 1) {
5367
5368 if (!(mhyp_ & flg)) continue;
5369 if (l_mass == lead_) continue;
5370
5371 // Check the mom. to decide of the refit with this mass assumption
5372 if ((lead_ != 0 && l_mass==0 && pp > pe_cut_) ||
5373 (lead_ != 1 && l_mass==1 && pp > pmu_cut_) ||
5374 (lead_ != 2 && l_mass==2 && pp > ppi_cut_) ||
5375 (lead_ != 3 && l_mass==3 && pp > pk_cut_) ||
5376 (lead_ != 4 && l_mass==4 && pp > pp_cut_))
5377 continue;
5378 if(debug_ == 4) cout<<"complete_track..REFIT ASSUMPION " << l_mass << endl;
5379 // Initialisation :
5380 double chiSq = 0;
5381 int nhits = 0;
5382
5383 // Initialisation : (x, a, ea)
5384 HepPoint3D x_trasan(TrasanTRK.pivot[0],
5385 TrasanTRK.pivot[1],
5386 TrasanTRK.pivot[2]);
5387 HepVector a_trasan(5);
5388 for(int i = 0; i < 5; i++)
5389 a_trasan[i] = TrasanTRK.helix[i];
5390
5391 HepSymMatrix ea_trasan(5);
5392 for(int i = 0, k = 0; i < 5; i++) {
5393 for(int j = 0; j <= i; j++) {
5394 ea_trasan[i][j] = matrixg_*TrasanTRK.error[k++];
5395 ea_trasan[j][i] = ea_trasan[i][j];
5396 }
5397 }
5398
5399 KalFitTrack track(x_trasan,a_trasan, ea_trasan, l_mass, chiSq, nhits);
5400 track.HitsMdc(track_lead.HitsMdc());
5401 double fiTerm = TrasanTRK.fiTerm;
5402 track.pivot(track.x(fiTerm));
5403 HepSymMatrix Eakal(5,0);
5404
5405 double costheta = track.a()[4] / sqrt(1.0 + track.a()[4]*track.a()[4]);
5406 if( (1.0/fabs(track.a()[2]) < pt_cut_ ) && (fabs(costheta)> theta_cut_) ) {
5407 choice_ = 6;
5408 }
5409
5410 init_matrix(choice_,TrasanTRK, Eakal);
5411 filter_fwd_anal(track, l_mass, way, Eakal);
5412 KalFitTrack track_z(track);
5413 ///fill tds with results got at (0,0,0)
5414 innerwall(track_z, l_mass, way);
5415 fillTds_ip(TrasanTRK, track_z, kaltrk, l_mass);
5416 // Fill tds
5417 fillTds(TrasanTRK, track, kaltrk, l_mass);
5418 }
5419 } // end of //end of if (!(i_front<0))
5420
5421
5422 // Refit with an enhancement of the error matrix at Mdc level :
5423 if (enhance_) {
5424
5425 HepPoint3D x_first(0, 0, 0);
5426 HepVector a_first(kaltrk->getFHelix());
5427 HepSymMatrix ea_first(kaltrk->getFError());
5428 HepVector fac(5);
5429 fac[0]=fac_h1_; fac[1]=fac_h2_; fac[2]=fac_h3_; fac[3]=fac_h4_; fac[4]=fac_h5_;
5430 for(int i = 0; i < 5; i++)
5431 for(int j = 0; j <= i; j++)
5432 ea_first[i][j] = fac[i]*fac[j]*ea_first[i][j];
5433 KalFitTrack track(x_first, a_first, ea_first, 2, 0, 0);
5434 }
5435
5436 // Backward filter :
5437 KalFitTrack track_back(track_lead);
5438 if (debug_ == 4) {
5439 cout << " Backward fitting flag:" << back_<< endl;
5440 cout << "track_back pivot " << track_back.pivot()
5441 << " track_lead kappa " << track_lead.a()[2]
5442 <<endl;
5443 }
5444
5445 if (back_ && track_lead.a()[2] != 0 &&
5446 1/fabs(track_lead.a()[2]) > pT_) {
5447 track_back.HitsMdc(track_lead.HitsMdc());
5448
5450 double p_kaon(0), p_proton(0);
5451 if (!(kaltrk->getStat(0,3))) {
5452 p_kaon = 1 / fabs(kaltrk->getZHelixK()[2]) *
5453 sqrt(1 + kaltrk->getZHelixK()[4]*kaltrk->getZHelixK()[4]);
5454 track_back.p_kaon(p_kaon);
5455 } else {
5456 p_kaon = 1 / fabs(track_back.a()[2]) *
5457 sqrt(1 + track_back.a()[4]*track_back.a()[4]);
5458 track_back.p_kaon(p_kaon);
5459 }
5460 if (!(kaltrk->getStat(0,4))) {
5461 p_proton = 1 / fabs(kaltrk->getZHelixP()[2]) *
5462 sqrt(1 + kaltrk->getZHelixP()[4]*kaltrk->getZHelixP()[4]);
5463 track_back.p_proton(p_proton);
5464 } else {
5465 p_proton = 1 / fabs(track_back.a()[2]) *
5466 sqrt(1 + track_back.a()[4]*track_back.a()[4]);
5467 track_back.p_proton(p_proton);
5468 }
5469 }
5470
5471 if (!(i_back_<0)) {
5472 //cout<<" *** in smoothing process ***"<<endl;
5473 for(int l_mass = 0; l_mass < nmass; l_mass++) {
5474 //cout<<" --- in hypothesis "<<l_mass<<" :"<<endl;
5475 KalFitTrack track_seed(track_back);
5476 track_seed.chgmass(l_mass);
5477 /*cout<<"---------------"<<endl;//wangll
5478 cout<<"smooth track "<<l_mass<<endl;//wangll
5479 cout<<" pivot :"<<track_seed.pivot()<<endl;//wangll
5480 cout<<" helix :"<<track_seed.a()<<endl;//wangll
5481 */
5482 smoother_anal(track_seed, -way);
5483 // if( usage_ == 1) smoother_calib(track_seed, -way);
5484 //cout<<"fillTds_back 1"<<endl;
5485 // fill TDS for backward filter :
5486 fillTds_back(track_seed, kaltrk, TrasanTRK, l_mass, segcol, 1);
5487 //cout<<"nHits: "<<kaltrk->getVecHelixSegs().size()<<endl;
5488 }
5489 } else {
5490 smoother_anal(track_back, -way);
5491 //smoother_calib(track_back, -way);
5492 // smoother(track_back, -way);
5493 // fill TDS for backward filter :
5494 //cout<<"fillTds_back 2"<<endl;
5495 fillTds_back(track_back, kaltrk, TrasanTRK, lead_, segcol, 1);
5496 }
5497 }
5498 /*
5499 // Take care of the pointers (use lead. hyp results by default)
5500 for(int pid = 0; pid < nmass;
5501 pid++) {
5502 if (pid == lead_) continue;
5503 if (kaltrk->getStat(1,pid))
5504 sameas(kaltrk, pid, lead_);
5505 }
5506 */
5507
5508 //check: before register into TDS
5509
5510 log << MSG::DEBUG << "registered MDC Kalmantrack:"
5511 << "Track Id: " << kaltrk->getTrackId()
5512 << " Mass of the fit: "<< kaltrk->getMass(2)<< endreq
5513 << "Length of the track: "<< kaltrk->getLength(2)
5514 << " Tof of the track: "<< kaltrk->getTof(2) << endreq
5515 << "Chisq of the fit: "<< kaltrk->getChisq(0,2)
5516 <<" "<< kaltrk->getChisq(1,2) << endreq
5517 << "Ndf of the fit: "<< kaltrk->getNdf(0,2)
5518 <<" "<< kaltrk->getNdf(1,2) << endreq
5519 << "Helix " << kaltrk->getZHelix()[2]
5520 <<endreq;
5521
5522 kalcol->push_back(kaltrk);
5523 track_lead.HitsMdc().clear();
5524}
void filter_fwd_anal(KalFitTrack &trk, int l_mass, int way, HepSymMatrix &Eakal)
Kalman filter (forward) in Mdc.
Definition: KalFitAlg.cxx:2628
void smoother_anal(KalFitTrack &trk, int way)
Kalman filter (smoothing or backward part)
Definition: KalFitAlg.cxx:2275

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 654 of file KalFitAlg.cxx.

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

◆ 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 1139 of file KalFitAlg.cxx.

1140 {
1141
1142 HepPoint3D IP(0,0,0);
1143 track.pivot(IP);
1144 // Fit quality
1145 int iqual(1);
1146 int trasster = TrasanTRK.nster, trakster = track.nster(),
1147 trasax(TrasanTRK.nhits-trasster), trakax(track.nchits()-trakster);
1148 if (TrasanTRK.nhits-track.nchits()>fitnocut_ ||
1149 TrasanTRK.helix[2]*track.a()[2]<0)
1150 iqual = 0;
1151
1152 if (debug_ == 4) {
1153 cout<< "trasster trakster trasax trakax TrasK trackK iqual"<<endl
1154 <<trasster<<" "<<trakster<<" "<<trasax<<" "<<trakax
1155 <<" "<<TrasanTRK.helix[2]<<" "<<track.a()[2]<<" "<<iqual<<endl;
1156 cout<<"FillTds> track.chiSq..."<<track.chiSq()<<" nchits "<<track.nchits()
1157 <<" nster "<<track.nster()<<" iqual "<<iqual<<" track.Ea "<< track.Ea()<<endl;
1158
1159 cout<<"fillTds>.....track.Ea[2][2] "<<track.Ea()[2][2]<<endl;
1160 cout << " TRASAN stereo = " << trasster
1161 << " and KalFitTrack = " << trakster << std::endl;
1162 cout << " TRASAN axial = " << trasax
1163 << " and KalFitTrack = " << trakax << std::endl;
1164
1165 if (!iqual) {
1166 cout << "...there is a problem during fit !! " << std::endl;
1167 if (trasster-trakster>5)
1168 cout << " because stereo " << trasster-trakster << std::endl;
1169 if (trasax-trakax >5)
1170 cout << " because axial " << std::endl;
1171 if (TrasanTRK.helix[2]*track.a()[2]<0)
1172 cout << " because kappa sign " << std::endl;
1173 }
1174 }
1175 // Protection : if any problem, we keep the original information !!!!
1176 if (track.nchits() > 5 && track.nster() > 1 &&
1177 track.nchits()-track.nster() > 2 && track.chiSq() > 0 &&
1178 track.Ea()[0][0] > 0 && track.Ea()[1][1] > 0 &&
1179 track.Ea()[2][2] > 0 && track.Ea()[3][3] > 0 &&
1180 track.Ea()[4][4] > 0 && iqual) {
1181 if(debug_ == 4) cout<<"fillTds>.....going on "<<endl;
1182 trk->setStat(0,0,l_mass);
1183 trk->setMass(track.mass(),l_mass);
1184
1185 // chisq & ndf
1186 trk->setChisq(track.chiSq(),0,l_mass);
1187 trk->setNdf(track.nchits()-5,0,l_mass);
1188 trk->setNhits(track.nchits(),l_mass);
1189
1190 trk->setFHelix(track.a(),l_mass);
1191 trk->setFError(track.Ea(),l_mass);
1192
1193 } else {
1194
1195 if(debug_) cout<<"ALARM: FillTds Not refit with KalFilter!!!"<<endl;
1196 // NOT refit with Kalman filter :
1197 trk->setStat(1,0,l_mass);
1198 trk->setMass(KalFitTrack::mass(l_mass),l_mass);
1199 // chisq & ndf (0 : filter ; 1 : smoother;)
1200 trk->setChisq(TrasanTRK.chiSq,0,l_mass);
1201 trk->setNdf(TrasanTRK.nhits-5,0,l_mass);
1202 // nhits
1203 trk->setNhits(TrasanTRK.nhits,l_mass);
1204 double a_trasan[5], ea_trasan[15];
1205 for( int i =0 ; i <5; i++){
1206 a_trasan[i] = TrasanTRK.helix[i];
1207 }
1208 for( int j =0 ; j <15; j++){
1209 ea_trasan[j] = TrasanTRK.error[j];
1210 }
1211 trk->setFHelix(a_trasan, l_mass);
1212 trk->setFError(ea_trasan,l_mass);
1213 }
1214}
void setFHelix(const HepVector &fhelix, const int pid)
void setStat(int stat, int i, int pid)
void setChisq(double chisq, int i, int pid)
void setFError(const HepSymMatrix &ferror, const int pid)
void setNdf(int ndf, int i, int pid)
unsigned int nchits(void) const
Definition: KalFitTrack.h:198
double chiSq(void) const
Definition: KalFitTrack.h:183
unsigned int nster(void) const
Definition: KalFitTrack.h:199
double mass(void) const
Definition: KalFitTrack.h:182
const HepSymMatrix & Ea(void) const
returns error matrix.
const HepPoint3D & pivot(void) const
returns pivot position.
void setMass(double mass, int pid)
void setNhits(int nhits, int pid)

Referenced by 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 1468 of file KalFitAlg.cxx.

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

Referenced by 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 1626 of file KalFitAlg.cxx.

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

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

◆ 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 1309 of file KalFitAlg.cxx.

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

Referenced by complete_track().

◆ fillTds_lead()

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

Definition at line 1217 of file KalFitAlg.cxx.

1218 {
1219
1220 HepPoint3D IP(0,0,0);
1221 track.pivot(IP);
1222 // Fit quality
1223 // int iqual(1);
1224 int trasster = TrasanTRK.nster, trakster = track.nster(),
1225 trasax(TrasanTRK.nhits-trasster), trakax(track.nchits()-trakster);
1226 if (TrasanTRK.nhits-track.nchits()>fitnocut_ ||
1227 TrasanTRK.helix[2]*track.a()[2]<0)
1228 iqual_front_[l_mass] = 0;
1229 if (debug_ == 4) {
1230
1231 cout<<"Nhit from PR "<<TrasanTRK.nhits<<" nhit "<<track.nchits()<<endl;
1232 cout<< "trasster trakster trasax trakax TrasK trackK iqual"<<endl
1233 <<trasster<<" "<<trakster<<" "<<trasax<<" "<<trakax
1234 <<" "<<TrasanTRK.helix[2]<<" "<<track.a()[2]<<" "<<iqual_front_[l_mass]<<endl;
1235 cout<<"FillTds_lead> track.chiSq..."<<track.chiSq()<<" nchits "<<track.nchits()
1236 <<" nster "<<track.nster()<<" iqual_front_[l_mass] "<<iqual_front_[l_mass]<<" track.Ea "<<track.Ea()<<endl;
1237
1238 cout << " TRASAN stereo = " << trasster
1239 << " and KalFitTrack = " << trakster << std::endl;
1240 cout << " TRASAN axial = " << trasax
1241 << " and KalFitTrack = " << trakax << std::endl;
1242
1243 if (!iqual_front_[l_mass]) {
1244 cout << "...there is a problem during fit !! " << std::endl;
1245 if (trasster-trakster>5)
1246 cout << " because stereo " << trasster-trakster << std::endl;
1247 if (trasax-trakax >5)
1248 cout << " because axial " << std::endl;
1249 if (TrasanTRK.helix[2]*track.a()[2]<0)
1250 cout << " because kappa sign " << std::endl;
1251 }
1252 }
1253 // Protection : if any problem, we keep the original information !!!!
1254 if (track.nchits() > 5 && track.nster() > 1 &&
1255 track.nchits()-track.nster() > 2 && track.chiSq() > 0 &&
1256 track.Ea()[0][0] > 0 && track.Ea()[1][1] > 0 &&
1257 track.Ea()[2][2] > 0 && track.Ea()[3][3] > 0 &&
1258 track.Ea()[4][4] > 0 && iqual_front_[l_mass]) {
1259
1260 trk->setStat(0,0,l_mass);
1261 trk->setMass(track.mass(),l_mass);
1262 trk->setChisq(track.chiSq(),0,l_mass);
1263 trk->setNdf(track.nchits()-5,0,l_mass);
1264 trk->setNhits(track.nchits(),l_mass);
1265 //trkid
1266 trk->setTrackId(TrasanTRK.id);
1267
1268 if (debug_ == 4) cout<<" trasan id...1 "<<TrasanTRK.id<<endl;
1269
1270 trk->setFHelix(track.a(),l_mass);
1271 trk->setFError(track.Ea(),l_mass);
1272
1273 } else {
1274
1275 //cout<<"copy Mdc Helix in fillTds_lead()"<<endl;
1276
1277 if(debug_) cout<<"ALARM: FillTds_forMdc Not refit with KalFilter!!!"<<endl;
1278 // NOT refit with Kalman filter :
1279 trk->setStat(1,0,l_mass);
1280 trk->setMass(KalFitTrack::mass(l_mass),l_mass);
1281
1282 // chisq & ndf
1283 trk->setChisq(TrasanTRK.chiSq,0,l_mass);
1284 trk->setNdf(TrasanTRK.nhits-5,0,l_mass);
1285 //trkid
1286 trk->setTrackId(TrasanTRK.id);
1287
1288 if (debug_ ==4) cout<<" trasan id...2 "<<TrasanTRK.id<<endl;
1289
1290 // nhits
1291 trk->setNhits(TrasanTRK.nhits,l_mass);
1292 double a_trasan[5], ea_trasan[15];
1293 for( int i =0 ; i <5; i++){
1294 a_trasan[i] = TrasanTRK.helix[i];
1295 }
1296 for( int j =0 ; j <15; j++){
1297 ea_trasan[j] = TrasanTRK.error[j];
1298 }
1299 trk->setFHelix(a_trasan,l_mass);
1300 trk->setFError(ea_trasan,l_mass);
1301 // trk->setFHelix(TrasanTRK.helix,l_mass);
1302 // trk->setFError(TrasanTRK.error,l_mass);
1303 }
1304}
void setTrackId(int trackId)

Referenced by 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 2628 of file KalFitAlg.cxx.

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

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 2868 of file KalFitAlg.cxx.

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

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 294 of file KalFitAlg.cxx.

295{
296 MsgStream log(msgSvc(), name());
297 log << MSG::DEBUG<<"KalFitAlg:: nTotalTrks = "<<nTotalTrks<<endreq;
298 log << MSG::DEBUG<<" e: "<<nFailedTrks[0]<<" failed, "<<nTotalTrks-nFailedTrks[0]<<" successed"<<endreq;
299 log << MSG::DEBUG<<" mu: "<<nFailedTrks[1]<<" failed, "<<nTotalTrks-nFailedTrks[1]<<" successed"<<endreq;
300 log << MSG::DEBUG<<" pi: "<<nFailedTrks[2]<<" failed, "<<nTotalTrks-nFailedTrks[2]<<" successed"<<endreq;
301 log << MSG::DEBUG<<" K: "<<nFailedTrks[3]<<" failed, "<<nTotalTrks-nFailedTrks[3]<<" successed"<<endreq;
302 log << MSG::DEBUG<<" p: "<<nFailedTrks[4]<<" failed, "<<nTotalTrks-nFailedTrks[4]<<" successed"<<endreq;
303 return StatusCode::SUCCESS;
304}

◆ getEventStarTime()

void KalFitAlg::getEventStarTime ( void  )

◆ getWallMdcNumber()

int KalFitAlg::getWallMdcNumber ( const HepPoint3D point)

◆ hist_def()

void KalFitAlg::hist_def ( void  )

hist definition

Definition at line 343 of file KalFitAlg.cxx.

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

Referenced by initialize().

◆ init_matrix() [1/2]

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

Definition at line 5750 of file KalFitAlg.cxx.

5751{
5752 if(0==k){
5753 for ( int i=0; i<5; i++) {
5754 for( int j = 1; j<i+2;j++) {
5755 Eakal(i+1,j) = matrixg_*(trk.error[i*(i+1)/2+j-1]);
5756 Eakal(j,i+1) = Eakal(i+1,j);
5757 }
5758 Eakal(1,1) = Eakal(1,1)* gain1_;
5759 Eakal(2,2) = Eakal(2,2)* gain2_;
5760 Eakal(3,3) = Eakal(3,3)* gain3_;
5761 Eakal(4,4) = Eakal(4,4)* gain4_;
5762 Eakal(5,5) = Eakal(5,5)* gain5_;
5763 }
5764 }
5765 // HepSymMatrix ea_temp(5);
5766 // for(int i = 0, k = 0; i < 5; i++) {
5767 // for(int j = 0; j <= i; j++) {
5768 // ea_temp[i][j] = matrixg_*trk.error[k++];
5769 // ea_temp[j][i] = ea_temp[i][j];
5770 // }
5771 // }
5772
5773 if(1==k){
5774 Eakal(1,1) = .2;
5775 Eakal(2,2) = .001;
5776 Eakal(3,3) = 1.0;
5777 Eakal(4,4) = 10.0;
5778 Eakal(5,5) = 0.002;
5779 }
5780
5781 if(2==k){
5782 Eakal(1,1) = .2;
5783 Eakal(2,2) = 0.1;
5784 Eakal(3,3) = 1.0;
5785 Eakal(4,4) = 25.0;
5786 Eakal(5,5) = 0.10;
5787 }
5788
5789
5790 if(3==k){
5791 Eakal(1,1) = .2;
5792 Eakal(2,2) = .001;
5793 Eakal(3,3) = 1.0;
5794 Eakal(4,4) = 25.0;
5795 Eakal(5,5) = 0.10;
5796 }
5797
5798 if(4==k){
5799 Eakal(1,1) = .2;
5800 Eakal(2,2) = .01;
5801 Eakal(3,3) = 0.01;
5802 Eakal(4,4) = 1.;
5803 Eakal(5,5) = .01;
5804 }
5805
5806 if(5==k) {
5807 Eakal(1,1) = 2.;
5808 Eakal(2,2) = 0.1;
5809 Eakal(3,3) = 1.;
5810 Eakal(4,4) = 20.;
5811 Eakal(5,5) = 0.1;
5812 }
5813
5814 if(6==k) {
5815 Eakal(1,1) = 0.01;
5816 Eakal(2,2) = 0.01;
5817 Eakal(3,3) = 0.01;
5818 Eakal(4,4) = 100.;
5819 Eakal(5,5) = 0.5;
5820 }
5821
5822 if(k!=0){
5823 Eakal(3,3) = 0.2;
5824 Eakal(1,1) = 1;
5825 Eakal(4,4) = 1;
5826 }
5827
5828 if (debug_ == 4) cout<<"initialised Eakal.. "<<Eakal<<endl;
5829}

◆ init_matrix() [2/2]

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

Definition at line 5736 of file KalFitAlg.cxx.

5737{
5738 for ( int i=0; i<5; i++) {
5739 for( int j = 1; j<i+2;j++) {
5740 Eakal(i+1,j) = matrixg_*(trk.error[i*(i+1)/2+j-1]);
5741 Eakal(j,i+1) = Eakal(i+1,j);
5742 }
5743 }
5744
5745 if (debug_ == 4) cout<<"initialised Ea.. "<<Eakal<<endl;
5746}

Referenced by 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 178 of file KalFitAlg.cxx.

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

◆ innerwall()

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

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

Definition at line 3066 of file KalFitAlg.cxx.

3066 {
3067
3068 if (debug_ ==4) cout<<"innerwall....."<<endl;
3069 for(int i = 0; i < _BesKalmanFitWalls.size(); i++) {
3070 _BesKalmanFitWalls[i].updateTrack(track, way);
3071 if (debug_ == 4) cout<<"Wall "<<i<<" update the track!(filter)"<<endl;
3072 }
3073}

Referenced by 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 3080 of file KalFitAlg.cxx.

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

Referenced by execute().

◆ kalman_fitting_calib()

void KalFitAlg::kalman_fitting_calib ( void  )

Definition at line 3703 of file KalFitAlg.cxx.

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

Referenced by execute().

◆ kalman_fitting_csmalign()

void KalFitAlg::kalman_fitting_csmalign ( void  )

Definition at line 4781 of file KalFitAlg.cxx.

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

Referenced by execute().

◆ kalman_fitting_MdcxReco_Csmc_Sew()

void KalFitAlg::kalman_fitting_MdcxReco_Csmc_Sew ( void  )

Definition at line 4292 of file KalFitAlg.cxx.

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

Referenced by execute().

◆ sameas()

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

complete the RecMdcKalTrackCol

Definition at line 2256 of file KalFitAlg.cxx.

2257{
2258 // note: for this function,only imain==lead(2) considered
2259 //std::cout<<"BEGINNING THE sameas() function ..."<<std::endl;
2260 trk->setMass(trk->getMass(imain), l_mass);
2261 trk->setLength(trk->getLength(imain), l_mass);
2262 trk->setTof(trk->getTof(imain), l_mass);
2263 trk->setNhits(trk->getNhits(imain), l_mass);
2264
2265 for(int jj = 0; jj<2; jj++) {
2266 trk->setStat(trk->getStat(jj,imain), jj, l_mass);
2267 trk->setChisq(trk->getChisq(jj, l_mass), jj, l_mass);
2268 trk->setNdf(trk->getChisq(jj, l_mass), jj, l_mass);
2269 }
2270 trk->setLHelix(trk->getFHelix(),l_mass);
2271 trk->setLError(trk->getFError(),l_mass);
2272}
int getNhits(int pid) const

◆ set_Mdc()

void KalFitAlg::set_Mdc ( void  )

Set up the wires, layers and superlayers...

Definition at line 114 of file KalFitAlg2.cxx.

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

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 12 of file KalFitReadGdml.cxx.

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

Referenced by initialize().

◆ setCalibSvc_init()

void KalFitAlg::setCalibSvc_init ( void  )

initialize for the services

Definition at line 247 of file KalFitAlg2.cxx.

248 {
249 IMdcCalibFunSvc* imdcCalibSvc;
250 MsgStream log(msgSvc(), name());
251 StatusCode sc = service ("MdcCalibFunSvc", imdcCalibSvc);
252 m_mdcCalibFunSvc_ = dynamic_cast<MdcCalibFunSvc*>(imdcCalibSvc);
253 if ( sc.isFailure() ){
254 log << MSG::FATAL << "Could not load MdcCalibFunSvc!" << endreq;
255 }
256 KalFitTrack::setMdcCalibFunSvc( m_mdcCalibFunSvc_);
257 }
static void setMdcCalibFunSvc(const MdcCalibFunSvc *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 551 of file KalFitAlg.cxx.

552{
553 int layid = 0;
554
555 /// set dchi2cutf_anal
556 for(layid = 0; layid<2; layid++) {
558 }
561 for(layid = 4; layid<12; layid++) {
563 }
564 for(layid = 12; layid<20; layid++) {
566 }
567 for(layid = 20; layid<43; layid++) {
569 }
570
571
572 /// set dchi2cuts_anal
573 for(layid = 0; layid<2; layid++) {
575 }
576
579 for(layid = 4; layid<12; layid++) {
581 }
582 for(layid = 12; layid<20; layid++) {
584 }
585 for(layid = 20; layid<43; layid++) {
587 }
588
589 /// temporary
590 // for(layid = 0; layid<43; layid++) {
591 // KalFitTrack::dchi2cuts_anal[layid] = 10.0;
592 // }
593
594
595 /// set dchi2cutf_calib
596 for(layid = 0; layid<2; layid++) {
598 }
599
602
603 for(layid = 4; layid<12; layid++) {
605 }
606
607 for(layid = 12; layid<20; layid++) {
609 }
610
611 for(layid = 20; layid<43; layid++) {
613 }
614
615 /// temporary
616 if(usage_<2){
617 for(layid = 0; layid<43; layid++) {
618 KalFitTrack::dchi2cutf_calib[layid] = 10.0;
619 }
620 }
621
622
623 /// set dchi2cuts_calib
624 for(layid = 0; layid<2; layid++) {
626 }
627
630
631 for(layid = 4; layid<12; layid++) {
633 }
634
635 for(layid = 12; layid<20; layid++) {
637 }
638
639 for(layid = 20; layid<43; layid++) {
641 }
642
643 /// temporary
644 if(usage_<2){
645 for(layid = 0; layid<43; layid++) {
646 KalFitTrack::dchi2cuts_calib[layid] = 10.0;
647 }
648 }
649}
static double dchi2cuts_anal[43]
Definition: KalFitTrack.h:290
static double dchi2cuts_calib[43]
Definition: KalFitTrack.h:294
static double dchi2cutf_calib[43]
Definition: KalFitTrack.h:292
static double dchi2cutf_anal[43]
Definition: KalFitTrack.h:288

Referenced by initialize().

◆ setGeomSvc_init()

void KalFitAlg::setGeomSvc_init ( void  )

Definition at line 259 of file KalFitAlg2.cxx.

260 {
261 IMdcGeomSvc* imdcGeomSvc;
262 MsgStream log(msgSvc(), name());
263 StatusCode sc = service ("MdcGeomSvc", imdcGeomSvc);
264// m_mdcGeomSvc_ = dynamic_cast<MdcGeomSvc*>(imdcGeomSvc);
265 if ( sc.isFailure() ){
266 log << MSG::FATAL << "Could not load MdcGeomSvc!" << endreq;
267 }
268 imdcGeomSvc_ = imdcGeomSvc;
269
270 KalFitTrack::setIMdcGeomSvc( imdcGeomSvc);
271 }
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 2275 of file KalFitAlg.cxx.

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

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

Referenced by complete_track().

◆ start_seed()

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

Definition at line 5834 of file KalFitAlg.cxx.

5835{
5836 if (debug_ == 4)
5837 cout << "start_seed begin... " << std::endl;
5838 // keep initial helix parameters
5839 Hep3Vector x_init(track.pivot());
5840 HepSymMatrix Ea_init(5,0);
5841 Ea_init = track.Ea();
5842 HepVector a_init(5);
5843 a_init = track.a();
5844
5845 // LR assumption :
5846 unsigned int nhit_included(10);
5847 int LR[8][3] = {
5848 {1,1,1},
5849 {1,1,-1},
5850 {1,-1,1},
5851 {1,-1,-1},
5852 {-1,1,1},
5853 {-1,1,-1},
5854 {-1,-1,1},
5855 {-1,-1,-1}
5856 };
5857
5858 unsigned int nhit = track.HitsMdc().size();
5859 double chi2_min(DBL_MAX);
5860 int i_min(-1);
5861 for (int ktrial = 0; ktrial < 8; ktrial++) {
5862
5863 // Come back to trasan seed :
5864 track.pivot(x_init);
5865 track.a(a_init);
5866 track.Ea(Ea_init);
5867
5868 track.chiSq(0);
5869 track.chiSq_back(0);
5870 track.nchits(0);
5871 track.nster(0);
5872 track.ndf_back(0);
5873
5874 HepSymMatrix Eakal(5,0);
5875
5876 init_matrix(choice_,TrasanTRK, Eakal);
5877 // initialize the Mdc hits :
5878 for( unsigned i=0 ; i < nhit; i++ ){
5879 KalFitHitMdc& HitMdc = track.HitMdc(i);
5880 int lr_decision(0);
5881 if (i<3) lr_decision = LR[ktrial][i];
5882 HitMdc.LR(lr_decision);
5883 if (i<nhit_included)
5884 HitMdc.chi2(0);
5885 else
5886 HitMdc.chi2(-1);
5887 }
5888 // Mdc fit the ... first hits :
5889
5890 if(usage_==0) filter_fwd_anal(track, lead_, way, Eakal);
5891 way=999;
5892 if(usage_>0) filter_fwd_calib(track, lead_, way, Eakal);
5893
5894 // Check the chi2
5895 if (debug_ == 4)
5896 cout << "---- Result for " << ktrial << " case : chi2 = " << track.chiSq()
5897 << ", nhits included = " << track.nchits() << " for nhits available = "
5898 << nhit << std::endl;
5899
5900 if (track.chiSq() < chi2_min &&
5901 (track.nchits() == nhit_included || track.nchits() == nhit)){
5902 chi2_min = track.chiSq();
5903 i_min = ktrial;
5904 }
5905 }
5906
5907 // Initialize to the best solution :
5908 if (debug_ == 4)
5909 cout << "*** i_min = " << i_min << " with a chi2 = " << chi2_min << std::endl;
5910
5911 for( unsigned i=0 ; i < nhit; i++ ){
5912 KalFitHitMdc& HitMdc = track.HitMdc(i);
5913 int lr_decision(0);
5914 if (i_min >= 0 && i < 3)
5915 lr_decision = LR[i_min][i];
5916 HitMdc.LR(lr_decision);
5917 HitMdc.chi2(0);
5918 HitMdc.chi2_back(0);
5919 }
5920 track.pivot(x_init);
5921 track.a(a_init);
5922 track.Ea(Ea_init);
5923 track.chiSq(0);
5924 track.chiSq_back(0);
5925 track.nchits(0);
5926 track.nster(0);
5927 track.ndf_back(0);
5928
5929 // For debugging purpose :
5930 if (debug_ == 4) {
5931 for( unsigned i=0 ; i < 3; i++ ){
5932 KalFitHitMdc& HitMdc = track.HitMdc(i);
5933 cout << " LR(" << i << ") = " << HitMdc.LR()
5934 << ", stereo = " << HitMdc.wire().stereo()
5935 << ", layer = " << HitMdc.wire().layer().layerId() << std::endl;
5936 }
5937 }
5938}
double chi2_back(void) const
Definition: KalFitHitMdc.h:31
KalFitHitMdc & HitMdc(int i)
Definition: KalFitTrack.h:230

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 194 of file KalFitAlg.h.

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

◆ back_

int KalFitAlg::back_

flag to perform smoothing

Definition at line 176 of file KalFitAlg.h.

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

◆ choice_

◆ cylfile_

string KalFitAlg::cylfile_

Definition at line 218 of file KalFitAlg.h.

Referenced by KalFitAlg().

◆ dchi2cut_inner_

double KalFitAlg::dchi2cut_inner_

Definition at line 222 of file KalFitAlg.h.

Referenced by KalFitAlg(), and setDchisqCut().

◆ dchi2cut_layid2_

double KalFitAlg::dchi2cut_layid2_

Definition at line 222 of file KalFitAlg.h.

Referenced by KalFitAlg(), and setDchisqCut().

◆ dchi2cut_layid3_

double KalFitAlg::dchi2cut_layid3_

Definition at line 222 of file KalFitAlg.h.

Referenced by KalFitAlg(), and setDchisqCut().

◆ dchi2cut_mid1_

double KalFitAlg::dchi2cut_mid1_

Definition at line 222 of file KalFitAlg.h.

Referenced by KalFitAlg(), and setDchisqCut().

◆ dchi2cut_mid2_

double KalFitAlg::dchi2cut_mid2_

Definition at line 222 of file KalFitAlg.h.

Referenced by KalFitAlg(), and setDchisqCut().

◆ dchi2cut_outer_

double KalFitAlg::dchi2cut_outer_

Definition at line 222 of file KalFitAlg.h.

Referenced by KalFitAlg(), and setDchisqCut().

◆ dchi2cutf_

double KalFitAlg::dchi2cutf_

Definition at line 220 of file KalFitAlg.h.

Referenced by initialize(), and KalFitAlg().

◆ dchi2cuts_

double KalFitAlg::dchi2cuts_

Definition at line 220 of file KalFitAlg.h.

Referenced by initialize(), and KalFitAlg().

◆ debug_

◆ debug_kft_

int KalFitAlg::debug_kft_

Definition at line 214 of file KalFitAlg.h.

Referenced by initialize(), and KalFitAlg().

◆ drifttime_choice_

int KalFitAlg::drifttime_choice_

Definition at line 209 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 196 of file KalFitAlg.h.

Referenced by complete_track().

◆ eventno

int KalFitAlg::eventno

Definition at line 178 of file KalFitAlg.h.

◆ eventNo

int KalFitAlg::eventNo

Definition at line 232 of file KalFitAlg.h.

Referenced by execute(), and fillTds_back().

◆ fac_h1_

double KalFitAlg::fac_h1_

Definition at line 197 of file KalFitAlg.h.

Referenced by complete_track().

◆ fac_h2_

double KalFitAlg::fac_h2_

Definition at line 197 of file KalFitAlg.h.

Referenced by complete_track().

◆ fac_h3_

double KalFitAlg::fac_h3_

Definition at line 197 of file KalFitAlg.h.

Referenced by complete_track().

◆ fac_h4_

double KalFitAlg::fac_h4_

Definition at line 197 of file KalFitAlg.h.

Referenced by complete_track().

◆ fac_h5_

double KalFitAlg::fac_h5_

Definition at line 197 of file KalFitAlg.h.

Referenced by complete_track().

◆ fitnocut_

int KalFitAlg::fitnocut_

Definition at line 207 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 225 of file KalFitAlg.h.

Referenced by initialize(), and KalFitAlg().

◆ gain1_

double KalFitAlg::gain1_

Definition at line 199 of file KalFitAlg.h.

Referenced by init_matrix(), and KalFitAlg().

◆ gain2_

double KalFitAlg::gain2_

Definition at line 199 of file KalFitAlg.h.

Referenced by init_matrix(), and KalFitAlg().

◆ gain3_

double KalFitAlg::gain3_

Definition at line 199 of file KalFitAlg.h.

Referenced by init_matrix(), and KalFitAlg().

◆ gain4_

double KalFitAlg::gain4_

Definition at line 199 of file KalFitAlg.h.

Referenced by init_matrix(), and KalFitAlg().

◆ gain5_

double KalFitAlg::gain5_

Definition at line 199 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 211 of file KalFitAlg.h.

Referenced by complete_track(), and KalFitAlg().

◆ i_front_

int KalFitAlg::i_front_

Definition at line 212 of file KalFitAlg.h.

Referenced by complete_track(), and KalFitAlg().

◆ inner_steps_

int KalFitAlg::inner_steps_

Definition at line 203 of file KalFitAlg.h.

Referenced by initialize(), and KalFitAlg().

◆ iqual_back_

int KalFitAlg::iqual_back_

Definition at line 228 of file KalFitAlg.h.

Referenced by execute(), and fillTds_back().

◆ iqual_front_

int KalFitAlg::iqual_front_[5]

Definition at line 228 of file KalFitAlg.h.

Referenced by execute(), fillTds_back(), fillTds_ip(), fillTds_lead(), and kalman_fitting_anal().

◆ lead_

◆ loss_

int KalFitAlg::loss_

Definition at line 194 of file KalFitAlg.h.

Referenced by initialize(), and KalFitAlg().

◆ lr_

int KalFitAlg::lr_

Definition at line 194 of file KalFitAlg.h.

Referenced by initialize(), and KalFitAlg().

◆ m_csmflag

int KalFitAlg::m_csmflag

◆ m_dangcut

double KalFitAlg::m_dangcut

Definition at line 235 of file KalFitAlg.h.

Referenced by execute(), and KalFitAlg().

◆ m_dphicut

double KalFitAlg::m_dphicut

Definition at line 235 of file KalFitAlg.h.

Referenced by execute(), and KalFitAlg().

◆ m_usevtxdb

int KalFitAlg::m_usevtxdb

Definition at line 233 of file KalFitAlg.h.

Referenced by KalFitAlg(), and smoother_anal().

◆ matfile_

string KalFitAlg::matfile_

Definition at line 218 of file KalFitAlg.h.

Referenced by KalFitAlg().

◆ matrixg_

◆ mhyp_

int KalFitAlg::mhyp_

Definition at line 186 of file KalFitAlg.h.

Referenced by complete_track(), and initialize().

◆ 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 194 of file KalFitAlg.h.

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

◆ ntuple_

◆ numf_

int KalFitAlg::numf_

Definition at line 202 of file KalFitAlg.h.

Referenced by initialize(), and KalFitAlg().

◆ numf_in_

int KalFitAlg::numf_in_

Definition at line 205 of file KalFitAlg.h.

◆ numf_out_

int KalFitAlg::numf_out_

Definition at line 206 of file KalFitAlg.h.

◆ numfcor_

int KalFitAlg::numfcor_

Definition at line 201 of file KalFitAlg.h.

Referenced by initialize(), and KalFitAlg().

◆ outer_steps_

int KalFitAlg::outer_steps_

Definition at line 204 of file KalFitAlg.h.

Referenced by initialize(), and KalFitAlg().

◆ pathl_

int KalFitAlg::pathl_

Definition at line 172 of file KalFitAlg.h.

Referenced by fillTds_back(), initialize(), smoother_anal(), and smoother_calib().

◆ pe_cut_

double KalFitAlg::pe_cut_

value of the momentum cut to decide refit

Definition at line 188 of file KalFitAlg.h.

Referenced by complete_track(), and KalFitAlg().

◆ pk_cut_

double KalFitAlg::pk_cut_

Definition at line 188 of file KalFitAlg.h.

Referenced by complete_track(), and KalFitAlg().

◆ pmu_cut_

double KalFitAlg::pmu_cut_

Definition at line 188 of file KalFitAlg.h.

Referenced by complete_track(), and KalFitAlg().

◆ pp_cut_

double KalFitAlg::pp_cut_

Definition at line 188 of file KalFitAlg.h.

Referenced by complete_track(), and KalFitAlg().

◆ ppi_cut_

double KalFitAlg::ppi_cut_

Definition at line 188 of file KalFitAlg.h.

Referenced by complete_track(), and KalFitAlg().

◆ pT_

double KalFitAlg::pT_

value of the pT cut for backward filter

Definition at line 182 of file KalFitAlg.h.

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

◆ pt_cut_

◆ resolution_

int KalFitAlg::resolution_

Definition at line 227 of file KalFitAlg.h.

Referenced by initialize(), and KalFitAlg().

◆ steplev_

int KalFitAlg::steplev_

Definition at line 200 of file KalFitAlg.h.

Referenced by initialize(), and KalFitAlg().

◆ Tds_back_no

int KalFitAlg::Tds_back_no

Definition at line 180 of file KalFitAlg.h.

◆ theta_cut_

◆ tof_hyp_

int KalFitAlg::tof_hyp_

Definition at line 194 of file KalFitAlg.h.

Referenced by initialize(), and KalFitAlg().

◆ tofflag_

int KalFitAlg::tofflag_

Definition at line 194 of file KalFitAlg.h.

Referenced by initialize(), and KalFitAlg().

◆ tprop_

int KalFitAlg::tprop_

propagation correction

Definition at line 231 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 168 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 174 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: