EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
analysis.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file analysis.C
1 
2 void analysis()
3 {
4  // Load basic libraries;
5  gROOT->Macro("$VMCWORKDIR/gconfig/rootlogon.C");
6 
7  // Input simulated & reconstructed files;
8  TFile *ff = new TFile("simulation.root");
9  TTree *cbmsim = ff->Get("cbmsim");
10  cbmsim->AddFriend("cbmsim", "reconstruction.root");
11 
12  // Branches of interest;
13  TClonesArray *mcTrackArray = new TClonesArray("PndMCTrack");
14  cbmsim->SetBranchAddress("MCTrack", &mcTrackArray);
15  TClonesArray *rcTrackArray = new TClonesArray("PndPidCandidate");
16  cbmsim->SetBranchAddress("PidChargedCand", &rcTrackArray);
17 
18  // Book 1D dp/p histogram;
19  TH1D *dp = new TH1D("dp", "dp", 100, -5., 5.);
20 
21  // Loop through all events; NB: for box-generated events without secondaries
22  // could simply use cbmsim->Project() as well; in general EicEventAssembler
23  // should be used for "true" physics events;
24  int nEvents = cbmsim->GetEntries();
25  for(unsigned ev=0; ev<nEvents; ev++) {
26  cbmsim->GetEntry(ev);
27 
28  // Loop through all reconstructed tracks;
29  for(unsigned rc=0; rc<rcTrackArray->GetEntriesFast(); rc++) {
30  PndPidCandidate *rctrack = rcTrackArray->At(rc);
31 #if 0
32  {
33  for(unsigned iq=0; iq<rctrack->GetSmoothedValuesCount(); iq++) {
34  const TVector3 &pos = rctrack->GetSmoothedPosition(iq);
35  const TVector3 &mom = rctrack->GetSmoothedMomentum(iq);
36 
37  if (rctrack->GetSmoothedValuesCount() != 10)
38  printf("%10.4f %10.4f %10.4f -> %10.4f %10.4f %10.4f\n",
39  pos.X(), pos.Y(), pos.Z(), mom.X(), mom.Y(), mom.Z());
40  } //for iq
41  }
42 #endif
43  {
44  TVector3 plxx(0.0, 0.0, 111.0), plnx(0.0, 0.0, 1.0);
45  NaiveTrackParam param = rctrack->GetNearestParameterization(plxx, plnx);
46 
47 #if 1
48  if (param.IsValid()) {
49  const TVector3 &pos = param.GetPosition();
50  const TVector3 &mom = param.GetMomentum();
51 
52  //if (rctrack->GetSmoothedValuesCount() != 10)
53  printf(" %10.4f %10.4f %10.4f -> %10.4f %10.4f %10.4f -> %10.4f\n",
54  pos.X(), pos.Y(), pos.Z(), mom.X(), mom.Y(), mom.Z(),
55  param.DistanceToPlane(plxx, plnx));
56  }
57  else
58  // Can hardly happen (fitter would not be started on such a track);
59  printf(" ---> No hits!\n");
60 #endif
61  }
62 
63  int mcTrackId = rctrack->GetMcIndex();
64 
65  // Select only correctly rc->mc identified tracks;
66  if (mcTrackId < 0 || mcTrackId >= mcTrackArray->GetEntriesFast()) continue;
67 
68  // Find MC track associated with this reconstructed track;
69  PndMCTrack *mctrack = mcTrackArray->At(mcTrackId);
70 
71  // Well, for plotting select primary pi-minus tracks only (see simulation.C);
72  if (mctrack->GetPdgCode() == 211 && mctrack->GetMotherID() == -1)
73  dp->Fill(100.*(rctrack->GetMomentum().Mag() - mctrack->GetMomentum().Mag())/mctrack->GetMomentum().Mag());
74  } //for rc
75  } //for ev
76 
77  gStyle->SetOptStat(0);
78 
79  dp->SetTitle("Momentum resolution");
80 
81  dp->GetXaxis()->SetTitle("(P_{rec} - P_{sim})/P_{sim}, [%]");
82  dp->GetXaxis()->SetTitleOffset(0.9);
83  dp->GetXaxis()->SetLabelFont(52);
84  dp->GetXaxis()->SetLabelSize(0.040);
85  dp->GetXaxis()->SetTitleFont(52);
86  dp->GetXaxis()->SetTitleSize(0.050);
87 
88  dp->GetYaxis()->SetTitle("Events");
89  dp->GetYaxis()->SetTitleOffset(0.7);
90  dp->GetYaxis()->SetLabelFont(52);
91  dp->GetYaxis()->SetLabelSize(0.040);
92  dp->GetYaxis()->SetTitleFont(52);
93  dp->GetYaxis()->SetTitleSize(0.050);
94 
95  dp->Fit("gaus");
96 } // analysis()