]>
Commit | Line | Data |
---|---|---|
dc740de4 | 1 | /* $Id$ */ |
2 | ||
75ec0f41 | 3 | #include "dNdEtaAnalysis.h" |
4 | ||
ceb5d1b5 | 5 | #include <TFile.h> |
45e97e28 | 6 | #include <TH3F.h> |
74fd10b3 | 7 | #include <TH2F.h> |
8 | #include <TH1F.h> | |
ceb5d1b5 | 9 | #include <TMath.h> |
10 | #include <TCanvas.h> | |
7029240a | 11 | #include <TCollection.h> |
12 | #include <TIterator.h> | |
13 | #include <TList.h> | |
fcf2fb36 | 14 | #include <TLegend.h> |
74fd10b3 | 15 | #include <TLine.h> |
fcf2fb36 | 16 | |
45e97e28 | 17 | #include "AlidNdEtaCorrection.h" |
74fd10b3 | 18 | #include <AliCorrection.h> |
19 | #include <AliPWG0Helper.h> | |
20 | #include <AliCorrectionMatrix2D.h> | |
21 | #include <AliCorrectionMatrix3D.h> | |
ceb5d1b5 | 22 | |
75ec0f41 | 23 | //____________________________________________________________________ |
b7f4a1fd | 24 | ClassImp(dNdEtaAnalysis) |
75ec0f41 | 25 | |
1afae8ff | 26 | //____________________________________________________________________ |
27 | dNdEtaAnalysis::dNdEtaAnalysis() : | |
28 | TNamed(), | |
29 | fData(0), | |
1afae8ff | 30 | fPtDist(0) |
31 | { | |
32 | // default constructor | |
33 | ||
34 | for (Int_t i=0; i<kVertexBinning; ++i) | |
35 | { | |
36 | fdNdEta[i] = 0; | |
37 | fdNdEtaPtCutOffCorrected[i] = 0; | |
38 | } | |
39 | } | |
40 | ||
75ec0f41 | 41 | //____________________________________________________________________ |
7029240a | 42 | dNdEtaAnalysis::dNdEtaAnalysis(Char_t* name, Char_t* title) : |
16e24ca3 | 43 | TNamed(name, title), |
45e97e28 | 44 | fData(0), |
1afae8ff | 45 | fPtDist(0) |
7029240a | 46 | { |
6bf0714d | 47 | // constructor |
4dd2ad81 | 48 | |
74fd10b3 | 49 | Float_t binLimitsPt[] = {0.0, 0.05, 0.1, 0.125, 0.15, 0.175, 0.2, 0.225, 0.25, 0.275, 0.3, 0.325, 0.35, 0.375, 0.4, 0.425, 0.45, 0.475, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.5, 2.0, 5.0, 10.0, 100.0}; |
6bf0714d | 50 | |
74fd10b3 | 51 | fData = new AliCorrection("Analysis", Form("%s Analysis", title)); |
45e97e28 | 52 | |
74fd10b3 | 53 | // do not add this hists to the directory |
54 | Bool_t oldStatus = TH1::AddDirectoryStatus(); | |
55 | TH1::AddDirectory(kFALSE); | |
1afae8ff | 56 | |
0448e811 | 57 | fdNdEta[0] = new TH1F("dNdEta", "dN_{ch}/d#eta;#eta;dN_{ch}/d#eta", 40, -2, 2); |
74fd10b3 | 58 | |
59 | fdNdEtaPtCutOffCorrected[0] = dynamic_cast<TH1F*> (fdNdEta[0]->Clone(Form("%s_corrected", fdNdEta[0]->GetName()))); | |
1afae8ff | 60 | |
45e97e28 | 61 | for (Int_t i=1; i<kVertexBinning; ++i) |
7029240a | 62 | { |
74fd10b3 | 63 | fdNdEta[i] = dynamic_cast<TH1F*> (fdNdEta[0]->Clone(Form("%s_%d", fdNdEta[0]->GetName(), i))); |
64 | fdNdEtaPtCutOffCorrected[i] = dynamic_cast<TH1F*> (fdNdEtaPtCutOffCorrected[0]->Clone(Form("%s_%d", fdNdEtaPtCutOffCorrected[0]->GetName(), i))); | |
7029240a | 65 | } |
75ec0f41 | 66 | |
74fd10b3 | 67 | fPtDist = new TH1F("Pt", "p_{T} distribution;p_{T} [GeV/c];#frac{dN}{d#eta dp_{T}} [c/GeV]", 28, binLimitsPt); |
68 | ||
69 | TH1::AddDirectory(oldStatus); | |
75ec0f41 | 70 | } |
71 | ||
16e24ca3 | 72 | //____________________________________________________________________ |
73 | dNdEtaAnalysis::~dNdEtaAnalysis() | |
74 | { | |
75 | // destructor | |
76 | ||
0ab29cfa | 77 | if (fData) |
78 | { | |
79 | delete fData; | |
80 | fData = 0; | |
81 | } | |
16e24ca3 | 82 | |
16e24ca3 | 83 | for (Int_t i=0; i<kVertexBinning; ++i) |
84 | { | |
0ab29cfa | 85 | if (fdNdEta[i]) |
86 | { | |
87 | delete fdNdEta[i]; | |
88 | fdNdEta[i] = 0; | |
89 | } | |
90 | if (fdNdEtaPtCutOffCorrected[i]) | |
91 | { | |
92 | delete fdNdEtaPtCutOffCorrected[i]; | |
93 | fdNdEtaPtCutOffCorrected[i] = 0; | |
94 | } | |
16e24ca3 | 95 | } |
1afae8ff | 96 | |
0ab29cfa | 97 | if (fPtDist) |
98 | { | |
99 | delete fPtDist; | |
100 | fPtDist = 0; | |
101 | } | |
16e24ca3 | 102 | } |
103 | ||
104 | //_____________________________________________________________________________ | |
105 | dNdEtaAnalysis::dNdEtaAnalysis(const dNdEtaAnalysis &c) : | |
106 | TNamed(c), | |
45e97e28 | 107 | fData(0), |
1afae8ff | 108 | fPtDist(0) |
16e24ca3 | 109 | { |
110 | // | |
111 | // dNdEtaAnalysis copy constructor | |
112 | // | |
113 | ||
114 | ((dNdEtaAnalysis &) c).Copy(*this); | |
115 | } | |
116 | ||
117 | //_____________________________________________________________________________ | |
118 | dNdEtaAnalysis &dNdEtaAnalysis::operator=(const dNdEtaAnalysis &c) | |
119 | { | |
120 | // | |
121 | // Assignment operator | |
122 | // | |
123 | ||
124 | if (this != &c) ((dNdEtaAnalysis &) c).Copy(*this); | |
125 | return *this; | |
126 | } | |
127 | ||
128 | //_____________________________________________________________________________ | |
129 | void dNdEtaAnalysis::Copy(TObject &c) const | |
130 | { | |
131 | // | |
132 | // Copy function | |
133 | // | |
134 | ||
135 | dNdEtaAnalysis& target = (dNdEtaAnalysis &) c; | |
136 | ||
74fd10b3 | 137 | target.fData = dynamic_cast<AliCorrection*> (fData->Clone()); |
16e24ca3 | 138 | |
139 | for (Int_t i=0; i<kVertexBinning; ++i) | |
1afae8ff | 140 | { |
74fd10b3 | 141 | target.fdNdEta[i] = dynamic_cast<TH1F*> (fdNdEta[i]->Clone()); |
142 | target.fdNdEtaPtCutOffCorrected[i] = dynamic_cast<TH1F*> (fdNdEtaPtCutOffCorrected[i]->Clone()); | |
1afae8ff | 143 | } |
16e24ca3 | 144 | |
74fd10b3 | 145 | target.fPtDist = dynamic_cast<TH1F*> (fPtDist->Clone()); |
45e97e28 | 146 | |
16e24ca3 | 147 | TNamed::Copy((TNamed &) c); |
148 | } | |
149 | ||
75ec0f41 | 150 | //____________________________________________________________________ |
74fd10b3 | 151 | void dNdEtaAnalysis::FillTrack(Float_t vtx, Float_t eta, Float_t pt) |
6bf0714d | 152 | { |
153 | // fills a track into the histograms | |
154 | ||
74fd10b3 | 155 | fData->GetTrackCorrection()->FillMeas(vtx, eta, pt); |
75ec0f41 | 156 | } |
157 | ||
158 | //____________________________________________________________________ | |
74fd10b3 | 159 | void dNdEtaAnalysis::FillEvent(Float_t vtx, Float_t n) |
6bf0714d | 160 | { |
161 | // fills an event into the histograms | |
162 | ||
74fd10b3 | 163 | fData->GetEventCorrection()->FillMeas(vtx, n); |
75ec0f41 | 164 | } |
165 | ||
166 | //____________________________________________________________________ | |
74fd10b3 | 167 | void dNdEtaAnalysis::Finish(AlidNdEtaCorrection* correction, Float_t ptCut, AlidNdEtaCorrection::CorrectionType correctionType) |
fcf2fb36 | 168 | { |
74fd10b3 | 169 | // |
170 | // correct with the given correction values and calculate dNdEta and pT distribution | |
171 | // the corrections that are applied can be steered by the flag correctionType | |
172 | // | |
173 | ||
174 | // TODO put tag somewhere which corrections have been applied | |
175 | ||
176 | // set corrections to 1 | |
177 | fData->SetCorrectionToUnity(); | |
178 | ||
179 | if (correction && correctionType != AlidNdEtaCorrection::kNone) | |
180 | { | |
181 | TH3F* trackCorr = fData->GetTrackCorrection()->GetCorrectionHistogram(); | |
182 | TH2F* eventCorr = fData->GetEventCorrection()->GetCorrectionHistogram(); | |
183 | ||
184 | if (correctionType >= AlidNdEtaCorrection::kTrack2Particle) | |
185 | trackCorr->Multiply(correction->GetTrack2ParticleCorrection()->GetTrackCorrection()->GetCorrectionHistogram()); | |
6bf0714d | 186 | |
74fd10b3 | 187 | if (correctionType >= AlidNdEtaCorrection::kVertexReco) |
188 | { | |
189 | trackCorr->Multiply(correction->GetVertexRecoCorrection()->GetTrackCorrection()->GetCorrectionHistogram()); | |
190 | eventCorr->Multiply(correction->GetVertexRecoCorrection()->GetEventCorrection()->GetCorrectionHistogram()); | |
191 | } | |
192 | ||
193 | switch (correctionType) | |
194 | { | |
195 | case AlidNdEtaCorrection::kINEL : | |
196 | { | |
197 | trackCorr->Multiply(correction->GetTriggerBiasCorrectionINEL()->GetTrackCorrection()->GetCorrectionHistogram()); | |
198 | eventCorr->Multiply(correction->GetTriggerBiasCorrectionINEL()->GetEventCorrection()->GetCorrectionHistogram()); | |
199 | break; | |
200 | } | |
201 | case AlidNdEtaCorrection::kNSD : | |
202 | { | |
203 | trackCorr->Multiply(correction->GetTriggerBiasCorrectionNSD()->GetTrackCorrection()->GetCorrectionHistogram()); | |
204 | eventCorr->Multiply(correction->GetTriggerBiasCorrectionNSD()->GetEventCorrection()->GetCorrectionHistogram()); | |
205 | break; | |
206 | } | |
207 | case AlidNdEtaCorrection::kND : | |
208 | { | |
209 | trackCorr->Multiply(correction->GetTriggerBiasCorrectionND()->GetTrackCorrection()->GetCorrectionHistogram()); | |
210 | eventCorr->Multiply(correction->GetTriggerBiasCorrectionND()->GetEventCorrection()->GetCorrectionHistogram()); | |
211 | break; | |
212 | } | |
213 | default : break; | |
214 | } | |
215 | } | |
216 | else | |
fcf2fb36 | 217 | printf("INFO: No correction applied\n"); |
218 | ||
74fd10b3 | 219 | fData->Multiply(); |
220 | ||
221 | TH3F* dataHist = fData->GetTrackCorrection()->GetGeneratedHistogram(); | |
222 | ||
223 | // integrate multiplicity axis out (include under/overflow bins!!!) | |
224 | TH2F* tmp = fData->GetEventCorrection()->GetGeneratedHistogram(); | |
225 | TH1D* vertexHist = tmp->ProjectionX("_px", 0, tmp->GetNbinsY() + 1, "e"); | |
fcf2fb36 | 226 | |
1afae8ff | 227 | // create pt hist |
228 | { | |
229 | // reset all ranges | |
74fd10b3 | 230 | dataHist->GetXaxis()->SetRange(0, 0); |
231 | dataHist->GetYaxis()->SetRange(0, 0); | |
232 | dataHist->GetZaxis()->SetRange(0, 0); | |
1afae8ff | 233 | |
234 | // vtx cut | |
74fd10b3 | 235 | Int_t vertexBinBegin = dataHist->GetXaxis()->FindBin(-5); |
236 | Int_t vertexBinEnd = dataHist->GetXaxis()->FindBin(5); | |
237 | dataHist->GetXaxis()->SetRange(vertexBinBegin, vertexBinEnd); | |
238 | Float_t nEvents = vertexHist->Integral(vertexBinBegin, vertexBinEnd); | |
1afae8ff | 239 | |
74fd10b3 | 240 | if (nEvents > 0) |
241 | { | |
242 | // eta cut | |
243 | dataHist->GetYaxis()->SetRange(dataHist->GetYaxis()->FindBin(-0.8), dataHist->GetYaxis()->FindBin(0.8)); | |
244 | Float_t etaWidth = 1.6; | |
1afae8ff | 245 | |
74fd10b3 | 246 | TH1D* ptHist = dynamic_cast<TH1D*> (dataHist->Project3D("ze")); |
1afae8ff | 247 | |
74fd10b3 | 248 | for (Int_t i=1; i<=fPtDist->GetNbinsX(); ++i) |
249 | { | |
250 | Float_t binSize = fPtDist->GetBinWidth(i); | |
251 | fPtDist->SetBinContent(i, ptHist->GetBinContent(i) / binSize / nEvents / etaWidth); | |
252 | fPtDist->SetBinError(i, ptHist->GetBinError(i) / binSize / nEvents / etaWidth); | |
253 | } | |
1afae8ff | 254 | |
74fd10b3 | 255 | delete ptHist; |
256 | } | |
257 | else | |
258 | printf("ERROR: nEvents is 0!\n"); | |
1afae8ff | 259 | } |
260 | ||
261 | // reset all ranges | |
74fd10b3 | 262 | dataHist->GetXaxis()->SetRange(0, 0); |
263 | dataHist->GetYaxis()->SetRange(0, 0); | |
264 | dataHist->GetZaxis()->SetRange(0, 0); | |
1afae8ff | 265 | |
847489f7 | 266 | // integrate over pt (with pt cut) |
1afae8ff | 267 | Int_t ptLowBin = 1; |
268 | if (ptCut > 0) | |
74fd10b3 | 269 | ptLowBin = dataHist->GetZaxis()->FindBin(ptCut); |
1afae8ff | 270 | |
74fd10b3 | 271 | dataHist->GetZaxis()->SetRange(ptLowBin, dataHist->GetZaxis()->GetNbins()); |
272 | printf("range %d %d\n", ptLowBin, dataHist->GetZaxis()->GetNbins()); | |
273 | TH2D* vtxVsEta = dynamic_cast<TH2D*> (dataHist->Project3D("yx2e")); | |
274 | ||
275 | dataHist->GetZaxis()->SetRange(0, 0); | |
276 | vtxVsEta->GetXaxis()->SetTitle(dataHist->GetXaxis()->GetTitle()); | |
277 | vtxVsEta->GetYaxis()->SetTitle(dataHist->GetYaxis()->GetTitle()); | |
1afae8ff | 278 | |
847489f7 | 279 | if (vtxVsEta == 0) |
280 | { | |
281 | printf("ERROR: pt integration failed\n"); | |
282 | return; | |
fcf2fb36 | 283 | } |
284 | ||
0448e811 | 285 | const Float_t vertexRange = 9.99; |
b4b9cacc | 286 | |
74fd10b3 | 287 | for (Int_t iEta=1; iEta<=vtxVsEta->GetNbinsY(); iEta++) |
5af55649 | 288 | { |
7029240a | 289 | // do we have several histograms for different vertex positions? |
b4b9cacc | 290 | Int_t vertexBinGlobalBegin = vertexHist->GetXaxis()->FindBin(-vertexRange); |
291 | Int_t vertexBinWidth = (vertexHist->GetXaxis()->FindBin(vertexRange) - vertexBinGlobalBegin + 1) / (kVertexBinning-1); | |
292 | //printf("vertexBinGlobalBegin = %d, vertexBinWidth = %d\n", vertexBinGlobalBegin, vertexBinWidth); | |
7029240a | 293 | for (Int_t vertexPos=0; vertexPos<kVertexBinning; ++vertexPos) |
294 | { | |
b4b9cacc | 295 | Int_t vertexBinBegin = vertexBinGlobalBegin; |
296 | Int_t vertexBinEnd = vertexBinGlobalBegin + vertexBinWidth * (kVertexBinning-1); | |
fcf2fb36 | 297 | |
298 | // the first histogram is always for the whole vertex range | |
299 | if (vertexPos > 0) | |
300 | { | |
b4b9cacc | 301 | vertexBinBegin = vertexBinGlobalBegin + vertexBinWidth * (vertexPos-1); |
fcf2fb36 | 302 | vertexBinEnd = vertexBinBegin + vertexBinWidth; |
303 | } | |
7029240a | 304 | |
b4b9cacc | 305 | //printf("vertexBinBegin = %d, vertexBinEnd = %d\n", vertexBinBegin, vertexBinEnd); |
306 | ||
74fd10b3 | 307 | Float_t totalEvents = vertexHist->Integral(vertexBinBegin, vertexBinEnd - 1); |
5af55649 | 308 | if (totalEvents == 0) |
309 | { | |
310 | printf("WARNING: No events for hist %d %d %d\n", vertexPos, vertexBinBegin, vertexBinEnd); | |
311 | continue; | |
7029240a | 312 | } |
7029240a | 313 | |
5af55649 | 314 | Float_t sum = 0; |
315 | Float_t sumError2 = 0; | |
316 | for (Int_t iVtx = vertexBinBegin; iVtx < vertexBinEnd; iVtx++) | |
317 | { | |
847489f7 | 318 | if (vtxVsEta->GetBinContent(iVtx, iEta) != 0) |
5af55649 | 319 | { |
847489f7 | 320 | sum = sum + vtxVsEta->GetBinContent(iVtx, iEta); |
321 | sumError2 = sumError2 + TMath::Power(vtxVsEta->GetBinError(iVtx, iEta),2); | |
5af55649 | 322 | } |
323 | } | |
7029240a | 324 | |
1afae8ff | 325 | Float_t ptCutOffCorrection = 1; |
74fd10b3 | 326 | if (correction && ptCut > 0) |
327 | ptCutOffCorrection = correction->GetMeasuredFraction(correctionType, ptCut, vtxVsEta->GetYaxis()->GetBinCenter(iEta)); | |
1afae8ff | 328 | |
847489f7 | 329 | if (ptCutOffCorrection <= 0) |
330 | { | |
331 | printf("UNEXPECTED: ptCutOffCorrection is %f for hist %d %d %d\n", ptCutOffCorrection, vertexPos, vertexBinBegin, vertexBinEnd); | |
332 | continue; | |
333 | } | |
334 | ||
74fd10b3 | 335 | printf("Eta: %d Vertex Range: %d %d, Event Count %f, Track Sum: %f, Track Sum corrected: %f\n", iEta, vertexBinBegin, vertexBinEnd, totalEvents, sum, sum / ptCutOffCorrection); |
336 | ||
1afae8ff | 337 | Float_t dndeta = sum / totalEvents; |
338 | Float_t error = TMath::Sqrt(sumError2) / totalEvents; | |
7029240a | 339 | |
6bf0714d | 340 | dndeta = dndeta/fdNdEta[vertexPos]->GetBinWidth(iEta); |
341 | error = error/fdNdEta[vertexPos]->GetBinWidth(iEta); | |
7029240a | 342 | |
6bf0714d | 343 | fdNdEta[vertexPos]->SetBinContent(iEta, dndeta); |
344 | fdNdEta[vertexPos]->SetBinError(iEta, error); | |
1afae8ff | 345 | |
346 | dndeta /= ptCutOffCorrection; | |
347 | error /= ptCutOffCorrection; | |
348 | ||
349 | fdNdEtaPtCutOffCorrected[vertexPos]->SetBinContent(iEta, dndeta); | |
350 | fdNdEtaPtCutOffCorrected[vertexPos]->SetBinError(iEta, error); | |
75ec0f41 | 351 | } |
847489f7 | 352 | } |
75ec0f41 | 353 | } |
354 | ||
75ec0f41 | 355 | //____________________________________________________________________ |
6bf0714d | 356 | void dNdEtaAnalysis::SaveHistograms() |
357 | { | |
358 | // save the histograms to a directory with the name of this class (retrieved from TNamed) | |
75ec0f41 | 359 | |
7029240a | 360 | gDirectory->mkdir(GetName()); |
361 | gDirectory->cd(GetName()); | |
5fbd0b17 | 362 | |
1afae8ff | 363 | if (fData) |
364 | { | |
74fd10b3 | 365 | fData->SaveHistograms(); |
1afae8ff | 366 | } |
367 | else | |
368 | printf("dNdEtaAnalysis::SaveHistograms: UNEXPECTED: fData is 0\n"); | |
369 | ||
d09fb536 | 370 | if (fPtDist) |
371 | fPtDist ->Write(); | |
372 | else | |
373 | printf("dNdEtaAnalysis::SaveHistograms: UNEXPECTED: fPtDist is 0\n"); | |
374 | ||
7029240a | 375 | for (Int_t i=0; i<kVertexBinning; ++i) |
1afae8ff | 376 | { |
377 | if (fdNdEta[i]) | |
378 | fdNdEta[i]->Write(); | |
379 | else | |
380 | printf("dNdEtaAnalysis::SaveHistograms: UNEXPECTED: fdNdEta[%d] is 0\n", i); | |
381 | ||
382 | if (fdNdEtaPtCutOffCorrected[i]) | |
383 | fdNdEtaPtCutOffCorrected[i]->Write(); | |
384 | else | |
385 | printf("dNdEtaAnalysis::SaveHistograms: UNEXPECTED: fdNdEtaPtCutOffCorrected[%d] is 0\n", i); | |
386 | } | |
75ec0f41 | 387 | |
388 | gDirectory->cd("../"); | |
389 | } | |
390 | ||
74fd10b3 | 391 | void dNdEtaAnalysis::LoadHistograms(const Char_t* dir) |
5fbd0b17 | 392 | { |
6bf0714d | 393 | // loads the histograms from a directory with the name of this class (retrieved from TNamed) |
394 | ||
74fd10b3 | 395 | if (!dir) |
396 | dir = GetName(); | |
5fbd0b17 | 397 | |
74fd10b3 | 398 | gDirectory->cd(dir); |
5fbd0b17 | 399 | |
74fd10b3 | 400 | fData->LoadHistograms(); |
5fbd0b17 | 401 | |
402 | for (Int_t i=0; i<kVertexBinning; ++i) | |
1afae8ff | 403 | { |
74fd10b3 | 404 | fdNdEta[i] = dynamic_cast<TH1F*> (gDirectory->Get(fdNdEta[i]->GetName())); |
405 | fdNdEtaPtCutOffCorrected[i] = dynamic_cast<TH1F*> (gDirectory->Get(fdNdEtaPtCutOffCorrected[i]->GetName())); | |
1afae8ff | 406 | } |
5fbd0b17 | 407 | |
74fd10b3 | 408 | fPtDist = dynamic_cast<TH1F*> (gDirectory->Get(fPtDist->GetName())); |
0ab29cfa | 409 | |
5fbd0b17 | 410 | gDirectory->cd("../"); |
411 | } | |
412 | ||
ceb5d1b5 | 413 | //____________________________________________________________________ |
74fd10b3 | 414 | void dNdEtaAnalysis::DrawHistograms(Bool_t simple) |
ceb5d1b5 | 415 | { |
6bf0714d | 416 | // draws the histograms |
74fd10b3 | 417 | |
418 | if (!simple) | |
419 | { | |
420 | if (fData) | |
421 | fData->DrawHistograms(GetName()); | |
6bf0714d | 422 | |
74fd10b3 | 423 | TCanvas* canvas = new TCanvas(Form("%s_dNdEtaAnalysis", GetName()), Form("%s_dNdEtaAnalysis", GetName()), 800, 400); |
424 | canvas->Divide(2, 1); | |
ceb5d1b5 | 425 | |
74fd10b3 | 426 | canvas->cd(1); |
427 | if (fdNdEtaPtCutOffCorrected[0]) | |
428 | fdNdEtaPtCutOffCorrected[0]->Draw(); | |
ceb5d1b5 | 429 | |
74fd10b3 | 430 | if (fdNdEta[0]) |
431 | { | |
432 | fdNdEta[0]->SetLineColor(kRed); | |
433 | fdNdEta[0]->Draw("SAME"); | |
434 | } | |
1afae8ff | 435 | |
74fd10b3 | 436 | canvas->cd(2); |
437 | if (fPtDist) | |
438 | fPtDist->Draw(); | |
1afae8ff | 439 | } |
440 | ||
fcf2fb36 | 441 | // histograms for different vertices? |
442 | if (kVertexBinning > 0) | |
443 | { | |
444 | // doesnt work, but i dont get it, giving up... | |
74fd10b3 | 445 | TCanvas* canvas2 = new TCanvas(Form("%s_dNdEtaAnalysisVtx", GetName()), Form("%s_dNdEtaAnalysisVtx", GetName()), 450, 450); |
446 | TCanvas* canvas3 = 0; | |
447 | if (!simple) | |
448 | canvas3 = new TCanvas(Form("%s_dNdEtaAnalysisVtx_noptcutoff", GetName()), Form("%s_dNdEtaAnalysisVtx_noptcutoff", GetName()), 450, 450); | |
449 | ||
fcf2fb36 | 450 | //Int_t yPads = (Int_t) TMath::Ceil(((Double_t) kVertexBinning - 1) / 2); |
451 | //printf("%d\n", yPads); | |
452 | //canvas2->Divide(2, yPads); | |
453 | ||
0448e811 | 454 | TLegend* legend = new TLegend(0.4, 0.2, 0.6, 0.4); |
fcf2fb36 | 455 | |
5af55649 | 456 | for (Int_t i=0; i<kVertexBinning; ++i) |
fcf2fb36 | 457 | { |
1afae8ff | 458 | if (fdNdEtaPtCutOffCorrected[i]) |
fcf2fb36 | 459 | { |
74fd10b3 | 460 | canvas2->cd(); |
461 | ||
1afae8ff | 462 | fdNdEtaPtCutOffCorrected[i]->SetLineColor(i+1); |
463 | fdNdEtaPtCutOffCorrected[i]->Draw((i == 0) ? "" : "SAME"); | |
464 | legend->AddEntry(fdNdEtaPtCutOffCorrected[i], (i == 0) ? "Vtx All" : Form("Vtx Bin %d", i-1)); | |
fcf2fb36 | 465 | } |
74fd10b3 | 466 | if (canvas3 && fdNdEta[i]) |
467 | { | |
468 | canvas3->cd(); | |
469 | ||
470 | fdNdEta[i]->SetLineColor(i+1); | |
471 | fdNdEta[i]->Draw((i == 0) ? "" : "SAME"); | |
472 | } | |
fcf2fb36 | 473 | } |
474 | ||
74fd10b3 | 475 | canvas2->cd(); |
fcf2fb36 | 476 | legend->Draw(); |
74fd10b3 | 477 | canvas2->SaveAs(Form("%s_%s.gif", canvas2->GetName(), GetName())); |
478 | ||
479 | if (canvas3) | |
480 | { | |
481 | canvas3->cd(); | |
482 | legend->Draw(); | |
483 | } | |
fcf2fb36 | 484 | } |
74fd10b3 | 485 | |
486 | if (kVertexBinning == 3) | |
487 | { | |
488 | TH1* clone = dynamic_cast<TH1*> (fdNdEtaPtCutOffCorrected[1]->Clone("clone")); | |
489 | TH1* clone2 = dynamic_cast<TH1*> (fdNdEtaPtCutOffCorrected[2]->Clone("clone2")); | |
490 | ||
491 | if (clone && clone2) | |
492 | { | |
493 | TCanvas* canvas4 = new TCanvas(Form("%s_dNdEtaAnalysisVtxRatios", GetName()), Form("%s_dNdEtaAnalysisVtxRatios", GetName()), 450, 450); | |
494 | ||
495 | clone->Divide(fdNdEtaPtCutOffCorrected[0]); | |
496 | clone->GetYaxis()->SetRangeUser(0.95, 1.05); | |
497 | clone->Draw(); | |
498 | ||
499 | clone2->Divide(fdNdEtaPtCutOffCorrected[0]); | |
500 | clone2->Draw("SAME"); | |
501 | ||
502 | TLine* line = new TLine(-1, 1, 1, 1); | |
503 | line->Draw(); | |
504 | ||
505 | canvas4->SaveAs(Form("%s_%s.gif", canvas4->GetName(), GetName())); | |
506 | } | |
507 | } | |
7029240a | 508 | } |
509 | ||
510 | Long64_t dNdEtaAnalysis::Merge(TCollection* list) | |
511 | { | |
512 | // Merges a list of dNdEtaAnalysis objects with this one. | |
513 | // This is needed for PROOF. | |
514 | // Returns the number of merged objects (including this) | |
515 | ||
516 | if (!list) | |
517 | return 0; | |
518 | ||
519 | if (list->IsEmpty()) | |
520 | return 1; | |
521 | ||
522 | TIterator* iter = list->MakeIterator(); | |
523 | TObject* obj; | |
524 | ||
525 | // sub collections | |
74fd10b3 | 526 | const Int_t nCollections = 2 * kVertexBinning + 2; // 2 standalone hists, two arrays of size kVertexBinning |
7029240a | 527 | TList* collections[nCollections]; |
528 | for (Int_t i=0; i<nCollections; ++i) | |
529 | collections[i] = new TList; | |
530 | ||
531 | Int_t count = 0; | |
532 | while ((obj = iter->Next())) | |
533 | { | |
534 | dNdEtaAnalysis* entry = dynamic_cast<dNdEtaAnalysis*> (obj); | |
535 | if (entry == 0) | |
536 | continue; | |
537 | ||
45e97e28 | 538 | collections[0]->Add(entry->fData); |
74fd10b3 | 539 | collections[1]->Add(entry->fPtDist); |
7029240a | 540 | |
541 | for (Int_t i=0; i<kVertexBinning; ++i) | |
1afae8ff | 542 | { |
74fd10b3 | 543 | collections[2+i]->Add(entry->fdNdEta[i]); |
544 | collections[2+kVertexBinning+i]->Add(entry->fdNdEtaPtCutOffCorrected[i]); | |
1afae8ff | 545 | } |
7029240a | 546 | |
547 | ++count; | |
548 | } | |
549 | ||
45e97e28 | 550 | fData->Merge(collections[0]); |
74fd10b3 | 551 | fPtDist->Merge(collections[1]); |
7029240a | 552 | for (Int_t i=0; i<kVertexBinning; ++i) |
1afae8ff | 553 | { |
74fd10b3 | 554 | fdNdEta[i]->Merge(collections[2+i]); |
555 | fdNdEta[i]->Merge(collections[2+kVertexBinning+i]); | |
1afae8ff | 556 | } |
7029240a | 557 | |
558 | for (Int_t i=0; i<nCollections; ++i) | |
559 | delete collections[i]; | |
560 | ||
561 | return count+1; | |
ceb5d1b5 | 562 | } |