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),
39 // default constructor
41 for (Int_t i=0; i<kVertexBinning; ++i)
44 fdNdEtaPtCutOffCorrected[i] = 0;
48 //____________________________________________________________________
49 dNdEtaAnalysis::dNdEtaAnalysis(const Char_t* name, const Char_t* title, AliPWG0Helper::AnalysisMode analysisMode) :
54 fAnalysisMode(analysisMode),
61 fData = new AliCorrection("Analysis", Form("%s Analysis", title), analysisMode);
63 // do not add this hists to the directory
64 Bool_t oldStatus = TH1::AddDirectoryStatus();
65 TH1::AddDirectory(kFALSE);
67 fMult = new TH1F("TriggeredMultiplicity", "Triggered Events;raw multiplicity;entries", 1000, -0.5, 999.5);
69 TH1* histForBinning = fData->GetTrackCorrection()->GetGeneratedHistogram();
70 fdNdEta[0] = new TH1F("dNdEta", "dN_{ch}/d#eta;#eta;dN_{ch}/d#eta", histForBinning->GetNbinsY(), histForBinning->GetYaxis()->GetXbins()->GetArray());
72 fdNdEtaPtCutOffCorrected[0] = dynamic_cast<TH1F*> (fdNdEta[0]->Clone(Form("%s_corrected", fdNdEta[0]->GetName())));
74 for (Int_t i=1; i<kVertexBinning; ++i)
76 fdNdEta[i] = dynamic_cast<TH1F*> (fdNdEta[0]->Clone(Form("%s_%d", fdNdEta[0]->GetName(), i)));
77 fdNdEtaPtCutOffCorrected[i] = dynamic_cast<TH1F*> (fdNdEtaPtCutOffCorrected[0]->Clone(Form("%s_%d", fdNdEtaPtCutOffCorrected[0]->GetName(), i)));
80 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());
82 TH1::AddDirectory(oldStatus);
85 //____________________________________________________________________
86 dNdEtaAnalysis::~dNdEtaAnalysis()
102 for (Int_t i=0; i<kVertexBinning; ++i)
109 if (fdNdEtaPtCutOffCorrected[i])
111 delete fdNdEtaPtCutOffCorrected[i];
112 fdNdEtaPtCutOffCorrected[i] = 0;
123 //_____________________________________________________________________________
124 dNdEtaAnalysis::dNdEtaAnalysis(const dNdEtaAnalysis &c) :
129 fAnalysisMode(AliPWG0Helper::kInvalid),
135 // dNdEtaAnalysis copy constructor
138 ((dNdEtaAnalysis &) c).Copy(*this);
141 //_____________________________________________________________________________
142 dNdEtaAnalysis &dNdEtaAnalysis::operator=(const dNdEtaAnalysis &c)
145 // Assignment operator
148 if (this != &c) ((dNdEtaAnalysis &) c).Copy(*this);
152 //_____________________________________________________________________________
153 void dNdEtaAnalysis::Copy(TObject &c) const
159 dNdEtaAnalysis& target = (dNdEtaAnalysis &) c;
161 target.fData = dynamic_cast<AliCorrection*> (fData->Clone());
162 target.fMult = dynamic_cast<TH1F*> (fMult->Clone());
164 for (Int_t i=0; i<kVertexBinning; ++i)
166 target.fdNdEta[i] = dynamic_cast<TH1F*> (fdNdEta[i]->Clone());
167 target.fdNdEtaPtCutOffCorrected[i] = dynamic_cast<TH1F*> (fdNdEtaPtCutOffCorrected[i]->Clone());
170 target.fPtDist = dynamic_cast<TH1F*> (fPtDist->Clone());
172 target.fAnalysisMode = fAnalysisMode;
175 TNamed::Copy((TNamed &) c);
178 //____________________________________________________________________
179 void dNdEtaAnalysis::FillTrack(Float_t vtx, Float_t eta, Float_t pt)
181 // fills a track into the histograms
183 fData->GetTrackCorrection()->FillMeas(vtx, eta, pt);
186 //____________________________________________________________________
187 void dNdEtaAnalysis::FillEvent(Float_t vtx, Float_t n)
189 // fills an event into the histograms
191 fData->GetEventCorrection()->FillMeas(vtx, n);
194 //____________________________________________________________________
195 void dNdEtaAnalysis::FillTriggeredEvent(Float_t n)
197 // fills a triggered event into the histograms
202 //____________________________________________________________________
203 void dNdEtaAnalysis::Finish(AlidNdEtaCorrection* correction, Float_t ptCut, AlidNdEtaCorrection::CorrectionType correctionType, const char* tag, Int_t backgroundSubtraction, TH1* combinatoricsCorrection)
206 // correct with the given correction values and calculate dNdEta and pT distribution
207 // the corrections that are applied can be steered by the flag correctionType
208 // the measured result is not used up to a multiplicity of multCut (the bin at multCut is the first that is used!)
211 fTag.Form("Correcting dN/deta spectrum (data: %d) >>> %s <<<. Correction type: %d, pt cut: %.2f.", (Int_t) fAnalysisMode, tag, (Int_t) correctionType, ptCut);
212 Printf("\n\n%s", fTag.Data());
214 if (combinatoricsCorrection)
215 Printf("Combinatorics subtraction active!");
217 // set corrections to 1
218 fData->SetCorrectionToUnity();
220 if (correction && correctionType != AlidNdEtaCorrection::kNone)
222 TH3* trackCorr = fData->GetTrackCorrection()->GetCorrectionHistogram();
223 TH2* eventCorr = fData->GetEventCorrection()->GetCorrectionHistogram();
225 if (correctionType >= AlidNdEtaCorrection::kTrack2Particle)
226 trackCorr->Multiply(correction->GetTrack2ParticleCorrection()->GetTrackCorrection()->GetCorrectionHistogram());
228 if (correctionType >= AlidNdEtaCorrection::kVertexReco)
230 trackCorr->Multiply(correction->GetVertexRecoCorrection()->GetTrackCorrection()->GetCorrectionHistogram());
231 eventCorr->Multiply(correction->GetVertexRecoCorrection()->GetEventCorrection()->GetCorrectionHistogram());
233 // set bin with multiplicity 0 to unity (correction has no meaning in this bin)
234 for (Int_t i=0; i<=eventCorr->GetNbinsX()+1; i++)
235 eventCorr->SetBinContent(i, 1, 1);
238 switch (correctionType)
240 case AlidNdEtaCorrection::kINEL :
242 trackCorr->Multiply(correction->GetTriggerBiasCorrectionINEL()->GetTrackCorrection()->GetCorrectionHistogram());
243 eventCorr->Multiply(correction->GetTriggerBiasCorrectionINEL()->GetEventCorrection()->GetCorrectionHistogram());
246 case AlidNdEtaCorrection::kNSD :
248 trackCorr->Multiply(correction->GetTriggerBiasCorrectionNSD()->GetTrackCorrection()->GetCorrectionHistogram());
249 eventCorr->Multiply(correction->GetTriggerBiasCorrectionNSD()->GetEventCorrection()->GetCorrectionHistogram());
252 case AlidNdEtaCorrection::kND :
254 trackCorr->Multiply(correction->GetTriggerBiasCorrectionND()->GetTrackCorrection()->GetCorrectionHistogram());
255 eventCorr->Multiply(correction->GetTriggerBiasCorrectionND()->GetEventCorrection()->GetCorrectionHistogram());
258 case AlidNdEtaCorrection::kOnePart :
260 trackCorr->Multiply(correction->GetTriggerBiasCorrectionOnePart()->GetTrackCorrection()->GetCorrectionHistogram());
261 eventCorr->Multiply(correction->GetTriggerBiasCorrectionOnePart()->GetEventCorrection()->GetCorrectionHistogram());
268 printf("INFO: No correction applied\n");
270 TH2F* rawMeasured = (TH2F*) fData->GetEventCorrection()->GetMeasuredHistogram()->Clone("rawMeasured");
272 fData->ResetErrorsOnCorrections();
275 if (correction && correctionType >= AlidNdEtaCorrection::kVertexReco)
277 // There are no events with vertex that have 0 multiplicity, therefore
278 // populate bin with 0 multiplicity with the following idea:
279 // alpha = triggered events with vertex at a given vertex position / all triggered events with vertex
280 // triggered events without vertex and 0 multiplicity at a given vertex position = alpha * all triggered events with 0 multiplicity
281 // afterwards we still correct for the trigger efficiency
282 // at the same time calculate expectation from MC (not used, just to check the value)
284 //TH2* measuredEvents = fData->GetEventCorrection()->GetMeasuredHistogram();
285 TH2* correctedEvents = fData->GetEventCorrection()->GetGeneratedHistogram();
287 TH2* eAll = correction->GetCorrection(correctionType)->GetEventCorrection()->GetGeneratedHistogram();
288 TH2* eTrig = correction->GetVertexRecoCorrection()->GetEventCorrection()->GetGeneratedHistogram();
289 TH2* eTrigVtx = correction->GetVertexRecoCorrection()->GetEventCorrection()->GetMeasuredHistogram();
290 TH1* eTrigVtx_projx = eTrigVtx->ProjectionX("eTrigVtx_projx", 2, eTrigVtx->GetNbinsY()+1);
292 //new TCanvas; correctedEvents->DrawCopy("TEXT");
294 // start above 0 mult. bin with integration
295 TH1* vertexDist = rawMeasured->ProjectionX("vertexdist_measured", 2, rawMeasured->GetNbinsY()+1);
296 //new TCanvas; vertexDist->DrawCopy();
298 Int_t allEventsWithVertex = (Int_t) vertexDist->Integral(0, vertexDist->GetNbinsX()+1); // include under/overflow!
299 Int_t triggeredEventsWith0Mult = (Int_t) fMult->GetBinContent(1);
301 Printf("%d triggered events with 0 mult. -- %d triggered events with vertex", triggeredEventsWith0Mult, allEventsWithVertex);
303 if (backgroundSubtraction > 0)
305 triggeredEventsWith0Mult -= backgroundSubtraction;
306 Printf("Subtracted %d background events from 0 mult. bin", backgroundSubtraction);
309 TH1* kineBias = (TH1*) vertexDist->Clone("kineBias");
312 // loop over vertex bins
313 for (Int_t i = 1; i <= rawMeasured->GetNbinsX(); i++)
315 Double_t alpha = (Double_t) vertexDist->GetBinContent(i) / allEventsWithVertex;
316 Double_t events = alpha * triggeredEventsWith0Mult;
318 if (eTrigVtx_projx->GetBinContent(i) == 0)
321 // calculate how many events we would have got with a pure MC-based correction
322 // 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
323 Printf("+++ 0-Bin Correction for bin %d +++", i);
324 Printf(" Events: %f", vertexDist->GetBinContent(i));
325 Printf(" Ratio triggered N==0 / triggered vertex N>0: %f", eTrig->GetBinContent(i, 1) / eTrigVtx_projx->GetBinContent(i));
326 Printf(" Ratio all N==0 / triggered vertex N>0: %f", eAll->GetBinContent(i, 1) / eTrigVtx_projx->GetBinContent(i));
327 Printf(" Correction factor: %f", fData->GetEventCorrection()->GetCorrectionHistogram()->GetBinContent(i, 1));
329 //Double_t mcEvents = vertexDist->GetBinContent(i) * eTrig->GetBinContent(i, 1) / eTrigVtx_projx->GetBinContent(i) * fData->GetEventCorrection()->GetCorrectionHistogram()->GetBinContent(i, 1);
330 Double_t mcEvents = vertexDist->GetBinContent(i) * eAll->GetBinContent(i, 1) / eTrigVtx_projx->GetBinContent(i);
331 if (backgroundSubtraction == -1)
333 Printf("Using MC value for 0-bin correction!");
338 Double_t fZ = eTrigVtx_projx->Integral(0, eTrigVtx_projx->GetNbinsX()+1) / eTrigVtx_projx->GetBinContent(i) *
339 eTrig->GetBinContent(i, 1) / eTrig->Integral(0, eTrig->GetNbinsX()+1, 1, 1);
341 kineBias->SetBinContent(i, fZ);
345 // multiply with trigger correction if set above
346 events *= fData->GetEventCorrection()->GetCorrectionHistogram()->GetBinContent(i, 1);
348 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);
351 correctedEvents->SetBinContent(i, 1, events);
354 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));
356 //new TCanvas; correctedEvents->DrawCopy("TEXT");
357 //new TCanvas; kineBias->DrawCopy();
360 fData->PrintInfo(ptCut);
362 TH3* dataHist = fData->GetTrackCorrection()->GetGeneratedHistogram();
364 // integrate multiplicity axis out (include under/overflow bins!!!)
365 TH2* tmp = fData->GetEventCorrection()->GetGeneratedHistogram();
367 TH1D* vertexHist = (TH1D*) tmp->ProjectionX("_px", 0, tmp->GetNbinsY() + 1, "e");
370 if (fAnalysisMode & AliPWG0Helper::kTPC || fAnalysisMode & AliPWG0Helper::kTPCITS)
373 dataHist->GetXaxis()->SetRange(0, 0);
374 dataHist->GetYaxis()->SetRange(0, 0);
375 dataHist->GetZaxis()->SetRange(0, 0);
378 Int_t vertexBinBegin = dataHist->GetXaxis()->FindBin(-5);
379 Int_t vertexBinEnd = dataHist->GetXaxis()->FindBin(5);
380 dataHist->GetXaxis()->SetRange(vertexBinBegin, vertexBinEnd);
381 Float_t nEvents = vertexHist->Integral(vertexBinBegin, vertexBinEnd);
386 dataHist->GetYaxis()->SetRange(dataHist->GetYaxis()->FindBin(-0.8), dataHist->GetYaxis()->FindBin(0.8));
387 Float_t etaWidth = 1.6;
389 TH1D* ptHist = static_cast<TH1D*> (dataHist->Project3D("ze"));
391 for (Int_t i=1; i<=fPtDist->GetNbinsX(); ++i)
393 Float_t binSize = fPtDist->GetBinWidth(i);
394 fPtDist->SetBinContent(i, ptHist->GetBinContent(i) / binSize / nEvents / etaWidth);
395 fPtDist->SetBinError(i, ptHist->GetBinError(i) / binSize / nEvents / etaWidth);
401 printf("ERROR: nEvents is 0!\n");
405 dataHist->GetXaxis()->SetRange(0, 0);
406 dataHist->GetYaxis()->SetRange(0, 0);
407 dataHist->GetZaxis()->SetRange(0, 0);
409 // integrate over pt (with pt cut) (TPC, TPCITS) or multiplicity (SPD)
411 if (ptCut > 0 && (fAnalysisMode & AliPWG0Helper::kTPC || fAnalysisMode & AliPWG0Helper::kTPCITS))
412 ptLowBin = dataHist->GetZaxis()->FindBin(ptCut);
414 //new TCanvas; dataHist->DrawCopy();
417 dataHist->GetZaxis()->SetRange(ptLowBin, dataHist->GetZaxis()->GetNbins()+1);
418 printf("pt/multiplicity range %d %d\n", ptLowBin, dataHist->GetZaxis()->GetNbins()+1);
419 TH2D* vtxVsEta = dynamic_cast<TH2D*> (dataHist->Project3D("yx2e"));
421 //new TCanvas; vtxVsEta->Draw("COLZ");
423 dataHist->GetZaxis()->SetRange(0, 0);
424 vtxVsEta->GetXaxis()->SetTitle(dataHist->GetXaxis()->GetTitle());
425 vtxVsEta->GetYaxis()->SetTitle(dataHist->GetYaxis()->GetTitle());
429 printf("ERROR: pt/multiplicity integration failed\n");
433 //new TCanvas(tag, tag, 800, 600); vtxVsEta->DrawCopy("COLZ");
435 // clear result histograms
436 for (Int_t vertexPos=0; vertexPos<kVertexBinning; ++vertexPos)
438 fdNdEta[vertexPos]->Reset();
439 fdNdEtaPtCutOffCorrected[vertexPos]->Reset();
442 //const Float_t vertexRangeBegin[kVertexBinning] = { -9.99, -9.99, 0.01 };
443 //const Float_t vertexRangeEnd[kVertexBinning] = { 9.99, -0.01, 9.99 };
444 const Float_t vertexRangeBegin[kVertexBinning] = { fvtxMin, fvtxMin, 0.01 };
445 const Float_t vertexRangeEnd[kVertexBinning] = { fvtxMax, -0.01, fvtxMax };
447 for (Int_t iEta=1; iEta<=vtxVsEta->GetNbinsY(); iEta++)
449 // loop over vertex ranges
450 for (Int_t vertexPos=0; vertexPos<kVertexBinning; ++vertexPos)
452 Int_t vertexBinBegin = vertexHist->GetXaxis()->FindBin(vertexRangeBegin[vertexPos]);
453 Int_t vertexBinEnd = vertexHist->GetXaxis()->FindBin(vertexRangeEnd[vertexPos]);
455 const Int_t *binBegin = 0;
456 const Int_t maxBins = 20;
457 const Int_t maxBins1 = 40;
459 if (dataHist->GetNbinsY() != maxBins)
460 AliFatal(Form("Binning of acceptance is different from data histogram: data=%d, acceptance=%d", dataHist->GetNbinsY(), maxBins));
462 // adjust acceptance range
463 // produce with drawPlots.C: DetermineAcceptance(...)
465 //const Int_t binBeginSPD[maxBins] = {19, 18, 17, 15, 14, 12, 10, 9, 8, 7, 6, 6, 5, 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};
466 //const Int_t binBeginTPC[maxBins] = {-1, -1, -1, -1, -1, -1, 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, 4, 4, 4, 4, -1, -1, -1, -1, -1};
467 //const Int_t binBeginTPCITS[maxBins] = {-1, -1, -1, -1, -1, -1, -1, 14, 10, 8, 7, 6, 5, 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};
469 const Int_t binBeginSPD[maxBins1] = {19, 18, 17, 15, 14, 12, 10, 9, 8, 7, 6, 6, 5, 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};
470 const Int_t binBeginTPC[maxBins1] = {-1, -1, -1, -1, -1, -1, 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, 4, 4, 4, 4, -1, -1, -1, -1, -1};
471 const Int_t binBeginTPCITS[maxBins] = {-1, -1, -1, -1, -1, -1, 4, 4, 4, 4, 4, 4, 4, 4, -1, -1, -1, -1, -1, -1};
472 if (fAnalysisMode & AliPWG0Helper::kSPD)
474 binBegin = binBeginSPD;
476 else if (fAnalysisMode & AliPWG0Helper::kTPC)
478 binBegin = binBeginTPC;
480 else if (fAnalysisMode & AliPWG0Helper::kTPCITS)
482 binBegin = binBeginTPCITS;
486 Int_t vtxEnd = maxBins;
490 vtxBegin = binBegin[iEta - 1];
491 vtxEnd = (Int_t) vtxVsEta->GetNbinsX() + 1 - binBegin[maxBins - iEta];
494 Printf("WARNING: No acceptance applied!");
496 // eta range not accessible
500 //Printf("%d %d | %d %d", vtxBegin, vertexHist->GetXaxis()->FindBin(GetVtxMin(eta)), vtxEnd, vertexHist->GetXaxis()->FindBin(-GetVtxMin(-eta)));
501 //vtxBegin = vertexHist->GetXaxis()->FindBin(GetVtxMin(eta));
502 //vtxEnd = vertexHist->GetXaxis()->FindBin(-GetVtxMin(-eta));
504 //Float_t eta = vtxVsEta->GetYaxis()->GetBinCenter(iEta);
505 //printf("Eta bin: %d (%f) Vertex range: %d; before: %d %d (range) %d %d (acceptance)", iEta, eta, vertexPos, vertexBinBegin, vertexBinEnd, vtxBegin, vtxEnd);
506 vertexBinBegin = TMath::Max(vertexBinBegin, vtxBegin);
507 vertexBinEnd = TMath::Min(vertexBinEnd, vtxEnd);
508 //Printf(" after: %d %d", vertexBinBegin, vertexBinEnd);
510 // no data for this bin
511 if (vertexBinBegin > vertexBinEnd)
513 //Printf("Bin empty. Skipped");
517 Float_t totalEvents = 0;
519 Float_t sumError2 = 0;
520 Float_t unusedTracks = 0;
521 Float_t unusedEvents = 0;
522 for (Int_t iVtx = 1; iVtx <= vtxVsEta->GetNbinsX(); iVtx++)
524 if (iVtx >= vertexBinBegin && iVtx <= vertexBinEnd)
526 if (vtxVsEta->GetBinContent(iVtx, iEta) != 0)
528 sum += vtxVsEta->GetBinContent(iVtx, iEta);
530 if (sumError2 > 10e30)
531 Printf("WARNING: sum of error2 is dangerously large - be prepared for crash... ");
533 sumError2 = sumError2 + TMath::Power(vtxVsEta->GetBinError(iVtx, iEta),2);
535 totalEvents += vertexHist->GetBinContent(iVtx);
539 unusedTracks += vtxVsEta->GetBinContent(iVtx, iEta);
540 unusedEvents += vertexHist->GetBinContent(iVtx);
544 if (totalEvents == 0)
546 printf("WARNING: No events for hist %d %d %d\n", vertexPos, vertexBinBegin, vertexBinEnd);
550 Float_t ptCutOffCorrection = 1;
552 // find pt cut off correction factor
553 if ((fAnalysisMode & AliPWG0Helper::kTPC || fAnalysisMode & AliPWG0Helper::kTPCITS) && (fAnalysisMode & AliPWG0Helper::kFieldOn))
555 if (correction && ptCut > 0)
556 ptCutOffCorrection = correction->GetMeasuredFraction(correctionType, ptCut, vtxVsEta->GetYaxis()->GetBinCenter(iEta), vertexBinBegin, vertexBinEnd);
558 if (ptCutOffCorrection <= 0)
560 printf("UNEXPECTED: ptCutOffCorrection is %f for hist %d %d %d\n", ptCutOffCorrection, vertexPos, vertexBinBegin, vertexBinEnd);
565 //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);
567 Int_t bin = fdNdEta[vertexPos]->FindBin(vtxVsEta->GetYaxis()->GetBinCenter(iEta));
568 if (bin > 0 && bin <= fdNdEta[vertexPos]->GetNbinsX())
570 Float_t dndeta = sum / totalEvents;
571 Float_t error = TMath::Sqrt(sumError2) / totalEvents;
573 // correct for additional combinatorics
574 Float_t combCorr = 0;
575 if (combinatoricsCorrection)
577 combCorr = combinatoricsCorrection->GetBinContent(combinatoricsCorrection->GetXaxis()->FindBin(vtxVsEta->GetYaxis()->GetBinCenter(iEta)));
582 dndeta = dndeta / fdNdEta[vertexPos]->GetBinWidth(bin);
583 error = error / fdNdEta[vertexPos]->GetBinWidth(bin);
585 fdNdEta[vertexPos]->SetBinContent(bin, dndeta);
586 fdNdEta[vertexPos]->SetBinError(bin, error);
588 dndeta /= ptCutOffCorrection;
589 error /= ptCutOffCorrection;
591 fdNdEtaPtCutOffCorrected[vertexPos]->SetBinContent(bin, dndeta);
592 fdNdEtaPtCutOffCorrected[vertexPos]->SetBinError(bin, error);
594 //Printf("Bin %d has dN/deta = %f +- %f; %.2f tracks %.2f events (outside acceptance: %.2f tracks, %.2f events) (comb. corr: %f)", bin, dndeta, error, sum, totalEvents, unusedTracks, unusedEvents, combCorr);
600 //____________________________________________________________________
601 Float_t dNdEtaAnalysis::GetVtxMin(Float_t eta)
603 // helper function for the SPD acceptance
604 // the function returns the beginning of the acceptance window in z vertex position as function of eta
605 // to get the maximum: -GetVtxMin(-eta)
607 Float_t a[2] = { -15, 0 };
608 Float_t b[2] = { 0, -1.4 };
609 Float_t c[2] = { 15, -2.2 };
612 meanAB[0] = (b[0] + a[0]) / 2;
613 meanAB[1] = (b[1] + a[1]) / 2;
616 meanBC[0] = (c[0] + b[0]) / 2;
617 meanBC[1] = (c[1] + b[1]) / 2;
619 Float_t mAB = (b[1] - a[1]) / (b[0] - a[0]);
620 Float_t mBC = (c[1] - b[1]) / (c[0] - b[0]);
622 Float_t bAB = meanAB[1] - mAB * meanAB[0];
623 Float_t bBC = meanBC[1] - mBC * meanBC[0];
626 return 1.0 / mAB * eta - bAB / mAB;
628 return 1.0 / mBC * eta - bBC / mBC;
631 //____________________________________________________________________
632 void dNdEtaAnalysis::SaveHistograms()
634 // save the histograms to a directory with the name of this class (retrieved from TNamed)
636 gDirectory->mkdir(GetName());
637 gDirectory->cd(GetName());
641 fData->SaveHistograms();
644 printf("dNdEtaAnalysis::SaveHistograms: UNEXPECTED: fData is 0\n");
651 printf("dNdEtaAnalysis::SaveHistograms: UNEXPECTED: fMult is 0\n");
656 printf("dNdEtaAnalysis::SaveHistograms: UNEXPECTED: fPtDist is 0\n");
658 for (Int_t i=0; i<kVertexBinning; ++i)
663 printf("dNdEtaAnalysis::SaveHistograms: UNEXPECTED: fdNdEta[%d] is 0\n", i);
665 if (fdNdEtaPtCutOffCorrected[i])
666 fdNdEtaPtCutOffCorrected[i]->Write();
668 printf("dNdEtaAnalysis::SaveHistograms: UNEXPECTED: fdNdEtaPtCutOffCorrected[%d] is 0\n", i);
671 TNamed named("fTag", fTag.Data());
674 TParameter<Int_t> param("fAnalysisMode", fAnalysisMode);
677 gDirectory->cd("../");
680 void dNdEtaAnalysis::LoadHistograms(const Char_t* dir)
682 // loads the histograms from a directory with the name of this class (retrieved from TNamed)
689 fData->LoadHistograms();
690 fMult = dynamic_cast<TH1F*> (gDirectory->Get(fMult->GetName()));
692 for (Int_t i=0; i<kVertexBinning; ++i)
694 fdNdEta[i] = dynamic_cast<TH1F*> (gDirectory->Get(fdNdEta[i]->GetName()));
695 fdNdEtaPtCutOffCorrected[i] = dynamic_cast<TH1F*> (gDirectory->Get(fdNdEtaPtCutOffCorrected[i]->GetName()));
698 fPtDist = dynamic_cast<TH1F*> (gDirectory->Get(fPtDist->GetName()));
700 if (static_cast<TNamed*> (gDirectory->Get("fTag")))
701 fTag = (static_cast<TNamed*> (gDirectory->Get("fTag")))->GetTitle();
703 if (static_cast<TParameter<Int_t>*> (gDirectory->Get("fAnalysisMode")))
704 fAnalysisMode = (AliPWG0Helper::AnalysisMode) (static_cast<TParameter<Int_t>*> (gDirectory->Get("fAnalysisMode")))->GetVal();
706 gDirectory->cd("../");
709 //____________________________________________________________________
710 void dNdEtaAnalysis::DrawHistograms(Bool_t simple)
712 // draws the histograms
717 fData->DrawHistograms(GetName());
719 TCanvas* canvas = new TCanvas(Form("%s_dNdEtaAnalysis", GetName()), Form("%s_dNdEtaAnalysis", GetName()), 800, 400);
720 canvas->Divide(2, 1);
723 if (fdNdEtaPtCutOffCorrected[0])
724 fdNdEtaPtCutOffCorrected[0]->DrawCopy();
728 fdNdEta[0]->SetLineColor(kRed);
729 fdNdEta[0]->DrawCopy("SAME");
737 // histograms for different vertices?
738 if (kVertexBinning > 0)
740 // doesnt work, but i dont get it, giving up...
741 TCanvas* canvas2 = new TCanvas(Form("%s_dNdEtaAnalysisVtx", GetName()), Form("%s_dNdEtaAnalysisVtx", GetName()), 450, 450);
742 TCanvas* canvas3 = 0;
744 canvas3 = new TCanvas(Form("%s_dNdEtaAnalysisVtx_noptcutoff", GetName()), Form("%s_dNdEtaAnalysisVtx_noptcutoff", GetName()), 450, 450);
746 //Int_t yPads = (Int_t) TMath::Ceil(((Double_t) kVertexBinning - 1) / 2);
747 //printf("%d\n", yPads);
748 //canvas2->Divide(2, yPads);
750 TLegend* legend = new TLegend(0.4, 0.2, 0.6, 0.4);
752 for (Int_t i=0; i<kVertexBinning; ++i)
754 if (fdNdEtaPtCutOffCorrected[i])
758 fdNdEtaPtCutOffCorrected[i]->SetLineColor(i+1);
759 fdNdEtaPtCutOffCorrected[i]->DrawCopy((i == 0) ? "" : "SAME");
760 legend->AddEntry(fdNdEtaPtCutOffCorrected[i], (i == 0) ? "Vtx All" : Form("Vtx Bin %d", i-1));
762 if (canvas3 && fdNdEta[i])
766 fdNdEta[i]->SetLineColor(i+1);
767 fdNdEta[i]->DrawCopy((i == 0) ? "" : "SAME");
773 canvas2->SaveAs(Form("%s_%s.gif", canvas2->GetName(), GetName()));
782 if (kVertexBinning == 3)
784 TH1* clone = dynamic_cast<TH1*> (fdNdEtaPtCutOffCorrected[1]->Clone("clone"));
785 TH1* clone2 = dynamic_cast<TH1*> (fdNdEtaPtCutOffCorrected[2]->Clone("clone2"));
789 TCanvas* canvas4 = new TCanvas(Form("%s_dNdEtaAnalysisVtxRatios", GetName()), Form("%s_dNdEtaAnalysisVtxRatios", GetName()), 450, 450);
791 clone->Divide(fdNdEtaPtCutOffCorrected[0]);
792 clone->GetYaxis()->SetRangeUser(0.95, 1.05);
795 clone2->Divide(fdNdEtaPtCutOffCorrected[0]);
796 clone2->DrawCopy("SAME");
798 TLine* line = new TLine(-1, 1, 1, 1);
801 canvas4->SaveAs(Form("%s_%s.gif", canvas4->GetName(), GetName()));
806 Long64_t dNdEtaAnalysis::Merge(TCollection* list)
808 // Merges a list of dNdEtaAnalysis objects with this one.
809 // This is needed for PROOF.
810 // Returns the number of merged objects (including this)
818 TIterator* iter = list->MakeIterator();
822 const Int_t nCollections = 2 * kVertexBinning + 3; // 3 standalone hists, 3 arrays of size kVertexBinning
823 TList* collections[nCollections];
824 for (Int_t i=0; i<nCollections; ++i)
825 collections[i] = new TList;
828 while ((obj = iter->Next()))
830 dNdEtaAnalysis* entry = dynamic_cast<dNdEtaAnalysis*> (obj);
834 collections[0]->Add(entry->fData);
835 collections[1]->Add(entry->fMult);
836 collections[2]->Add(entry->fPtDist);
838 for (Int_t i=0; i<kVertexBinning; ++i)
840 collections[3+i]->Add(entry->fdNdEta[i]);
841 collections[3+kVertexBinning+i]->Add(entry->fdNdEtaPtCutOffCorrected[i]);
847 fData->Merge(collections[0]);
848 fMult->Merge(collections[1]);
849 fPtDist->Merge(collections[2]);
851 for (Int_t i=0; i<kVertexBinning; ++i)
853 fdNdEta[i]->Merge(collections[3+i]);
854 fdNdEtaPtCutOffCorrected[i]->Merge(collections[3+kVertexBinning+i]);
857 for (Int_t i=0; i<nCollections; ++i)
858 delete collections[i];