8   gStyle->SetOptFit(1011);
 
   13   gROOT->Macro(
"$VMCWORKDIR/gconfig/rootlogon.C");
 
   16   TString inPidFile  = 
"evt_pid.root";
 
   18   TFile *
inFile = TFile::Open(inSimFile,
"READ");
 
   19   TTree *
tree=(TTree *) inFile->Get(
"pndsim") ;
 
   20   tree->AddFriend(
"pndsim",inPidFile);
 
   21   TClonesArray* 
mc_array=
new TClonesArray(
"PndMCTrack");
 
   22   tree->SetBranchAddress(
"MCTrack",&mc_array);
 
   24   TClonesArray* cand_array=
new TClonesArray(
"PndPidCandidate");
 
   25   tree->SetBranchAddress(
"PidChargedCand",&cand_array);
 
   27     FairMCEventHeader* evthead;
 
   28    tree->SetBranchAddress(
"MCEventHeader.", &evthead);
 
   30   TFile *
out=TFile::Open(
"ana_invariantmass_2pi_tpc.root",
"RECREATE");
 
   32   PndEventReader evr(inPidFile);
 
   37   TH1F *
nc=
new TH1F(
"nc",
"Number of Charged Tracks; Charged Tracks",20,-0.5,19.5);
 
   38   TH1F *invmassnosel=
new TH1F(
"invmassnosel",
"#pi^{+}#pi^{-} Invariant mass;Invariant Mass (GeV)",100,0,10);
 
   39   TH1F *invmassnocut=
new TH1F(
"invmassnocut",
"#pi^{+}#pi^{-} Invariant mass;Invariant Mass (GeV)",100,2,4);
 
   40   TH1F *invmasswithpid=
new TH1F(
"invmasswithpid",
"#pi^{+}#pi^{-} Invariant mass;Invariant Mass (GeV)",100,0,10);
 
   41   TH1F *invmasswithpid_sel=
new TH1F(
"invmasswithpid_sel",
"#pi^{+}#pi^{-} Invariant mass;Invariant Mass (GeV)",100,2,4);
 
   43   TH1F *invmass_trackhighmom= 
new TH1F(
"invmass_trackhighmom",
"#pi^{+}#pi^{-} Invariant mass;Invariant Mass (GeV)",100,2,4);
 
   45  TH1F *invmasschicut_best=
new TH1F(
"invmasschicut_best",
"#pi^{+}#pi^{-} Invariant mass;Invariant Mass (GeV)",100,2,4);
 
   47  TH2F *
hvpos = 
new TH2F(
"hvpos",
"(x,y) projection of fitted decay vertex",100,-5,5,100,-5,5);
 
   48  TH1F *
hvzpos = 
new TH1F(
"hvzpos",
"z position of fitted decay vertex",100,-4,4);
 
   50   TH1F *chivtx=
new TH1F(
"chivtx",
"Chi Square RhoKinVtxFitter; Chi Square/N_{df}",100,0,8);
 
   52   TH1F *
hvtxresX = 
new TH1F(
"hvtxresX",
"X resolution of fitted decay vertex",100,-0.3,0.3);
 
   53   TH1F *
hvtxresY = 
new TH1F(
"hvtxresY",
"Y resolution of fitted decay vertex",100,-0.3,0.3);
 
   54   TH1F *
hvtxresZ = 
new TH1F(
"hvtxresZ",
"Z resolution of fitted decay vertex",100,-0.3,0.3);
 
   56   TPidPlusSelector *piplusSel=
new TPidPlusSelector(
"piplus");
 
   57   TPidMinusSelector *piminusSel=
new TPidMinusSelector(
"piminus");
 
   59   TCandList pp, pm, pipi,pipinosel, pipiwithpid;
 
   62   TLorentzVector ini(0,0,4.0,5.04684);
 
   63   int i=0,j=0,k=0,l=0,
y=0;
 
   66   beam.SetXYZM (0.0,0.0,4.0,0.938272);
 
   67   TLorentzVector target;
 
   68   target.SetXYZM (0.0,0.0,0.0,0.938272);
 
   69   TLorentzVector pbarp=beam+target;
 
   72   float energypip, energypim, momxpip, momypip, momzpip;
 
   73   TPidMassSelector *pipisel=
new TPidMassSelector(
"pipisel",3.07,1.0); 
 
   75   TPidPlusSelector *piplusSel=
new TPidPlusSelector(
"piplus");
 
   76   TPidMinusSelector *piminusSel=
new TPidMinusSelector(
"piminus");
 
   78   if (nEntries==0) nEntries=evr.GetEntries();
 
   79   while (evr.GetEvent() && i++<nEntries){
 
   81     if (!((i+1)%100)) cout<<
"evt " << i << 
"\n";
 
   83     evr.FillList(pp,
"Charged");
 
   84     evr.FillList(pm,
"Charged");
 
   86     pm.Select(piminusSel);
 
   88     int nchrg=pp.GetLength();
 
   90     float momentumpplus, momentumpminus, theta1, theta2, phi1, phi2;
 
   92     for (Int_t l=0;l<pp.GetLength();l++){
 
   93       pp[l].SetMass(TRho::Instance()->GetPDG()->GetParticle(211)->
Mass());
 
   94       momentumpplus=pp[l].GetMicroCandidate().GetMomentum().Mag();
 
   95       theta1=pp[l].GetMicroCandidate().GetMomentum().Theta()*TMath::RadToDeg();
 
   96       phi1=pp[l].GetMicroCandidate().GetMomentum().Phi()*TMath::RadToDeg();
 
   99     for (Int_t l=0;l<pm.GetLength();l++){
 
  100       pm[l].SetMass(TRho::Instance()->GetPDG()->GetParticle(211)->
Mass());
 
  101       momentumpminus=pm[l].GetMicroCandidate().GetMomentum().Mag();
 
  102       theta2=pm[l].GetMicroCandidate().GetMomentum().Theta()*TMath::RadToDeg();
 
  103       phi2=pm[l].GetMicroCandidate().GetMomentum().Phi()*TMath::RadToDeg();
 
  109     pipinosel.Combine(pp,pm);
 
  111     for (
y=0;
y<pipinosel.GetLength();++
y){
 
  112       invmassnosel->Fill(pipinosel[
y].M());
 
  116     pipi.Select(pipisel); 
 
  118     for (
y=0;
y<pipi.GetLength();++
y){
 
  119       invmassnocut->Fill(pipi[
y].M());
 
  120       if (momentumpplus>0.3 && momentumpminus >0.3){ 
 
  121         invmass_trackhighmom->Fill(pipi[
y].M());
 
  130     evthead->GetVertex(mcVertex);
 
  136     for (l=0;l<pp.GetLength();++l) {
 
  138       if (pp[ii].GetMicroCandidate().GetMcIndex()>-1){
 
  150             std::cout<<
"Pi plus, element "<<l<<
" has no assosiated mcTRack"<<std::endl;
 
  158     for (l=0;l<pm.GetLength();++l) {
 
  160       if (pm[ii].GetMicroCandidate().GetMcIndex()>-1){
 
  172             std::cout<<
"Pi Minus,  element "<<l<<
" has no assosiated mcTRack"<<std::endl;
 
  179     pipiwithpid.Combine(pp,pm);
 
  180     for (
y=0;
y<pipiwithpid.GetLength();++
y){
 
  181       invmasswithpid->Fill(pipiwithpid[
y].M());
 
  185     pipiwithpid.Combine(pp,pm);
 
  186     pipiwithpid.Select(pipisel); 
 
  187     for (
y=0;
y<pipiwithpid.GetLength();++
y){
 
  188       invmasswithpid_sel->Fill(pipiwithpid[
y].M());
 
  192     double best_chi2=1000;
 
  193     TCandidate *pipifit_best=0;
 
  194     Float_t pipivtx_mass;
 
  196   for (
y=0;
y<pipiwithpid.GetLength();++
y){
 
  200       TCandidate *pipifit=vtxfitter.FittedCand(pipiwithpid[
y]);
 
  202       TVector3 pipiVtx=pipifit->Pos();
 
  203       double chi2_vtx=vtxfitter.GlobalChi2();
 
  205       hvpos->Fill(pipiVtx.X(),pipiVtx.Y());
 
  206       hvzpos->Fill(pipiVtx.Z());
 
  208       if(chi2_vtx<best_chi2)
 
  212           pipifit_best=pipifit;
 
  213           pipivtx_mass=pipifit_best->M();
 
  214           bestPos = pipifit->Pos();
 
  217       chivtx->Fill(chi2_vtx/1); 
 
  221     if((pipiwithpid.GetLength()!=0))
 
  223         invmasschicut_best->Fill(pipivtx_mass);
 
  225         hvtxresX->Fill(mcVertex.X()-bestPos.X());
 
  226         hvtxresY->Fill(mcVertex.Y()-bestPos.Y());
 
  227         hvtxresZ->Fill(mcVertex.Z()-bestPos.Z());
 
Int_t GetMotherID() const