3 #include "dNdEtaAnalysis.h"
11 #include <TCollection.h>
12 #include <TIterator.h>
16 #include <TParameter.h>
19 #include "AlidNdEtaCorrection.h"
20 #include <AliCorrection.h>
21 #include <AliPWG0Helper.h>
22 #include <AliCorrectionMatrix2D.h>
23 #include <AliCorrectionMatrix3D.h>
25 //____________________________________________________________________
26 ClassImp(dNdEtaAnalysis)
28 //____________________________________________________________________
29 dNdEtaAnalysis::dNdEtaAnalysis() :
34 fAnalysisMode(AliPWG0Helper::kInvalid),
37 // default constructor
39 for (Int_t i=0; i<kVertexBinning; ++i)
42 fdNdEtaPtCutOffCorrected[i] = 0;
46 //____________________________________________________________________
47 dNdEtaAnalysis::dNdEtaAnalysis(const Char_t* name, const Char_t* title, AliPWG0Helper::AnalysisMode analysisMode) :
52 fAnalysisMode(analysisMode),
57 fData = new AliCorrection("Analysis", Form("%s Analysis", title), analysisMode);
59 // do not add this hists to the directory
60 Bool_t oldStatus = TH1::AddDirectoryStatus();
61 TH1::AddDirectory(kFALSE);
63 fMult = new TH1F("TriggeredMultiplicity", "Triggered Events;raw multiplicity;entries", 1000, -0.5, 999.5);
65 TH1* histForBinning = fData->GetTrackCorrection()->GetGeneratedHistogram();
66 fdNdEta[0] = new TH1F("dNdEta", "dN_{ch}/d#eta;#eta;dN_{ch}/d#eta", histForBinning->GetNbinsY(), histForBinning->GetYaxis()->GetXbins()->GetArray());
68 fdNdEtaPtCutOffCorrected[0] = dynamic_cast<TH1F*> (fdNdEta[0]->Clone(Form("%s_corrected", fdNdEta[0]->GetName())));
70 for (Int_t i=1; i<kVertexBinning; ++i)
72 fdNdEta[i] = dynamic_cast<TH1F*> (fdNdEta[0]->Clone(Form("%s_%d", fdNdEta[0]->GetName(), i)));
73 fdNdEtaPtCutOffCorrected[i] = dynamic_cast<TH1F*> (fdNdEtaPtCutOffCorrected[0]->Clone(Form("%s_%d", fdNdEtaPtCutOffCorrected[0]->GetName(), i)));
76 fPtDist = new TH1F("Pt", "p_{T} distribution;p_{T} [GeV/c];#frac{dN}{d#eta dp_{T}} [c/GeV]", histForBinning->GetNbinsZ(), histForBinning->GetZaxis()->GetXbins()->GetArray());
78 TH1::AddDirectory(oldStatus);
81 //____________________________________________________________________
82 dNdEtaAnalysis::~dNdEtaAnalysis()
98 for (Int_t i=0; i<kVertexBinning; ++i)
105 if (fdNdEtaPtCutOffCorrected[i])
107 delete fdNdEtaPtCutOffCorrected[i];
108 fdNdEtaPtCutOffCorrected[i] = 0;
119 //_____________________________________________________________________________
120 dNdEtaAnalysis::dNdEtaAnalysis(const dNdEtaAnalysis &c) :
125 fAnalysisMode(AliPWG0Helper::kInvalid),
129 // dNdEtaAnalysis copy constructor
132 ((dNdEtaAnalysis &) c).Copy(*this);
135 //_____________________________________________________________________________
136 dNdEtaAnalysis &dNdEtaAnalysis::operator=(const dNdEtaAnalysis &c)
139 // Assignment operator
142 if (this != &c) ((dNdEtaAnalysis &) c).Copy(*this);
146 //_____________________________________________________________________________
147 void dNdEtaAnalysis::Copy(TObject &c) const
153 dNdEtaAnalysis& target = (dNdEtaAnalysis &) c;
155 target.fData = dynamic_cast<AliCorrection*> (fData->Clone());
156 target.fMult = dynamic_cast<TH1F*> (fMult->Clone());
158 for (Int_t i=0; i<kVertexBinning; ++i)
160 target.fdNdEta[i] = dynamic_cast<TH1F*> (fdNdEta[i]->Clone());
161 target.fdNdEtaPtCutOffCorrected[i] = dynamic_cast<TH1F*> (fdNdEtaPtCutOffCorrected[i]->Clone());
164 target.fPtDist = dynamic_cast<TH1F*> (fPtDist->Clone());
166 target.fAnalysisMode = fAnalysisMode;
169 TNamed::Copy((TNamed &) c);
172 //____________________________________________________________________
173 void dNdEtaAnalysis::FillTrack(Float_t vtx, Float_t eta, Float_t pt)
175 // fills a track into the histograms
177 fData->GetTrackCorrection()->FillMeas(vtx, eta, pt);
180 //____________________________________________________________________
181 void dNdEtaAnalysis::FillEvent(Float_t vtx, Float_t n)
183 // fills an event into the histograms
185 fData->GetEventCorrection()->FillMeas(vtx, n);
188 //____________________________________________________________________
189 void dNdEtaAnalysis::FillTriggeredEvent(Float_t n)
191 // fills a triggered event into the histograms
196 //____________________________________________________________________
197 void dNdEtaAnalysis::Finish(AlidNdEtaCorrection* correction, Float_t ptCut, AlidNdEtaCorrection::CorrectionType correctionType, const char* tag)
200 // correct with the given correction values and calculate dNdEta and pT distribution
201 // the corrections that are applied can be steered by the flag correctionType
202 // the measured result is not used up to a multiplicity of multCut (the bin at multCut is the first that is used!)
205 fTag.Form("Correcting dN/deta spectrum (data: %d) >>> %s <<<. Correction type: %d, pt cut: %.2f.", (Int_t) fAnalysisMode, tag, (Int_t) correctionType, ptCut);
206 Printf("\n\n%s", fTag.Data());
208 // set corrections to 1
209 fData->SetCorrectionToUnity();
211 if (correction && correctionType != AlidNdEtaCorrection::kNone)
213 TH3* trackCorr = fData->GetTrackCorrection()->GetCorrectionHistogram();
214 TH2* eventCorr = fData->GetEventCorrection()->GetCorrectionHistogram();
216 if (correctionType >= AlidNdEtaCorrection::kTrack2Particle)
217 trackCorr->Multiply(correction->GetTrack2ParticleCorrection()->GetTrackCorrection()->GetCorrectionHistogram());
219 if (correctionType >= AlidNdEtaCorrection::kVertexReco)
221 trackCorr->Multiply(correction->GetVertexRecoCorrection()->GetTrackCorrection()->GetCorrectionHistogram());
222 eventCorr->Multiply(correction->GetVertexRecoCorrection()->GetEventCorrection()->GetCorrectionHistogram());
224 // set bin with multiplicity 0 to unity (correction has no meaning in this bin)
225 for (Int_t i=0; i<=eventCorr->GetNbinsX()+1; i++)
226 eventCorr->SetBinContent(i, 1, 1);
229 switch (correctionType)
231 case AlidNdEtaCorrection::kINEL :
233 trackCorr->Multiply(correction->GetTriggerBiasCorrectionINEL()->GetTrackCorrection()->GetCorrectionHistogram());
234 eventCorr->Multiply(correction->GetTriggerBiasCorrectionINEL()->GetEventCorrection()->GetCorrectionHistogram());
237 case AlidNdEtaCorrection::kNSD :
239 trackCorr->Multiply(correction->GetTriggerBiasCorrectionNSD()->GetTrackCorrection()->GetCorrectionHistogram());
240 eventCorr->Multiply(correction->GetTriggerBiasCorrectionNSD()->GetEventCorrection()->GetCorrectionHistogram());
243 case AlidNdEtaCorrection::kND :
245 trackCorr->Multiply(correction->GetTriggerBiasCorrectionND()->GetTrackCorrection()->GetCorrectionHistogram());
246 eventCorr->Multiply(correction->GetTriggerBiasCorrectionND()->GetEventCorrection()->GetCorrectionHistogram());
253 printf("INFO: No correction applied\n");
255 TH2F* rawMeasured = (TH2F*) fData->GetEventCorrection()->GetMeasuredHistogram()->Clone("rawMeasured");
257 fData->ResetErrorsOnCorrections();
260 if (correctionType >= AlidNdEtaCorrection::kVertexReco)
262 // There are no events with vertex that have 0 multiplicity, therefore
263 // populate bin with 0 multiplicity with the following idea:
264 // alpha = triggered events with vertex at a given vertex position / all triggered events with vertex
265 // triggered events without vertex and 0 multiplicity at a given vertex position = alpha * all triggered events with 0 multiplicity
266 // afterwards we still correct for the trigger efficiency
267 // at the same time calculate expectation from MC (not used, just to check the value)
269 //TH2* measuredEvents = fData->GetEventCorrection()->GetMeasuredHistogram();
270 TH2* correctedEvents = fData->GetEventCorrection()->GetGeneratedHistogram();
272 TH2* eTrig = correction->GetVertexRecoCorrection()->GetEventCorrection()->GetGeneratedHistogram();
273 TH2* eTrigVtx = correction->GetVertexRecoCorrection()->GetEventCorrection()->GetMeasuredHistogram();
274 TH1* eTrigVtx_projx = eTrigVtx->ProjectionX("eTrigVtx_projx", 2, rawMeasured->GetNbinsY()+1);
276 //new TCanvas; correctedEvents->DrawCopy("TEXT");
278 // start above 0 mult. bin with integration
279 TH1* vertexDist = rawMeasured->ProjectionX("vertexdist_measured", 2, rawMeasured->GetNbinsY()+1);
280 //new TCanvas; vertexDist->DrawCopy();
282 Int_t allEventsWithVertex = (Int_t) vertexDist->Integral(0, vertexDist->GetNbinsX()+1); // include under/overflow!
283 Int_t triggeredEventsWith0Mult = (Int_t) fMult->GetBinContent(1);
285 Printf("%d triggered events with 0 mult. -- %d triggered events with vertex", triggeredEventsWith0Mult, allEventsWithVertex);
287 TH1* kineBias = (TH1*) vertexDist->Clone("kineBias");
290 // loop over vertex bins
291 for (Int_t i = 1; i <= rawMeasured->GetNbinsX(); i++)
293 Double_t alpha = (Double_t) vertexDist->GetBinContent(i) / allEventsWithVertex;
294 Double_t events = alpha * triggeredEventsWith0Mult;
296 if (eTrigVtx_projx->GetBinContent(i) == 0)
299 Double_t fZ = eTrigVtx_projx->Integral(0, eTrigVtx_projx->GetNbinsX()+1) / eTrigVtx_projx->GetBinContent(i) *
300 eTrig->GetBinContent(i, 1) / eTrig->Integral(0, eTrig->GetNbinsX()+1, 1, 1);
301 kineBias->SetBinContent(i, fZ);
305 // multiply with trigger correction if set above
306 events *= fData->GetEventCorrection()->GetCorrectionHistogram()->GetBinContent(i, 1);
308 // calculate how many events we would have got with a pure MC-based correction
309 // in the given bin: measured events with vertex (mult > 0) * triggered events with mult 0 (mc) / events with vertex and mult > 0 (mc) * trigger correction for bin 0
310 Double_t mcEvents = vertexDist->GetBinContent(i) * eTrig->GetBinContent(i, 1) / eTrigVtx_projx->GetBinContent(i) * fData->GetEventCorrection()->GetCorrectionHistogram()->GetBinContent(i, 1);
312 Printf("Bin %d, alpha is %.2f, fZ is %.3f, number of events with 0 mult.: %.2f (MC comparison: %.2f)", i, alpha * 100., fZ, events, mcEvents);
313 Printf("Using MC value for 0-bin correction!");
316 correctedEvents->SetBinContent(i, 1, events);
319 Printf("In |vtx-z| < 10 cm: %d events have been added", (Int_t) correctedEvents->Integral(vertexDist->FindBin(-9.9), vertexDist->FindBin(9.9), 1, 1));
321 //new TCanvas; correctedEvents->DrawCopy("TEXT");
322 //new TCanvas; kineBias->DrawCopy();
325 fData->PrintInfo(ptCut);
327 TH3* dataHist = fData->GetTrackCorrection()->GetGeneratedHistogram();
329 // integrate multiplicity axis out (include under/overflow bins!!!)
330 TH2* tmp = fData->GetEventCorrection()->GetGeneratedHistogram();
332 TH1D* vertexHist = (TH1D*) tmp->ProjectionX("_px", 0, tmp->GetNbinsY() + 1, "e");
335 if (fAnalysisMode & AliPWG0Helper::kTPC || fAnalysisMode & AliPWG0Helper::kTPCITS)
338 dataHist->GetXaxis()->SetRange(0, 0);
339 dataHist->GetYaxis()->SetRange(0, 0);
340 dataHist->GetZaxis()->SetRange(0, 0);
343 Int_t vertexBinBegin = dataHist->GetXaxis()->FindBin(-5);
344 Int_t vertexBinEnd = dataHist->GetXaxis()->FindBin(5);
345 dataHist->GetXaxis()->SetRange(vertexBinBegin, vertexBinEnd);
346 Float_t nEvents = vertexHist->Integral(vertexBinBegin, vertexBinEnd);
351 dataHist->GetYaxis()->SetRange(dataHist->GetYaxis()->FindBin(-0.8), dataHist->GetYaxis()->FindBin(0.8));
352 Float_t etaWidth = 1.6;
354 TH1D* ptHist = dynamic_cast<TH1D*> (dataHist->Project3D("ze"));
356 for (Int_t i=1; i<=fPtDist->GetNbinsX(); ++i)
358 Float_t binSize = fPtDist->GetBinWidth(i);
359 fPtDist->SetBinContent(i, ptHist->GetBinContent(i) / binSize / nEvents / etaWidth);
360 fPtDist->SetBinError(i, ptHist->GetBinError(i) / binSize / nEvents / etaWidth);
366 printf("ERROR: nEvents is 0!\n");
370 dataHist->GetXaxis()->SetRange(0, 0);
371 dataHist->GetYaxis()->SetRange(0, 0);
372 dataHist->GetZaxis()->SetRange(0, 0);
374 // integrate over pt (with pt cut) (TPC, TPCITS) or multiplicity (SPD)
376 if (ptCut > 0 && (fAnalysisMode & AliPWG0Helper::kTPC || fAnalysisMode & AliPWG0Helper::kTPCITS))
377 ptLowBin = dataHist->GetZaxis()->FindBin(ptCut);
379 //new TCanvas; dataHist->DrawCopy();
382 dataHist->GetZaxis()->SetRange(ptLowBin, dataHist->GetZaxis()->GetNbins()+1);
383 printf("pt/multiplicity range %d %d\n", ptLowBin, dataHist->GetZaxis()->GetNbins()+1);
384 TH2D* vtxVsEta = dynamic_cast<TH2D*> (dataHist->Project3D("yx2e"));
386 //new TCanvas; vtxVsEta->Draw("COLZ");
388 dataHist->GetZaxis()->SetRange(0, 0);
389 vtxVsEta->GetXaxis()->SetTitle(dataHist->GetXaxis()->GetTitle());
390 vtxVsEta->GetYaxis()->SetTitle(dataHist->GetYaxis()->GetTitle());
394 printf("ERROR: pt/multiplicity integration failed\n");
398 //new TCanvas(tag, tag, 800, 600); vtxVsEta->DrawCopy("COLZ");
400 // clear result histograms
401 for (Int_t vertexPos=0; vertexPos<kVertexBinning; ++vertexPos)
403 fdNdEta[vertexPos]->Reset();
404 fdNdEtaPtCutOffCorrected[vertexPos]->Reset();
407 const Float_t vertexRangeBegin[kVertexBinning] = { -9.99, -9.99, 0.01 };
408 const Float_t vertexRangeEnd[kVertexBinning] = { 9.99, -0.01, 9.99 };
410 for (Int_t iEta=1; iEta<=vtxVsEta->GetNbinsY(); iEta++)
412 // loop over vertex ranges
413 for (Int_t vertexPos=0; vertexPos<kVertexBinning; ++vertexPos)
415 Int_t vertexBinBegin = vertexHist->GetXaxis()->FindBin(vertexRangeBegin[vertexPos]);
416 Int_t vertexBinEnd = vertexHist->GetXaxis()->FindBin(vertexRangeEnd[vertexPos]);
418 const Int_t *binBegin = 0;
419 const Int_t maxBins = 14;
421 if (dataHist->GetNbinsY() != maxBins)
422 AliFatal(Form("Binning of acceptance is different from data histogram: data=%d, acceptance=%d", dataHist->GetNbinsY(), maxBins));
424 // adjust acceptance range
425 // produce with drawPlots.C: DetermineAcceptance(...)
426 if (fAnalysisMode & AliPWG0Helper::kSPD)
428 const Int_t binBeginSPD[maxBins] = {-1, 16, 13, 9, 7, 5, 4, 4, 3, 3, 2, 2, 2, -1};
430 binBegin = binBeginSPD;
432 else if (fAnalysisMode & AliPWG0Helper::kTPC)
434 //const Int_t binBeginTPC[30] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1}; // limit 5, pt cut off 0.2 mev/c
435 //const Int_t binBeginTPC[maxBins] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 9, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}; // limit 5
437 //binBegin = binBeginTPC;
439 else if (fAnalysisMode & AliPWG0Helper::kTPCITS)
445 Int_t vtxEnd = maxBins;
449 vtxBegin = binBegin[iEta - 1];
450 vtxEnd = 18 + 1 - binBegin[maxBins - iEta];
453 Printf("WARNING: No acceptance applied!");
455 // eta range not accessible
459 //Printf("%d %d | %d %d", vtxBegin, vertexHist->GetXaxis()->FindBin(GetVtxMin(eta)), vtxEnd, vertexHist->GetXaxis()->FindBin(-GetVtxMin(-eta)));
460 //vtxBegin = vertexHist->GetXaxis()->FindBin(GetVtxMin(eta));
461 //vtxEnd = vertexHist->GetXaxis()->FindBin(-GetVtxMin(-eta));
463 //Float_t eta = vtxVsEta->GetYaxis()->GetBinCenter(iEta);
464 //printf("Eta bin: %d (%f) Vertex range: %d; before: %d %d (range) %d %d (acceptance)", iEta, eta, vertexPos, vertexBinBegin, vertexBinEnd, vtxBegin, vtxEnd);
465 vertexBinBegin = TMath::Max(vertexBinBegin, vtxBegin);
466 vertexBinEnd = TMath::Min(vertexBinEnd, vtxEnd);
467 //Printf(" after: %d %d", vertexBinBegin, vertexBinEnd);
469 // no data for this bin
470 if (vertexBinBegin > vertexBinEnd)
472 //Printf("Bin empty. Skipped");
476 Float_t totalEvents = 0;
478 Float_t sumError2 = 0;
479 Float_t unusedTracks = 0;
480 Float_t unusedEvents = 0;
481 for (Int_t iVtx = 1; iVtx <= vtxVsEta->GetNbinsX(); iVtx++)
483 if (iVtx >= vertexBinBegin && iVtx <= vertexBinEnd)
485 if (vtxVsEta->GetBinContent(iVtx, iEta) != 0)
487 sum += vtxVsEta->GetBinContent(iVtx, iEta);
489 if (sumError2 > 10e30)
490 Printf("WARNING: sum of error2 is dangerously large - be prepared for crash... ");
492 sumError2 = sumError2 + TMath::Power(vtxVsEta->GetBinError(iVtx, iEta),2);
494 totalEvents += vertexHist->GetBinContent(iVtx);
498 unusedTracks += vtxVsEta->GetBinContent(iVtx, iEta);
499 unusedEvents += vertexHist->GetBinContent(iVtx);
503 if (totalEvents == 0)
505 printf("WARNING: No events for hist %d %d %d\n", vertexPos, vertexBinBegin, vertexBinEnd);
509 Float_t ptCutOffCorrection = 1;
511 // find pt cut off correction factor
512 if ((fAnalysisMode & AliPWG0Helper::kTPC || fAnalysisMode & AliPWG0Helper::kTPCITS) && (fAnalysisMode & AliPWG0Helper::kFieldOn))
514 if (correction && ptCut > 0)
515 ptCutOffCorrection = correction->GetMeasuredFraction(correctionType, ptCut, vtxVsEta->GetYaxis()->GetBinCenter(iEta), vertexBinBegin, vertexBinEnd);
517 if (ptCutOffCorrection <= 0)
519 printf("UNEXPECTED: ptCutOffCorrection is %f for hist %d %d %d\n", ptCutOffCorrection, vertexPos, vertexBinBegin, vertexBinEnd);
524 //printf("Eta: %d (%f) Vertex Range: %d %d, Event Count %f, Track Sum: %f, Track Sum corrected: %f \n", iEta, vtxVsEta->GetYaxis()->GetBinCenter(iEta), vertexBinBegin, vertexBinEnd, totalEvents, sum, sum / ptCutOffCorrection);
526 Int_t bin = fdNdEta[vertexPos]->FindBin(vtxVsEta->GetYaxis()->GetBinCenter(iEta));
527 if (bin > 0 && bin <= fdNdEta[vertexPos]->GetNbinsX())
529 Float_t dndeta = sum / totalEvents;
530 Float_t error = TMath::Sqrt(sumError2) / totalEvents;
532 dndeta = dndeta / fdNdEta[vertexPos]->GetBinWidth(bin);
533 error = error / fdNdEta[vertexPos]->GetBinWidth(bin);
535 fdNdEta[vertexPos]->SetBinContent(bin, dndeta);
536 fdNdEta[vertexPos]->SetBinError(bin, error);
538 dndeta /= ptCutOffCorrection;
539 error /= ptCutOffCorrection;
541 fdNdEtaPtCutOffCorrected[vertexPos]->SetBinContent(bin, dndeta);
542 fdNdEtaPtCutOffCorrected[vertexPos]->SetBinError(bin, error);
544 //Printf("Bin %d has dN/deta = %f +- %f; %.2f tracks %.2f events (outside acceptance: %.2f tracks, %.2f events)", bin, dndeta, error, sum, totalEvents, unusedTracks, unusedEvents);
550 //____________________________________________________________________
551 Float_t dNdEtaAnalysis::GetVtxMin(Float_t eta)
553 // helper function for the SPD acceptance
554 // the function returns the beginning of the acceptance window in z vertex position as function of eta
555 // to get the maximum: -GetVtxMin(-eta)
557 Float_t a[2] = { -15, 0 };
558 Float_t b[2] = { 0, -1.4 };
559 Float_t c[2] = { 15, -2.2 };
562 meanAB[0] = (b[0] + a[0]) / 2;
563 meanAB[1] = (b[1] + a[1]) / 2;
566 meanBC[0] = (c[0] + b[0]) / 2;
567 meanBC[1] = (c[1] + b[1]) / 2;
569 Float_t mAB = (b[1] - a[1]) / (b[0] - a[0]);
570 Float_t mBC = (c[1] - b[1]) / (c[0] - b[0]);
572 Float_t bAB = meanAB[1] - mAB * meanAB[0];
573 Float_t bBC = meanBC[1] - mBC * meanBC[0];
576 return 1.0 / mAB * eta - bAB / mAB;
578 return 1.0 / mBC * eta - bBC / mBC;
581 //____________________________________________________________________
582 void dNdEtaAnalysis::SaveHistograms()
584 // save the histograms to a directory with the name of this class (retrieved from TNamed)
586 gDirectory->mkdir(GetName());
587 gDirectory->cd(GetName());
591 fData->SaveHistograms();
594 printf("dNdEtaAnalysis::SaveHistograms: UNEXPECTED: fData is 0\n");
601 printf("dNdEtaAnalysis::SaveHistograms: UNEXPECTED: fMult is 0\n");
606 printf("dNdEtaAnalysis::SaveHistograms: UNEXPECTED: fPtDist is 0\n");
608 for (Int_t i=0; i<kVertexBinning; ++i)
613 printf("dNdEtaAnalysis::SaveHistograms: UNEXPECTED: fdNdEta[%d] is 0\n", i);
615 if (fdNdEtaPtCutOffCorrected[i])
616 fdNdEtaPtCutOffCorrected[i]->Write();
618 printf("dNdEtaAnalysis::SaveHistograms: UNEXPECTED: fdNdEtaPtCutOffCorrected[%d] is 0\n", i);
621 TNamed named("fTag", fTag.Data());
624 TParameter<Int_t> param("fAnalysisMode", fAnalysisMode);
627 gDirectory->cd("../");
630 void dNdEtaAnalysis::LoadHistograms(const Char_t* dir)
632 // loads the histograms from a directory with the name of this class (retrieved from TNamed)
639 fData->LoadHistograms();
640 fMult = dynamic_cast<TH1F*> (gDirectory->Get(fMult->GetName()));
642 for (Int_t i=0; i<kVertexBinning; ++i)
644 fdNdEta[i] = dynamic_cast<TH1F*> (gDirectory->Get(fdNdEta[i]->GetName()));
645 fdNdEtaPtCutOffCorrected[i] = dynamic_cast<TH1F*> (gDirectory->Get(fdNdEtaPtCutOffCorrected[i]->GetName()));
648 fPtDist = dynamic_cast<TH1F*> (gDirectory->Get(fPtDist->GetName()));
650 if (dynamic_cast<TNamed*> (gDirectory->Get("fTag")))
651 fTag = (dynamic_cast<TNamed*> (gDirectory->Get("fTag")))->GetTitle();
653 if (dynamic_cast<TParameter<Int_t>*> (gDirectory->Get("fAnalysisMode")))
654 fAnalysisMode = (AliPWG0Helper::AnalysisMode) (dynamic_cast<TParameter<Int_t>*> (gDirectory->Get("fAnalysisMode")))->GetVal();
656 gDirectory->cd("../");
659 //____________________________________________________________________
660 void dNdEtaAnalysis::DrawHistograms(Bool_t simple)
662 // draws the histograms
667 fData->DrawHistograms(GetName());
669 TCanvas* canvas = new TCanvas(Form("%s_dNdEtaAnalysis", GetName()), Form("%s_dNdEtaAnalysis", GetName()), 800, 400);
670 canvas->Divide(2, 1);
673 if (fdNdEtaPtCutOffCorrected[0])
674 fdNdEtaPtCutOffCorrected[0]->DrawCopy();
678 fdNdEta[0]->SetLineColor(kRed);
679 fdNdEta[0]->DrawCopy("SAME");
687 // histograms for different vertices?
688 if (kVertexBinning > 0)
690 // doesnt work, but i dont get it, giving up...
691 TCanvas* canvas2 = new TCanvas(Form("%s_dNdEtaAnalysisVtx", GetName()), Form("%s_dNdEtaAnalysisVtx", GetName()), 450, 450);
692 TCanvas* canvas3 = 0;
694 canvas3 = new TCanvas(Form("%s_dNdEtaAnalysisVtx_noptcutoff", GetName()), Form("%s_dNdEtaAnalysisVtx_noptcutoff", GetName()), 450, 450);
696 //Int_t yPads = (Int_t) TMath::Ceil(((Double_t) kVertexBinning - 1) / 2);
697 //printf("%d\n", yPads);
698 //canvas2->Divide(2, yPads);
700 TLegend* legend = new TLegend(0.4, 0.2, 0.6, 0.4);
702 for (Int_t i=0; i<kVertexBinning; ++i)
704 if (fdNdEtaPtCutOffCorrected[i])
708 fdNdEtaPtCutOffCorrected[i]->SetLineColor(i+1);
709 fdNdEtaPtCutOffCorrected[i]->DrawCopy((i == 0) ? "" : "SAME");
710 legend->AddEntry(fdNdEtaPtCutOffCorrected[i], (i == 0) ? "Vtx All" : Form("Vtx Bin %d", i-1));
712 if (canvas3 && fdNdEta[i])
716 fdNdEta[i]->SetLineColor(i+1);
717 fdNdEta[i]->DrawCopy((i == 0) ? "" : "SAME");
723 canvas2->SaveAs(Form("%s_%s.gif", canvas2->GetName(), GetName()));
732 if (kVertexBinning == 3)
734 TH1* clone = dynamic_cast<TH1*> (fdNdEtaPtCutOffCorrected[1]->Clone("clone"));
735 TH1* clone2 = dynamic_cast<TH1*> (fdNdEtaPtCutOffCorrected[2]->Clone("clone2"));
739 TCanvas* canvas4 = new TCanvas(Form("%s_dNdEtaAnalysisVtxRatios", GetName()), Form("%s_dNdEtaAnalysisVtxRatios", GetName()), 450, 450);
741 clone->Divide(fdNdEtaPtCutOffCorrected[0]);
742 clone->GetYaxis()->SetRangeUser(0.95, 1.05);
745 clone2->Divide(fdNdEtaPtCutOffCorrected[0]);
746 clone2->DrawCopy("SAME");
748 TLine* line = new TLine(-1, 1, 1, 1);
751 canvas4->SaveAs(Form("%s_%s.gif", canvas4->GetName(), GetName()));
756 Long64_t dNdEtaAnalysis::Merge(TCollection* list)
758 // Merges a list of dNdEtaAnalysis objects with this one.
759 // This is needed for PROOF.
760 // Returns the number of merged objects (including this)
768 TIterator* iter = list->MakeIterator();
772 const Int_t nCollections = 2 * kVertexBinning + 3; // 3 standalone hists, 3 arrays of size kVertexBinning
773 TList* collections[nCollections];
774 for (Int_t i=0; i<nCollections; ++i)
775 collections[i] = new TList;
778 while ((obj = iter->Next()))
780 dNdEtaAnalysis* entry = dynamic_cast<dNdEtaAnalysis*> (obj);
784 collections[0]->Add(entry->fData);
785 collections[1]->Add(entry->fMult);
786 collections[2]->Add(entry->fPtDist);
788 for (Int_t i=0; i<kVertexBinning; ++i)
790 collections[3+i]->Add(entry->fdNdEta[i]);
791 collections[3+kVertexBinning+i]->Add(entry->fdNdEtaPtCutOffCorrected[i]);
797 fData->Merge(collections[0]);
798 fMult->Merge(collections[1]);
799 fPtDist->Merge(collections[2]);
801 for (Int_t i=0; i<kVertexBinning; ++i)
803 fdNdEta[i]->Merge(collections[3+i]);
804 fdNdEtaPtCutOffCorrected[i]->Merge(collections[3+kVertexBinning+i]);
807 for (Int_t i=0; i<nCollections; ++i)
808 delete collections[i];