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, -50., 50.);
20  TH1D *dp = new TH1D("dp", "dp", 200, -1., 1.);
21 
22  // Loop through all events; NB: for box-generated events without secondaries
23  // could simply use cbmsim->Project() as well; in general EicEventAssembler
24  // should be used for "true" physics events;
25  int nEvents = cbmsim->GetEntries();
26  for(unsigned ev=0; ev<nEvents; ev++) {
27  cbmsim->GetEntry(ev);
28 
29  // Loop through all reconstructed tracks;
30  for(unsigned rc=0; rc<rcTrackArray->GetEntriesFast(); rc++) {
31  PndPidCandidate *rctrack = rcTrackArray->At(rc);
32  int mcTrackId = rctrack->GetMcIndex();
33 
34  // Select only correctly rc->mc identified tracks;
35  if (mcTrackId < 0 || mcTrackId >= mcTrackArray->GetEntriesFast()) continue;
36 
37  // Find MC track associated with this reconstructed track;
38  PndMCTrack *mctrack = mcTrackArray->At(mcTrackId);
39 
40  //printf("%f\n", mctrack->GetMomentum().Mag());
41  // Well, for plotting select primary pi-minus tracks only (see simulation.C);
42  if (mctrack->GetPdgCode() == 2212 && mctrack->GetMotherID() == -1)
43  //dp->Fill(100.*(rctrack->GetMomentum().Mag() - mctrack->GetMomentum().Mag())/mctrack->GetMomentum().Mag());
44  dp->Fill(rctrack->GetMomentum().Pt() - mctrack->GetMomentum().Pt());
45  } //for rc
46  } //for ev
47 
48  //gStyle->SetOptStat(0);
49 
50  dp->SetTitle("Momentum resolution");
51 
52  //dp->GetXaxis()->SetTitle("(P_{rec} - P_{sim})/P_{sim}, [%]");
53  dp->GetXaxis()->SetTitle("Pt_{rec} - Pt_{sim}, [GeV/c]");
54  dp->GetXaxis()->SetTitleOffset(0.9);
55  dp->GetXaxis()->SetLabelFont(52);
56  dp->GetXaxis()->SetLabelSize(0.040);
57  dp->GetXaxis()->SetTitleFont(52);
58  dp->GetXaxis()->SetTitleSize(0.050);
59 
60  dp->GetYaxis()->SetTitle("Events");
61  dp->GetYaxis()->SetTitleOffset(0.7);
62  dp->GetYaxis()->SetLabelFont(52);
63  dp->GetYaxis()->SetLabelSize(0.040);
64  dp->GetYaxis()->SetTitleFont(52);
65  dp->GetYaxis()->SetTitleSize(0.050);
66 
67  dp->Fit("gaus");
68 } // analysis()