/
MakeHistsForSlides.C
97 lines (78 loc) · 2.42 KB
/
MakeHistsForSlides.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
Double_t MakeHistsForSlides(TString goodFile, TString badFile, TString rootFile)
{
//Extracting the histogram
TFile* f = TFile::Open(rootFile);
TDirectoryFile* dirFile = (TDirectoryFile*)(f->Get("AliAnalysisTaskCalibEmcal"));
TList* list = (TList*)(dirFile->Get("histogram"));
TH2D* cellVAmplitude = (TH2D*)(list->FindObject("_histogram_cell_id_amplitude"));
//Getting a Good Cell
TH1D* goodC = new TH1D();
ifstream myFile(goodFile);
TString title = "";
const int num = 500;
if(myFile.is_open())
{
string line = "";
std::getline(myFile,line);
int index = 0;
double chi2 = 0.0;
while(myFile >> index >> chi2 && index < num)
{
//cout << index << "\t" << chi2 << endl;
title = Form("Energy distribution of Cell %d",index);
TH1D* goodCell = cellVAmplitude->ProjectionY("goodCell", index+1,index+1);
goodC = (TH1D*)goodCell->Clone();
}
}
myFile.close();
Int_t bins = goodC->GetSize()-2;//minus for the over and underflow ins
for(int i = 1; i < bins+1; i++)
{
double dE = goodC->GetBinWidth(i);
double dN = goodC->GetBinContent(i);
double newContent = dN/dE;
goodC->SetBinContent(i,newContent);
}
TCanvas* c3 = new TCanvas("c3","c3",500,500);
c3->SetLogx();
c3->SetLogy();
goodC->SetTitle(title);
goodC->GetXaxis()->SetTitle("E (GeV)");
goodC->GetYaxis()->SetTitle("dN/dE");
gStyle->SetOptStat(0);
goodC->Draw();//*/
//Getting a Bad Cell
TH1D* badC = new TH1D();
ifstream badList(badFile);
TString title2 = "";
if(badList.is_open())
{
string line = "";
std::getline(badList,line);
int index = 0;
double chi1, chi2;
while(badList >> index >> chi2 && index < num)
{
title2 = Form("Energy distribution of Cell %d",index);
TH1D* badCell = cellVAmplitude->ProjectionY("badCell", index+1,index+1);
badC = (TH1D*)badCell->Clone();
}
}
badList.close();
Int_t bins2 = badC->GetSize()-2;//minus for the over and underflow ins
for(int i = 1; i < bins2+1; i++)
{
double dE = badC->GetBinWidth(i);
double dN = badC->GetBinContent(i);
double newContent = dN/dE;
badC->SetBinContent(i,newContent);
}
TCanvas* c4 = new TCanvas("c4","c4",500,500);
c4->SetLogx();
c4->SetLogy();
badC->SetTitle(title2);
badC->GetXaxis()->SetTitle("E (GeV)");
badC->GetYaxis()->SetTitle("dN/dE");
gStyle->SetOptStat(0);
badC->Draw();//*/
}