9   gStyle->SetOptFit(1011);
 
   14   gROOT->Macro(
"$VMCWORKDIR/gconfig/rootlogon.C");
 
   16   TString inPidFile  = 
"evt_pid.root";
 
   19   TFile *
inFile = TFile::Open(inSimFile,
"READ");
 
   20   TTree *
tree=(TTree *) inFile->Get(
"pndsim") ;
 
   21   tree->AddFriend(
"pndsim",inPidFile);
 
   23   TClonesArray* 
mc_array=
new TClonesArray(
"PndMCTrack");
 
   24   tree->SetBranchAddress(
"MCTrack",&mc_array);
 
   26   FairMCEventHeader* evthead;
 
   27   tree->SetBranchAddress(
"MCEventHeader.", &evthead);
 
   29   TFile *
out = TFile::Open(OutFile,
"RECREATE");
 
   32   PndEventReader evr(inPidFile);
 
   34   TH1F *h_psi_nocut=
new TH1F(
"h_psi_nocut",
"m(psi), (no cuts);E, GeV",100,3.2,4.4);
 
   35   TH1F *h_mD1_nocuts=
new TH1F(
"h_mD1_nocuts",
"D+: m(#pi+ #pi+ K-) (no cuts)",100,1.5,2.2);
 
   36   TH1F *h_mD2_nocuts=
new TH1F(
"h_mD2_nocuts",
"D-: m(#pi- #pi- K+) (no cuts)",100,1.5,2.2);
 
   37   TH1F *h_mD1_pid=
new TH1F(
"h_mD1_pid",
"D+: m(#pi+ #pi+ K-) (pid)",100,1.5,2.2);
 
   38   TH1F *h_mD2_pid=
new TH1F(
"h_mD2_pid",
"D-: m(#pi- #pi- K+) (pid)",100,1.5,2.2);
 
   40   TH1F *h_psi_pid=
new TH1F(
"h_psi_pid",
"m(#psi), (MC PID);E, GeV",100,3.2,4.4);
 
   41   TH1F *h_psi_pid_vtx=
new TH1F(
"h_psi_pid_vtx",
"m(#psi), (MC PID);E, GeV",100,3.2,4.4);
 
   43   TH1F *h_psi_4c=
new TH1F(
"h_psi_4c",
"m(#psi), 4C-fit",100,3.2,4.4);
 
   44   TH1F *h_mD_4c=
new TH1F(
"h_mD_4c",
"D: m(K #pi #pi) (4C-fit)",100,1.5,2.2);
 
   46   TH1F *h_psi_vtx=
new TH1F(
"h_psi_vtx",
"m(#psi), Vertex fit",100,3.2,4.4);
 
   47   TH1F *h_D1_vtx_bef=
new TH1F(
"h_D1_vtx_bef",
"#phi: m(K #pi #pi) (Vertex fit)",100,1.5,2.2);
 
   48   TH1F *h_D2_vtx_bef=
new TH1F(
"h_D2_vtx_bef",
"#phi: m(K #pi #pi) (Vertex fit)",100,1.5,2.2);
 
   49   TH1F *h_D1_vtx=
new TH1F(
"h_D1_vtx",
"#phi: m(K #pi #pi) (Vertex fit)",100,1.5,2.2);
 
   50   TH1F *h_D2_vtx=
new TH1F(
"h_D2_vtx",
"#phi: m(K #pi #pi) (Vertex fit)",100,1.5,2.2);
 
   52   TH1F *h_psi_Dmass=
new TH1F(
"h_psi_Dmass",
"m(#psi), (cut on D mass);E, GeV",100,3.2,4.4);
 
   53   TH1F *h_mD_final=
new TH1F(
"h_mD_final",
"D: m(K #pi #pi)",100,1.5,2.2);
 
   55   TH1F *
nc=
new TH1F(
"nc",
"n charged",20,0,20);
 
   57   TH1F *
h_chi2_4c=
new TH1F(
"h_chi2_4c",
"#chi^{2} 4C-fit;#chi^{2}/N_{df}",100,0,100);
 
   58   TH1F *
h_chi2b_4c=
new TH1F(
"h_chi2b_4c",
"#chi^{2} 4C-fit;#chi^{2}/N_{df}",100,0,100);
 
   59   TH1F *h_chi2_vtx_D1=
new TH1F(
"h_chi2_vtx_D1",
"#chi^{2} vertex;#chi^{2}/N_{df}",100,0,100);
 
   60   TH1F *h_chi2_vtx_D2=
new TH1F(
"h_chi2_vtx_D2",
"#chi^{2} vertex;#chi^{2}/N_{df}",100,0,100);
 
   61   TH2F *hvpos_D1 = 
new TH2F(
"hvpos_D1",
"(x,y) projection of fitted decay vertex",100,-5,5,100,-5,5);
 
   62   TH1F *hvzpos_D1 = 
new TH1F(
"hvzpos_D1",
"z position of fitted decay vertex",100,-10,10);
 
   63   TH1F *hvtxresX_D1 = 
new TH1F(
"hvtxresX_D1",
"X resolution of fitted decay vertex",100,-0.1,0.1);
 
   64   TH1F *hvtxresY_D1 = 
new TH1F(
"hvtxresY_D1",
"Y resolution of fitted decay vertex",100,-0.1,0.1);
 
   65   TH1F *hvtxresZ_D1 = 
new TH1F(
"hvtxresZ_D1",
"Z resolution of fitted decay vertex",100,-0.1,0.1);
 
   66   TH2F *hvpos_D2 = 
new TH2F(
"hvpos_D2",
"(x,y) projection of fitted decay vertex",100,-5,5,100,-5,5);
 
   67   TH1F *hvzpos_D2 = 
new TH1F(
"hvzpos_D2",
"z position of fitted decay vertex",100,-10,10);
 
   68   TH1F *hvtxresX_D2 = 
new TH1F(
"hvtxresX_D2",
"X resolution of fitted decay vertex",100,-0.1,0.1);
 
   69   TH1F *hvtxresY_D2 = 
new TH1F(
"hvtxresY_D2",
"Y resolution of fitted decay vertex",100,-0.1,0.1);
 
   70   TH1F *hvtxresZ_D2 = 
new TH1F(
"hvtxresZ_D2",
"Z resolution of fitted decay vertex",100,-0.1,0.1);
 
   72   TPidMassSelector *psiMassSel=
new TPidMassSelector(
"psi",1.87,0.07);
 
   74   TPidPlusSelector *pplusSel=
new TPidPlusSelector(
"pplus");
 
   75   TPidMinusSelector *pminusSel=
new TPidMinusSelector(
"pminus");
 
   78   TCandList 
p1, 
p2, k1, k2, D1, D1_pid, D2, D2_pid, psi, psi_pid,  psi_nocut;
 
   82   TH1F *
n_events=
new TH1F(
"n_events",
"total number of events",1,0,1);
 
   83   TH1F *n_psi=
new TH1F(
"n_psi",
"number of reconstructed eta_c",1,0,1);
 
   85   TLorentzVector ini(0,0,6.578800,7.583333);
 
   87   if (nevts==0) nevts=evr.GetEntries();
 
   89   n_events->SetBinContent(1,nevts);
 
   91   int i=0,j=0, k=0, l=0;
 
   96   while (evr.GetEvent() && i++<nevts)
 
   99       if ((i%100)==0)  cout<<
"evt " << i << 
"\n";
 
  101       evr.FillList(p1,
"Charged");
 
  102       evr.FillList(p2,
"Charged");
 
  103       evr.FillList(k1,
"Charged");
 
  104       evr.FillList(k2,
"Charged");
 
  107       p2.Select(pminusSel);
 
  109       k2.Select(pminusSel);
 
  111       int nchrg=p1.GetLength()+p2.GetLength();
 
  114       for (j=0;j<p1.GetLength();++j) {
 
  115         p1[j].SetMass(TRho::Instance()->GetPDG()->GetParticle(211)->
Mass());
 
  117       for (j=0;j<p2.GetLength();++j) {
 
  118         p2[j].SetMass(TRho::Instance()->GetPDG()->GetParticle(211)->
Mass());
 
  120       for (j=0;j<k1.GetLength();++j) {
 
  121         k1[j].SetMass(TRho::Instance()->GetPDG()->GetParticle(321)->
Mass());
 
  123       for (j=0;j<k2.GetLength();++j) {
 
  124         k2[j].SetMass(TRho::Instance()->GetPDG()->GetParticle(321)->
Mass());
 
  128       D1.Combine(p1,p1, k2);
 
  129       D2.Combine(p2,p2, k1);
 
  131       for (j=0;j<D1.GetLength();++j) h_mD1_nocuts->Fill(D1[j].M());
 
  132       for (j=0;j<D2.GetLength();++j) h_mD2_nocuts->Fill(D2[j].M());
 
  134       D1.Select(psiMassSel);
 
  135       D2.Select(psiMassSel);
 
  136       psi_nocut.Combine(D1,D2);
 
  138       for (l=0;l<psi_nocut.GetLength();++l) {
 
  139         h_psi_nocut->Fill(psi_nocut[l].M());
 
  143       TVector3 mcVertex, mcD1Vertex, mcD2vertex;
 
  145       if (((
PndMCTrack*)mc_array->At(0))!=0) mcD1Vertex = ((
PndMCTrack*)mc_array->At(0))->GetStartVertex();
 
  147         cout << 
"Not found k1!" << endl;
 
  148       if (((
PndMCTrack*)mc_array->At(3))!=0) mcD2Vertex = ((
PndMCTrack*)mc_array->At(3))->GetStartVertex();
 
  150         cout << 
"Not found k2!" << endl;
 
  152       evthead->GetVertex(mcVertex);
 
  158       for (l=0;l<p1.GetLength();++l) {
 
  160         if (p1[ii].GetMicroCandidate().GetMcIndex()>-1){
 
  172               std::cout<<
"stt h: " << p1[ii].GetMicroCandidate().GetSttHits() << std::endl;
 
  173               std::cout<<
"Kaon list 1, element "<<l<<
" has no assosiated mcTRack"<<std::endl;
 
  180       for (l=0;l<p2.GetLength();++l) {
 
  182         if (p2[ii].GetMicroCandidate().GetMcIndex()>-1){
 
  194               std::cout<<
"stt h: " << p2[ii].GetMicroCandidate().GetSttHits() << std::endl;
 
  195               std::cout<<
"Kaon list 2, element "<<l<<
" has no assosiated mcTRack"<<std::endl;
 
  202       for (l=0;l<k1.GetLength();++l) {
 
  204         if (k1[ii].GetMicroCandidate().GetMcIndex()>-1){
 
  216               std::cout<<
"stt h: " << k1[ii].GetMicroCandidate().GetSttHits() << std::endl;
 
  217               std::cout<<
"Kaon list 2, element "<<l<<
" has no assosiated mcTRack"<<std::endl;
 
  224       for (l=0;l<k2.GetLength();++l) {
 
  226         if (k2[ii].GetMicroCandidate().GetMcIndex()>-1){
 
  238               std::cout<<
"stt h: " << k2[ii].GetMicroCandidate().GetSttHits() << std::endl;
 
  239               std::cout<<
"Kaon list 2, element "<<l<<
" has no assosiated mcTRack"<<std::endl;
 
  244       D1_pid.Combine(p1,p1, k2);
 
  245       D2_pid.Combine(p2,p2, k1);
 
  247       for (j=0;j<D1_pid.GetLength();++j) h_mD1_pid->Fill(D1_pid[j].M());
 
  248       for (j=0;j<D2_pid.GetLength();++j) h_mD2_pid->Fill(D2_pid[j].M());
 
  249       D1_pid.Select(psiMassSel);
 
  250       D2_pid.Select(psiMassSel);
 
  251       psi.Combine(D1_pid,D2_pid);
 
  253       for (l=0;l<psi.GetLength();++l) {
 
  254         h_psi_pid->Fill(psi[l].M());
 
  262           double best_chi2=100000;
 
  265           for (l=0;l<psi.GetLength();++l) {
 
  273                 ccfit = (TCandidate*)fitter.FittedCand(psi[l]);
 
  274                 TCandidate *D1best = fitter.FittedCand(*(psi[l].Daughter(0)));
 
  275                 TCandidate *D2best = fitter.FittedCand(*(psi[l].Daughter(1)));
 
  276                 TCandidate *p1best = fitter.FittedCand(*(psi[l].Daughter(0)->Daughter(0)));
 
  277                 TCandidate *p2best = fitter.FittedCand(*(psi[l].Daughter(0)->Daughter(1)));
 
  278                 TCandidate *k1best = fitter.FittedCand(*(psi[l].Daughter(0)->Daughter(2)));
 
  279                 TCandidate *p3best = fitter.FittedCand(*(psi[l].Daughter(1)->Daughter(0)));
 
  280                 TCandidate *p4best = fitter.FittedCand(*(psi[l].Daughter(1)->Daughter(1)));
 
  281                 TCandidate *k2best = fitter.FittedCand(*(psi[l].Daughter(1)->Daughter(2)));
 
  282                 TLorentzVector tlvk1 = p1best->P4();
 
  283                 TLorentzVector tlvk2 = p2best->P4();
 
  284                 TLorentzVector tlvk3 = k1best->P4();
 
  285                 TLorentzVector tlvk4 = p3best->P4();
 
  286                 TLorentzVector tlvk5 = p4best->P4();
 
  287                 TLorentzVector tlvk6 = k2best->P4();
 
  288                 m_D1= (tlvk1+tlvk2+tlvk3).M();
 
  289                 m_D2= (tlvk4+tlvk5+tlvk6).M();
 
  291             h_chi2_4c->Fill(chi2/9); 
 
  294           if (psi.GetLength()!=0) cout << 
"evt: " << i << 
"\tbest: " << best_chi2 << 
"\tlen " << psi.GetLength() << endl;
 
  296           if((psi.GetLength()!=0))
 
  298               h_chi2b_4c->Fill(best_chi2/9); 
 
  299               h_psi_4c->Fill(ccfit->M());
 
  302               h_mD_final->Fill(m_D1);
 
  303               h_mD_final->Fill(m_D2);
 
  304               if (((m_D1>1.87-0.07)&&(m_D1<1.87+0.07))&&((m_D2>1.87-0.07)&&(m_D2<1.87+0.07)))
 
  306                   h_psi_Dmass->Fill(psi[best_i].M());
 
  307                   if ((psi[best_i].M()>3.7)&&(psi[best_i].M()<3.9))
 
  314           TCandList psi_vtx, D1_vtx, D2_vtx;
 
  315           TCandidate *ck1, *ck2, *cp1, *cp2, *cp3, *cp4, *D1tmp, *D2tmp, *D1_tmp, *D2_tmp, *psi_tmp;
 
  318           for (j=0;j<psi.GetLength();++j)
 
  320               D1tmp=psi[j].Daughter(0);
 
  321               D2tmp=psi[j].Daughter(1);
 
  323               cp1=D1tmp->Daughter(0);
 
  324               cp2=D1tmp->Daughter(1);
 
  325               ck1=D1tmp->Daughter(2);
 
  327               cp3=D2tmp->Daughter(0);
 
  328               cp4=D2tmp->Daughter(1);
 
  329               ck2=D2tmp->Daughter(2);
 
  330               D1_tmp=cp1->Combine(*cp2,*ck1);
 
  331               D2_tmp=cp3->Combine(*cp4,*ck2);
 
  338           for (l=0;l<psi.GetLength();++l) {
 
  345             double best_chi2=1000;
 
  346             TCandidate *D1fit_best=0;
 
  347             TCandidate *k1fit_best, *p1fit_best, *p2fit_best, *k1nofit, *p1nofit, *p2nofit;
 
  349             Float_t D1vtx_mass, pre_m_D1;
 
  350             for (j=0;j<D1_vtx.GetLength();++j)
 
  355                 TCandidate *D1fit=vtxfitter.FittedCand(D1_vtx[j]);  
 
  356                 TVector3 D1Vtx=D1fit->Pos();                    
 
  357                 double chi2_vtx_D1=vtxfitter.GlobalChi2();
 
  358                 h_chi2_vtx_D1->Fill(chi2_vtx_D1/5); 
 
  360                 hvpos_D1->Fill(D1Vtx.X(),D1Vtx.Y());
 
  361                 hvzpos_D1->Fill(D1Vtx.Z());
 
  362                 if(chi2_vtx_D1<best_chi2)
 
  364                   best_chi2=chi2_vtx_D1;
 
  367                   p1fit_best=vtxfitter.FittedCand(*(D1fit_best->Daughter(0)));
 
  368                   p2fit_best=vtxfitter.FittedCand(*(D1fit_best->Daughter(1)));
 
  369                   k1fit_best=vtxfitter.FittedCand(*(D1fit_best->Daughter(2)));
 
  370                   p1nofit=D1_vtx[j].Daughter(0);
 
  371                   p2nofit=D1_vtx[j].Daughter(1);
 
  372                   k1nofit=D1_vtx[j].Daughter(2);
 
  373                   TLorentzVector tlvp1 = p1nofit->P4();
 
  374                   TLorentzVector tlvp2 = p2nofit->P4();
 
  375                   TLorentzVector tlvk1 = k1nofit->P4();
 
  376                   pre_m_D1= (tlvp1+tlvp2+tlvk1).M();
 
  378                   D1vtx_mass = D1fit_best->M();
 
  379                   bestPos = D1fit->Pos();
 
  382             if((psi.GetLength()!=0))
 
  384                 h_D1_vtx->Fill(D1vtx_mass);
 
  385                 h_D1_vtx_bef->Fill(pre_m_D1);
 
  387                 hvtxresX_D1->Fill(mcD1Vertex.X()-bestPos.X());
 
  388                 hvtxresY_D1->Fill(mcD1Vertex.Y()-bestPos.Y());
 
  389                 hvtxresZ_D1->Fill(mcD1Vertex.Z()-bestPos.Z());
 
  398             double best_chi2=1000;
 
  399             TCandidate *D2fit_best=0;
 
  400             TCandidate *k1fit_best, *p1fit_best, *p2fit_best, *k1nofit, *p1nofit, *p2nofit;
 
  402             Float_t D2vtx_mass, pre_m_D2;
 
  403             for (j=0;j<D2_vtx.GetLength();++j)
 
  408                 TCandidate *D2fit=vtxfitter.FittedCand(D2_vtx[j]);  
 
  409                 TVector3 D2Vtx=D2fit->Pos();                    
 
  410                 double chi2_vtx_D2=vtxfitter.GlobalChi2();
 
  411                 h_chi2_vtx_D2->Fill(chi2_vtx_D2/5); 
 
  413                 hvpos_D2->Fill(D2Vtx.X(),D2Vtx.Y());
 
  414                 hvzpos_D2->Fill(D2Vtx.Z());
 
  415                 if(chi2_vtx_D2<best_chi2)
 
  417                   best_chi2=chi2_vtx_D2;
 
  420                   p1fit_best=vtxfitter.FittedCand(*(D2fit_best->Daughter(0)));
 
  421                   p2fit_best=vtxfitter.FittedCand(*(D2fit_best->Daughter(1)));
 
  422                   k1fit_best=vtxfitter.FittedCand(*(D2fit_best->Daughter(2)));
 
  423                   p1nofit=D2_vtx[j].Daughter(0);
 
  424                   p2nofit=D2_vtx[j].Daughter(1);
 
  425                   k1nofit=D2_vtx[j].Daughter(2);
 
  426                   TLorentzVector tlvp1 = p1nofit->P4();
 
  427                   TLorentzVector tlvp2 = p2nofit->P4();
 
  428                   TLorentzVector tlvk1 = k1nofit->P4();
 
  429                   pre_m_D2= (tlvp1+tlvp2+tlvk1).M();
 
  431                   D2vtx_mass = D2fit_best->M();
 
  432                   bestPos = D2fit->Pos();
 
  435             if((psi.GetLength()!=0))
 
  437                 h_D2_vtx->Fill(D2vtx_mass);
 
  438                 h_D2_vtx_bef->Fill(pre_m_D2);
 
  439                 hvtxresX_D2->Fill(mcD2Vertex.X()-bestPos.X());
 
  440                 hvtxresY_D2->Fill(mcD2Vertex.Y()-bestPos.Y());
 
  441                 hvtxresZ_D2->Fill(mcD2Vertex.Z()-bestPos.Z());
 
  448   std::cout<<
"Number of reconstructed eta_c = "<<n_reco<<std::endl;
 
  449   n_psi->SetBinContent(1,n_reco);
 
  454   h_mD1_nocuts->Write();
 
  456   h_mD2_nocuts->Write();
 
  458   h_psi_nocut->Write();
 
  465   h_psi_Dmass->Write();
 
  467   h_D1_vtx_bef->Write();
 
  468   h_D2_vtx_bef->Write();
 
  482   h_chi2_vtx_D1->Write();
 
  485   hvtxresX_D1->Write();
 
  486   hvtxresY_D1->Write();
 
  487   hvtxresZ_D1->Write();
 
  490   hvtxresX_D2->Write();
 
  491   hvtxresY_D2->Write();
 
  492   hvtxresZ_D2->Write();
 
  500   printf(
"RealTime=%f seconds, CpuTime=%f seconds\n",rtime,ctime);
 
  507   TCandidate *phi1, *phi2, *k1, *k2, *k3, *k4;
 
  510   int len1=psi_list.GetLength();
 
  513   for (
int i=0; 
i<len1; ++
i)
 
  515       phi1=psi_list[ii].Daughter(0);
 
  516       phi2=psi_list[ii].Daughter(1);
 
  517       k1=phi1->Daughter(0);
 
  518       k2=phi1->Daughter(1);
 
  519       k3=phi2->Daughter(0);
 
  520       k4=phi2->Daughter(1);
 
  522       if ((k1->IsCloneOf(*k3))||(k2->IsCloneOf(*k4)))
 
  524           psi_list.Remove(psi_list[ii]);
 
  525           std::cout<<
"Overlap found, i="<<
i<<std::endl;
 
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
Bool_t FitConserveMasses()
int ana_check_psi(int nevts=0)
void removeCombinatoric(TCandList &psi_list)
Int_t GetMotherID() const