3 #include "dNdEtaAnalysis.h"
11 #include <TCollection.h>
12 #include <TIterator.h>
16 #include <TParameter.h>
18 #include "AlidNdEtaCorrection.h"
19 #include <AliCorrection.h>
20 #include <AliPWG0Helper.h>
21 #include <AliCorrectionMatrix2D.h>
22 #include <AliCorrectionMatrix3D.h>
24 //____________________________________________________________________
25 ClassImp(dNdEtaAnalysis)
27 //____________________________________________________________________
28 dNdEtaAnalysis::dNdEtaAnalysis() :
33 fAnalysisMode(AliPWG0Helper::kInvalid),
36 // default constructor
38 for (Int_t i=0; i<kVertexBinning; ++i)
41 fdNdEtaPtCutOffCorrected[i] = 0;
45 //____________________________________________________________________
46 dNdEtaAnalysis::dNdEtaAnalysis(const Char_t* name, const Char_t* title, AliPWG0Helper::AnalysisMode analysisMode) :
51 fAnalysisMode(analysisMode),
56 fData = new AliCorrection("Analysis", Form("%s Analysis", title), analysisMode);
58 // do not add this hists to the directory
59 Bool_t oldStatus = TH1::AddDirectoryStatus();
60 TH1::AddDirectory(kFALSE);
62 fMult = new TH1F("TriggeredMultiplicity", "Triggered Events;raw multiplicity;entries", 1000, -0.5, 999.5);
64 TH1* histForBinning = fData->GetTrackCorrection()->GetGeneratedHistogram();
65 fdNdEta[0] = new TH1F("dNdEta", "dN_{ch}/d#eta;#eta;dN_{ch}/d#eta", histForBinning->GetNbinsY(), histForBinning->GetYaxis()->GetXbins()->GetArray());
67 fdNdEtaPtCutOffCorrected[0] = dynamic_cast<TH1F*> (fdNdEta[0]->Clone(Form("%s_corrected", fdNdEta[0]->GetName())));
69 for (Int_t i=1; i<kVertexBinning; ++i)
71 fdNdEta[i] = dynamic_cast<TH1F*> (fdNdEta[0]->Clone(Form("%s_%d", fdNdEta[0]->GetName(), i)));
72 fdNdEtaPtCutOffCorrected[i] = dynamic_cast<TH1F*> (fdNdEtaPtCutOffCorrected[0]->Clone(Form("%s_%d", fdNdEtaPtCutOffCorrected[0]->GetName(), i)));
75 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());
77 TH1::AddDirectory(oldStatus);
80 //____________________________________________________________________
81 dNdEtaAnalysis::~dNdEtaAnalysis()
97 for (Int_t i=0; i<kVertexBinning; ++i)
104 if (fdNdEtaPtCutOffCorrected[i])
106 delete fdNdEtaPtCutOffCorrected[i];
107 fdNdEtaPtCutOffCorrected[i] = 0;
118 //_____________________________________________________________________________
119 dNdEtaAnalysis::dNdEtaAnalysis(const dNdEtaAnalysis &c) :
124 fAnalysisMode(AliPWG0Helper::kInvalid),
128 // dNdEtaAnalysis copy constructor
131 ((dNdEtaAnalysis &) c).Copy(*this);
134 //_____________________________________________________________________________
135 dNdEtaAnalysis &dNdEtaAnalysis::operator=(const dNdEtaAnalysis &c)
138 // Assignment operator
141 if (this != &c) ((dNdEtaAnalysis &) c).Copy(*this);
145 //_____________________________________________________________________________
146 void dNdEtaAnalysis::Copy(TObject &c) const
152 dNdEtaAnalysis& target = (dNdEtaAnalysis &) c;
154 target.fData = dynamic_cast<AliCorrection*> (fData->Clone());
155 target.fMult = dynamic_cast<TH1F*> (fMult->Clone());
157 for (Int_t i=0; i<kVertexBinning; ++i)
159 target.fdNdEta[i] = dynamic_cast<TH1F*> (fdNdEta[i]->Clone());
160 target.fdNdEtaPtCutOffCorrected[i] = dynamic_cast<TH1F*> (fdNdEtaPtCutOffCorrected[i]->Clone());
163 target.fPtDist = dynamic_cast<TH1F*> (fPtDist->Clone());
165 target.fAnalysisMode = fAnalysisMode;
168 TNamed::Copy((TNamed &) c);
171 //____________________________________________________________________
172 void dNdEtaAnalysis::FillTrack(Float_t vtx, Float_t eta, Float_t pt)
174 // fills a track into the histograms
176 fData->GetTrackCorrection()->FillMeas(vtx, eta, pt);
179 //____________________________________________________________________
180 void dNdEtaAnalysis::FillEvent(Float_t vtx, Float_t n)
182 // fills an event into the histograms
184 fData->GetEventCorrection()->FillMeas(vtx, n);
187 //____________________________________________________________________
188 void dNdEtaAnalysis::FillTriggeredEvent(Float_t n)
190 // fills a triggered event into the histograms
195 //____________________________________________________________________
196 void dNdEtaAnalysis::Finish(AlidNdEtaCorrection* correction, Float_t ptCut, AlidNdEtaCorrection::CorrectionType correctionType, const char* tag)
199 // correct with the given correction values and calculate dNdEta and pT distribution
200 // the corrections that are applied can be steered by the flag correctionType
201 // the measured result is not used up to a multiplicity of multCut (the bin at multCut is the first that is used!)
204 fTag.Form("Correcting dN/deta spectrum (data: %d) >>> %s <<<. Correction type: %d, pt cut: %.2f.", (Int_t) fAnalysisMode, tag, (Int_t) correctionType, ptCut);
205 Printf("\n\n%s", fTag.Data());
207 // set corrections to 1
208 fData->SetCorrectionToUnity();
210 if (correction && correctionType != AlidNdEtaCorrection::kNone)
212 TH3* trackCorr = fData->GetTrackCorrection()->GetCorrectionHistogram();
213 TH2* eventCorr = fData->GetEventCorrection()->GetCorrectionHistogram();
215 if (correctionType >= AlidNdEtaCorrection::kTrack2Particle)
216 trackCorr->Multiply(correction->GetTrack2ParticleCorrection()->GetTrackCorrection()->GetCorrectionHistogram());
218 if (correctionType >= AlidNdEtaCorrection::kVertexReco)
220 trackCorr->Multiply(correction->GetVertexRecoCorrection()->GetTrackCorrection()->GetCorrectionHistogram());
221 eventCorr->Multiply(correction->GetVertexRecoCorrection()->GetEventCorrection()->GetCorrectionHistogram());
223 // set bin with multiplicity 0 to unity (correction has no meaning in this bin)
224 for (Int_t i=0; i<=eventCorr->GetNbinsX()+1; i++)
225 eventCorr->SetBinContent(i, 1, 1);
228 switch (correctionType)
230 case AlidNdEtaCorrection::kINEL :
232 trackCorr->Multiply(correction->GetTriggerBiasCorrectionINEL()->GetTrackCorrection()->GetCorrectionHistogram());
233 eventCorr->Multiply(correction->GetTriggerBiasCorrectionINEL()->GetEventCorrection()->GetCorrectionHistogram());
236 case AlidNdEtaCorrection::kNSD :
238 trackCorr->Multiply(correction->GetTriggerBiasCorrectionNSD()->GetTrackCorrection()->GetCorrectionHistogram());
239 eventCorr->Multiply(correction->GetTriggerBiasCorrectionNSD()->GetEventCorrection()->GetCorrectionHistogram());
242 case AlidNdEtaCorrection::kND :
244 trackCorr->Multiply(correction->GetTriggerBiasCorrectionND()->GetTrackCorrection()->GetCorrectionHistogram());
245 eventCorr->Multiply(correction->GetTriggerBiasCorrectionND()->GetEventCorrection()->GetCorrectionHistogram());
252 printf("INFO: No correction applied\n");
254 TH2F* rawMeasured = (TH2F*) fData->GetEventCorrection()->GetMeasuredHistogram()->Clone("rawMeasured");
258 if (correctionType >= AlidNdEtaCorrection::kVertexReco)
260 // There are no events with vertex that have 0 multiplicity, therefore
261 // populate bin with 0 multiplicity with the following idea:
262 // alpha = triggered events with vertex at a given vertex position / all triggered events with vertex
263 // triggered events without vertex and 0 multiplicity at a given vertex position = alpha * all triggered events with 0 multiplicity
264 // afterwards we still correct for the trigger efficiency
265 // at the same time calculate expectation from MC (not used, just to check the value)
267 //TH2* measuredEvents = fData->GetEventCorrection()->GetMeasuredHistogram();
268 TH2* correctedEvents = fData->GetEventCorrection()->GetGeneratedHistogram();
270 TH2* eTrig = correction->GetVertexRecoCorrection()->GetEventCorrection()->GetGeneratedHistogram();
271 TH2* eTrigVtx = correction->GetVertexRecoCorrection()->GetEventCorrection()->GetMeasuredHistogram();
272 TH1* eTrigVtx_projx = eTrigVtx->ProjectionX("eTrigVtx_projx", 2, rawMeasured->GetNbinsY()+1);
274 //new TCanvas; correctedEvents->DrawCopy("TEXT");
276 // start above 0 mult. bin with integration
277 TH1* vertexDist = rawMeasured->ProjectionX("vertexdist_measured", 2, rawMeasured->GetNbinsY()+1);
278 //new TCanvas; vertexDist->DrawCopy();
280 Int_t allEventsWithVertex = (Int_t) vertexDist->Integral(0, vertexDist->GetNbinsX()+1); // include under/overflow!
281 Int_t triggeredEventsWith0Mult = (Int_t) fMult->GetBinContent(1);
283 Printf("%d triggered events with 0 mult. -- %d triggered events with vertex", triggeredEventsWith0Mult, allEventsWithVertex);
285 TH1* kineBias = (TH1*) vertexDist->Clone("kineBias");
288 // loop over vertex bins
289 for (Int_t i = 1; i <= rawMeasured->GetNbinsX(); i++)
291 Double_t alpha = (Double_t) vertexDist->GetBinContent(i) / allEventsWithVertex;
292 Double_t events = alpha * triggeredEventsWith0Mult;
294 if (eTrigVtx_projx->GetBinContent(i) == 0)
297 Double_t fZ = eTrigVtx_projx->Integral(0, eTrigVtx_projx->GetNbinsX()+1) / eTrigVtx_projx->GetBinContent(i) *
298 eTrig->GetBinContent(i, 1) / eTrig->Integral(0, eTrig->GetNbinsX()+1, 1, 1);
299 kineBias->SetBinContent(i, fZ);
303 // multiply with trigger correction if set above
304 events *= fData->GetEventCorrection()->GetCorrectionHistogram()->GetBinContent(i, 1);
306 // calculate how many events we would have got with a pure MC-based correction
307 // 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
308 Double_t mcEvents = vertexDist->GetBinContent(i) * eTrig->GetBinContent(i, 1) / eTrigVtx_projx->GetBinContent(i) * fData->GetEventCorrection()->GetCorrectionHistogram()->GetBinContent(i, 1);
310 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);
312 correctedEvents->SetBinContent(i, 1, events);
315 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));
317 //new TCanvas; correctedEvents->DrawCopy("TEXT");
318 //new TCanvas; kineBias->DrawCopy();
321 fData->PrintInfo(ptCut);
323 TH3* dataHist = fData->GetTrackCorrection()->GetGeneratedHistogram();
325 // integrate multiplicity axis out (include under/overflow bins!!!)
326 TH2* tmp = fData->GetEventCorrection()->GetGeneratedHistogram();
328 TH1D* vertexHist = (TH1D*) tmp->ProjectionX("_px", 0, tmp->GetNbinsY() + 1, "e");
331 if (fAnalysisMode & AliPWG0Helper::kTPC || fAnalysisMode & AliPWG0Helper::kTPCITS)
334 dataHist->GetXaxis()->SetRange(0, 0);
335 dataHist->GetYaxis()->SetRange(0, 0);
336 dataHist->GetZaxis()->SetRange(0, 0);
339 Int_t vertexBinBegin = dataHist->GetXaxis()->FindBin(-5);
340 Int_t vertexBinEnd = dataHist->GetXaxis()->FindBin(5);
341 dataHist->GetXaxis()->SetRange(vertexBinBegin, vertexBinEnd);
342 Float_t nEvents = vertexHist->Integral(vertexBinBegin, vertexBinEnd);
347 dataHist->GetYaxis()->SetRange(dataHist->GetYaxis()->FindBin(-0.8), dataHist->GetYaxis()->FindBin(0.8));
348 Float_t etaWidth = 1.6;
350 TH1D* ptHist = dynamic_cast<TH1D*> (dataHist->Project3D("ze"));
352 for (Int_t i=1; i<=fPtDist->GetNbinsX(); ++i)
354 Float_t binSize = fPtDist->GetBinWidth(i);
355 fPtDist->SetBinContent(i, ptHist->GetBinContent(i) / binSize / nEvents / etaWidth);
356 fPtDist->SetBinError(i, ptHist->GetBinError(i) / binSize / nEvents / etaWidth);
362 printf("ERROR: nEvents is 0!\n");
366 dataHist->GetXaxis()->SetRange(0, 0);
367 dataHist->GetYaxis()->SetRange(0, 0);
368 dataHist->GetZaxis()->SetRange(0, 0);
370 // integrate over pt (with pt cut) (TPC, TPCITS) or multiplicity (SPD)
372 if (ptCut > 0 && (fAnalysisMode & AliPWG0Helper::kTPC || fAnalysisMode & AliPWG0Helper::kTPCITS))
373 ptLowBin = dataHist->GetZaxis()->FindBin(ptCut);
375 //new TCanvas; dataHist->DrawCopy();
378 dataHist->GetZaxis()->SetRange(ptLowBin, dataHist->GetZaxis()->GetNbins()+1);
379 printf("pt/multiplicity range %d %d\n", ptLowBin, dataHist->GetZaxis()->GetNbins()+1);
380 TH2D* vtxVsEta = dynamic_cast<TH2D*> (dataHist->Project3D("yx2e"));
382 //new TCanvas; vtxVsEta->Draw("COLZ");
384 dataHist->GetZaxis()->SetRange(0, 0);
385 vtxVsEta->GetXaxis()->SetTitle(dataHist->GetXaxis()->GetTitle());
386 vtxVsEta->GetYaxis()->SetTitle(dataHist->GetYaxis()->GetTitle());
390 printf("ERROR: pt/multiplicity integration failed\n");
394 //new TCanvas(tag, tag, 800, 600); vtxVsEta->DrawCopy("COLZ");
396 // clear result histograms
397 for (Int_t vertexPos=0; vertexPos<kVertexBinning; ++vertexPos)
399 fdNdEta[vertexPos]->Reset();
400 fdNdEtaPtCutOffCorrected[vertexPos]->Reset();
403 const Float_t vertexRangeBegin[kVertexBinning] = { -9.99, -9.99, 0.01 };
404 const Float_t vertexRangeEnd[kVertexBinning] = { 9.99, -0.01, 9.99 };
406 for (Int_t iEta=1; iEta<=vtxVsEta->GetNbinsY(); iEta++)
408 // loop over vertex ranges
409 for (Int_t vertexPos=0; vertexPos<kVertexBinning; ++vertexPos)
411 Int_t vertexBinBegin = vertexHist->GetXaxis()->FindBin(vertexRangeBegin[vertexPos]);
412 Int_t vertexBinEnd = vertexHist->GetXaxis()->FindBin(vertexRangeEnd[vertexPos]);
414 const Int_t *binBegin = 0;
415 const Int_t maxBins = 60;
417 // adjust acceptance range
418 // produce with drawPlots.C: DetermineAcceptance(...)
419 if (fAnalysisMode & AliPWG0Helper::kSPD)
421 //const Int_t binBeginSPD[30] = { 18, 16, 15, 14, 13, 13, 12, 11, 9, 7, 6, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 1 }; // by eye
422 //const Int_t binBeginSPD[30] = { -1, -1, -1, -1, 16, 14, 12, 10, 9, 7, 6, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, -1, -1, -1, -1}; // limit in correction map is 5
424 //const Int_t binBegin[30] = { -1, -1, -1, 17, 15, 14, 12, 10, 8, 7, 6, 5, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, -1, -1, -1}; // limit in correction map is 10
426 //const Int_t binBeginSPD[30] = { -1, -1, -1, -1, 16, 15, 13, 11, 9, 8, 7, 6, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, -1, -1, -1, -1}; // limit 2
427 const Int_t binBeginSPD[maxBins] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 15, 14, 13, 12, 11, 10, 9, 9, 8, 7, 7, 6, 6, 5, 5, 4, 4, 4, 4, 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}; //limit 5
429 binBegin = binBeginSPD;
431 else if (fAnalysisMode & AliPWG0Helper::kTPC)
433 //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
434 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
436 binBegin = binBeginTPC;
438 else if (fAnalysisMode & AliPWG0Helper::kTPCITS)
444 Int_t vtxEnd = maxBins;
448 vtxBegin = binBegin[iEta - 1];
449 vtxEnd = 18 + 1 - binBegin[maxBins - iEta];
452 Printf("WARNING: No acceptance applied!");
454 // eta range not accessible
458 //Printf("%d %d | %d %d", vtxBegin, vertexHist->GetXaxis()->FindBin(GetVtxMin(eta)), vtxEnd, vertexHist->GetXaxis()->FindBin(-GetVtxMin(-eta)));
459 //vtxBegin = vertexHist->GetXaxis()->FindBin(GetVtxMin(eta));
460 //vtxEnd = vertexHist->GetXaxis()->FindBin(-GetVtxMin(-eta));
462 //Float_t eta = vtxVsEta->GetYaxis()->GetBinCenter(iEta);
463 //printf("Eta bin: %d (%f) Vertex range: %d; before: %d %d (range) %d %d (acceptance)", iEta, eta, vertexPos, vertexBinBegin, vertexBinEnd, vtxBegin, vtxEnd);
464 vertexBinBegin = TMath::Max(vertexBinBegin, vtxBegin);
465 vertexBinEnd = TMath::Min(vertexBinEnd, vtxEnd);
466 //Printf(" after: %d %d", vertexBinBegin, vertexBinEnd);
468 // no data for this bin
469 if (vertexBinBegin > vertexBinEnd)
471 //Printf("Bin empty. Skipped");
475 Float_t totalEvents = 0;
477 Float_t sumError2 = 0;
478 Float_t unusedTracks = 0;
479 Float_t unusedEvents = 0;
480 for (Int_t iVtx = 1; iVtx <= vtxVsEta->GetNbinsX(); iVtx++)
482 if (iVtx >= vertexBinBegin && iVtx <= vertexBinEnd)
484 if (vtxVsEta->GetBinContent(iVtx, iEta) != 0)
486 sum += vtxVsEta->GetBinContent(iVtx, iEta);
488 if (sumError2 > 10e30)
489 Printf("WARNING: sum of error2 is dangerously large - be prepared for crash... ");
491 sumError2 = sumError2 + TMath::Power(vtxVsEta->GetBinError(iVtx, iEta),2);
493 totalEvents += vertexHist->GetBinContent(iVtx);
497 unusedTracks += vtxVsEta->GetBinContent(iVtx, iEta);
498 unusedEvents += vertexHist->GetBinContent(iVtx);
502 if (totalEvents == 0)
504 printf("WARNING: No events for hist %d %d %d\n", vertexPos, vertexBinBegin, vertexBinEnd);
508 Float_t ptCutOffCorrection = 1;
510 // find pt cut off correction factor
511 if ((fAnalysisMode & AliPWG0Helper::kTPC || fAnalysisMode & AliPWG0Helper::kTPCITS) && (fAnalysisMode & AliPWG0Helper::kFieldOn))
513 if (correction && ptCut > 0)
514 ptCutOffCorrection = correction->GetMeasuredFraction(correctionType, ptCut, vtxVsEta->GetYaxis()->GetBinCenter(iEta), vertexBinBegin, vertexBinEnd);
516 if (ptCutOffCorrection <= 0)
518 printf("UNEXPECTED: ptCutOffCorrection is %f for hist %d %d %d\n", ptCutOffCorrection, vertexPos, vertexBinBegin, vertexBinEnd);
523 //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);
525 Int_t bin = fdNdEta[vertexPos]->FindBin(vtxVsEta->GetYaxis()->GetBinCenter(iEta));
526 if (bin > 0 && bin <= fdNdEta[vertexPos]->GetNbinsX())
528 Float_t dndeta = sum / totalEvents;
529 Float_t error = TMath::Sqrt(sumError2) / totalEvents;
531 dndeta = dndeta / fdNdEta[vertexPos]->GetBinWidth(bin);
532 error = error / fdNdEta[vertexPos]->GetBinWidth(bin);
534 fdNdEta[vertexPos]->SetBinContent(bin, dndeta);
535 fdNdEta[vertexPos]->SetBinError(bin, error);
537 dndeta /= ptCutOffCorrection;
538 error /= ptCutOffCorrection;
540 fdNdEtaPtCutOffCorrected[vertexPos]->SetBinContent(bin, dndeta);
541 fdNdEtaPtCutOffCorrected[vertexPos]->SetBinError(bin, error);
543 //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);
549 //____________________________________________________________________
550 Float_t dNdEtaAnalysis::GetVtxMin(Float_t eta)
552 // helper function for the SPD acceptance
553 // the function returns the beginning of the acceptance window in z vertex position as function of eta
554 // to get the maximum: -GetVtxMin(-eta)
556 Float_t a[2] = { -15, 0 };
557 Float_t b[2] = { 0, -1.4 };
558 Float_t c[2] = { 15, -2.2 };
561 meanAB[0] = (b[0] + a[0]) / 2;
562 meanAB[1] = (b[1] + a[1]) / 2;
565 meanBC[0] = (c[0] + b[0]) / 2;
566 meanBC[1] = (c[1] + b[1]) / 2;
568 Float_t mAB = (b[1] - a[1]) / (b[0] - a[0]);
569 Float_t mBC = (c[1] - b[1]) / (c[0] - b[0]);
571 Float_t bAB = meanAB[1] - mAB * meanAB[0];
572 Float_t bBC = meanBC[1] - mBC * meanBC[0];
575 return 1.0 / mAB * eta - bAB / mAB;
577 return 1.0 / mBC * eta - bBC / mBC;
580 //____________________________________________________________________
581 void dNdEtaAnalysis::SaveHistograms()
583 // save the histograms to a directory with the name of this class (retrieved from TNamed)
585 gDirectory->mkdir(GetName());
586 gDirectory->cd(GetName());
590 fData->SaveHistograms();
593 printf("dNdEtaAnalysis::SaveHistograms: UNEXPECTED: fData is 0\n");
600 printf("dNdEtaAnalysis::SaveHistograms: UNEXPECTED: fMult is 0\n");
605 printf("dNdEtaAnalysis::SaveHistograms: UNEXPECTED: fPtDist is 0\n");
607 for (Int_t i=0; i<kVertexBinning; ++i)
612 printf("dNdEtaAnalysis::SaveHistograms: UNEXPECTED: fdNdEta[%d] is 0\n", i);
614 if (fdNdEtaPtCutOffCorrected[i])
615 fdNdEtaPtCutOffCorrected[i]->Write();
617 printf("dNdEtaAnalysis::SaveHistograms: UNEXPECTED: fdNdEtaPtCutOffCorrected[%d] is 0\n", i);
620 TNamed named("fTag", fTag.Data());
623 TParameter<Int_t> param("fAnalysisMode", fAnalysisMode);
626 gDirectory->cd("../");
629 void dNdEtaAnalysis::LoadHistograms(const Char_t* dir)
631 // loads the histograms from a directory with the name of this class (retrieved from TNamed)
638 fData->LoadHistograms();
639 fMult = dynamic_cast<TH1F*> (gDirectory->Get(fMult->GetName()));
641 for (Int_t i=0; i<kVertexBinning; ++i)
643 fdNdEta[i] = dynamic_cast<TH1F*> (gDirectory->Get(fdNdEta[i]->GetName()));
644 fdNdEtaPtCutOffCorrected[i] = dynamic_cast<TH1F*> (gDirectory->Get(fdNdEtaPtCutOffCorrected[i]->GetName()));
647 fPtDist = dynamic_cast<TH1F*> (gDirectory->Get(fPtDist->GetName()));
649 if (dynamic_cast<TNamed*> (gDirectory->Get("fTag")))
650 fTag = (dynamic_cast<TNamed*> (gDirectory->Get("fTag")))->GetTitle();
652 if (dynamic_cast<TParameter<Int_t>*> (gDirectory->Get("fAnalysisMode")))
653 fAnalysisMode = (AliPWG0Helper::AnalysisMode) (dynamic_cast<TParameter<Int_t>*> (gDirectory->Get("fAnalysisMode")))->GetVal();
655 gDirectory->cd("../");
658 //____________________________________________________________________
659 void dNdEtaAnalysis::DrawHistograms(Bool_t simple)
661 // draws the histograms
666 fData->DrawHistograms(GetName());
668 TCanvas* canvas = new TCanvas(Form("%s_dNdEtaAnalysis", GetName()), Form("%s_dNdEtaAnalysis", GetName()), 800, 400);
669 canvas->Divide(2, 1);
672 if (fdNdEtaPtCutOffCorrected[0])
673 fdNdEtaPtCutOffCorrected[0]->DrawCopy();
677 fdNdEta[0]->SetLineColor(kRed);
678 fdNdEta[0]->DrawCopy("SAME");
686 // histograms for different vertices?
687 if (kVertexBinning > 0)
689 // doesnt work, but i dont get it, giving up...
690 TCanvas* canvas2 = new TCanvas(Form("%s_dNdEtaAnalysisVtx", GetName()), Form("%s_dNdEtaAnalysisVtx", GetName()), 450, 450);
691 TCanvas* canvas3 = 0;
693 canvas3 = new TCanvas(Form("%s_dNdEtaAnalysisVtx_noptcutoff", GetName()), Form("%s_dNdEtaAnalysisVtx_noptcutoff", GetName()), 450, 450);
695 //Int_t yPads = (Int_t) TMath::Ceil(((Double_t) kVertexBinning - 1) / 2);
696 //printf("%d\n", yPads);
697 //canvas2->Divide(2, yPads);
699 TLegend* legend = new TLegend(0.4, 0.2, 0.6, 0.4);
701 for (Int_t i=0; i<kVertexBinning; ++i)
703 if (fdNdEtaPtCutOffCorrected[i])
707 fdNdEtaPtCutOffCorrected[i]->SetLineColor(i+1);
708 fdNdEtaPtCutOffCorrected[i]->DrawCopy((i == 0) ? "" : "SAME");
709 legend->AddEntry(fdNdEtaPtCutOffCorrected[i], (i == 0) ? "Vtx All" : Form("Vtx Bin %d", i-1));
711 if (canvas3 && fdNdEta[i])
715 fdNdEta[i]->SetLineColor(i+1);
716 fdNdEta[i]->DrawCopy((i == 0) ? "" : "SAME");
722 canvas2->SaveAs(Form("%s_%s.gif", canvas2->GetName(), GetName()));
731 if (kVertexBinning == 3)
733 TH1* clone = dynamic_cast<TH1*> (fdNdEtaPtCutOffCorrected[1]->Clone("clone"));
734 TH1* clone2 = dynamic_cast<TH1*> (fdNdEtaPtCutOffCorrected[2]->Clone("clone2"));
738 TCanvas* canvas4 = new TCanvas(Form("%s_dNdEtaAnalysisVtxRatios", GetName()), Form("%s_dNdEtaAnalysisVtxRatios", GetName()), 450, 450);
740 clone->Divide(fdNdEtaPtCutOffCorrected[0]);
741 clone->GetYaxis()->SetRangeUser(0.95, 1.05);
744 clone2->Divide(fdNdEtaPtCutOffCorrected[0]);
745 clone2->DrawCopy("SAME");
747 TLine* line = new TLine(-1, 1, 1, 1);
750 canvas4->SaveAs(Form("%s_%s.gif", canvas4->GetName(), GetName()));
755 Long64_t dNdEtaAnalysis::Merge(TCollection* list)
757 // Merges a list of dNdEtaAnalysis objects with this one.
758 // This is needed for PROOF.
759 // Returns the number of merged objects (including this)
767 TIterator* iter = list->MakeIterator();
771 const Int_t nCollections = 2 * kVertexBinning + 3; // 3 standalone hists, 3 arrays of size kVertexBinning
772 TList* collections[nCollections];
773 for (Int_t i=0; i<nCollections; ++i)
774 collections[i] = new TList;
777 while ((obj = iter->Next()))
779 dNdEtaAnalysis* entry = dynamic_cast<dNdEtaAnalysis*> (obj);
783 collections[0]->Add(entry->fData);
784 collections[1]->Add(entry->fMult);
785 collections[2]->Add(entry->fPtDist);
787 for (Int_t i=0; i<kVertexBinning; ++i)
789 collections[3+i]->Add(entry->fdNdEta[i]);
790 collections[3+kVertexBinning+i]->Add(entry->fdNdEtaPtCutOffCorrected[i]);
796 fData->Merge(collections[0]);
797 fMult->Merge(collections[1]);
798 fPtDist->Merge(collections[2]);
800 for (Int_t i=0; i<kVertexBinning; ++i)
802 fdNdEta[i]->Merge(collections[3+i]);
803 fdNdEtaPtCutOffCorrected[i]->Merge(collections[3+kVertexBinning+i]);
806 for (Int_t i=0; i<nCollections; ++i)
807 delete collections[i];