10 #include <THnSparse.h>
21 TString filename_mc_smeared =
"",
25 gSystem->Load(
"libeicsmear");
28 TFile *file_mc =
new TFile(filename_mc,
"OPEN");
29 TFile *file_mc_smeared =
new TFile(filename_mc_smeared,
"OPEN");
32 TTree *
tree = (TTree*)file_mc->Get(
"EICTree");
33 TTree *tree_smeared = (TTree*)file_mc_smeared->Get(
"Smeared");
39 tree->AddFriend(tree_smeared);
41 erhic::EventPythia *
event = NULL;
42 Smear::Event *eventS = NULL;
44 tree->SetBranchAddress(
"event", &
event);
45 tree->SetBranchAddress(
"eventS", &eventS);
48 TH2F* h_e_smeared_vs_eta =
new TH2F(
"h_e_smeared_vs_eta",
"Energy Smeared vs True Pseudorapidity",100,-5,5,70,0,35);
49 h_e_smeared_vs_eta->GetXaxis()->SetTitle(
"#eta_{true}");
50 h_e_smeared_vs_eta->GetYaxis()->SetTitle(
"E_{smeared} (GeV)");
52 TH2F* h_e_smeared_vs_true =
new TH2F(
"h_e_smeared_vs_true",
"Energy Smeared vs True",60,0,30,70,0,35);
53 h_e_smeared_vs_true->GetXaxis()->SetTitle(
"E_{true} (GeV)");
54 h_e_smeared_vs_true->GetYaxis()->SetTitle(
"E_{smeared} (GeV)");
56 TH1F* h_eta =
new TH1F(
"h_eta",
";#eta;dN/d#eta", 100, -5, 5);
57 TH1F* h_eta_accept = (TH1F*)h_eta->Clone(
"h_eta_accept");
58 h_eta_accept->SetLineColor(kGreen+4);
60 TH1F* h_e_eref_true =
new TH1F(
"h_e_eref_true",
"True reference energy",300,0,30);
61 h_e_eref_true->GetXaxis()->SetTitle(
"E_{true} (GeV)");
62 h_e_eref_true->GetYaxis()->SetTitle(
"# entries");
63 h_e_eref_true->SetLineColor(kRed);
65 TH1F* h_e_eref_smeared =
new TH1F(
"h_e_eref_smeared",
"Smeared reference energy",300,0,30);
66 h_e_eref_smeared->GetXaxis()->SetTitle(
"E_{smeared} (GeV)");
67 h_e_eref_smeared->GetYaxis()->SetTitle(
"# entries");
68 h_e_eref_smeared->SetLineColor(kBlue);
71 unsigned max_event = tree->GetEntries();
73 for (
unsigned ievent = 0; ievent < max_event; ievent++ )
75 if ( ievent%1000 == 0 )
76 cout <<
"Processing event " << ievent << endl;
79 tree->GetEntry(ievent);
82 float y =
event->GetTrueY();
83 if ( y > 0.99 || y < 0.01 )
86 float energy =
event->ScatteredLepton()->GetE();
87 float energy_smeared = eventS->ScatteredLepton()->GetE();
89 float eta =
event->ScatteredLepton()->GetEta();
92 h_e_smeared_vs_eta->Fill(eta,energy_smeared);
93 h_e_smeared_vs_true->Fill(energy,energy_smeared);
96 if ( energy_smeared > 0 )
97 h_eta_accept->Fill( eta );
102 if ( energy > (eref-erange/2.) && energy < (eref+erange/2.) )
104 h_e_eref_true->Fill(energy);
105 h_e_eref_smeared->Fill(energy_smeared);
110 float underflow = tree->GetEntry(0);
111 float overflow = tree->GetEntry(max_event + 1);
112 cout <<
"underflow: " << underflow << endl;
113 cout <<
"overflow: " << overflow << endl;
120 TCanvas *c1 =
new TCanvas();
121 h_e_smeared_vs_true->DrawClone(
"COLZ");
124 TCanvas *
c2 =
new TCanvas();
125 h_e_smeared_vs_eta->DrawClone(
"COLZ");
128 TCanvas *c3 =
new TCanvas();
129 h_e_eref_smeared->Draw();
130 h_e_eref_smeared->Fit(
"gaus");
131 h_e_eref_true->Draw(
"sames");
134 TCanvas *c4 =
new TCanvas();
135 h_eta_accept->Divide(h_eta);
136 h_eta_accept->Draw();