CGEM BOSS 6.6.5.i
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 myEventNo
 
int m_usevtxdb
 
int m_csmflag
 
double m_dangcut
 
double m_dphicut
 
double m_alpha
 
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 innerwall (KalFitTrack &trk, int l_mass, int way, int begin, int end)
 
void innerwall (KalFitTrack &track, int l_mass, int way, double r1, double r2, int &index)
 
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)
 
void makeGemHitsCol ()
 
void fromFHitToInnerWall (KalFitTrack &track, int way)
 
void fitGemHits (KalFitTrack &track, int hypo, int way)
 
KalFitTrack Cgem_filter_anal (KalFitTrack &track, int hypo, int way)
 
void residual (KalFitTrack &track)
 

Detailed Description

Definition at line 61 of file KalFitAlg.h.

Constructor & Destructor Documentation

◆ KalFitAlg()

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

constructor

Constructor.

Definition at line 99 of file KalFitAlg.cxx.

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

◆ ~KalFitAlg()

KalFitAlg::~KalFitAlg ( void )

destructor

Definition at line 182 of file KalFitAlg.cxx.

183{
184 MsgStream log(msgSvc(), name());
185 log << MSG::INFO <<" Start cleaning, delete Mdc geometry objects" << endreq;
186 clean();
187 log << MSG::INFO << "End cleaning " << endreq;
188}
IMessageSvc * msgSvc()
void clean(void)

Member Function Documentation

◆ beginRun()

StatusCode KalFitAlg::beginRun ( )

Definition at line 342 of file KalFitAlg.cxx.

343{
344 MsgStream log(msgSvc(), name());
345 log << MSG::INFO << "in beginRun()" << endreq;
346 log << MSG::INFO << "Present Parameters: muls: " << muls_ <<" loss: "
347 << " activeonly "<< activeonly_ << endreq;
348
349 // initialize the MdcGeomSvc
351 // Wires, Layers and SuperLayers of Mdc :
352 set_Mdc();
353
354 IMagneticFieldSvc* IMFSvc;
355 StatusCode sc = service ("MagneticFieldSvc",IMFSvc);
356 if(sc!=StatusCode::SUCCESS) {
357 log << MSG::ERROR << "Unable to open Magnetic field service"<<endreq;
358 }
359
360 // Nominal magnetic field :
362 KalFitTrack::Bznom_ = (IMFSvc->getReferField())*10000; //unit is KGauss
364
365 if(4 == debug_){
366 std::cout<<" beginRun, referField from MagneticFieldSvc:"<< (IMFSvc->getReferField())*10000 <<std::endl;
367 std::cout<<" magnetic field: "<<KalFitTrack::Bznom_<<std::endl;
368 }
369 }
370
371 return StatusCode::SUCCESS;
372}
virtual double getReferField()=0
void setGeomSvc_init(void)
void set_Mdc(void)
Set up the wires, layers and superlayers...
static double Bznom_
static int numfcor_
NUMF treatment improved.

◆ Cgem_filter_anal()

KalFitTrack KalFitAlg::Cgem_filter_anal ( KalFitTrack & track,
int hypo,
int way )

—readin clusters of this track

—set the start and stop point of fit

—update track

Definition at line 7783 of file KalFitAlg.cxx.

7784{
7785
7786 ///---readin clusters of this track
7787 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
7788 if (!eventHeader) {
7789 cout << "Could not find Event Header" << endl;
7790 }
7791 int eventNo = eventHeader->eventNumber();
7792 int runNo = eventHeader->runNumber();
7793 SmartDataPtr<RecMdcTrackCol> recMdcTrack(eventSvc(),"/Event/Recon/RecMdcTrackCol");
7794 if (!recMdcTrack) {
7795 cout << "Could not find RecMdcTrackCol" << endl;
7796 }
7797 RecMdcTrackCol::iterator itrk = recMdcTrack->begin();
7798 ClusterRefVec clusterRefVec;
7799 for(; itrk != recMdcTrack->end(); itrk++){
7800 if((*itrk)->trackId() == track.trasan_id() && (*itrk)->getNcluster() > 0) {
7801 clusterRefVec = (*itrk)->getVecClusters();
7802 break;
7803 }
7804 else {
7805 if(4 == debug_) cout<<"run:"<<runNo<<" , Event:"<<eventNo<<" , track:"<<track.trasan_id()<<" has no cluster!"<<endl;
7806 }
7807 }
7808
7809 if(debug_==4){ cout<<"wall size"<<_BesKalmanFitWalls.size()<<endl;}
7810
7811 ///---set the start and stop point of fit
7812 ClusterRefVec::iterator itCluster;
7813 ClusterRefVec::iterator itStartFlag;
7814 ClusterRefVec::iterator itStopFlag;
7815 int step;
7816 int index=0;
7817 double lastR;
7818 double R_o_cgem=_BesKalmanFitWalls[0].radius();
7819 if(way<0){
7820 itStartFlag = clusterRefVec.begin();
7821 itStopFlag = clusterRefVec.end();
7822 lastR=0;
7823 step = 1;
7824 }
7825 else {
7826 itStartFlag = clusterRefVec.end()-1;
7827 itStopFlag = clusterRefVec.begin()-1;
7828 lastR=R_o_cgem;
7829 step = -1;
7830 double pathl;
7831 track.pivot_numf(track.x(track.intersect_cylinder(R_o_cgem)),pathl);
7832 if(KalFitElement::muls()) track.msgasmdc(pathl, way);
7833 if(KalFitElement::loss()) track.eloss(pathl, _BesKalmanFitMaterials[0], way);
7834 }
7835
7836 ///---update track
7837 for(itCluster = itStartFlag; itCluster !=itStopFlag; itCluster = itCluster + step){
7838 int layer = (*itCluster)->getlayerid();
7839 CgemGeoLayer* CgemLayer = m_CgemGeomSvc_->getCgemLayer(layer);
7840 double dmR = CgemLayer->getMiddleROfGapD()/10;
7841 innerwall(track,hypo,way,lastR,dmR,index);
7842 lastR=dmR;
7843 double dchi2(0);
7844 //track.update_hits(*itCluster, dmR, way, m_csmflag);
7845 dchi2 = track.update_hits(*itCluster, dmR, way, m_csmflag);
7846 if (ntuple_&256 && way>0) {
7847
7848 //cout<<"cgem: "<<m_hit_no<<endl;
7849 m_nCluster++;
7850 if(hypo == 0){
7851 m_dchi2_hit_e[m_hit_no] = dchi2;
7852 m_residest_hit_e[m_hit_no] = 0;
7853 m_residnew_hit_e[m_hit_no] = 0;
7854 m_layer_hit_e[m_hit_no] = layer;
7855 KalmanFit::Helix worktemp = *(KalmanFit::Helix*)&track;
7856 m_anal_dr_hit_e[m_hit_no] = worktemp.a()[0];
7857 m_anal_phi0_hit_e[m_hit_no] = worktemp.a()[1];
7858 m_anal_kappa_hit_e[m_hit_no] = worktemp.a()[2];
7859 m_anal_dz_hit_e[m_hit_no] = worktemp.a()[3];
7860 m_anal_tanl_hit_e[m_hit_no] = worktemp.a()[4];
7861 m_anal_ea_dr_hit_e[m_hit_no] = worktemp.Ea()[0][0];
7862 m_anal_ea_phi0_hit_e[m_hit_no] = worktemp.Ea()[1][1];
7863 m_anal_ea_kappa_hit_e[m_hit_no] = worktemp.Ea()[2][2];
7864 m_anal_ea_dz_hit_e[m_hit_no] = worktemp.Ea()[3][3];
7865 m_anal_ea_tanl_hit_e[m_hit_no] = worktemp.Ea()[4][4];
7866 }
7867
7868
7869 else if(hypo == 1){
7870 m_dchi2_hit_mu[m_hit_no] = dchi2;
7871 m_residest_hit_mu[m_hit_no] = 0;
7872 m_residnew_hit_mu[m_hit_no] = 0;
7873 m_layer_hit_mu[m_hit_no] = layer;
7874 KalmanFit::Helix worktemp = *(KalmanFit::Helix*)&track;
7875 m_anal_dr_hit_mu[m_hit_no] = worktemp.a()[0];
7876 m_anal_phi0_hit_mu[m_hit_no] = worktemp.a()[1];
7877 m_anal_kappa_hit_mu[m_hit_no] = worktemp.a()[2];
7878 m_anal_dz_hit_mu[m_hit_no] = worktemp.a()[3];
7879 m_anal_tanl_hit_mu[m_hit_no] = worktemp.a()[4];
7880 m_anal_ea_dr_hit_mu[m_hit_no] = worktemp.Ea()[0][0];
7881 m_anal_ea_phi0_hit_mu[m_hit_no] = worktemp.Ea()[1][1];
7882 m_anal_ea_kappa_hit_mu[m_hit_no] = worktemp.Ea()[2][2];
7883 m_anal_ea_dz_hit_mu[m_hit_no] = worktemp.Ea()[3][3];
7884 m_anal_ea_tanl_hit_mu[m_hit_no] = worktemp.Ea()[4][4];
7885 }
7886
7887
7888
7889 else if(hypo == 2){
7890 m_dchi2_hit_pi[m_hit_no] = dchi2;
7891 m_residest_hit_pi[m_hit_no] = 0;
7892 m_residnew_hit_pi[m_hit_no] = 0;
7893 m_layer_hit_pi[m_hit_no] = layer;
7894 KalmanFit::Helix worktemp = *(KalmanFit::Helix*)&track;
7895 m_anal_dr_hit_pi[m_hit_no] = worktemp.a()[0];
7896 m_anal_phi0_hit_pi[m_hit_no] = worktemp.a()[1];
7897 m_anal_kappa_hit_pi[m_hit_no] = worktemp.a()[2];
7898 m_anal_dz_hit_pi[m_hit_no] = worktemp.a()[3];
7899 m_anal_tanl_hit_pi[m_hit_no] = worktemp.a()[4];
7900 m_anal_ea_dr_hit_pi[m_hit_no] = worktemp.Ea()[0][0];
7901 m_anal_ea_phi0_hit_pi[m_hit_no] = worktemp.Ea()[1][1];
7902 m_anal_ea_kappa_hit_pi[m_hit_no] = worktemp.Ea()[2][2];
7903 m_anal_ea_dz_hit_pi[m_hit_no] = worktemp.Ea()[3][3];
7904 m_anal_ea_tanl_hit_pi[m_hit_no] = worktemp.Ea()[4][4];
7905 }
7906
7907
7908 else if(hypo == 3){
7909 m_dchi2_hit_k[m_hit_no] = dchi2;
7910 m_residest_hit_k[m_hit_no] = 0;
7911 m_residnew_hit_k[m_hit_no] = 0;
7912 m_layer_hit_k[m_hit_no] = layer;
7913 KalmanFit::Helix worktemp = *(KalmanFit::Helix*)&track;
7914 m_anal_dr_hit_k[m_hit_no] = worktemp.a()[0];
7915 m_anal_phi0_hit_k[m_hit_no] = worktemp.a()[1];
7916 m_anal_kappa_hit_k[m_hit_no] = worktemp.a()[2];
7917 m_anal_dz_hit_k[m_hit_no] = worktemp.a()[3];
7918 m_anal_tanl_hit_k[m_hit_no] = worktemp.a()[4];
7919 m_anal_ea_dr_hit_k[m_hit_no] = worktemp.Ea()[0][0];
7920 m_anal_ea_phi0_hit_k[m_hit_no] = worktemp.Ea()[1][1];
7921 m_anal_ea_kappa_hit_k[m_hit_no] = worktemp.Ea()[2][2];
7922 m_anal_ea_dz_hit_k[m_hit_no] = worktemp.Ea()[3][3];
7923 m_anal_ea_tanl_hit_k[m_hit_no] = worktemp.Ea()[4][4];
7924 }
7925
7926
7927 else if(hypo == 4){
7928 m_dchi2_hit_p[m_hit_no] = dchi2;
7929 m_residest_hit_p[m_hit_no] = 0;
7930 m_residnew_hit_p[m_hit_no] = 0;
7931 m_layer_hit_p[m_hit_no] = layer;
7932 KalmanFit::Helix worktemp = *(KalmanFit::Helix*)&track;
7933 m_anal_dr_hit_p[m_hit_no] = worktemp.a()[0];
7934 m_anal_phi0_hit_p[m_hit_no] = worktemp.a()[1];
7935 m_anal_kappa_hit_p[m_hit_no] = worktemp.a()[2];
7936 m_anal_dz_hit_p[m_hit_no] = worktemp.a()[3];
7937 m_anal_tanl_hit_p[m_hit_no] = worktemp.a()[4];
7938 m_anal_ea_dr_hit_p[m_hit_no] = worktemp.Ea()[0][0];
7939 m_anal_ea_phi0_hit_p[m_hit_no] = worktemp.Ea()[1][1];
7940 m_anal_ea_kappa_hit_p[m_hit_no] = worktemp.Ea()[2][2];
7941 m_anal_ea_dz_hit_p[m_hit_no] = worktemp.Ea()[3][3];
7942 m_anal_ea_tanl_hit_p[m_hit_no] = worktemp.Ea()[4][4];
7943 }
7944
7945 m_hit_no++;
7946 }
7947 }// loop clusters
7948 KalFitTrack track_first(track);
7949 if(way<0){
7950 innerwall(track,hypo,way,lastR,R_o_cgem,index);
7951 }
7952 else
7953 {
7954 innerwall(track,hypo,way,lastR,0,index);
7955 }
7956
7957 return track_first;
7958}
int runNo
int eventNo
SmartRefVector< RecCgemCluster > ClusterRefVec
Definition RecMdcTrack.h:28
double getMiddleROfGapD() const
CgemGeoLayer * getCgemLayer(int i) const
Definition CgemGeomSvc.h:48
void innerwall(KalFitTrack &trk, int l_mass, int way)
Take the inner walls (eloss and mult scat) into account.
static int muls(void)
static int loss(void)
Description of a track class (<- Helix.cc)
Definition KalFitTrack.h:36
int trasan_id(void) const
const HepPoint3D & pivot_numf(const HepPoint3D &newPivot)
Sets pivot position in a given mag field.
double intersect_cylinder(double r) const
Intersection with different geometry.
void msgasmdc(double path, int index)
Calculate multiple scattering angle.
void eloss(double path, const KalFitMaterial &m, int index)
Calculate total energy lost in material.
double update_hits(KalFitHitMdc &HitMdc, int inext, CLHEP::Hep3Vector &meas, int way, double &dchi2, double &dtrack, double &dtracknew, double &dtdc, int csmflag)
Include the Mdc wire hits.
const HepSymMatrix & Ea(void) const
returns error matrix.
HepPoint3D x(double dPhi=0.) const
returns position after rotating angle dPhi in phi direction.
const HepVector & a(void) const
returns helix parameters.

Referenced by complete_track().

◆ clean()

void KalFitAlg::clean ( void )

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

Definition at line 190 of file KalFitAlg.cxx.

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

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

◆ clearTables()

void KalFitAlg::clearTables ( )

Definition at line 6761 of file KalFitAlg.cxx.

6761 {
6762
6763 if(debug_ == 4) cout<<"Begining to clear Tables ...."<<endl;
6764 vector<MdcRec_trk>* mdcMgr = MdcRecTrkCol::getMdcRecTrkCol();
6765 vector<MdcRec_trk_add>* mdc_addMgr = MdcRecTrkAddCol::getMdcRecTrkAddCol();
6766 vector<MdcRec_wirhit>* whMgr = MdcRecWirhitCol::getMdcRecWirhitCol();
6767 vector<MdcRec_trk>::iterator tit=mdcMgr->begin();
6768 for( ; tit != mdcMgr->end(); tit++) {
6769 vector<MdcRec_wirhit*>::iterator vit= tit->hitcol.begin() ;
6770 for(; vit != tit->hitcol.end(); vit++) {
6771 delete (*vit);
6772 }
6773 }
6774
6775 mdcMgr->clear();
6776 mdc_addMgr->clear();
6777 whMgr->clear();
6778
6779 // delete mdcMgr;
6780 // delete mdc_addMgr;
6781 // delete whMgr;
6782 // mdcMgr = 0;
6783 // mdc_addMgr = 0;
6784 // whMgr = 0;
6785
6786}
static vector< MdcRec_trk_add > * getMdcRecTrkAddCol(void)
static vector< MdcRec_trk > * getMdcRecTrkCol(void)
static vector< MdcRec_wirhit > * getMdcRecWirhitCol(void)

Referenced by execute().

◆ complete_track() [1/2]

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

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

Definition at line 6345 of file KalFitAlg.cxx.

6350{
6351 static int nmass = KalFitTrack::nmass();
6352 int way(1);
6353 MsgStream log(msgSvc(), name());
6354 KalFitTrack track_first(track_lead);
6355 KalFitTrack track_ip(track_lead);
6356
6357 if (debug_ == 4){
6358 cout << "track_first pivot "<<track_first.pivot()<< " helix "<<track_first.a()<<endl;
6359 }
6360 if(usage_==1) innerwall(track_ip, lead_, way);
6361 // Fill Tds
6362 fillTds_ip(TrasanTRK, track_ip, kaltrk, lead_);
6363
6364 if (debug_ == 4) {
6365 cout << "after inner wall, track_ip pivot "<<track_first.pivot()<< " helix "<<track_first.a()<<endl;
6366 }
6367
6368 fillTds_lead(TrasanTRK, track_first, kaltrk, lead_);
6369
6370 // Refit for different mass assumptions :
6371 double pp = track_lead.momentum().mag();
6372
6373 //w if (!KalFitDSSD::cosmic_)
6374 if(!(i_front_<0)){
6375
6376 for(int l_mass = 0, flg = 1; l_mass < nmass;
6377 l_mass++, flg <<= 1) {
6378
6379 if (!(mhyp_ & flg)) continue;
6380 if (l_mass == lead_) continue;
6381
6382 // Check the mom. to decide of the refit with this mass assumption
6383 if ((lead_ != 0 && l_mass==0 && pp > pe_cut_) ||
6384 (lead_ != 1 && l_mass==1 && pp > pmu_cut_) ||
6385 (lead_ != 2 && l_mass==2 && pp > ppi_cut_) ||
6386 (lead_ != 3 && l_mass==3 && pp > pk_cut_) ||
6387 (lead_ != 4 && l_mass==4 && pp > pp_cut_))
6388 continue;
6389
6390 if(debug_ == 4) {
6391 cout<<"complete_track..REFIT ASSUMPION " << l_mass << endl;
6392 }
6393
6394 // Initialisation :
6395 double chiSq = 0;
6396 int nhits = 0;
6397
6398 // Initialisation : (x, a, ea)
6399 HepPoint3D x_trasan(TrasanTRK.pivot[0],
6400 TrasanTRK.pivot[1],
6401 TrasanTRK.pivot[2]);
6402
6403 HepVector a_trasan(5);
6404 for(int i = 0; i < 5; i++){
6405 a_trasan[i] = TrasanTRK.helix[i];
6406 }
6407
6408 HepSymMatrix ea_trasan(5);
6409 for(int i = 0, k = 0; i < 5; i++) {
6410 for(int j = 0; j <= i; j++) {
6411 ea_trasan[i][j] = matrixg_*TrasanTRK.error[k++];
6412 ea_trasan[j][i] = ea_trasan[i][j];
6413 }
6414 }
6415
6416 KalFitTrack track(x_trasan,a_trasan, ea_trasan, l_mass, chiSq, nhits);
6417 track.HitsMdc(track_lead.HitsMdc());
6418
6419 double fiTerm = TrasanTRK.fiTerm;
6420 track.pivot(track.x(fiTerm));
6421
6422 HepSymMatrix Eakal(5,0);
6423
6424 double costheta = track_lead.a()[4] / sqrt(1.0 + track_lead.a()[4]*track_lead.a()[4]);
6425 if( (1.0/fabs(track_lead.a()[2]) < pt_cut_ ) && (fabs(costheta)> theta_cut_) ) {
6426 choice_ = 6;
6427 }
6428
6429 init_matrix(choice_, TrasanTRK, Eakal);
6430
6431 filter_fwd_calib(track, l_mass, way, Eakal);
6432
6433 KalFitTrack track_z(track);
6434 ///fill tds with results got at (0,0,0)
6435 innerwall(track_z, l_mass, way);
6436 fillTds_ip(TrasanTRK, track_z, kaltrk, l_mass);
6437 // Fill tds
6438 fillTds(TrasanTRK, track, kaltrk, l_mass);
6439 }
6440 } //end of if (!(i_front<0))
6441
6442 // Refit with an enhancement of the error matrix at Mdc level :
6443
6444 if (enhance_) {
6445 HepPoint3D x_first(0, 0, 0);
6446 HepVector a_first(kaltrk->getFHelix());
6447 HepSymMatrix ea_first(kaltrk->getFError());
6448 HepVector fac(5);
6449 fac[0]=fac_h1_; fac[1]=fac_h2_; fac[2]=fac_h3_; fac[3]=fac_h4_; fac[4]=fac_h5_;
6450
6451 for(int i = 0; i < 5; i++)
6452 for(int j = 0; j <= i; j++)
6453 ea_first[i][j] = fac[i]*fac[j]*ea_first[i][j];
6454 KalFitTrack track(x_first, a_first, ea_first, 2, 0, 0);
6455 }
6456
6457 // Backward filter
6458 // Attention, the initial error matrix of track_back is the error matrix
6459 // that after filter_fwd_calib(...) course of track_lead. So one thing need
6460 // more consideration that how to chose the inital error matrix of this smoother,
6461 // to put it by hand or use the error matrix after filter_fwd_calib. I think
6462 // it should be to refer R.G.Brown's book.
6463
6464 KalFitTrack track_back(track_lead);
6465
6466 //track_back(track);
6467
6468
6469 if (debug_ == 4) {
6470 cout << " Backward fitting flag:" << back_<< endl;
6471 cout << "track_back pivot " << track_back.pivot()
6472 << " track_lead kappa " << track_lead.a()[2]
6473 <<endl;
6474 }
6475
6476 if (back_ && track_lead.a()[2] != 0 &&
6477 1/fabs(track_lead.a()[2]) > pT_) {
6478 track_back.HitsMdc(track_lead.HitsMdc());
6479
6481
6482 double p_kaon(0), p_proton(0);
6483
6484 if (!(kaltrk->getStat(0,3))) {
6485 p_kaon = 1 / fabs(kaltrk->getZHelixK()[2]) *
6486 sqrt(1 + kaltrk->getZHelixK()[4]*kaltrk->getZHelixK()[4]);
6487 track_back.p_kaon(p_kaon);
6488 } else {
6489 p_kaon = 1 / fabs(track_back.a()[2]) *
6490 sqrt(1 + track_back.a()[4]*track_back.a()[4]);
6491 track_back.p_kaon(p_kaon);
6492 }
6493 if (!(kaltrk->getStat(0,4))) {
6494 p_proton = 1 / fabs(kaltrk->getZHelixP()[2]) *
6495 sqrt(1 + kaltrk->getZHelixP()[4]*kaltrk->getZHelixP()[4]);
6496 track_back.p_proton(p_proton);
6497 } else {
6498 p_proton = 1 / fabs(track_back.a()[2]) *
6499 sqrt(1 + track_back.a()[4]*track_back.a()[4]);
6500 track_back.p_proton(p_proton);
6501 }
6502
6503 }
6504
6505
6506 if (!(i_back_<0)) {
6507 for(int l_mass = 0; l_mass < nmass; l_mass++) {
6508 KalFitTrack track_seed(track_back);
6509 track_seed.chgmass(l_mass);
6510 smoother_calib(track_seed, -way);
6511 // fill TDS for backward filter :
6512 fillTds_back(track_seed, kaltrk, TrasanTRK, l_mass,segcol);
6513 }
6514 } else {
6515
6516 smoother_calib(track_back, -way);
6517 // fill TDS for backward filter , for leading particle hypothesis :
6518 fillTds_back(track_back, kaltrk, TrasanTRK, lead_,segcol);
6519 // fillTds_helixsegs(track_back,TrasanTRK);
6520 }
6521 }
6522
6523 /*
6524 // Take care of the pointers (use lead. hyp results by default)
6525 for(int pid = 0; pid < nmass;
6526 pid++) {
6527 if (pid == lead_) continue;
6528 if (kaltrk->getStat(1,pid))
6529 sameas(kaltrk, pid, lead_);
6530 }
6531 */
6532
6533 //check: before register into TDS
6534
6535 log << MSG::DEBUG << "registered MDC Kalmantrack:"
6536 << "Track Id: " << kaltrk->getTrackId()
6537 << " Mass of the fit: "<< kaltrk->getMass(2)<< endreq
6538 << "Length of the track: "<< kaltrk->getLength(2)
6539 << " Tof of the track: "<< kaltrk->getTof(2) << endreq
6540 << "Chisq of the fit: "<< kaltrk->getChisq(0,2)
6541 <<" "<< kaltrk->getChisq(1,2) << endreq
6542 << "Ndf of the fit: "<< kaltrk->getNdf(0,2)
6543 <<" "<< kaltrk->getNdf(1,2) << endreq
6544 << "Helix " << kaltrk->getZHelix()[2]
6545 <<endreq;
6546
6547 kalcol->push_back(kaltrk);
6548 track_lead.HitsMdc().clear();
6549 track_back.HelixSegs().clear();
6550 // ??ATTENTION!! should track_back.HelixSegs() be cleared ??
6551}
void filter_fwd_calib(KalFitTrack &trk, int l_mass, int way, HepSymMatrix &Eakal)
void fillTds_lead(MdcRec_trk &TrasanTRK, KalFitTrack &track, RecMdcKalTrack *trk, int l_mass)
void fillTds_ip(MdcRec_trk &TrasanTRK, KalFitTrack &track, RecMdcKalTrack *trk, int l_mass)
with results got at (0,0,0)
void fillTds(MdcRec_trk &TrasanTRK, KalFitTrack &track, RecMdcKalTrack *trk, int l_mass)
with results got at the inner Mdc hit
void smoother_calib(KalFitTrack &trk, int way)
void init_matrix(MdcRec_trk &trk, HepSymMatrix &Ea)
void fillTds_back(KalFitTrack &track, RecMdcKalTrack *trk, MdcRec_trk &TrasanTRK, int l_mass)
with results got at the outer Mdc hit
static int nmass(void)
static int tofall_
void HitsMdc(vector< KalFitHitMdc > &lh)
Hep3Vector momentum(double dPhi=0.) const
returns momentum vector after rotating angle dPhi in phi direction.
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

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

6135{
6136 static int nmass = KalFitTrack::nmass();
6137 int way(1);
6138 MsgStream log(msgSvc(), name());
6139 KalFitTrack track_ip(track_lead);
6140 //fromFHitToInnerWall(track_lead, way);
6141 // cout << "m_esti" << m_esti1_r[0] << endl;
6142 //cout<<"fitGemHits for pion"<<endl;
6143 //if(useNCGem_>0) fitGemHits(track_lead, lead_, way);
6144 if(useNCGem_>0) track_lead=Cgem_filter_anal(track_ip, lead_, way);
6145 else if(useNCGem_==0) innerwall(track_ip, lead_, way);
6146 KalFitTrack track_first(track_lead);
6147 //cout<<"__FUNCTION__: track_lead.nLayerUsed = "<<track_lead.nLayerUsed()<<endl;
6148 //cout<<"__FUNCTION__: track_ip.nLayerUsed = "<<track_ip.nLayerUsed()<<endl;
6149 //innerwall(track_ip, lead_, way,95,99);
6150 // Fill Tds
6151 fillTds_ip(TrasanTRK, track_ip, kaltrk, lead_);
6152 // std::cout<<"track_first nster"<<track_first.nster()<<std::endl;
6153
6154 //fillTds_lead(TrasanTRK, track_first, kaltrk, lead_);
6155 fillTds(TrasanTRK, track_first, kaltrk, lead_);
6156 // Refit for different mass assumptions :
6157 double pp = track_lead.momentum().mag();
6158
6159 if(!(i_front_<0)){
6160 //cout << "!!!!i_front" << i_front_<< endl;
6161 for(int l_mass = 0, flg = 1; l_mass < nmass;
6162 l_mass++, flg <<= 1) {
6163
6164 if (!(mhyp_ & flg)) continue;
6165 if (l_mass == lead_) continue;
6166
6167 // Check the mom. to decide of the refit with this mass assumption
6168 if ((lead_ != 0 && l_mass==0 && pp > pe_cut_) ||
6169 (lead_ != 1 && l_mass==1 && pp > pmu_cut_) ||
6170 (lead_ != 2 && l_mass==2 && pp > ppi_cut_) ||
6171 (lead_ != 3 && l_mass==3 && pp > pk_cut_) ||
6172 (lead_ != 4 && l_mass==4 && pp > pp_cut_))
6173 continue;
6174 if(debug_ == 4) cout<<"complete_track..REFIT ASSUMPION " << l_mass << endl;
6175 // Initialisation :
6176 double chiSq = 0;
6177 int nhits = 0;
6178
6179 // Initialisation : (x, a, ea)
6180 HepPoint3D x_trasan(TrasanTRK.pivot[0],
6181 TrasanTRK.pivot[1],
6182 TrasanTRK.pivot[2]);
6183 HepVector a_trasan(5);
6184 for(int i = 0; i < 5; i++)
6185 a_trasan[i] = TrasanTRK.helix[i];
6186
6187 HepSymMatrix ea_trasan(5);
6188 for(int i = 0, k = 0; i < 5; i++) {
6189 for(int j = 0; j <= i; j++) {
6190 ea_trasan[i][j] = matrixg_*TrasanTRK.error[k++];
6191 ea_trasan[j][i] = ea_trasan[i][j];
6192 }
6193 }
6194
6195 KalFitTrack track(x_trasan,a_trasan, ea_trasan, l_mass, chiSq, nhits);
6196 track.HitsMdc(track_lead.HitsMdc());
6197 track.trasan_id(TrasanTRK.id);
6198 double fiTerm = TrasanTRK.fiTerm;
6199 track.pivot(track.x(fiTerm));
6200 HepSymMatrix Eakal(5,0);
6201
6202 double costheta = track.a()[4] / sqrt(1.0 + track.a()[4]*track.a()[4]);
6203 if( (1.0/fabs(track.a()[2]) < pt_cut_ ) && (fabs(costheta)> theta_cut_) ) {
6204 choice_ = 6;
6205 }
6206
6207 init_matrix(choice_,TrasanTRK, Eakal);
6208 if(ntuple_&256) {
6209 m_hit_no=0;
6210 m_nCluster=0;
6211 }
6212 filter_fwd_anal(track, l_mass, way, Eakal);
6213 KalFitTrack track_z(track);
6214 track_first=track;
6215 //fromFHitToInnerWall(track_z, way);
6216 //cout<<"fitGemHits for i="<<l_mass<<endl;
6217 //if(useNCGem_>0) fitGemHits(track_z, l_mass, way);
6218 if(useNCGem_>0) track_first=Cgem_filter_anal(track_z, l_mass, way);
6219 else if(useNCGem_==0) innerwall(track_z, l_mass, way);
6220 ///fill tds with results got at (0,0,0)
6221 //innerwall(track_z, l_mass, way,95,99);
6222 fillTds_ip(TrasanTRK, track_z, kaltrk, l_mass);
6223 // Fill tds with the result at the inner most hit
6224 fillTds(TrasanTRK, track_first, kaltrk, l_mass);
6225 if(ifProdNt12){
6226 if(l_mass==1)residual(track_z);
6227 }
6228 }
6229 } // end of //end of if (!(i_front<0))
6230
6231
6232 if(ntuple_&256) StatusCode sc7 = m_nt7 ->write();
6233 // Refit with an enhancement of the error matrix at Mdc level :
6234 if (enhance_) {
6235
6236 HepPoint3D x_first(0, 0, 0);
6237 HepVector a_first(kaltrk->getFHelix());
6238 HepSymMatrix ea_first(kaltrk->getFError());
6239 HepVector fac(5);
6240 fac[0]=fac_h1_; fac[1]=fac_h2_; fac[2]=fac_h3_; fac[3]=fac_h4_; fac[4]=fac_h5_;
6241 for(int i = 0; i < 5; i++)
6242 for(int j = 0; j <= i; j++)
6243 ea_first[i][j] = fac[i]*fac[j]*ea_first[i][j];
6244 KalFitTrack track(x_first, a_first, ea_first, 2, 0, 0);
6245 }
6246 //if(myEventNo==1080) cout<<"mu_status_filled2 = "<<kaltrk->getStat(0,1)<<endl;
6247
6248 // Backward filter :
6249 KalFitTrack track_back(track_lead);
6250 if (debug_ == 4) {
6251 cout << " Backward fitting flag:" << back_<< endl;
6252 cout << "track_back pivot " << track_back.pivot()
6253 << " track_lead kappa " << track_lead.a()[2]
6254 <<endl;
6255 }
6256
6257 if (back_ && track_lead.a()[2] != 0 &&
6258 1/fabs(track_lead.a()[2]) > pT_) {
6259 track_back.HitsMdc(track_lead.HitsMdc());
6260
6262 double p_kaon(0), p_proton(0);
6263 if (!(kaltrk->getStat(0,3))) {
6264 p_kaon = 1 / fabs(kaltrk->getZHelixK()[2]) *
6265 sqrt(1 + kaltrk->getZHelixK()[4]*kaltrk->getZHelixK()[4]);
6266 track_back.p_kaon(p_kaon);
6267 } else {
6268 p_kaon = 1 / fabs(track_back.a()[2]) *
6269 sqrt(1 + track_back.a()[4]*track_back.a()[4]);
6270 track_back.p_kaon(p_kaon);
6271 }
6272 if (!(kaltrk->getStat(0,4))) {
6273 p_proton = 1 / fabs(kaltrk->getZHelixP()[2]) *
6274 sqrt(1 + kaltrk->getZHelixP()[4]*kaltrk->getZHelixP()[4]);
6275 track_back.p_proton(p_proton);
6276 } else {
6277 p_proton = 1 / fabs(track_back.a()[2]) *
6278 sqrt(1 + track_back.a()[4]*track_back.a()[4]);
6279 track_back.p_proton(p_proton);
6280 }
6281 }
6282
6283 if (!(i_back_<0)) {
6284 //cout<<" *** in smoothing process ***"<<endl;
6285 for(int l_mass = 0; l_mass < nmass; l_mass++)
6286 {
6287 //cout<<" --- in hypothesis "<<l_mass<<" :"<<endl;
6288 KalFitTrack track_seed(track_back);
6289 track_seed.chgmass(l_mass);
6290 //cout<<"---------------"<<endl;//wangll
6291 //cout<<"smooth track "<<l_mass<<endl;//wangll
6292 //cout<<" pivot :"<<track_seed.pivot()<<endl;//wangll
6293 //cout<<" helix :"<<track_seed.a()<<endl;//wangll
6294
6295 if(useNCGem_>0) Cgem_filter_anal(track_seed, l_mass, -way);
6296 smoother_anal(track_seed, -way);
6297 // if( usage_ == 1) smoother_calib(track_seed, -way);
6298 //cout<<"fillTds_back 1"<<endl;
6299 // fill TDS for backward filter :
6300 fillTds_back(track_seed, kaltrk, TrasanTRK, l_mass, segcol, 1);
6301 //cout<<"nHits: "<<kaltrk->getVecHelixSegs().size()<<endl;
6302 }
6303 } else {
6304 if(useNCGem_>0) Cgem_filter_anal(track_back, lead_, -way);
6305 smoother_anal(track_back, -way);
6306 //smoother_calib(track_back, -way);
6307 // smoother(track_back, -way);
6308 // fill TDS for backward filter :
6309 //cout<<"fillTds_back 2"<<endl;
6310 fillTds_back(track_back, kaltrk, TrasanTRK, lead_, segcol, 1);
6311 }
6312 }
6313
6314 // Take care of the pointers (use lead. hyp results by default)
6315 //if(myEventNo==1080) cout<<"mu_status_filled3 = "<<kaltrk->getStat(0,1)<<endl;
6316 /*
6317 for(int pid = 0; pid < nmass;
6318 pid++) {
6319 if (pid == lead_) continue;
6320 if (kaltrk->getStat(1,pid))
6321 sameas(kaltrk, pid, lead_);
6322 }*/
6323
6324
6325 //check: before register into TDS
6326
6327 log << MSG::DEBUG << "registered MDC Kalmantrack:"
6328 << "Track Id: " << kaltrk->getTrackId()
6329 << " Mass of the fit: "<< kaltrk->getMass(2)<< endreq
6330 << "Length of the track: "<< kaltrk->getLength(2)
6331 << " Tof of the track: "<< kaltrk->getTof(2) << endreq
6332 << "Chisq of the fit: "<< kaltrk->getChisq(0,2)
6333 <<" "<< kaltrk->getChisq(1,2) << endreq
6334 << "Ndf of the fit: "<< kaltrk->getNdf(0,2)
6335 <<" "<< kaltrk->getNdf(1,2) << endreq
6336 << "Helix " << kaltrk->getZHelix()[2]
6337 <<endreq;
6338
6339 //if(myEventNo==1080) cout<<"mu_status_filled4 = "<<kaltrk->getStat(0,1)<<endl;
6340 kalcol->push_back(kaltrk);
6341 track_lead.HitsMdc().clear();
6342}
void residual(KalFitTrack &track)
void filter_fwd_anal(KalFitTrack &trk, int l_mass, int way, HepSymMatrix &Eakal)
Kalman filter (forward) in Mdc.
void smoother_anal(KalFitTrack &trk, int way)
Kalman filter (smoothing or backward part)
KalFitTrack Cgem_filter_anal(KalFitTrack &track, int hypo, int way)

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

922{
923 MsgStream log(msgSvc(), name());
924 log << MSG::INFO << "in execute()" << endreq;
925 if(testOutput) std::cout<<"begin to deal with EVENT ..."<<(++eventno)<<std::endl;
926 for(int i=0; i<5; i++) iqual_front_[i] = 1;
927 iqual_back_ = 1;
928
929
930 /*
931 MdcID mdcId;
932 SmartDataPtr<RecMdcKalTrackCol> recmdckaltrkCol(eventSvc(),"/Event/Recon/RecMdcKalTrackCol");
933 SmartDataPtr<RecMdcKalHelixSegCol> recSegCol(eventSvc(),"/Event/Recon/RecMdcKalHelixSegCol");
934 if(recmdckaltrkCol) {
935 cout<<"------------------------ new event ---------------------"<<endl;
936 cout<<"recmdckaltrkCol->size()="<<recmdckaltrkCol->size()<<endl;
937 cout<<"recSegCol.size()="<<recSegCol->size()<<endl;
938 cout<<"--------------------------------------------------------"<<endl;
939 RecMdcKalTrack::setPidType(RecMdcKalTrack::electron);
940 RecMdcKalTrackCol::iterator KalTrk= recmdckaltrkCol->begin();
941 int i_trk=0;
942 for(;KalTrk !=recmdckaltrkCol->end();KalTrk++){
943 cout<<"*** track "<<i_trk++<<" ***"<<endl;
944 HelixSegRefVec gothelixsegs = (*KalTrk)->getVecHelixSegs();
945 for(int i=0;i<5;i++) cout<<"pid "<<i<<" nSegs="<<((*KalTrk)->getVecHelixSegs(i)).size()<<endl;
946 HelixSegRefVec::iterator iter_hit = gothelixsegs.begin();
947 if(iter_hit == gothelixsegs.end())cout<<"iter_hit == gothelixsegs.end()"<<endl;
948 int nhitofthistrk=0;
949 for( ; iter_hit != gothelixsegs.end(); iter_hit++){
950 nhitofthistrk++;
951 //cout<<"layerId: "<<(*iter_hit)->getLayerId()<<endl;
952 //cout<<"Identifier: "<<(*iter_hit)->getMdcId()<<endl;
953 //cout<<"layerId: "<<mdcId.layer((*iter_hit)->getMdcId())<<endl;
954 //cout<<"getDT: "<<(*iter_hit)->getDT()<<endl;
955 }
956 iter_hit=gothelixsegs.begin();
957 //for(int m=0; m<nhitofthistrk/5;m++){
958 // identifier = (*iter_hit) -> getMdcId();
959 //}
960 cout<<"nhitofthistrk="<<nhitofthistrk<<endl;
961 }
962 }
963 else cout<<"did not find /Event/Recon/RecMdcKalTrackCol"<<endl;
964 */
965
966
967
968
969 ///
970 IMagneticFieldSvc* IMFSvc;
971 StatusCode sc = service ("MagneticFieldSvc",IMFSvc);
972 if(sc!=StatusCode::SUCCESS) {
973 log << MSG::ERROR << "Unable to open Magnetic field service"<<endreq;
974 }
975
976 // Nominal magnetic field :
978 KalFitTrack::Bznom_ = (IMFSvc->getReferField())*10000; //unit is KGauss
980
981 if(4 == debug_){
982 std::cout<<" execute, referField from MagneticFieldSvc: "<< (IMFSvc->getReferField())*10000 <<std::endl;
983 std::cout<<" magnetic field: "<<KalFitTrack::Bznom_<<std::endl;
984 }
985 }
986
988
989 IDataProviderSvc* evtSvc = NULL;
990 Gaudi::svcLocator()->service("EventDataSvc", evtSvc);
991 if (evtSvc) {
992 log << MSG::INFO << "makeTds:event Svc has been found" << endreq;
993 } else {
994 log << MSG::FATAL << "makeTds:Could not find eventSvc" << endreq;
995 return StatusCode::SUCCESS;
996 }
997
998 StatusCode kalsc;
999 IDataManagerSvc *dataManSvc;
1000 dataManSvc= dynamic_cast<IDataManagerSvc*>(evtSvc);
1001 DataObject *aKalTrackCol;
1002 evtSvc->findObject("/Event/Recon/RecMdcKalTrackCol",aKalTrackCol);
1003 if(aKalTrackCol != NULL) {
1004 dataManSvc->clearSubTree("/Event/Recon/RecMdcKalTrackCol");
1005 evtSvc->unregisterObject("/Event/Recon/RecMdcKalTrackCol");
1006 }
1007
1008 kalsc = evtSvc->registerObject("/Event/Recon/RecMdcKalTrackCol", kalcol);
1009 if( kalsc.isFailure() ) {
1010 log << MSG::FATAL << "Could not register RecMdcKalTrack" << endreq;
1011 return StatusCode::SUCCESS;
1012 }
1013 log << MSG::INFO << "RecMdcKalTrackCol registered successfully!" <<endreq;
1014
1015 DataObject *aKalHelixSegCol;
1016 evtSvc->findObject("/Event/Recon/RecMdcKalHelixSegCol", aKalHelixSegCol);
1017 if(aKalHelixSegCol != NULL){
1018 dataManSvc->clearSubTree("/Event/Recon/RecMdcKalHelixSegCol");
1019 evtSvc->unregisterObject("/Event/Recon/RecMdcKalHelixSegCol");
1020 }
1021 RecMdcKalHelixSegCol *helixsegcol = new RecMdcKalHelixSegCol;
1022 kalsc = evtSvc->registerObject("/Event/Recon/RecMdcKalHelixSegCol", helixsegcol);
1023 if( kalsc.isFailure()){
1024 log<< MSG::FATAL << "Could not register RecMdcKalHelixSeg" <<endreq;
1025 return StatusCode::SUCCESS;
1026 }
1027 log << MSG::INFO << "RecMdcKalHelixSegCol register successfully!" <<endreq;
1028
1029
1030 /*IMdcGeomSvc* geosvc;
1031 StatusCode sc = service("MdcGeomSvc", geosvc);
1032 if (sc == StatusCode::SUCCESS) {
1033 } else {
1034 return sc;
1035 }*/
1036
1037 ISvcLocator* svcLocator = Gaudi::svcLocator();
1038 ICgemGeomSvc* ISvc;
1039 StatusCode Cgem_sc=svcLocator->service("CgemGeomSvc", ISvc);
1040 m_CgemGeomSvc_=dynamic_cast<CgemGeomSvc *>(ISvc);
1041 if (!Cgem_sc.isSuccess()) log<< MSG::INFO << "KalFitAlg::execute(): Could not open CGEM geometry file" << endreq;
1042 //myNCgemLayers = myCgemGeomSvc->getNumberOfCgemLayer();
1043 //if(myPrintFlag) cout<<"CgemClusterCreate::initialize() "<<myNCgemLayers<<" Cgem layers"<<endl;
1044
1045 MdcGeomSvc* const geosvc = dynamic_cast<MdcGeomSvc*>(imdcGeomSvc_);
1046 if(!geosvc) {
1047 std::cout<<"ERROR OCCUR when dynamic_cast in KalFitAlg::execute ...!!"<<std::endl;
1048 }
1049
1050 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
1051 if (!eventHeader) {
1052 log << MSG::WARNING << "Could not find Event Header" << endreq;
1053 return StatusCode::FAILURE;
1054 }
1055 int eventNo = eventHeader->eventNumber();
1057 int runNo = eventHeader->runNumber();
1058 if(runNo>0) wsag_=4;
1059 else wsag_=0;
1060
1061 if(testOutput) cout<<endl<<"$$$$$$$$$$$ run="<<runNo<<", evt="<<eventNo<<" $$$$$$$$$$$$$$$$$"<<endl<<endl;
1062
1063 double t0=0.;
1064 SmartDataPtr<RecEsTimeCol> estimeCol(eventSvc(),"/Event/Recon/RecEsTimeCol");
1065 if (estimeCol && estimeCol->size()) {
1066 RecEsTimeCol::iterator iter_evt = estimeCol->begin();
1067 t0 = (*iter_evt)->getTest();
1068 // t0Stat = (*iter_evt)->getStat();
1069 }else{
1070 log << MSG::WARNING << "Could not find EvTimeCol" << endreq;
1071 return StatusCode::SUCCESS;
1072 }
1073
1074
1075 if(debug_==4) {
1076 std::cout<<"in KalFitAlg , we get the event start time = "<<t0<<std::endl;
1077 }
1079
1080 SmartDataPtr<MdcDigiCol> mdcDigiCol(evtSvc,"/Event/Digi/MdcDigiCol");
1081 if (sc!=StatusCode::SUCCESS) {
1082 log << MSG::FATAL << "Could not find MdcDigiCol!" << endreq;
1083 return StatusCode::SUCCESS;
1084 }
1085 KalFitTrack::setMdcDigiCol(mdcDigiCol);
1086
1087 // register RecMdcTrack and MdcRecHit collection
1088
1089 if((ntuple_&16)&&(ntuple_&1)) {
1090 // McTruth infor,Retrieve MC track truth
1091 // bool mcstat = true;
1092 // more research needed ...
1093
1094 m_evtid = eventHeader->eventNumber();
1095 bool mcstat = true;
1096
1097 SmartDataPtr<McParticleCol> mcPartCol(eventSvc(),"/Event/MC/McParticleCol");
1098 if (!mcPartCol) {
1099 log << MSG::WARNING << "Could not find McParticle" << endreq;
1100 mcstat = false;
1101 }
1102
1103 if(mcstat) {
1104 McParticleCol::iterator i_mcTrk = mcPartCol->begin();
1105 for (;i_mcTrk != mcPartCol->end(); i_mcTrk++) {
1106 if(!(*i_mcTrk)->primaryParticle()) continue;
1107 const HepLorentzVector& mom((*i_mcTrk)->initialFourMomentum());
1108 const HepLorentzVector& pos = (*i_mcTrk)->initialPosition();
1109 log << MSG::DEBUG << "MCINFO:particleId=" << (*i_mcTrk)->particleProperty()
1110 << " theta=" << mom.theta() <<" phi="<< mom.phi()
1111 <<" px="<< mom.px() <<" py="<< mom.py() <<" pz="<< mom.pz()
1112 << endreq;
1113 double charge = 0.0;
1114 int pid = (*i_mcTrk)->particleProperty();
1115 int mother_id = ((*i_mcTrk)->mother()).particleProperty();
1116 if( pid >0 ) {
1117 charge = m_particleTable->particle( pid )->charge();
1118 } else if ( pid <0 ) {
1119 charge = m_particleTable->particle( -pid )->charge();
1120 charge *= -1;
1121 } else {
1122 log << MSG::WARNING << "wrong particle id, please check data" <<endreq;
1123 }
1124 HepPoint3D pos2(pos.x(),pos.y(),pos.z());
1125 Hep3Vector mom2(mom.px(),mom.py(),mom.pz());
1126
1127 KalmanFit::Helix mchelix(pos2, mom2, charge);
1128 log << MSG::DEBUG << "charge of the track " << charge << endreq;
1129 if( debug_ == 4) cout<< "helix: "<<mchelix.a()<<endl;
1130 mchelix.pivot( HepPoint3D(0,0,0) );
1131 for( int j =0; j<5; j++) {
1132 m_mchelix[j] = mchelix.a()[j];
1133 }
1134 m_mcpid = pid;
1135 m_mcptot = sqrt(1+pow(m_mchelix[4],2))/m_mchelix[2];
1136 if(testOutput)
1137 {
1138 cout<<"MC pid, mother_id = "<<pid<<", "<<mother_id<<endl;
1139 cout<<" p4 = "<<(*i_mcTrk)->initialFourMomentum()<<endl;
1140 cout<<" start from "<<(*i_mcTrk)->initialPosition()<<endl;
1141 cout<<" end at "<<(*i_mcTrk)->finalPosition()<<endl;
1142 cout<<" Helix: "<<mchelix.a()<<endl;
1143 cout<<"mc ptot, theta, phi, R = "<<m_mcptot<<", "<<mom2.theta()/acos(-1.)*180<<", "<<mom2.phi()/acos(-1.)*180<<", "<<mchelix.radius()<<endl;
1144 }
1145 }
1146 }
1147 }
1148
1149 Identifier mdcid;
1150
1151 //retrieve RecMdcTrackCol from TDS
1152 SmartDataPtr<RecMdcTrackCol> newtrkCol(eventSvc(),"/Event/Recon/RecMdcTrackCol");
1153 if (!newtrkCol) {
1154 log << MSG::FATAL << "Could not find RecMdcTrackCol" << endreq;
1155 return( StatusCode::SUCCESS);
1156 }
1157 log << MSG::INFO << "Begin to make MdcRecTrkCol and MdcRecWirhitCol"<<endreq;
1158
1159 vector<MdcRec_trk>* mtrk_mgr = MdcRecTrkCol::getMdcRecTrkCol();
1160 mtrk_mgr->clear();
1161 // m_tracks_kal = mtrk_mgr ->size();
1162 vector<MdcRec_trk_add>* mtrkadd_mgr = MdcRecTrkAddCol::getMdcRecTrkAddCol();
1163 mtrkadd_mgr->clear();
1164 vector<MdcRec_wirhit>* mhit_mgr = MdcRecWirhitCol::getMdcRecWirhitCol();
1165 mhit_mgr->clear();
1166
1167 double trkx1,trkx2,trky1,trky2,trkz1,trkz2,trkthe1,trkthe2,trkphi1,trkphi2,trkp1,trkp2,trkr1,trkr2,trkkap1,trkkap2,trktanl1,trktanl2;
1168 Hep3Vector csmp3[2];
1169 double csmphi[2];
1170 int status_temp=0;
1171 RecMdcTrackCol::iterator iter_trk = newtrkCol->begin();
1172 for(int kj = 1; iter_trk != newtrkCol->end(); iter_trk++,kj++) {
1173 if(kj<3){
1174 csmp3[kj-1]=(*iter_trk)->p3();
1175 csmphi[kj-1] = (*iter_trk)->phi();
1176 }
1177 if(ntuple_&2) {
1178 //check trackcol, track level
1179 for( int j = 0, ij = 0; j<5; j++) {
1180 m_trkhelix[j] = (*iter_trk)->helix()[j];
1181 if(ntuple_&32) {
1182 for(int k=0; k<=j; k++,ij++) {
1183 m_trkerror[ij] = (*iter_trk)->err()[j][k];
1184 }
1185 }
1186 }
1187 m_trkptot = sqrt(1+pow(m_trkhelix[4],2))/m_trkhelix[2];
1188 if(ntuple_&32){
1189 m_trksigp = sqrt(pow((m_trkptot/m_trkhelix[2]),2)*m_trkerror[5]+
1190 pow((m_trkhelix[4]/m_trkptot),2)*pow((1/m_trkhelix[2]),4)*m_trkerror[14]-
1191 2*m_trkhelix[4]*m_trkerror[12]*pow((1/m_trkhelix[2]),3));
1192 }
1193 m_trkndf = (*iter_trk)->ndof();
1194 m_trkchisq = (*iter_trk)->chi2();
1195
1196 if (debug_ == 4) cout<<"Ea from RecMdcTrackCol..." <<(*iter_trk)->err()<<endl;
1197
1198 StatusCode sc3 = m_nt3->write();
1199 if( sc3.isFailure() ) cout<<"Ntuple3 filling failed!"<<endl;
1200 }
1201 //end of track level check and prepare evt check
1202 if(ntuple_&4) {
1203 /*
1204 if(kj == 1) {
1205 trkphi1 = (*iter_trk)->getFi0();
1206 trkr1 = (*iter_trk)->getDr();
1207 trkz1 = (*iter_trk)->getDz();
1208 trkkap1 = (*iter_trk)->getCpa();
1209 trktanl1 = (*iter_trk)->getTanl();
1210 trkx1 = trkr1*cos(trkphi1);
1211 trky1 = trkr1*sin(trkphi1);
1212 trkp1 = sqrt(1+trktanl1*trktanl1)/trkkap1;
1213 trkthe1 = M_PI/2-atan(trktanl1);
1214 } else if(kj == 2) {
1215 trkphi2 = (*iter_trk)->getFi0();
1216 trkr2 = (*iter_trk)->getDr();
1217 trkz2 = (*iter_trk)->getDz();
1218 trkkap2 = (*iter_trk)->getCpa();
1219 trktanl2 = (*iter_trk)->getTanl();
1220 trkx2 = trkr2*cos(trkphi2);
1221 trky2 = trkr2*sin(trkphi2);
1222 trkp2 = sqrt(1+trktanl2*trktanl2)/trkkap1;
1223 trkthe2 = M_PI/2-atan(trktanl2);
1224 }
1225 */
1226 }
1227 //end prepare
1228
1229 log << MSG::DEBUG << "retrieved MDC tracks:"
1230 << " Nhits " <<(*iter_trk)->getNhits()
1231 << " Nster " <<(*iter_trk)->nster() <<endreq;
1232 // so ,use this to get the hits vector belong to this track ...
1233 HitRefVec gothits = (*iter_trk)->getVecHits();
1234
1235 MdcRec_trk* rectrk = new MdcRec_trk;
1236
1237 rectrk->id = (*iter_trk)->trackId();
1238 rectrk->chiSq = (*iter_trk)->chi2();
1239 rectrk->ndf = (*iter_trk)->ndof();
1240 rectrk->fiTerm = (*iter_trk)->getFiTerm();
1241 rectrk->nhits = (*iter_trk)->getNhits();
1242 rectrk->nster = (*iter_trk)->nster();
1243 rectrk->nclus = (*iter_trk)->getNcluster();
1244 rectrk->stat = (*iter_trk)->stat();
1245 status_temp = (*iter_trk)->stat();
1246 MdcRec_trk_add* trkadd = new MdcRec_trk_add;
1247 trkadd->id = (*iter_trk)->trackId();
1248 trkadd->quality = 0;
1249 trkadd->kind = 1;
1250 trkadd->decision = 0;
1251 trkadd->body = rectrk;
1252 rectrk->add = trkadd;
1253
1254 // --- just check nCgemXCluster, nCgemVCluster
1255 //cout<<"KalFitAlg::execute(): nCgemXCluster, nCgemVCluster = "<<(*iter_trk)->nCgemXCluster()<<", "<<(*iter_trk)->nCgemVCluster()<<endl;
1256
1257 for ( int i=0; i<5; i++) {
1258 rectrk->helix[i] = (*iter_trk)->helix()[i];
1259 if( i<3 ) rectrk->pivot[i] = (*iter_trk)->getPivot()[i];
1260 for( int j = 1; j<i+2;j++) {
1261 rectrk->error[i*(i+1)/2+j-1] = (*iter_trk)->err()(i+1,j);
1262 }
1263 }
1264 std::sort(gothits.begin(), gothits.end(), order_rechits);
1265 HitRefVec::iterator it_gothit = gothits.begin();
1266 for( ; it_gothit != gothits.end(); it_gothit++) {
1267
1268 if( (*it_gothit)->getStat() != 1 ) {
1269 if(activeonly_) {
1270 log<<MSG::WARNING<<"this hit is not used in helix fitting!"<<endreq;
1271 continue;
1272 }
1273 }
1274
1275 log << MSG::DEBUG << "retrieved hits in MDC tracks:"
1276 << " hits DDL " <<(*it_gothit)->getDriftDistLeft()
1277 << " hits DDR " <<(*it_gothit)->getDriftDistRight()
1278 << " error DDL " <<(*it_gothit)->getErrDriftDistLeft()
1279 << " error DDR " <<(*it_gothit)->getErrDriftDistRight()
1280 << " id of hit "<<(*it_gothit)->getId()
1281 << " track id of hit "<<(*it_gothit)->getTrkId()
1282 << " hits ADC " <<(*it_gothit)->getAdc() << endreq;
1283
1284 MdcRec_wirhit* whit = new MdcRec_wirhit;
1285 whit->id = (*it_gothit)->getId();
1286 whit->ddl = (*it_gothit)->getDriftDistLeft();
1287 whit->ddr = (*it_gothit)->getDriftDistRight();
1288 whit->erddl = (*it_gothit)->getErrDriftDistLeft();
1289 whit->erddr = (*it_gothit)->getErrDriftDistRight();
1290 whit->pChiSq = (*it_gothit)->getChisqAdd();
1291 whit->lr = (*it_gothit)->getFlagLR();
1292 whit->stat = (*it_gothit)->getStat();
1293 mdcid = (*it_gothit)->getMdcId();
1294 int layid = MdcID::layer(mdcid);
1295 int localwid = MdcID::wire(mdcid);
1296 int w0id = geosvc->Layer(layid)->Wirst();
1297 int wid = w0id + localwid;
1298 log << MSG::INFO
1299 << "lr from PR: "<<whit->lr
1300 << " layerId = " << layid
1301 << " wireId = " << localwid
1302 << endreq;
1303
1304 const MdcGeoWire * const wirgeo = geosvc->Wire(wid);
1305
1306 //std::cout<<"the track id of *it_gothit... "<<(*it_gothit)->getTrackId()<<std::endl;
1307 whit->rechitptr = *it_gothit;
1308 whit->geo = wirgeo;
1309 whit->dat = 0;
1310 whit->trk = rectrk;
1311 whit->tdc = (*it_gothit)->getTdc();
1312 whit->adc= (*it_gothit)->getAdc();
1313 rectrk->hitcol.push_back(whit);
1314 mhit_mgr->push_back(*whit);
1315 }
1316 mtrk_mgr->push_back(*rectrk);
1317 mtrkadd_mgr->push_back(*trkadd);
1318
1319 delete rectrk;
1320 delete trkadd;
1321 }
1322
1323 // check trkcol: evt level
1324 if(ntuple_&4) {
1325 m_trkdelx = trkx1 - trkx2;
1326 m_trkdely = trky1 - trky2;
1327 m_trkdelz = trkz1 - trkz2;
1328 m_trkdelthe = trkthe1 + trkthe2;
1329 m_trkdelphi = trkphi1- trkphi2;
1330 m_trkdelp = trkp1 - trkp2;
1331 StatusCode sc4 = m_nt4->write();
1332 if( sc4.isFailure() ) cout<<"Ntuple4 filling failed!"<<endl;
1333 }
1334
1335 if(debug_ == 4) { std::cout<<"before refit,ntrk,nhits,nadd..."<<mtrk_mgr->size()
1336 <<"********"<<mhit_mgr->size()<<"****"<<mtrkadd_mgr->size()<<endl;
1337 }
1338
1339 if(useNCGem_>0) makeGemHitsCol();
1340
1341 // Actual fitter procedure :
1342 //cout << "m_trackid" << m_trackid << endl;
1343 //cout << "m_qua" << m_qua << endl;
1344 //cout << "m_esti" << m_esti1_r[0] << endl;
1345 if(usage_ == 0) kalman_fitting_anal();
1346 if(usage_ == 1) kalman_fitting_calib();
1347 double mdang = 180.0 - csmp3[0].angle(csmp3[1].unit())*180.0/M_PI;
1348 double mdphi = 180.0 - fabs(csmphi[0]-csmphi[1])*180.0/M_PI;
1349 //std::cout<<"before refit,ntrk,nhits,nadd..."<<mtrk_mgr->size()<<" , "<<mhit_mgr->size()<<" , "<<mtrkadd_mgr->size()<<endl;
1350 if(usage_ == 2 && (mtrk_mgr->size())==2 && fabs(mdang)<m_dangcut && fabs(mdphi)<m_dphicut) kalman_fitting_csmalign();
1351 if(usage_ == 3 && (mtrk_mgr->size())==1 && status_temp==-1) kalman_fitting_MdcxReco_Csmc_Sew();
1352
1353 log << MSG::DEBUG <<"after kalman_fitting(),but in execute...."<<endreq;
1354 clearTables();
1355
1356
1357 ///*
1358 // --- test for songxy
1359 MdcID mdcId;
1360 SmartDataPtr<RecMdcKalTrackCol> recmdckaltrkCol(eventSvc(),"/Event/Recon/RecMdcKalTrackCol");
1361 //cout<<"------------------------ new event ---------------------"<<endl;
1362 //cout<<"recmdckaltrkCol->size()="<<recmdckaltrkCol->size()<<endl;
1363 //cout<<"--------------------------------------------------------"<<endl;
1365 RecMdcKalTrackCol::iterator KalTrk= recmdckaltrkCol->begin();
1366 int i_trk=0;
1367 for(;KalTrk !=recmdckaltrkCol->end();KalTrk++, i_trk++){
1368 //cout<<"*** track "<<i_trk++<<" ***"<<endl;
1369 bool trkFailed = false;
1370 for(int hypo=0; hypo<5; hypo++)
1371 {
1372 if((*KalTrk)->getStat(0,hypo)==1) {
1373 nFailedTrks[hypo]++;
1374 trkFailed=true;
1375 }
1376 }
1377 if(debug_==5&&trkFailed) cout<<" Evt "<<myEventNo<<", track "<<i_trk<<": Kalman filter failed"<<endl;
1378 //if(eventNo==1080) cout<<"mu_status = "<<(*KalTrk)->getStat(0,1)<<endl;
1379 HelixSegRefVec gothelixsegs = (*KalTrk)->getVecHelixSegs();
1380 HelixSegRefVec::iterator iter_hit = gothelixsegs.begin();
1381 //if(iter_hit == gothelixsegs.end())cout<<"iter_hit == gothelixsegs.end()"<<endl;
1382 int nhitofthistrk=0;
1383 for( ; iter_hit != gothelixsegs.end(); iter_hit++){
1384 nhitofthistrk++;
1385 //cout<<"layerId: "<<(*iter_hit)->getLayerId()<<endl;
1386 //cout<<"Identifier: "<<(*iter_hit)->getMdcId()<<endl;
1387 //cout<<"layerId: "<<mdcId.layer((*iter_hit)->getMdcId())<<endl;
1388 //cout<<"getDT: "<<(*iter_hit)->getDT()<<endl;
1389 }
1390 iter_hit=gothelixsegs.begin();
1391 //for(int m=0; m<nhitofthistrk/5;m++){
1392 // identifier = (*iter_hit) -> getMdcId();
1393 //}
1394 }
1395 // */
1396
1397 // --- test for getStat(2, pid)
1398 /*
1399 SmartDataPtr<RecMdcKalTrackCol> recmdckaltrkCol(eventSvc(),"/Event/Recon/RecMdcKalTrackCol");
1400 SmartDataPtr<RecMdcTrackCol> mdcTrkCol(eventSvc(),"/Event/Recon/RecMdcTrackCol");
1401 //RecMdcKalTrack::setPidType(RecMdcKalTrack::electron);
1402 RecMdcKalTrackCol::iterator KalTrk= recmdckaltrkCol->begin();
1403 int i_trk=0;
1404 for(RecMdcTrackCol::iterator mdcTrk = mdcTrkCol->begin(); KalTrk !=recmdckaltrkCol->end(); KalTrk++, mdcTrk++){
1405 cout<<"*** track "<<i_trk++<<" ***"<<endl;
1406 cout<<"trackId mdc: "<<(*mdcTrk)->trackId()<<endl;
1407 cout<<"trackId kal: "<<(*KalTrk)->trackId()<<endl;
1408 bool KalIsValid = true;
1409 for(int i_pid=0; i_pid<5; i_pid++) {
1410 cout<<"pid "<<i_pid<<" state 0 : "<<(*KalTrk)->getStat(0, i_pid)<<endl;
1411 cout<<"pid "<<i_pid<<" state 1 : "<<(*KalTrk)->getStat(1, i_pid)<<endl;
1412 if((*KalTrk)->getStat(0, i_pid)==1) {
1413 KalIsValid = false;
1414 switch(i_pid) {
1415 case 0: RecMdcKalTrack::setPidType(RecMdcKalTrack::electron);
1416 break;
1417 case 1: RecMdcKalTrack::setPidType(RecMdcKalTrack::muon);
1418 break;
1419 case 2: RecMdcKalTrack::setPidType(RecMdcKalTrack::pion);
1420 break;
1421 case 3: RecMdcKalTrack::setPidType(RecMdcKalTrack::kaon);
1422 break;
1423 case 4: RecMdcKalTrack::setPidType(RecMdcKalTrack::proton);
1424 break;
1425 }
1426 cout<<"Helix Kal: "<<(*KalTrk)->helix()<<endl;
1427 cout<<"Helix Kal err: "<<(*KalTrk)->err()<<endl;
1428 }
1429 }
1430 if(!KalIsValid) {
1431 cout<<"Helix Mdc: "<<(*mdcTrk)->helix()<<endl;
1432 cout<<"Helix Mdc err: "<<(*mdcTrk)->err()<<endl;
1433 }
1434 }
1435 */
1436 if(ifProdNt11)
1437 {
1438 SmartDataPtr<Event::CgemMcHitCol> cgemMcHitCol(eventSvc(), "/Event/MC/CgemMcHitCol");
1439 if (!cgemMcHitCol){
1440 log << MSG::WARNING << "Could not retrieve Cgem MC truth" << endreq;
1441 return StatusCode::FAILURE;
1442 }
1443 m_evt4=eventHeader->eventNumber();
1444 Event::CgemMcHitCol::iterator iter_truth = cgemMcHitCol->begin();
1445 int jj=0;
1446 double dprex,dprey,dprez,dpostx,dposty,dpostz;
1447 int layer;
1448 for(; iter_truth != cgemMcHitCol->end(); ++iter_truth){
1449 layer = (*iter_truth)->GetLayerID();
1450 dprex = (*iter_truth)->GetPositionXOfPrePoint();
1451 dprey = (*iter_truth)->GetPositionYOfPrePoint();
1452 dprez = (*iter_truth)->GetPositionZOfPrePoint();
1453 dpostx = (*iter_truth)->GetPositionXOfPostPoint();
1454 dposty = (*iter_truth)->GetPositionYOfPostPoint();
1455 dpostz = (*iter_truth)->GetPositionZOfPostPoint();
1456
1457 double midx=0;
1458 double midy=0;
1459 CgemGeoLayer* CgemLayer = m_CgemGeomSvc_->getCgemLayer(layer);
1460 double diR = CgemLayer->getInnerROfGapD();
1461 double dmR = CgemLayer->getMiddleROfGapD();
1462 double doR = CgemLayer->getOuterROfGapD();
1463 if((dprex >=0&&dprey>=0)||(dprex <0&&dprey>=0)){
1464 //m_dtphi[jj] = acos(dprex/dr_layer[layer]);
1465 m_dtphi[jj] = acos(dprex/diR);
1466 m_dtv[jj] = dprez;
1467 //m_dtpostphi[jj] = acos(dpostx/dor_layer[layer]);
1468 m_dtpostphi[jj] = acos(dpostx/doR);
1469 m_dtpostz[jj]= dpostz;
1470 }
1471 if((dprex <0&&dprey<0)||(dprex >=0&&dprey<0)){
1472 //m_dtphi[jj] = -acos(dprex/dr_layer[layer]);
1473 m_dtphi[jj] = -acos(dprex/diR);
1474 m_dtv[jj] = dprez;
1475 //m_dtpostphi[jj] = -acos(dpostx/dor_layer[layer]);
1476 m_dtpostphi[jj] = -acos(dpostx/doR);
1477 m_dtpostz[jj]= dpostz;
1478 }
1479 midx=(dprex+dpostx)/2;
1480 midy=(dprey+dposty)/2;
1481 if((midx>=0&&midy>=0)||(midx<0&&midy>=0)){
1482 //m_dtphi[jj]=acos(midx/dmr_layer[layer]);
1483 m_dtphi[jj]=acos(midx/dmR);
1484 }
1485 if((midx<0&&midy<0)||(midx>=0&&midy<0)){
1486 //m_dtphi[jj]=-acos(midx/dmr_layer[layer]);
1487 m_dtphi[jj]=-acos(midx/dmR);
1488 }
1489 m_dtv[jj] = (m_dtv[jj]+m_dtpostz[jj])/20;
1490 m_tlayer[jj] = layer;
1491 jj++;
1492 }
1493 m_ntruth = jj;
1494
1495 m_nt11->write();
1496 }
1497
1498
1499
1500 return StatusCode::SUCCESS;
1501}
*******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
bool testOutput
Definition KalFitAlg.cxx:96
HepGeom::Point3D< double > HepPoint3D
Definition KalFitAlg.h:54
ObjectVector< RecMdcKalHelixSeg > RecMdcKalHelixSegCol
SmartRefVector< RecMdcKalHelixSeg > HelixSegRefVec
ObjectVector< RecMdcKalTrack > RecMdcKalTrackCol
SmartRefVector< RecMdcHit > HitRefVec
Definition RecMdcTrack.h:26
#define M_PI
Definition TConstant.h:4
double getOuterROfGapD() const
double getInnerROfGapD() const
static void setPidType(PidType pidType)
int iqual_front_[5]
Definition KalFitAlg.h:241
void kalman_fitting_MdcxReco_Csmc_Sew(void)
void kalman_fitting_calib(void)
void makeGemHitsCol()
void kalman_fitting_anal(void)
int myEventNo
Definition KalFitAlg.h:245
void kalman_fitting_csmalign(void)
void clearTables()
static void setMdcDigiCol(MdcDigiCol *digicol)
static void setT0(double t0)
const MdcGeoWire *const Wire(unsigned id)
const MdcGeoLayer *const Layer(unsigned id)
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
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

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

1505 {
1506
1507 HepPoint3D IP(0,0,0);
1508 track.pivot(IP);
1509 // Fit quality
1510 int iqual(1);
1511 int trasster = TrasanTRK.nster, trakster = track.nster(),
1512 trasax(TrasanTRK.nhits-trasster), trakax(track.nchits()-trakster);
1513
1514
1515 if(ntuple_&256){
1516 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
1517 if(!eventHeader){
1518 cout<<"Open event header file failed!"<<endl;
1519 }
1520 m_run_kal = eventHeader->runNumber();
1521 m_event_kal = eventHeader->eventNumber();
1522
1523 m_trkid_kal = track.trasan_id();
1524 if(l_mass==0){
1525 //m_dropedHits_kal_e = TrasanTRK.nhits+TrasanTRK.nclus*2-track.nchits();
1526 m_dropedHits_kal_e = TrasanTRK.ndf+5-track.nchits();
1527 m_kappa2_kal_e = TrasanTRK.helix[2]*track.a()[2];
1528 m_trackNhits_kal_e = track.nchits();
1529 m_trackNster_kal_e = track.nster();
1530 m_trackNaxis_kal_e = track.nchits()-track.nster();
1531 m_chi2_kal_e = track.chiSq();
1532 m_Ea00_kal_e = track.Ea()[0][0];
1533 m_Ea11_kal_e = track.Ea()[1][1];
1534 m_Ea22_kal_e = track.Ea()[2][2];
1535 m_Ea33_kal_e = track.Ea()[3][3];
1536 m_Ea44_kal_e = track.Ea()[4][4];
1537 }
1538 else if(l_mass==1){
1539 //m_dropedHits_kal_mu = TrasanTRK.nhits+TrasanTRK.nclus*2-track.nchits();
1540 m_dropedHits_kal_mu = TrasanTRK.ndf+5-track.nchits();
1541 m_kappa2_kal_mu = TrasanTRK.helix[2]*track.a()[2];
1542 m_trackNhits_kal_mu = track.nchits();
1543 m_trackNster_kal_mu = track.nster();
1544 m_trackNaxis_kal_mu = track.nchits()-track.nster();
1545 m_chi2_kal_mu = track.chiSq();
1546 m_Ea00_kal_mu = track.Ea()[0][0];
1547 m_Ea11_kal_mu = track.Ea()[1][1];
1548 m_Ea22_kal_mu = track.Ea()[2][2];
1549 m_Ea33_kal_mu = track.Ea()[3][3];
1550 m_Ea44_kal_mu = track.Ea()[4][4];
1551 //if(myEventNo==1080) cout<<"m_dropedHits_kal_mu = "<<m_dropedHits_kal_mu<<endl;
1552 }
1553 else if(l_mass==2){
1554 //m_dropedHits_kal_pi = TrasanTRK.nhits+TrasanTRK.nclus*2-track.nchits();
1555 m_dropedHits_kal_pi = TrasanTRK.ndf+5-track.nchits();
1556 m_kappa2_kal_pi = TrasanTRK.helix[2]*track.a()[2];
1557 m_trackNhits_kal_pi = track.nchits();
1558 m_trackNster_kal_pi = track.nster();
1559 m_trackNaxis_kal_pi = track.nchits()-track.nster();
1560 m_chi2_kal_pi = track.chiSq();
1561 m_Ea00_kal_pi = track.Ea()[0][0];
1562 m_Ea11_kal_pi = track.Ea()[1][1];
1563 m_Ea22_kal_pi = track.Ea()[2][2];
1564 m_Ea33_kal_pi = track.Ea()[3][3];
1565 m_Ea44_kal_pi = track.Ea()[4][4];
1566
1567 }
1568 else if(l_mass==3){
1569 //m_dropedHits_kal_k = TrasanTRK.nhits+TrasanTRK.nclus*2-track.nchits();
1570 m_dropedHits_kal_k = TrasanTRK.ndf+5-track.nchits();
1571 m_kappa2_kal_k = TrasanTRK.helix[2]*track.a()[2];
1572 m_trackNhits_kal_k = track.nchits();
1573 m_trackNster_kal_k = track.nster();
1574 m_trackNaxis_kal_k = track.nchits()-track.nster();
1575 m_chi2_kal_k = track.chiSq();
1576 m_Ea00_kal_k = track.Ea()[0][0];
1577 m_Ea11_kal_k = track.Ea()[1][1];
1578 m_Ea22_kal_k = track.Ea()[2][2];
1579 m_Ea33_kal_k = track.Ea()[3][3];
1580 m_Ea44_kal_k = track.Ea()[4][4];
1581
1582 }
1583 else if(l_mass==4){
1584 //m_dropedHits_kal_p = TrasanTRK.nhits+TrasanTRK.nclus*2-track.nchits();
1585 m_dropedHits_kal_p = TrasanTRK.ndf+5-track.nchits();
1586 m_kappa2_kal_p = TrasanTRK.helix[2]*track.a()[2];
1587 m_trackNhits_kal_p = track.nchits();
1588 m_trackNster_kal_p = track.nster();
1589 m_trackNaxis_kal_p = track.nchits()-track.nster();
1590 m_chi2_kal_p = track.chiSq();
1591 m_Ea00_kal_p = track.Ea()[0][0];
1592 m_Ea11_kal_p = track.Ea()[1][1];
1593 m_Ea22_kal_p = track.Ea()[2][2];
1594 m_Ea33_kal_p = track.Ea()[3][3];
1595 m_Ea44_kal_p = track.Ea()[4][4];
1596
1597 }
1598 }
1599
1600
1601 // if (TrasanTRK.nhits+TrasanTRK.nclus*2-track.nchits()>fitnocut_ ||
1602 if(TrasanTRK.ndf+5-track.nchits()>fitnocut_
1603 || TrasanTRK.helix[2]*track.a()[2]<0)
1604 iqual = 0;
1605
1606 if (debug_ == 4) {
1607 cout<< "trasster trakster trasax trakax TrasK trackK iqual"<<endl
1608 <<trasster<<" "<<trakster<<" "<<trasax<<" "<<trakax
1609 <<" "<<TrasanTRK.helix[2]<<" "<<track.a()[2]<<" "<<iqual<<endl;
1610 cout<<"FillTds> track.chiSq..."<<track.chiSq()<<" nchits "<<track.nchits()
1611 <<" nster "<<track.nster()<<" iqual "<<iqual<<" track.Ea "<< track.Ea()<<endl;
1612
1613 cout<<"fillTds>.....track.Ea[2][2] "<<track.Ea()[2][2]<<endl;
1614 cout << " TRASAN stereo = " << trasster
1615 << " and KalFitTrack = " << trakster << std::endl;
1616 cout << " TRASAN axial = " << trasax
1617 << " and KalFitTrack = " << trakax << std::endl;
1618
1619 if (!iqual) {
1620 cout << "...there is a problem during fit !! " << std::endl;
1621 if (trasster-trakster>5)
1622 cout << " because stereo " << trasster-trakster << std::endl;
1623 if (trasax-trakax >5)
1624 cout << " because axial " << std::endl;
1625 if (TrasanTRK.helix[2]*track.a()[2]<0)
1626 cout << " because kappa sign " << std::endl;
1627 }
1628 }
1629 // Protection : if any problem, we keep the original information !!!!
1630 if (track.nchits() > 5 && track.nster() > 1 &&
1631 track.nchits()-track.nster() > 2 && track.chiSq() > 0 &&
1632 track.Ea()[0][0] > 0 && track.Ea()[1][1] > 0 &&
1633 track.Ea()[2][2] > 0 && track.Ea()[3][3] > 0 &&
1634 track.Ea()[4][4] > 0 && iqual) {
1635 if(debug_ == 4) cout<<"fillTds>.....going on "<<endl;
1636 trk->setStat(0,0,l_mass);
1637 trk->setMass(track.mass(),l_mass);
1638
1639 // chisq & ndf
1640 trk->setChisq(track.chiSq(),0,l_mass);
1641 trk->setNdf(track.nchits()-5,0,l_mass);
1642 trk->setNhits(track.nchits(),l_mass);
1643
1644 trk->setFHelix(track.a(),l_mass);
1645 trk->setFError(track.Ea(),l_mass);
1646
1647 } else {
1648
1649 if(debug_==4) cout<<"ALARM: FillTds Not refit with KalFilter!!! lmass="<<l_mass<<endl;
1650 // NOT refit with Kalman filter :
1651 trk->setStat(1,0,l_mass);
1652 trk->setMass(KalFitTrack::mass(l_mass),l_mass);
1653 // chisq & ndf (0 : filter ; 1 : smoother;)
1654 trk->setChisq(TrasanTRK.chiSq,0,l_mass);
1655 //trk->setNdf(TrasanTRK.nhits-5,0,l_mass);
1656 trk->setNdf(TrasanTRK.ndf,0,l_mass);
1657 // nhits
1658 //trk->setNhits(TrasanTRK.nhits,l_mass);
1659 trk->setNhits(TrasanTRK.ndf+5,l_mass);
1660 double a_trasan[5], ea_trasan[15];
1661 for( int i =0 ; i <5; i++){
1662 a_trasan[i] = TrasanTRK.helix[i];
1663 }
1664 for( int j =0 ; j <15; j++){
1665 ea_trasan[j] = TrasanTRK.error[j];
1666 }
1667 trk->setFHelix(a_trasan, l_mass);
1668 trk->setFError(ea_trasan,l_mass);
1669 }
1670 //if(l_mass==1&&m_event_kal==1080) cout<<"mu_status_filled = "<<trk->getStat(0,l_mass)<<endl;
1671}
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
double chiSq(void) const
unsigned int nster(void) const
double mass(void) const
const HepPoint3D & pivot(void) const
returns pivot position.
void setMass(double mass, int pid)
void setNhits(int nhits, int pid)

Referenced by complete_track(), and complete_track().

◆ fillTds_back() [1/3]

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

with results got at the outer Mdc hit

right???

Definition at line 2034 of file KalFitAlg.cxx.

2036{
2037
2038 HepPoint3D IP(0,0,0);
2039 //track.pivot(IP);
2040
2041 // Fit quality
2042 int iqual(1);
2043
2044 if ((trk->getNdf(0,l_mass))-(track.ndf_back()-5)>5) iqual = 0;
2045
2046 if(debug_ == 4) cout<< "fillTds_back> mass "<<trk->getMass(2)<<" ndf[0] "<<trk->getNdf(0,2)<<endl;
2047 if(debug_ == 4) cout<<"ndf_back "<< track.ndf_back() << " chi2_back " << track.chiSq_back()<<endl;
2048
2049 if (track.ndf_back() > 5 && track.chiSq_back() > 0 &&
2050 track.Ea()[0][0] > 0 && track.Ea()[1][1] > 0 &&
2051 track.Ea()[2][2] > 0 && track.Ea()[3][3] > 0 &&
2052 track.Ea()[4][4] > 0 && fabs(track.a()[0]) < DBL_MAX &&
2053 fabs(track.a()[1]) < DBL_MAX && fabs(track.a()[2]) < DBL_MAX &&
2054 fabs(track.a()[3]) < DBL_MAX && fabs(track.a()[4]) < DBL_MAX &&
2055 iqual) {
2056
2057 // chisq ( for backward filter)
2058
2059 trk->setStat(0,1,l_mass);
2060 trk->setChisq(track.chiSq_back(),1,l_mass);
2061 trk->setNdf(track.ndf_back()-5,1,l_mass);
2062 trk->setLength(track.pathip(),l_mass);
2063 if(debug_ == 4) cout<<"l_mass "<<l_mass<<" path set as "<<track.pathip()<<endl;
2064 trk->setTof(track.tof(),l_mass);
2065
2067 if(l_mass == 3) trk->setTof(track.tof_kaon(),l_mass);
2068 if(l_mass == 4) trk->setTof(track.tof_proton(),l_mass);
2069 }
2070
2071 // Path length in each MDC layer :
2072 if (pathl_)
2073 for (int i = 0; i<43; i++) {
2074 trk->setPathl(track.pathl()[i],i);
2075 }
2076
2077 trk->setLHelix(track.a(),l_mass);
2078 trk->setLError(track.Ea(),l_mass);
2079 trk->setLPivot(track.pivot(),l_mass);
2080
2081 trk->setLPoint(track.point_last(),l_mass);
2082 trk->setPathSM(track.getPathSM(),l_mass);
2083 trk->setTof(track.getTofSM(),l_mass);
2084 trk->setFiTerm(track.getFiTerm(),l_mass);
2085
2086 if(4 == debug_){
2087 std::cout<<" last pivot: "<< trk->getLPivot(0)<<std::endl;
2088 std::cout<<" pathl in SM: "<< trk->getPathSM(0)<<std::endl;
2089 std::cout<<" fiTerm: "<< trk->getFiTerm(0)<<std::endl;
2090 std::cout<<" last point: "<< trk->getLPoint(0)<<std::endl;
2091 }
2092
2093 } else {
2094 if(debug_==4) cout<<"ALARM: FillTds_back Not refit with KalFilter!!!"<<endl;
2095 // NOT refit with Kalman filter :
2096 trk->setStat(1,1,l_mass);
2097 HepPoint3D piv(TrasanTRK.pivot[0],
2098 TrasanTRK.pivot[1],
2099 TrasanTRK.pivot[2]);
2100
2101 HepVector a(5);
2102 for(int i = 0; i < 5; i++)
2103 a[i] = TrasanTRK.helix[i];
2104
2105 HepSymMatrix ea(5);
2106 for(int i = 0, k = 0; i < 5; i++) {
2107 for(int j = 0; j <= i; j++) {
2108 ea[i][j] = matrixg_*TrasanTRK.error[k++];
2109 ea[j][i] = ea[i][j];
2110 }
2111 }
2112
2113 KalFitTrack track_rep(piv, a, ea, lead_,
2114 TrasanTRK.chiSq, TrasanTRK.nhits);
2115 double fiTerm = TrasanTRK.fiTerm;
2116
2117 double fi0 = track_rep.phi0();
2118 HepPoint3D xc(track_rep.kappa()/fabs(track_rep.kappa())*
2119 track_rep.center() );
2120 double x = xc.x();
2121 double y = xc.y();
2122 double phi_x;
2123 if( fabs( x ) > 1.0e-10 ){
2124 phi_x = atan2( y, x );
2125 if( phi_x < 0 ) phi_x += 2*M_PI;
2126 } else {
2127 phi_x = ( y > 0 ) ? M_PI_4: 3.0*M_PI_4;
2128 }
2129 if(debug_ == 4) cout<<"fiterm "<<fiTerm<<" fi0 "<<fi0<<" phi_x "<<phi_x<<endl;
2130 double dphi = fabs( fiTerm + fi0 - phi_x );
2131 if( dphi >= 2*M_PI ) dphi -= 2*M_PI;
2132 double tanl = track_rep.tanl();
2133 double cosl_inv = sqrt( tanl*tanl + 1.0 );
2134 if(debug_ == 4) {
2135 cout<<"tanl= "<<tanl<<" radius "<<track_rep.radius()<<" dphi "<<dphi<<endl;
2136 cout<<" cosl_inv "<<cosl_inv<<" radius_numf "<<track_rep.radius_numf()<<endl;
2137 }
2138 double track_len(fabs( track_rep.radius() * dphi * cosl_inv ));
2139 double light_speed( 29.9792458 ); // light speed in cm/nsec
2140 double pt( 1.0 / track_rep.kappa() );
2141 double p( pt * sqrt( 1.0 + tanl*tanl ) );
2142
2143 // chisq (2 : for backward filter)
2144 trk->setStat(1,1,l_mass);
2145 trk->setChisq(TrasanTRK.chiSq,1,l_mass);
2146 if(debug_ == 4) {
2147 std::cout<<".....fillTds_back...chiSq..."<< TrasanTRK.chiSq<<endl;
2148 std::cout<<"...track_len..."<<track_len<<" ndf[1] "<< trk->getNdf(0,l_mass)<<endl;
2149 }
2150 trk->setNdf(TrasanTRK.nhits-5,1,l_mass);
2151 trk->setLength(track_len,l_mass);
2152 double mass_over_p( KalFitTrack::mass(l_mass)/ p );
2153 double beta( 1.0 / sqrt( 1.0 + mass_over_p * mass_over_p ) );
2154 trk->setTof(track_len / ( light_speed * beta ), l_mass) ;
2155
2156 track_rep.pivot(IP);
2157
2158 trk->setLHelix(track_rep.a(),l_mass);
2159 trk->setLError(track_rep.Ea(),l_mass);
2160 trk->setLPivot(track.pivot(),l_mass);
2161
2162 /// right???
2163 trk->setLPoint(track.point_last(),l_mass);
2164 trk->setPathSM(track.getPathSM(),l_mass);
2165 trk->setTof(track.getTofSM(),l_mass);
2166 trk->setFiTerm(track.getFiTerm(),l_mass);
2167 }
2168
2169 // test--------
2170 if(debug_ == 4) {
2171
2172 std::cout<<" last point: "<< trk->getLPoint(0)<<std::endl;
2173 std::cout<<" pathl in SM: "<< trk->getPathSM(0)<<std::endl;
2174 std::cout<<" fiTerm: "<< trk->getFiTerm(0)<<std::endl;
2175
2176 cout<<"Now let us see results after smoothering at IP:........."<<endl;
2177 cout << " dr = " << track.a()[0]
2178 << ", Er_dr = " << sqrt(track.Ea()[0][0]) << std::endl;
2179 cout<< " phi0 = " << track.a()[1]
2180 << ", Er_phi0 = " << sqrt(track.Ea()[1][1]) << std::endl;
2181 cout << " PT = " << 1/track.a()[2]
2182 << ", Er_kappa = " << sqrt(track.Ea()[2][2]) << std::endl;
2183 cout << " dz = " << track.a()[3]
2184 << ", Er_dz = " << sqrt(track.Ea()[3][3]) << std::endl;
2185 cout << " tanl = " << track.a()[4]
2186 << ", Er_tanl = " << sqrt(track.Ea()[4][4]) << std::endl;
2187 cout << " Ea = " << track.Ea() <<endl;
2188 }
2189 // test end ----------
2190}
Double_t x[10]
#define DBL_MAX
Definition KalFitAlg.h:13
double * pathl(void)
double tof_proton(void) const
double tof_kaon(void) const
int ndf_back(void) const
double chiSq_back(void) const
double getFiTerm(void)
double getPathSM(void)
double pathip(void) const
void point_last(const HepPoint3D &point)
set and give out the last point of the track
void tof(double path)
Update the tof estimation.
double getTofSM(void)
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)

Referenced by complete_track(), and complete_track().

◆ fillTds_back() [2/3]

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

right???

Definition at line 2192 of file KalFitAlg.cxx.

2195{
2196
2197 HepPoint3D IP(0,0,0);
2198
2199 // attention the pivot problem of the HelixSeg ... ???
2200 track.pivot(IP);
2201 // Fit quality
2202 //int iqual(1);
2203 //if ((trk->getNdf(0,2))-(track.ndf_back()-5)>5)
2204 // form getNdf(0,2) to getNdf(0,1) for muon hypothesis
2205
2206 if ((trk->getNdf(0,l_mass))-(track.ndf_back()-5)>5){
2207 iqual_back_ = 0;
2208 }
2209 if(usage_>1){
2210 for(int i=0; i<5; i++) iqual_front_[i] = 1;
2211 iqual_back_ = 1;
2212 }
2213 if(debug_ == 4){
2214 std::cout<< "fillTds_back> mass "<<trk->getMass(2)<<" ndf[0][l_mass] "<<trk->getNdf(0,l_mass)<<endl;
2215 std::cout<<"ndf_back "<< track.ndf_back() << " chi2_back " << track.chiSq_back()<<endl;
2216 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;
2217 }
2218
2219 if (track.ndf_back() > 5 && track.chiSq_back() > 0 &&
2220 track.Ea()[0][0] > 0 && track.Ea()[1][1] > 0 &&
2221 track.Ea()[2][2] > 0 && track.Ea()[3][3] > 0 &&
2222 track.Ea()[4][4] > 0 && fabs(track.a()[0]) < DBL_MAX &&
2223 fabs(track.a()[1]) < DBL_MAX && fabs(track.a()[2]) < DBL_MAX &&
2224 fabs(track.a()[3]) < DBL_MAX && fabs(track.a()[4]) < DBL_MAX && iqual_front_[l_mass] && iqual_back_){
2225
2226 // chisq ( for backward filter)
2227 //std::cout<<"begin to fillTds_back track no. : "<<(++Tds_back_no)<<std::endl;
2228
2229
2230 HelixSegRefVec helixsegrefvec;
2231 for (vector<KalFitHelixSeg>::iterator it = track.HelixSegs().begin(); it!=track.HelixSegs().end();it ++)
2232 {
2233
2234 //std::cout<<" alpha of KalFitHelixSeg: "<<it->alpha()<<std::endl;
2235 //std::cout<<" doca1 of KalFitHelixSeg: "<<(it->approach(*(it->HitMdc()),false))<<std::endl;
2236
2237 it->pivot(IP);
2238
2239 //std::cout<<" doca2 of KalFitHelixSeg: "<<(it->approach(*(it->HitMdc()),false))<<std::endl;
2240
2241 RecMdcKalHelixSeg* helixseg = new RecMdcKalHelixSeg;
2242 helixseg->setResIncl(it->residual_include());
2243 helixseg->setResExcl(it->residual_exclude());
2244 if(debug_ == 4) {
2245 std::cout<<"helixseg->Res_inc ..."<<helixseg->getResIncl()<<std::endl;
2246 }
2247 helixseg->setDrIncl(it->a_include()[0]);
2248 helixseg->setFi0Incl(it->a_include()[1]);
2249 helixseg->setCpaIncl(it->a_include()[2]);
2250 helixseg->setDzIncl(it->a_include()[3]);
2251 helixseg->setTanlIncl(it->a_include()[4]);
2252
2253
2254 helixseg->setDrExcl(it->a_exclude()[0]);
2255 helixseg->setFi0Excl(it->a_exclude()[1]);
2256 helixseg->setCpaExcl(it->a_exclude()[2]);
2257 helixseg->setDzExcl(it->a_exclude()[3]);
2258 helixseg->setTanlExcl(it->a_exclude()[4]);
2259
2260 helixseg->setHelixIncl(it->a_include());
2261 helixseg->setErrorIncl(it->Ea_include());
2262
2263 //Helix temp(IP, it->a(), it->Ea());
2264
2265 //std::cout<<" doca3 of KalFitHelixSeg: "<<(temp.approach(*(it->HitMdc()),false))<<std::endl;
2266
2267 helixseg->setHelixExcl(it->a_exclude());
2268 helixseg->setErrorExcl(it->Ea_exclude());
2269 helixseg->setLayerId(it->layer());
2270
2271 if(debug_ == 4) {
2272 std::cout<<"KalFitHelixSeg track id .."<<it->HitMdc()->rechitptr()->getTrkId()<<std::endl;
2273 std::cout<<"helixseg a: "<<it->a()<<std::endl;
2274 std::cout<<"helixseg a_excl: "<<helixseg->getHelixExcl()<<std::endl;
2275 std::cout<<"helixseg a_incl: "<<helixseg->getHelixIncl()<<std::endl;
2276
2277 std::cout<<"helixseg Ea: "<<it->Ea()<<std::endl;
2278 std::cout<<"helixseg Ea_excl: "<<helixseg->getErrorExcl()<<std::endl;
2279 std::cout<<"helixseg Ea_incl: "<<helixseg->getErrorIncl()<<std::endl;
2280
2281 std::cout<<"helixseg layer: "<<it->layer()<<std::endl;
2282 }
2283
2284
2285 helixseg->setTrackId(it->HitMdc()->rechitptr()->getTrkId());
2286 helixseg->setMdcId(it->HitMdc()->rechitptr()->getMdcId());
2287 helixseg->setFlagLR(it->HitMdc()->LR());
2288 helixseg->setTdc(it->HitMdc()->rechitptr()->getTdc());
2289 helixseg->setAdc(it->HitMdc()->rechitptr()->getAdc());
2290 helixseg->setZhit(it->HitMdc()->rechitptr()->getZhit());
2291 helixseg->setTof(it->tof());
2292 helixseg->setDocaIncl(it->doca_include());
2293 helixseg->setDocaExcl(it->doca_exclude());
2294 helixseg->setDD(it->dd());
2295 helixseg->setEntra(it->HitMdc()->rechitptr()->getEntra());
2296 helixseg->setDT(it->dt());
2297 segcol->push_back(helixseg);
2298 SmartRef<RecMdcKalHelixSeg> refhelixseg(helixseg);
2299 helixsegrefvec.push_back(refhelixseg);
2300
2301 if(ntuple_&8){
2302 m_docaInc = helixseg -> getDocaIncl();
2303 m_docaExc = helixseg -> getDocaExcl();
2304 m_residualInc = helixseg -> getResIncl();
2305 m_residualExc = helixseg -> getResExcl();
2306 m_dd = helixseg -> getDD();
2307 m_lr = helixseg->getFlagLR();
2308 m_tdrift = helixseg -> getDT();
2309 m_layerid = helixseg -> getLayerId();
2310 m_yposition= it->HitMdc()->wire().fwd().y();
2311 m_eventNo = myEventNo;
2312 StatusCode sc6 = m_nt6->write();
2313 if( sc6.isFailure() ) cout<<"Ntuple6 helixseg filling failed!"<<endl;
2314
2315 }
2316 }
2317
2318 trk->setVecHelixSegs(helixsegrefvec, l_mass);
2319 if(debug_ == 4) {
2320 std::cout<<"trk->getVecHelixSegs size..."<<(trk->getVecHelixSegs()).size()<<std::endl;
2321 }
2322 trk->setStat(0,1,l_mass);
2323 trk->setChisq(track.chiSq_back(),1,l_mass);
2324 trk->setNdf(track.ndf_back()-5,1,l_mass);
2325 // add setNhits ,maybe some problem
2326 trk->setNhits(track.ndf_back(),l_mass);
2327 if(!(track.ndf_back()==track.HelixSegs().size())) {
2328 std::cout<<"THEY ARE NOT EQUALL!!!"<<std::endl;
2329 }
2330 trk->setLength(track.pathip(),l_mass);
2331 if(debug_ == 4) {
2332 std::cout<<"l_mass "<<l_mass<<" path set as "<<track.pathip()<<endl;
2333 }
2334 trk->setTof(track.tof(),l_mass);
2336 if(l_mass == 3) trk->setTof(track.tof_kaon(),l_mass);
2337 if(l_mass == 4) trk->setTof(track.tof_proton(),l_mass);
2338 }
2339 // Path length in each MDC layer :
2340 if (pathl_)
2341 for (int i = 0; i<43; i++) {
2342 trk->setPathl(track.pathl()[i],i);
2343 }
2344 trk->setLHelix(track.a(),l_mass);
2345 trk->setLError(track.Ea(),l_mass);
2346 trk->setLPivot(track.pivot(),l_mass);
2347
2348 trk->setLPoint(track.point_last(),l_mass);
2349 trk->setPathSM(track.getPathSM(),l_mass);
2350 trk->setTof(track.getTofSM(),l_mass);
2351 trk->setFiTerm(track.getFiTerm(),l_mass);
2352 double a_trasan[5], ea_trasan[15];
2353 for( int i =0 ; i <5; i++){
2354 a_trasan[i] = TrasanTRK.helix[i];
2355 }
2356 for( int j =0 ; j <15; j++){
2357 ea_trasan[j] = TrasanTRK.helix[j];
2358 }
2359 trk->setTHelix(a_trasan);
2360 trk->setTError(ea_trasan);
2361
2362 if(4 == debug_){
2363 std::cout<<" last pivot: "<< trk->getLPivot(0)<<std::endl;
2364 std::cout<<" pathl in SM: "<< trk->getPathSM(0)<<std::endl;
2365 std::cout<<" fiTerm: "<< trk->getFiTerm(0)<<std::endl;
2366 std::cout<<" last point: "<< trk->getLPoint(0)<<std::endl;
2367 }
2368
2369 } else {
2370
2371 if(debug_==4) cout<<"ALARM: FillTds_back Not refit with KalFilter!!!"<<endl;
2372 // NOT refit with Kalman filter :
2373 trk->setStat(1,1,l_mass);
2374
2375 HepPoint3D piv(TrasanTRK.pivot[0],
2376 TrasanTRK.pivot[1],
2377 TrasanTRK.pivot[2]);
2378
2379 HepVector a(5);
2380 for(int i = 0; i < 5; i++)
2381 a[i] = TrasanTRK.helix[i];
2382
2383 HepSymMatrix ea(5);
2384 for(int i = 0, k = 0; i < 5; i++) {
2385 for(int j = 0; j <= i; j++) {
2386 ea[i][j] = matrixg_*TrasanTRK.error[k++];
2387 ea[j][i] = ea[i][j];
2388 }
2389 }
2390
2391 KalFitTrack track_rep(piv, a, ea, lead_,
2392 TrasanTRK.chiSq, TrasanTRK.nhits);
2393 double fiTerm = TrasanTRK.fiTerm;
2394
2395 double fi0 = track_rep.phi0();
2396 HepPoint3D xc(track_rep.kappa()/fabs(track_rep.kappa())*
2397 track_rep.center() );
2398 double x = xc.x();
2399 double y = xc.y();
2400 double phi_x;
2401 if( fabs( x ) > 1.0e-10 ){
2402 phi_x = atan2( y, x );
2403 if( phi_x < 0 ) phi_x += 2*M_PI;
2404 } else {
2405 phi_x = ( y > 0 ) ? M_PI_4: 3.0*M_PI_4;
2406 }
2407 if(debug_ == 4) cout<<"fiterm "<<fiTerm<<" fi0 "<<fi0<<" phi_x "<<phi_x<<endl;
2408 double dphi = fabs( fiTerm + fi0 - phi_x );
2409 if( dphi >= 2*M_PI ) dphi -= 2*M_PI;
2410 double tanl = track_rep.tanl();
2411 double cosl_inv = sqrt( tanl*tanl + 1.0 );
2412 if(debug_ == 4) {
2413 cout<<"tanl= "<<tanl<<" radius "<<track_rep.radius()<<" dphi "<<dphi<<endl;
2414 cout<<" cosl_inv "<<cosl_inv<<" radius_numf "<<track_rep.radius_numf()<<endl;
2415 }
2416 double track_len(fabs( track_rep.radius() * dphi * cosl_inv ));
2417 double light_speed( 29.9792458 ); // light speed in cm/nsec
2418 double pt( 1.0 / track_rep.kappa() );
2419 double p( pt * sqrt( 1.0 + tanl*tanl ) );
2420
2421
2422 // chisq (2 : for backward filter)
2423
2424 trk->setStat(1,1,l_mass);
2425 trk->setChisq(TrasanTRK.chiSq,1,l_mass);
2426 if(debug_ == 4) {
2427 std::cout<<".....fillTds_back...chiSq..."<< TrasanTRK.chiSq<<std::endl;
2428 std::cout<<"...track_len..."<<track_len<<" ndf[1] "<< trk->getNdf(0,l_mass)<<std::endl;
2429 }
2430 trk->setNdf(TrasanTRK.nhits-5,1,l_mass);
2431 trk->setLength(track_len,l_mass);
2432 double mass_over_p( KalFitTrack::mass(l_mass)/ p );
2433 double beta( 1.0 / sqrt( 1.0 + mass_over_p * mass_over_p ) );
2434 trk->setTof(track_len / ( light_speed * beta ), l_mass) ;
2435
2436 track_rep.pivot(IP);
2437
2438 trk->setLHelix(track_rep.a(),l_mass);
2439 trk->setLError(track_rep.Ea(),l_mass);
2440 trk->setLPivot(track.pivot(),l_mass);
2441
2442 /// right???
2443 trk->setLPoint(track.point_last(),l_mass);
2444 trk->setPathSM(track.getPathSM(),l_mass);
2445 trk->setTof(track.getTofSM(),l_mass);
2446 trk->setFiTerm(track.getFiTerm(),l_mass);
2447 trk->setTHelix(track_rep.a());
2448 trk->setTError(track_rep.Ea());
2449
2450 }
2451
2452 // test--------
2453 if(debug_ == 4) {
2454 cout<<"Now let us see results after smoothering at IP:........."<<endl;
2455 cout << " dr = " << track.a()[0]
2456 << ", Er_dr = " << sqrt(track.Ea()[0][0]) << std::endl;
2457 cout<< " phi0 = " << track.a()[1]
2458 << ", Er_phi0 = " << sqrt(track.Ea()[1][1]) << std::endl;
2459 cout << " PT = " << 1/track.a()[2]
2460 << ", Er_kappa = " << sqrt(track.Ea()[2][2]) << std::endl;
2461 cout << " dz = " << track.a()[3]
2462 << ", Er_dz = " << sqrt(track.Ea()[3][3]) << std::endl;
2463 cout << " tanl = " << track.a()[4]
2464 << ", Er_tanl = " << sqrt(track.Ea()[4][4]) << std::endl;
2465 cout << " Ea = " << track.Ea() <<endl;
2466 }
2467 // test end ----------
2468}
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 2470 of file KalFitAlg.cxx.

2473{
2474
2475 HepPoint3D IP(0,0,0);
2476
2477 // attention the pivot problem of the HelixSeg ... ???
2478 //track.pivot(IP);
2479 // Fit quality
2480 //int iqual(1);
2481 //if ((trk->getNdf(0,2))-(track.ndf_back()-5)>5)
2482 // form getNdf(0,2) to getNdf(0,1) for muon hypothesis
2483
2484 iqual_back_ = 1;
2485 if ((trk->getNdf(0,l_mass))-(track.ndf_back()-5)>5){
2486 iqual_back_ = 0;
2487 }
2488
2489 if(debug_ == 4){
2490 std::cout<< "fillTds_back> mass "<<trk->getMass(2)<<" ndf[0][l_mass] "<<trk->getNdf(0,l_mass)<<endl;
2491 std::cout<<"ndf_back "<< track.ndf_back() << " chi2_back " << track.chiSq_back()<<endl;
2492 }
2493
2494
2495 if (track.ndf_back() > 5 && track.chiSq_back() > 0 &&
2496 track.Ea()[0][0] > 0 && track.Ea()[1][1] > 0 &&
2497 track.Ea()[2][2] > 0 && track.Ea()[3][3] > 0 &&
2498 track.Ea()[4][4] > 0 && fabs(track.a()[0]) < DBL_MAX &&
2499 fabs(track.a()[1]) < DBL_MAX && fabs(track.a()[2]) < DBL_MAX &&
2500 fabs(track.a()[3]) < DBL_MAX && fabs(track.a()[4]) < DBL_MAX && iqual_front_[l_mass] && iqual_back_){
2501
2502 // chisq ( for backward filter)
2503 //std::cout<<"begin to fillTds_back track no. : "<<(++Tds_back_no)<<std::endl;
2504
2505
2506 HelixSegRefVec helixsegrefvec;
2507 for (vector<KalFitHelixSeg>::iterator it = track.HelixSegs().begin(); it!=track.HelixSegs().end();it ++)
2508 {
2509
2510 //std::cout<<" alpha of KalFitHelixSeg: "<<it->alpha()<<std::endl;
2511 //std::cout<<" doca1 of KalFitHelixSeg: "<<(it->approach(*(it->HitMdc()),false))<<std::endl;
2512
2513 it->pivot(IP);
2514
2515 //std::cout<<" doca2 of KalFitHelixSeg: "<<(it->approach(*(it->HitMdc()),false))<<std::endl;
2516
2517 RecMdcKalHelixSeg* helixseg = new RecMdcKalHelixSeg;
2518 helixseg->setResIncl(it->residual_include());
2519 helixseg->setResExcl(it->residual_exclude());
2520 if(debug_ == 4) {
2521 std::cout<<"helixseg->Res_inc ..."<<helixseg->getResIncl()<<std::endl;
2522 }
2523 // helixseg->setDrIncl(it->a_include()[0]);
2524 // helixseg->setFi0Incl(it->a_include()[1]);
2525 // helixseg->setCpaIncl(it->a_include()[2]);
2526 // helixseg->setDzIncl(it->a_include()[3]);
2527 // helixseg->setTanlIncl(it->a_include()[4]);
2528 //
2529 //
2530 // helixseg->setDrExcl(it->a_exclude()[0]);
2531 // helixseg->setFi0Excl(it->a_exclude()[1]);
2532 // helixseg->setCpaExcl(it->a_exclude()[2]);
2533 // helixseg->setDzExcl(it->a_exclude()[3]);
2534 // helixseg->setTanlExcl(it->a_exclude()[4]);
2535
2536 helixseg->setHelixIncl(it->a_include());
2537 //helixseg->setErrorIncl(it->Ea_include());
2538
2539 //Helix temp(IP, it->a(), it->Ea());
2540
2541 //std::cout<<" doca3 of KalFitHelixSeg: "<<(temp.approach(*(it->HitMdc()),false))<<std::endl;
2542
2543 helixseg->setHelixExcl(it->a_exclude());
2544 //helixseg->setErrorExcl(it->Ea_exclude());
2545 //helixseg->setLayerId(it->layer());
2546
2547 if(debug_ == 4) {
2548 std::cout<<"KalFitHelixSeg track id .."<<it->HitMdc()->rechitptr()->getTrkId()<<std::endl;
2549 std::cout<<"helixseg a: "<<it->a()<<std::endl;
2550 std::cout<<"helixseg a_excl: "<<helixseg->getHelixExcl()<<std::endl;
2551 std::cout<<"helixseg a_incl: "<<helixseg->getHelixIncl()<<std::endl;
2552
2553 std::cout<<"helixseg Ea: "<<it->Ea()<<std::endl;
2554 std::cout<<"helixseg Ea_excl: "<<helixseg->getErrorExcl()<<std::endl;
2555 std::cout<<"helixseg Ea_incl: "<<helixseg->getErrorIncl()<<std::endl;
2556
2557 std::cout<<"helixseg layer: "<<it->layer()<<std::endl;
2558 }
2559
2560
2561 helixseg->setTrackId(it->HitMdc()->rechitptr()->getTrkId());
2562 helixseg->setMdcId(it->HitMdc()->rechitptr()->getMdcId());
2563 helixseg->setFlagLR(it->HitMdc()->LR());
2564 helixseg->setTdc(it->HitMdc()->rechitptr()->getTdc());
2565 helixseg->setAdc(it->HitMdc()->rechitptr()->getAdc());
2566 helixseg->setZhit(it->HitMdc()->rechitptr()->getZhit());
2567 helixseg->setTof(it->tof());
2568 helixseg->setDocaIncl(it->doca_include());
2569 helixseg->setDocaExcl(it->doca_exclude());
2570 helixseg->setDD(it->dd());
2571 helixseg->setEntra(it->HitMdc()->rechitptr()->getEntra());
2572 helixseg->setDT(it->dt());
2573 //cout<<"setDT( "<<it->dt()<<" )"<<endl;
2574 segcol->push_back(helixseg);
2575 SmartRef<RecMdcKalHelixSeg> refhelixseg(helixseg);
2576 helixsegrefvec.push_back(refhelixseg);
2577 if(ntuple_&8){
2578 m_docaInc = helixseg -> getDocaIncl();
2579 m_docaExc = helixseg -> getDocaExcl();
2580 m_residualInc = helixseg -> getResIncl();
2581 m_residualExc = helixseg -> getResExcl();
2582 m_dd = helixseg -> getDD();
2583 m_lr = helixseg->getFlagLR();
2584 m_tdrift = helixseg -> getDT();
2585 m_layerid = helixseg -> getLayerId();
2586 m_yposition= it->HitMdc()->wire().fwd().y();
2587 m_eventNo = myEventNo;
2588 StatusCode sc6 = m_nt6->write();
2589 if( sc6.isFailure() ) cout<<"Ntuple6 helixseg filling failed!"<<endl;
2590
2591 }
2592 }
2593
2594 trk->setVecHelixSegs(helixsegrefvec, l_mass);
2595 //cout<<"setVecHelixSegs with Kalman hits"<<endl;
2596 if(debug_ == 4) {
2597 std::cout<<"trk->getVecHelixSegs size..."<<(trk->getVecHelixSegs()).size()<<std::endl;
2598 }
2599 trk->setStat(0,1,l_mass);
2600 trk->setChisq(track.chiSq_back(),1,l_mass);
2601 trk->setNdf(track.ndf_back()-5,1,l_mass);
2602 // add setNhits ,maybe some problem
2603 trk->setNhits(track.ndf_back(),l_mass);
2604 if(!(track.ndf_back()==track.HelixSegs().size())) {
2605 std::cout<<__FILE__<<": "<<__LINE__<<": "<<"track.ndf_back()!=track.HelixSegs().size() !!!"<<std::endl;
2606 }
2607 trk->setLength(track.pathip(),l_mass);
2608 if(debug_ == 4) {
2609 std::cout<<"l_mass "<<l_mass<<" path set as "<<track.pathip()<<endl;
2610 }
2611 trk->setTof(track.tof(),l_mass);
2613 if(l_mass == 3) trk->setTof(track.tof_kaon(),l_mass);
2614 if(l_mass == 4) trk->setTof(track.tof_proton(),l_mass);
2615 }
2616 // Path length in each MDC layer :
2617 if (pathl_)
2618 for (int i = 0; i<43; i++) {
2619 trk->setPathl(track.pathl()[i],i);
2620 }
2621 trk->setLHelix(track.a(),l_mass);
2622 trk->setLError(track.Ea(),l_mass);
2623 trk->setLPivot(track.pivot(),l_mass);
2624
2625 trk->setLPoint(track.point_last(),l_mass);
2626 trk->setPathSM(track.getPathSM(),l_mass);
2627 trk->setTof(track.getTofSM(),l_mass);
2628 trk->setFiTerm(track.getFiTerm(),l_mass);
2629 double a_trasan[5], ea_trasan[15];
2630 for( int i =0 ; i <5; i++){
2631 a_trasan[i] = TrasanTRK.helix[i];
2632 }
2633 for( int j =0 ; j <15; j++){
2634 ea_trasan[j] = TrasanTRK.helix[j];
2635 }
2636 trk->setTHelix(a_trasan);
2637 trk->setTError(ea_trasan);
2638
2639 if(4 == debug_){
2640 std::cout<<" last pivot: "<< trk->getLPivot(0)<<std::endl;
2641 std::cout<<" pathl in SM: "<< trk->getPathSM(0)<<std::endl;
2642 std::cout<<" fiTerm: "<< trk->getFiTerm(0)<<std::endl;
2643 std::cout<<" last point: "<< trk->getLPoint(0)<<std::endl;
2644 }
2645
2646 } else {
2647
2648 if(debug_==4) cout<<"ALARM: FillTds_back Not refit with KalFilter!!!"<<endl;
2649 // NOT refit with Kalman filter :
2650 trk->setStat(1,1,l_mass);
2651
2652 HepPoint3D piv(TrasanTRK.pivot[0],
2653 TrasanTRK.pivot[1],
2654 TrasanTRK.pivot[2]);
2655
2656 HepVector a(5);
2657 for(int i = 0; i < 5; i++)
2658 a[i] = TrasanTRK.helix[i];
2659
2660 HepSymMatrix ea(5);
2661 for(int i = 0, k = 0; i < 5; i++) {
2662 for(int j = 0; j <= i; j++) {
2663 ea[i][j] = matrixg_*TrasanTRK.error[k++];
2664 ea[j][i] = ea[i][j];
2665 }
2666 }
2667
2668 KalFitTrack track_rep(piv, a, ea, lead_,
2669 TrasanTRK.chiSq, TrasanTRK.nhits);
2670 double fiTerm = TrasanTRK.fiTerm;
2671
2672 double fi0 = track_rep.phi0();
2673 HepPoint3D xc(track_rep.kappa()/fabs(track_rep.kappa())*
2674 track_rep.center() );
2675 double x = xc.x();
2676 double y = xc.y();
2677 double phi_x;
2678 if( fabs( x ) > 1.0e-10 ){
2679 phi_x = atan2( y, x );
2680 if( phi_x < 0 ) phi_x += 2*M_PI;
2681 } else {
2682 phi_x = ( y > 0 ) ? M_PI_4: 3.0*M_PI_4;
2683 }
2684 if(debug_ == 4) cout<<"fiterm "<<fiTerm<<" fi0 "<<fi0<<" phi_x "<<phi_x<<endl;
2685 double dphi = fabs( fiTerm + fi0 - phi_x );
2686 if( dphi >= 2*M_PI ) dphi -= 2*M_PI;
2687 double tanl = track_rep.tanl();
2688 double cosl_inv = sqrt( tanl*tanl + 1.0 );
2689 if(debug_ == 4) {
2690 cout<<"tanl= "<<tanl<<" radius "<<track_rep.radius()<<" dphi "<<dphi<<endl;
2691 cout<<" cosl_inv "<<cosl_inv<<" radius_numf "<<track_rep.radius_numf()<<endl;
2692 }
2693 //double track_len(fabs( track_rep.radius() * dphi * cosl_inv ));
2694 double track_len(fabs( track_rep.radius() * fiTerm * cosl_inv )); // 2010-11-26 added by wangll
2695 //cout<<"track radius : "<<track_rep.radius()<<" "<<track.radius()<<endl;
2696 double light_speed( 29.9792458 ); // light speed in cm/nsec
2697 double pt( 1.0 / track_rep.kappa() );
2698 double p( pt * sqrt( 1.0 + tanl*tanl ) );
2699
2700
2701 // chisq (2 : for backward filter)
2702
2703 trk->setStat(1,1,l_mass);
2704 trk->setChisq(TrasanTRK.chiSq,1,l_mass);
2705 if(debug_ == 4) {
2706 std::cout<<".....fillTds_back...chiSq..."<< TrasanTRK.chiSq<<std::endl;
2707 std::cout<<"...track_len..."<<track_len<<" ndf[1] "<< trk->getNdf(0,l_mass)<<std::endl;
2708 }
2709 trk->setNdf(TrasanTRK.nhits-5,1,l_mass);
2710 trk->setLength(track_len,l_mass);
2711 double mass_over_p( KalFitTrack::mass(l_mass)/ p );
2712 double beta( 1.0 / sqrt( 1.0 + mass_over_p * mass_over_p ) );
2713 trk->setTof(track_len / ( light_speed * beta ), l_mass) ;
2714
2715 //track_rep.pivot(IP);
2716 HepPoint3D LPiovt = track_rep.x(fiTerm);
2717 track_rep.pivot(LPiovt);
2718
2719 trk->setLHelix(track_rep.a(),l_mass);
2720 trk->setLError(track_rep.Ea(),l_mass);
2721 //trk->setLPivot(track.pivot(),l_mass); // commented 2010-09-02
2722 //trk->setLPivot(IP, l_mass); // add 2010-09-02
2723 trk->setLPivot(LPiovt, l_mass); // add 2010-11-25
2724
2725 /// right???
2726 trk->setLPoint(track.point_last(),l_mass);
2727 //trk->setPathSM(track.getPathSM(),l_mass);// commented 2010-11-25 by wangll
2728 trk->setPathSM(track_len,l_mass);// added 2010-11-25 by wangll
2729 //trk->setTof(track.getTofSM(),l_mass);// commented 2010-11-25 by wangll
2730 // trk->setFiTerm(track.getFiTerm(),l_mass); // commented 2010-11-25 by wangll
2731 trk->setFiTerm(fiTerm,l_mass); // added by wangll 2010-11-25
2732 trk->setTHelix(track_rep.a());
2733 trk->setTError(track_rep.Ea());
2734
2735 /*
2736 // --- check track id by wangll 2010-08-15
2737 if(l_mass==lead_) {
2738 //cout<<" ----- bad smooth track -----"<<endl;
2739 //cout<<"l_mass = "<<l_mass<<endl;
2740 int trkId = trk->trackId();
2741 //
2742 // cout<<"track id = "<<trkId<<endl;
2743 // cout<<"THelix: "<<trk->getTHelix()<<endl;
2744 // cout<<"FHelix: "<<trk->getFHelix()<<endl;
2745 // cout<<"size of VecHelixSegs: "<<trk->getVecHelixSegs().size()<<endl;
2746 //
2747 SmartDataPtr<RecMdcTrackCol> mdcTrkCol(eventSvc(),"/Event/Recon/RecMdcTrackCol");
2748 //int nMdcTrk = mdcTrkCol.size();
2749 //cout<<"number of Mdc Tracks: "<<nMdcTrk<<endl;
2750 RecMdcTrackCol::iterator iter_mdcTrk = mdcTrkCol->begin();
2751 bool findMdcTrk = false;
2752 for(; iter_mdcTrk != mdcTrkCol->end(); iter_mdcTrk++) {
2753 if(trkId==(*iter_mdcTrk)->trackId()) {
2754 findMdcTrk = true;
2755 break;
2756 }
2757 }
2758 if(findMdcTrk) {
2759 HitRefVec mdcVecHits = (*iter_mdcTrk)->getVecHits();
2760 int nHits = mdcVecHits.size();
2761 //cout<<"number of Mdc Hits: "<<nHits<<endl;
2762 HelixSegRefVec helixsegrefvec;
2763 HitRefVec::iterator iter_mdcHit = mdcVecHits.begin();
2764 for(int iii=0; iter_mdcHit!=mdcVecHits.end(); iter_mdcHit++,iii++) {
2765 RecMdcKalHelixSeg* helixseg = new RecMdcKalHelixSeg;
2766 //cout<<"hit "<<iii<<endl;
2767 //cout<<"getMdcId: "<<(*iter_mdcHit)->getMdcId()<<endl;
2768 //cout<<"getAdc: "<<(*iter_mdcHit)->getAdc()<<endl;
2769 //cout<<"getTdc: "<<(*iter_mdcHit)->getTdc()<<endl;
2770 //cout<<"getDriftT: "<<(*iter_mdcHit)->getDriftT()<<endl;
2771 //cout<<"getZhit: "<<(*iter_mdcHit)->getZhit()<<endl;
2772 //cout<<"getFlagLR: "<<(*iter_mdcHit)->getFlagLR()<<endl;
2773 //cout<<"getDriftDistLeft: "<<(*iter_mdcHit)->getDriftDistLeft()<<endl;
2774 //cout<<"getDriftDistRight: "<<(*iter_mdcHit)->getDriftDistRight()<<endl;
2775 //cout<<"getDoca: "<<(*iter_mdcHit)->getDoca()<<endl;
2776 //cout<<"getEntra: "<<(*iter_mdcHit)->getEntra()<<endl;
2777 //
2778 helixseg->setMdcId((*iter_mdcHit)->getMdcId());
2779 helixseg->setAdc((*iter_mdcHit)->getAdc());
2780 helixseg->setTdc((*iter_mdcHit)->getTdc());
2781 helixseg->setZhit((*iter_mdcHit)->getZhit());
2782 helixseg->setFlagLR((*iter_mdcHit)->getFlagLR());
2783 if((*iter_mdcHit)->getFlagLR()==0) helixseg->setDD((*iter_mdcHit)->getDriftDistLeft());
2784 if((*iter_mdcHit)->getFlagLR()==1) helixseg->setDD((*iter_mdcHit)->getDriftDistRight());
2785 helixseg->setDocaIncl((*iter_mdcHit)->getDoca());
2786 helixseg->setEntra((*iter_mdcHit)->getEntra());
2787 helixseg->setDT((*iter_mdcHit)->getDriftT());
2788 segcol->push_back(helixseg);
2789 SmartRef<RecMdcKalHelixSeg> refhelixseg(helixseg);
2790 helixsegrefvec.push_back(refhelixseg);
2791 }
2792 trk->setVecHelixSegs(helixsegrefvec);
2793 cout<<"setVecHelixSegs with Mdc hits"<<endl;
2794 }
2795 else cout<<"not find the Mdc Track!";
2796 //cout<<"size of VecHelixSegs: "<<trk->getVecHelixSegs().size()<<endl;
2797 }
2798 */
2799
2800 }
2801
2802 // test--------
2803 if(debug_ == 4) {
2804 cout<<"Now let us see results after smoothering at IP:........."<<endl;
2805 cout << " dr = " << track.a()[0]
2806 << ", Er_dr = " << sqrt(track.Ea()[0][0]) << std::endl;
2807 cout<< " phi0 = " << track.a()[1]
2808 << ", Er_phi0 = " << sqrt(track.Ea()[1][1]) << std::endl;
2809 cout << " PT = " << 1/track.a()[2]
2810 << ", Er_kappa = " << sqrt(track.Ea()[2][2]) << std::endl;
2811 cout << " dz = " << track.a()[3]
2812 << ", Er_dz = " << sqrt(track.Ea()[3][3]) << std::endl;
2813 cout << " tanl = " << track.a()[4]
2814 << ", Er_tanl = " << sqrt(track.Ea()[4][4]) << std::endl;
2815 cout << " Ea = " << track.Ea() <<endl;
2816 }
2817 // test end ----------
2818}

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

1771{
1772 //cout<<"call fillTds_ip() done!"<<endl;
1773 HepPoint3D IP(0,0,0);
1774 track.pivot(IP);
1775
1776 if (debug_ == 4&& l_mass==lead_) {
1777 cout << "fillTds_IP>......"<<endl;
1778 cout << " dr = " << track.a()[0]
1779 << ", Er_dr = " << sqrt(track.Ea()[0][0]) << std::endl;
1780 cout << " phi0 = " << track.a()[1]
1781 << ", Er_phi0 = " << sqrt(track.Ea()[1][1]) << std::endl;
1782 cout << " PT = " << 1/track.a()[2]
1783 << ", Er_kappa =" << sqrt(track.Ea()[2][2]) << std::endl;
1784 cout << " dz = " << track.a()[3]
1785 << ", Er_dz = " << sqrt(track.Ea()[3][3]) << std::endl;
1786 cout << " tanl = " << track.a()[4]
1787 << ", Er_tanl = " << sqrt(track.Ea()[4][4]) << std::endl;
1788 }
1789
1790
1791 //cout<<"start to get the event!"<<endl;
1792
1793
1794
1795
1796 //cout<<"get the event done!"<<endl;
1797
1798/*
1799 if(ntuple_&256){
1800
1801 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
1802 if(!eventHeader){
1803 cout<<"Open event header file failed!"<<endl;
1804 }
1805// cout<<__LINE__<<endl;
1806 int run = eventHeader->runNumber();
1807// cout<<__LINE__<<endl;
1808 //m_run_kal = eventHeader->runNumber();
1809 m_run_kal = run;
1810// cout<<__LINE__<<endl;
1811 m_event_kal = eventHeader->eventNumber();
1812// cout<<__LINE__<<endl;
1813
1814 if(l_mass==0){
1815// cout<<__LINE__<<endl;
1816 m_dropedHits_kal_e = TrasanTRK.nhits+TrasanTRK.nclus*2-track.nchits();
1817// cout<<__LINE__<<endl;
1818 m_kappa2_kal_e = TrasanTRK.helix[2]*track.a()[2];
1819// cout<<__LINE__<<endl;
1820 m_trackNhits_kal_e = track.nchits();
1821// cout<<__LINE__<<endl;
1822 m_trackNster_kal_e = track.nster();
1823// cout<<__LINE__<<endl;
1824 m_trackNaxis_kal_e = track.nchits()-track.nster();
1825// cout<<__LINE__<<endl;
1826 m_chi2_kal_e = track.chiSq();
1827// cout<<__LINE__<<endl;
1828 m_Ea00_kal_e = track.Ea()[0][0];
1829// cout<<__LINE__<<endl;
1830 m_Ea11_kal_e = track.Ea()[1][1];
1831// cout<<__LINE__<<endl;
1832 m_Ea22_kal_e = track.Ea()[2][2];
1833// cout<<__LINE__<<endl;
1834 m_Ea33_kal_e = track.Ea()[3][3];
1835// cout<<__LINE__<<endl;
1836 m_Ea44_kal_e = track.Ea()[4][4];
1837// cout<<__LINE__<<endl;
1838
1839 }
1840 else if(l_mass==1){
1841 m_dropedHits_kal_mu = TrasanTRK.nhits+TrasanTRK.nclus*2-track.nchits();
1842 m_kappa2_kal_mu = TrasanTRK.helix[2]*track.a()[2];
1843 m_trackNhits_kal_mu = track.nchits();
1844 m_trackNster_kal_mu = track.nster();
1845 m_trackNaxis_kal_mu = track.nchits()-track.nster();
1846 m_chi2_kal_mu = track.chiSq();
1847 m_Ea00_kal_mu = track.Ea()[0][0];
1848 m_Ea11_kal_mu = track.Ea()[1][1];
1849 m_Ea22_kal_mu = track.Ea()[2][2];
1850 m_Ea33_kal_mu = track.Ea()[3][3];
1851 m_Ea44_kal_mu = track.Ea()[4][4];
1852
1853
1854 }
1855 else if(l_mass==2){
1856 m_dropedHits_kal_pi = TrasanTRK.nhits+TrasanTRK.nclus*2-track.nchits();
1857 m_kappa2_kal_pi = TrasanTRK.helix[2]*track.a()[2];
1858 m_trackNhits_kal_pi = track.nchits();
1859 m_trackNster_kal_pi = track.nster();
1860 m_trackNaxis_kal_pi = track.nchits()-track.nster();
1861 m_chi2_kal_pi = track.chiSq();
1862 m_Ea00_kal_pi = track.Ea()[0][0];
1863 m_Ea11_kal_pi = track.Ea()[1][1];
1864 m_Ea22_kal_pi = track.Ea()[2][2];
1865 m_Ea33_kal_pi = track.Ea()[3][3];
1866 m_Ea44_kal_pi = track.Ea()[4][4];
1867
1868 }
1869 else if(l_mass==3){
1870 m_dropedHits_kal_k = TrasanTRK.nhits+TrasanTRK.nclus*2-track.nchits();
1871 m_kappa2_kal_k = TrasanTRK.helix[2]*track.a()[2];
1872 m_trackNhits_kal_k = track.nchits();
1873 m_trackNster_kal_k = track.nster();
1874 m_trackNaxis_kal_k = track.nchits()-track.nster();
1875 m_chi2_kal_k = track.chiSq();
1876 m_Ea00_kal_k = track.Ea()[0][0];
1877 m_Ea11_kal_k = track.Ea()[1][1];
1878 m_Ea22_kal_k = track.Ea()[2][2];
1879 m_Ea33_kal_k = track.Ea()[3][3];
1880 m_Ea44_kal_k = track.Ea()[4][4];
1881
1882 }
1883 else if(l_mass==4){
1884 m_dropedHits_kal_p = TrasanTRK.nhits+TrasanTRK.nclus*2-track.nchits();
1885 m_kappa2_kal_p = TrasanTRK.helix[2]*track.a()[2];
1886 m_trackNhits_kal_p = track.nchits();
1887 m_trackNster_kal_p = track.nster();
1888 m_trackNaxis_kal_p = track.nchits()-track.nster();
1889 m_chi2_kal_p = track.chiSq();
1890 m_Ea00_kal_p = track.Ea()[0][0];
1891 m_Ea11_kal_p = track.Ea()[1][1];
1892 m_Ea22_kal_p = track.Ea()[2][2];
1893 m_Ea33_kal_p = track.Ea()[3][3];
1894 m_Ea44_kal_p = track.Ea()[4][4];
1895
1896 }
1897
1898
1899
1900 //cout<<"fill the ntuple done!"<<endl;
1901
1902 //StatusCode sc7 = m_nt7 ->write();
1903
1904 //if(sc7.isFailure()) cout<<" Write Kalfit failure ntuple failed !"<<endl;
1905
1906 //cout<<"save the ntuple done!"<<endl;
1907 }
1908*/
1909
1910
1911 //if (TrasanTRK.nhits+TrasanTRK.nclus*2-track.nchits()>fitnocut_ ||
1912 if (TrasanTRK.ndf+5-track.nchits()>fitnocut_ ||
1913 TrasanTRK.helix[2]*track.a()[2]<0)
1914 iqual_front_[l_mass] = 0;
1915
1916
1917 if (track.nchits() > 5 && track.nster() > 1 &&
1918 track.nchits()-track.nster() > 2 && track.chiSq() > 0 &&
1919 track.Ea()[0][0] > 0 && track.Ea()[1][1] > 0 &&
1920 track.Ea()[2][2] > 0 && track.Ea()[3][3] > 0 &&
1921 track.Ea()[4][4] > 0 && iqual_front_[l_mass]) {
1922
1923 // fill track information
1924 double dr = track.a()[0];
1925 double phi0 = track.a()[1];
1926 double kappa = track.a()[2];
1927 double dz = track.a()[3];
1928 double tanl = track.a()[4];
1929
1930 // vertex of the track
1931 double vx = dr*cos(phi0);
1932 double vy = dr*sin(phi0);
1933 double vz = dz;
1934
1935 // see Belle note148 for the formulas
1936 // initial momentum of the track
1937 if(0==kappa) kappa = 10e-10;
1938 double px = -sin(phi0)/fabs(kappa);
1939 double py = cos(phi0)/fabs(kappa);
1940 double pz = tanl/fabs(kappa);
1941
1942 trk->setX(vx, l_mass);
1943 trk->setY(vy, l_mass);
1944 trk->setZ(vz, l_mass);
1945 trk->setPx(px, l_mass);
1946 trk->setPy(py, l_mass);
1947 trk->setPz(pz, l_mass);
1948
1949 const HepPoint3D poca(dr*cos(phi0),dr*sin(phi0),dz);
1950 trk->setPoca(poca,l_mass);
1951
1952 trk->setZHelix(track.a(),l_mass);
1953 trk->setZError(track.Ea(),l_mass);
1954
1955
1956 //set charge
1957 int charge=0;
1958 if (kappa > 0.0000000001)
1959 charge = 1;
1960 else if (kappa < -0.0000000001)
1961 charge = -1;
1962 trk->setCharge(charge,l_mass);
1963
1964 //set theta
1965 double ptot = sqrt(px*px+py*py+pz*pz);
1966 trk->setTheta(acos(pz/ptot),l_mass);
1967 }
1968
1969 else{
1970 //cout<<"copy Mdc Helix in fillTds_ip()"<<endl;
1971
1972 if(4==debug_) cout<<"track "<< track.trasan_id() <<", pid "<< l_mass <<" fails"<<endl;
1973
1974 // fill track information
1975 double dr = TrasanTRK.helix[0];
1976 double phi0 = TrasanTRK.helix[1];
1977 double kappa = TrasanTRK.helix[2];
1978 double dz = TrasanTRK.helix[3];
1979 double tanl = TrasanTRK.helix[4];
1980
1981 double vx = dr*cos(phi0);
1982 double vy = dr*sin(phi0);
1983 double vz = dz;
1984
1985 if(0==kappa) kappa = 10e-10;
1986 double px = -sin(phi0)/fabs(kappa);
1987 double py = cos(phi0)/fabs(kappa);
1988 double pz = tanl/fabs(kappa);
1989
1990 trk->setX(vx, l_mass);
1991 trk->setY(vy, l_mass);
1992 trk->setZ(vz, l_mass);
1993
1994 trk->setPx(px, l_mass);
1995 trk->setPy(py, l_mass);
1996 trk->setPz(pz, l_mass);
1997
1998 const HepPoint3D poca(dr*cos(phi0),dr*sin(phi0),dz);
1999
2000 trk->setPoca(poca,l_mass);
2001 //trk->setZHelix(TrasanTRK.helix,l_mass);
2002 //trk->setZError(TrasanTRK.error,l_mass);
2003 double a_trasan[5], ea_trasan[15];
2004 for( int i =0 ; i <5; i++){
2005 a_trasan[i] = TrasanTRK.helix[i];
2006 }
2007 for( int j =0 ; j <15; j++){
2008 ea_trasan[j] = TrasanTRK.error[j];
2009 }
2010 trk->setZHelix(a_trasan,l_mass);
2011 trk->setZError(ea_trasan,l_mass);
2012
2013 //set charge
2014 int charge=0;
2015 if (kappa > 0.0000000001)
2016 charge = 1;
2017 else if (kappa < -0.0000000001)
2018 charge = -1;
2019 trk->setCharge(charge,l_mass);
2020
2021 //set theta
2022 double ptot = sqrt(px*px+py*py+pz*pz);
2023 trk->setTheta(acos(pz/ptot),l_mass);
2024 }
2025
2026 if(4==debug_) {
2028 std::cout<<"px: "<<trk->px()<<" py: "<<trk->py()<<" pz: "<<trk->pz()<<std::endl;
2029 std::cout<<"vx: "<<trk->x()<<" vy: "<<trk->y()<<" vz: "<<trk->z()<<std::endl;
2030 }
2031}
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)
const double x() const

Referenced by complete_track(), and complete_track().

◆ fillTds_lead()

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

Definition at line 1674 of file KalFitAlg.cxx.

1675 {
1676
1677 HepPoint3D IP(0,0,0);
1678 track.pivot(IP);
1679 // Fit quality
1680 // int iqual(1);
1681 int trasster = TrasanTRK.nster, trakster = track.nster(),
1682 trasax(TrasanTRK.nhits-trasster), trakax(track.nchits()-trakster);
1683 //if (TrasanTRK.nhits-track.nchits()>fitnocut_ ||
1684 if(TrasanTRK.ndf+5-track.nchits()>fitnocut_ ||
1685 TrasanTRK.helix[2]*track.a()[2]<0)
1686 iqual_front_[l_mass] = 0;
1687 if (debug_ == 4) {
1688
1689 cout<<"Nhit from PR "<<TrasanTRK.nhits<<" nhit "<<track.nchits()<<endl;
1690 cout<< "trasster trakster trasax trakax TrasK trackK iqual"<<endl
1691 <<trasster<<" "<<trakster<<" "<<trasax<<" "<<trakax
1692 <<" "<<TrasanTRK.helix[2]<<" "<<track.a()[2]<<" "<<iqual_front_[l_mass]<<endl;
1693 cout<<"FillTds_lead> track.chiSq..."<<track.chiSq()<<" nchits "<<track.nchits()
1694 <<" nster "<<track.nster()<<" iqual_front_[l_mass] "<<iqual_front_[l_mass]<<" track.Ea "<<track.Ea()<<endl;
1695
1696 cout << " TRASAN stereo = " << trasster
1697 << " and KalFitTrack = " << trakster << std::endl;
1698 cout << " TRASAN axial = " << trasax
1699 << " and KalFitTrack = " << trakax << std::endl;
1700
1701 if (!iqual_front_[l_mass]) {
1702 cout << "...there is a problem during fit !! " << std::endl;
1703 if (trasster-trakster>5)
1704 cout << " because stereo " << trasster-trakster << std::endl;
1705 if (trasax-trakax >5)
1706 cout << " because axial " << std::endl;
1707 if (TrasanTRK.helix[2]*track.a()[2]<0)
1708 cout << " because kappa sign " << std::endl;
1709 }
1710 }
1711 // Protection : if any problem, we keep the original information !!!!
1712 if (track.nchits() > 5 && track.nster() > 1 &&
1713 track.nchits()-track.nster() > 2 && track.chiSq() > 0 &&
1714 track.Ea()[0][0] > 0 && track.Ea()[1][1] > 0 &&
1715 track.Ea()[2][2] > 0 && track.Ea()[3][3] > 0 &&
1716 track.Ea()[4][4] > 0 && iqual_front_[l_mass]) {
1717
1718 trk->setStat(0,0,l_mass);
1719 trk->setMass(track.mass(),l_mass);
1720 trk->setChisq(track.chiSq(),0,l_mass);
1721 trk->setNdf(track.nchits()-5,0,l_mass);
1722 trk->setNhits(track.nchits(),l_mass);
1723 //trkid
1724 trk->setTrackId(TrasanTRK.id);
1725
1726 if (debug_ == 4) cout<<" trasan id...1 "<<TrasanTRK.id<<endl;
1727
1728 trk->setFHelix(track.a(),l_mass);
1729 trk->setFError(track.Ea(),l_mass);
1730
1731 } else {
1732
1733 //cout<<"copy Mdc Helix in fillTds_lead()"<<endl;
1734
1735 if(debug_==4) cout<<"ALARM: FillTds_forMdc Not refit with KalFilter!!! lmass="<<l_mass<<endl;
1736 // NOT refit with Kalman filter :
1737 trk->setStat(1,0,l_mass);
1738 trk->setMass(KalFitTrack::mass(l_mass),l_mass);
1739
1740 // chisq & ndf
1741 trk->setChisq(TrasanTRK.chiSq,0,l_mass);
1742 //trk->setNdf(TrasanTRK.nhits-5,0,l_mass);
1743 trk->setNdf(TrasanTRK.ndf,0,l_mass);
1744 //trkid
1745 trk->setTrackId(TrasanTRK.id);
1746
1747 if (debug_ ==4) cout<<" trasan id...2 "<<TrasanTRK.id<<endl;
1748
1749 // nhits
1750 //trk->setNhits(TrasanTRK.nhits,l_mass);
1751 trk->setNhits(TrasanTRK.ndf+5,l_mass);
1752 double a_trasan[5], ea_trasan[15];
1753 for( int i =0 ; i <5; i++){
1754 a_trasan[i] = TrasanTRK.helix[i];
1755 }
1756 for( int j =0 ; j <15; j++){
1757 ea_trasan[j] = TrasanTRK.error[j];
1758 }
1759 trk->setFHelix(a_trasan,l_mass);
1760 trk->setFError(ea_trasan,l_mass);
1761 // trk->setFHelix(TrasanTRK.helix,l_mass);
1762 // trk->setFError(TrasanTRK.error,l_mass);
1763 }
1764}
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 3194 of file KalFitAlg.cxx.

3195{
3196
3197 if(debug_==4) {
3198 cout<<"**********************"<<endl;//wangll
3199 cout<<"filter pid type "<<l_mass<<endl;//wangll
3200 }
3201
3202 // retrieve Mdc geometry information
3203 IMdcGeomSvc* igeomsvc;
3204 StatusCode sc = Gaudi::svcLocator()->service("MdcGeomSvc", igeomsvc);
3205 if(sc==StatusCode::FAILURE) cout << "GeoSvc failing!!!!!!!SC=" << sc << endl;
3206 MdcGeomSvc* geomsvc = dynamic_cast<MdcGeomSvc*>(igeomsvc);
3207 if(!geomsvc){
3208 std::cout<<"ERROR OCCUR when dynamic_cast in KalFitTrack.cxx !!"<<std::endl;
3209 }
3210
3211 //Hep3Vector x0inner(track.pivot());
3212 HepVector pos_old(3,0);
3213 double r0kal_prec(0);
3214 int nhits_read(0);
3215 int nhit = track.HitsMdc().size();
3216 if(debug_ == 4) cout<<"filter_fwd..........111 nhit="<<nhit<<endl;
3217 for( int i=0 ; i < nhit; i++ ) {
3218 KalFitHitMdc& HitMdc = track.HitMdc(i);
3219 // veto on some hits :
3220 if (HitMdc.chi2()<0) continue;
3221 const KalFitWire& Wire = HitMdc.wire();
3222 int layerf = Wire.layer().layerId();
3223
3224 //std::cout<<"in layer: "<<layerf<<std::endl;
3225
3226 int wireid = Wire.geoID();
3227 nhits_read++;
3228 HepPoint3D fwd(Wire.fwd());
3229 HepPoint3D bck(Wire.bck());
3230 Hep3Vector wire = (CLHEP::Hep3Vector)fwd -(CLHEP::Hep3Vector)bck;
3231 KalmanFit::Helix work = *(KalmanFit::Helix*)&track;
3232 work.ignoreErrorMatrix();
3233 work.pivot((fwd + bck) * .5);
3234
3235 //std::cout<<" (fwd + bck) * .5: "<<(fwd + bck)*.5<<std::endl;
3236 //std::cout<<" track.x(0): "<<track.x(0)<<std::endl;
3237 //std::cout<<" work.x(0): "<<work.x(0)<<std::endl;
3238 //std::cout<<" bck: "<<bck<<std::endl;
3239
3240 HepPoint3D x0kal = (work.x(0).z() - bck.z())/ wire.z() * wire + bck;
3241
3242 if(4 == debug_) {
3243 std::cout<<" a="<<track.a()<<std::endl;
3244 std::cout<<" pivot="<<track.pivot()<<std::endl;
3245 std::cout<<" x0kal before sag: "<<x0kal<<std::endl;
3246 }
3247
3248 // Modification to take account of the wire sag :
3249 /*
3250 if (wsag_==1) {
3251 double A(1.2402E-6);
3252 if (nhits_read != 1 && r0kal_prec > RMW && x0kal.perp() < RMW)
3253 A = 8.5265E-7;
3254 HepPoint3D x0kal_up(x0kal);
3255 double length = sqrt(wire.x()*wire.x()+wire.z()*wire.z());
3256 double zp = (x0kal.z() - bck.z())*length/wire.z();
3257
3258 x0kal_up.setX(wire.x()*(x0kal.z()-bck.z())/wire.z()+bck.x());
3259 x0kal_up.setY((A*(zp-length)+wire.y()/length)*zp+bck.y());
3260 double slopex = wire.x()/wire.z();
3261 double slopey = (A*(2*zp-length)*length+wire.y())/wire.z();
3262
3263 x0kal = x0kal_up;
3264 wire.setX(slopex);
3265 wire.setY(slopey);
3266 wire.setZ(1);
3267
3268 } else if (wsag_ == 2 || wsag_ == 3){
3269 double slopex = wire.x()/wire.z();
3270 double slopey(0), zinit(x0kal.z());
3271 double pos[3], yb_sag(0), yf_sag(0);
3272 int wire_ID = Wire.geoID();
3273 if (wsag_ == 2)
3274 calcdc_sag2_(&wire_ID, &zinit, pos, &slopey, &yb_sag, &yf_sag);
3275
3276 else
3277 calcdc_sag3_(&wire_ID, &zinit, pos, &slopey, &yb_sag, &yf_sag);
3278
3279 wire.setX(slopex);
3280 wire.setY(slopey);
3281 wire.setZ(1);
3282 x0kal.setX(pos[0]);
3283 x0kal.setY(pos[1]);
3284 } else
3285 */
3286
3287 if (wsag_ == 4){
3288 Hep3Vector result;
3289 const MdcGeoWire* geowire = geomsvc->Wire(wireid);
3290 double tension = geowire->Tension();
3291 //std::cout<<" tension: "<<tension<<std::endl;
3292 double zinit(x0kal.z()), lzx(Wire.lzx());
3293 // double A(Wire.Acoef());
3294 double A = 47.35E-6/tension;
3295 double Zp = (zinit - bck.z())*lzx/wire.z();
3296
3297 if(4 == debug_){
3298 std::cout<<" sag in filter_fwd_anal: "<<std::endl;
3299 std::cout<<" x0kal.x(): "<<std::setprecision(10)<<x0kal.x()<<std::endl;
3300 std::cout<<"zinit: "<<zinit<<" bck.z(): "<<bck.z()<<std::endl;
3301 std::cout<<" wire.x()*(zinit-bck.z())/wire.z(): "<<std::setprecision(10)
3302 <<(wire.x()*(zinit-bck.z())/wire.z())<<std::endl;
3303 std::cout<<"bck.x(): "<<std::setprecision(10)<<bck.x()<<std::endl;
3304 std::cout<<" wire.x()*(zinit-bck.z())/wire.z() + bck.x(): "<<std::setprecision(10)
3305 <<(wire.x()*(zinit-bck.z())/wire.z() + bck.x())<<std::endl;
3306 }
3307
3308 result.setX(wire.x()*(zinit-bck.z())/wire.z() + bck.x());
3309 result.setY((A*(Zp-lzx)+wire.y()/lzx)*Zp+bck.y());
3310 result.setZ((A*(2*Zp-lzx)*lzx+wire.y())/wire.z());
3311
3312 wire.setX(wire.x()/wire.z());
3313 wire.setY(result.z());
3314 wire.setZ(1);
3315 x0kal.setX(result.x());
3316 x0kal.setY(result.y());
3317 }
3318
3319
3320 // If x0kal is after the inner wall and x0kal_prec before :
3321 double r0kal = x0kal.perp();
3322
3323 // change PIVOT :
3324 double pathl(0);
3325
3326 if(i==0) track.pivot(x0kal);
3327 else track.pivot_numf(x0kal, pathl);
3328
3329
3330 if (nhits_read == 1) {
3331 track.Ea(Eakal);
3332 } else {
3333 //std::cout<<" Ea="<<track.Ea()<<std::endl;
3334 if(KalFitElement::muls()) track.msgasmdc(pathl, way);
3335 //std::cout<<" after muls Ea="<<track.Ea()<<std::endl;
3336 if(KalFitElement::loss()) track.eloss(pathl, _BesKalmanFitMaterials[0], way);
3337 //std::cout<<" after eloss Ea="<<track.Ea()<<std::endl;
3338 }
3339
3340 if(4 == debug_) {
3341 std::cout<<" x0kal after sag: "<<x0kal<<std::endl;
3342 std::cout<<" a="<<track.a()<<std::endl;
3343 std::cout<<" Ea="<<track.Ea()<<std::endl;
3344 }
3345
3346 double dtracknew = 0.;
3347 double dtrack = 0.;
3348 double dtdc = 0.;
3349 // Add info hit wire :
3350 if(fabs(track.kappa())>0&&fabs(track.kappa())<1000.0&&fabs(track.tanl())<7.02) {
3351 Hep3Vector meas = track.momentum(0).cross(wire).unit();
3352 double diff_chi2 = track.chiSq();
3353 Hep3Vector IP(0,0,0);
3354 KalmanFit::Helix work_bef = *(KalmanFit::Helix*)&track;
3355 work_bef.ignoreErrorMatrix();
3356 work_bef.pivot(IP);
3357 int inext(-1);
3358 if (i+1<nhit)
3359 for( unsigned k=i+1 ; k < nhit; k++ )
3360 if (!(track.HitMdc(k).chi2()<0)) {
3361 inext = (signed) k;
3362 break;
3363 }
3364 double dchi2 = -1.0;
3365
3366 double chi2 = track.update_hits(HitMdc,inext,meas,way,dchi2,dtrack,dtracknew,dtdc,m_csmflag);
3367
3368 //cout << "dchi2=" << dchi2 << endl;
3369 /// get the doca from another other independent method
3370
3371 /*
3372 std::cout<<" step0: "<<std::endl;
3373 KalFitTrack temp2(track);
3374 std::cout<<" step1: "<<std::endl;
3375
3376 KalmanFit::Helix temp3(track.pivot(),track.a(),track.Ea());
3377 KalmanFit::Helix temp4(track.pivot(),track.a(),track.Ea());
3378
3379 std::cout<<" step2: "<<std::endl;
3380 double doca25 = temp2.approach(HitMdc, false);
3381 std::cout<<" step3: "<<std::endl;
3382
3383 temp2.pivot(IP);
3384 std::cout<<" a2: "<<temp2.a()<<std::endl;
3385
3386 std::cout<<" step4: "<<std::endl;
3387
3388 double doca26 = temp3.approach(HitMdc, false);
3389 std::cout<<" another doca2.6: "<<doca26<<std::endl;
3390
3391 temp3.pivot(IP);
3392 std::cout<<" a3: "<<temp3.a()<<std::endl;
3393
3394 temp4.bFieldZ(-10);
3395 temp4.pivot(IP);
3396 std::cout<<" a4: "<<temp4.a()<<std::endl;
3397
3398 std::cout<<" step5: "<<std::endl;
3399
3400 double doca1 = track.approach(HitMdc, false);
3401 double doca2 = temp2.approach(HitMdc, false);
3402 double doca3 = temp3.approach(HitMdc, false);
3403 double doca4 = temp4.approach(HitMdc, false);
3404
3405 std::cout<<" dtrack: "<<dtrack<<std::endl;
3406 std::cout<<" another doca1: "<<doca1<<std::endl;
3407 std::cout<<" another doca2: "<<doca2<<std::endl;
3408 std::cout<<" another doca2.5: "<<doca25<<std::endl;
3409 std::cout<<" another doca3: "<<doca3<<std::endl;
3410 std::cout<<" another doca4: "<<doca4<<std::endl;
3411 */
3412
3413
3414 //if( dchi2 <0 ) { std::cout<<" ... ERROR OF dchi2... "<<std::endl; }
3415
3416 if (ntuple_&8) {
3417 m_dchi2 = dchi2;
3418 m_masshyp = l_mass;
3419 m_residest = dtrack-dtdc;
3420 m_residnew = dtracknew -dtdc;
3421 m_layer = Wire.layer().layerId();
3422 KalmanFit::Helix worktemp = *(KalmanFit::Helix*)&track;
3423 m_anal_dr = worktemp.a()[0];
3424 m_anal_phi0 = worktemp.a()[1];
3425 m_anal_kappa = worktemp.a()[2];
3426 m_anal_dz = worktemp.a()[3];
3427 m_anal_tanl = worktemp.a()[4];
3428 m_anal_ea_dr = worktemp.Ea()[0][0];
3429 m_anal_ea_phi0 = worktemp.Ea()[1][1];
3430 m_anal_ea_kappa = worktemp.Ea()[2][2];
3431 m_anal_ea_dz = worktemp.Ea()[3][3];
3432 m_anal_ea_tanl = worktemp.Ea()[4][4];
3433 StatusCode sc5 = m_nt5->write();
3434 if( sc5.isFailure() ) cout<<"Ntuple5 filling failed!"<<endl;
3435 }
3436
3437 if (ntuple_&256) {
3438
3439 //cout<<"Mdc: "<<m_hit_no<<endl;
3440
3441 if(l_mass == 0){
3442 m_dchi2_hit_e[m_hit_no] = dchi2;
3443 m_residest_hit_e[m_hit_no] = dtrack-dtdc;
3444 m_residnew_hit_e[m_hit_no] = dtracknew -dtdc;
3445 m_layer_hit_e[m_hit_no] = Wire.layer().layerId();
3446 KalmanFit::Helix worktemp = *(KalmanFit::Helix*)&track;
3447 m_anal_dr_hit_e[m_hit_no] = worktemp.a()[0];
3448 m_anal_phi0_hit_e[m_hit_no] = worktemp.a()[1];
3449 m_anal_kappa_hit_e[m_hit_no] = worktemp.a()[2];
3450 m_anal_dz_hit_e[m_hit_no] = worktemp.a()[3];
3451 m_anal_tanl_hit_e[m_hit_no] = worktemp.a()[4];
3452 m_anal_ea_dr_hit_e[m_hit_no] = worktemp.Ea()[0][0];
3453 m_anal_ea_phi0_hit_e[m_hit_no] = worktemp.Ea()[1][1];
3454 m_anal_ea_kappa_hit_e[m_hit_no] = worktemp.Ea()[2][2];
3455 m_anal_ea_dz_hit_e[m_hit_no] = worktemp.Ea()[3][3];
3456 m_anal_ea_tanl_hit_e[m_hit_no] = worktemp.Ea()[4][4];
3457
3458 }
3459
3460 else if(l_mass == 1){
3461 m_dchi2_hit_mu[m_hit_no] = dchi2;
3462 m_residest_hit_mu[m_hit_no] = dtrack-dtdc;
3463 m_residnew_hit_mu[m_hit_no] = dtracknew -dtdc;
3464 m_layer_hit_mu[m_hit_no] = Wire.layer().layerId();
3465 KalmanFit::Helix worktemp = *(KalmanFit::Helix*)&track;
3466 m_anal_dr_hit_mu[m_hit_no] = worktemp.a()[0];
3467 m_anal_phi0_hit_mu[m_hit_no] = worktemp.a()[1];
3468 m_anal_kappa_hit_mu[m_hit_no] = worktemp.a()[2];
3469 m_anal_dz_hit_mu[m_hit_no] = worktemp.a()[3];
3470 m_anal_tanl_hit_mu[m_hit_no] = worktemp.a()[4];
3471 m_anal_ea_dr_hit_mu[m_hit_no] = worktemp.Ea()[0][0];
3472 m_anal_ea_phi0_hit_mu[m_hit_no] = worktemp.Ea()[1][1];
3473 m_anal_ea_kappa_hit_mu[m_hit_no] = worktemp.Ea()[2][2];
3474 m_anal_ea_dz_hit_mu[m_hit_no] = worktemp.Ea()[3][3];
3475 m_anal_ea_tanl_hit_mu[m_hit_no] = worktemp.Ea()[4][4];
3476
3477 }
3478
3479
3480 else if(l_mass == 2){
3481 m_dchi2_hit_pi[m_hit_no] = dchi2;
3482 m_residest_hit_pi[m_hit_no] = dtrack-dtdc;
3483 m_residnew_hit_pi[m_hit_no] = dtracknew -dtdc;
3484 m_layer_hit_pi[m_hit_no] = Wire.layer().layerId();
3485 KalmanFit::Helix worktemp = *(KalmanFit::Helix*)&track;
3486 m_anal_dr_hit_pi[m_hit_no] = worktemp.a()[0];
3487 m_anal_phi0_hit_pi[m_hit_no] = worktemp.a()[1];
3488 m_anal_kappa_hit_pi[m_hit_no] = worktemp.a()[2];
3489 m_anal_dz_hit_pi[m_hit_no] = worktemp.a()[3];
3490 m_anal_tanl_hit_pi[m_hit_no] = worktemp.a()[4];
3491 m_anal_ea_dr_hit_pi[m_hit_no] = worktemp.Ea()[0][0];
3492 m_anal_ea_phi0_hit_pi[m_hit_no] = worktemp.Ea()[1][1];
3493 m_anal_ea_kappa_hit_pi[m_hit_no] = worktemp.Ea()[2][2];
3494 m_anal_ea_dz_hit_pi[m_hit_no] = worktemp.Ea()[3][3];
3495 m_anal_ea_tanl_hit_pi[m_hit_no] = worktemp.Ea()[4][4];
3496
3497 }
3498
3499
3500 else if(l_mass == 3){
3501 m_dchi2_hit_k[m_hit_no] = dchi2;
3502 m_residest_hit_k[m_hit_no] = dtrack-dtdc;
3503 m_residnew_hit_k[m_hit_no] = dtracknew -dtdc;
3504 m_layer_hit_k[m_hit_no] = Wire.layer().layerId();
3505 KalmanFit::Helix worktemp = *(KalmanFit::Helix*)&track;
3506 m_anal_dr_hit_k[m_hit_no] = worktemp.a()[0];
3507 m_anal_phi0_hit_k[m_hit_no] = worktemp.a()[1];
3508 m_anal_kappa_hit_k[m_hit_no] = worktemp.a()[2];
3509 m_anal_dz_hit_k[m_hit_no] = worktemp.a()[3];
3510 m_anal_tanl_hit_k[m_hit_no] = worktemp.a()[4];
3511 m_anal_ea_dr_hit_k[m_hit_no] = worktemp.Ea()[0][0];
3512 m_anal_ea_phi0_hit_k[m_hit_no] = worktemp.Ea()[1][1];
3513 m_anal_ea_kappa_hit_k[m_hit_no] = worktemp.Ea()[2][2];
3514 m_anal_ea_dz_hit_k[m_hit_no] = worktemp.Ea()[3][3];
3515 m_anal_ea_tanl_hit_k[m_hit_no] = worktemp.Ea()[4][4];
3516
3517 }
3518
3519
3520 else if(l_mass == 4){
3521 m_dchi2_hit_p[m_hit_no] = dchi2;
3522 m_residest_hit_p[m_hit_no] = dtrack-dtdc;
3523 m_residnew_hit_p[m_hit_no] = dtracknew -dtdc;
3524 m_layer_hit_p[m_hit_no] = Wire.layer().layerId();
3525 KalmanFit::Helix worktemp = *(KalmanFit::Helix*)&track;
3526 m_anal_dr_hit_p[m_hit_no] = worktemp.a()[0];
3527 m_anal_phi0_hit_p[m_hit_no] = worktemp.a()[1];
3528 m_anal_kappa_hit_p[m_hit_no] = worktemp.a()[2];
3529 m_anal_dz_hit_p[m_hit_no] = worktemp.a()[3];
3530 m_anal_tanl_hit_p[m_hit_no] = worktemp.a()[4];
3531 m_anal_ea_dr_hit_p[m_hit_no] = worktemp.Ea()[0][0];
3532 m_anal_ea_phi0_hit_p[m_hit_no] = worktemp.Ea()[1][1];
3533 m_anal_ea_kappa_hit_p[m_hit_no] = worktemp.Ea()[2][2];
3534 m_anal_ea_dz_hit_p[m_hit_no] = worktemp.Ea()[3][3];
3535 m_anal_ea_tanl_hit_p[m_hit_no] = worktemp.Ea()[4][4];
3536
3537 }
3538
3539 m_hit_no++;
3540 }
3541
3542
3543 KalmanFit::Helix work_aft = *(KalmanFit::Helix*)&track;
3544 work_aft.ignoreErrorMatrix();
3545 work_aft.pivot(IP);
3546 diff_chi2 = chi2 - diff_chi2;
3547 HitMdc.chi2(diff_chi2);
3548 }
3549 r0kal_prec = r0kal;
3550 }
3551 //cout <<"filter end" << endl;
3552}
Description of a Hit in Mdc.
double chi2(void) const
const KalFitWire & wire(void) const
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...

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

3557{
3558
3559 // retrieve Mdc geometry information
3560 IMdcGeomSvc* igeomsvc;
3561 StatusCode sc = Gaudi::svcLocator()->service("MdcGeomSvc", igeomsvc);
3562 if(sc==StatusCode::FAILURE) cout << "GeoSvc failing!!!!!!!SC=" << sc << endl;
3563 MdcGeomSvc* geomsvc = dynamic_cast<MdcGeomSvc*>(igeomsvc);
3564 if(!geomsvc){
3565 std::cout<<"ERROR OCCUR when dynamic_cast in KalFitTrack.cxx !!"<<std::endl;
3566 }
3567
3568 if(debug_ == 4) {
3569 std::cout<<"filter_fwd_calib starting ...the inital error Matirx is "<<track.Ea()<<std::endl;
3570 }
3571 Hep3Vector x0inner(track.pivot());
3572 HepVector pos_old(3,0);
3573 double r0kal_prec(0);
3574 int nhits_read(0);
3575
3576 unsigned int nhit = track.HitsMdc().size();
3577 if(debug_ == 4) cout<<"filter_fwd..........111 nhit="<<nhit<<endl;
3578 for( unsigned i=0 ; i < nhit; i++ ) {
3579
3580 KalFitHitMdc& HitMdc = track.HitMdc(i);
3581 if(debug_ == 4)
3582 cout<<"filter_fwd...........222 chi2="<<HitMdc.chi2()<<endl;
3583 // veto on some hits :
3584 if (HitMdc.chi2()<0) continue;
3585 const KalFitWire& Wire = HitMdc.wire();
3586
3587 int wireid = Wire.geoID();
3588 nhits_read++;
3589
3590 // if (nhits_read == 1) track.Ea(Eakal);
3591 HepPoint3D fwd(Wire.fwd());
3592 HepPoint3D bck(Wire.bck());
3593 Hep3Vector wire = (CLHEP::Hep3Vector)fwd -(CLHEP::Hep3Vector)bck;
3594 KalmanFit::Helix work = *(KalmanFit::Helix*)&track;
3595 work.ignoreErrorMatrix();
3596 work.pivot((fwd + bck) * .5);
3597 HepPoint3D x0kal = (work.x(0).z() - bck.z())/ wire.z() * wire + bck;
3598
3599 if(4 == debug_)
3600 std::cout<<" x0kal before sag: "<<x0kal<<std::endl;
3601
3602 if (wsag_ == 4){
3603 Hep3Vector result;
3604 const MdcGeoWire* geowire = geomsvc->Wire(wireid);
3605 double tension = geowire->Tension();
3606 //std::cout<<" tension: "<<tension<<std::endl;
3607 double zinit(x0kal.z()), lzx(Wire.lzx());
3608 // double A(Wire.Acoef());
3609 double A = 47.35E-6/tension;
3610 double Zp = (zinit - bck.z())*lzx/wire.z();
3611
3612 if(4 == debug_){
3613
3614 std::cout<<" sag in filter_fwd_calib: "<<std::endl;
3615 std::cout<<" x0kal.x(): "<<std::setprecision(10)<<x0kal.x()<<std::endl;
3616 std::cout<<" wire.x()*(zinit-bck.z())/wire.z(): "<<std::setprecision(10)
3617 <<(wire.x()*(zinit-bck.z())/wire.z())<<std::endl;
3618 std::cout<<"bck.x(): "<<std::setprecision(10)<<bck.x()<<std::endl;
3619 std::cout<<" wire.x()*(zinit-bck.z())/wire.z() + bck.x(): "<<std::setprecision(10)
3620 <<(wire.x()*(zinit-bck.z())/wire.z() + bck.x())<<std::endl;
3621 }
3622
3623 result.setX(wire.x()*(zinit-bck.z())/wire.z() + bck.x());
3624 result.setY((A*(Zp-lzx)+wire.y()/lzx)*Zp+bck.y());
3625 result.setZ((A*(2*Zp-lzx)*lzx+wire.y())/wire.z());
3626 wire.setX(wire.x()/wire.z());
3627 wire.setY(result.z());
3628 wire.setZ(1);
3629 x0kal.setX(result.x());
3630 x0kal.setY(result.y());
3631 }
3632
3633 if(4 == debug_)
3634 std::cout<<" x0kal after sag: "<<x0kal<<std::endl;
3635
3636 // If x0kal is after the inner wall and x0kal_prec before :
3637 double r0kal = x0kal.perp();
3638
3639 // change PIVOT :
3640 double pathl(0);
3641
3642 //std::cout<<" track a3: "<<track.a()<<std::endl;
3643 //std::cout<<" track p3: "<<sqrt(1.0+track.a()[4]*track.a()[4])/track.a()[2]<<std::endl;
3644
3645 if (debug_ == 4)
3646 cout << "*** move from " << track.pivot() << " ( Kappa = "
3647 << track.a()[2] << ")" << endl;
3648 track.pivot_numf(x0kal, pathl); //see the code , the error matrix has been changed in this function ..
3649
3650 //std::cout<<" track a4: "<<track.a()<<std::endl;
3651 //std::cout<<" track p4: "<<sqrt(1.0+track.a()[4]*track.a()[4])/track.a()[2]<<std::endl;
3652
3653
3654 if (debug_ == 4)
3655 cout << "*** to " << track.pivot() << " ( Kappa = "
3656 << track.a()[2] << ")" << std::endl;
3657
3658 if (nhits_read == 1) {
3659 track.Ea(Eakal);
3660 if(debug_==4) cout << "filter_fwd::Ea = " << track.Ea()<<endl;
3661
3662
3663 } else {
3664 if(KalFitElement::muls()) track.msgasmdc(pathl, way);
3665 if(KalFitElement::loss()) track.eloss(pathl, _BesKalmanFitMaterials[0], way);
3666 }
3667
3668
3669 //std::cout<<" track a5: "<<track.a()<<std::endl;
3670 //std::cout<<" track p5: "<<sqrt(1.0+track.a()[4]*track.a()[4])/track.a()[2]<<std::endl;
3671
3672 // Add info hit wire :
3673 if(fabs(track.kappa())>0&&fabs(track.kappa())<1000.0&&fabs(track.tanl())<7.02) {
3674 Hep3Vector meas = track.momentum(0).cross(wire).unit();
3675
3676 double diff_chi2 = track.chiSq();
3677
3678 Hep3Vector IP(0,0,0);
3679 KalmanFit::Helix work_bef = *(KalmanFit::Helix*)&track;
3680 work_bef.ignoreErrorMatrix();
3681 work_bef.pivot(IP);
3682 int inext(-1);
3683 if (i+1<nhit)
3684 for( unsigned k=i+1 ; k < nhit; k++ )
3685 if (!(track.HitMdc(k).chi2()<0)) {
3686 inext = (signed) k;
3687 break;
3688 }
3689 double dchi2 = -1.0;
3690
3691 if (debug_ == 4) {
3692 std::cout<<"the value of x0kal is "<<x0kal<<std::endl;
3693 std::cout<<"the value of track.pivot() is "<<track.pivot()<<std::endl;
3694 }
3695
3696 HepVector Va(5,0);
3697 HepSymMatrix Ma(5,0);
3698 KalFitHelixSeg HelixSeg(&HitMdc,x0kal,Va,Ma);
3699
3700 if(debug_ == 4) {
3701 std::cout<<"HelixSeg.Ea_pre_fwd() ..."<<HelixSeg.Ea_pre_fwd()<<std::endl;
3702 std::cout<<"HelixSeg.a_pre_fwd() ..."<<HelixSeg.a_pre_fwd()<<std::endl;
3703 std::cout<<"HelixSeg.Ea_filt_fwd() ..."<<HelixSeg.Ea_filt_fwd()<<std::endl;
3704 }
3705
3706 //std::cout<<" track a1: "<<track.a()<<std::endl;
3707 //std::cout<<" track p1: "<<sqrt(1.0+track.a()[4]*track.a()[4])/track.a()[2]<<std::endl;
3708
3709 double chi2=0.;
3710 if(usage_>1) chi2=track.update_hits_csmalign(HelixSeg, inext, meas, way, dchi2, m_csmflag);
3711 else chi2 = track.update_hits(HelixSeg, inext, meas, way, dchi2, m_csmflag);
3712
3713 //std::cout<<" track a2: "<<track.a()<<std::endl;
3714 //std::cout<<" track p2: "<<sqrt(1.0+track.a()[4]*track.a()[4])/track.a()[2]<<std::endl;
3715
3716 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;
3717
3718 if(debug_ == 4) cout<< "****inext***"<<inext<<" !!!! dchi2= "<< dchi2
3719 << " chisq= "<< chi2<< endl;
3720
3721 if (ntuple_&8) {
3722 m_dchi2 = dchi2;
3723 m_masshyp = l_mass;
3724 StatusCode sc5 = m_nt5->write();
3725 if( sc5.isFailure() ) cout<<"Ntuple5 filling failed!"<<endl;
3726 }
3727
3728 KalmanFit::Helix work_aft = *(KalmanFit::Helix*)&track;
3729 work_aft.ignoreErrorMatrix();
3730 work_aft.pivot(IP);
3731 diff_chi2 = chi2 - diff_chi2;
3732 HitMdc.chi2(diff_chi2);
3733
3734 if(debug_ == 4) {
3735
3736 cout << " -> after include meas = " << meas
3737 << " at R = " << track.pivot().perp() << std::endl;
3738 cout << " chi2 = " << chi2 << ", diff_chi2 = "
3739 << diff_chi2 << ", LR = "
3740 << HitMdc.LR() << ", stereo = " << HitMdc.wire().stereo()
3741 << ", layer = " << HitMdc.wire().layer().layerId() << std::endl;
3742 cout<<"filter_fwd..........HitMdc.chi2... "<<HitMdc.chi2()<<endl;
3743 }
3744
3745 if(dchi2>0.0 && (way!=999)) {
3746 track.HelixSegs().push_back(HelixSeg);
3747 }
3748 }
3749 r0kal_prec = r0kal;
3750 }
3751}
int LR(void) const
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 320 of file KalFitAlg.cxx.

321{
322 MsgStream log(msgSvc(), name());
323 log << MSG::DEBUG<<"KalFitAlg:: nTotalTrks = "<<nTotalTrks<<endreq;
324 log << MSG::DEBUG<<" e: "<<nFailedTrks[0]<<" failed, "<<nTotalTrks-nFailedTrks[0]<<" successed"<<endreq;
325 log << MSG::DEBUG<<" mu: "<<nFailedTrks[1]<<" failed, "<<nTotalTrks-nFailedTrks[1]<<" successed"<<endreq;
326 log << MSG::DEBUG<<" pi: "<<nFailedTrks[2]<<" failed, "<<nTotalTrks-nFailedTrks[2]<<" successed"<<endreq;
327 log << MSG::DEBUG<<" K: "<<nFailedTrks[3]<<" failed, "<<nTotalTrks-nFailedTrks[3]<<" successed"<<endreq;
328 log << MSG::DEBUG<<" p: "<<nFailedTrks[4]<<" failed, "<<nTotalTrks-nFailedTrks[4]<<" successed"<<endreq;
329 if(debug_==5||debug_==4)
330 {
331 cout<<"KalFitAlg:: nTotalTrks = "<<nTotalTrks<<endl;
332 cout<<" e: "<<nFailedTrks[0]<<" failed, "<<nTotalTrks-nFailedTrks[0]<<" successed"<<endl;
333 cout<<" mu: "<<nFailedTrks[1]<<" failed, "<<nTotalTrks-nFailedTrks[1]<<" successed"<<endl;
334 cout<<" pi: "<<nFailedTrks[2]<<" failed, "<<nTotalTrks-nFailedTrks[2]<<" successed"<<endl;
335 cout<<" K: "<<nFailedTrks[3]<<" failed, "<<nTotalTrks-nFailedTrks[3]<<" successed"<<endl;
336 cout<<" p: "<<nFailedTrks[4]<<" failed, "<<nTotalTrks-nFailedTrks[4]<<" successed"<<endl;
337 }
338 return StatusCode::SUCCESS;
339}

◆ fitGemHits()

void KalFitAlg::fitGemHits ( KalFitTrack & track,
int hypo,
int way )

Definition at line 7375 of file KalFitAlg.cxx.

7376{
7377 {
7378 //cout<<endl;
7379 //cout<<"--------------------------------------"<<endl;
7380 //cout<<"start GEM Kalman fit: hypo = "<<hypo<<endl;
7381 //cout<<"--------------------------------------"<<endl;
7382 // std::vector<double> dchi2_all;
7383 // std::vector<HepPoint3D> posnew;
7384 // std::vector<HepSymMatrix> eanew;
7385 // std::vector<HepVector> anew;
7386 //std::map<int,double> dchi2;
7387 std::map<double,double> esti1_r;
7388 std::map<double,double> esti2_r;
7389 std::map<double,double> esti1_phi;
7390 std::map<double,double> esti2_phi;
7391 std::map<double,double> esti1_z;
7392 std::map<double,double> esti2_z;
7393 std::map<double,double> diff1_phi;
7394 std::map<double,double> diff1_z;
7395 std::map<double,double> diff2_phi;
7396 std::map<double,double> diff2_z;
7397 std::map<double,HepPoint3D> posnew;
7398 std::map<double,HepSymMatrix> eanew;
7399 std::map<double,HepVector> anew;
7400 std::map<double,double> meas_r;
7401 std::map<double,double> meas_phi;
7402 std::map<double,double> meas_z;
7403 std::map<double,double> meas_phierr;
7404 std::map<double,double> esti_phierr;
7405 std::map<double,double> meas_zerr;
7406 std::map<double,double> esti_zerr;
7407 int ii=0;
7408 if(debug_==4){ cout << "wall size" << _BesKalmanFitWalls.size() << endl;}
7409 for(int iLayer=2; iLayer>=0; iLayer--)
7410 {
7411 posnew.clear();
7412 eanew.clear();
7413 anew.clear();
7414 esti1_r.clear();
7415 esti2_r.clear();
7416 esti1_phi.clear();
7417 esti2_phi.clear();
7418 esti1_z.clear();
7419 esti2_z.clear();
7420 diff1_phi.clear();
7421 diff1_z.clear();
7422 diff2_phi.clear();
7423 diff2_z.clear();
7424 meas_r.clear();
7425 meas_phi.clear();
7426 meas_z.clear();
7427 meas_phierr.clear();
7428 meas_zerr.clear();
7429 esti_phierr.clear();
7430 esti_zerr.clear();
7431 //cout<<"iLayer = "<<iLayer<<endl;
7432 int nHits=myGemHitCol[iLayer].size();
7433 //cout << "nhits" << nHits << "in layer" << iLayer << endl;
7434
7435 if (nHits <= 0) continue;
7436 //if(nHits!=1) continue;
7437
7438 vector<KalFitGemHit>::iterator iter;
7439 int ihit=0;
7440 // int ii=0;
7441 //cout <<"track before" << "pivot=" << track.pivot() << "a=" << track.a() << "ea=" <<track.Ea() << endl;
7442 innerwall(track,hypo,way,64+iLayer*(-32),88+iLayer*(-32));
7443 KalFitTrack track_start(track);
7444 //cout << "now position" << track_start.pivot().perp() << ","<< track_start.pivot().phi() << "," << track_start.pivot().z() <<endl;
7445 for(iter=myGemHitCol[iLayer].begin();iter!=myGemHitCol[iLayer].end();iter++ )
7446 {
7447 //cout <<"track" << "pivot=" << track.pivot() << "a=" << track.a() << "ea=" <<track.Ea() << endl;
7448 track.set(track_start.pivot(),track_start.a(),track_start.Ea());
7449 //cout << "track start" << "pivot=" << track_start.pivot() << "a=" << track_start.a() << "ea=" << track_start.Ea() << endl;
7450 double rGem=(*iter).getR();
7451 double phiGem=(*iter).getPhi();
7452 double zGem=(*iter).getZ();
7453 HepVector v_measu=(*iter).getVecPos();
7454 //cout << "hit" << ihit << "r=" << rGem << "phi=" << phiGem << "z=" << zGem << endl;
7455 // cout << "v_measu= " << v_measu << endl;
7456 /*
7457 double rGem=(myGemHitCol[iLayer].begin())->getR();
7458 double phiGem=(myGemHitCol[iLayer].begin())->getPhi();
7459 double zGem=(myGemHitCol[iLayer].begin())->getZ();
7460 HepVector v_measu=(myGemHitCol[iLayer].begin())->getVecPos();
7461 cout<<"v_measu = "<<v_measu<<endl;
7462 */
7463 double dPhiToGem = track.intersect_cylinder(rGem);
7464 //cout << "dPhiToGem=" << dPhiToGem << endl;
7465 HepPoint3D posEstiAtGem = track.x(dPhiToGem);
7466 double x0=posEstiAtGem.x();
7467 double y0=posEstiAtGem.y();
7468 double pathInGem;
7469 //cout << "before move" << "pivot" <<track.pivot() << "a" << track.a() << "ea" << track.Ea() << endl;
7470 track.pivot_numf(posEstiAtGem, pathInGem);
7471 //cout << "posEstiAtGem=" << posEstiAtGem << endl;
7472 //cout << "pathInGem=" << pathInGem << endl;
7473 if(pathInGem>0)
7474 {
7475 if(muls_) track.ms(pathInGem, _BesKalmanFitMaterials[26+32*iLayer], way);
7476 if(loss_) track.eloss(pathInGem, _BesKalmanFitMaterials[26+32*iLayer], way);
7477 }
7478 //cout << "after move" << "pivot" <<track.pivot() << "a" << track.a() << "ea" << track.Ea() << endl;
7479 double rGemEsti=posEstiAtGem.perp();
7480 double phiGemEsti=posEstiAtGem.phi();
7481 double zGemEsti=posEstiAtGem.z();
7482 HepVector v_estim(2,0);
7483 v_estim(1)=phiGemEsti;
7484 v_estim(2)=zGemEsti;
7485 //cout<<"GEM layer "<<iLayer+1<<" : MC r,phi,z="<<rGem<<", "<<phiGem<<", "<<zGem<<endl;
7486 //cout<<" esti r,phi,z="<<rGemEsti<<", "<<phiGemEsti<<", "<<zGemEsti<<endl;
7487 double dPhi=track.intersect_cylinder(rGem);
7488 //cout << "dPhi=" << dPhi << endl;
7489 HepPoint3D pos = track.x(dPhi);
7490 //cout<< "assumed esti phi,z" << pos.phi() << "," << pos.z() << endl;
7491 const HepSymMatrix& Ea = track.Ea();
7492 HepVector v_a = track.a();
7493 double drho=v_a(1);
7494 double phi0=v_a(2);
7495 double kappa=v_a(3);
7496 double tl=v_a(5);
7497 //cout<<"v_a = "<<v_a<<endl;
7498 //cout<<"phi0 = "<<phi0<<endl;
7499 // --- derivative matrix
7500 HepMatrix H(2, 5, 0);
7501 //H(1,2)=(x0*cos(phi0)-y0*sin(phi0))/(x0*x0+y0*y0);
7502 //H(2,4)=1.0;
7503 H(1,1)=-y0*cos(phi0)/(y0*y0+x0*x0)+x0*sin(phi0)/(x0*x0+y0*y0);
7504 //H(1,1)=(x0*cos(phi0)-y0*sin(phi0))/(x0*x0+y0*y0);
7505 //H(1,2)=-y0/(y0*y0+x0*x0)*sin(phi0+dPhi)-x0/(x0*x0+y0*y0)*cos(phi0+dPhi);
7506 H(1,2)=-y0/(y0*y0+x0*x0)*((-1)*drho*sin(phi0)+m_alpha/kappa*(sin(phi0+dPhi)-sin(phi0)))+x0/(x0*x0+y0*y0)*(drho*cos(phi0)+m_alpha/kappa*(cos(phi0)-cos(phi0+dPhi)));
7507 H(1,3)=-y0/(y0*y0+x0*x0)*(-1)*m_alpha/(kappa*kappa)*(cos(phi0)-cos(phi0+dPhi))+x0/(x0*x0+y0*y0)*(-1)*m_alpha/(kappa*kappa)*(sin(phi0)-sin(phi0+dPhi));
7508 H(2,3)=m_alpha/(kappa*kappa)*tl*dPhi;
7509 H(2,4)=1.0;
7510 H(2,5)=-1*(m_alpha/kappa)*dPhi;
7511 //cout<<"H="<<H<<endl;
7512 HepMatrix H_T=H.T();
7513 //cout<<"H_T="<<H_T<<endl;
7514 //cout << "H*v_a=" << H*v_a << endl;
7515 //cout << "H*v_a+estim=" <<H*v_a+v_estim << endl;
7516 // --- error matrix of Gem hit
7517 HepSymMatrix V=(*iter).getErrMat();
7518 //cout<<"V="<<V<<endl;
7519 HepMatrix HEa=H*Ea;
7520 HepMatrix HEaH_T=HEa*H_T;
7521 int ierr=-1;
7522 HepMatrix Vinv=(V+HEaH_T).inverse(ierr);
7523 if(ierr!=0) cout<<"error in HEaH_T.inverse()!"<<endl;
7524 // --- gain matrix
7525 HepMatrix K=Ea*H_T*Vinv;
7526 // --- new error matrix
7527 HepSymMatrix EaNew(5,0);
7528 EaNew.assign(Ea-K*H*Ea);
7529 // --- diff
7530 HepVector v_diff=v_measu-v_estim;
7531 //cout << "v_diff before= " << v_diff << endl;
7532 double delPhi=v_diff(1);
7533 if(fabs(v_diff(1))>6.28) v_measu(1)=-1*v_measu(1);
7534 while(delPhi> M_PI) delPhi-=M_PI;
7535 while(delPhi<-M_PI) delPhi+=M_PI;
7536 v_diff(1)=delPhi;
7537 //v_diff=v_measu-(H*v_a+v_estim);
7538 //cout<<"v_diff = "<<v_diff<<endl;
7539 // --- new parameters
7540 HepVector aNew=v_a+K*v_diff;
7541 //cout << "matrix K=" << K << endl;
7542 //cout << "aNew=" << aNew << endl;
7543 // --- new v_estim
7544 KalFitTrack track_test(posEstiAtGem,aNew,EaNew,hypo,0.0,track.nchits());
7545 double dPhiToGem_New = track_test.intersect_cylinder(rGem);
7546 HepPoint3D posEstiAtGem_new = track_test.x(dPhiToGem_New);
7547 double phiGemEsti_new=posEstiAtGem_new.phi();
7548 double zGemEsti_new=posEstiAtGem_new.z();
7549 double x0_new = posEstiAtGem_new.x();
7550 double y0_new = posEstiAtGem_new.y();
7551 HepVector v_estim_new(2,0);
7552 v_estim_new(1)=phiGemEsti_new;
7553 v_estim_new(2)=zGemEsti_new;
7554 //cout<<"v_estim_new = "<<v_estim_new<<endl;
7555 //cout << "assumed v_estim_new =" << H*aNew+v_estim << endl;
7556 // --- diff between measurement and updated estimation
7557 v_diff=v_measu-v_estim_new;
7558 delPhi=v_diff(1);
7559 while(delPhi> M_PI) delPhi-=M_PI;
7560 while(delPhi<-M_PI) delPhi+=M_PI;
7561 //cout<<"v_diff_new = "<<v_diff<<endl;
7562 //cout << "H*aNew"<< H*aNew << endl;
7563 //cout << "test v_diff new" << v_measu-v_estim-H*aNew << endl;
7564 // --- new derivative matrix
7565 track_test.pivot_numf(posEstiAtGem_new, pathInGem);
7566 HepVector v_a_new = track_test.a();
7567 //cout << "v_a_new=" << v_a_new << endl;
7568 HepSymMatrix Ea_new = track_test.Ea();
7569 //cout << "Ea_new =" << Ea_new << endl;
7570 double phi0_new = v_a_new(2);
7571 double kappa_new=v_a_new(3);
7572 HepMatrix H_new(2, 5, 0);
7573 //H_new(1,1)=-y0_new/(x0_new*x0_new+y0_new*y0_new)*cos(phi0_new)+x0_new/(x0_new*x0_new+y0_new*y0_new)*sin(phi0_new);
7574 //H_new(2,4)=1.0;
7575 //H_new(1,1)=(x0_new*cos(phi0_new)-y0_new*sin(phi0_new))/(x0_new*x0_new+y0_new*y0_new);
7576
7577 /* H_new(1,1)=-y0_new/(1+x0_new*x0_new)*cos(phi0_new)+x0_new/(x0_new*x0_new+y0_new*y0_new)*sin(phi0_new);
7578 H_new(1,2)=-y0_new/(1+x0_new*x0_new)*sin(phi0_new+dPhiToGem_New)-x0_new/(x0_new*x0_new+y0_new*y0_new)*cos(phi0_new+dPhiToGem_New);
7579 H_new(2,4)=1.0;
7580 H_new(2,5)=-(-333.564095)/kappa_new*dPhiToGem_New;*/
7581 HepMatrix H_new_T=H_new.T();
7582 // --- R mactrix
7583 //cout<<"H_new*Ea_new*H_new_T = "<<H_new*Ea_new*H_new_T<<endl;
7584 //cout << "H*Ea_new*H_T=" << H*Ea_new*H_T << endl;
7585 //cout << "H*EaNew*H_T=" << H*EaNew*H_T<< endl;
7586 //cout << "H_new*Eanew*H_new_T = "<< H_new*EaNew*H_new_T << endl;
7587 //cout << "assumed R=" <<V-H*Ea_new*H_T << endl;
7588 HepSymMatrix R(2,0);
7589 //R.assign(V-H_new*Ea_new*H_new_T);
7590 R.assign(V-H*EaNew*H_T);
7591
7592 //cout << "test track" << "pivot" << track.pivot() << "a" << track.a() << "ea" << track.Ea() << endl;
7593 // --- Chi^2 added
7594 //cout << "v_diff_T=" << v_diff.T() <<endl;
7595 //cout << "v_diff=" << v_diff <<endl;
7596 //cout << "R="<<R << endl;
7597 //cout << "R inverse=" << R.inverse(ierr)<< endl;
7598 HepVector v_dChi2=v_diff.T()*R.inverse(ierr)*v_diff;
7599 if(ierr!=0) cout<<"error in R.inverse()!"<<endl;
7600 //cout<<"v_dChi2 = "<<v_dChi2<<endl;
7601 //cout<< "test dchi2=" << (H*v_a).T()*R.inverse(ierr)*(H*v_a) << endl;
7602 double dChi2=v_dChi2(1);
7603
7604 // --- comparison
7605 if(debug_==4){
7606 cout<<"pivot: "<<posEstiAtGem<<endl;
7607 cout<<"new pivot: "<<posEstiAtGem<<endl;
7608 cout<<"a: "<<v_a<<endl;
7609 cout<<"new a: "<<aNew<<endl;
7610 cout<<"Ea: "<<Ea<<endl;
7611 cout<<"new Ea: "<<EaNew<<endl;
7612 cout<<"dchi2= "<<dChi2<<endl;
7613 }
7614 /* if(ntuple_&1){
7615 m_diff[ii]=delPhi;
7616 cout << v_diff(2) << endl;
7617 m_diffz[ii]=v_diff(2);
7618 m_phi[ii]=phiGem;
7619 m_z[ii]=zGem;
7620 m_Gemdchi2[ii]=dChi2;
7621 m_Glayer[ii]=iLayer;
7622 m_hypo[ii]=hypo;
7623 m_meas_r[ii]=rGem;
7624 m_meas_phi[ii]=phiGem;
7625 m_meas_z[ii]=zGem;
7626 m_esti1_r[ii]=rGemEsti;
7627 m_esti1_phi[ii]=phiGemEsti;
7628 m_esti1_z[ii]=zGemEsti;
7629 m_esti2_r[ii]=rGem;
7630 m_esti2_phi[ii]=phiGemEsti_new;
7631 m_esti2_z[ii]=zGemEsti_new;
7632 m_diff1_phi[ii]=phiGem-phiGemEsti;
7633 m_diff1_z[ii]=zGem-zGemEsti;
7634 m_diff2_phi[ii]=phiGem-phiGemEsti_new;
7635 m_diff2_z[ii]=zGem-zGemEsti_new;
7636 m_Gchi2[ii]=dChi2;
7637 m_GemLayer[ii]=iLayer;
7638 m_mass[ii]=hypo;
7639 } */
7640 // --- update KalFitTrack
7641 //track.set(posEstiAtGem_new,v_a_new,Ea_new);
7642 //dchi2_all.push_back(dChi2);
7643 //posnew.push_back(posEstiAtGem_new);
7644 //anew.push_back(v_a_new);
7645 //eanew.push_back(Ea_new);
7646 //dchi2[ii]=dChi2;
7647 esti1_r[dChi2]=rGemEsti;
7648 esti1_phi[dChi2]=phiGemEsti;
7649 esti1_z[dChi2]=zGemEsti;
7650 esti2_r[dChi2]=rGem;
7651 esti2_phi[dChi2]=phiGemEsti_new;
7652 esti2_z[dChi2]=zGemEsti_new;
7653 diff1_phi[dChi2]=phiGem-phiGemEsti;
7654 diff1_z[dChi2]=zGem-zGemEsti;
7655 diff2_phi[dChi2]=phiGem-phiGemEsti_new;
7656 diff2_z[dChi2]=zGem-zGemEsti_new;
7657 posnew[dChi2]=posEstiAtGem;
7658 anew[dChi2]=aNew;
7659 eanew[dChi2]=EaNew;
7660 meas_r[dChi2]=rGem;
7661 meas_phi[dChi2]=phiGem;
7662 //cout << "meas_phi[dChi2]" << phiGem << endl;
7663 meas_z[dChi2]=zGem;
7664 meas_phierr[dChi2]=sqrt(V[0][0]);
7665 //cout << "meas_phierr[dChi2]" << meas_phierr[dChi2] << endl;
7666 meas_zerr[dChi2]=sqrt(V[1][1]);
7667 //cout << "meas_zerr[dChi2]" << meas_zerr[dChi2] << endl;
7668 esti_phierr[dChi2]=sqrt((H*(track_start.Ea())*H_T)[0][0]);
7669 //cout << "esti_phierr[dChi2]" << esti_phierr[dChi2] << endl;
7670 esti_zerr[dChi2]=sqrt((H*(track_start.Ea())*H_T)[1][1]);
7671 //cout << "esti_zerr[dChi2]" << esti_zerr[dChi2] << endl;
7672
7673 ihit++;
7674 // ii++;
7675 }
7676
7677 //m_Gemhits=ii;
7678 //m_nt7->write();
7679 track.set((posnew.begin())->second,(anew.begin())->second,(eanew.begin()->second));
7680
7681 CgemGeoLayer* CgemLayer = m_CgemGeomSvc_->getCgemLayer(iLayer);
7682 double new_dPhiToGem = track.intersect_cylinder((CgemLayer->getInnerROfGapD())/10);
7683 HepPoint3D new_posEstiAtGem = track.x(new_dPhiToGem);
7684 double new_pathInGem;
7685 //cout << "new_dPhiToGem" << new_dPhiToGem << endl;
7686 //cout << "before move2" << "pivot" <<track.pivot().perp() << "," << track.pivot().phi() << "," << track.pivot().z()<< "a" << track.a() << "ea" << track.Ea() << endl;
7687 track.pivot_numf(new_posEstiAtGem, new_pathInGem);
7688 //cout << "posEstiAtGem2=" << new_posEstiAtGem << endl;
7689 //cout << "pathInGem2=" << new_pathInGem << endl;
7690 if(new_pathInGem>0)
7691 {
7692 if(muls_) track.ms(new_pathInGem, _BesKalmanFitMaterials[26+32*iLayer], way);
7693 if(loss_) track.eloss(new_pathInGem, _BesKalmanFitMaterials[26+32*iLayer], way);
7694 }
7695 //cout << "after move2: " << "pivot" <<track.pivot().perp() << "," << track.pivot().phi() << "," << track.pivot().z() << "a" << track.a() << "ea" << track.Ea() << endl;
7696 if(iLayer>=1){
7697 innerwall(track,hypo,way,90+(-32)*iLayer,95+(-32)*iLayer);}
7698 else{
7699 innerwall(track,hypo,way,90+(-32)*iLayer,94+(-32)*iLayer);}
7700 //cout <<"!!!!ntuple" << ntuple_ << endl;
7701 //cout << "!!!(esti1_phi.begin())->second" << (esti1_phi.begin())->second << endl;
7702 //cout<<" Finish innerwall"<<endl;
7703 if(ntuple_&1)
7704 {
7705 //cout << "good!" << endl;
7706 //cout << "m_esti1_r[ii]0" << m_esti1_r[ii] << endl;
7707 m_esti1_r[ii]=(esti1_r.begin())->second;
7708 //cout << "m_esti1_r[ii]1" << m_esti1_r[ii] << endl;
7709 m_esti1_phi[ii]=(esti1_phi.begin())->second;
7710 m_esti1_z[ii]=(esti1_z.begin())->second;
7711 m_esti2_r[ii]=(esti2_r.begin())->second;
7712 m_esti2_phi[ii]=(esti2_phi.begin())->second;
7713 m_esti2_z[ii]=(esti2_z.begin())->second;
7714 m_diff1_phi[ii]=(diff1_phi.begin())->second;
7715 m_diff1_z[ii]=(diff1_z.begin())->second;
7716 m_diff2_phi[ii]=(diff2_phi.begin())->second;
7717 m_diff2_z[ii]=(diff2_z.begin())->second;
7718 m_Gchi2[ii]=(esti1_r.begin())->first;
7719 m_meas_r[ii]=(meas_r.begin())->second;
7720 m_meas_phi[ii]=(meas_phi.begin())->second;
7721 //cout << "m_meas_phi[ii]" << m_meas_phi[ii] << endl;
7722 m_meas_z[ii]=(meas_z.begin())->second;
7723 m_meas_phierr[ii]=(meas_phierr.begin())->second;
7724 m_meas_zerr[ii]=(meas_zerr.begin())->second;
7725 m_esti_phierr[ii]=(esti_phierr.begin())->second;
7726 m_esti_zerr[ii]=(esti_zerr.begin())->second;
7727 m_GemLayer[ii]=iLayer;
7728 m_mass[ii]=hypo;
7729 }
7730 //cout<<" end of ntuple_"<<endl;
7731 ii++;
7732 }// loop layers
7733 //cout<<"finish layer loop"<<endl;
7734
7735 //SmartDataPtr<Event::EventHeader> evtHeader(eventSvc(),"/Event/EventHeader");
7736 //m_evt3 = evtHeader->eventNumber();
7737 if(ifProdNt10) {
7738 //cout << "m_meas_phi[ii]" << m_meas_phi[0] << endl;
7739 if(m_meas_phi[0]>0 && m_meas_phi[0]<1.5707963) m_qua=0;
7740 if(m_meas_phi[0]>1.5707963 && m_meas_phi[0]<3.1415926) m_qua=1;
7741 if(m_meas_phi[0]>-3.1415926&& m_meas_phi[0]<-1.5707963) m_qua=2;
7742 if(m_meas_phi[0]>-1.5707963&& m_meas_phi[0]<0) m_qua=3;
7743 //cout << "m_qua=" << m_qua << endl;
7744 m_nGemHits=ii;
7745 }
7746 //m_Gemhits=ii;
7747 // m_nt7->write();
7748 // m_nt10->write();
7749 posnew.clear();
7750 eanew.clear();
7751 anew.clear();
7752 esti1_r.clear();
7753 esti2_r.clear();
7754 esti1_phi.clear();
7755 esti2_phi.clear();
7756 esti1_z.clear();
7757 esti2_z.clear();
7758 diff1_phi.clear();
7759 diff1_z.clear();
7760 diff2_phi.clear();
7761 diff2_z.clear();
7762 meas_r.clear();
7763 meas_phi.clear();
7764 meas_z.clear();
7765 meas_phierr.clear();
7766 meas_zerr.clear();
7767 esti_phierr.clear();
7768 esti_zerr.clear();
7769
7770 }// end of GEM Kalman fit
7771 //cout << "end of GEM Kalman fit" << endl;
7772 if(ifProdNt10) {
7773 SmartDataPtr<Event::EventHeader> evtHeader(eventSvc(),"/Event/EventHeader");
7774 //cout << "evtHeader" << m_evt3 << endl;
7775 m_evt3 = evtHeader->eventNumber();
7776 m_nt10->write();
7777 }
7778
7779}
EvtStreamInputIterator< typename Generator::result_type > iter(Generator gen, int N=0)
double m_alpha
Definition KalFitAlg.h:249
void ms(double path, const KalFitMaterial &m, int index)
void set(const HepPoint3D &pivot, const HepVector &a, const HepSymMatrix &Ea)
sets helix pivot position, parameters, and error matrix.
IMPLICIT REAL *A H
Definition myXsection.h:1
complex_t R(double Q2, double M2, double G, double Mp2, double Mm2)
Definition TUtil.h:27

◆ fromFHitToInnerWall()

void KalFitAlg::fromFHitToInnerWall ( KalFitTrack & track,
int way )

Definition at line 6888 of file KalFitAlg.cxx.

6889{
6890 double rMaxInnerWall=6.42005+0.00495;
6891 if(useNCGem_>1) { // GEM mode
6892 //rMaxInnerWall=m_CGEM.end()->radius();
6893 //rMaxInnerWall=16.7;
6894 rMaxInnerWall=m_innerWall[0].radius();
6895 }
6896 else { // MDC mode
6897 rMaxInnerWall=_BesKalmanFitWalls[0].radius();
6898 }
6899 double dPhiToInnerWall = track.intersect_cylinder(rMaxInnerWall);
6900 HepPoint3D posAtInnerWall = track.x(dPhiToInnerWall);
6901 double pathToInnerWall;
6902 track.pivot_numf(posAtInnerWall, pathToInnerWall);
6903 //cout<<"__FUNCTION__: rMaxInnerWall = "<<rMaxInnerWall<<endl;
6904 //cout<<"posAtInnerWall, pathToInnerWall = "<<posAtInnerWall<<", "<<pathToInnerWall<<endl;
6905 if(pathToInnerWall>0)
6906 {
6907 if(muls_) track.ms(pathToInnerWall, _BesKalmanFitMaterials[0], way);
6908 if(loss_) track.eloss(pathToInnerWall, _BesKalmanFitMaterials[0], way);
6909 }
6910 if(useNCGem_>0) m_innerWall[0].updateTrack(track, way);
6911
6912}

◆ getEventStarTime()

void KalFitAlg::getEventStarTime ( void )

◆ getWallMdcNumber()

int KalFitAlg::getWallMdcNumber ( const HepPoint3D & point)

◆ hist_def()

void KalFitAlg::hist_def ( void )

hist definition

Definition at line 378 of file KalFitAlg.cxx.

379{
380 if(ntuple_&1) {
381 NTuplePtr nt1(ntupleSvc(),"FILE104/n101");
382 StatusCode status;
383 if ( nt1 ) m_nt1 = nt1;
384 else {
385 m_nt1= ntupleSvc()->book("FILE104/n101",CLID_ColumnWiseTuple,"KalFit");
386 if ( m_nt1 ) {
387
388 status = m_nt1->addItem("trackid",m_trackid);
389 status = m_nt1->addItem("stat",5,2,m_stat);
390 status = m_nt1->addItem("ndf",5,2,m_ndf);
391 status = m_nt1->addItem("chisq",5,2,m_chisq);
392 status = m_nt1->addItem("length",5,m_length);
393 status = m_nt1->addItem("tof",5,m_tof);
394 status = m_nt1->addItem("nhits",5,m_nhits);
395 status = m_nt1->addItem("zhelix",5,m_zhelix);
396 status = m_nt1->addItem("zhelixe",5,m_zhelixe);
397 status = m_nt1->addItem("zhelixmu",5,m_zhelixmu);
398 status = m_nt1->addItem("zhelixk",5,m_zhelixk);
399 status = m_nt1->addItem("zhelixp",5,m_zhelixp);
400 status = m_nt1->addItem("zptot",m_zptot);
401 status = m_nt1->addItem("zptote",m_zptote);
402 status = m_nt1->addItem("zptotmu",m_zptotmu);
403 status = m_nt1->addItem("zptotk",m_zptotk);
404 status = m_nt1->addItem("zptotp",m_zptotp);
405
406 status = m_nt1->addItem("zpt",m_zpt);
407 status = m_nt1->addItem("zpte",m_zpte);
408 status = m_nt1->addItem("zptmu",m_zptmu);
409 status = m_nt1->addItem("zptk",m_zptk);
410 status = m_nt1->addItem("zptp",m_zptp);
411
412 status = m_nt1->addItem("fptot",m_fptot);
413 status = m_nt1->addItem("fptote",m_fptote);
414 status = m_nt1->addItem("fptotmu",m_fptotmu);
415 status = m_nt1->addItem("fptotk",m_fptotk);
416 status = m_nt1->addItem("fptotp",m_fptotp);
417 status = m_nt1->addItem("fpt",m_fpt);
418 status = m_nt1->addItem("fpte",m_fpte);
419 status = m_nt1->addItem("fptmu",m_fptmu);
420 status = m_nt1->addItem("fptk",m_fptk);
421 status = m_nt1->addItem("fptp",m_fptp);
422
423 status = m_nt1->addItem("lptot",m_lptot);
424 status = m_nt1->addItem("lptote",m_lptote);
425 status = m_nt1->addItem("lptotmu",m_lptotmu);
426 status = m_nt1->addItem("lptotk",m_lptotk);
427 status = m_nt1->addItem("lptotp",m_lptotp);
428 status = m_nt1->addItem("lpt",m_lpt);
429 status = m_nt1->addItem("lpte",m_lpte);
430 status = m_nt1->addItem("lptmu",m_lptmu);
431 status = m_nt1->addItem("lptk",m_lptk);
432 status = m_nt1->addItem("lptp",m_lptp);
433
434 status = m_nt1->addItem("zsigp",m_zsigp);
435 status = m_nt1->addItem("zsigpe",m_zsigpe);
436 status = m_nt1->addItem("zsigpmu",m_zsigpmu);
437 status = m_nt1->addItem("zsigpk",m_zsigpk);
438 status = m_nt1->addItem("zsigpp",m_zsigpp);
439 status = m_nt1->addItem("fhelix",5,m_fhelix);
440 status = m_nt1->addItem("fhelixe",5,m_fhelixe);
441 status = m_nt1->addItem("fhelixmu",5,m_fhelixmu);
442 status = m_nt1->addItem("fhelixk",5,m_fhelixk);
443 status = m_nt1->addItem("fhelixp",5,m_fhelixp);
444 status = m_nt1->addItem("lhelix",5,m_lhelix);
445 status = m_nt1->addItem("lhelixe",5,m_lhelixe);
446 status = m_nt1->addItem("lhelixmu",5,m_lhelixmu);
447 status = m_nt1->addItem("lhelixk",5,m_lhelixk);
448 status = m_nt1->addItem("lhelixp",5,m_lhelixp);
449 status = m_nt1->addItem("rGem",4,m_rGem);
450 status = m_nt1->addItem("chi2Gem",4,m_chi2Gem);
451 status = m_nt1->addItem("phiGemExp",4,m_phiGemExp);
452 status = m_nt1->addItem("phiGemHit",4,m_phiGemHit);
453 status = m_nt1->addItem("zGemExp",4,m_zGemExp);
454 status = m_nt1->addItem("zGemHit",4,m_zGemHit);
455 if(ntuple_&32) {
456 status = m_nt1->addItem("zerror",15,m_zerror);
457 status = m_nt1->addItem("zerrore",15,m_zerrore);
458 status = m_nt1->addItem("zerrormu",15,m_zerrormu);
459 status = m_nt1->addItem("zerrork",15,m_zerrork);
460 status = m_nt1->addItem("zerrorp",15,m_zerrorp);
461 status = m_nt1->addItem("ferror",15,m_ferror);
462 status = m_nt1->addItem("ferrore",15,m_ferrore);
463 status = m_nt1->addItem("ferrormu",15,m_ferrormu);
464 status = m_nt1->addItem("ferrork",15,m_ferrork);
465 status = m_nt1->addItem("ferrorp",15,m_ferrorp);
466 status = m_nt1->addItem("lerror",15,m_lerror);
467 status = m_nt1->addItem("lerrore",15,m_lerrore);
468 status = m_nt1->addItem("lerrormu",15,m_lerrormu);
469 status = m_nt1->addItem("lerrork",15,m_lerrork);
470 status = m_nt1->addItem("lerrorp",15,m_lerrorp);
471 }
472 if((ntuple_&16)&&(ntuple_&1)) {
473 status = m_nt1->addItem("evtid",m_evtid);
474 status = m_nt1->addItem("mchelix",5,m_mchelix);
475 status = m_nt1->addItem("mcptot",m_mcptot);
476 status = m_nt1->addItem("mcpid",m_mcpid);
477 }
478 if( status.isFailure() ) cout<<"Ntuple1 add item failed!"<<endl;
479 }
480 }
481 }
482
483 if(ntuple_&4) {
484 NTuplePtr nt2(ntupleSvc(),"FILE104/n102");
485 StatusCode status2;
486 if ( nt2 ) m_nt2 = nt2;
487 else {
488 m_nt2= ntupleSvc()->book("FILE104/n102",CLID_ColumnWiseTuple,"KalFitComp");
489 if ( m_nt2 ) {
490 status2 = m_nt2->addItem("delx",m_delx);
491 status2 = m_nt2->addItem("dely",m_dely);
492 status2 = m_nt2->addItem("delz",m_delz);
493 status2 = m_nt2->addItem("delthe",m_delthe);
494 status2 = m_nt2->addItem("delphi",m_delphi);
495 status2 = m_nt2->addItem("delp",m_delp);
496 status2 = m_nt2->addItem("delpx",m_delpx);
497 status2 = m_nt2->addItem("delpy",m_delpy);
498 status2 = m_nt2->addItem("delpz",m_delpz);
499
500 if( status2.isFailure() ) cout<<"Ntuple2 add item failed!"<<endl;
501 }
502 }
503 }
504
505 if(ntuple_&2) {
506 NTuplePtr nt3(ntupleSvc(),"FILE104/n103");
507 StatusCode status3;
508 if ( nt3 ) m_nt3 = nt3;
509 else {
510 m_nt3= ntupleSvc()->book("FILE104/n103",CLID_ColumnWiseTuple,"PatRec");
511 if ( m_nt3 ) {
512 status3 = m_nt3->addItem("trkhelix",5,m_trkhelix);
513 status3 = m_nt3->addItem("trkptot",m_trkptot);
514 if(ntuple_&32) {
515 status3 = m_nt3->addItem("trkerror",15,m_trkerror);
516 status3 = m_nt3->addItem("trksigp",m_trksigp);
517 }
518 status3 = m_nt3->addItem("trkndf",m_trkndf);
519 status3 = m_nt3->addItem("trkchisq",m_trkchisq);
520 if( status3.isFailure() ) cout<<"Ntuple3 add item failed!"<<endl;
521 }
522 }
523 }
524
525 if(ntuple_&4) {
526 NTuplePtr nt4(ntupleSvc(),"FILE104/n104");
527 StatusCode status4;
528 if ( nt4 ) m_nt4 = nt4;
529 else {
530 m_nt4= ntupleSvc()->book("FILE104/n104",CLID_ColumnWiseTuple,"PatRecComp");
531 if ( m_nt4 ) {
532 status4 = m_nt4->addItem("trkdelx",m_trkdelx);
533 status4 = m_nt4->addItem("trkdely",m_trkdely);
534 status4 = m_nt4->addItem("trkdelz",m_trkdelz);
535 status4 = m_nt4->addItem("trkdelthe",m_trkdelthe);
536 status4 = m_nt4->addItem("trkdelphi",m_trkdelphi);
537 status4 = m_nt4->addItem("trkdelp",m_trkdelp);
538 if( status4.isFailure() ) cout<<"Ntuple4 add item failed!"<<endl;
539 }
540 }
541 }
542 if(ntuple_&8) {
543 NTuplePtr nt5(ntupleSvc(), "FILE104/n105");
544 StatusCode status5;
545 if ( nt5 ) m_nt5 = nt5;
546 else {
547 m_nt5= ntupleSvc()->book("FILE104/n105",CLID_ColumnWiseTuple,"KalFitdChisq");
548 if ( m_nt5 ) {
549 status5 = m_nt5->addItem("dchi2",m_dchi2);
550 status5 = m_nt5->addItem("masshyp",m_masshyp);
551 status5 = m_nt5->addItem("residual_estim",m_residest);
552 status5 = m_nt5->addItem("residual",m_residnew);
553 status5 = m_nt5->addItem("layer",m_layer);
554 status5 = m_nt5->addItem("kaldr",m_anal_dr);
555 status5 = m_nt5->addItem("kalphi0",m_anal_phi0);
556 status5 = m_nt5->addItem("kalkappa",m_anal_kappa);
557 status5 = m_nt5->addItem("kaldz",m_anal_dz);
558 status5 = m_nt5->addItem("kaltanl",m_anal_tanl);
559 status5 = m_nt5->addItem("dr_ea",m_anal_ea_dr);
560 status5 = m_nt5->addItem("phi0_ea",m_anal_ea_phi0);
561 status5 = m_nt5->addItem("kappa_ea",m_anal_ea_kappa);
562 status5 = m_nt5->addItem("dz_ea",m_anal_ea_dz);
563 status5 = m_nt5->addItem("tanl_ea",m_anal_ea_tanl);
564 if( status5.isFailure() ) cout<<"Ntuple5 add item failed!"<<endl;
565 }
566 }
567 }
568
569 //For kalman fit failure
570 //cout<<"start to book ntuple!"<<endl;
571 NTuplePtr nt7(ntupleSvc(),"FILE104/n120");
572 StatusCode status7;
573 if(nt7) m_nt7 = nt7;
574 else{
575 m_nt7 = ntupleSvc()-> book("FILE104/n120",CLID_ColumnWiseTuple,"kalfit_failure");
576 if(m_nt7){
577 status7 = m_nt7 ->addItem("run_kal",m_run_kal);
578 status7 = m_nt7 ->addItem("event_kal",m_event_kal);
579 status7 = m_nt7 ->addItem("trkid_kal",m_trkid_kal);
580 status7 = m_nt7->addItem("mchelix",5,m_mchelix);
581 status7 = m_nt7->addItem("mcptot",m_mcptot);
582 status7 = m_nt7->addItem("mcpid",m_mcpid);
583 status7 = m_nt7 ->addItem("dropedHits_kal_e",m_dropedHits_kal_e);
584 status7 = m_nt7 ->addItem("kappa2_kal_e",m_kappa2_kal_e);
585 status7 = m_nt7 ->addItem("trackNhits_kal_e",m_trackNhits_kal_e);
586 status7 = m_nt7 ->addItem("trackNster_kal_e",m_trackNster_kal_e);
587 status7 = m_nt7 ->addItem("trackNaxis_kal_e",m_trackNaxis_kal_e);
588 status7 = m_nt7 ->addItem("chi2_kal_e",m_chi2_kal_e);
589 status7 = m_nt7 ->addItem("Ea00_kal_e",m_Ea00_kal_e);
590 status7 = m_nt7 ->addItem("Ea11_kal_e",m_Ea11_kal_e);
591 status7 = m_nt7 ->addItem("Ea22_kal_e",m_Ea22_kal_e);
592 status7 = m_nt7 ->addItem("Ea33_kal_e",m_Ea33_kal_e);
593 status7 = m_nt7 ->addItem("Ea44_kal_e",m_Ea44_kal_e);
594 status7 = m_nt7 ->addItem("dropedHits_kal_mu",m_dropedHits_kal_mu);
595 status7 = m_nt7 ->addItem("kappa2_kal_mu",m_kappa2_kal_mu);
596 status7 = m_nt7 ->addItem("trackNhits_kal_mu",m_trackNhits_kal_mu);
597 status7 = m_nt7 ->addItem("trackNster_kal_mu",m_trackNster_kal_mu);
598 status7 = m_nt7 ->addItem("trackNaxis_kal_mu",m_trackNaxis_kal_mu);
599 status7 = m_nt7 ->addItem("chi2_kal_mu",m_chi2_kal_mu);
600 status7 = m_nt7 ->addItem("Ea00_kal_mu",m_Ea00_kal_mu);
601 status7 = m_nt7 ->addItem("Ea11_kal_mu",m_Ea11_kal_mu);
602 status7 = m_nt7 ->addItem("Ea22_kal_mu",m_Ea22_kal_mu);
603 status7 = m_nt7 ->addItem("Ea33_kal_mu",m_Ea33_kal_mu);
604 status7 = m_nt7 ->addItem("Ea44_kal_mu",m_Ea44_kal_mu);
605 status7 = m_nt7 ->addItem("iqual_front_kal_mu",m_iqual_front_kal_mu);
606 status7 = m_nt7 ->addItem("dropedHits_kal_pi",m_dropedHits_kal_pi);
607 status7 = m_nt7 ->addItem("kappa2_kal_pi",m_kappa2_kal_pi);
608 status7 = m_nt7 ->addItem("trackNhits_kal_pi",m_trackNhits_kal_pi);
609 status7 = m_nt7 ->addItem("trackNster_kal_pi",m_trackNster_kal_pi);
610 status7 = m_nt7 ->addItem("trackNaxis_kal_pi",m_trackNaxis_kal_pi);
611 status7 = m_nt7 ->addItem("chi2_kal_pi",m_chi2_kal_pi);
612 status7 = m_nt7 ->addItem("Ea00_kal_pi",m_Ea00_kal_pi);
613 status7 = m_nt7 ->addItem("Ea11_kal_pi",m_Ea11_kal_pi);
614 status7 = m_nt7 ->addItem("Ea22_kal_pi",m_Ea22_kal_pi);
615 status7 = m_nt7 ->addItem("Ea33_kal_pi",m_Ea33_kal_pi);
616 status7 = m_nt7 ->addItem("Ea44_kal_pi",m_Ea44_kal_pi);
617 status7 = m_nt7 ->addItem("dropedHits_kal_k",m_dropedHits_kal_k);
618 status7 = m_nt7 ->addItem("kappa2_kal_k",m_kappa2_kal_k);
619 status7 = m_nt7 ->addItem("trackNhits_kal_k",m_trackNhits_kal_k);
620 status7 = m_nt7 ->addItem("trackNster_kal_k",m_trackNster_kal_k);
621 status7 = m_nt7 ->addItem("trackNaxis_kal_k",m_trackNaxis_kal_k);
622 status7 = m_nt7 ->addItem("chi2_kal_k",m_chi2_kal_k);
623 status7 = m_nt7 ->addItem("Ea00_kal_k",m_Ea00_kal_k);
624 status7 = m_nt7 ->addItem("Ea11_kal_k",m_Ea11_kal_k);
625 status7 = m_nt7 ->addItem("Ea22_kal_k",m_Ea22_kal_k);
626 status7 = m_nt7 ->addItem("Ea33_kal_k",m_Ea33_kal_k);
627 status7 = m_nt7 ->addItem("Ea44_kal_k",m_Ea44_kal_k);
628 status7 = m_nt7 ->addItem("dropedHits_kal_p",m_dropedHits_kal_p);
629 status7 = m_nt7 ->addItem("kappa2_kal_p",m_kappa2_kal_p);
630 status7 = m_nt7 ->addItem("trackNhits_kal_p",m_trackNhits_kal_p);
631 status7 = m_nt7 ->addItem("trackNster_kal_p",m_trackNster_kal_p);
632 status7 = m_nt7 ->addItem("trackNaxis_kal_p",m_trackNaxis_kal_p);
633 status7 = m_nt7 ->addItem("chi2_kal_p",m_chi2_kal_p);
634 status7 = m_nt7 ->addItem("Ea00_kal_p",m_Ea00_kal_p);
635 status7 = m_nt7 ->addItem("Ea11_kal_p",m_Ea11_kal_p);
636 status7 = m_nt7 ->addItem("Ea22_kal_p",m_Ea22_kal_p);
637 status7 = m_nt7 ->addItem("Ea33_kal_p",m_Ea33_kal_p);
638 status7 = m_nt7 ->addItem("Ea44_kal_p",m_Ea44_kal_p);
639
640 status7 = m_nt7 ->addItem("hit_number",m_hit_no,0, 1000);
641 status7 = m_nt7 ->addItem("nCluster",m_nCluster,0, 1000);
642 status7 = m_nt7->addIndexedItem("dchi2_hit_e",m_hit_no,m_dchi2_hit_e);
643 status7 = m_nt7->addIndexedItem("residual_estim_hit_e",m_hit_no,m_residest_hit_e);
644 status7 = m_nt7->addIndexedItem("residual_hit_e",m_hit_no,m_residnew_hit_e);
645 status7 = m_nt7->addIndexedItem("layer_hit_e",m_hit_no,m_layer_hit_e);
646 status7 = m_nt7->addIndexedItem("kaldr_hit_e",m_hit_no,m_anal_dr_hit_e);
647 status7 = m_nt7->addIndexedItem("kalphi0_hit_e",m_hit_no,m_anal_phi0_hit_e);
648 status7 = m_nt7->addIndexedItem("kalkappa_hit_e",m_hit_no,m_anal_kappa_hit_e);
649 status7 = m_nt7->addIndexedItem("kaldz_hit_e",m_hit_no,m_anal_dz_hit_e);
650 status7 = m_nt7->addIndexedItem("kaltanl_hit_e",m_hit_no,m_anal_tanl_hit_e);
651 status7 = m_nt7->addIndexedItem("dr_ea_hit_e",m_hit_no,m_anal_ea_dr_hit_e);
652 status7 = m_nt7->addIndexedItem("phi0_ea_hit_e",m_hit_no,m_anal_ea_phi0_hit_e);
653 status7 = m_nt7->addIndexedItem("kappa_ea_hit_e",m_hit_no,m_anal_ea_kappa_hit_e);
654 status7 = m_nt7->addIndexedItem("dz_ea_hit_e",m_hit_no,m_anal_ea_dz_hit_e);
655 status7 = m_nt7->addIndexedItem("tanl_ea_hit_e",m_hit_no,m_anal_ea_tanl_hit_e);
656 status7 = m_nt7->addIndexedItem("dchi2_hit_mu",m_hit_no,m_dchi2_hit_mu);
657 status7 = m_nt7->addIndexedItem("residual_estim_hit_mu",m_hit_no,m_residest_hit_mu);
658 status7 = m_nt7->addIndexedItem("residual_hit_mu",m_hit_no,m_residnew_hit_mu);
659 status7 = m_nt7->addIndexedItem("layer_hit_mu",m_hit_no,m_layer_hit_mu);
660 status7 = m_nt7->addIndexedItem("kaldr_hit_mu",m_hit_no,m_anal_dr_hit_mu);
661 status7 = m_nt7->addIndexedItem("kalphi0_hit_mu",m_hit_no,m_anal_phi0_hit_mu);
662 status7 = m_nt7->addIndexedItem("kalkappa_hit_mu",m_hit_no,m_anal_kappa_hit_mu);
663 status7 = m_nt7->addIndexedItem("kaldz_hit_mu",m_hit_no,m_anal_dz_hit_mu);
664 status7 = m_nt7->addIndexedItem("kaltanl_hit_mu",m_hit_no,m_anal_tanl_hit_mu);
665 status7 = m_nt7->addIndexedItem("dr_ea_hit_mu",m_hit_no,m_anal_ea_dr_hit_mu);
666 status7 = m_nt7->addIndexedItem("phi0_ea_hit_mu",m_hit_no,m_anal_ea_phi0_hit_mu);
667 status7 = m_nt7->addIndexedItem("kappa_ea_hit_mu",m_hit_no,m_anal_ea_kappa_hit_mu);
668 status7 = m_nt7->addIndexedItem("dz_ea_hit_mu",m_hit_no,m_anal_ea_dz_hit_mu);
669 status7 = m_nt7->addIndexedItem("tanl_ea_hit_mu",m_hit_no,m_anal_ea_tanl_hit_mu);
670 status7 = m_nt7->addIndexedItem("dchi2_hit_pi",m_hit_no,m_dchi2_hit_pi);
671 status7 = m_nt7->addIndexedItem("residual_estim_hit_pi",m_hit_no,m_residest_hit_pi);
672 status7 = m_nt7->addIndexedItem("residual_hit_pi",m_hit_no,m_residnew_hit_pi);
673 status7 = m_nt7->addIndexedItem("layer_hit_pi",m_hit_no,m_layer_hit_pi);
674 status7 = m_nt7->addIndexedItem("kaldr_hit_pi",m_hit_no,m_anal_dr_hit_pi);
675 status7 = m_nt7->addIndexedItem("kalphi0_hit_pi",m_hit_no,m_anal_phi0_hit_pi);
676 status7 = m_nt7->addIndexedItem("kalkappa_hit_pi",m_hit_no,m_anal_kappa_hit_pi);
677 status7 = m_nt7->addIndexedItem("kaldz_hit_pi",m_hit_no,m_anal_dz_hit_pi);
678 status7 = m_nt7->addIndexedItem("kaltanl_hit_pi",m_hit_no,m_anal_tanl_hit_pi);
679 status7 = m_nt7->addIndexedItem("dr_ea_hit_pi",m_hit_no,m_anal_ea_dr_hit_pi);
680 status7 = m_nt7->addIndexedItem("phi0_ea_hit_pi",m_hit_no,m_anal_ea_phi0_hit_pi);
681 status7 = m_nt7->addIndexedItem("kappa_ea_hit_pi",m_hit_no,m_anal_ea_kappa_hit_pi);
682 status7 = m_nt7->addIndexedItem("dz_ea_hit_pi",m_hit_no,m_anal_ea_dz_hit_pi);
683 status7 = m_nt7->addIndexedItem("tanl_ea_hit_pi",m_hit_no,m_anal_ea_tanl_hit_pi);
684 status7 = m_nt7->addIndexedItem("dchi2_hit_k",m_hit_no,m_dchi2_hit_k);
685 status7 = m_nt7->addIndexedItem("residual_estim_hit_k",m_hit_no,m_residest_hit_k);
686 status7 = m_nt7->addIndexedItem("residual_hit_k",m_hit_no,m_residnew_hit_k);
687 status7 = m_nt7->addIndexedItem("layer_hit_k",m_hit_no,m_layer_hit_k);
688 status7 = m_nt7->addIndexedItem("kaldr_hit_k",m_hit_no,m_anal_dr_hit_k);
689 status7 = m_nt7->addIndexedItem("kalphi0_hit_k",m_hit_no,m_anal_phi0_hit_k);
690 status7 = m_nt7->addIndexedItem("kalkappa_hit_k",m_hit_no,m_anal_kappa_hit_k);
691 status7 = m_nt7->addIndexedItem("kaldz_hit_k",m_hit_no,m_anal_dz_hit_k);
692 status7 = m_nt7->addIndexedItem("kaltanl_hit_k",m_hit_no,m_anal_tanl_hit_k);
693 status7 = m_nt7->addIndexedItem("dr_ea_hit_k",m_hit_no,m_anal_ea_dr_hit_k);
694 status7 = m_nt7->addIndexedItem("phi0_ea_hit_k",m_hit_no,m_anal_ea_phi0_hit_k);
695 status7 = m_nt7->addIndexedItem("kappa_ea_hit_k",m_hit_no,m_anal_ea_kappa_hit_k);
696 status7 = m_nt7->addIndexedItem("dz_ea_hit_k",m_hit_no,m_anal_ea_dz_hit_k);
697 status7 = m_nt7->addIndexedItem("tanl_ea_hit_k",m_hit_no,m_anal_ea_tanl_hit_k);
698 status7 = m_nt7->addIndexedItem("dchi2_hit_p",m_hit_no,m_dchi2_hit_p);
699 status7 = m_nt7->addIndexedItem("residual_estim_hit_p",m_hit_no,m_residest_hit_p);
700 status7 = m_nt7->addIndexedItem("residual_hit_p",m_hit_no,m_residnew_hit_p);
701 status7 = m_nt7->addIndexedItem("layer_hit_p",m_hit_no,m_layer_hit_p);
702 status7 = m_nt7->addIndexedItem("kaldr_hit_p",m_hit_no,m_anal_dr_hit_p);
703 status7 = m_nt7->addIndexedItem("kalphi0_hit_p",m_hit_no,m_anal_phi0_hit_p);
704 status7 = m_nt7->addIndexedItem("kalkappa_hit_p",m_hit_no,m_anal_kappa_hit_p);
705 status7 = m_nt7->addIndexedItem("kaldz_hit_p",m_hit_no,m_anal_dz_hit_p);
706 status7 = m_nt7->addIndexedItem("kaltanl_hit_p",m_hit_no,m_anal_tanl_hit_p);
707 status7 = m_nt7->addIndexedItem("dr_ea_hit_p",m_hit_no,m_anal_ea_dr_hit_p);
708 status7 = m_nt7->addIndexedItem("phi0_ea_hit_p",m_hit_no,m_anal_ea_phi0_hit_p);
709 status7 = m_nt7->addIndexedItem("kappa_ea_hit_p",m_hit_no,m_anal_ea_kappa_hit_p);
710 status7 = m_nt7->addIndexedItem("dz_ea_hit_p",m_hit_no,m_anal_ea_dz_hit_p);
711 status7 = m_nt7->addIndexedItem("tanl_ea_hit_p",m_hit_no,m_anal_ea_tanl_hit_p);
712
713 if( status7.isFailure() ) cout<<"Ntuple7 add item failed!"<<endl;
714 }
715 }
716 //cout<<"book ntuple done!"<<endl;
717
718
719
720 NTuplePtr nt6(ntupleSvc(),"FILE104/n106");
721 StatusCode status6;
722 if ( nt6 ) m_nt6 = nt6;
723 else {
724 m_nt6= ntupleSvc()->book("FILE104/n106",CLID_ColumnWiseTuple,"kal seg");
725 if ( m_nt6 ) {
726 status6 = m_nt6->addItem("docaInc",m_docaInc);
727 status6 = m_nt6->addItem("docaExc",m_docaExc);
728 status6 = m_nt6->addItem("tdr",m_tdrift);
729 status6 = m_nt6->addItem("layerid", m_layerid);
730 status6 = m_nt6->addItem("event", m_eventNo);
731 status6 = m_nt6->addItem("residualInc",m_residualInc);
732 status6 = m_nt6->addItem("residualExc",m_residualExc);
733 status6 = m_nt6->addItem("lr",m_lr);
734 status6 = m_nt6->addItem("dd",m_dd);
735 status6 = m_nt6->addItem("y",m_yposition);
736
737 if( status6.isFailure() ) cout<<"Ntuple6 add item failed!"<<endl;
738 }
739 }
740
741 if(ifProdNt10) {
742 NTuplePtr nt10(ntupleSvc(),"FILE104/n110");
743 StatusCode status10;
744 if ( nt10 ) m_nt10 = nt10;
745 else {
746 m_nt10= ntupleSvc()->book("FILE104/n110",CLID_ColumnWiseTuple,"test");
747 if ( m_nt10 ) {
748 status10 = m_nt10->addItem("evt",m_evt3);
749 status10 = m_nt10->addItem("qua",m_qua);
750 status10 = m_nt10->addItem("nhit",m_nGemHits,0,4000000);
751 status10 = m_nt10->addIndexedItem("meas_r",m_nGemHits,m_meas_r);
752 status10 = m_nt10->addIndexedItem("meas_phi",m_nGemHits,m_meas_phi);
753 status10 = m_nt10->addIndexedItem("meas_z",m_nGemHits,m_meas_z);
754 status10 = m_nt10->addIndexedItem("esti1_r",m_nGemHits,m_esti1_r);
755 status10 = m_nt10->addIndexedItem("esti1_phi",m_nGemHits,m_esti1_phi);
756 status10 = m_nt10->addIndexedItem("esti1_z",m_nGemHits,m_esti1_z);
757 status10 = m_nt10->addIndexedItem("esti2_r",m_nGemHits,m_esti2_r);
758 status10 = m_nt10->addIndexedItem("esti2_phi",m_nGemHits,m_esti2_phi);
759 status10 = m_nt10->addIndexedItem("esti2_z",m_nGemHits,m_esti2_z);
760 status10 = m_nt10->addIndexedItem("diff1_phi",m_nGemHits,m_diff1_phi);
761 status10 = m_nt10->addIndexedItem("diff1_z",m_nGemHits,m_diff1_z);
762 status10 = m_nt10->addIndexedItem("diff2_phi",m_nGemHits,m_diff2_phi);
763 status10 = m_nt10->addIndexedItem("diff2_z",m_nGemHits,m_diff2_z);
764 status10 = m_nt10->addIndexedItem("layer",m_nGemHits,m_GemLayer);
765 status10 = m_nt10->addIndexedItem("mass",m_nGemHits,m_mass);
766 status10 = m_nt10->addIndexedItem("dchi2",m_nGemHits,m_Gchi2);
767 status10 = m_nt10->addIndexedItem("meas_phierr",m_nGemHits,m_meas_phierr);
768 status10 = m_nt10->addIndexedItem("meas_zerr",m_nGemHits,m_meas_zerr);
769 status10 = m_nt10->addIndexedItem("esti_phierr",m_nGemHits,m_esti_phierr);
770 status10 = m_nt10->addIndexedItem("esti_zerr",m_nGemHits,m_esti_zerr);
771 if( status10.isFailure() ) cout<<"Ntuple10 add item failed!"<<endl;
772 }
773 }
774 }
775
776 if(ifProdNt11) {
777 NTuplePtr nt11(ntupleSvc(),"FILE104/n111");
778 StatusCode status11;
779 if ( nt11 ) m_nt11 = nt11;
780 else {
781 m_nt11= ntupleSvc()->book("FILE104/n111",CLID_ColumnWiseTuple,"truth");
782 if ( m_nt11 ) {
783 status11 = m_nt11->addItem("evt",m_evt4);
784 status11 = m_nt11->addItem("ntruth",m_ntruth,0,400000);
785 status11 = m_nt11->addIndexedItem("phi",m_ntruth,m_dtphi);
786 status11 = m_nt11->addIndexedItem("z",m_ntruth,m_dtv);
787 status11 = m_nt11->addIndexedItem("postphi",m_ntruth,m_dtpostphi);
788 status11 = m_nt11->addIndexedItem("postz",m_ntruth,m_dtpostz);
789 status11 = m_nt11->addIndexedItem("layer",m_ntruth,m_tlayer);
790 if( status11.isFailure() ) cout<<"Ntuple11 add item failed!"<<endl;
791 }
792 }
793 }
794
795 if(ifProdNt12) {
796 NTuplePtr nt12(ntupleSvc(),"FILE104/n112");
797 StatusCode status12;
798 if ( nt12 ) m_nt12 = nt12;
799 else {
800 m_nt12= ntupleSvc()->book("FILE104/n112",CLID_ColumnWiseTuple,"PatRecComp");
801 if ( m_nt12 ) {
802 status12 = m_nt12->addItem("evt",m_evt);
803 status12 = m_nt12->addItem("track",m_track);
804 status12 = m_nt12->addItem("diff_dr",m_diff_dr);
805 status12 = m_nt12->addItem("diff_phi0",m_diff_phi0);
806 status12 = m_nt12->addItem("diff_kappa",m_diff_kappa);
807 status12 = m_nt12->addItem("diff_dz",m_diff_dz);
808 status12 = m_nt12->addItem("diff_tanl",m_diff_tanl);
809 status12 = m_nt12->addItem("diff_p",m_diff_p);
810 if( status12.isFailure() ) cout<<"Ntuple12 add item failed!"<<endl;
811 }
812 }
813 }
814}
INTupleSvc * ntupleSvc()

Referenced by initialize().

◆ init_matrix() [1/2]

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

Definition at line 6568 of file KalFitAlg.cxx.

6569{
6570 if(0==k){
6571 for ( int i=0; i<5; i++) {
6572 for( int j = 1; j<i+2;j++) {
6573 Eakal(i+1,j) = matrixg_*(trk.error[i*(i+1)/2+j-1]);
6574 Eakal(j,i+1) = Eakal(i+1,j);
6575 }
6576 Eakal(1,1) = Eakal(1,1)* gain1_;
6577 Eakal(2,2) = Eakal(2,2)* gain2_;
6578 Eakal(3,3) = Eakal(3,3)* gain3_;
6579 Eakal(4,4) = Eakal(4,4)* gain4_;
6580 Eakal(5,5) = Eakal(5,5)* gain5_;
6581 }
6582 }
6583 // HepSymMatrix ea_temp(5);
6584 // for(int i = 0, k = 0; i < 5; i++) {
6585 // for(int j = 0; j <= i; j++) {
6586 // ea_temp[i][j] = matrixg_*trk.error[k++];
6587 // ea_temp[j][i] = ea_temp[i][j];
6588 // }
6589 // }
6590
6591 if(1==k){
6592 Eakal(1,1) = .2;
6593 Eakal(2,2) = .001;
6594 Eakal(3,3) = 1.0;
6595 Eakal(4,4) = 10.0;
6596 Eakal(5,5) = 0.002;
6597 }
6598
6599 if(2==k){
6600 Eakal(1,1) = .2;
6601 Eakal(2,2) = 0.1;
6602 Eakal(3,3) = 1.0;
6603 Eakal(4,4) = 25.0;
6604 Eakal(5,5) = 0.10;
6605 }
6606
6607
6608 if(3==k){
6609 Eakal(1,1) = .2;
6610 Eakal(2,2) = .001;
6611 Eakal(3,3) = 1.0;
6612 Eakal(4,4) = 25.0;
6613 Eakal(5,5) = 0.10;
6614 }
6615
6616 if(4==k){
6617 Eakal(1,1) = .2;
6618 Eakal(2,2) = .01;
6619 Eakal(3,3) = 0.01;
6620 Eakal(4,4) = 1.;
6621 Eakal(5,5) = .01;
6622 }
6623
6624 if(5==k) {
6625 Eakal(1,1) = 2.;
6626 Eakal(2,2) = 0.1;
6627 Eakal(3,3) = 1.;
6628 Eakal(4,4) = 20.;
6629 Eakal(5,5) = 0.1;
6630 }
6631
6632 if(6==k) {
6633 Eakal(1,1) = 0.01;
6634 Eakal(2,2) = 0.01;
6635 Eakal(3,3) = 0.01;
6636 Eakal(4,4) = 100.;
6637 Eakal(5,5) = 0.5;
6638 }
6639
6640 if(k!=0){
6641 Eakal(3,3) = 0.2;
6642 Eakal(1,1) = 1;
6643 Eakal(4,4) = 1;
6644 }
6645
6646 if (debug_ == 4) cout<<"initialised Eakal.. "<<Eakal<<endl;
6647}

◆ init_matrix() [2/2]

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

Definition at line 6554 of file KalFitAlg.cxx.

6555{
6556 for ( int i=0; i<5; i++) {
6557 for( int j = 1; j<i+2;j++) {
6558 Eakal(i+1,j) = matrixg_*(trk.error[i*(i+1)/2+j-1]);
6559 Eakal(j,i+1) = Eakal(i+1,j);
6560 }
6561 }
6562
6563 if (debug_ == 4) cout<<"initialised Ea.. "<<Eakal<<endl;
6564}

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

◆ initialize()

StatusCode KalFitAlg::initialize ( )

initialize

Definition at line 204 of file KalFitAlg.cxx.

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

◆ innerwall() [1/3]

void KalFitAlg::innerwall ( KalFitTrack & track,
int l_mass,
int way,
double r1,
double r2,
int & index )

Definition at line 3773 of file KalFitAlg.cxx.

3773 {
3774 if (debug_ ==4) cout<<"innerwall....."<<endl;
3775 double ri=(r1<r2)?r1:r2;
3776 double ro=(r1<r2)?r2:r1;
3777 double Rmin,Rmax;
3778 int step;
3779 vector<KalFitCylinder>::iterator it;
3780 vector<KalFitCylinder>::iterator itStart;
3781 vector<KalFitCylinder>::iterator itStop;
3782 if(way<0){
3783 step=-1;
3784 itStart=_BesKalmanFitWalls.end()-index-1;
3785 itStop =_BesKalmanFitWalls.begin()-1;
3786 }
3787 else{
3788 step=1;
3789 itStart=_BesKalmanFitWalls.begin()+index;
3790 itStop =_BesKalmanFitWalls.end();
3791 }
3792 for(it=itStart; it != itStop; it=it+step) {
3793 if(ri < it->rmin() && it->radius() < ro) {
3794 it->updateTrack(track,way);
3795 Rmin=it->rmin();
3796 Rmax=it->radius();
3797 continue;
3798 }
3799 else if(it->rmin() <= ri && ri <= it->radius() && it->radius() < ro){
3800 it->updateTrack(track,way,ri,it->radius());
3801 Rmin=ri;
3802 Rmax=it->radius();
3803 if(way>0){
3804 //index = it - _BesKalmanFitWalls.begin();
3805 break;
3806 }
3807 else continue;
3808 }
3809 else if(ri < it->rmin() && it->rmin() <= ro && ro <= it->radius()){
3810 it->updateTrack(track,way,it->rmin(),ro);
3811 Rmin=it->rmin();
3812 Rmax=ro;
3813 if(way<0){
3814 //index = _BesKalmanFitWalls.end() - it;
3815 break;
3816 }
3817 else continue;
3818 }
3819 else if(it->radius()<ri || ro < it->rmin()){
3820 continue;
3821 }
3822 else {
3823 it->updateTrack(track,way,ri,ro);
3824 Rmin=ri;
3825 Rmax=ro;
3826 //index=it-_BesKalmanFitWalls.begin();
3827 break;
3828 }
3829 }
3830 if(way<0){
3831 //double phi=track.intersect_cylinder(Rmax);
3832 //HepPoint3D pivot=track.x(phi);
3833 //track.pivot_numf(pivot);
3834 track.pivot_numf(track.x(track.intersect_cylinder(Rmax)));
3835 index = _BesKalmanFitWalls.end() - it-1;
3836 }
3837 else{
3838 //double phi=track.intersect_cylinder(Rmin);
3839 //HepPoint3D pivot=track.x(phi);
3840 //track.pivot_numf(pivot);
3841 track.pivot_numf(track.x(track.intersect_cylinder(Rmin)));
3842 index = it - _BesKalmanFitWalls.begin();
3843 }
3844
3845}

◆ innerwall() [2/3]

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

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

Definition at line 3754 of file KalFitAlg.cxx.

3754 {
3755
3756 if (debug_ ==4) cout<<"innerwall....."<<endl;
3757 for(int i = 0; i < _BesKalmanFitWalls.size(); i++) {
3758 _BesKalmanFitWalls[i].updateTrack(track, way);
3759 if (debug_ == 4) cout<<"Wall "<<i<<" update the track!(filter)"<<endl;
3760 }
3761}

Referenced by Cgem_filter_anal(), complete_track(), complete_track(), and fitGemHits().

◆ innerwall() [3/3]

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

Definition at line 3763 of file KalFitAlg.cxx.

3763 {
3764 if (debug_ ==4) cout<<"innerwall....."<<endl;
3765 for(int i = begin; i <= end; i++) {
3766 _BesKalmanFitWalls[i].updateTrack(track, way);
3767 if(debug_ == 4){cout << "wall" << i << endl;
3768 cout <<"track" << "pivot=" << track.pivot() << "a=" << track.a() << "ea=" <<track.Ea() << endl;}
3769 if (debug_ == 4) cout<<"Wall "<<i<<" update the track!(filter)"<<endl;
3770 }
3771}

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

3853{
3854
3855 //cout<<"kalman_fitting_anal deal with a new event"<<endl;//wangll
3856
3857 MsgStream log(msgSvc(), name());
3858 double Pt_threshold(0.3);
3859 Hep3Vector IP(0,0,0);
3860 vector<MdcRec_trk>* mdcMgr = MdcRecTrkCol::getMdcRecTrkCol();
3861 vector<MdcRec_trk_add>* mdc_addMgr = MdcRecTrkAddCol::getMdcRecTrkAddCol();
3862 vector<MdcRec_wirhit>* whMgr = MdcRecWirhitCol::getMdcRecWirhitCol();
3863
3864 // Table Manager
3865 if ( !&whMgr ) return;
3866
3867 // Get reduced chi**2 of Mdc track :
3868 int ntrk = mdcMgr->size();
3869 double* rPt = new double[ntrk];
3870 int* rOM = new int[ntrk];
3871 unsigned int* order = new unsigned int[ntrk];
3872 unsigned int* rCont = new unsigned int[ntrk];
3873 unsigned int* rGen = new unsigned int[ntrk];
3874
3875 if(testOutput) cout<<"nMdcTrk = "<<ntrk<<endl;
3876
3877 int index = 0;
3878 for(vector<MdcRec_trk>::iterator it = mdcMgr->begin(),
3879 end = mdcMgr->end(); it != end; it++) {
3880 // Pt
3881 rPt[index] = 0;
3882 if (it->helix[2])
3883 rPt[index] = 1 / fabs(it->helix[2]);
3884 if(debug_ == 4) cout<<"rPt...[ "<<index<<" ]...."<< rPt[index] <<endl;
3885 if(rPt[index] < 0) rPt[index] = DBL_MAX;
3886 // Outermost layer
3887 std::vector<MdcRec_wirhit*> pt = it->hitcol ;
3888 if(debug_ == 4) cout<<"ppt size: "<< pt.size()<<endl;
3889 int outermost(-1);
3890 for (vector<MdcRec_wirhit*>::iterator ii = pt.end()-1;
3891 ii !=pt.begin()-1; ii--) {
3892 int lyr((*ii)->geo->Lyr()->Id());
3893 if (outermost < lyr) outermost = lyr;
3894 if(debug_ == 4) cout<<"outmost: "<<outermost<<" lyr: "<<lyr<<endl;
3895 }
3896 rOM[index] = outermost;
3897 order[index] = index;
3898 ++index;
3899 }
3900
3901 // Sort Mdc tracks by Pt
3902 for (int j, k = ntrk - 1; k >= 0; k = j){
3903 j = -1;
3904 for(int i = 1; i <= k; i++)
3905 if(rPt[i - 1] < rPt[i]){
3906 j = i - 1;
3907 std::swap(order[i], order[j]);
3908 std::swap(rPt[i], rPt[j]);
3909 std::swap(rOM[i], rOM[j]);
3910 std::swap(rCont[i], rCont[j]);
3911 std::swap(rGen[i], rGen[j]);
3912 }
3913 }
3914 delete [] rPt;
3915
3916 //
3917 int newcount(0);
3918 //check whether Recon already registered
3919 DataObject *aReconEvent;
3920 eventSvc()->findObject("/Event/Recon",aReconEvent);
3921 if(!aReconEvent) {
3922 // register ReconEvent Data Object to TDS;
3923 ReconEvent* recevt = new ReconEvent;
3924 StatusCode sc = eventSvc()->registerObject("/Event/Recon",recevt );
3925 if(sc!=StatusCode::SUCCESS) {
3926 log << MSG::FATAL << "Could not register ReconEvent" <<endreq;
3927 return;
3928 }
3929 }
3930
3931 RecMdcKalTrackCol* kalcol = new RecMdcKalTrackCol;
3933 //make RecMdcKalTrackCol
3934 log << MSG::INFO << "beginning to make RecMdcKalTrackCol" <<endreq;
3935 // Loop over tracks given by trasan :
3936 for(int l = 0; l < ntrk; l++) {
3937
3938 //cout<<"----------------"<<endl;//wangll
3939 //cout<<"track "<<l<<" : "<<endl;//wangll
3940 nTotalTrks++;
3941
3942 for(int i=0; i<5; i++) iqual_front_[i] = 1; // wangll 2010-11-01
3943
3944 // m_timer[3]->start();
3945 MdcRec_trk& TrasanTRK = *(mdcMgr->begin() + order[l]);
3946 MdcRec_trk_add& TrasanTRK_add = *(mdc_addMgr->begin()+order[l]);
3947
3948 // Reject the ones with quality != 0
3949 int trasqual = TrasanTRK_add.quality;
3950 if(debug_ == 4) cout<<"kalman_fitting>trasqual... "<<trasqual<<endl;
3951 if (trasqual) continue;
3952
3953 newcount++;
3954 if (debug_ == 4)
3955 cout << "******* KalFit NUMBER : " << newcount << std::endl;
3956
3957 // What kind of KalFit ?
3958 int type(0);
3959 if ((TrasanTRK_add.decision & 32) == 32 ||
3960 (TrasanTRK_add.decision & 64) == 64) type = 1;
3961
3962 // Initialisation : (x, a, ea)
3963 HepPoint3D x(TrasanTRK.pivot[0],
3964 TrasanTRK.pivot[1],
3965 TrasanTRK.pivot[2]);
3966
3967 HepVector a(5);
3968 for(int i = 0; i < 5; i++)
3969 a[i] = TrasanTRK.helix[i];
3970
3971 HepSymMatrix ea(5);
3972 for(int i = 0, k = 0; i < 5; i++) {
3973 for(int j = 0; j <= i; j++) {
3974 ea[i][j] = matrixg_*TrasanTRK.error[k++];
3975 ea[j][i] = ea[i][j];
3976 }
3977 }
3978 double fiTerm = TrasanTRK.fiTerm;
3979 int way(1);
3980 // Prepare the track found :
3981 KalFitTrack track_lead = KalFitTrack(x, a, ea, lead_, 0, 0);
3982
3983 track_lead.bFieldZ(KalFitTrack::Bznom_);
3984 double pT_trk = fabs(track_lead.pt());
3985
3986 // Mdc Hits
3987 int inlyr(999), outlyr(-1);
3988 int* rStat = new int[43];
3989 for(int irStat=0;irStat<43;++irStat)rStat[irStat]=0;
3990 std::vector<MdcRec_wirhit*> pt=TrasanTRK.hitcol;
3991 int hit_in(0);
3992 if(debug_ == 4) cout<<"*********Pt size****"<< pt.size()<<endl;
3993 // Number of hits/layer
3994 int Num[43] = {0};
3995 for (vector<MdcRec_wirhit*>::iterator ii = pt.end()-1;
3996 ii != pt.begin()-1; ii--) {
3997 Num[(*ii)->geo->Lyr()->Id()]++;
3998 }
3999 int hit_asso(0);
4000 for (vector<MdcRec_wirhit*>::iterator ii = pt.end()-1;
4001 ii != pt.begin()-1; ii--) {
4002 hit_asso++;
4003
4004 //if (pT_trk>0.12 && Num[(*ii)->geo->Lyr()->Id()]>3)
4005 if( (useNCGem_==0&&Num[(*ii)->geo->Lyr()->Id()]>3) || (useNCGem_>0&&pT_trk>0.12 && Num[(*ii)->geo->Lyr()->Id()]>3) )
4006 {
4007 if (debug_==4 )
4008 cout << "WARNING: I found " << Num[(*ii)->geo->Lyr()->Id()]
4009 << " hits in the layer "
4010 << (*ii)->geo->Lyr()->Id() << std::endl;
4011 continue;
4012 }
4013 // comment out wangll 2020-05-22
4014
4015 // if(ii!=pt.end()-1){
4016 // int layer_before=(*(ii+1))->geo->Lyr()->Id();
4017 // if(layer_before == (*ii)->geo->Lyr()->Id()){
4018 // MdcRec_wirhit * rechit_before = *(ii+1);
4019 // if((*rechit_before).rechitptr->getDriftT()>450 || (**ii).rechitptr->getDriftT()>450.){
4020 // if((*rechit_before).tdc < (**ii).tdc) continue;
4021 // else if(track_lead.HitsMdc().size()>0 && rStat[layer_before]){
4022 // track_lead.HitsMdc().pop_back();
4023 // }
4024 // }
4025 // }
4026 // }
4027
4028 hit_in++;
4029 MdcRec_wirhit & rechit = **ii;
4030 double dist[2] = {rechit.ddl, rechit.ddr};
4031 double erdist[2] = {rechit.erddl, rechit.erddr};
4032 const MdcGeoWire* geo = rechit.geo;
4033
4034 int lr_decision(0);
4035 if (KalFitTrack::LR_ == 1){
4036 if (rechit.lr==2 || rechit.lr==0) lr_decision=-1;
4037 // if (rechit.lr==0) lr_decision=-1;
4038 else if (rechit.lr==1) lr_decision=1;
4039 }
4040
4041 int ind(geo->Lyr()->Id());
4042
4043 // ATTENTION HERE!!!
4044 track_lead.appendHitsMdc( KalFitHitMdc(rechit.id,
4045 lr_decision, rechit.tdc,
4046 dist, erdist,
4047 _wire+(geo->Id()), rechit.rechitptr));
4048 // inner/outer layer :
4049 rStat[ind]++;
4050 if (inlyr>ind) inlyr = ind;
4051 if (outlyr<ind) outlyr = ind;
4052 }
4053 if (debug_ == 4)
4054 cout << "**** NUMBER OF Mdc HITS (TRASAN) = " << hit_asso << std::endl;
4055
4056 // Empty layers :
4057 int empty_between(0), empty(0);
4058 for (int i= inlyr; i <= outlyr; i++)
4059 if (!rStat[i]) empty_between++;
4060 empty = empty_between+inlyr+(42-outlyr);
4061 delete [] rStat;
4062
4063 // RMK high momentum track under study, probably not neeeded...
4064 track_lead.order_wirhit(1);
4065 //track_lead.order_hits();
4066
4067 for(std::vector<KalFitHitMdc>::iterator it_hit = track_lead.HitsMdc().begin(); it_hit!=track_lead.HitsMdc().end(); it_hit++){
4068 //std::cout<<" the id of this hits after sorting in PatRec is "<<it_hit->id()<<std::endl;
4069 //std::cout<<" the layerid of the hit is "<<it_hit->wire().layer().layerId()<<std::endl;
4070 //std::cout<<" the cellid of this wire is "<<it_hit->wire().localId()<<std::endl;
4071 }
4072
4073 track_lead.type(type);
4074 track_lead.trasan_id(TrasanTRK.id);
4075 unsigned int nhit = track_lead.HitsMdc().size();
4076 if (!nhit && debug_ == 4) {
4077 cout << " ATTENTION TRACK WITH ONLY HITS " << nhit << std::endl;
4078 continue;
4079 }
4080
4081 // Initialisation :
4082 double KalFitst(0), KalFitax(0), KalFitschi2(0);
4083 // Move to the outer hit :
4084
4085 Hep3Vector outer_pivot(track_lead.x(fiTerm));
4086 track_lead.pivot(outer_pivot);
4087
4088 track_lead.bFieldZ(KalFitTrack::Bznom_);
4089 // attention best_chi2 reinitialize !!!
4090 if (nhit>=3 && !KalFitTrack::LR_)
4091 start_seed(track_lead, lead_, way, TrasanTRK);
4092 HepSymMatrix Eakal(5,0);
4093
4094 /// very low momentum and very big costheta angle, use special initial error matrix
4095 double costheta = track_lead.a()[4] / sqrt(1.0 + track_lead.a()[4]*track_lead.a()[4]);
4096 if( (1.0/fabs(track_lead.a()[2]) < pt_cut_ ) && (fabs(costheta)> theta_cut_) ) {
4097 choice_ = 6;
4098 }
4099
4100 /// chose different initial error matrix
4101 init_matrix(choice_,TrasanTRK, Eakal);
4102
4103
4104 if (debug_ == 4){
4105 cout << "from Mdc Pattern Recognition: " << std::endl;
4106 HepPoint3D IP(0,0,0);
4107 KalmanFit::Helix work(track_lead.pivot(),
4108 track_lead.a(),
4109 track_lead.Ea());
4110 work.pivot(IP);
4111 cout << " dr = " << work.a()[0]
4112 << ", Er_dr = " << sqrt(work.Ea()[0][0]) << std::endl;
4113 cout << " phi0 = " << work.a()[1]
4114 << ", Er_phi0 = " << sqrt(work.Ea()[1][1]) << std::endl;
4115 cout << " PT = " << 1/work.a()[2]
4116 << ", Er_kappa = " << sqrt(work.Ea()[2][2]) << std::endl;
4117 cout << " dz = " << work.a()[3]
4118 << ", Er_dz = " << sqrt(work.Ea()[3][3]) << std::endl;
4119 cout << " tanl = " << work.a()[4]
4120 << ", Er_tanl = " << sqrt(work.Ea()[4][4]) << std::endl;
4121 }
4122
4123 if(testOutput) {
4124 cout<<"----------------------"<<endl;//660a
4125 cout<<"track "<<l<<", pid = "<<lead_<<": "<<endl;
4126 //int n_hits=(*itRecMdcTrack)->getNhits();
4127 //int n_hit_Axis=n_hits-(*itRecMdcTrack)->nster();
4128 //cout<<"nMdcHits,nMdcHitsAxis = "<<n_hits<<", "<<n_hit_Axis<<endl;//660a
4129 //cout<<"----------------------"<<endl;
4130 //cout<<"# old track par #"<<endl<<" pivot: "<<track.pivot()<<endl<<" helix: "<<track.a()<<endl<<" error: "<<track.Ea()<<endl;
4131 //cout<<"# true track par #"<<endl<<" helix: "<<mc_a<<endl;
4132 }
4133
4134
4135 filter_fwd_anal(track_lead, lead_, way, Eakal);
4136
4137 // std::cout<<" step3, track_lead.Ea: "<<track_lead.Ea()<<std::endl;
4138 track_lead.update_forMdc();
4139
4140 HepPoint3D IP(0,0,0);
4141 if (debug_ == 4) {
4142 cout << " Mdc FIRST KALMAN FIT " << std::endl;
4143 KalmanFit::Helix work(track_lead.pivot(),
4144 track_lead.a(),
4145 track_lead.Ea());
4146 work.pivot(IP);
4147 cout << " dr = " << work.a()[0]
4148 << ", Er_dr = " << sqrt(work.Ea()[0][0]) << std::endl;
4149 cout << " phi0 = " << work.a()[1]
4150 << ", Er_phi0 = " << sqrt(work.Ea()[1][1]) << std::endl;
4151 cout << " PT = " << 1/work.a()[2]
4152 << ", Er_kappa = " << sqrt(work.Ea()[2][2]) << std::endl;
4153 cout << " dz = " << work.a()[3]
4154 << ", Er_dz = " << sqrt(work.Ea()[3][3]) << std::endl;
4155 cout << " tanl = " << work.a()[4]
4156 << ", Er_tanl = " << sqrt(work.Ea()[4][4]) << std::endl;
4157 }
4158
4159 // fill TDS
4160 RecMdcKalTrack* kaltrk = new RecMdcKalTrack;
4161 kaltrk->setTrackId(TrasanTRK.id);
4162 // Complete the track (other mass assumption, backward) and
4163 complete_track(TrasanTRK, TrasanTRK_add, track_lead, kaltrk,kalcol,segcol,1);
4164 }// loop mdc tracks
4165
4166
4167 IDataProviderSvc* eventSvc = NULL;
4168 Gaudi::svcLocator()->service("EventDataSvc", eventSvc);
4169 if (eventSvc) {
4170 log << MSG::INFO << "makeTds:event Svc has been found" << endreq;
4171 } else {
4172 log << MSG::FATAL << "makeTds:Could not find eventSvc" << endreq;
4173 return ;
4174 }
4175 StatusCode kalsc;
4176 IDataManagerSvc *dataManSvc;
4177 dataManSvc= dynamic_cast<IDataManagerSvc*>(eventSvc);
4178 DataObject *aKalTrackCol;
4179 eventSvc->findObject("/Event/Recon/RecMdcKalTrackCol",aKalTrackCol);
4180 if(aKalTrackCol != NULL) {
4181 dataManSvc->clearSubTree("/Event/Recon/RecMdcKalTrackCol");
4182 eventSvc->unregisterObject("/Event/Recon/RecMdcKalTrackCol");
4183 }
4184 kalsc = eventSvc->registerObject("/Event/Recon/RecMdcKalTrackCol", kalcol);
4185 if( kalsc.isFailure() ) {
4186 log << MSG::FATAL << "Could not register RecMdcKalTrack" << endreq;
4187 return ;
4188 }
4189 log << MSG::INFO << "RecMdcKalTrackCol registered successfully!" <<endreq;
4190 StatusCode segsc;
4191 //check whether the RecMdcKalHelixSegCol has been already registered
4192 DataObject *aRecKalSegEvent;
4193 eventSvc->findObject("/Event/Recon/RecMdcKalHelixSegCol", aRecKalSegEvent);
4194 if(aRecKalSegEvent!=NULL) {
4195 //then unregister RecMdcKalHelixSegCol
4196 segsc = eventSvc->unregisterObject("/Event/Recon/RecMdcKalHelixSegCol");
4197 if(segsc != StatusCode::SUCCESS) {
4198 log << MSG::FATAL << "Could not unregister RecMdcKalHelixSegCol collection" << endreq;
4199 return;
4200 }
4201 }
4202 segsc = eventSvc->registerObject("/Event/Recon/RecMdcKalHelixSegCol", segcol);
4203 if( segsc.isFailure() ) {
4204 log << MSG::FATAL << "Could not register RecMdcKalHelixSeg" << endreq;
4205 return;
4206 }
4207 log << MSG::INFO << "RecMdcKalHelixSegCol registered successfully!" <<endreq;
4208
4209 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.);
4210 double r1(0.),r2(0.),kap1(999.),kap2(999.),tanl1(0),tanl2(0.);
4211 double px1(0.),px2(0.),py1(0.),py2(0.),pz1(0.),pz2(0.),charge1(0.),charge2(0.);
4212
4213 //check the result:RecMdcKalTrackCol
4214 SmartDataPtr<RecMdcKalTrackCol> kaltrkCol(eventSvc,"/Event/Recon/RecMdcKalTrackCol");
4215 if (!kaltrkCol) {
4216 log << MSG::FATAL << "Could not find RecMdcKalTrackCol" << endreq;
4217 return;
4218 }
4219 log << MSG::INFO << "Begin to check RecMdcKalTrackCol"<<endreq;
4220 RecMdcKalTrackCol::iterator iter_trk = kaltrkCol->begin();
4221 for( int jj=1; iter_trk != kaltrkCol->end(); iter_trk++,jj++) {
4222 log << MSG::DEBUG << "retrieved MDC Kalmantrack:"
4223 << "Track Id: " << (*iter_trk)->getTrackId()
4224 << " Mass of the fit: "<< (*iter_trk)->getMass(2)<< endreq
4225 << " Length of the track: "<< (*iter_trk)->getLength(2)
4226 << " Tof of the track: "<< (*iter_trk)->getTof(2) << endreq
4227 << " Chisq of the fit: "<< (*iter_trk)->getChisq(0,2)
4228 <<" "<< (*iter_trk)->getChisq(1,2) << endreq
4229 << "Ndf of the fit: "<< (*iter_trk)->getNdf(0,2)
4230 <<" "<< (*iter_trk)->getNdf(1,2) << endreq
4231 << "Kappa " << (*iter_trk)->getZHelix()[2]
4232 << endreq;
4233 for( int i = 0; i<43; i++) {
4234 log << MSG::DEBUG << "retrieved pathl["<<i<<"]= "
4235 << (*iter_trk)->getPathl(i) <<endreq;
4236 }
4237 if(ntuple_&1) {
4238 m_trackid = (*iter_trk)->getTrackId();
4239
4240 for( int jj =0, iii=0; jj<5; jj++) {
4241
4242 m_length[jj] = (*iter_trk)->getLength(jj);
4243 m_tof[jj] = (*iter_trk)->getTof(jj);
4244 m_nhits[jj] = (*iter_trk)->getNhits(jj);
4245 m_zhelix[jj] = (*iter_trk)->getZHelix()[jj];
4246 m_zhelixe[jj] = (*iter_trk)->getZHelixE()[jj];
4247 m_zhelixmu[jj] = (*iter_trk)->getZHelixMu()[jj];
4248 m_zhelixk[jj] = (*iter_trk)->getZHelixK()[jj];
4249 m_zhelixp[jj] = (*iter_trk)->getZHelixP()[jj];
4250 m_fhelix[jj] = (*iter_trk)->getFHelix()[jj];
4251 m_fhelixe[jj] = (*iter_trk)->getFHelixE()[jj];
4252 m_fhelixmu[jj] = (*iter_trk)->getFHelixMu()[jj];
4253 m_fhelixk[jj] = (*iter_trk)->getFHelixK()[jj];
4254 m_fhelixp[jj] = (*iter_trk)->getFHelixP()[jj];
4255 m_lhelix[jj] = (*iter_trk)->getLHelix()[jj];
4256 m_lhelixe[jj] = (*iter_trk)->getLHelixE()[jj];
4257 m_lhelixmu[jj] = (*iter_trk)->getLHelixMu()[jj];
4258 m_lhelixk[jj] = (*iter_trk)->getLHelixK()[jj];
4259 m_lhelixp[jj] = (*iter_trk)->getLHelixP()[jj];
4260
4261 if(ntuple_&32) {
4262 for(int kk=0; kk<=jj; kk++,iii++) {
4263 m_zerror[iii] = (*iter_trk)->getZError()[jj][kk];
4264 m_zerrore[iii] = (*iter_trk)->getZErrorE()[jj][kk];
4265 m_zerrormu[iii] = (*iter_trk)->getZErrorMu()[jj][kk];
4266 m_zerrork[iii] = (*iter_trk)->getZErrorK()[jj][kk];
4267 m_zerrorp[iii] = (*iter_trk)->getZErrorP()[jj][kk];
4268 m_ferror[iii] = (*iter_trk)->getFError()[jj][kk];
4269 m_ferrore[iii] = (*iter_trk)->getFErrorE()[jj][kk];
4270 m_ferrormu[iii] = (*iter_trk)->getFErrorMu()[jj][kk];
4271 m_ferrork[iii] = (*iter_trk)->getFErrorK()[jj][kk];
4272 m_ferrorp[iii] = (*iter_trk)->getFErrorP()[jj][kk];
4273 m_lerror[iii] = (*iter_trk)->getLError()[jj][kk];
4274 m_lerrore[iii] = (*iter_trk)->getLErrorE()[jj][kk];
4275 m_lerrormu[iii] = (*iter_trk)->getLErrorMu()[jj][kk];
4276 m_lerrork[iii] = (*iter_trk)->getLErrorK()[jj][kk];
4277 m_lerrorp[iii] = (*iter_trk)->getLErrorP()[jj][kk];
4278 }
4279 }
4280 }
4281
4282 // // the following logic may seem peculiar, but it IS the case(for BOSS5.0 and BOSS5.1)
4283 // m_chisq[0][0] = (*iter_trk)->getChisq(0,0);
4284 // m_chisq[0][1] = (*iter_trk)->getChisq(0,1);
4285 // m_chisq[1][0] = (*iter_trk)->getChisq(0,2);
4286 // m_chisq[1][1] = (*iter_trk)->getChisq(0,3);
4287 // m_chisq[2][0] = (*iter_trk)->getChisq(0,4);
4288 // m_chisq[2][1] = (*iter_trk)->getChisq(1,0);
4289 // m_chisq[3][0] = (*iter_trk)->getChisq(1,1);
4290 // m_chisq[3][1] = (*iter_trk)->getChisq(1,2);
4291 // m_chisq[4][0] = (*iter_trk)->getChisq(1,3);
4292 // m_chisq[4][1] = (*iter_trk)->getChisq(1,4);
4293
4294 // m_ndf[0][0] = (*iter_trk)->getNdf(0,0);
4295 // m_ndf[0][1] = (*iter_trk)->getNdf(0,1);
4296 // m_ndf[1][0] = (*iter_trk)->getNdf(0,2);
4297 // m_ndf[1][1] = (*iter_trk)->getNdf(0,3);
4298 // m_ndf[2][0] = (*iter_trk)->getNdf(0,4);
4299 // m_ndf[2][1] = (*iter_trk)->getNdf(1,0);
4300 // m_ndf[3][0] = (*iter_trk)->getNdf(1,1);
4301 // m_ndf[3][1] = (*iter_trk)->getNdf(1,2);
4302 // m_ndf[4][0] = (*iter_trk)->getNdf(1,3);
4303 // m_ndf[4][1] = (*iter_trk)->getNdf(1,4);
4304
4305 // m_stat[0][0] = (*iter_trk)->getStat(0,0);
4306 // m_stat[0][1] = (*iter_trk)->getStat(0,1);
4307 // m_stat[1][0] = (*iter_trk)->getStat(0,2);
4308 // m_stat[1][1] = (*iter_trk)->getStat(0,3);
4309 // m_stat[2][0] = (*iter_trk)->getStat(0,4);
4310 // m_stat[2][1] = (*iter_trk)->getStat(1,0);
4311 // m_stat[3][0] = (*iter_trk)->getStat(1,1);
4312 // m_stat[3][1] = (*iter_trk)->getStat(1,2);
4313 // m_stat[4][0] = (*iter_trk)->getStat(1,3);
4314 // m_stat[4][1] = (*iter_trk)->getStat(1,4);
4315
4316 // RootConversion changed in BOSS6.0, so use thefollowing:
4317 m_chisq[0][0] = (*iter_trk)->getChisq(0,0);
4318 m_chisq[1][0] = (*iter_trk)->getChisq(0,1);
4319 m_chisq[2][0] = (*iter_trk)->getChisq(0,2);
4320 m_chisq[3][0] = (*iter_trk)->getChisq(0,3);
4321 m_chisq[4][0] = (*iter_trk)->getChisq(0,4);
4322 m_chisq[0][1] = (*iter_trk)->getChisq(1,0);
4323 m_chisq[1][1] = (*iter_trk)->getChisq(1,1);
4324 m_chisq[2][1] = (*iter_trk)->getChisq(1,2);
4325 m_chisq[3][1] = (*iter_trk)->getChisq(1,3);
4326 m_chisq[4][1] = (*iter_trk)->getChisq(1,4);
4327
4328 m_ndf[0][0] = (*iter_trk)->getNdf(0,0);
4329 m_ndf[1][0] = (*iter_trk)->getNdf(0,1);
4330 m_ndf[2][0] = (*iter_trk)->getNdf(0,2);
4331 m_ndf[3][0] = (*iter_trk)->getNdf(0,3);
4332 m_ndf[4][0] = (*iter_trk)->getNdf(0,4);
4333 m_ndf[0][1] = (*iter_trk)->getNdf(1,0);
4334 m_ndf[1][1] = (*iter_trk)->getNdf(1,1);
4335 m_ndf[2][1] = (*iter_trk)->getNdf(1,2);
4336 m_ndf[3][1] = (*iter_trk)->getNdf(1,3);
4337 m_ndf[4][1] = (*iter_trk)->getNdf(1,4);
4338
4339 m_stat[0][0] = (*iter_trk)->getStat(0,0);
4340 m_stat[1][0] = (*iter_trk)->getStat(0,1);
4341 m_stat[2][0] = (*iter_trk)->getStat(0,2);
4342 m_stat[3][0] = (*iter_trk)->getStat(0,3);
4343 m_stat[4][0] = (*iter_trk)->getStat(0,4);
4344 m_stat[0][1] = (*iter_trk)->getStat(1,0);
4345 m_stat[1][1] = (*iter_trk)->getStat(1,1);
4346 m_stat[2][1] = (*iter_trk)->getStat(1,2);
4347 m_stat[3][1] = (*iter_trk)->getStat(1,3);
4348 m_stat[4][1] = (*iter_trk)->getStat(1,4);
4349
4350 m_fptot = sqrt(1+pow(m_fhelix[4],2))/m_fhelix[2];
4351 m_fptote = sqrt(1+pow(m_fhelixe[4],2))/m_fhelixe[2];
4352 m_fptotmu = sqrt(1+pow(m_fhelixmu[4],2))/m_fhelixmu[2];
4353 m_fptotk = sqrt(1+pow(m_fhelixk[4],2))/m_fhelixk[2];
4354 m_fptotp = sqrt(1+pow(m_fhelixp[4],2))/m_fhelixp[2];
4355
4356 m_lptot = sqrt(1+pow(m_lhelix[4],2))/m_lhelix[2];
4357 m_lptote = sqrt(1+pow(m_lhelixe[4],2))/m_lhelixe[2];
4358 m_lptotmu = sqrt(1+pow(m_lhelixmu[4],2))/m_lhelixmu[2];
4359 m_lptotk = sqrt(1+pow(m_lhelixk[4],2))/m_lhelixk[2];
4360 m_lptotp = sqrt(1+pow(m_lhelixp[4],2))/m_lhelixp[2];
4361
4362 m_lpt = 1/m_lhelix[2];
4363 m_lpte = 1/m_lhelixe[2];
4364 m_lptmu = 1/m_lhelixmu[2];
4365 m_lptk = 1/m_lhelixk[2];
4366 m_lptp = 1/m_lhelixp[2];
4367
4368 m_fpt = 1/m_fhelix[2];
4369 m_fpte = 1/m_fhelixe[2];
4370 m_fptmu = 1/m_fhelixmu[2];
4371 m_fptk = 1/m_fhelixk[2];
4372 m_fptp = 1/m_fhelixp[2];
4373
4374 if(debug_ >= 3){
4375 std::cout<<" "<<std::endl;
4376 std::cout<<"in file Kalman_fitting_anal ,the m_fpt is .."<<m_fpt<<std::endl;
4377 std::cout<<"in file Kalman_fitting_anal ,the m_fpte is .."<<m_fpte<<std::endl;
4378 std::cout<<"in file Kalman_fitting_anal ,the m_fptmu is .."<<m_fptmu<<std::endl;
4379 std::cout<<"in file Kalman_fitting_anal ,the m_fptk is .."<<m_fptk<<std::endl;
4380 std::cout<<"in file Kalman_fitting_anal ,the m_fptp is .."<<m_fptp<<std::endl;
4381 }
4382
4383 m_zpt = 1/m_zhelix[2];
4384 m_zpte = 1/m_zhelixe[2];
4385 m_zptmu = 1/m_zhelixmu[2];
4386 m_zptk = 1/m_zhelixk[2];
4387 m_zptp = 1/m_zhelixp[2];
4388
4389 if(debug_ >= 3) {
4390 std::cout<<"in file Kalman_fitting_anal ,the m_zpt is .."<<m_zpt<<std::endl;
4391 std::cout<<"in file Kalman_fitting_anal ,the m_zpte is .."<<m_zpte<<std::endl;
4392 std::cout<<"in file Kalman_fitting_anal ,the m_zptmu is .."<<m_zptmu<<std::endl;
4393 std::cout<<"in file Kalman_fitting_anal ,the m_zptk is .."<<m_zptk<<std::endl;
4394 std::cout<<"in file Kalman_fitting_anal ,the m_zptp is .."<<m_zptp<<std::endl;
4395 }
4396 m_zptot = sqrt(1+pow(m_zhelix[4],2))/m_zhelix[2];
4397 m_zptote = sqrt(1+pow(m_zhelixe[4],2))/m_zhelixe[2];
4398 m_zptotmu = sqrt(1+pow(m_zhelixmu[4],2))/m_zhelixmu[2];
4399 m_zptotk = sqrt(1+pow(m_zhelixk[4],2))/m_zhelixk[2];
4400 m_zptotp = sqrt(1+pow(m_zhelixp[4],2))/m_zhelixp[2];
4401
4402 if(debug_ >= 3) {
4403 std::cout<<"in file Kalman_fitting_anal ,the m_zptot is .."<<m_zptot<<std::endl;
4404 std::cout<<"in file Kalman_fitting_anal ,the m_zptote is .."<<m_zptote<<std::endl;
4405 std::cout<<"in file Kalman_fitting_anal ,the m_zptotmu is .."<<m_zptotmu<<std::endl;
4406 std::cout<<"in file Kalman_fitting_anal ,the m_zptotk is .."<<m_zptotk<<std::endl;
4407 std::cout<<"in file Kalman_fitting_anal ,the m_zptotp is .."<<m_zptotp<<std::endl;
4408 }
4409
4410 if(ntuple_&32) {
4411 m_zsigp = sqrt(pow((m_zptot/m_zhelix[2]),2)*m_zerror[5]+
4412 pow((m_zhelix[4]/m_zptot),2)*pow((1/m_zhelix[2]),4)*m_zerror[14]-
4413 2*m_zhelix[4]*m_zerror[12]*pow((1/m_zhelix[2]),3));
4414 m_zsigpe = sqrt(pow((m_zptote/m_zhelixe[2]),2)*m_zerrore[5]+
4415 pow((m_zhelixe[4]/m_zptote),2)*pow((1/m_zhelixe[2]),4)*m_zerrore[14]-
4416 2*m_zhelixe[4]*m_zerrore[12]*pow((1/m_zhelixe[2]),3));
4417 m_zsigpmu = sqrt(pow((m_zptotmu/m_zhelixmu[2]),2)*m_zerrormu[5]+
4418 pow((m_zhelixmu[4]/m_zptotmu),2)*pow((1/m_zhelixmu[2]),4)*m_zerrormu[14]-
4419 2*m_zhelixmu[4]*m_zerrormu[12]*pow((1/m_zhelixmu[2]),3));
4420 m_zsigpk = sqrt(pow((m_zptotk/m_zhelixk[2]),2)*m_zerrork[5]+
4421 pow((m_zhelixk[4]/m_zptotk),2)*pow((1/m_zhelixk[2]),4)*m_zerrork[14]-
4422 2*m_zhelixk[4]*m_zerrork[12]*pow((1/m_zhelixk[2]),3));
4423 m_zsigpp = sqrt(pow((m_zptotp/m_zhelixp[2]),2)*m_zerrorp[5]+
4424 pow((m_zhelixp[4]/m_zptotp),2)*pow((1/m_zhelixp[2]),4)*m_zerrorp[14]-
4425 2*m_zhelixp[4]*m_zerrorp[12]*pow((1/m_zhelixp[2]),3));
4426 }
4427
4428 StatusCode sc1 = m_nt1->write();
4429 if( sc1.isFailure() ) cout<<"Ntuple1 filling failed!"<<endl;
4430 }
4431
4432 if(ntuple_&4) {
4433 if(jj == 1) {
4434 phi1 = (*iter_trk)->getFFi0();
4435 r1 = (*iter_trk)->getFDr();
4436 z1 = (*iter_trk)->getFDz();
4437 kap1 = (*iter_trk)->getFCpa();
4438 tanl1 = (*iter_trk)->getFTanl();
4439 charge1 = kap1/fabs(kap1);
4440 x1 = r1*cos(phi1);
4441 y1 = r1*sin(phi1);
4442 p1 = sqrt(1+tanl1*tanl1)/kap1;
4443 the1 = M_PI/2-atan(tanl1);
4444 px1 = -sin(phi1)/fabs(kap1);
4445 py1 = cos(phi1)/fabs(kap1);
4446 pz1= tanl1/fabs(kap1);
4447
4448 } else if(jj == 2) {
4449 phi2 = (*iter_trk)->getFFi0();
4450 r2 = (*iter_trk)->getFDr();
4451 z2 = (*iter_trk)->getFDz();
4452 kap2 = (*iter_trk)->getFCpa();
4453 tanl2 = (*iter_trk)->getFTanl();
4454 charge2 = kap2/fabs(kap2);
4455 x2 = r1*cos(phi2);
4456 y2 = r1*sin(phi2);
4457 p2 = sqrt(1+tanl2*tanl2)/kap1;
4458 the2 = M_PI/2-atan(tanl2);
4459 px2 = -sin(phi2)/fabs(kap2);
4460 py2 = cos(phi2)/fabs(kap2);
4461 pz2= tanl2/fabs(kap2);
4462 }
4463 }
4464 }
4465 if(ntuple_&4) {
4466 m_delx = x1 - x2;
4467 m_dely = y1 - y2;
4468 m_delz = z1 - z2;
4469 m_delthe = the1 + the2;
4470 m_delphi = phi1- phi2;
4471 m_delp = p1 - p2;
4472 m_delpx = charge1*fabs(px1) + charge2*fabs(px2);
4473 m_delpy = charge1*fabs(py1) + charge2*fabs(py2);
4474 m_delpz = charge1*fabs(pz1) + charge2*fabs(pz2);
4475
4476 StatusCode sc2 = m_nt2->write();
4477 if( sc2.isFailure() ) cout<<"Ntuple2 filling failed!"<<endl;
4478 }
4479
4480 delete [] order;
4481 delete [] rCont;
4482 delete [] rGen;
4483 delete [] rOM;
4484
4485 if (debug_ == 4)
4486 cout << "Kalfitting finished " << std::endl;
4487 //cout << "kalman fitting end" << endl;
4488}
Double_t phi2
Double_t phi1
void complete_track(MdcRec_trk &TrasanTRK, MdcRec_trk_add &TrasanTRK_add, KalFitTrack &track_lead, RecMdcKalTrack *kaltrk, RecMdcKalTrackCol *kalcol, RecMdcKalHelixSegCol *segcol, int flagsmooth)
void start_seed(KalFitTrack &track, int lead_, int way, MdcRec_trk &trk)
int type(void) const
void order_wirhit(int index)
void update_forMdc(void)
void appendHitsMdc(KalFitHitMdc h)
Functions for Mdc hits list.
double bFieldZ(double)
sets/returns z componet of the magnetic field.

Referenced by execute().

◆ kalman_fitting_calib()

void KalFitAlg::kalman_fitting_calib ( void )

Definition at line 4490 of file KalFitAlg.cxx.

4491{
4492
4493 MsgStream log(msgSvc(), name());
4494 double Pt_threshold(0.3);
4495 Hep3Vector IP(0,0,0);
4496
4497 vector<MdcRec_trk>* mdcMgr = MdcRecTrkCol::getMdcRecTrkCol();
4498 vector<MdcRec_trk_add>* mdc_addMgr = MdcRecTrkAddCol::getMdcRecTrkAddCol();
4499 vector<MdcRec_wirhit>* whMgr = MdcRecWirhitCol::getMdcRecWirhitCol();
4500
4501 // Table Manager
4502 if ( !&whMgr ) return;
4503
4504 // Get reduced chi**2 of Mdc track :
4505 int ntrk = mdcMgr->size();
4506 double* rPt = new double[ntrk];
4507 int* rOM = new int[ntrk];
4508 unsigned int* order = new unsigned int[ntrk];
4509 unsigned int* rCont = new unsigned int[ntrk];
4510 unsigned int* rGen = new unsigned int[ntrk];
4511
4512 int index = 0;
4513 for(vector<MdcRec_trk>::iterator it = mdcMgr->begin(),
4514 end = mdcMgr->end(); it != end; it++) {
4515 // Pt
4516 rPt[index] = 0;
4517 if (it->helix[2])
4518 rPt[index] = 1 / fabs(it->helix[2]);
4519 if(debug_ == 4) cout<<"rPt...[ "<<index<<" ]...."<< rPt[index] <<endl;
4520 if(rPt[index] < 0) rPt[index] = DBL_MAX;
4521 // Outermost layer
4522 std::vector<MdcRec_wirhit*> pt = it->hitcol ;
4523 if(debug_ == 4) cout<<"ppt size: "<< pt.size()<<endl;
4524 int outermost(-1);
4525 for (vector<MdcRec_wirhit*>::iterator ii = pt.end()-1;
4526 ii !=pt.begin()-1; ii--) {
4527 int lyr((*ii)->geo->Lyr()->Id());
4528 if (outermost < lyr) outermost = lyr;
4529 if(debug_ == 4) cout<<"outmost: "<<outermost<<" lyr: "<<lyr<<endl;
4530 }
4531 rOM[index] = outermost;
4532 order[index] = index;
4533 ++index;
4534 }
4535
4536 // Sort Mdc tracks by Pt
4537 for (int j, k = ntrk - 1; k >= 0; k = j){
4538 j = -1;
4539 for(int i = 1; i <= k; i++)
4540 if(rPt[i - 1] < rPt[i]){
4541 j = i - 1;
4542 std::swap(order[i], order[j]);
4543 std::swap(rPt[i], rPt[j]);
4544 std::swap(rOM[i], rOM[j]);
4545 std::swap(rCont[i], rCont[j]);
4546 std::swap(rGen[i], rGen[j]);
4547 }
4548 }
4549 delete [] rPt;
4550 //
4551 int newcount(0);
4552 //check whether Recon already registered
4553 DataObject *aReconEvent;
4554 eventSvc()->findObject("/Event/Recon",aReconEvent);
4555 if(!aReconEvent) {
4556 // register ReconEvent Data Object to TDS;
4557 ReconEvent* recevt = new ReconEvent;
4558 StatusCode sc = eventSvc()->registerObject("/Event/Recon",recevt );
4559 if(sc!=StatusCode::SUCCESS) {
4560 log << MSG::FATAL << "Could not register ReconEvent" <<endreq;
4561 return;
4562 }
4563 }
4564
4565 RecMdcKalTrackCol* kalcol = new RecMdcKalTrackCol;
4567 //make RecMdcKalTrackCol
4568 log << MSG::INFO << "beginning to make RecMdcKalTrackCol" <<endreq;
4569
4570 // Loop over tracks given by PatRecon :
4571 for(int l = 0; l < ntrk; l++) {
4572 // m_timer[3]->start();
4573 MdcRec_trk& TrasanTRK = *(mdcMgr->begin() + order[l]);
4574 MdcRec_trk_add& TrasanTRK_add = *(mdc_addMgr->begin()+order[l]);
4575
4576 // Reject the ones with quality != 0
4577 int trasqual = TrasanTRK_add.quality;
4578 if(debug_ == 4) cout<<"kalman_fitting>trasqual... "<<trasqual<<endl;
4579 if (trasqual) continue;
4580
4581 newcount++;
4582 if (debug_ == 4)
4583 cout << "******* KalFit NUMBER : " << newcount << std::endl;
4584
4585 // What kind of KalFit ?
4586 int type(0);
4587 if ((TrasanTRK_add.decision & 32) == 32 ||
4588 (TrasanTRK_add.decision & 64) == 64) type = 1;
4589
4590 // Initialisation : (x, a, ea)
4591 HepPoint3D x(TrasanTRK.pivot[0],
4592 TrasanTRK.pivot[1],
4593 TrasanTRK.pivot[2]);
4594
4595 HepVector a(5);
4596 for(int i = 0; i < 5; i++)
4597 a[i] = TrasanTRK.helix[i];
4598
4599 HepSymMatrix ea(5);
4600 for(int i = 0, k = 0; i < 5; i++) {
4601 for(int j = 0; j <= i; j++) {
4602 ea[i][j] = matrixg_*TrasanTRK.error[k++];
4603 ea[j][i] = ea[i][j];
4604 }
4605 }
4606
4608
4609 double fiTerm = TrasanTRK.fiTerm;
4610 int way(1);
4611 // Prepare the track found :
4612 KalFitTrack track_lead = KalFitTrack(x, a, ea, lead_, 0, 0);
4613 track_lead.bFieldZ(KalFitTrack::Bznom_);
4614 // Mdc Hits
4615 int inlyr(999), outlyr(-1);
4616 int* rStat = new int[43];
4617 for(int irStat=0;irStat<43;++irStat)rStat[irStat]=0;
4618 std::vector<MdcRec_wirhit*> pt=TrasanTRK.hitcol;
4619 int hit_in(0);
4620 if(debug_ == 4) cout<<"*********Pt size****"<< pt.size()<<endl;
4621 // Number of hits/layer
4622 int Num[43] = {0};
4623 for (vector<MdcRec_wirhit*>::iterator ii = pt.end()-1;
4624 ii != pt.begin()-1; ii--) {
4625 Num[(*ii)->geo->Lyr()->Id()]++;
4626 }
4627
4628 int hit_asso(0);
4629 for (vector<MdcRec_wirhit*>::iterator ii = pt.end()-1;
4630 ii != pt.begin()-1; ii--) {
4631
4632 hit_asso++;
4633 if (Num[(*ii)->geo->Lyr()->Id()]>3) {
4634 if (debug_ ==4)
4635 cout << "WARNING: I found " << Num[(*ii)->geo->Lyr()->Id()]
4636 << " hits in the layer "
4637 << (*ii)->geo->Lyr()->Id() << std::endl;
4638 continue;
4639 }
4640 // if(ii!=pt.end()-1){
4641 // if(42 == (*ii)->geo->Lyr()->Id() && 42 == (*(ii+1))->geo->Lyr()->Id()){
4642 // MdcRec_wirhit * rechit_before = *(ii+1);
4643 // if((*rechit_before).tdc < (**ii).tdc) continue;
4644 // else if(track_lead.HitsMdc().size()>0 && rStat[42]){
4645 // track_lead.HitsMdc().pop_back();
4646 // }
4647 // }
4648 // else{
4649 // int layer_before=(*(ii+1))->geo->Lyr()->Id();
4650 // if(layer_before == (*ii)->geo->Lyr()->Id()){
4651 // MdcRec_wirhit * rechit_before = *(ii+1);
4652 // if((*rechit_before).rechitptr->getDriftT()>450 || (**ii).rechitptr->getDriftT()>450.){
4653 // if((*rechit_before).tdc < (**ii).tdc) continue;
4654 // else if(track_lead.HitsMdc().size()>0 && rStat[layer_before]){
4655 // track_lead.HitsMdc().pop_back();
4656 // }
4657 // }
4658 // }
4659 // }
4660 // }
4661
4662 hit_in++;
4663 MdcRec_wirhit & rechit = **ii;
4664 double dist[2] = {rechit.ddl, rechit.ddr};
4665 double erdist[2] = {rechit.erddl, rechit.erddr};
4666 const MdcGeoWire* geo = rechit.geo;
4667
4668 int lr_decision(0);
4669 if (KalFitTrack::LR_ == 1){
4670 if (rechit.lr==2 || rechit.lr==0) lr_decision=-1;
4671 // if (rechit.lr==0) lr_decision=-1;
4672 else if (rechit.lr==1) lr_decision=1;
4673 }
4674
4675 int ind(geo->Lyr()->Id());
4676 track_lead.appendHitsMdc( KalFitHitMdc(rechit.id,
4677 lr_decision, rechit.tdc,
4678 dist, erdist,
4679 _wire+(geo->Id()), rechit.rechitptr));
4680 // inner/outer layer :
4681 rStat[ind]++;
4682 if (inlyr>ind) inlyr = ind;
4683 if (outlyr<ind) outlyr = ind;
4684 }
4685 if (debug_ == 4)
4686 cout << "**** NUMBER OF Mdc HITS (TRASAN) = " << hit_asso << std::endl;
4687
4688 // Empty layers :
4689 int empty_between(0), empty(0);
4690 for (int i= inlyr; i <= outlyr; i++)
4691 if (!rStat[i]) empty_between++;
4692 empty = empty_between+inlyr+(42-outlyr);
4693 delete [] rStat;
4694
4695 // RMK high momentum track under study, probably not neeeded...
4696 track_lead.order_wirhit(1);
4697 track_lead.type(type);
4698 unsigned int nhit = track_lead.HitsMdc().size();
4699 if (!nhit && debug_ == 4) {
4700 cout << " ATTENTION TRACK WITH ONLY HITS " << nhit << std::endl;
4701 continue;
4702 }
4703
4704 // Initialisation :
4705 double KalFitst(0), KalFitax(0), KalFitschi2(0);
4706 // Move to the outer most hit :
4707 Hep3Vector outer_pivot(track_lead.x(fiTerm));
4708
4709 if(debug_ == 4) {
4710 std::cout<<"before track_lead.pivot(outer_pivot) ,the error matrix of track_lead is .."<<track_lead.Ea()<<std::endl;
4711 }
4712 track_lead.pivot(outer_pivot); // hi gay, the error matrix is changed in this function!!
4713 track_lead.bFieldZ(KalFitTrack::Bznom_);
4714 // attention best_chi2 reinitialize !!!
4715 if (nhit>=3 && !KalFitTrack::LR_)
4716 start_seed(track_lead, lead_, way, TrasanTRK);
4717 HepSymMatrix Eakal(5,0);
4718
4719 //init_matrix(TrasanTRK, Eakal);
4720
4721 double costheta = track_lead.a()[4] / sqrt(1.0 + track_lead.a()[4]*track_lead.a()[4]);
4722 if( (1.0/fabs(track_lead.a()[2]) < pt_cut_ ) && (fabs(costheta)> theta_cut_) ) {
4723 choice_ = 6;
4724 }
4725
4726 init_matrix(choice_,TrasanTRK, Eakal);
4727
4728 //std::cout<<" Eakal be here: "<<Eakal<<std::endl;
4729
4730 if (debug_ == 4){
4731 std::cout << "from Mdc Pattern Recognition: " << std::endl;
4732 HepPoint3D IP(0,0,0);
4733 KalmanFit::Helix work(track_lead.pivot(),
4734 track_lead.a(),
4735 track_lead.Ea());
4736 work.pivot(IP);
4737 std::cout << " dr = " << work.a()[0]
4738 << ", Er_dr = " << sqrt(work.Ea()[0][0]) << std::endl;
4739 std::cout << " phi0 = " << work.a()[1]
4740 << ", Er_phi0 = " << sqrt(work.Ea()[1][1]) << std::endl;
4741 std::cout << " PT = " << 1/work.a()[2]
4742 << ", Er_kappa = " << sqrt(work.Ea()[2][2]) << std::endl;
4743 std::cout << " dz = " << work.a()[3]
4744 << ", Er_dz = " << sqrt(work.Ea()[3][3]) << std::endl;
4745 std::cout << " tanl = " << work.a()[4]
4746 << ", Er_tanl = " << sqrt(work.Ea()[4][4]) << std::endl;
4747 }
4748
4749 filter_fwd_calib(track_lead, lead_, way, Eakal);
4750 track_lead.update_forMdc();
4751
4752 HepPoint3D IP(0,0,0);
4753 if (debug_ == 4) {
4754 cout << " Mdc FIRST KALMAN FIT " << std::endl;
4755 KalmanFit::Helix work(track_lead.pivot(),
4756 track_lead.a(),
4757 track_lead.Ea());
4758 work.pivot(IP);
4759 cout << " dr = " << work.a()[0]
4760 << ", Er_dr = " << sqrt(work.Ea()[0][0]) << std::endl;
4761 cout << " phi0 = " << work.a()[1]
4762 << ", Er_phi0 = " << sqrt(work.Ea()[1][1]) << std::endl;
4763 cout << " PT = " << 1/work.a()[2]
4764 << ", Er_kappa = " << sqrt(work.Ea()[2][2]) << std::endl;
4765 cout << " dz = " << work.a()[3]
4766 << ", Er_dz = " << sqrt(work.Ea()[3][3]) << std::endl;
4767 cout << " tanl = " << work.a()[4]
4768 << ", Er_tanl = " << sqrt(work.Ea()[4][4]) << std::endl;
4769 }
4770
4771 // fill TDS
4772 RecMdcKalTrack* kaltrk = new RecMdcKalTrack;
4773
4774 // Complete the track (other mass assumption, backward) and
4775 complete_track(TrasanTRK, TrasanTRK_add, track_lead, kaltrk,kalcol,segcol);
4776 }
4777
4778
4779 StatusCode kalsc;
4780 //check whether the RecMdcKalTrackCol has been already registered
4781 DataObject *aRecKalEvent;
4782 eventSvc()->findObject("/Event/Recon/RecMdcKalTrackCol", aRecKalEvent);
4783 if(aRecKalEvent!=NULL) {
4784 //then unregister RecMdcKalCol
4785 kalsc = eventSvc()->unregisterObject("/Event/Recon/RecMdcKalTrackCol");
4786 if(kalsc != StatusCode::SUCCESS) {
4787 log << MSG::FATAL << "Could not unregister RecMdcKalTrack collection" << endreq;
4788 return;
4789 }
4790 }
4791
4792 kalsc = eventSvc()->registerObject("/Event/Recon/RecMdcKalTrackCol", kalcol);
4793 if( kalsc.isFailure()) {
4794 log << MSG::FATAL << "Could not register RecMdcKalTrack" << endreq;
4795 return;
4796 }
4797 log << MSG::INFO << "RecMdcKalTrackCol registered successfully!" <<endreq;
4798
4799
4800
4801 StatusCode segsc;
4802 //check whether the RecMdcKalHelixSegCol has been already registered
4803 DataObject *aRecKalSegEvent;
4804 eventSvc()->findObject("/Event/Recon/RecMdcKalHelixSegCol", aRecKalSegEvent);
4805 if(aRecKalSegEvent!=NULL) {
4806 //then unregister RecMdcKalHelixSegCol
4807 segsc = eventSvc()->unregisterObject("/Event/Recon/RecMdcKalHelixSegCol");
4808 if(segsc != StatusCode::SUCCESS) {
4809 log << MSG::FATAL << "Could not unregister RecMdcKalHelixSegCol collection" << endreq;
4810 return;
4811 }
4812 }
4813
4814 segsc = eventSvc()->registerObject("/Event/Recon/RecMdcKalHelixSegCol", segcol);
4815 if( segsc.isFailure() ) {
4816 log << MSG::FATAL << "Could not register RecMdcKalHelixSeg" << endreq;
4817 return;
4818 }
4819 log << MSG::INFO << "RecMdcKalHelixSegCol registered successfully!" <<endreq;
4820
4821
4822 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.);
4823 double r1(0.),r2(0.),kap1(999.),kap2(999.),tanl1(0.),tanl2(0.);
4824 //check the result:RecMdcKalTrackCol
4825
4826 SmartDataPtr<RecMdcKalTrackCol> kaltrkCol(eventSvc(),"/Event/Recon/RecMdcKalTrackCol");
4827 if (!kaltrkCol) {
4828 log << MSG::FATAL << "Could not find RecMdcKalTrackCol" << endreq;
4829 return;
4830 }
4831 log << MSG::INFO << "Begin to check RecMdcKalTrackCol"<<endreq;
4832 RecMdcKalTrackCol::iterator iter_trk = kaltrkCol->begin();
4833 for( int jj=1; iter_trk != kaltrkCol->end(); iter_trk++,jj++) {
4834 log << MSG::DEBUG << "retrieved MDC Kalmantrack:"
4835 << "Track Id: " << (*iter_trk)->getTrackId()
4836 << " Mass of the fit: "<< (*iter_trk)->getMass(2)<< endreq
4837 << " Length of the track: "<< (*iter_trk)->getLength(2)
4838 << " Tof of the track: "<< (*iter_trk)->getTof(2) << endreq
4839 << " Chisq of the fit: "<< (*iter_trk)->getChisq(0,2)
4840 <<" "<< (*iter_trk)->getChisq(1,2) << endreq
4841 << "Ndf of the fit: "<< (*iter_trk)->getNdf(0,1)
4842 <<" "<< (*iter_trk)->getNdf(1,2) << endreq
4843 << "Kappa " << (*iter_trk)->getZHelix()[2]
4844 << endreq;
4845
4846 HelixSegRefVec gothelixsegs = (*iter_trk)->getVecHelixSegs();
4847 if(debug_ == 4) {
4848 std::cout<<"the size of gothelixsegs ..."<<gothelixsegs.size()<<std::endl;
4849 }
4850
4851 HelixSegRefVec::iterator it_gothelixseg = gothelixsegs.begin();
4852 for( ; it_gothelixseg != gothelixsegs.end(); it_gothelixseg++) {
4853 if(debug_ == 4) {
4854 std::cout<<"the layerId of this helixseg is ..."<<(*it_gothelixseg)->getLayerId()<<std::endl;
4855 std::cout<<"the residual of this helixseg exclude the meas hit"<<(*it_gothelixseg)->getResExcl()<<std::endl;
4856 std::cout<<"the residual of this helixseg include the meas hit"<<(*it_gothelixseg)->getResIncl()<<std::endl;
4857 std::cout<<"the track id of the helixseg is ..."<<(*it_gothelixseg)->getTrackId() <<std::endl;
4858 std::cout<<"the tof of the helixseg is ..."<<(*it_gothelixseg)->getTof()<<std::endl;
4859 std::cout<<"the Zhit of the helixseg is ..."<<(*it_gothelixseg)->getZhit()<<std::endl;
4860 }
4861 }
4862 for( int i = 0; i<43; i++) {
4863 log << MSG::DEBUG << "retrieved pathl["<<i<<"]= "
4864 << (*iter_trk)->getPathl(i) <<endreq;
4865 }
4866
4867 if(ntuple_&1) {
4868 m_trackid = (*iter_trk)->getTrackId();
4869 for( int jj =0, iii=0; jj<5; jj++) {
4870 m_length[jj] = (*iter_trk)->getLength(jj);
4871 m_tof[jj] = (*iter_trk)->getTof(jj);
4872 m_nhits[jj] = (*iter_trk)->getNhits(jj);
4873 m_zhelix[jj] = (*iter_trk)->getZHelix()[jj];
4874 m_zhelixe[jj] = (*iter_trk)->getZHelixE()[jj];
4875 m_zhelixmu[jj] = (*iter_trk)->getZHelixMu()[jj];
4876 m_zhelixk[jj] = (*iter_trk)->getZHelixK()[jj];
4877 m_zhelixp[jj] = (*iter_trk)->getZHelixP()[jj];
4878 m_fhelix[jj] = (*iter_trk)->getFHelix()[jj];
4879 m_fhelixe[jj] = (*iter_trk)->getFHelixE()[jj];
4880 m_fhelixmu[jj] = (*iter_trk)->getFHelixMu()[jj];
4881 m_fhelixk[jj] = (*iter_trk)->getFHelixK()[jj];
4882 m_fhelixp[jj] = (*iter_trk)->getFHelixP()[jj];
4883 m_lhelix[jj] = (*iter_trk)->getLHelix()[jj];
4884 m_lhelixe[jj] = (*iter_trk)->getLHelixE()[jj];
4885 m_lhelixmu[jj] = (*iter_trk)->getLHelixMu()[jj];
4886 m_lhelixk[jj] = (*iter_trk)->getLHelixK()[jj];
4887 m_lhelixp[jj] = (*iter_trk)->getLHelixP()[jj];
4888 if(ntuple_&32) {
4889 for(int kk=0; kk<=jj; kk++,iii++) {
4890 m_zerror[iii] = (*iter_trk)->getZError()[jj][kk];
4891 m_zerrore[iii] = (*iter_trk)->getZErrorE()[jj][kk];
4892 m_zerrormu[iii] = (*iter_trk)->getZErrorMu()[jj][kk];
4893 m_zerrork[iii] = (*iter_trk)->getZErrorK()[jj][kk];
4894 m_zerrorp[iii] = (*iter_trk)->getZErrorP()[jj][kk];
4895 m_ferror[iii] = (*iter_trk)->getFError()[jj][kk];
4896 m_ferrore[iii] = (*iter_trk)->getFErrorE()[jj][kk];
4897 m_ferrormu[iii] = (*iter_trk)->getFErrorMu()[jj][kk];
4898 m_ferrork[iii] = (*iter_trk)->getFErrorK()[jj][kk];
4899 m_ferrorp[iii] = (*iter_trk)->getFErrorP()[jj][kk];
4900 m_lerror[iii] = (*iter_trk)->getLError()[jj][kk];
4901 m_lerrore[iii] = (*iter_trk)->getLErrorE()[jj][kk];
4902 m_lerrormu[iii] = (*iter_trk)->getLErrorMu()[jj][kk];
4903 m_lerrork[iii] = (*iter_trk)->getLErrorK()[jj][kk];
4904 m_lerrorp[iii] = (*iter_trk)->getLErrorP()[jj][kk];
4905 }
4906
4907 }
4908 }
4909
4910 // // the following logic may seem peculiar, but it IS the case(for BOSS5.0 and BOSS5.1)
4911 // m_chisq[0][0] = (*iter_trk)->getChisq(0,0);
4912 // m_chisq[0][1] = (*iter_trk)->getChisq(0,1);
4913 // m_chisq[1][0] = (*iter_trk)->getChisq(0,2);
4914 // m_chisq[1][1] = (*iter_trk)->getChisq(0,3);
4915 // m_chisq[2][0] = (*iter_trk)->getChisq(0,4);
4916 // m_chisq[2][1] = (*iter_trk)->getChisq(1,0);
4917 // m_chisq[3][0] = (*iter_trk)->getChisq(1,1);
4918 // m_chisq[3][1] = (*iter_trk)->getChisq(1,2);
4919 // m_chisq[4][0] = (*iter_trk)->getChisq(1,3);
4920 // m_chisq[4][1] = (*iter_trk)->getChisq(1,4);
4921
4922 // m_ndf[0][0] = (*iter_trk)->getNdf(0,0);
4923 // m_ndf[0][1] = (*iter_trk)->getNdf(0,1);
4924 // m_ndf[1][0] = (*iter_trk)->getNdf(0,2);
4925 // m_ndf[1][1] = (*iter_trk)->getNdf(0,3);
4926 // m_ndf[2][0] = (*iter_trk)->getNdf(0,4);
4927 // m_ndf[2][1] = (*iter_trk)->getNdf(1,0);
4928 // m_ndf[3][0] = (*iter_trk)->getNdf(1,1);
4929 // m_ndf[3][1] = (*iter_trk)->getNdf(1,2);
4930 // m_ndf[4][0] = (*iter_trk)->getNdf(1,3);
4931 // m_ndf[4][1] = (*iter_trk)->getNdf(1,4);
4932
4933 // m_stat[0][0] = (*iter_trk)->getStat(0,0);
4934 // m_stat[0][1] = (*iter_trk)->getStat(0,1);
4935 // m_stat[1][0] = (*iter_trk)->getStat(0,2);
4936 // m_stat[1][1] = (*iter_trk)->getStat(0,3);
4937 // m_stat[2][0] = (*iter_trk)->getStat(0,4);
4938 // m_stat[2][1] = (*iter_trk)->getStat(1,0);
4939 // m_stat[3][0] = (*iter_trk)->getStat(1,1);
4940 // m_stat[3][1] = (*iter_trk)->getStat(1,2);
4941 // m_stat[4][0] = (*iter_trk)->getStat(1,3);
4942 // m_stat[4][1] = (*iter_trk)->getStat(1,4);
4943
4944 // RootConversion changed in BOSS6.0, so use thefollowing:
4945 m_chisq[0][0] = (*iter_trk)->getChisq(0,0);
4946 m_chisq[1][0] = (*iter_trk)->getChisq(0,1);
4947 m_chisq[2][0] = (*iter_trk)->getChisq(0,2);
4948 m_chisq[3][0] = (*iter_trk)->getChisq(0,3);
4949 m_chisq[4][0] = (*iter_trk)->getChisq(0,4);
4950 m_chisq[0][1] = (*iter_trk)->getChisq(1,0);
4951 m_chisq[1][1] = (*iter_trk)->getChisq(1,1);
4952 m_chisq[2][1] = (*iter_trk)->getChisq(1,2);
4953 m_chisq[3][1] = (*iter_trk)->getChisq(1,3);
4954 m_chisq[4][1] = (*iter_trk)->getChisq(1,4);
4955
4956 m_ndf[0][0] = (*iter_trk)->getNdf(0,0);
4957 m_ndf[1][0] = (*iter_trk)->getNdf(0,1);
4958 m_ndf[2][0] = (*iter_trk)->getNdf(0,2);
4959 m_ndf[3][0] = (*iter_trk)->getNdf(0,3);
4960 m_ndf[4][0] = (*iter_trk)->getNdf(0,4);
4961 m_ndf[0][1] = (*iter_trk)->getNdf(1,0);
4962 m_ndf[1][1] = (*iter_trk)->getNdf(1,1);
4963 m_ndf[2][1] = (*iter_trk)->getNdf(1,2);
4964 m_ndf[3][1] = (*iter_trk)->getNdf(1,3);
4965 m_ndf[4][1] = (*iter_trk)->getNdf(1,4);
4966
4967 m_stat[0][0] = (*iter_trk)->getStat(0,0);
4968 m_stat[1][0] = (*iter_trk)->getStat(0,1);
4969 m_stat[2][0] = (*iter_trk)->getStat(0,2);
4970 m_stat[3][0] = (*iter_trk)->getStat(0,3);
4971 m_stat[4][0] = (*iter_trk)->getStat(0,4);
4972 m_stat[0][1] = (*iter_trk)->getStat(1,0);
4973 m_stat[1][1] = (*iter_trk)->getStat(1,1);
4974 m_stat[2][1] = (*iter_trk)->getStat(1,2);
4975 m_stat[3][1] = (*iter_trk)->getStat(1,3);
4976 m_stat[4][1] = (*iter_trk)->getStat(1,4);
4977
4978 m_fptot = sqrt(1+pow(m_fhelix[4],2))/m_fhelix[2];
4979 m_fptote = sqrt(1+pow(m_fhelixe[4],2))/m_fhelixe[2];
4980 m_fptotmu = sqrt(1+pow(m_fhelixmu[4],2))/m_fhelixmu[2];
4981 m_fptotk = sqrt(1+pow(m_fhelixk[4],2))/m_fhelixk[2];
4982 m_fptotp = sqrt(1+pow(m_fhelixp[4],2))/m_fhelixp[2];
4983
4984 m_zpt = 1/m_zhelix[2];
4985 m_zpte = 1/m_zhelixe[2];
4986 m_zptmu = 1/m_zhelixmu[2];
4987 m_zptk = 1/m_zhelixk[2];
4988 m_zptp = 1/m_zhelixp[2];
4989
4990 m_fpt = 1/m_fhelix[2];
4991 m_fpte = 1/m_fhelixe[2];
4992 m_fptmu = 1/m_fhelixmu[2];
4993 m_fptk = 1/m_fhelixk[2];
4994 m_fptp = 1/m_fhelixp[2];
4995
4996 m_lpt = 1/m_lhelix[2];
4997 m_lpte = 1/m_lhelixe[2];
4998 m_lptmu = 1/m_lhelixmu[2];
4999 m_lptk = 1/m_lhelixk[2];
5000 m_lptp = 1/m_lhelixp[2];
5001
5002 m_lptot = sqrt(1+pow(m_lhelix[4],2))/m_lhelix[2];
5003 m_lptote = sqrt(1+pow(m_lhelixe[4],2))/m_lhelixe[2];
5004 m_lptotmu = sqrt(1+pow(m_lhelixmu[4],2))/m_lhelixmu[2];
5005 m_lptotk = sqrt(1+pow(m_lhelixk[4],2))/m_lhelixk[2];
5006 m_lptotp = sqrt(1+pow(m_lhelixp[4],2))/m_lhelixp[2];
5007
5008 m_zptot = sqrt(1+pow(m_zhelix[4],2))/m_zhelix[2];
5009 m_zptote = sqrt(1+pow(m_zhelixe[4],2))/m_zhelixe[2];
5010 m_zptotmu = sqrt(1+pow(m_zhelixmu[4],2))/m_zhelixmu[2];
5011 m_zptotk = sqrt(1+pow(m_zhelixk[4],2))/m_zhelixk[2];
5012 m_zptotp = sqrt(1+pow(m_zhelixp[4],2))/m_zhelixp[2];
5013 if(ntuple_&32) {
5014 m_zsigp = sqrt(pow((m_zptot/m_zhelix[2]),2)*m_zerror[5]+
5015 pow((m_zhelix[4]/m_zptot),2)*pow((1/m_zhelix[2]),4)*m_zerror[14]-
5016 2*m_zhelix[4]*m_zerror[12]*pow((1/m_zhelix[2]),3));
5017 m_zsigpe = sqrt(pow((m_zptote/m_zhelixe[2]),2)*m_zerrore[5]+
5018 pow((m_zhelixe[4]/m_zptote),2)*pow((1/m_zhelixe[2]),4)*m_zerrore[14]-
5019 2*m_zhelixe[4]*m_zerrore[12]*pow((1/m_zhelixe[2]),3));
5020 m_zsigpmu = sqrt(pow((m_zptotmu/m_zhelixmu[2]),2)*m_zerrormu[5]+
5021 pow((m_zhelixmu[4]/m_zptotmu),2)*pow((1/m_zhelixmu[2]),4)*m_zerrormu[14]-
5022 2*m_zhelixmu[4]*m_zerrormu[12]*pow((1/m_zhelixmu[2]),3));
5023 m_zsigpk = sqrt(pow((m_zptotk/m_zhelixk[2]),2)*m_zerrork[5]+
5024 pow((m_zhelixk[4]/m_zptotk),2)*pow((1/m_zhelixk[2]),4)*m_zerrork[14]-
5025 2*m_zhelixk[4]*m_zerrork[12]*pow((1/m_zhelixk[2]),3));
5026 m_zsigpp = sqrt(pow((m_zptotp/m_zhelixp[2]),2)*m_zerrorp[5]+
5027 pow((m_zhelixp[4]/m_zptotp),2)*pow((1/m_zhelixp[2]),4)*m_zerrorp[14]-
5028 2*m_zhelixp[4]*m_zerrorp[12]*pow((1/m_zhelixp[2]),3));
5029 }
5030
5031 StatusCode sc1 = m_nt1->write();
5032 if( sc1.isFailure() ) cout<<"Ntuple1 filling failed!"<<endl;
5033 }
5034
5035 if(ntuple_&4) {
5036 if(jj == 1) {
5037 phi1 = (*iter_trk)->getFFi0();
5038 r1 = (*iter_trk)->getFDr();
5039 z1 = (*iter_trk)->getFDz();
5040 kap1 = (*iter_trk)->getFCpa();
5041 tanl1 = (*iter_trk)->getFTanl();
5042 x1 = r1*cos(phi1);
5043 y1 = r1*sin(phi1);
5044 p1 = sqrt(1+tanl1*tanl1)/kap1;
5045 the1 = M_PI/2-atan(tanl1);
5046 } else if(jj == 2) {
5047 phi2 = (*iter_trk)->getFFi0();
5048 r2 = (*iter_trk)->getFDr();
5049 z2 = (*iter_trk)->getFDz();
5050 kap2 = (*iter_trk)->getFCpa();
5051 tanl2 = (*iter_trk)->getFTanl();
5052 x2 = r1*cos(phi2);
5053 y2 = r1*sin(phi2);
5054 p2 = sqrt(1+tanl2*tanl2)/kap1;
5055 the2 = M_PI/2-atan(tanl2);
5056 }
5057 }
5058 }
5059 if(ntuple_&4) {
5060 m_delx = x1 - x2;
5061 m_dely = y1 - y2;
5062 m_delz = z1 - z2;
5063 m_delthe = the1 + the2;
5064 m_delphi = phi1- phi2;
5065 m_delp = p1 - p2;
5066 StatusCode sc2 = m_nt2->write();
5067 if( sc2.isFailure() ) cout<<"Ntuple2 filling failed!"<<endl;
5068 }
5069 delete [] order;
5070 delete [] rCont;
5071 delete [] rGen;
5072 delete [] rOM;
5073
5074 if (debug_ == 4)
5075 cout << "Kalfitting finished " << std::endl;
5076}
static void setInitMatrix(HepSymMatrix m)

Referenced by execute().

◆ kalman_fitting_csmalign()

void KalFitAlg::kalman_fitting_csmalign ( void )

Definition at line 5568 of file KalFitAlg.cxx.

5569{
5570
5571 MsgStream log(msgSvc(), name());
5572 double Pt_threshold(0.3);
5573 Hep3Vector IP(0,0,0);
5574
5575 vector<MdcRec_trk>* mdcMgr = MdcRecTrkCol::getMdcRecTrkCol();
5576 vector<MdcRec_trk_add>* mdc_addMgr = MdcRecTrkAddCol::getMdcRecTrkAddCol();
5577 vector<MdcRec_wirhit>* whMgr = MdcRecWirhitCol::getMdcRecWirhitCol();
5578
5579 // Table Manager
5580 if ( !&whMgr ) return;
5581
5582 // Get reduced chi**2 of Mdc track :
5583 int ntrk = mdcMgr->size();
5584 //cout<<"ntrk: "<<ntrk<<endl;
5585
5586 int nhits = whMgr->size();
5587 //cout<<"nhits: "<<nhits<<endl;
5588
5589
5590 double* rY = new double[ntrk];
5591 double* rfiTerm = new double[ntrk];
5592 double* rPt = new double[ntrk];
5593 int* rOM = new int[ntrk];
5594 unsigned int* order = new unsigned int[ntrk];
5595 unsigned int* rCont = new unsigned int[ntrk];
5596 unsigned int* rGen = new unsigned int[ntrk];
5597
5598 int index = 0;
5599 Hep3Vector csmp3[2];
5600 for(vector<MdcRec_trk>::iterator it = mdcMgr->begin(),
5601 end = mdcMgr->end(); it != end; it++) {
5602 //order by phi term
5603 rfiTerm[index]=it->fiTerm;
5604 //cout<<"fiTerm: "<<rfiTerm[index]<<endl;
5605 // Pt
5606 rPt[index] = 0;
5607 if (it->helix[2])
5608 rPt[index] = 1 / fabs(it->helix[2]);
5609 if(debug_ == 4) cout<<"rPt...[ "<<index<<" ]...."<< rPt[index] <<endl;
5610 if(rPt[index] < 0) rPt[index] = DBL_MAX;
5611 // Outermost layer
5612 std::vector<MdcRec_wirhit*> pt = it->hitcol ;
5613 if(debug_ == 4) cout<<"ppt size: "<< pt.size()<<endl;
5614 int outermost(-1);
5615 for (vector<MdcRec_wirhit*>::iterator ii = pt.end()-1;
5616 ii !=pt.begin()-1; ii--) {
5617 int lyr((*ii)->geo->Lyr()->Id());
5618 if (outermost < lyr) {
5619 outermost = lyr;
5620 rY[index] = (*ii)->geo->Forward().y();
5621 }
5622 if(debug_ == 4) cout<<"outmost: "<<outermost<<" lyr: "<<lyr<<endl;
5623 }
5624 rOM[index] = outermost;
5625 order[index] = index;
5626 ++index;
5627 }
5628
5629 // Sort Mdc tracks by fiTerm
5630 for (int j, k = ntrk - 1; k >= 0; k = j){
5631 j = -1;
5632 for(int i = 1; i <= k; i++)
5633 if(rY[i - 1] < rY[i]){
5634 j = i - 1;
5635 std::swap(order[i], order[j]);
5636 std::swap(rY[i], rY[j]);
5637 std::swap(rOM[i], rOM[j]);
5638 std::swap(rCont[i], rCont[j]);
5639 std::swap(rGen[i], rGen[j]);
5640 }
5641 }
5642 delete [] rPt;
5643 delete [] rY;
5644 delete [] rfiTerm;
5645 //
5646 int newcount(0);
5647 //check whether Recon already registered
5648 DataObject *aReconEvent;
5649 eventSvc()->findObject("/Event/Recon",aReconEvent);
5650 if(!aReconEvent) {
5651 // register ReconEvent Data Object to TDS;
5652 ReconEvent* recevt = new ReconEvent;
5653 StatusCode sc = eventSvc()->registerObject("/Event/Recon",recevt );
5654 if(sc!=StatusCode::SUCCESS) {
5655 log << MSG::FATAL << "Could not register ReconEvent" <<endreq;
5656 return;
5657 }
5658 }
5659
5660 RecMdcKalTrackCol* kalcol = new RecMdcKalTrackCol;
5662 //make RecMdcKalTrackCol
5663 log << MSG::INFO << "beginning to make RecMdcKalTrackCol" <<endreq;
5664
5665 // m_timer[3]->start();
5666 // MdcRec_trk& TrasanTRK;
5667 // MdcRec_trk_add& TrasanTRK_add;
5668
5669 // for(int l = 0; l < ntrk; l++) {
5670 MdcRec_trk& TrasanTRK = *(mdcMgr->begin() + order[1]);
5671 MdcRec_trk_add& TrasanTRK_add = *(mdc_addMgr->begin()+order[1]);
5672 // Reject the ones with quality != 0
5673 // int trasqual = TrasanTRK_add.quality;
5674 // if(debug_ == 4) cout<<"kalman_fitting>trasqual... "<<trasqual<<endl;
5675 // if (trasqual) continue;
5676
5677 newcount++;
5678 if (debug_ == 4)
5679 cout << "******* KalFit NUMBER : " << newcount << std::endl;
5680
5681 // What kind of KalFit ?
5682 int type(0);
5683 if ((TrasanTRK_add.decision & 32) == 32 ||
5684 (TrasanTRK_add.decision & 64) == 64) type = 1;
5685
5686 // Initialisation : (x, a, ea)
5687 HepPoint3D x(TrasanTRK.pivot[0],
5688 TrasanTRK.pivot[1],
5689 TrasanTRK.pivot[2]);
5690
5691 HepVector a(5);
5692 for(int i = 0; i < 5; i++)
5693 a[i] = TrasanTRK.helix[i];
5694
5695 HepSymMatrix ea(5);
5696 for(int i = 0, k = 0; i < 5; i++) {
5697 for(int j = 0; j <= i; j++) {
5698 ea[i][j] = matrixg_*TrasanTRK.error[k++];
5699 ea[j][i] = ea[i][j];
5700 }
5701 }
5702
5704
5705 double fiTerm = TrasanTRK.fiTerm;
5706 int way(1);
5707 // Prepare the track found :
5708 KalFitTrack track_lead = KalFitTrack(x, a, ea, lead_, 0, 0);
5709 track_lead.bFieldZ(KalFitTrack::Bznom_);
5710
5711 int hit_asso(0);
5712 for(int l = 0; l < ntrk; l++) {
5713 MdcRec_trk& TrasanTRK1 = *(mdcMgr->begin() + order[l]);
5714 MdcRec_trk_add& TrasanTRK_add1 = *(mdc_addMgr->begin()+order[l]);
5715 // Reject the ones with quality != 0
5716 int trasqual = TrasanTRK_add1.quality;
5717 if(debug_ == 4) cout<<"kalman_fitting>trasqual... "<<trasqual<<endl;
5718 if (trasqual) continue;
5719 // Mdc Hits
5720 int inlyr(999), outlyr(-1);
5721 int* rStat = new int[43];
5722 for(int irStat=0;irStat<43;++irStat)rStat[irStat]=0;
5723 std::vector<MdcRec_wirhit*> pt=TrasanTRK1.hitcol;
5724 int hit_in(0);
5725 if(debug_ == 4) cout<<"*********Pt size****"<< pt.size()<<endl;
5726 // Number of hits/layer
5727 int Num[43] = {0};
5728 for (vector<MdcRec_wirhit*>::iterator ii = pt.end()-1;
5729 ii != pt.begin()-1; ii--) {
5730 Num[(*ii)->geo->Lyr()->Id()]++;
5731 }
5732
5733 for (vector<MdcRec_wirhit*>::iterator ii = pt.end()-1;
5734 ii != pt.begin()-1; ii--) {
5735
5736 hit_asso++;
5737 if (Num[(*ii)->geo->Lyr()->Id()]>3) {
5738 if (debug_ ==4)
5739 cout << "WARNING: I found " << Num[(*ii)->geo->Lyr()->Id()]
5740 << " hits in the layer "
5741 << (*ii)->geo->Lyr()->Id() << std::endl;
5742 continue;
5743 }
5744
5745 hit_in++;
5746 MdcRec_wirhit & rechit = **ii;
5747 double dist[2] = {rechit.ddl, rechit.ddr};
5748 double erdist[2] = {rechit.erddl, rechit.erddr};
5749 const MdcGeoWire* geo = rechit.geo;
5750
5751 int lr_decision(0);
5752 if (KalFitTrack::LR_ == 1){
5753 if (rechit.lr==2 || rechit.lr==0) lr_decision=-1;
5754 // if (rechit.lr==0) lr_decision=-1;
5755 else if (rechit.lr==1) lr_decision=1;
5756 }
5757
5758 int ind(geo->Lyr()->Id());
5759 track_lead.appendHitsMdc( KalFitHitMdc(rechit.id,
5760 lr_decision, rechit.tdc,
5761 dist, erdist,
5762 _wire+(geo->Id()), rechit.rechitptr));
5763 // inner/outer layer :
5764 rStat[ind]++;
5765 if (inlyr>ind) inlyr = ind;
5766 if (outlyr<ind) outlyr = ind;
5767 }
5768 // Empty layers :
5769 int empty_between(0), empty(0);
5770 for (int i= inlyr; i <= outlyr; i++)
5771 if (!rStat[i]) empty_between++;
5772 empty = empty_between+inlyr+(42-outlyr);
5773 delete [] rStat;
5774 }
5775 if (debug_ == 4)
5776 cout << "**** NUMBER OF Mdc HITS (TRASAN) = " << hit_asso << std::endl;
5777
5778
5779 // RMK high momentum track under study, probably not neeeded...
5780 track_lead.order_wirhit(0);
5781 track_lead.type(type);
5782 unsigned int nhit = track_lead.HitsMdc().size();
5783 if (nhit<70) {
5784 cout << " ATTENTION TRACK WITH ONLY HITS " << nhit << std::endl;
5785 return;
5786 }
5787
5788 // Initialisation :
5789 double KalFitst(0), KalFitax(0), KalFitschi2(0);
5790 // Move to the outer most hit :
5791 Hep3Vector outer_pivot(track_lead.x(fiTerm));
5792
5793 if(debug_ == 4) {
5794 std::cout<<"before track_lead.pivot(outer_pivot) ,the error matrix of track_lead is .."<<track_lead.Ea()<<std::endl;
5795 }
5796 track_lead.pivot(outer_pivot); // hi gay, the error matrix is changed in this function!!
5797 track_lead.bFieldZ(KalFitTrack::Bznom_);
5798 // attention best_chi2 reinitialize !!!
5799 if (nhit>=3 && !KalFitTrack::LR_)
5800 start_seed(track_lead, lead_, way, TrasanTRK);
5801 HepSymMatrix Eakal(5,0);
5802
5803 //init_matrix(TrasanTRK, Eakal);
5804
5805 double costheta = track_lead.a()[4] / sqrt(1.0 + track_lead.a()[4]*track_lead.a()[4]);
5806 if( (1.0/fabs(track_lead.a()[2]) < pt_cut_ ) && (fabs(costheta)> theta_cut_) ) {
5807 choice_ = 6;
5808 }
5809
5810 init_matrix(choice_,TrasanTRK, Eakal);
5811
5812 //std::cout<<" Eakal be here: "<<Eakal<<std::endl;
5813
5814 if (debug_ == 4){
5815 std::cout << "from Mdc Pattern Recognition: " << std::endl;
5816 //HepPoint3D IP(0,0,0);
5817 KalmanFit::Helix work(track_lead.pivot(),
5818 track_lead.a(),
5819 track_lead.Ea());
5820 work.pivot(IP);
5821 std::cout << " dr = " << work.a()[0]
5822 << ", Er_dr = " << sqrt(work.Ea()[0][0]) << std::endl;
5823 std::cout << " phi0 = " << work.a()[1]
5824 << ", Er_phi0 = " << sqrt(work.Ea()[1][1]) << std::endl;
5825 std::cout << " PT = " << 1/work.a()[2]
5826 << ", Er_kappa = " << sqrt(work.Ea()[2][2]) << std::endl;
5827 std::cout << " dz = " << work.a()[3]
5828 << ", Er_dz = " << sqrt(work.Ea()[3][3]) << std::endl;
5829 std::cout << " tanl = " << work.a()[4]
5830 << ", Er_tanl = " << sqrt(work.Ea()[4][4]) << std::endl;
5831 }
5832 filter_fwd_calib(track_lead, lead_, way, Eakal);
5833 track_lead.update_forMdc();
5834
5835 //HepPoint3D IP(0,0,0);
5836 if (debug_ == 4) {
5837 cout << " Mdc FIRST KALMAN FIT " << std::endl;
5838 KalmanFit::Helix work1(track_lead.pivot(),
5839 track_lead.a(),
5840 track_lead.Ea());
5841 work1.pivot(IP);
5842 cout << " dr = " << work1.a()[0]
5843 << ", Er_dr = " << sqrt(work1.Ea()[0][0]) << std::endl;
5844 cout << " phi0 = " << work1.a()[1]
5845 << ", Er_phi0 = " << sqrt(work1.Ea()[1][1]) << std::endl;
5846 cout << " PT = " << 1/work1.a()[2]
5847 << ", Er_kappa = " << sqrt(work1.Ea()[2][2]) << std::endl;
5848 cout << " dz = " << work1.a()[3]
5849 << ", Er_dz = " << sqrt(work1.Ea()[3][3]) << std::endl;
5850 cout << " tanl = " << work1.a()[4]
5851 << ", Er_tanl = " << sqrt(work1.Ea()[4][4]) << std::endl;
5852 }
5853
5854 // fill TDS
5855 RecMdcKalTrack* kaltrk = new RecMdcKalTrack;
5856
5857 // Complete the track (other mass assumption, backward) and
5858 complete_track(TrasanTRK, TrasanTRK_add, track_lead, kaltrk,kalcol,segcol);
5859 // }
5860
5861
5862 StatusCode kalsc;
5863 //check whether the RecMdcKalTrackCol has been already registered
5864 DataObject *aRecKalEvent;
5865 eventSvc()->findObject("/Event/Recon/RecMdcKalTrackCol", aRecKalEvent);
5866 if(aRecKalEvent!=NULL) {
5867 //then unregister RecMdcKalCol
5868 kalsc = eventSvc()->unregisterObject("/Event/Recon/RecMdcKalTrackCol");
5869 if(kalsc != StatusCode::SUCCESS) {
5870 log << MSG::FATAL << "Could not unregister RecMdcKalTrack collection" << endreq;
5871 return;
5872 }
5873 }
5874
5875 kalsc = eventSvc()->registerObject("/Event/Recon/RecMdcKalTrackCol", kalcol);
5876 if( kalsc.isFailure()) {
5877 log << MSG::FATAL << "Could not register RecMdcKalTrack" << endreq;
5878 return;
5879 }
5880 log << MSG::INFO << "RecMdcKalTrackCol registered successfully!" <<endreq;
5881
5882
5883
5884 StatusCode segsc;
5885 //check whether the RecMdcKalHelixSegCol has been already registered
5886 DataObject *aRecKalSegEvent;
5887 eventSvc()->findObject("/Event/Recon/RecMdcKalHelixSegCol", aRecKalSegEvent);
5888 if(aRecKalSegEvent!=NULL) {
5889 //then unregister RecMdcKalHelixSegCol
5890 segsc = eventSvc()->unregisterObject("/Event/Recon/RecMdcKalHelixSegCol");
5891 if(segsc != StatusCode::SUCCESS) {
5892 log << MSG::FATAL << "Could not unregister RecMdcKalHelixSegCol collection" << endreq;
5893 return;
5894 }
5895 }
5896
5897 segsc = eventSvc()->registerObject("/Event/Recon/RecMdcKalHelixSegCol", segcol);
5898 if( segsc.isFailure() ) {
5899 log << MSG::FATAL << "Could not register RecMdcKalHelixSeg" << endreq;
5900 return;
5901 }
5902 log << MSG::INFO << "RecMdcKalHelixSegCol registered successfully!" <<endreq;
5903
5904
5905 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.);
5906 double r1(0.),r2(0.),kap1(999.),kap2(999.),tanl1(0.),tanl2(0.);
5907 //check the result:RecMdcKalTrackCol
5908
5909 SmartDataPtr<RecMdcKalTrackCol> kaltrkCol(eventSvc(),"/Event/Recon/RecMdcKalTrackCol");
5910 if (!kaltrkCol) {
5911 log << MSG::FATAL << "Could not find RecMdcKalTrackCol" << endreq;
5912 return;
5913 }
5914 log << MSG::INFO << "Begin to check RecMdcKalTrackCol"<<endreq;
5915 RecMdcKalTrackCol::iterator iter_trk = kaltrkCol->begin();
5916 for( int jj=1; iter_trk != kaltrkCol->end(); iter_trk++,jj++) {
5917 log << MSG::DEBUG << "retrieved MDC Kalmantrack:"
5918 << "Track Id: " << (*iter_trk)->getTrackId()
5919 << " Mass of the fit: "<< (*iter_trk)->getMass(2)<< endreq
5920 << " Length of the track: "<< (*iter_trk)->getLength(2)
5921 << " Tof of the track: "<< (*iter_trk)->getTof(2) << endreq
5922 << " Chisq of the fit: "<< (*iter_trk)->getChisq(0,2)
5923 <<" "<< (*iter_trk)->getChisq(1,2) << endreq
5924 << "Ndf of the fit: "<< (*iter_trk)->getNdf(0,1)
5925 <<" "<< (*iter_trk)->getNdf(1,2) << endreq
5926 << "Kappa " << (*iter_trk)->getZHelix()[2]
5927 << "zhelixmu "<<(*iter_trk)->getZHelixMu()
5928 << endreq;
5929
5930 HelixSegRefVec gothelixsegs = (*iter_trk)->getVecHelixSegs();
5931 if(debug_ == 4) {
5932 std::cout<<"the size of gothelixsegs ..."<<gothelixsegs.size()<<std::endl;
5933 }
5934
5935 HelixSegRefVec::iterator it_gothelixseg = gothelixsegs.begin();
5936 for( ; it_gothelixseg != gothelixsegs.end(); it_gothelixseg++) {
5937 if(debug_ == 4) {
5938 std::cout<<"the layerId of this helixseg is ..."<<(*it_gothelixseg)->getLayerId()<<std::endl;
5939 std::cout<<"the residual of this helixseg exclude the meas hit"<<(*it_gothelixseg)->getResExcl()<<std::endl;
5940 std::cout<<"the residual of this helixseg include the meas hit"<<(*it_gothelixseg)->getResIncl()<<std::endl;
5941 std::cout<<"the track id of the helixseg is ..."<<(*it_gothelixseg)->getTrackId() <<std::endl;
5942 std::cout<<"the tof of the helixseg is ..."<<(*it_gothelixseg)->getTof()<<std::endl;
5943 std::cout<<"the Zhit of the helixseg is ..."<<(*it_gothelixseg)->getZhit()<<std::endl;
5944 }
5945 }
5946 for( int i = 0; i<43; i++) {
5947 log << MSG::DEBUG << "retrieved pathl["<<i<<"]= "
5948 << (*iter_trk)->getPathl(i) <<endreq;
5949 }
5950
5951 if(ntuple_&1) {
5952 m_trackid = (*iter_trk)->getTrackId();
5953 for( int jj =0, iii=0; jj<5; jj++) {
5954 m_length[jj] = (*iter_trk)->getLength(jj);
5955 m_tof[jj] = (*iter_trk)->getTof(jj);
5956 m_nhits[jj] = (*iter_trk)->getNhits(jj);
5957 m_zhelix[jj] = (*iter_trk)->getZHelix()[jj];
5958 m_zhelixe[jj] = (*iter_trk)->getZHelixE()[jj];
5959 m_zhelixmu[jj] = (*iter_trk)->getZHelixMu()[jj];
5960 m_zhelixk[jj] = (*iter_trk)->getZHelixK()[jj];
5961 m_zhelixp[jj] = (*iter_trk)->getZHelixP()[jj];
5962 m_fhelix[jj] = (*iter_trk)->getFHelix()[jj];
5963 m_fhelixe[jj] = (*iter_trk)->getFHelixE()[jj];
5964 m_fhelixmu[jj] = (*iter_trk)->getFHelixMu()[jj];
5965 m_fhelixk[jj] = (*iter_trk)->getFHelixK()[jj];
5966 m_fhelixp[jj] = (*iter_trk)->getFHelixP()[jj];
5967 m_lhelix[jj] = (*iter_trk)->getLHelix()[jj];
5968 m_lhelixe[jj] = (*iter_trk)->getLHelixE()[jj];
5969 m_lhelixmu[jj] = (*iter_trk)->getLHelixMu()[jj];
5970 m_lhelixk[jj] = (*iter_trk)->getLHelixK()[jj];
5971 m_lhelixp[jj] = (*iter_trk)->getLHelixP()[jj];
5972 if(ntuple_&32) {
5973 for(int kk=0; kk<=jj; kk++,iii++) {
5974 m_zerror[iii] = (*iter_trk)->getZError()[jj][kk];
5975 m_zerrore[iii] = (*iter_trk)->getZErrorE()[jj][kk];
5976 m_zerrormu[iii] = (*iter_trk)->getZErrorMu()[jj][kk];
5977 m_zerrork[iii] = (*iter_trk)->getZErrorK()[jj][kk];
5978 m_zerrorp[iii] = (*iter_trk)->getZErrorP()[jj][kk];
5979 m_ferror[iii] = (*iter_trk)->getFError()[jj][kk];
5980 m_ferrore[iii] = (*iter_trk)->getFErrorE()[jj][kk];
5981 m_ferrormu[iii] = (*iter_trk)->getFErrorMu()[jj][kk];
5982 m_ferrork[iii] = (*iter_trk)->getFErrorK()[jj][kk];
5983 m_ferrorp[iii] = (*iter_trk)->getFErrorP()[jj][kk];
5984 m_lerror[iii] = (*iter_trk)->getLError()[jj][kk];
5985 m_lerrore[iii] = (*iter_trk)->getLErrorE()[jj][kk];
5986 m_lerrormu[iii] = (*iter_trk)->getLErrorMu()[jj][kk];
5987 m_lerrork[iii] = (*iter_trk)->getLErrorK()[jj][kk];
5988 m_lerrorp[iii] = (*iter_trk)->getLErrorP()[jj][kk];
5989 }
5990
5991 }
5992 }
5993
5994 // RootConversion changed in BOSS6.0, so use thefollowing:
5995 m_chisq[0][0] = (*iter_trk)->getChisq(0,0);
5996 m_chisq[1][0] = (*iter_trk)->getChisq(0,1);
5997 m_chisq[2][0] = (*iter_trk)->getChisq(0,2);
5998 m_chisq[3][0] = (*iter_trk)->getChisq(0,3);
5999 m_chisq[4][0] = (*iter_trk)->getChisq(0,4);
6000 m_chisq[0][1] = (*iter_trk)->getChisq(1,0);
6001 m_chisq[1][1] = (*iter_trk)->getChisq(1,1);
6002 m_chisq[2][1] = (*iter_trk)->getChisq(1,2);
6003 m_chisq[3][1] = (*iter_trk)->getChisq(1,3);
6004 m_chisq[4][1] = (*iter_trk)->getChisq(1,4);
6005
6006 m_ndf[0][0] = (*iter_trk)->getNdf(0,0);
6007 m_ndf[1][0] = (*iter_trk)->getNdf(0,1);
6008 m_ndf[2][0] = (*iter_trk)->getNdf(0,2);
6009 m_ndf[3][0] = (*iter_trk)->getNdf(0,3);
6010 m_ndf[4][0] = (*iter_trk)->getNdf(0,4);
6011 m_ndf[0][1] = (*iter_trk)->getNdf(1,0);
6012 m_ndf[1][1] = (*iter_trk)->getNdf(1,1);
6013 m_ndf[2][1] = (*iter_trk)->getNdf(1,2);
6014 m_ndf[3][1] = (*iter_trk)->getNdf(1,3);
6015 m_ndf[4][1] = (*iter_trk)->getNdf(1,4);
6016
6017 m_stat[0][0] = (*iter_trk)->getStat(0,0);
6018 m_stat[1][0] = (*iter_trk)->getStat(0,1);
6019 m_stat[2][0] = (*iter_trk)->getStat(0,2);
6020 m_stat[3][0] = (*iter_trk)->getStat(0,3);
6021 m_stat[4][0] = (*iter_trk)->getStat(0,4);
6022 m_stat[0][1] = (*iter_trk)->getStat(1,0);
6023 m_stat[1][1] = (*iter_trk)->getStat(1,1);
6024 m_stat[2][1] = (*iter_trk)->getStat(1,2);
6025 m_stat[3][1] = (*iter_trk)->getStat(1,3);
6026 m_stat[4][1] = (*iter_trk)->getStat(1,4);
6027
6028 m_fptot = sqrt(1+pow(m_fhelix[4],2))/m_fhelix[2];
6029 m_fptote = sqrt(1+pow(m_fhelixe[4],2))/m_fhelixe[2];
6030 m_fptotmu = sqrt(1+pow(m_fhelixmu[4],2))/m_fhelixmu[2];
6031 m_fptotk = sqrt(1+pow(m_fhelixk[4],2))/m_fhelixk[2];
6032 m_fptotp = sqrt(1+pow(m_fhelixp[4],2))/m_fhelixp[2];
6033
6034 m_zpt = 1/m_zhelix[2];
6035 m_zpte = 1/m_zhelixe[2];
6036 m_zptmu = 1/m_zhelixmu[2];
6037 m_zptk = 1/m_zhelixk[2];
6038 m_zptp = 1/m_zhelixp[2];
6039
6040 m_fpt = 1/m_fhelix[2];
6041 m_fpte = 1/m_fhelixe[2];
6042 m_fptmu = 1/m_fhelixmu[2];
6043 m_fptk = 1/m_fhelixk[2];
6044 m_fptp = 1/m_fhelixp[2];
6045
6046 m_lpt = 1/m_lhelix[2];
6047 m_lpte = 1/m_lhelixe[2];
6048 m_lptmu = 1/m_lhelixmu[2];
6049 m_lptk = 1/m_lhelixk[2];
6050 m_lptp = 1/m_lhelixp[2];
6051
6052 m_lptot = sqrt(1+pow(m_lhelix[4],2))/m_lhelix[2];
6053 m_lptote = sqrt(1+pow(m_lhelixe[4],2))/m_lhelixe[2];
6054 m_lptotmu = sqrt(1+pow(m_lhelixmu[4],2))/m_lhelixmu[2];
6055 m_lptotk = sqrt(1+pow(m_lhelixk[4],2))/m_lhelixk[2];
6056 m_lptotp = sqrt(1+pow(m_lhelixp[4],2))/m_lhelixp[2];
6057
6058 m_zptot = sqrt(1+pow(m_zhelix[4],2))/m_zhelix[2];
6059 m_zptote = sqrt(1+pow(m_zhelixe[4],2))/m_zhelixe[2];
6060 m_zptotmu = sqrt(1+pow(m_zhelixmu[4],2))/m_zhelixmu[2];
6061 m_zptotk = sqrt(1+pow(m_zhelixk[4],2))/m_zhelixk[2];
6062 m_zptotp = sqrt(1+pow(m_zhelixp[4],2))/m_zhelixp[2];
6063 if(ntuple_&32) {
6064 m_zsigp = sqrt(pow((m_zptot/m_zhelix[2]),2)*m_zerror[5]+
6065 pow((m_zhelix[4]/m_zptot),2)*pow((1/m_zhelix[2]),4)*m_zerror[14]-
6066 2*m_zhelix[4]*m_zerror[12]*pow((1/m_zhelix[2]),3));
6067 m_zsigpe = sqrt(pow((m_zptote/m_zhelixe[2]),2)*m_zerrore[5]+
6068 pow((m_zhelixe[4]/m_zptote),2)*pow((1/m_zhelixe[2]),4)*m_zerrore[14]-
6069 2*m_zhelixe[4]*m_zerrore[12]*pow((1/m_zhelixe[2]),3));
6070 m_zsigpmu = sqrt(pow((m_zptotmu/m_zhelixmu[2]),2)*m_zerrormu[5]+
6071 pow((m_zhelixmu[4]/m_zptotmu),2)*pow((1/m_zhelixmu[2]),4)*m_zerrormu[14]-
6072 2*m_zhelixmu[4]*m_zerrormu[12]*pow((1/m_zhelixmu[2]),3));
6073 m_zsigpk = sqrt(pow((m_zptotk/m_zhelixk[2]),2)*m_zerrork[5]+
6074 pow((m_zhelixk[4]/m_zptotk),2)*pow((1/m_zhelixk[2]),4)*m_zerrork[14]-
6075 2*m_zhelixk[4]*m_zerrork[12]*pow((1/m_zhelixk[2]),3));
6076 m_zsigpp = sqrt(pow((m_zptotp/m_zhelixp[2]),2)*m_zerrorp[5]+
6077 pow((m_zhelixp[4]/m_zptotp),2)*pow((1/m_zhelixp[2]),4)*m_zerrorp[14]-
6078 2*m_zhelixp[4]*m_zerrorp[12]*pow((1/m_zhelixp[2]),3));
6079 }
6080
6081 StatusCode sc1 = m_nt1->write();
6082 if( sc1.isFailure() ) cout<<"Ntuple1 filling failed!"<<endl;
6083 }
6084
6085 if(ntuple_&4) {
6086 if(jj == 1) {
6087 phi1 = (*iter_trk)->getFFi0();
6088 r1 = (*iter_trk)->getFDr();
6089 z1 = (*iter_trk)->getFDz();
6090 kap1 = (*iter_trk)->getFCpa();
6091 tanl1 = (*iter_trk)->getFTanl();
6092 x1 = r1*cos(phi1);
6093 y1 = r1*sin(phi1);
6094 p1 = sqrt(1+tanl1*tanl1)/kap1;
6095 the1 = M_PI/2-atan(tanl1);
6096 } else if(jj == 2) {
6097 phi2 = (*iter_trk)->getFFi0();
6098 r2 = (*iter_trk)->getFDr();
6099 z2 = (*iter_trk)->getFDz();
6100 kap2 = (*iter_trk)->getFCpa();
6101 tanl2 = (*iter_trk)->getFTanl();
6102 x2 = r1*cos(phi2);
6103 y2 = r1*sin(phi2);
6104 p2 = sqrt(1+tanl2*tanl2)/kap1;
6105 the2 = M_PI/2-atan(tanl2);
6106 }
6107 }
6108 }
6109 if(ntuple_&4) {
6110 m_delx = x1 - x2;
6111 m_dely = y1 - y2;
6112 m_delz = z1 - z2;
6113 m_delthe = the1 + the2;
6114 m_delphi = phi1- phi2;
6115 m_delp = p1 - p2;
6116 StatusCode sc2 = m_nt2->write();
6117 if( sc2.isFailure() ) cout<<"Ntuple2 filling failed!"<<endl;
6118 }
6119 delete [] order;
6120 delete [] rCont;
6121 delete [] rGen;
6122 delete [] rOM;
6123
6124 if (debug_ == 4)
6125 cout << "Kalfitting finished " << std::endl;
6126}

Referenced by execute().

◆ kalman_fitting_MdcxReco_Csmc_Sew()

void KalFitAlg::kalman_fitting_MdcxReco_Csmc_Sew ( void )

Definition at line 5079 of file KalFitAlg.cxx.

5080{
5081
5082 MsgStream log(msgSvc(), name());
5083 double Pt_threshold(0.3);
5084 Hep3Vector IP(0,0,0);
5085
5086 vector<MdcRec_trk>* mdcMgr = MdcRecTrkCol::getMdcRecTrkCol();
5087 vector<MdcRec_trk_add>* mdc_addMgr = MdcRecTrkAddCol::getMdcRecTrkAddCol();
5088 vector<MdcRec_wirhit>* whMgr = MdcRecWirhitCol::getMdcRecWirhitCol();
5089
5090 // Table Manager
5091 if ( !&whMgr ) return;
5092
5093 // Get reduced chi**2 of Mdc track :
5094 int ntrk = mdcMgr->size();
5095 // cout<<"ntrk: "<<ntrk<<endl;
5096
5097 int nhits = whMgr->size();
5098 //cout<<"nhits: "<<nhits<<endl;
5099
5100
5101 //check whether Recon already registered
5102 DataObject *aReconEvent;
5103 eventSvc()->findObject("/Event/Recon",aReconEvent);
5104 if(!aReconEvent) {
5105 // register ReconEvent Data Object to TDS;
5106 ReconEvent* recevt = new ReconEvent;
5107 StatusCode sc = eventSvc()->registerObject("/Event/Recon",recevt );
5108 if(sc!=StatusCode::SUCCESS) {
5109 log << MSG::FATAL << "Could not register ReconEvent" <<endreq;
5110 return;
5111 }
5112 }
5113
5114 RecMdcKalTrackCol* kalcol = new RecMdcKalTrackCol;
5116 //make RecMdcKalTrackCol
5117 log << MSG::INFO << "beginning to make RecMdcKalTrackCol" <<endreq;
5118
5119
5120 MdcRec_trk& TrasanTRK = *(mdcMgr->begin());
5121 MdcRec_trk_add& TrasanTRK_add = *(mdc_addMgr->begin());
5122 // Reject the ones with quality != 0
5123 // int trasqual = TrasanTRK_add.quality;
5124 // if(debug_ == 4) cout<<"kalman_fitting>trasqual... "<<trasqual<<endl;
5125 // if (trasqual) continue;
5126
5127 // What kind of KalFit ?
5128 int type(0);
5129 if ((TrasanTRK_add.decision & 32) == 32 ||
5130 (TrasanTRK_add.decision & 64) == 64) type = 1;
5131
5132 // Initialisation : (x, a, ea)
5133 HepPoint3D x(TrasanTRK.pivot[0],
5134 TrasanTRK.pivot[1],
5135 TrasanTRK.pivot[2]);
5136
5137 HepVector a(5);
5138 for(int i = 0; i < 5; i++)
5139 a[i] = TrasanTRK.helix[i];
5140
5141 HepSymMatrix ea(5);
5142 for(int i = 0, k = 0; i < 5; i++) {
5143 for(int j = 0; j <= i; j++) {
5144 ea[i][j] = matrixg_*TrasanTRK.error[k++];
5145 ea[j][i] = ea[i][j];
5146 }
5147 }
5148
5150
5151 double fiTerm = TrasanTRK.fiTerm;
5152 int way(1);
5153 // Prepare the track found :
5154 KalFitTrack track_lead = KalFitTrack(x, a, ea, lead_, 0, 0);
5155 track_lead.bFieldZ(KalFitTrack::Bznom_);
5156
5157 int hit_asso(0);
5158 // Reject the ones with quality != 0
5159 int trasqual = TrasanTRK_add.quality;
5160 if(debug_ == 4) cout<<"kalman_fitting>trasqual... "<<trasqual<<endl;
5161 if (trasqual) return;
5162 // Mdc Hits
5163 int inlyr(999), outlyr(-1);
5164 int* rStat = new int[43];
5165 for(int irStat=0;irStat<43;++irStat)rStat[irStat]=0;
5166 std::vector<MdcRec_wirhit*> pt=TrasanTRK.hitcol;
5167 int hit_in(0);
5168 if(debug_ == 4) cout<<"*********Pt size****"<< pt.size()<<endl;
5169 // Number of hits/layer
5170 int Num[43] = {0};
5171 for (vector<MdcRec_wirhit*>::iterator ii = pt.end()-1;
5172 ii != pt.begin()-1; ii--) {
5173 Num[(*ii)->geo->Lyr()->Id()]++;
5174 }
5175
5176 for (vector<MdcRec_wirhit*>::iterator ii = pt.end()-1;
5177 ii != pt.begin()-1; ii--) {
5178
5179 hit_asso++;
5180 if (Num[(*ii)->geo->Lyr()->Id()]>3) {
5181 if (debug_ ==4)
5182 cout << "WARNING: I found " << Num[(*ii)->geo->Lyr()->Id()]
5183 << " hits in the layer "
5184 << (*ii)->geo->Lyr()->Id() << std::endl;
5185 continue;
5186 }
5187
5188 hit_in++;
5189 MdcRec_wirhit & rechit = **ii;
5190 double dist[2] = {rechit.ddl, rechit.ddr};
5191 double erdist[2] = {rechit.erddl, rechit.erddr};
5192 const MdcGeoWire* geo = rechit.geo;
5193
5194 int lr_decision(0);
5195 if (KalFitTrack::LR_ == 1){
5196 if (rechit.lr==2 || rechit.lr==0) lr_decision=-1;
5197 // if (rechit.lr==0) lr_decision=-1;
5198 else if (rechit.lr==1) lr_decision=1;
5199 }
5200
5201 int ind(geo->Lyr()->Id());
5202 track_lead.appendHitsMdc( KalFitHitMdc(rechit.id,
5203 lr_decision, rechit.tdc,
5204 dist, erdist,
5205 _wire+(geo->Id()), rechit.rechitptr));
5206 // inner/outer layer :
5207 rStat[ind]++;
5208 if (inlyr>ind) inlyr = ind;
5209 if (outlyr<ind) outlyr = ind;
5210 }
5211 // Empty layers :
5212 int empty_between(0), empty(0);
5213 for (int i= inlyr; i <= outlyr; i++)
5214 if (!rStat[i]) empty_between++;
5215 empty = empty_between+inlyr+(42-outlyr);
5216 delete [] rStat;
5217
5218 if (debug_ == 4)
5219 cout << "**** NUMBER OF Mdc HITS (TRASAN) = " << hit_asso << std::endl;
5220
5221
5222 // RMK high momentum track under study, probably not neeeded...
5223 track_lead.order_wirhit(0);
5224 track_lead.type(type);
5225 unsigned int nhit = track_lead.HitsMdc().size();
5226 if (nhit<70) {
5227 cout << " ATTENTION TRACK WITH ONLY HITS " << nhit << std::endl;
5228 return;
5229 }
5230
5231 // Initialisation :
5232 double KalFitst(0), KalFitax(0), KalFitschi2(0);
5233 // Move to the outer most hit :
5234 Hep3Vector outer_pivot(track_lead.x(fiTerm));
5235
5236 if(debug_ == 4) {
5237 std::cout<<"before track_lead.pivot(outer_pivot) ,the error matrix of track_lead is .."<<track_lead.Ea()<<std::endl;
5238 }
5239 track_lead.pivot(outer_pivot); // hi gay, the error matrix is changed in this function!!
5240 track_lead.bFieldZ(KalFitTrack::Bznom_);
5241 // attention best_chi2 reinitialize !!!
5242 if (nhit>=3 && !KalFitTrack::LR_)
5243 start_seed(track_lead, lead_, way, TrasanTRK);
5244 HepSymMatrix Eakal(5,0);
5245
5246 //init_matrix(TrasanTRK, Eakal);
5247
5248 double costheta = track_lead.a()[4] / sqrt(1.0 + track_lead.a()[4]*track_lead.a()[4]);
5249 if( (1.0/fabs(track_lead.a()[2]) < pt_cut_ ) && (fabs(costheta)> theta_cut_) ) {
5250 choice_ = 6;
5251 }
5252
5253 init_matrix(choice_,TrasanTRK, Eakal);
5254
5255 //std::cout<<" Eakal be here: "<<Eakal<<std::endl;
5256
5257 if (debug_ == 4){
5258 std::cout << "from Mdc Pattern Recognition: " << std::endl;
5259 //HepPoint3D IP(0,0,0);
5260 KalmanFit::Helix work(track_lead.pivot(),
5261 track_lead.a(),
5262 track_lead.Ea());
5263 work.pivot(IP);
5264 std::cout << " dr = " << work.a()[0]
5265 << ", Er_dr = " << sqrt(work.Ea()[0][0]) << std::endl;
5266 std::cout << " phi0 = " << work.a()[1]
5267 << ", Er_phi0 = " << sqrt(work.Ea()[1][1]) << std::endl;
5268 std::cout << " PT = " << 1/work.a()[2]
5269 << ", Er_kappa = " << sqrt(work.Ea()[2][2]) << std::endl;
5270 std::cout << " dz = " << work.a()[3]
5271 << ", Er_dz = " << sqrt(work.Ea()[3][3]) << std::endl;
5272 std::cout << " tanl = " << work.a()[4]
5273 << ", Er_tanl = " << sqrt(work.Ea()[4][4]) << std::endl;
5274 }
5275 filter_fwd_calib(track_lead, lead_, way, Eakal);
5276 track_lead.update_forMdc();
5277
5278 //HepPoint3D IP(0,0,0);
5279 if (debug_ == 4) {
5280 cout << " Mdc FIRST KALMAN FIT " << std::endl;
5281 KalmanFit::Helix work1(track_lead.pivot(),
5282 track_lead.a(),
5283 track_lead.Ea());
5284 work1.pivot(IP);
5285 cout << " dr = " << work1.a()[0]
5286 << ", Er_dr = " << sqrt(work1.Ea()[0][0]) << std::endl;
5287 cout << " phi0 = " << work1.a()[1]
5288 << ", Er_phi0 = " << sqrt(work1.Ea()[1][1]) << std::endl;
5289 cout << " PT = " << 1/work1.a()[2]
5290 << ", Er_kappa = " << sqrt(work1.Ea()[2][2]) << std::endl;
5291 cout << " dz = " << work1.a()[3]
5292 << ", Er_dz = " << sqrt(work1.Ea()[3][3]) << std::endl;
5293 cout << " tanl = " << work1.a()[4]
5294 << ", Er_tanl = " << sqrt(work1.Ea()[4][4]) << std::endl;
5295 }
5296
5297 // fill TDS
5298 RecMdcKalTrack* kaltrk = new RecMdcKalTrack;
5299
5300 // Complete the track (other mass assumption, backward) and
5301 complete_track(TrasanTRK, TrasanTRK_add, track_lead, kaltrk,kalcol,segcol);
5302
5303
5304 StatusCode kalsc;
5305 //check whether the RecMdcKalTrackCol has been already registered
5306 DataObject *aRecKalEvent;
5307 eventSvc()->findObject("/Event/Recon/RecMdcKalTrackCol", aRecKalEvent);
5308 if(aRecKalEvent!=NULL) {
5309 //then unregister RecMdcKalCol
5310 kalsc = eventSvc()->unregisterObject("/Event/Recon/RecMdcKalTrackCol");
5311 if(kalsc != StatusCode::SUCCESS) {
5312 log << MSG::FATAL << "Could not unregister RecMdcKalTrack collection" << endreq;
5313 return;
5314 }
5315 }
5316
5317 kalsc = eventSvc()->registerObject("/Event/Recon/RecMdcKalTrackCol", kalcol);
5318 if( kalsc.isFailure()) {
5319 log << MSG::FATAL << "Could not register RecMdcKalTrack" << endreq;
5320 return;
5321 }
5322 log << MSG::INFO << "RecMdcKalTrackCol registered successfully!" <<endreq;
5323
5324
5325
5326 StatusCode segsc;
5327 //check whether the RecMdcKalHelixSegCol has been already registered
5328 DataObject *aRecKalSegEvent;
5329 eventSvc()->findObject("/Event/Recon/RecMdcKalHelixSegCol", aRecKalSegEvent);
5330 if(aRecKalSegEvent!=NULL) {
5331 //then unregister RecMdcKalHelixSegCol
5332 segsc = eventSvc()->unregisterObject("/Event/Recon/RecMdcKalHelixSegCol");
5333 if(segsc != StatusCode::SUCCESS) {
5334 log << MSG::FATAL << "Could not unregister RecMdcKalHelixSegCol collection" << endreq;
5335 return;
5336 }
5337 }
5338
5339 segsc = eventSvc()->registerObject("/Event/Recon/RecMdcKalHelixSegCol", segcol);
5340 if( segsc.isFailure() ) {
5341 log << MSG::FATAL << "Could not register RecMdcKalHelixSeg" << endreq;
5342 return;
5343 }
5344 log << MSG::INFO << "RecMdcKalHelixSegCol registered successfully!" <<endreq;
5345
5346
5347 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.);
5348 double r1(0.),r2(0.),kap1(999.),kap2(999.),tanl1(0.),tanl2(0.);
5349 //check the result:RecMdcKalTrackCol
5350
5351 SmartDataPtr<RecMdcKalTrackCol> kaltrkCol(eventSvc(),"/Event/Recon/RecMdcKalTrackCol");
5352 if (!kaltrkCol) {
5353 log << MSG::FATAL << "Could not find RecMdcKalTrackCol" << endreq;
5354 return;
5355 }
5356 log << MSG::INFO << "Begin to check RecMdcKalTrackCol"<<endreq;
5357 RecMdcKalTrackCol::iterator iter_trk = kaltrkCol->begin();
5358 for( int jj=1; iter_trk != kaltrkCol->end(); iter_trk++,jj++) {
5359 log << MSG::DEBUG << "retrieved MDC Kalmantrack:"
5360 << "Track Id: " << (*iter_trk)->getTrackId()
5361 << " Mass of the fit: "<< (*iter_trk)->getMass(2)<< endreq
5362 << " Length of the track: "<< (*iter_trk)->getLength(2)
5363 << " Tof of the track: "<< (*iter_trk)->getTof(2) << endreq
5364 << " Chisq of the fit: "<< (*iter_trk)->getChisq(0,2)
5365 <<" "<< (*iter_trk)->getChisq(1,2) << endreq
5366 << "Ndf of the fit: "<< (*iter_trk)->getNdf(0,1)
5367 <<" "<< (*iter_trk)->getNdf(1,2) << endreq
5368 << "Kappa " << (*iter_trk)->getZHelix()[2]
5369 << "zhelixmu "<<(*iter_trk)->getZHelixMu()
5370 << endreq;
5371
5372 HelixSegRefVec gothelixsegs = (*iter_trk)->getVecHelixSegs();
5373 if(debug_ == 4) {
5374 std::cout<<"the size of gothelixsegs ..."<<gothelixsegs.size()<<std::endl;
5375 }
5376
5377 HelixSegRefVec::iterator it_gothelixseg = gothelixsegs.begin();
5378 for( ; it_gothelixseg != gothelixsegs.end(); it_gothelixseg++) {
5379 if(debug_ == 4) {
5380 std::cout<<"the layerId of this helixseg is ..."<<(*it_gothelixseg)->getLayerId()<<std::endl;
5381 std::cout<<"the residual of this helixseg exclude the meas hit"<<(*it_gothelixseg)->getResExcl()<<std::endl;
5382 std::cout<<"the residual of this helixseg include the meas hit"<<(*it_gothelixseg)->getResIncl()<<std::endl;
5383 std::cout<<"the track id of the helixseg is ..."<<(*it_gothelixseg)->getTrackId() <<std::endl;
5384 std::cout<<"the tof of the helixseg is ..."<<(*it_gothelixseg)->getTof()<<std::endl;
5385 std::cout<<"the Zhit of the helixseg is ..."<<(*it_gothelixseg)->getZhit()<<std::endl;
5386 }
5387 }
5388 for( int i = 0; i<43; i++) {
5389 log << MSG::DEBUG << "retrieved pathl["<<i<<"]= "
5390 << (*iter_trk)->getPathl(i) <<endreq;
5391 }
5392
5393 if(ntuple_&1) {
5394 m_trackid = (*iter_trk)->getTrackId();
5395 for( int jj =0, iii=0; jj<5; jj++) {
5396 m_length[jj] = (*iter_trk)->getLength(jj);
5397 m_tof[jj] = (*iter_trk)->getTof(jj);
5398 m_nhits[jj] = (*iter_trk)->getNhits(jj);
5399 m_zhelix[jj] = (*iter_trk)->getZHelix()[jj];
5400 m_zhelixe[jj] = (*iter_trk)->getZHelixE()[jj];
5401 m_zhelixmu[jj] = (*iter_trk)->getZHelixMu()[jj];
5402 m_zhelixk[jj] = (*iter_trk)->getZHelixK()[jj];
5403 m_zhelixp[jj] = (*iter_trk)->getZHelixP()[jj];
5404 m_fhelix[jj] = (*iter_trk)->getFHelix()[jj];
5405 m_fhelixe[jj] = (*iter_trk)->getFHelixE()[jj];
5406 m_fhelixmu[jj] = (*iter_trk)->getFHelixMu()[jj];
5407 m_fhelixk[jj] = (*iter_trk)->getFHelixK()[jj];
5408 m_fhelixp[jj] = (*iter_trk)->getFHelixP()[jj];
5409 m_lhelix[jj] = (*iter_trk)->getLHelix()[jj];
5410 m_lhelixe[jj] = (*iter_trk)->getLHelixE()[jj];
5411 m_lhelixmu[jj] = (*iter_trk)->getLHelixMu()[jj];
5412 m_lhelixk[jj] = (*iter_trk)->getLHelixK()[jj];
5413 m_lhelixp[jj] = (*iter_trk)->getLHelixP()[jj];
5414 if(ntuple_&32) {
5415 for(int kk=0; kk<=jj; kk++,iii++) {
5416 m_zerror[iii] = (*iter_trk)->getZError()[jj][kk];
5417 m_zerrore[iii] = (*iter_trk)->getZErrorE()[jj][kk];
5418 m_zerrormu[iii] = (*iter_trk)->getZErrorMu()[jj][kk];
5419 m_zerrork[iii] = (*iter_trk)->getZErrorK()[jj][kk];
5420 m_zerrorp[iii] = (*iter_trk)->getZErrorP()[jj][kk];
5421 m_ferror[iii] = (*iter_trk)->getFError()[jj][kk];
5422 m_ferrore[iii] = (*iter_trk)->getFErrorE()[jj][kk];
5423 m_ferrormu[iii] = (*iter_trk)->getFErrorMu()[jj][kk];
5424 m_ferrork[iii] = (*iter_trk)->getFErrorK()[jj][kk];
5425 m_ferrorp[iii] = (*iter_trk)->getFErrorP()[jj][kk];
5426 m_lerror[iii] = (*iter_trk)->getLError()[jj][kk];
5427 m_lerrore[iii] = (*iter_trk)->getLErrorE()[jj][kk];
5428 m_lerrormu[iii] = (*iter_trk)->getLErrorMu()[jj][kk];
5429 m_lerrork[iii] = (*iter_trk)->getLErrorK()[jj][kk];
5430 m_lerrorp[iii] = (*iter_trk)->getLErrorP()[jj][kk];
5431 }
5432
5433 }
5434 }
5435
5436 // RootConversion changed in BOSS6.0, so use thefollowing:
5437 m_chisq[0][0] = (*iter_trk)->getChisq(0,0);
5438 m_chisq[1][0] = (*iter_trk)->getChisq(0,1);
5439 m_chisq[2][0] = (*iter_trk)->getChisq(0,2);
5440 m_chisq[3][0] = (*iter_trk)->getChisq(0,3);
5441 m_chisq[4][0] = (*iter_trk)->getChisq(0,4);
5442 m_chisq[0][1] = (*iter_trk)->getChisq(1,0);
5443 m_chisq[1][1] = (*iter_trk)->getChisq(1,1);
5444 m_chisq[2][1] = (*iter_trk)->getChisq(1,2);
5445 m_chisq[3][1] = (*iter_trk)->getChisq(1,3);
5446 m_chisq[4][1] = (*iter_trk)->getChisq(1,4);
5447
5448 m_ndf[0][0] = (*iter_trk)->getNdf(0,0);
5449 m_ndf[1][0] = (*iter_trk)->getNdf(0,1);
5450 m_ndf[2][0] = (*iter_trk)->getNdf(0,2);
5451 m_ndf[3][0] = (*iter_trk)->getNdf(0,3);
5452 m_ndf[4][0] = (*iter_trk)->getNdf(0,4);
5453 m_ndf[0][1] = (*iter_trk)->getNdf(1,0);
5454 m_ndf[1][1] = (*iter_trk)->getNdf(1,1);
5455 m_ndf[2][1] = (*iter_trk)->getNdf(1,2);
5456 m_ndf[3][1] = (*iter_trk)->getNdf(1,3);
5457 m_ndf[4][1] = (*iter_trk)->getNdf(1,4);
5458
5459 m_stat[0][0] = (*iter_trk)->getStat(0,0);
5460 m_stat[1][0] = (*iter_trk)->getStat(0,1);
5461 m_stat[2][0] = (*iter_trk)->getStat(0,2);
5462 m_stat[3][0] = (*iter_trk)->getStat(0,3);
5463 m_stat[4][0] = (*iter_trk)->getStat(0,4);
5464 m_stat[0][1] = (*iter_trk)->getStat(1,0);
5465 m_stat[1][1] = (*iter_trk)->getStat(1,1);
5466 m_stat[2][1] = (*iter_trk)->getStat(1,2);
5467 m_stat[3][1] = (*iter_trk)->getStat(1,3);
5468 m_stat[4][1] = (*iter_trk)->getStat(1,4);
5469
5470 m_fptot = sqrt(1+pow(m_fhelix[4],2))/m_fhelix[2];
5471 m_fptote = sqrt(1+pow(m_fhelixe[4],2))/m_fhelixe[2];
5472 m_fptotmu = sqrt(1+pow(m_fhelixmu[4],2))/m_fhelixmu[2];
5473 m_fptotk = sqrt(1+pow(m_fhelixk[4],2))/m_fhelixk[2];
5474 m_fptotp = sqrt(1+pow(m_fhelixp[4],2))/m_fhelixp[2];
5475
5476 m_zpt = 1/m_zhelix[2];
5477 m_zpte = 1/m_zhelixe[2];
5478 m_zptmu = 1/m_zhelixmu[2];
5479 m_zptk = 1/m_zhelixk[2];
5480 m_zptp = 1/m_zhelixp[2];
5481
5482 m_fpt = 1/m_fhelix[2];
5483 m_fpte = 1/m_fhelixe[2];
5484 m_fptmu = 1/m_fhelixmu[2];
5485 m_fptk = 1/m_fhelixk[2];
5486 m_fptp = 1/m_fhelixp[2];
5487
5488 m_lpt = 1/m_lhelix[2];
5489 m_lpte = 1/m_lhelixe[2];
5490 m_lptmu = 1/m_lhelixmu[2];
5491 m_lptk = 1/m_lhelixk[2];
5492 m_lptp = 1/m_lhelixp[2];
5493
5494 m_lptot = sqrt(1+pow(m_lhelix[4],2))/m_lhelix[2];
5495 m_lptote = sqrt(1+pow(m_lhelixe[4],2))/m_lhelixe[2];
5496 m_lptotmu = sqrt(1+pow(m_lhelixmu[4],2))/m_lhelixmu[2];
5497 m_lptotk = sqrt(1+pow(m_lhelixk[4],2))/m_lhelixk[2];
5498 m_lptotp = sqrt(1+pow(m_lhelixp[4],2))/m_lhelixp[2];
5499
5500 m_zptot = sqrt(1+pow(m_zhelix[4],2))/m_zhelix[2];
5501 m_zptote = sqrt(1+pow(m_zhelixe[4],2))/m_zhelixe[2];
5502 m_zptotmu = sqrt(1+pow(m_zhelixmu[4],2))/m_zhelixmu[2];
5503 m_zptotk = sqrt(1+pow(m_zhelixk[4],2))/m_zhelixk[2];
5504 m_zptotp = sqrt(1+pow(m_zhelixp[4],2))/m_zhelixp[2];
5505 if(ntuple_&32) {
5506 m_zsigp = sqrt(pow((m_zptot/m_zhelix[2]),2)*m_zerror[5]+
5507 pow((m_zhelix[4]/m_zptot),2)*pow((1/m_zhelix[2]),4)*m_zerror[14]-
5508 2*m_zhelix[4]*m_zerror[12]*pow((1/m_zhelix[2]),3));
5509 m_zsigpe = sqrt(pow((m_zptote/m_zhelixe[2]),2)*m_zerrore[5]+
5510 pow((m_zhelixe[4]/m_zptote),2)*pow((1/m_zhelixe[2]),4)*m_zerrore[14]-
5511 2*m_zhelixe[4]*m_zerrore[12]*pow((1/m_zhelixe[2]),3));
5512 m_zsigpmu = sqrt(pow((m_zptotmu/m_zhelixmu[2]),2)*m_zerrormu[5]+
5513 pow((m_zhelixmu[4]/m_zptotmu),2)*pow((1/m_zhelixmu[2]),4)*m_zerrormu[14]-
5514 2*m_zhelixmu[4]*m_zerrormu[12]*pow((1/m_zhelixmu[2]),3));
5515 m_zsigpk = sqrt(pow((m_zptotk/m_zhelixk[2]),2)*m_zerrork[5]+
5516 pow((m_zhelixk[4]/m_zptotk),2)*pow((1/m_zhelixk[2]),4)*m_zerrork[14]-
5517 2*m_zhelixk[4]*m_zerrork[12]*pow((1/m_zhelixk[2]),3));
5518 m_zsigpp = sqrt(pow((m_zptotp/m_zhelixp[2]),2)*m_zerrorp[5]+
5519 pow((m_zhelixp[4]/m_zptotp),2)*pow((1/m_zhelixp[2]),4)*m_zerrorp[14]-
5520 2*m_zhelixp[4]*m_zerrorp[12]*pow((1/m_zhelixp[2]),3));
5521 }
5522
5523 StatusCode sc1 = m_nt1->write();
5524 if( sc1.isFailure() ) cout<<"Ntuple1 filling failed!"<<endl;
5525 }
5526
5527 if(ntuple_&4) {
5528 if(jj == 1) {
5529 phi1 = (*iter_trk)->getFFi0();
5530 r1 = (*iter_trk)->getFDr();
5531 z1 = (*iter_trk)->getFDz();
5532 kap1 = (*iter_trk)->getFCpa();
5533 tanl1 = (*iter_trk)->getFTanl();
5534 x1 = r1*cos(phi1);
5535 y1 = r1*sin(phi1);
5536 p1 = sqrt(1+tanl1*tanl1)/kap1;
5537 the1 = M_PI/2-atan(tanl1);
5538 } else if(jj == 2) {
5539 phi2 = (*iter_trk)->getFFi0();
5540 r2 = (*iter_trk)->getFDr();
5541 z2 = (*iter_trk)->getFDz();
5542 kap2 = (*iter_trk)->getFCpa();
5543 tanl2 = (*iter_trk)->getFTanl();
5544 x2 = r1*cos(phi2);
5545 y2 = r1*sin(phi2);
5546 p2 = sqrt(1+tanl2*tanl2)/kap1;
5547 the2 = M_PI/2-atan(tanl2);
5548 }
5549 }
5550 }
5551 if(ntuple_&4) {
5552 m_delx = x1 - x2;
5553 m_dely = y1 - y2;
5554 m_delz = z1 - z2;
5555 m_delthe = the1 + the2;
5556 m_delphi = phi1- phi2;
5557 m_delp = p1 - p2;
5558 StatusCode sc2 = m_nt2->write();
5559 if( sc2.isFailure() ) cout<<"Ntuple2 filling failed!"<<endl;
5560 }
5561
5562 if (debug_ == 4)
5563 cout << "Kalfitting finished " << std::endl;
5564}

Referenced by execute().

◆ makeGemHitsCol()

void KalFitAlg::makeGemHitsCol ( )

Definition at line 7270 of file KalFitAlg.cxx.

7271{
7272 for(int i=0; i<3; i++) myGemHitCol[i].clear();
7273
7274 /*SmartDataPtr<Event::MdcMcHitCol> mdcMcHitCol(eventSvc(), "/Event/MC/MdcMcHitCol");
7275 SmartDataPtr<MdcDigiCol> mdcDigiCol(eventSvc(),"/Event/Digi/MdcDigiCol");
7276
7277 int nHits, nDigi;
7278 unsigned int stripIndx, isVStrip;
7279 int layer;
7280 double x, y, z, r, phi;
7281
7282 nHits = mdcMcHitCol->size();
7283 nDigi = mdcDigiCol->size();
7284
7285 //cout<<__FUNCTION__<<":: nHits = "<<nHits<<endl;
7286
7287 Rndm::Numbers gaussRPhi(randSvc(), Rndm::Gauss(0.,0.023));
7288 Rndm::Numbers gaussZ(randSvc(), Rndm::Gauss(0.,0.05));
7289
7290 MdcMcHitCol::const_iterator it = mdcMcHitCol->begin();
7291
7292 cout<<endl<<endl<<" ------------- Mdc MC hits: ------------"<<endl<<endl;*/
7293
7294 SmartDataPtr<RecCgemClusterCol> cgemClusterCol(eventSvc(),"/Event/Recon/RecCgemClusterCol");
7295 int layer,sheet;
7296 double phi,v;
7297 RecCgemClusterCol::const_iterator it = cgemClusterCol->begin();
7298 for(;it!=cgemClusterCol->end();it++){
7299 //cout<<"cluster:"<<(*it)->getclusterid()<<" phi:"<<(*it)->getrecphi()<<" z:"<<(*it)->getRecZ()<<endl;
7300 if((*it)->getflag()==2){
7301 layer = (*it)->getlayerid();
7302 sheet = (*it)->getsheetid();
7303 phi = (*it)->getrecphi();
7304 v = (*it)->getrecv();
7305 KalFitGemHit aKalFitGemHit(phi,v,layer,sheet);
7306 myGemHitCol[layer].push_back(aKalFitGemHit);
7307 }
7308 }
7309 if(debug_==4){
7310 cout << "Gem information" << endl;
7311 cout << "first layer " << myGemHitCol[0].size() << endl;
7312 cout << "second layer" << myGemHitCol[1].size() << endl;
7313 cout << "third layer" << myGemHitCol[2].size() << endl;
7314 }
7315 /*
7316 for(;it!=mdcMcHitCol->end(); it++)
7317 {
7318 Identifier id= (*it)->identify();
7319 layer = MdcID::layer(id);
7320 if(layer>7) continue;
7321 stripIndx = (*it)->getDriftDistance();
7322 isVStrip = (*it)->getPositionFlag();
7323 x = ((*it)->getPositionX())*0.1; // mm->cm
7324 y = ((*it)->getPositionY())*0.1; // mm->cm
7325 z = ((*it)->getPositionZ())*0.1; // mm->cm
7326 r=sqrt(x*x+y*y);
7327 phi=atan2(y,x);
7328 cout<<"id, layer , stripIndx, isVSTrip = "<<id<<", "<<layer<<", "<<stripIndx<<", "<<isVStrip<<endl;
7329 //cout<<" true x, y, z, phi, r = "<<x<<", "<<y<<", "<<z<<", "<<phi<<", "<<r<<endl;
7330 if(myGemHitCol[layer].empty())
7331 {
7332 //cout<<"myGemHitCol["<<layer<<"] is empty"<<endl;
7333 phi+=gaussRPhi()/r;
7334 while(phi>M_PI) phi-=M_PI2;
7335 while(phi<-M_PI) phi+=M_PI2;
7336 z+=gaussZ();
7337 KalFitGemHit aKalFitGemHit(phi,z,r);
7338 //cout<<" resam x, y, z, phi, r = "<<x<<", "<<y<<", "<<z<<", "<<phi<<", "<<r<<endl;
7339 myGemHitCol[layer].push_back(aKalFitGemHit);
7340 }
7341 }
7342
7343 cout<<endl<<endl<<" ------------- Mdc digi: ------------"<<endl<<endl;
7344
7345 MdcDigiCol::const_iterator it_digi = mdcDigiCol->begin();
7346 for(;it_digi!=mdcDigiCol->end(); it_digi++)
7347 {
7348 Identifier id = (*it_digi)->identify();
7349 layer = MdcID::layer(id);
7350 if(layer>7) continue;
7351 double stripId = RawDataUtil::MdcTime((*it_digi)->getTimeChannel());
7352 double isV = RawDataUtil::MdcCharge((*it_digi)->getChargeChannel());
7353 cout<<"id, layer , stripIndx, isVSTrip = "<<id<<", "<<layer<<", "<<stripId<<", "<<isV<<endl;
7354 stripIndx=stripId+0.5;
7355 cout<<" stripIndx = "<<id<<", "<<layer<<", "<<stripIndx<<", "<<isV<<endl;
7356 }
7357 */
7358
7359 // --- print out GEM hits
7360 bool prtGemHits=false;
7361 //bool prtGemHits=true;
7362 if(prtGemHits) cout<<endl<<"------- GEM hits: --------"<<endl;
7363 for(int i=0; i<3; i++)
7364 {
7365 if(prtGemHits) cout<<"### layer "<<i<<endl;
7366 //int nhits = myGemHitCol[i].size();
7367 KalFitGemHitCol::const_iterator it_GemHit = (myGemHitCol[i]).begin();
7368 for(int j=0; it_GemHit!=(myGemHitCol[i]).end(); it_GemHit++, j++)
7369 {
7370 if(prtGemHits) cout<<" hit "<<(j+1)<<": phi, z, r = "<<it_GemHit->getPhi()<<", "<<it_GemHit->getZ()<<", "<<it_GemHit->getR()<<endl;
7371 }
7372 }
7373
7374}
**********Class see also m_nmax DOUBLE PRECISION m_amel DOUBLE PRECISION m_x2 DOUBLE PRECISION m_alfinv DOUBLE PRECISION m_Xenph INTEGER m_KeyWtm INTEGER m_idyfs DOUBLE PRECISION m_zini DOUBLE PRECISION m_q2 DOUBLE PRECISION m_Wt_KF DOUBLE PRECISION m_WtCut INTEGER m_KFfin *COMMON c_KarLud $ !Input CMS energy[GeV] $ !CMS energy after beam spread beam strahlung[GeV] $ !Beam energy spread[GeV] $ !z boost due to beam spread $ !electron beam mass *ff pair spectrum $ !minimum v
Definition KarLud.h:35

Referenced by execute().

◆ residual()

void KalFitAlg::residual ( KalFitTrack & track)

Definition at line 8097 of file KalFitAlg.cxx.

8098{
8099
8100 //cout<<"R:"<<track.pivot().perp()<<endl;
8101 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
8102 if (!eventHeader) {
8103 cout << "Could not find Event Header" << endl;
8104 }
8105 int eventNo = eventHeader->eventNumber();
8106 int runNo = eventHeader->runNumber();
8107 m_evt=eventNo;
8108 //cout<<"Event::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::"<<eventNo<<endl;
8109
8110 SmartDataPtr<McParticleCol> mcPartCol(eventSvc(),"/Event/MC/McParticleCol");
8111 if (!mcPartCol) {
8112 cout << "Could not find McParticle" << endl;
8113 }
8114
8115 HepVector mc_a(5,0);
8116 McParticleCol::iterator i_mcTrk = mcPartCol->begin();
8117 for (;i_mcTrk != mcPartCol->end(); i_mcTrk++) {
8118 if(!(*i_mcTrk)->primaryParticle()) continue;
8119 const HepLorentzVector& mom((*i_mcTrk)->initialFourMomentum());
8120 const HepLorentzVector& pos = (*i_mcTrk)->initialPosition();
8121 //cout<<"MCposition:"<<pos.x()<<" "<<pos.y()<<" "<<pos.z()<<" "<<endl;
8122 double charge = 0.0;
8123 int pid = (*i_mcTrk)->particleProperty();
8124 if( pid >0 ) {
8125 charge = m_particleTable->particle( pid )->charge();
8126 } else if ( pid <0 ) {
8127 charge = m_particleTable->particle( -pid )->charge();
8128 charge *= -1;
8129 } else {
8130 }
8131 HepPoint3D pos2(pos.x(),pos.y(),pos.z());
8132 Hep3Vector mom2(mom.px(),mom.py(),mom.pz());
8133
8134 KalmanFit::Helix mchelix(pos2, mom2, charge);
8135 //if( debug_ == 0) cout<< "helix: "<<mchelix.a()<<endl;
8136 mchelix.pivot( HepPoint3D(0,0,0) );
8137 for( int j =0; j<5; j++) {
8138 //m_mchelix[j] = mchelix.a()[j];
8139 mc_a[j] = mchelix.a()[j];
8140 }
8141 //m_mcpid = pid;
8142 //m_mcptot = sqrt(1+pow(m_mchelix[4],2))/m_mchelix[2];
8143 }
8144 HepPoint3D IP(0,0,0);
8145 KalmanFit::Helix MChelix(IP,mc_a);
8146 MChelix.pivot(track.pivot());
8147 m_diff_dr = track.a()[0]-MChelix.a()[0];
8148 m_diff_phi0 = track.a()[1]-MChelix.a()[1];
8149 m_diff_kappa = track.a()[2]-MChelix.a()[2];
8150 m_diff_dz = track.a()[3]-MChelix.a()[3];
8151 m_diff_tanl = track.a()[4]-MChelix.a()[4];
8152 if(track.a()[2] != 0 && MChelix.a()[2] != 0)
8153 m_diff_p = sqrt(1+track.a()[4]*track.a()[4])/track.a()[2] - sqrt(1+MChelix.a()[4]*MChelix.a()[4])/MChelix.a()[2];
8154 else
8155 m_diff_p =9999;
8156 StatusCode sc12 = m_nt12->write();
8157 if( sc12.isFailure() ) cout<<"Ntuple12 filling failed!"<<endl;
8158 //cout<<"kalfit a:"<<track.a()<<endl<<"MCtruth a:"<<MChelix.a()<<endl<<endl;
8159 ///*
8160 // --- calculate the material quantity
8161 bool printwalls = false;
8162 if(printwalls){
8163 double material_quantity(0);
8164 int size = _BesKalmanFitWalls.size();
8165 for(int i=0;i<size;i++)
8166 {
8167 double ro = _BesKalmanFitWalls[i].radius();
8168 double ri = _BesKalmanFitWalls[i].rmin();
8169 double thick = ro-ri;
8170 KalFitMaterial material = _BesKalmanFitWalls[i].material();
8171 double X0 = material.X0();
8172 double rho = material.get_density();
8173 double Z = material.Z();
8174 //double X = X0/rho;
8175 material_quantity += 100*thick/X0;
8176 cout<<"----------------------------------------------------------------------------------------------------"<<endl;
8177 cout<<"wall"<<i+1<<" Z:"<<setw(12)<<Z<<endl;
8178 cout<<"Ri(cm):"<<setw(12)<<ri<<"Ro(cm):"<<setw(12)<<ro<<"T(cm):"<<setw(12)<<thick<<"X0(cm):"<<setw(12)<<X0<<"T/X0(%)="<<setw(12)<<100*thick/X0<<"accumulation(%):"<<setw(12)<<material_quantity<<endl;
8179 cout<<"----------------------------------------------------------------------------------------------------"<<endl;
8180 cout<<endl;
8181 //cout<<"wall"<<i+1<<" Z:"<<Z<<" Thick:"<<thick<<" Density:"<<rho <<" X0:"<<X0<<endl;
8182 //cout<<"radiation length="<<x<<" material quantity="<<thick/x<<endl;
8183
8184 }
8185 cout<<"============================================================"<<endl;
8186 cout<<"total material quantity="<<material_quantity<<endl;
8187 cout<<"============================================================"<<endl;
8188 }
8189 //*/
8190}
#define X0
double get_density(void) const
double X0(void) const
Extractor.
double Z(void) const

Referenced by complete_track().

◆ sameas()

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

complete the RecMdcKalTrackCol

Definition at line 2822 of file KalFitAlg.cxx.

2823{
2824 // note: for this function,only imain==lead(2) considered
2825 //std::cout<<"BEGINNING THE sameas() function ..."<<std::endl;
2826 trk->setMass(trk->getMass(imain), l_mass);
2827 trk->setLength(trk->getLength(imain), l_mass);
2828 trk->setTof(trk->getTof(imain), l_mass);
2829 trk->setNhits(trk->getNhits(imain), l_mass);
2830
2831 for(int jj = 0; jj<2; jj++) {
2832 trk->setStat(trk->getStat(jj,imain), jj, l_mass);
2833 trk->setChisq(trk->getChisq(jj, l_mass), jj, l_mass);
2834 trk->setNdf(trk->getChisq(jj, l_mass), jj, l_mass);
2835 }
2836 trk->setLHelix(trk->getFHelix(),l_mass);
2837 trk->setLError(trk->getFError(),l_mass);
2838}
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}

Referenced by beginRun().

◆ setBesFromGdml()

void KalFitAlg::setBesFromGdml ( void )

Definition at line 12 of file KalFitReadGdml.cxx.

12 {
13 // --- gas Volumes
14 int nGas=2;
15 TString gasVolumes[3]={"logicalMdc", "logicalWorld", "Cgem_logic"};
16 if(useNCGem_>0) nGas=2;
17
18 // --- inner DC
19 int nIDC=3;
20 TString IDCVolumes[3]={"LogicalMdcInnerFilm1", "logicalMdcSegment2", "LogicalMdcInnerFilm0"};
21 if(useNCGem_>0) nIDC=0;
22
23 // --- CGEM-IT
24 int nCgemVolumes=114;
25 TString CgemVolumes[114]={
26 "Separator_logic_Al2", "Separator_logic_CarFib", "Separator_logic_Al1", // 3
27
28 "Anode_Cu4_logic2", "Anode_Kapton6_logic2", "Anode_Kapton5_logic2", "Anode_Cu3_logic2", "Anode_Epoxy5_logic2", "Anode_Carbonf2_logic2", "Anode_Epoxy4_logic2", "Anode_Honeycomb_logic2",
29 "Anode_Epoxy3_logic2", "Anode_Kapton3_logic2", "Anode_Epoxy2_logic2", "Anode_Kapton2_logic2", "Anode_Epoxy1_logic2", "Anode_Cu2_logic2", "Anode_Kapton1_logic2", "Anode_Cu1_logic2", //16
30 "Gap_I_logic2",
31 "GemFoil_Cu2_logic2foil2", "GemFoil_Kapton_logic2foil2", "GemFoil_Cu1_logic2foil2",
32 "Gap_T2_logic2",
33 "GemFoil_Cu2_logic2foil1", "GemFoil_Kapton_logic2foil1", "GemFoil_Cu1_logic2foil1",
34 "Gap_T1_logic2",
35 "GemFoil_Cu2_logic2foil0", "GemFoil_Kapton_logic2foil0", "GemFoil_Cu1_logic2foil0",
36 "Gap_D_logic2",//13
37 "Cathode_Cu2_logic2", "Cathode_Kapton3_logic2", "Cathode_Epoxy3_logic2", "Cathode_Kapton2_logic2", "Cathode_Epoxy2_logic2", "Cathode_Honeycomb_logic2", "Cathode_Epoxy1_logic2", "Cathode_Carbonf_logic2", "Cathode_Epoxy0_logic2",//9
38
39 "Anode_Kapton5_logic1", "Anode_Cu3_logic1", "Anode_Epoxy5_logic1", "Anode_Rohacell2_logic1", "Anode_Epoxy4_logic1", "Anode_Kapton4_logic1", "Anode_Epoxy3_logic1",
40 "Anode_Rohacell1_logic1", "Anode_Epoxy2_logic1", "Anode_Kapton2_logic1", "Anode_Epoxy1_logic1", "Anode_Cu2_logic1", "Anode_Kapton1_logic1", "Anode_Cu1_logic1",//14
41 "Gap_I_logic1",
42 "GemFoil_Cu2_logic1foil2", "GemFoil_Kapton_logic1foil2", "GemFoil_Cu1_logic1foil2",
43 "Gap_T2_logic1",
44 "GemFoil_Cu2_logic1foil1", "GemFoil_Kapton_logic1foil1", "GemFoil_Cu1_logic1foil1",
45 "Gap_T1_logic1",
46 "GemFoil_Cu2_logic1foil0", "GemFoil_Kapton_logic1foil0", "GemFoil_Cu1_logic1foil0",
47 "Gap_D_logic1",//13
48 "Cathode_Cu2_logic1", "Cathode_Kapton3_logic1", "Cathode_Epoxy4_logic1", "Cathode_Rohacell2_logic1", "Cathode_Epoxy3_logic1", "Cathode_Kapton2_logic1", "Cathode_Epoxy2_logic1", "Cathode_Rohacell1_logic1", "Cathode_Epoxy1_logic1", "Cathode_Kapton1_logic1",//10
49
50 "Anode_Kapton5_logic0", "Anode_Cu3_logic0", "Anode_Epoxy5_logic0", "Anode_Carbonf2_logic0", "Anode_Epoxy4_logic0", "Anode_Honeycomb_logic0", "Anode_Epoxy3_logic0", "Anode_Carbonf1_logic0",
51 "Anode_Epoxy2_logic0", "Anode_Kapton2_logic0", "Anode_Epoxy1_logic0", "Anode_Cu2_logic0", "Anode_Kapton1_logic0", "Anode_Cu1_logic0",//14
52 "Gap_I_logic0",
53 "GemFoil_Cu2_logic0foil2", "GemFoil_Kapton_logic0foil2", "GemFoil_Cu1_logic0foil2",
54 "Gap_T2_logic0",
55 "GemFoil_Cu2_logic0foil1", "GemFoil_Kapton_logic0foil1", "GemFoil_Cu1_logic0foil1",
56 "Gap_T1_logic0",
57 "GemFoil_Cu2_logic0foil0", "GemFoil_Kapton_logic0foil0", "GemFoil_Cu1_logic0foil0",
58 "Gap_D_logic0",//13
59 "Cathode_Cu2_logic0", "Cathode_Kapton3_logic0", "Cathode_Epoxy3_logic0", "Cathode_Kapton2_logic0", "Cathode_Epoxy2_logic0", "Cathode_Honeycomb_logic0", "Cathode_Epoxy1_logic0", "Cathode_Kapton1_logic0", "Cathode_Cu1_logic0"//9
60 };
61 if(useNCGem_==0) nCgemVolumes=0;
62
63 // --- beam pipe
64 int nPipeV=4;
65 TString beamPipeVolumes[4]={"logicalouterBe", "logicaloilLayer", "logicalinnerBe", "logicalgoldLayer"};
66
67 // --- volumes to construct
68 TString volumes[124];
69 int iV=0; int nV=nGas+nIDC+nCgemVolumes+nPipeV;
70 cout<<"KalFitAlg needs to prepare "<<nV<<" volumes"<<endl;
71 for(int i=0; i<nGas; i++, iV++) volumes[iV]=gasVolumes[i];
72 for(int i=0; i<nIDC; i++, iV++) volumes[iV]=IDCVolumes[i];
73 for(int i=0; i<nCgemVolumes; i++, iV++) volumes[iV]=CgemVolumes[i];
74 for(int i=0; i<nPipeV; i++, iV++) volumes[iV]=beamPipeVolumes[i];
75
76 // --- G4 from gdml
77 MdcG4Geo* aMdcG4Geo = new MdcG4Geo();
78 if(useNCGem_>0) CgemG4Geo* aCgemG4Geo = new CgemG4Geo();
79 BesG4Geo* aBesG4Geo = new BesG4Geo();
80
81 // --- fill materials
82 double Z(0.),A(0.),Ionization(0.),Density(0.),Radlen(0.);
83 for(iV=0; iV<nV; iV++)// fill materials
84 {
85 G4LogicalVolume* logicVolume = const_cast<G4LogicalVolume*>(GDMLProcessor::GetInstance()->GetLogicalVolume(volumes[iV]));
86 G4Material* material = logicVolume->GetMaterial();
87 Z = 0.;
88 A = 0.;
89 for(int i=0; i<material->GetElementVector()->size(); i++){
90 Z += (material->GetElement(i)->GetZ())*
91 (material->GetFractionVector()[i]);
92 A += (material->GetElement(i)->GetA())*
93 (material->GetFractionVector()[i]);
94 }
95 Ionization = material->GetIonisation()->GetMeanExcitationEnergy();
96 Density = material->GetDensity()/(g/cm3);
97 Radlen = material->GetRadlen();
98 if(iV==0) KalFitTrack::mdcGasRadlen_ = Radlen/10.;
99 KalFitMaterial kalFitMaterial(Z,A/g/mole,Ionization/eV,Density,Radlen/10.);
100 _BesKalmanFitMaterials.push_back(kalFitMaterial);
101 cout<<volumes[iV]<<": Z: "<<Z<<", A: "<<(A/(g/mole))<<", Ionization: "<<(Ionization/eV)<<", Density: "<<Density<<", Radlen: "<<Radlen<<", as material "<<_BesKalmanFitMaterials.size()<<endl;
102 }
103
104 // --- fill cylinders
105 double lastRmin=-100;
106 double radius, Rmax, thick, length , z0;
107 for(iV=nGas; iV<nV; iV++)// fill cylinders
108 {
109 G4LogicalVolume* logicVolume = const_cast<G4LogicalVolume*>(GDMLProcessor::GetInstance()->GetLogicalVolume(volumes[iV]));
110
111 G4Tubs* tub = dynamic_cast<G4Tubs*>(logicVolume->GetSolid());
112 radius = tub->GetInnerRadius()/(cm);
113 Rmax = tub->GetOuterRadius()/(cm);
114 thick = tub->GetOuterRadius()/(cm) - tub->GetInnerRadius()/(cm);
115 length = 2.0*tub->GetZHalfLength()/(cm);
116 z0 = 0.0;
117 if(iV>nGas&&lastRmin!=Rmax) {
118 cout<<" lastRmin!=Rmax from "<<volumes[iV-1]<<" to "<<volumes[iV]<<std::endl;
119 if(lastRmin-Rmax>0.0001) // 1 micon
120 {
121 KalFitCylinder aCylinder(&_BesKalmanFitMaterials[1], Rmax, lastRmin-Rmax, length , z0);
122 _BesKalmanFitWalls.push_back(aCylinder);
123 cout<<" add a cylinder with "<<lastRmin-Rmax<<" cm air"<<endl;
124 }
125 }
126 KalFitCylinder aCylinder(&_BesKalmanFitMaterials[iV], radius, thick, length , z0);
127 _BesKalmanFitWalls.push_back(aCylinder);
128 std::cout<<volumes[iV]<<": "<<"radius outer to inner: "<<radius+thick<<" "<<radius<<", length: "<<length<<std::endl;
129 cout<<" wall "<<_BesKalmanFitWalls.size()<<" Z: "<<_BesKalmanFitMaterials[iV].Z()<<endl;
130 lastRmin=radius;
131 }
132
133}//end of setBesFromGdml
double length
Cylinder is an Element whose shape is a cylinder.
static double mdcGasRadlen_

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

819{
820 int layid = 0;
821
822 /// set dchi2cutf_anal
823 for(layid = 0; layid<2; layid++) {
825 }
828 for(layid = 4; layid<12; layid++) {
830 }
831 for(layid = 12; layid<20; layid++) {
833 }
834 for(layid = 20; layid<43; layid++) {
836 }
837
838
839 /// set dchi2cuts_anal
840 for(layid = 0; layid<2; layid++) {
842 }
843
846 for(layid = 4; layid<12; layid++) {
848 }
849 for(layid = 12; layid<20; layid++) {
851 }
852 for(layid = 20; layid<43; layid++) {
854 }
855
856 /// temporary
857 // for(layid = 0; layid<43; layid++) {
858 // KalFitTrack::dchi2cuts_anal[layid] = 10.0;
859 // }
860
861
862 /// set dchi2cutf_calib
863 for(layid = 0; layid<2; layid++) {
865 }
866
869
870 for(layid = 4; layid<12; layid++) {
872 }
873
874 for(layid = 12; layid<20; layid++) {
876 }
877
878 for(layid = 20; layid<43; layid++) {
880 }
881
882 /// temporary
883 if(usage_<2){
884 for(layid = 0; layid<43; layid++) {
885 KalFitTrack::dchi2cutf_calib[layid] = 10.0;
886 }
887 }
888
889
890 /// set dchi2cuts_calib
891 for(layid = 0; layid<2; layid++) {
893 }
894
897
898 for(layid = 4; layid<12; layid++) {
900 }
901
902 for(layid = 12; layid<20; layid++) {
904 }
905
906 for(layid = 20; layid<43; layid++) {
908 }
909
910 /// temporary
911 if(usage_<2){
912 for(layid = 0; layid<43; layid++) {
913 KalFitTrack::dchi2cuts_calib[layid] = 10.0;
914 }
915 }
916}
static double dchi2cuts_anal[43]
Definition KalFitTrack.h:58
static double dchi2cuts_calib[43]
Definition KalFitTrack.h:60
static double dchi2cutf_calib[43]
Definition KalFitTrack.h:59
static double dchi2cutf_anal[43]
Definition KalFitTrack.h:57

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

2842{
2843 // retrieve Mdc geometry information
2844 IMdcGeomSvc* igeomsvc;
2845 StatusCode sc = Gaudi::svcLocator()->service("MdcGeomSvc", igeomsvc);
2846 if(sc==StatusCode::FAILURE) cout << "GeoSvc failing!!!!!!!SC=" << sc << endl;
2847 MdcGeomSvc* geomsvc = dynamic_cast<MdcGeomSvc*>(igeomsvc);
2848 if(!geomsvc){
2849 std::cout<<"ERROR OCCUR when dynamic_cast in KalFitTrack.cxx !!"<<std::endl;
2850 }
2851
2852 HepPoint3D ip(0,0,0);
2853 if(m_usevtxdb==1){
2854 Hep3Vector xorigin(0,0,0);
2855 IVertexDbSvc* vtxsvc;
2856 Gaudi::svcLocator()->service("VertexDbSvc", vtxsvc);
2857 if(vtxsvc->isVertexValid()){
2858 double* dbv = vtxsvc->PrimaryVertex();
2859 double* vv = vtxsvc->SigmaPrimaryVertex();
2860 xorigin.setX(dbv[0]);
2861 xorigin.setY(dbv[1]);
2862 xorigin.setZ(dbv[2]);
2863 }
2864 ip[0] = xorigin[0];
2865 ip[1] = xorigin[1];
2866 ip[2] = xorigin[2];
2867 }
2868
2869 // Estimation of the path length from ip to 1st cylinder
2870
2871 KalmanFit::Helix work = *(KalmanFit::Helix*)&track;
2872 work.ignoreErrorMatrix();
2873 work.pivot(ip);
2874
2875
2876 double tanl = track.tanl();
2877 double phi_old = work.phi0();
2878 double phi = track.phi0();
2879
2880 if (fabs(phi - phi_old) > M_PI) {
2881 if (phi > phi_old) phi -= 2 * M_PI;
2882 else phi_old -= 2 * M_PI;
2883 }
2884
2885 double path_zero = fabs(track.radius() * (phi_old-phi)* sqrt(1 + tanl * tanl));
2886 // track.addPathSM(path_zero);
2887
2888
2889 HepSymMatrix Eakal(5,0);
2890 track.pivot(ip);
2891 /// be attention to this inital error matrix of smoother,
2892 /// how is track.Ea() in the next sentence when use it?
2893 Eakal = track.Ea()*matrixg_;
2894 track.Ea(Eakal);
2895
2896 // Mdc part :
2897 unsigned int nhit = track.HitsMdc().size();
2898 int layer_prev = -1;
2899
2900 HepVector pos_old(3,0);
2901 double r0kal_prec(0);
2902 int nhits_read(0);
2903 for( unsigned i=0 ; i < nhit; i++ ) {
2904 int ihit = (nhit-1)-i;
2905 KalFitHitMdc& HitMdc = track.HitMdc(ihit);
2906 const KalFitWire& Wire = HitMdc.wire();
2907
2908 int wireid = Wire.geoID();
2909 nhits_read++;
2910
2911 int layer = Wire.layer().layerId();
2912 if (pathl_ && layer != layer_prev) {
2913
2914 if (debug_ == 4) cout<<"in smoother,layerid "<<layer<<" layer_prev "
2915 <<layer_prev <<" pathl_ "<<pathl_<<endl;
2916
2917 // track.PathL(Wire.layer().layerId());
2918 layer_prev = layer;
2919 }
2920
2921 HepPoint3D fwd(Wire.fwd());
2922 HepPoint3D bck(Wire.bck());
2923 Hep3Vector wire = (CLHEP::Hep3Vector)fwd - (CLHEP::Hep3Vector)bck;
2924 KalmanFit::Helix work = *(KalmanFit::Helix*)&track;
2925 work.ignoreErrorMatrix();
2926 work.pivot((fwd + bck) * .5);
2927 HepPoint3D x0kal = (work.x(0).z() - bck.z()) / wire.z() * wire + bck;
2928
2929 if(4 == debug_) std::cout<<" x0kal before sag: "<<x0kal<<std::endl;
2930 if (wsag_ == 4){
2931 Hep3Vector result;
2932 const MdcGeoWire* geowire = geomsvc->Wire(wireid);
2933 double tension = geowire->Tension();
2934
2935 //std::cout<<" tension: "<<tension<<std::endl;
2936 double zinit(x0kal.z()), lzx(Wire.lzx());
2937
2938 // double A(Wire.Acoef());
2939 double A = 47.35E-6/tension;
2940 double Zp = (zinit - bck.z())*lzx/wire.z();
2941
2942 if(4 == debug_){
2943 std::cout<<" sag in smoother_anal: "<<std::endl;
2944 std::cout<<" x0kal.x(): "<<std::setprecision(10)<<x0kal.x()<<std::endl;
2945 std::cout<<" wire.x()*(zinit-bck.z())/wire.z(): "<<std::setprecision(10)
2946 <<(wire.x()*(zinit-bck.z())/wire.z())<<std::endl;
2947 std::cout<<"bck.x(): "<<std::setprecision(10)<<bck.x()<<std::endl;
2948 std::cout<<" wire.x()*(zinit-bck.z())/wire.z() + bck.x(): "<<std::setprecision(10)
2949 <<(wire.x()*(zinit-bck.z())/wire.z() + bck.x())<<std::endl;
2950 }
2951
2952 result.setX(wire.x()*(zinit-bck.z())/wire.z() + bck.x());
2953 result.setY((A*(Zp-lzx)+wire.y()/lzx)*Zp+bck.y());
2954 result.setZ((A*(2*Zp-lzx)*lzx+wire.y())/wire.z());
2955
2956 wire.setX(wire.x()/wire.z());
2957 wire.setY(result.z());
2958 wire.setZ(1);
2959
2960 x0kal.setX(result.x());
2961 x0kal.setY(result.y());
2962 }
2963
2964 if(4 == debug_) std::cout<<" x0kal after sag: "<<x0kal<<std::endl;
2965
2966 // If x0kal is after the inner wall and x0kal_prec before :
2967 double r0kal = x0kal.perp();
2968 if (debug_ == 4) {
2969 cout<<"wire direction "<<wire<<endl;
2970 cout<<"x0kal "<<x0kal<<endl;
2971 cout<<"smoother::r0kal "<<r0kal<<" r0kal_prec "<<r0kal_prec <<endl;
2972 }
2973
2974 // change PIVOT :
2975 /*cout<<endl<<"before change pivot: "<<endl;//wangll
2976 cout<<"track.pivot = "<<track.pivot()<<endl;//wangll
2977 cout<<"track.helix = "<<track.a()<<endl;//wangll
2978 */
2979 double pathl(0);
2980 track.pivot_numf(x0kal, pathl);
2981 track.addPathSM(pathl);
2982 /*cout<<endl<<"after change pivot: "<<endl;//wangll
2983 cout<<"track.pivot = "<<track.pivot()<<endl;//wangll
2984 cout<<"track.helix = "<<track.a()<<endl;//wangll
2985 */
2986
2987 // calculate the tof time in this layer
2988 double pmag( sqrt( 1.0 + track.a()[4]*track.a()[4]) / track.a()[2]);
2989 double mass_over_p( track.mass()/ pmag );
2990 double beta( 1.0 / sqrt( 1.0 + mass_over_p * mass_over_p ) );
2991 double tofest = pathl / ( 29.9792458 * beta );
2992 track.addTofSM(tofest);
2993
2994 // std::cout<<" in layer: "<<layer<<" pathl: "<<pathl<<" tof: "<<tofest<<std::endl;
2995
2996 if(KalFitElement::muls()) track.msgasmdc(pathl, way);
2997 /*cout<<endl<<"after muls: "<<endl;//wangll
2998 cout<<"track.pivot = "<<track.pivot()<<endl;//wangll
2999 cout<<"track.helix = "<<track.a()<<endl;//wangll
3000 */
3001 if(!(way<0&&fabs(track.kappa())>1000.0)) {
3002 if(KalFitElement::loss()) track.eloss(pathl, _BesKalmanFitMaterials[0], way);
3003 }
3004
3005
3006 // Add info hit wire :
3007 /*cout<<endl<<"after eloss: "<<endl;//wangll
3008 cout<<"track.pivot = "<<track.pivot()<<endl;//wangll
3009 cout<<"track.helix = "<<track.a()<<endl;//wangll
3010 */
3011 if(fabs(track.kappa())>0&&fabs(track.kappa())<1000.0&&fabs(track.tanl())<7.02) {
3012 HepVector Va(5,0);
3013 HepSymMatrix Ma(5,0);
3014 KalFitHelixSeg HelixSeg(&HitMdc,x0kal,Va,Ma);
3015
3016 Hep3Vector meas = track.momentum(0).cross(wire).unit();
3017 double dchi2=-1;
3018 track.smoother_Mdc(HitMdc, meas, HelixSeg, dchi2, m_csmflag);
3019 if(dchi2>0.0) {
3020 track.HelixSegs().push_back(HelixSeg);
3021 }
3022 }
3023
3024 /// oh, to be the last hit
3025
3026 if(i == nhit-1){
3027
3028 /// calculate the lsat point in MDC
3029 HepPoint3D point;
3030 point.setX(x0kal.x() + track.a()[0]*cos(track.a()[1]));
3031 point.setY(x0kal.y() + track.a()[0]*sin(track.a()[1]));
3032 point.setZ(x0kal.z() + track.a()[3]);
3033 track.point_last(point);
3034
3035 /// calculate fiTerm
3036 double phi_old = track.a()[1];
3037 KalFitTrack temp(x0kal, track.a(), track.Ea(), 0, 0, 0);
3038 temp.pivot(ip);
3039 double phi_new = temp.a()[1];
3040 double fi = phi_new - phi_old;
3041 /// for protection purpose
3042 //if(fabs(fi) >= CLHEP::twopi) fi = fmod(fi+2*CLHEP::twopi,CLHEP::twopi);
3043
3044 if(fabs(fi) >= CLHEP::twopi) fi = fmod(fi+2*CLHEP::twopi,CLHEP::twopi);
3045
3046 track.fiTerm(fi);
3047 }
3048
3049 if (debug_==4) cout<<"track----7-----"<<track.a()<<endl;
3050 r0kal_prec = r0kal;
3051 }
3052}
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 3056 of file KalFitAlg.cxx.

3057{
3058
3059 // retrieve Mdc geometry information
3060 IMdcGeomSvc* igeomsvc;
3061 StatusCode sc = Gaudi::svcLocator()->service("MdcGeomSvc", igeomsvc);
3062 if(sc==StatusCode::FAILURE) cout << "GeoSvc failing!!!!!!!SC=" << sc << endl;
3063 MdcGeomSvc* geomsvc = dynamic_cast<MdcGeomSvc*>(igeomsvc);
3064 if(!geomsvc){
3065 std::cout<<"ERROR OCCUR when dynamic_cast in KalFitTrack.cxx !!"<<std::endl;
3066 }
3067
3068 HepSymMatrix Eakal(5,0);
3069 // Estimation of the path length from ip to 1st cylinder
3070 HepPoint3D ip(0,0,0);
3071 track.pivot(ip);
3072 Eakal = track.getInitMatrix();
3073 if( debug_ == 4) {
3074 std::cout<<"the initial error matrix in smoothing is "<<Eakal<<std::endl;
3075 }
3076 track.Ea(Eakal);
3077
3078 // Mdc part :
3079 unsigned int nseg = track.HelixSegs().size();
3080 int layer_prev = -1;
3081
3082 HepVector pos_old(3,0);
3083 double r0kal_prec(0);
3084 int nsegs_read(0);
3085 for( unsigned i=0 ; i < nseg; i++ ) {
3086
3087 int flag=0;
3088 int iseg = (nseg-1)-i;
3089 KalFitHelixSeg& HelixSeg = track.HelixSeg(iseg);
3090 const KalFitWire& Wire = HelixSeg.HitMdc()->wire();
3091
3092 int wireid = Wire.geoID();
3093 nsegs_read++;
3094
3095 int layer = Wire.layer().layerId();
3096 if (pathl_ && layer != layer_prev) {
3097
3098 if (debug_ == 4) cout<<"in smoother,layerid "<<layer<<" layer_prev "
3099 <<layer_prev <<" pathl_ "<<pathl_<<endl;
3100
3101 // track.PathL(Wire.layer().layerId());
3102 layer_prev = layer;
3103 }
3104
3105 HepPoint3D fwd(Wire.fwd());
3106 HepPoint3D bck(Wire.bck());
3107 Hep3Vector wire = (CLHEP::Hep3Vector)fwd -(CLHEP::Hep3Vector)bck;
3108 KalmanFit::Helix work = *(KalmanFit::Helix*)&track;
3109 work.ignoreErrorMatrix();
3110 work.pivot((fwd + bck) * .5);
3111 HepPoint3D x0kal = (work.x(0).z() - bck.z()) / wire.z() * wire + bck;
3112
3113
3114 if(4 == debug_) std::cout<<" x0kal before sag: "<<x0kal<<std::endl;
3115
3116 if (wsag_ == 4){
3117
3118 Hep3Vector result;
3119 const MdcGeoWire* geowire = geomsvc->Wire(wireid);
3120 double tension = geowire->Tension();
3121
3122 //std::cout<<" tension: "<<tension<<std::endl;
3123 double zinit(x0kal.z()), lzx(Wire.lzx());
3124
3125 // double A(Wire.Acoef());
3126
3127 double A = 47.35E-6/tension;
3128 double Zp = (zinit - bck.z())*lzx/wire.z();
3129
3130 if(4 == debug_){
3131
3132 std::cout<<" sag in smoother_calib: "<<std::endl;
3133 std::cout<<" x0kal.x(): "<<std::setprecision(10)<<x0kal.x()<<std::endl;
3134 std::cout<<" wire.x()*(zinit-bck.z())/wire.z(): "<<std::setprecision(10)
3135 <<(wire.x()*(zinit-bck.z())/wire.z())<<std::endl;
3136 std::cout<<"bck.x(): "<<std::setprecision(10)<<bck.x()<<std::endl;
3137 std::cout<<" wire.x()*(zinit-bck.z())/wire.z() + bck.x(): "<<std::setprecision(10)
3138 <<(wire.x()*(zinit-bck.z())/wire.z() + bck.x())<<std::endl;
3139 }
3140
3141 result.setX(wire.x()*(zinit-bck.z())/wire.z() + bck.x());
3142 result.setY((A*(Zp-lzx)+wire.y()/lzx)*Zp+bck.y());
3143 result.setZ((A*(2*Zp-lzx)*lzx+wire.y())/wire.z());
3144
3145 wire.setX(wire.x()/wire.z());
3146 wire.setY(result.z());
3147 wire.setZ(1);
3148
3149 x0kal.setX(result.x());
3150 x0kal.setY(result.y());
3151 }
3152
3153 if(4 == debug_) std::cout<<" x0kal after sag: "<<x0kal<<std::endl;
3154
3155
3156 // If x0kal is after the inner wall and x0kal_prec before :
3157 double r0kal = x0kal.perp();
3158 if (debug_ == 4) {
3159 cout<<"wire direction "<<wire<<endl;
3160 cout<<"x0kal "<<x0kal<<endl;
3161 cout<<"smoother::r0kal "<<r0kal<<" r0kal_prec "<<r0kal_prec <<endl;
3162 }
3163
3164 // change PIVOT :
3165 double pathl(0);
3166 track.pivot_numf(x0kal, pathl);
3167
3168 if (debug_ == 4) cout<<"track----6-----"<<track.a()<<" ...path..."<<pathl
3169 <<"momentum"<<track.momentum(0)<<endl;
3170 if(KalFitElement::muls()) track.msgasmdc(pathl, way);
3171 if(KalFitElement::loss()) track.eloss(pathl, _BesKalmanFitMaterials[0], way);
3172
3173 // Add info hit wire :
3174 if(fabs(track.kappa())>0&&fabs(track.kappa())<1000.0&&fabs(track.tanl())<7.02) {
3175 // attention to this measure value ,what is the measurement value !!
3176 Hep3Vector meas = track.momentum(0).cross(wire).unit();
3177
3178 if(usage_>1) track.smoother_Mdc_csmalign(HelixSeg, meas,flag, m_csmflag);
3179 else track.smoother_Mdc(HelixSeg, meas,flag, m_csmflag);
3180 // cout<<"layer, cell, track.a: "<<Wire.layer().layerId()<<" , "<<Wire.localId()<<" , "<<track.a()<<endl;
3181 }
3182
3183 if (debug_==4) cout<<"track----7-----"<<track.a()<<endl;
3184 r0kal_prec = r0kal;
3185 // can this kind of operation be right??
3186 if(flag == 0) {
3187 track.HelixSegs().erase(track.HelixSegs().begin()+iseg);
3188 }
3189 }
3190}
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 6652 of file KalFitAlg.cxx.

6653{
6654 if (debug_ == 4)
6655 cout << "start_seed begin... " << std::endl;
6656 // keep initial helix parameters
6657 Hep3Vector x_init(track.pivot());
6658 HepSymMatrix Ea_init(5,0);
6659 Ea_init = track.Ea();
6660 HepVector a_init(5);
6661 a_init = track.a();
6662
6663 // LR assumption :
6664 unsigned int nhit_included(10);
6665 int LR[8][3] = {
6666 {1,1,1},
6667 {1,1,-1},
6668 {1,-1,1},
6669 {1,-1,-1},
6670 {-1,1,1},
6671 {-1,1,-1},
6672 {-1,-1,1},
6673 {-1,-1,-1}
6674 };
6675
6676 unsigned int nhit = track.HitsMdc().size();
6677 double chi2_min(DBL_MAX);
6678 int i_min(-1);
6679 for (int ktrial = 0; ktrial < 8; ktrial++) {
6680
6681 // Come back to trasan seed :
6682 track.pivot(x_init);
6683 track.a(a_init);
6684 track.Ea(Ea_init);
6685
6686 track.chiSq(0);
6687 track.chiSq_back(0);
6688 track.nchits(0);
6689 track.nster(0);
6690 track.ndf_back(0);
6691
6692 HepSymMatrix Eakal(5,0);
6693
6694 init_matrix(choice_,TrasanTRK, Eakal);
6695 // initialize the Mdc hits :
6696 for( unsigned i=0 ; i < nhit; i++ ){
6697 KalFitHitMdc& HitMdc = track.HitMdc(i);
6698 int lr_decision(0);
6699 if (i<3) lr_decision = LR[ktrial][i];
6700 HitMdc.LR(lr_decision);
6701 if (i<nhit_included)
6702 HitMdc.chi2(0);
6703 else
6704 HitMdc.chi2(-1);
6705 }
6706 // Mdc fit the ... first hits :
6707
6708 if(usage_==0) filter_fwd_anal(track, lead_, way, Eakal);
6709 way=999;
6710 if(usage_>0) filter_fwd_calib(track, lead_, way, Eakal);
6711
6712 // Check the chi2
6713 if (debug_ == 4)
6714 cout << "---- Result for " << ktrial << " case : chi2 = " << track.chiSq()
6715 << ", nhits included = " << track.nchits() << " for nhits available = "
6716 << nhit << std::endl;
6717
6718 if (track.chiSq() < chi2_min &&
6719 (track.nchits() == nhit_included || track.nchits() == nhit)){
6720 chi2_min = track.chiSq();
6721 i_min = ktrial;
6722 }
6723 }
6724
6725 // Initialize to the best solution :
6726 if (debug_ == 4)
6727 cout << "*** i_min = " << i_min << " with a chi2 = " << chi2_min << std::endl;
6728
6729 for( unsigned i=0 ; i < nhit; i++ ){
6730 KalFitHitMdc& HitMdc = track.HitMdc(i);
6731 int lr_decision(0);
6732 if (i_min >= 0 && i < 3)
6733 lr_decision = LR[i_min][i];
6734 HitMdc.LR(lr_decision);
6735 HitMdc.chi2(0);
6736 HitMdc.chi2_back(0);
6737 }
6738 track.pivot(x_init);
6739 track.a(a_init);
6740 track.Ea(Ea_init);
6741 track.chiSq(0);
6742 track.chiSq_back(0);
6743 track.nchits(0);
6744 track.nster(0);
6745 track.ndf_back(0);
6746
6747 // For debugging purpose :
6748 if (debug_ == 4) {
6749 for( unsigned i=0 ; i < 3; i++ ){
6750 KalFitHitMdc& HitMdc = track.HitMdc(i);
6751 cout << " LR(" << i << ") = " << HitMdc.LR()
6752 << ", stereo = " << HitMdc.wire().stereo()
6753 << ", layer = " << HitMdc.wire().layer().layerId() << std::endl;
6754 }
6755 }
6756}
double chi2_back(void) const
KalFitHitMdc & HitMdc(int i)

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

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

◆ back_

int KalFitAlg::back_

flag to perform smoothing

Definition at line 189 of file KalFitAlg.h.

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

◆ choice_

◆ cylfile_

string KalFitAlg::cylfile_

Definition at line 231 of file KalFitAlg.h.

Referenced by KalFitAlg().

◆ dchi2cut_inner_

double KalFitAlg::dchi2cut_inner_

Definition at line 235 of file KalFitAlg.h.

Referenced by KalFitAlg(), and setDchisqCut().

◆ dchi2cut_layid2_

double KalFitAlg::dchi2cut_layid2_

Definition at line 235 of file KalFitAlg.h.

Referenced by KalFitAlg(), and setDchisqCut().

◆ dchi2cut_layid3_

double KalFitAlg::dchi2cut_layid3_

Definition at line 235 of file KalFitAlg.h.

Referenced by KalFitAlg(), and setDchisqCut().

◆ dchi2cut_mid1_

double KalFitAlg::dchi2cut_mid1_

Definition at line 235 of file KalFitAlg.h.

Referenced by KalFitAlg(), and setDchisqCut().

◆ dchi2cut_mid2_

double KalFitAlg::dchi2cut_mid2_

Definition at line 235 of file KalFitAlg.h.

Referenced by KalFitAlg(), and setDchisqCut().

◆ dchi2cut_outer_

double KalFitAlg::dchi2cut_outer_

Definition at line 235 of file KalFitAlg.h.

Referenced by KalFitAlg(), and setDchisqCut().

◆ dchi2cutf_

double KalFitAlg::dchi2cutf_

Definition at line 233 of file KalFitAlg.h.

Referenced by initialize(), and KalFitAlg().

◆ dchi2cuts_

double KalFitAlg::dchi2cuts_

Definition at line 233 of file KalFitAlg.h.

Referenced by initialize(), and KalFitAlg().

◆ debug_

◆ debug_kft_

int KalFitAlg::debug_kft_

Definition at line 227 of file KalFitAlg.h.

Referenced by initialize(), and KalFitAlg().

◆ drifttime_choice_

int KalFitAlg::drifttime_choice_

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

Referenced by complete_track(), and complete_track().

◆ eventno

int KalFitAlg::eventno

Definition at line 191 of file KalFitAlg.h.

Referenced by execute().

◆ fac_h1_

double KalFitAlg::fac_h1_

Definition at line 210 of file KalFitAlg.h.

Referenced by complete_track(), and complete_track().

◆ fac_h2_

double KalFitAlg::fac_h2_

Definition at line 210 of file KalFitAlg.h.

Referenced by complete_track(), and complete_track().

◆ fac_h3_

double KalFitAlg::fac_h3_

Definition at line 210 of file KalFitAlg.h.

Referenced by complete_track(), and complete_track().

◆ fac_h4_

double KalFitAlg::fac_h4_

Definition at line 210 of file KalFitAlg.h.

Referenced by complete_track(), and complete_track().

◆ fac_h5_

double KalFitAlg::fac_h5_

Definition at line 210 of file KalFitAlg.h.

Referenced by complete_track(), and complete_track().

◆ fitnocut_

int KalFitAlg::fitnocut_

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

Referenced by initialize(), and KalFitAlg().

◆ gain1_

double KalFitAlg::gain1_

Definition at line 212 of file KalFitAlg.h.

Referenced by init_matrix(), and KalFitAlg().

◆ gain2_

double KalFitAlg::gain2_

Definition at line 212 of file KalFitAlg.h.

Referenced by init_matrix(), and KalFitAlg().

◆ gain3_

double KalFitAlg::gain3_

Definition at line 212 of file KalFitAlg.h.

Referenced by init_matrix(), and KalFitAlg().

◆ gain4_

double KalFitAlg::gain4_

Definition at line 212 of file KalFitAlg.h.

Referenced by init_matrix(), and KalFitAlg().

◆ gain5_

double KalFitAlg::gain5_

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

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

◆ i_front_

int KalFitAlg::i_front_

Definition at line 225 of file KalFitAlg.h.

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

◆ inner_steps_

int KalFitAlg::inner_steps_

Definition at line 216 of file KalFitAlg.h.

Referenced by initialize(), and KalFitAlg().

◆ iqual_back_

int KalFitAlg::iqual_back_

Definition at line 241 of file KalFitAlg.h.

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

◆ iqual_front_

int KalFitAlg::iqual_front_[5]

◆ lead_

◆ loss_

int KalFitAlg::loss_

Definition at line 207 of file KalFitAlg.h.

Referenced by fitGemHits(), fromFHitToInnerWall(), initialize(), and KalFitAlg().

◆ lr_

int KalFitAlg::lr_

Definition at line 207 of file KalFitAlg.h.

Referenced by initialize(), and KalFitAlg().

◆ m_alpha

double KalFitAlg::m_alpha

Definition at line 249 of file KalFitAlg.h.

Referenced by fitGemHits().

◆ m_csmflag

int KalFitAlg::m_csmflag

◆ m_dangcut

double KalFitAlg::m_dangcut

Definition at line 248 of file KalFitAlg.h.

Referenced by execute(), and KalFitAlg().

◆ m_dphicut

double KalFitAlg::m_dphicut

Definition at line 248 of file KalFitAlg.h.

Referenced by execute(), and KalFitAlg().

◆ m_usevtxdb

int KalFitAlg::m_usevtxdb

Definition at line 246 of file KalFitAlg.h.

Referenced by KalFitAlg(), and smoother_anal().

◆ matfile_

string KalFitAlg::matfile_

Definition at line 231 of file KalFitAlg.h.

Referenced by KalFitAlg().

◆ matrixg_

◆ mhyp_

int KalFitAlg::mhyp_

Definition at line 199 of file KalFitAlg.h.

Referenced by complete_track(), 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 207 of file KalFitAlg.h.

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

◆ myEventNo

int KalFitAlg::myEventNo

Definition at line 245 of file KalFitAlg.h.

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

◆ ntuple_

◆ numf_

int KalFitAlg::numf_

Definition at line 215 of file KalFitAlg.h.

Referenced by initialize(), and KalFitAlg().

◆ numf_in_

int KalFitAlg::numf_in_

Definition at line 218 of file KalFitAlg.h.

◆ numf_out_

int KalFitAlg::numf_out_

Definition at line 219 of file KalFitAlg.h.

◆ numfcor_

int KalFitAlg::numfcor_

Definition at line 214 of file KalFitAlg.h.

Referenced by initialize(), and KalFitAlg().

◆ outer_steps_

int KalFitAlg::outer_steps_

Definition at line 217 of file KalFitAlg.h.

Referenced by initialize(), and KalFitAlg().

◆ pathl_

int KalFitAlg::pathl_

◆ pe_cut_

double KalFitAlg::pe_cut_

value of the momentum cut to decide refit

Definition at line 201 of file KalFitAlg.h.

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

◆ pk_cut_

double KalFitAlg::pk_cut_

Definition at line 201 of file KalFitAlg.h.

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

◆ pmu_cut_

double KalFitAlg::pmu_cut_

Definition at line 201 of file KalFitAlg.h.

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

◆ pp_cut_

double KalFitAlg::pp_cut_

Definition at line 201 of file KalFitAlg.h.

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

◆ ppi_cut_

double KalFitAlg::ppi_cut_

Definition at line 201 of file KalFitAlg.h.

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

◆ pT_

double KalFitAlg::pT_

value of the pT cut for backward filter

Definition at line 195 of file KalFitAlg.h.

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

◆ pt_cut_

◆ resolution_

int KalFitAlg::resolution_

Definition at line 240 of file KalFitAlg.h.

Referenced by initialize(), and KalFitAlg().

◆ steplev_

int KalFitAlg::steplev_

Definition at line 213 of file KalFitAlg.h.

Referenced by initialize(), and KalFitAlg().

◆ Tds_back_no

int KalFitAlg::Tds_back_no

Definition at line 193 of file KalFitAlg.h.

◆ theta_cut_

◆ tof_hyp_

int KalFitAlg::tof_hyp_

Definition at line 207 of file KalFitAlg.h.

Referenced by initialize(), and KalFitAlg().

◆ tofflag_

int KalFitAlg::tofflag_

Definition at line 207 of file KalFitAlg.h.

Referenced by initialize(), and KalFitAlg().

◆ tprop_

int KalFitAlg::tprop_

propagation correction

Definition at line 244 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 181 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 187 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: