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 // Bjorken X smearing 2D plot parameters;
3 #define _X_MIN_ (1E-5)
4 #define _X_MAX_ (1)
5 #define _X_BNUM_ (100)
6 #define _LOGX_BWID_ ((log(_X_MAX_)-log(_X_MIN_))/_X_BNUM_)
7 
8 void analysis()
9 {
10  // Force some beautification;
11  gStyle->SetOptStat(0);
12  gStyle->SetPalette(55, 0);
13  gStyle->SetLabelSize(0.04, "xy");
14  gStyle->SetPadLeftMargin(0.12);
15  gStyle->SetPadBottomMargin(0.13);
16  gStyle->SetTextFont(52);
17 
18  // Calculate binning in log units;
19  double xb[_X_BNUM_+1];
20  for(int ip=0; ip<=_X_BNUM_; ip++)
21  xb [ip] = exp(log(_X_MIN_) + ip*_LOGX_BWID_);
22 
23  // Declare 2D smearing plot;
24  auto xx = new TH2D("xx", "", _X_BNUM_, xb, _X_BNUM_, xb);
25 
26  // Input MC & reconstructed event file;
27  TString mcInFile = "simulation.root";
28  TString rcInFile = "reconstruction.root";
29 
30  // Well, a clear hack for now; have to use this wrapper rather
31  // than ROOT friend declaration and TTree-based GetEntry() calls;
32  auto io = new EicRootManager(mcInFile, 0, rcInFile);
33 
34  // Loop through all events;
35  for(unsigned ev=0; ev<io->GetEicRcTreeEntries(); ev++) {
36  // Get event entry (TTree GetEntry() wrapper which takes care
37  // to establish all the links between different event components);
38  io->GetEicRcTreeEntry(ev);
39 
40  // Get pointers to the reconstructed and respective simulated event parts;
41  auto rcEvent = io->GetEicRcEvent();
42  auto mcEvent = rcEvent->GetGenMcEvent();
43 
44  // If record has no reconstructed tracks, nothing to talk about -> skip;
45  // in fact expect exactly one track (leading electron);
46  if (!rcEvent->GetNTracks()) continue;
47 
48  // Use reconstructed quantities to calculate scattered lepton kinematics;
49  erhic::LeptonKinematicsComputer rcDis(*rcEvent);
50  auto rcKin = rcDis.Calculate();
51 
52  // Use simulated quantities to calculate scattered lepton kinematics;
53  erhic::LeptonKinematicsComputer mcDis(*mcEvent);
54  auto mcKin = mcDis.Calculate();
55 
56  // Fill 2D plot;
57  xx->Fill(mcKin->mX, rcKin->mX);
58 
59  // May want to loop through all the tracks later (if pass all tracks
60  // through the Monte-Carlo rather than just leading lepton);
61  //printf(" -> %2d\n", event->GetNTracks());
62  //for(unsigned tr=0; tr<rcEvent->GetNTracks(); tr++) {
63  //const EicRcParticle *rcTrack = rcEvent->GetTrack(tr);
64  //} //for tr
65  } //for ev
66 
67  // Plotting part (trivial);
68  auto c11 = new TCanvas("c11", "c11", 0, 0, 400, 400);
69  gPad->SetLogx();
70  gPad->SetLogy();
71  gPad->SetLogz();
72  //xx->SetMinimum(2);
73  xx->GetXaxis()->SetTitle("Simulated X_{Bj}");
74  xx->GetXaxis()->SetTitleSize(0.05);
75  xx->GetXaxis()->SetTitleFont(52);
76  xx->GetXaxis()->SetLabelSize(0.04);
77  xx->GetXaxis()->SetLabelFont(52);
78  xx->GetXaxis()->SetTitleOffset(1.2);
79  xx->GetYaxis()->SetTitle("Reconstructed X_{Bj}");
80  xx->GetYaxis()->SetTitleSize(0.05);
81  xx->GetYaxis()->SetTitleFont(52);
82  xx->GetYaxis()->SetLabelSize(0.04);
83  xx->GetYaxis()->SetLabelFont(52);
84  xx->Draw("COLZ");
85 } // analysis()