Transition PWG0 -> PWGUD
[u/mrichter/AliRoot.git] / PWGUD / selectors / dNdEta / correct.C
CommitLineData
7a1ac44b 1void loadlibs()
2{
3 gSystem->Load("libTree");
4 gSystem->Load("libVMC");
5
6 gSystem->Load("libSTEERBase");
7 gSystem->Load("libANALYSIS");
8 gSystem->Load("libPWG0base");
9}
10
1d107532 11void FinishAnalysisAll(const char* dataInput = "analysis_esd_raw.root", const char* dataOutput = "analysis_esd.root", const char* correctionMapFile = "correction_map2.root", const char* correctionMapFolder = "dndeta_correction_ua5")
7a1ac44b 12{
13 loadlibs();
14
81be4ee8 15 AlidNdEtaCorrection* dNdEtaCorrection = 0;
16
17 if (correctionMapFile)
18 {
19 dNdEtaCorrection = new AlidNdEtaCorrection(correctionMapFolder, correctionMapFolder);
20 if (!TFile::Open(correctionMapFile))
21 return;
22 dNdEtaCorrection->LoadHistograms();
23 }
24
7a1ac44b 25 TFile* file = TFile::Open(dataInput);
26
27 if (!file)
28 {
29 cout << "Error. File not found" << endl;
30 return;
31 }
81be4ee8 32
33 Int_t backgroundEvents = 0;
34
35 //backgroundEvents = 1162+434; // Michele for MB1, run 104892, 15.02.10
36 //backgroundEvents = 842; // JF estimate for V0 systematic case 1
76532b17 37 //backgroundEvents = 6; // Michele for V0AND, run 104892, 15.02.10
81be4ee8 38
39 //backgroundEvents = 1758+434; // MB1, run 104867-92
40
41 //backgroundEvents = 4398+961; // Michele for MB1, run 104824-52, 16.02.10
42 //backgroundEvents = 19; // Michele for V0AND, run 104824-52, 16.02.10
43
76532b17 44 backgroundEvents = -1; // use 0 bin from MC! for 2.36 TeV
81be4ee8 45 //backgroundEvents = 900; // my estimate for 2.36 TeV
46
47 //backgroundEvents = 918; // V0OR for run 114786 w/o bunch intensities w/o proper 0 checking!
48 //backgroundEvents = 723; // V0OR for run 114798 w/o bunch intensities w/o proper 0 checking!
49
50 Printf("Subtracting %d background events!!!", backgroundEvents);
51 gSystem->Sleep(1000);
52
53 TH1* combinatoricsCorrection = 0;
54 if (1)
55 {
56 TFile::Open("corrComb.root");
57 combinatoricsCorrection = (TH1*) gFile->Get("ratioofratios");
76532b17 58 if (!combinatoricsCorrection)
59 combinatoricsCorrection = (TH1*) gFile->Get("correctiondNdEta");
81be4ee8 60 file->cd();
61 }
62
63 // Note: the last parameter does not define which analysis is going to happen, the histograms will be overwritten when loading from the file
7a1ac44b 64 dNdEtaAnalysis* fdNdEtaAnalysis = new dNdEtaAnalysis("dndetaNSD", "dndetaNSD");
65 fdNdEtaAnalysis->LoadHistograms("fdNdEtaAnalysisESD");
81be4ee8 66 fdNdEtaAnalysis->Finish(dNdEtaCorrection, 0.151, AlidNdEtaCorrection::kNSD, "ESD -> NSD", backgroundEvents, combinatoricsCorrection);
7a1ac44b 67 //fdNdEtaAnalysis->DrawHistograms(kTRUE);
68 TFile* file2 = TFile::Open(dataOutput, "RECREATE");
69 fdNdEtaAnalysis->SaveHistograms();
81be4ee8 70
7a1ac44b 71 file->cd();
72 dNdEtaAnalysis* fdNdEtaAnalysis = new dNdEtaAnalysis("dndeta", "dndeta");
73 fdNdEtaAnalysis->LoadHistograms("fdNdEtaAnalysisESD");
81be4ee8 74 fdNdEtaAnalysis->Finish(dNdEtaCorrection, 0.151, AlidNdEtaCorrection::kINEL, "ESD -> full inelastic", backgroundEvents, combinatoricsCorrection);
7a1ac44b 75 //fdNdEtaAnalysis->DrawHistograms(kTRUE);
76 file2->cd();
77 fdNdEtaAnalysis->SaveHistograms();
78
79 file->cd();
80 fdNdEtaAnalysis = new dNdEtaAnalysis("dndetaTr", "dndetaTr");
81 fdNdEtaAnalysis->LoadHistograms("fdNdEtaAnalysisESD");
81be4ee8 82 fdNdEtaAnalysis->Finish(dNdEtaCorrection, 0.151, AlidNdEtaCorrection::kVertexReco, "ESD -> minimum bias", backgroundEvents, combinatoricsCorrection);
7a1ac44b 83 //fdNdEtaAnalysis->DrawHistograms(kTRUE);
84 file2->cd();
85 fdNdEtaAnalysis->SaveHistograms();
86
87 file->cd();
88 fdNdEtaAnalysis = new dNdEtaAnalysis("dndetaTrVtx", "dndetaTrVtx");
89 fdNdEtaAnalysis->LoadHistograms("fdNdEtaAnalysisESD");
81be4ee8 90 fdNdEtaAnalysis->Finish(dNdEtaCorrection, 0.151, AlidNdEtaCorrection::kTrack2Particle, "ESD -> MB with vertex", backgroundEvents, combinatoricsCorrection);
7a1ac44b 91 //fdNdEtaAnalysis->DrawHistograms(kTRUE);
92 file2->cd();
93 fdNdEtaAnalysis->SaveHistograms();
94
95 file->cd();
96 fdNdEtaAnalysis = new dNdEtaAnalysis("dndetaTracks", "dndetaTracks");
97 fdNdEtaAnalysis->LoadHistograms("fdNdEtaAnalysisESD");
81be4ee8 98 fdNdEtaAnalysis->Finish(0, 0.151, AlidNdEtaCorrection::kNone, "ESD raw with pt cut", backgroundEvents, combinatoricsCorrection);
7a1ac44b 99 //fdNdEtaAnalysis->DrawHistograms(kTRUE);
100 file2->cd();
101 fdNdEtaAnalysis->SaveHistograms();
102
103 file->cd();
104 fdNdEtaAnalysis = new dNdEtaAnalysis("dndetaTracksAll", "dndetaTracksAll");
105 fdNdEtaAnalysis->LoadHistograms("fdNdEtaAnalysisESD");
81be4ee8 106 fdNdEtaAnalysis->Finish(0, -1, AlidNdEtaCorrection::kNone, "ESD raw", backgroundEvents, combinatoricsCorrection);
107 //fdNdEtaAnalysis->DrawHistograms(kTRUE);
108 file2->cd();
109 fdNdEtaAnalysis->SaveHistograms();
110
111 file->cd();
112 fdNdEtaAnalysis = new dNdEtaAnalysis("dndetaOnePart", "dndetaOnePart");
113 fdNdEtaAnalysis->LoadHistograms("fdNdEtaAnalysisESD");
114 fdNdEtaAnalysis->Finish(dNdEtaCorrection, 0.151, AlidNdEtaCorrection::kOnePart, "ESD -> OnePart", backgroundEvents, combinatoricsCorrection);
7a1ac44b 115 //fdNdEtaAnalysis->DrawHistograms(kTRUE);
116 file2->cd();
117 fdNdEtaAnalysis->SaveHistograms();
118
119 file2->Write();
120 file2->Close();
121}
122
123void* FinishAnalysis(const char* analysisFile = "analysis_esd_raw.root", const char* analysisDir = "fdNdEtaAnalysisESD", const char* correctionMapFile = "correction_map.root", const char* correctionMapFolder = "dndeta_correction", Bool_t useUncorrected = kFALSE, Bool_t simple = kFALSE)
124{
125 loadlibs();
126
127 TFile* file = TFile::Open(analysisFile);
128
129 dNdEtaAnalysis* fdNdEtaAnalysis = new dNdEtaAnalysis(analysisDir, analysisDir);
130 fdNdEtaAnalysis->LoadHistograms();
131
132 if (correctionMapFile)
133 {
134 AlidNdEtaCorrection* dNdEtaCorrection = new AlidNdEtaCorrection(correctionMapFolder, correctionMapFolder);
135 TFile::Open(correctionMapFile);
136 dNdEtaCorrection->LoadHistograms();
137
81be4ee8 138 fdNdEtaAnalysis->Finish(dNdEtaCorrection, 0.151, AlidNdEtaCorrection::kINEL);
7a1ac44b 139 //fdNdEtaAnalysis->Finish(dNdEtaCorrection, 0, AlidNdEtaCorrection::kINEL);
140 //fdNdEtaAnalysis->Finish(dNdEtaCorrection, 0, AlidNdEtaCorrection::kTrack2Particle);
141 }
142 else
81be4ee8 143 fdNdEtaAnalysis->Finish(0, 0.151, AlidNdEtaCorrection::kNone);
7a1ac44b 144
81be4ee8 145 return fdNdEtaAnalysis;
146
7a1ac44b 147 fdNdEtaAnalysis->DrawHistograms(simple);
148
149 TH1* hist = fdNdEtaAnalysis->GetdNdEtaHistogram(1);
150 Int_t binLeft = hist->GetXaxis()->FindBin(-0.5);
151 Int_t binRight = hist->GetXaxis()->FindBin(0.5);
152 Float_t value1 = hist->Integral(binLeft, binRight);
153
154 hist = fdNdEtaAnalysis->GetdNdEtaHistogram(2);
155 Float_t value2 = hist->Integral(binLeft, binRight);
156
157 if (value2 > 0)
158 printf("Ratio is %f, values are %f %f\n", value1 / value2, value1, value2);
159
160 return fdNdEtaAnalysis;
161}
162
81be4ee8 163void FinishMC()
b0913a13 164{
81be4ee8 165 loadlibs();
166
167 result1 = (dNdEtaAnalysis*) FinishAnalysis("analysis_mc.root", "dndeta", 0, 0, 1);
168 result2 = (dNdEtaAnalysis*) FinishAnalysis("analysis_mc.root", "dndetaNSD", 0, 0, 1);
169
170 file = TFile::Open("out.root", "RECREATE");
171 result1->SaveHistograms();
172 result2->SaveHistograms();
173 file->Close();
174}
175
176void correct(Bool_t onlyESD = kFALSE, Bool_t mergedXSections = kTRUE)
177{
178 gSystem->Unlink("analysis_esd.root");
179 if (mergedXSections)
180 FinishAnalysisAll("analysis_esd_raw.root", "analysis_esd.root", "correction_map2.root", "dndeta_correction_ua5");
181 else
182 FinishAnalysisAll("analysis_esd_raw.root", "analysis_esd.root", "correction_map.root", "dndeta_correction");
183
b0913a13 184 gROOT->ProcessLine(".L $ALICE_ROOT/PWG0/dNdEta/drawPlots.C");
69b09e3b 185 dNdEta(onlyESD);
b0913a13 186}
187
188