////////////////////////////////////////////////////////////////////////// // // // PndMassFitter // // // // Author: D. Mishra, GSI, 2008 // // // ////////////////////////////////////////////////////////////////////////// #include #include "RhoFitter/PndMassFitter.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(PndMassFitter) TBuffer &operator>>(TBuffer &buf, PndMassFitter *&obj) { obj = (PndMassFitter *) buf.ReadObject(PndMassFitter::Class()); return buf; } PndMassFitter::PndMassFitter( const TCandidate& b, double mass ) : VAbsFitter( b ) { m_fitIncludingVertex=1; m_atDecayPoint=KF_AT_DECAY_POINT; m_isFixMass=1; m_vertex_b=TVector3(0.,0.,0.); m_necessaryTrackNum = 2; m_invariantMass=mass; m_errorFlag = KF_NO_ERROR; } PndMassFitter::~PndMassFitter() { //if(fHeadOfTree) delete fHeadOfTree; } void PndMassFitter::Fit() { TCandidate theHead=*fHeadOfTree; TCandListIterator iter=theHead.DaughterIterator(); cout <<"Fit: head of Tree:"<Cov7(); cout <<"PndMassFitter: Daughter "<SetP4(0.4,TVector3(0.2,0.3,0.4)); } /** This is same as "fit()" function in "kfitterbase". **/ unsigned PndMassFitter::DoVertexFitMassConstraintWOIncludeVertex() { if(m_errorFlag != KF_NO_ERROR)return m_errorFlag; //cout<<"======SetInputMatrix part Start========== "< KF_MAX_TRACK_NUMBER){ m_errorFlag = KF_INPUT_TRACK_SIZE; return m_errorFlag; }*/ SetInputMatrix(); //Set input matrix CalDgf(); // Calculate Dgf /** Fit function _fit() Starts **/ cout<<"++++++ Fit function _fit() Starts +++++++ "< chiSq){ tmp_chiSq = chiSq; tmp_al_a = tmp_al_1; tmp_al_1 = m_al_1; tmp_V_al_1 = m_V_al_1; if(j == KF_MAX_ITERATION_NUMBER-1){ m_al_a = tmp_al_1; m_overIterationFlag = KF_OVER_ITERATION; }else continue; }else if(j != 0){ chiSq = tmp_chiSq; m_al_1 = tmp_al_1; m_al_a = tmp_al_a; m_V_al_1 = tmp_V_al_1; break; }else if(j == 0){ m_errorFlag = KF_INIT_CHISQ; return m_errorFlag; } } //Iteration Loop ends // cout<<"Final Momenta are "< chiSq){ tmp_chiSq = chiSq; tmp_al_a = tmp_al_1; tmp_al_1 = m_al_1; tmp_V_al_1 = m_V_al_1; if(j == KF_MAX_ITERATION_NUMBER-1){ m_al_a = tmp_al_1; m_overIterationFlag = KF_OVER_ITERATION; }else continue; }else if(j != 0){ chiSq = tmp_chiSq; m_al_1 = tmp_al_1; m_al_a = tmp_al_a; m_V_al_1 = tmp_V_al_1; break; }else if(j == 0){ m_errorFlag = KF_INIT_CHISQ; return m_errorFlag; } } //Iteration Loop ends // cout<<"Final Momenta are "< KF_MAX_TRACK_NUMBER){ m_errorFlag = KF_INPUT_TRACK_SIZE; return m_errorFlag; } if(m_fitIncludingVertex==0){ unsigned index(0); TMatrixDSym tmp_V_al_0(KF_NUM7*m_trackNum); m_al_0.ResizeTo(KF_NUM7*m_trackNum,1); m_al_1.ResizeTo(KF_NUM7*m_trackNum,1); m_property.ResizeTo(m_trackNum,3); m_D.ResizeTo(1,KF_NUM7*m_trackNum); m_d.ResizeTo(1,1); m_V_D.ResizeTo(1,1); m_lam.ResizeTo(1,1); TMatrixDSym tmp_ErrCov(KF_NUM6); m_D_T.ResizeTo(KF_NUM7*m_trackNum,1); Int_t nTra = fDaughters.GetLength(); it =new VtxFitterParticle; for(Int_t i=0;iGetCovMat1( tc.Cov7() ) ); //Charge, Mass and a m_property[index][0] = tc.GetCharge()/3; m_property[index][1] = tc.P4().M(); //get the mass:Dummy value set by hand:Dipak m_property[index][2] = -KF_PHOTON_VELOCITY*m_magField*tc.GetCharge()/3; ++index; } delete it; // //Error between the tracks : will be done later :Dipak // if(m_correlationFlag == 1){ // m_errorFlag = m_setCorrelation(); // if(m_errorFlag != KF_NO_ERROR)return m_errorFlag; // } m_V_al_0.ResizeTo(tmp_V_al_0); m_V_al_0 = tmp_V_al_0; m_al_1 = m_al_0; m_V_al_1.ResizeTo(KF_NUM7*m_trackNum,KF_NUM7*m_trackNum); m_D = m_V_al_1.GetSub(0,0,0,KF_NUM7*m_trackNum-1); }else{//m_fitIncludingVertex ==1 unsigned index(0); TMatrixDSym tmp_V_al_0(KF_NUM7*m_trackNum+3); m_al_0.ResizeTo(KF_NUM7*m_trackNum+3,1); m_al_1.ResizeTo(KF_NUM7*m_trackNum+3,1); m_property.ResizeTo(m_trackNum,3); m_D.ResizeTo(1,KF_NUM7*m_trackNum+3); m_d.ResizeTo(1,1); m_V_D.ResizeTo(1,1); m_lam.ResizeTo(1,1); m_D_T.ResizeTo(KF_NUM7*m_trackNum+3,1); Int_t nTra = fDaughters.GetLength(); it =new VtxFitterParticle; for(Int_t i=0;iGetCovMat1( tc.Cov7() ) ); //Charge, Mass and a m_property[index][0] = tc.GetCharge()/3; m_property[index][1] = tc.P4().M(); //get the mass:Dummy value set by hand:Dipak m_property[index][2] = -KF_PHOTON_VELOCITY*m_magField*tc.GetCharge()/3; ++index; } delete it; /* for(Int_t i=0;iGetEntriesFast();i++) { it = (VtxFitterParticle*)fArr1->At(i); m_al_0[index*KF_NUM7+0][0] = it->GetMomentum().Px(); m_al_0[index*KF_NUM7+1][0] = it->GetMomentum().Py(); m_al_0[index*KF_NUM7+2][0] = it->GetMomentum().Pz(); m_al_0[index*KF_NUM7+3][0] = it->GetMomentum().E(); m_al_0[index*KF_NUM7+4][0] = it->GetPosition().X(); m_al_0[index*KF_NUM7+5][0] = it->GetPosition().Y(); m_al_0[index*KF_NUM7+6][0] = it->GetPosition().Z(); tmp_V_al_0.SetSub(index*KF_NUM7, it->GetErrorCovMatrix()); //Charge, Mass and a m_property[index][0] = it->GetCharge(); m_property[index][1] = it->GetMomentum().M(); //get the mass : this a dummy value set by hand m_property[index][2] = -KF_PHOTON_VELOCITY*m_magField*it->GetCharge(); ++index; } */ m_al_0[KF_NUM7*m_trackNum+0][0] = m_vertex_b.X(); m_al_0[KF_NUM7*m_trackNum+1][0] = m_vertex_b.Y(); m_al_0[KF_NUM7*m_trackNum+2][0] = m_vertex_b.Z(); tmp_V_al_0.SetSub(KF_NUM7*m_trackNum,it->GetErrVertexOut()); cout<GetEntriesFast();i++) { it = (VtxFitterParticle*)fArr1->At(i); h3v.SetX(m_al_1[index1*KF_NUM7+0][0]); h3v.SetY(m_al_1[index1*KF_NUM7+1][0]); h3v.SetZ(m_al_1[index1*KF_NUM7+2][0]); if(m_isFixMass == KF_FIX_MASS){ //Filling Momentum it->SetMomentum(TLorentzVector(h3v, sqrt(h3v.Mag2()+0.005*0.005))); }else{ it->SetMomentum(TLorentzVector(h3v, m_al_1[index1*KF_NUM7+3][0])); } //Filling Position it->SetPosition(TVector3(m_al_1[index1*KF_NUM7+4][0], m_al_1[index1*KF_NUM7+5][0], m_al_1[index1*KF_NUM7+6][0])); //Errors on Momentum will be filling later : Dipak if(m_errorFlag != KF_NO_ERROR)break; ++index1; } if(m_fitIncludingVertex == 0){ it->SetVertex(m_vertex_b); }else{ it->SetVertex(TVector3(m_al_1[KF_NUM7*m_trackNum+0][0],m_al_1[KF_NUM7*m_trackNum+1][0],m_al_1[KF_NUM7*m_trackNum+2][0])); //SetVertex //Error of the Vertex and Error betweem vertex and tracks will be implemented later : Dipak } */ return m_errorFlag; } //Fill output to TCandidate unsigned PndMassFitter::SetOutputToTCandidate() { TVector3 h3v; cout<<"# of Tracks are in TCandidate ************ "<At(i); h3v.SetX(m_al_1[index1*KF_NUM7+0][0]);//px h3v.SetY(m_al_1[index1*KF_NUM7+1][0]);//py h3v.SetZ(m_al_1[index1*KF_NUM7+2][0]);//pz tcand->SetP3(h3v); if(m_isFixMass == KF_FIX_MASS){ //Filling Momentum tcand->SetP4(TLorentzVector(h3v, sqrt(h3v.Mag2()+0.139*0.139)));//filling 4-mom }else{ tcand->SetP4(TLorentzVector(h3v, m_al_1[index1*KF_NUM7+3][0])); } //Filling Position tcand->SetPosition(TVector3(m_al_1[index1*KF_NUM7+4][0], m_al_1[index1*KF_NUM7+5][0], m_al_1[index1*KF_NUM7+6][0])); //convert 6x6 cov matrices to 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); //filled in TCandidate if(m_errorFlag != KF_NO_ERROR)break; */ ++index1; } //Will be filled later since there is no function available to store //Vertex info in TCandidate /* if(m_fitIncludingVertex == 0){ it->SetVertex(m_vertex_b); }else{ it->SetVertex(TVector3(m_al_1[KF_NUM7*m_trackNum+0][0],m_al_1[KF_NUM7*m_trackNum+1][0],m_al_1[KF_NUM7*m_trackNum+2][0])); //SetVertex //Error of the Vertex and Error between vertex and tracks will be implemented later : Dipak }*/ cout <<"sum: "<SetP4(sum); //fHeadOfTree->SetPos(TVector3( m_v_a[0][0], m_v_a[1][0],m_v_a[2][0])); fHeadOfTree->SetPos(TVector3(m_al_1[KF_NUM7*m_trackNum+0][0],m_al_1[KF_NUM7*m_trackNum+1][0],m_al_1[KF_NUM7*m_trackNum+2][0])); cout <<"SetOutputToTCandidate head of Tree:"<<(*fHeadOfTree)<