7   gStyle->SetOptFit(1011);
 
   12   gROOT->Macro(
"$VMCWORKDIR/gconfig/rootlogon.C");
 
   14   TString inPidFile  = 
"evt_pid_stt.root";
 
   16   TFile *
inFile = TFile::Open(inSimFile,
"READ");
 
   17   TTree *
tree=(TTree *) inFile->Get(
"pndsim") ;
 
   18   tree->AddFriend(
"pndsim",inPidFile);
 
   19   TClonesArray* 
mc_array=
new TClonesArray(
"PndMCTrack");
 
   20   tree->SetBranchAddress(
"MCTrack",&mc_array);
 
   22   TClonesArray* cand_array=
new TClonesArray(
"PndPidCandidate");
 
   23   tree->SetBranchAddress(
"PidChargedCand",&cand_array);
 
   25     FairMCEventHeader* evthead;
 
   26    tree->SetBranchAddress(
"MCEventHeader.", &evthead);
 
   28   TFile *
out=TFile::Open(
"invariantmass_4pi_stt.root",
"RECREATE");
 
   30   PndEventReader evr(inPidFile);
 
   32   TH1F *
nc=
new TH1F(
"nc",
"Number of Charged Tracks; Charged Tracks",20,-0.5,19.5);
 
   33   TH1F *invmassnosel=
new TH1F(
"invmassnosel",
"2(#pi^{+}#pi^{-}) Invariant mass;Invariant Mass (GeV)",100,0,10);
 
   34   TH1F *invmassnocut=
new TH1F(
"invmassnocut",
"2(#pi^{+}#pi^{-}) Invariant mass;Invariant Mass (GeV)",100,2,4);
 
   36   TH1F *invmasswithpid=
new TH1F(
"invmasswithpid",
"#pi^{+}#pi^{-} Invariant mass;Invariant Mass (GeV)",100,0,10);
 
   37   TH1F *invmasswithpid_sel=
new TH1F(
"invmasswithpid_sel",
"#pi^{+}#pi^{-} Invariant mass;Invariant Mass (GeV)",100,2,4);
 
   38 TH1F *invmass_trackhighmom= 
new TH1F(
"invmass_trackhighmom",
"2(#pi^{+}#pi^{-}) Invariant mass;Invariant Mass (GeV)",100,2,4);
 
   39  TH1F *invmasschicut=
new TH1F(
"invmasschicut",
"#2(pi^{+}#pi^{-}) Invariant mass;Invariant Mass (GeV)",100,2,4);
 
   40  TH1F *invmasschicut_best=
new TH1F(
"invmasschicut_best",
"2(#pi^{+}#pi^{-}) Invariant mass;Invariant Mass (GeV)",100,2,4);
 
   42  TH2F *
hvpos = 
new TH2F(
"hvpos",
"(x,y) projection of fitted decay vertex",100,-5,5,100,-5,5);
 
   43  TH1F *
hvzpos = 
new TH1F(
"hvzpos",
"z position of fitted decay vertex",100,-4,4);
 
   45  TH1F *chivtx=
new TH1F(
"chivtx",
"Chi Square RhoKinVtxFitter; Chi Square / N_{df}",100,0,100);
 
   46   TH1F *
hvtxresX = 
new TH1F(
"hvtxresX",
"X resolution of fitted decay vertex",100,-0.3,0.3);
 
   47   TH1F *
hvtxresY = 
new TH1F(
"hvtxresY",
"Y resolution of fitted decay vertex",100,-0.3,0.3);
 
   48   TH1F *
hvtxresZ = 
new TH1F(
"hvtxresZ",
"Z resolution of fitted decay vertex",100,-0.3,0.3);
 
   51    TPidPlusSelector *piplusSel=
new TPidPlusSelector(
"piplus");
 
   52   TPidMinusSelector *piminusSel=
new TPidMinusSelector(
"piminus");
 
   54   TCandList pp, pm, pipi,pipinosel, pipiwithpid;
 
   58   TLorentzVector ini(0,0,4.0,5.04684);
 
   59   int i=0,j=0,k=0,l=0,
y=0;
 
   62   beam.SetXYZM (0.0,0.0,4.0,0.938272);
 
   63   TLorentzVector target;
 
   64   target.SetXYZM (0.0,0.0,0.0,0.938272);
 
   65   TLorentzVector pbarp=beam+target;
 
   69   float energypip, energypim, momxpip, momypip, momzpip;
 
   70   TPidMassSelector *pipisel=
new TPidMassSelector(
"pipisel",3.07,0.5); 
 
   71   TPidPlusSelector *piplusSel=
new TPidPlusSelector(
"piplus");
 
   72   TPidMinusSelector *piminusSel=
new TPidMinusSelector(
"piminus");
 
   74     if (nEntries==0) nEntries=evr.GetEntries();
 
   75     while (evr.GetEvent() && i++<nEntries){
 
   77       if (!((i+1)%100)) cout<<
"evt " << i << 
"\n";
 
   79       evr.FillList(pp,
"Charged");
 
   80     evr.FillList(pm,
"Charged");
 
   83     pm.Select(piminusSel);
 
   85  int nchrg=pp.GetLength();
 
   89     float momentumpplus, momentumpminus, theta1, theta2, phi1, phi2;
 
   93     for (Int_t l=0;l<pp.GetLength();l++){
 
   95       if((pp[ii].GetMicroCandidate()->GetSttHits())==0){
 
  103     for (Int_t l=0;l<pm.GetLength();l++){
 
  105       if((pm[ii].GetMicroCandidate()->GetSttHits())==0){
 
  113    for (Int_t l=0;l<pp.GetLength();l++){
 
  114       pp[l].SetMass(TRho::Instance()->GetPDG()->GetParticle(211)->
Mass());
 
  115       momentumpplus=pp[l].GetMicroCandidate().GetMomentum().Mag();
 
  118     for (Int_t l=0;l<pm.GetLength();l++){
 
  119       pm[l].SetMass(TRho::Instance()->GetPDG()->GetParticle(211)->
Mass());
 
  120       momentumpminus=pm[l].GetMicroCandidate().GetMomentum().Mag();
 
  125     pipinosel.Combine(pp,pm,pp,pm);
 
  127     for (
y=0;
y<pipinosel.GetLength();++
y){
 
  128       invmassnosel->Fill(pipinosel[
y].M());
 
  131     pipi.Combine(pp,pm,pp,pm);
 
  132     pipi.Select(pipisel);
 
  134     for (
y=0;
y<pipi.GetLength();++
y){
 
  135       invmassnocut->Fill(pipi[
y].M());
 
  136             if (momentumpplus>0.3 && momentumpminus >0.3){
 
  137         invmass_trackhighmom->Fill(pipi[
y].M());
 
  147     evthead->GetVertex(mcVertex);
 
  153     for (l=0;l<pp.GetLength();++l) {
 
  155       if (pp[ii].GetMicroCandidate().GetMcIndex()>-1){
 
  167             std::cout<<
"Pi plus, element "<<l<<
" has no assosiated mcTRack"<<std::endl;
 
  175     for (l=0;l<pm.GetLength();++l) {
 
  177       if (pm[ii].GetMicroCandidate().GetMcIndex()>-1){
 
  189             std::cout<<
"Pi Minus,  element "<<l<<
" has no assosiated mcTRack"<<std::endl;
 
  195     pipiwithpid.Combine(pp,pm,pp,pm);
 
  196     for (
y=0;
y<pipiwithpid.GetLength();++
y){
 
  197       invmasswithpid->Fill(pipiwithpid[
y].M());
 
  201     pipiwithpid.Combine(pp,pm,pp,pm);
 
  202     pipiwithpid.Select(pipisel); 
 
  203     for (
y=0;
y<pipiwithpid.GetLength();++
y){
 
  204       invmasswithpid_sel->Fill(pipiwithpid[
y].M());
 
  209     double best_chi2=1000;
 
  210     TCandidate *pipifit_best=0;
 
  211     Float_t pipivtx_mass;
 
  212   for (
y=0;
y<pipiwithpid.GetLength();++
y){
 
  216       TCandidate *pipifit=vtxfitter.FittedCand(pipiwithpid[
y]);
 
  218   TVector3 pipiVtx=pipifit->Pos();
 
  219       double chi2_vtx=vtxfitter.GlobalChi2();
 
  221       hvpos->Fill(pipiVtx.X(),pipiVtx.Y());
 
  222       hvzpos->Fill(pipiVtx.Z());
 
  224       if(chi2_vtx<best_chi2)
 
  228           pipifit_best=pipifit;
 
  229           pipivtx_mass=pipifit_best->M();
 
  230           bestPos = pipifit->Pos();
 
  232       chivtx->Fill(chi2_vtx/5); 
 
  236   if((pipiwithpid.GetLength()!=0))
 
  238       invmasschicut_best->Fill(pipivtx_mass);
 
  240       hvtxresX->Fill(mcVertex.X()-bestPos.X());
 
  241       hvtxresY->Fill(mcVertex.Y()-bestPos.Y());
 
  242       hvtxresZ->Fill(mcVertex.Z()-bestPos.Z());
 
Int_t GetMotherID() const