////////////////////////////////////////////////////////////////////////// // // // PndVtxFitter // // // // Author: D. Mishra, GSI, 2008 // // // ////////////////////////////////////////////////////////////////////////// #include #include "RhoFitter/PndVtxFitter.h" #include "RhoBase/TCandListIterator.h" #include "RhoFitter/VtxFitterParticle.h" #include "RhoFitter/VtxFitter_Init.h" #include "RhoFitter/VtxFitterError.h" #include "RhoBase/TFactory.h" using namespace std; ClassImp(PndVtxFitter) TBuffer &operator>>(TBuffer &buf, PndVtxFitter *&obj) { obj = (PndVtxFitter *) buf.ReadObject(PndVtxFitter::Class()); return buf; } PndVtxFitter::PndVtxFitter( const TCandidate& b ) : VAbsFitter( b ) { // fHeadOfTree=TFactory::Instance()->NewCandidate(b); m_mode=0; m_vertexChisq=0.; m_vertex_b=TVector3(0.,0.,0.); m_errVertex_a=3; m_errBeam=3; m_beam=0; m_knownVertex=0; m_tube=0; m_itrk_tube=-1; m_magField=KF_MAGNETIC_FIELD; //m_eachChisq = new Double_t[KF_MAX_TRACK_NUMBER2]; m_necessaryTrackNum = 2; } PndVtxFitter::~PndVtxFitter() { //if(fHeadOfTree) delete fHeadOfTree; } void PndVtxFitter::Fit() { TCandidate theHead=*fHeadOfTree; TCandListIterator iter=theHead.DaughterIterator(); //cout <<"Fit: head of Tree:"<Cov7(); //cout <<"PndVtxFitter: Daughter "<SetP4(0.4,TVector3(0.2,0.3,0.4)); DoVertexFitWOCorr(); } /** No Correlations between the tracks. ==>Section 4.2 of Belle Note #194: "Vertex Constraint to an Unknown position". This is same as "_fit2()" function in "kvertexfitter" ***/ unsigned PndVtxFitter::DoVertexFitWOCorr() { m_trackNum = fDaughters.GetLength(); cout<<"PndVtxFitter::DoVertexFitWOCorr: "< chiSq) { for(Int_t k=0;k chiSq){ for(Int_t k=0;kSection C.5 of Belle Note #194: "Fitting with constraints for Unknown parameters". Vertex Refitter in the point with Errors. This is same as "_fit3()" function in "kvertexfitter". **/ unsigned PndVtxFitter::DoVertexFitBeamConstraint() { m_trackNum = fDaughters.GetLength(); // if(m_errorFlag != KF_NO_ERROR)return m_errorFlag; if(m_trackNum < m_necessaryTrackNum-1) { m_errorFlag = KF_TRACK_SIZE; return m_errorFlag; } SetInputMatrix(); //Set input matrix CalDgf(); //calculate Dgf /** Fit function _fit3() Starts **/ cout<<"++++++ Fit function _fit3() Starts +++++++ "< chiSq || (tmp_chiSq <= chiSq && itFlag == 0)) { if(tmp_chiSq <= chiSq)itFlag = 1; for(unsigned k=0;kGetEntriesFast(); cout<<"+++++++++++++ Retriving NTRA+++++++++ "<At(i); Double_t px = it->GetMomentum().Px(); Double_t py = it->GetMomentum().Py(); Double_t pz = it->GetMomentum().Pz(); cout<<"px = "<GetCharge()<GetCalDgf()<GetErrVertex(); cout<GetEntriesFast(); cout<<"+++++++++++++ Retriving NTRA From TCand+++++++++ "<At(i); Double_t px = tcand->GetMomentum().Px(); Double_t py = tcand->GetMomentum().Py(); Double_t pz = tcand->GetMomentum().Pz(); // cout<<"px = "<GetCharge()<GetCalDgf()<GetErrVertex(); // cout< KF_MAX_TRACK_NUMBER2){ m_errorFlag = KF_INPUT_TRACK_SIZE; return m_errorFlag; } }else{ if(m_trackNum > KF_MAX_TRACK_NUMBER){ m_errorFlag = KF_INPUT_TRACK_SIZE; return m_errorFlag; } } unsigned index(0); TMatrixD tmp_al_0(KF_NUM6*m_trackNum,1); TMatrixDSym tmp_V_al_0(KF_NUM6*m_trackNum); TMatrixD tmp_property(m_trackNum,3); TMatrixDSym tmp_ErrCov(KF_NUM6); // m_trackNum = fArr->GetEntriesFast(); it =new VtxFitterParticle; for(Int_t i=0;iGetCovMat(mat7); //cout <<"after resetting"<SetFitParameter(j); //Get px,py,pz,x,y,z tmp_V_al_0.SetSub(index*KF_NUM6, tmp_ErrCov); //Dipak tmp_property[index][0] = tc.GetCharge()/3; // tmp_property[index][1] = 0.139; //Dummy value:Dipak tmp_property[index][1] = tc.P4().M();//get the mass:Dummy value set by hand :Dipak tmp_property[index][2] = -KF_PHOTON_VELOCITY*m_magField*tc.GetCharge()/3; ++index; } delete it; /* for(Int_t i=0;iGetEntriesFast();i++) { it = (VtxFitterParticle*)fArr->At(i); for(unsigned j=0;jSetFitParameter(j); //Get px,py,pz,x,y,z //Convert 7x7 (px,py,pz,E,x,y,z) cov matrices to 6x6 (px,py,pz,x,y,z) tmp_ErrCov = it->GetFitError(it->GetErrorCovMatrix()); // tmp_V_al_0.SetSub(index*KF_NUM6, it->GetErrorCovMatrix()); //Dipak tmp_V_al_0.SetSub(index*KF_NUM6, tmp_ErrCov); //Dipak tmp_property[index][0] = it->GetCharge(); // tmp_property[index][1] = 0.139; //Dummy value:Dipak tmp_property[index][1] = it->GetMomentum().M();//get the mass:Dummy value set by hand :Dipak tmp_property[index][2] = -KF_PHOTON_VELOCITY*m_magField*it->GetCharge(); ++index; } */ cout<<" Total number of Tracks 'PndVtxFitter' SetInputMatrix ***######### "< 6x6 matrix //m_setCorrelation function has been defined in kfitterbase.cc if(m_knownVertex == 0 && m_beam == 0 && m_mode != KF_MODE_WO_CORRELATION){ if(m_correlationFlag == 1){ m_errorFlag = m_setCorrelation(); if(m_errorFlag != KF_NO_ERROR)return m_errorFlag; } } ******/ m_v_a[0][0] = m_vertex_b.X(); m_v_a[1][0] = m_vertex_b.Y(); m_v_a[2][0] = m_vertex_b.Z(); m_al_0 = tmp_al_0; m_al_1 = m_al_0; m_property = tmp_property; m_D = m_V_al_1.GetSub(0,m_trackNum*2-1,0,KF_NUM6*m_trackNum-1); m_E = m_V_al_1.GetSub(0,m_trackNum*2-1,0,2); m_d = m_V_al_1.GetSub(0,m_trackNum*2-1,0,0); m_V_D = m_V_al_1.GetSub(0,m_trackNum*2-1,0,m_trackNum*2-1); m_lam = m_V_al_1.GetSub(0,m_trackNum*2-1,0,0); m_lam0 = m_V_al_1.GetSub(0,m_trackNum*2-1,0,0); m_V_Dt = m_V_al_1.GetSub(0,m_trackNum*2-1,0,m_trackNum*2-1); m_Cov_v_al_1 = m_V_al_1.GetSub(0,2,0,KF_NUM6*m_trackNum-1); return m_errorFlag; } unsigned PndVtxFitter::MakeCoreMatrix() { Double_t px,py,pz,x,y,z,a; Double_t pt,invPt,invPt2,dlx,dly,dlz,a1,a2,r2d2,B,Rx,Ry,S,U; Double_t sininv,sqrtag; for(unsigned i=0;i 1.){ m_errorFlag = KF_ARCSIN; return m_errorFlag; } //sin^(-1)(B) sininv = TMath::ASin(B); Double_t tmp0 = 1.0-B*B; if(tmp0 == 0.){ m_errorFlag = KF_DIV_ZERO; return m_errorFlag; } //1/sqrt(1-B^2) sqrtag = 1.0/sqrt(tmp0); S = sqrtag*invPt2; U = dlz-pz*sininv/a; }else{ // neutral B = 0.0; sininv = 0.0; sqrtag = 1.0; S = invPt2; U = dlz-pz*a2*invPt2; } //d: Matrix m_d[i*2+0][0] = a1-0.5*a*r2d2; m_d[i*2+1][0] = U*pt; //D: Matrix m_D[i*2+0][i*KF_NUM6+0] = dly; m_D[i*2+0][i*KF_NUM6+1] = -dlx; m_D[i*2+0][i*KF_NUM6+2] = 0.0; m_D[i*2+0][i*KF_NUM6+3] = py+a*dlx; m_D[i*2+0][i*KF_NUM6+4] = -px+a*dly; m_D[i*2+0][i*KF_NUM6+5] = 0.0; m_D[i*2+1][i*KF_NUM6+0] = -pz*pt*S*Rx+U*px*invPt; m_D[i*2+1][i*KF_NUM6+1] = -pz*pt*S*Ry+U*py*invPt; if(a != 0.){ m_D[i*2+1][i*KF_NUM6+2] = -sininv*pt/a; }else{ m_D[i*2+1][i*KF_NUM6+2] = -a2*invPt; } m_D[i*2+1][i*KF_NUM6+3] = px*pz*pt*S; m_D[i*2+1][i*KF_NUM6+4] = py*pz*pt*S; m_D[i*2+1][i*KF_NUM6+5] = -pt; //E: Matrix m_E[i*2+0][0] = -py-a*dlx; m_E[i*2+0][1] = px-a*dly; m_E[i*2+0][2] = 0.0; m_E[i*2+1][0] = -px*pz*pt*S; m_E[i*2+1][1] = -py*pz*pt*S; m_E[i*2+1][2] = pt; } // for loop 'i' return m_errorFlag; } //Set output to VtxFitterParticle class unsigned PndVtxFitter::SetOutputMatrix() { cout<GetEntriesFast();i++){ it = (VtxFitterParticle*)fArr->At(i); //track momentum h3m.SetX(m_al_1[index1*KF_NUM6+0][0]); h3m.SetY(m_al_1[index1*KF_NUM6+1][0]); h3m.SetZ(m_al_1[index1*KF_NUM6+2][0]); it->SetMomentum(TLorentzVector(h3m, sqrt(h3m.Mag2()+0.139*0.139)));//filling the momentum it->SetPosition(TVector3(m_al_1[index1*KF_NUM6+3][0],m_al_1[index1*KF_NUM6+4][0],m_al_1[index1*KF_NUM6+5][0]));//filling positions //convert the 6x6 cov matrices ==> 7x7 trCov = it->GetFitError(it->GetMomentum(), m_V_al_1.GetSub(index1*KF_NUM6, (index1+1)*KF_NUM6-1,index1*KF_NUM6,(index1+1)*KF_NUM6-1)); //Convert cov matrices px,py,pz,E,x,y,z ==> x,y,z,px,py,pz,E //because TCandidate uses the above format TMatrixD trCovC = it->GetConverted7(trCov); // m_V_al_1.Print(); index1++; } it->SetVertex(TVector3(m_v_a[0][0],m_v_a[1][0],m_v_a[2][0]));//filling the vertex //Error of the vertex for(unsigned i=0;i<3;++i){ for(unsigned j=i;j<3;++j){ m_errVertex_a[i][j] = m_V_E[i][j]; } } it->SetErrVertex(m_errVertex_a); //filling Error of the Vertex it->SetCalDgf(m_dgf); */ return m_errorFlag; } //Fill output to TCandidate unsigned PndVtxFitter::SetOutputToTCandidate() { cout<<"I'm inside OutputToTCandidate *** "<SetP3(h3m); //filling momentum tcand->SetP4(TLorentzVector(h3m,sqrt(h3m.Mag2()+0.139*0.139)));//filling 4-momentum tcand->SetPosition(TVector3(m_al_1[index1*KF_NUM6+3][0],m_al_1[index1*KF_NUM6+4][0],m_al_1[index1*KF_NUM6+5][0]));//filling position TLorentzVector h4m = tcand->P4(); //convert the 6x6 cov matrices ==> 7x7 trCov = it->GetFitError(tcand->P4(),m_V_al_1.GetSub(index1*KF_NUM6, (index1+1)*KF_NUM6-1, index1*KF_NUM6,(index1+1)*KF_NUM6-1)); //Convert cov matrices px,py,pz,E,x,y,z ==> x,y,z,px,py,pz,E //because TCandidate uses the above format TMatrixD trCovC = it->GetConverted7(trCov); tcand->SetCov7(trCovC); tcand->SetCharge(1);//dummy value */ index1++; } // No function available for storing vertex position and its errors cout <<"sum: "<SetP4(sum); fHeadOfTree->SetPos(TVector3( m_v_a[0][0], m_v_a[1][0],m_v_a[2][0])); cout <<"SetOutputToTCandidate head of Tree:"<<(*fHeadOfTree)<GetEntriesFast()<< endl; TMatrixD trCov(7,7); Int_t index1(0); TClonesArray &cands = *fCandidates; for(Int_t i=0;iGetEntriesFast();i++){ Int_t ncands=cands.GetEntriesFast(); tcand=new (cands[ncands]) TCandidate(); //Filling the TCandidate h3m.SetX(m_al_1[index1*KF_NUM6+0][0]); //px h3m.SetY(m_al_1[index1*KF_NUM6+1][0]); //py h3m.SetZ(m_al_1[index1*KF_NUM6+2][0]); //pz tcand->SetP3(h3m); //filling momentum tcand->SetP4(TLorentzVector(h3m,sqrt(h3m.Mag2()+0.139*0.139)));//filling 4-momentum tcand->SetPosition(TVector3(m_al_1[index1*KF_NUM6+3][0],m_al_1[index1*KF_NUM6+4][0],m_al_1[index1*KF_NUM6+5][0]));//filling position TLorentzVector h4m = tcand->P4(); //convert the 6x6 cov matrices ==> 7x7 trCov = it->GetFitError(tcand->P4(),m_V_al_1.GetSub(index1*KF_NUM6, (index1+1)*KF_NUM6-1, index1*KF_NUM6,(index1+1)*KF_NUM6-1)); //Convert cov matrices px,py,pz,E,x,y,z ==> x,y,z,px,py,pz,E //because TCandidate uses the above format TMatrixD trCovC = it->GetConverted7(trCov); tcand->SetCov7(trCovC); tcand->SetCharge(1);//dummy value index1++; } // No function available for storing vertex position and its errors */ return m_errorFlag; } //void PndVtxFitter::Finish() //{cout<<"I'm Quiting from PndVtxFitter======="<