Protection aginst 0 returned by rndm as argument to log function
[u/mrichter/AliRoot.git] / PWG0 / dNdEta / AlidNdEtaCorrection.cxx
CommitLineData
55e05544 1/* $Id$ */
2
3#include "AlidNdEtaCorrection.h"
4
5#include <TCanvas.h>
45e97e28 6#include <TH2F.h>
55e05544 7
8//____________________________________________________________________
9ClassImp(AlidNdEtaCorrection)
10
11//____________________________________________________________________
12AlidNdEtaCorrection::AlidNdEtaCorrection(Char_t* name)
45e97e28 13 : TNamed(name, name),
14 fNEvents(0),
15 fNTriggeredEvents(0)
55e05544 16{
17 // constructor
18 //
19
45e97e28 20 fTrack2ParticleCorrection = new AliCorrectionMatrix3D("nTrackToNPart", "nTrackToNPart",80,-20,20,120,-6,6, 100, 0, 10);
55e05544 21
22 Float_t binLimitsN[] = {-0.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5,
23 10.5, 12.5, 14.5, 16.5, 18.5, 20.5, 25.5, 30.5, 40.5, 50.5, 100.5, 300.5};
24 Float_t binLimitsVtx[] = {-20,-15,-10,-6,-3,0,3,6,10,15,20};
25
45e97e28 26 fVertexRecoCorrection = new AliCorrectionMatrix2D("vtxReco", "vtxReco",10,binLimitsVtx ,22,binLimitsN);
55e05544 27
45e97e28 28 fTriggerBiasCorrection = new AliCorrectionMatrix2D("triggerBias", "triggerBias",120,-6,6,100, 0, 10);
55e05544 29
45e97e28 30 fTrack2ParticleCorrection ->SetAxisTitles("vtx z [cm]", "#eta", "p_{T}");
55e05544 31 fVertexRecoCorrection ->SetAxisTitles("vtx z [cm]", "n particles/tracks/tracklets?");
45e97e28 32
55e05544 33 fTriggerBiasCorrection ->SetAxisTitles("#eta", "p_{T} [GeV/c]");
34}
35
36//____________________________________________________________________
37void
45e97e28 38AlidNdEtaCorrection::Finish() {
55e05544 39 //
40 // finish method
41 //
45e97e28 42 // divide the histograms in the AliCorrectionMatrix2D objects to get the corrections
55e05544 43
45e97e28 44
45 fTrack2ParticleCorrection->Divide();
55e05544 46
47 fVertexRecoCorrection->Divide();
48
45e97e28 49 fTriggerBiasCorrection->GetMeasuredHistogram()->Scale(Double_t(fNTriggeredEvents)/Double_t(fNEvents));
55e05544 50 fTriggerBiasCorrection->Divide();
51
52}
53
54//____________________________________________________________________
55Long64_t
56AlidNdEtaCorrection::Merge(TCollection* list) {
57 // Merge a list of dNdEtaCorrection objects with this (needed for
58 // PROOF).
59 // Returns the number of merged objects (including this).
60
61 if (!list)
62 return 0;
63
64 if (list->IsEmpty())
65 return 1;
66
67 TIterator* iter = list->MakeIterator();
68 TObject* obj;
69
70 // collections of measured and generated histograms
71 TList* collectionNtrackToNparticle = new TList;
72 TList* collectionVertexReco = new TList;
73 TList* collectionTriggerBias = new TList;
74
75 Int_t count = 0;
76 while ((obj = iter->Next())) {
77
78 AlidNdEtaCorrection* entry = dynamic_cast<AlidNdEtaCorrection*> (obj);
79 if (entry == 0)
80 continue;
81
45e97e28 82 collectionNtrackToNparticle ->Add(entry->GetTrack2ParticleCorrection());
55e05544 83 collectionVertexReco ->Add(entry->GetVertexRecoCorrection());
84 collectionTriggerBias ->Add(entry->GetTriggerBiasCorrection());
85
86 count++;
87 }
45e97e28 88 fTrack2ParticleCorrection ->Merge(collectionNtrackToNparticle);
55e05544 89 fVertexRecoCorrection ->Merge(collectionVertexReco);
90 fTriggerBiasCorrection ->Merge(collectionTriggerBias);
91
92 delete collectionNtrackToNparticle;
93 delete collectionVertexReco;
94 delete collectionTriggerBias;
95
96 return count+1;
97}
98
99
100//____________________________________________________________________
101Bool_t
102AlidNdEtaCorrection::LoadHistograms(Char_t* fileName, Char_t* dir) {
103 //
104 // loads the histograms
105 //
106
45e97e28 107 fTrack2ParticleCorrection ->LoadHistograms(fileName, dir);
55e05544 108 fVertexRecoCorrection ->LoadHistograms(fileName, dir);
109 fTriggerBiasCorrection ->LoadHistograms(fileName, dir);
110
111 return kTRUE;
112}
113
114
115//____________________________________________________________________
116void
117AlidNdEtaCorrection::SaveHistograms() {
118 //
119 // save the histograms
120 //
121
122 gDirectory->mkdir(fName.Data());
123 gDirectory->cd(fName.Data());
124
45e97e28 125 fTrack2ParticleCorrection ->SaveHistograms();
55e05544 126 fVertexRecoCorrection ->SaveHistograms();
127 fTriggerBiasCorrection ->SaveHistograms();
128
129 gDirectory->cd("../");
130}
131
132//____________________________________________________________________
133void AlidNdEtaCorrection::DrawHistograms()
134{
135 //
45e97e28 136 // call the draw histogram method of the two AliCorrectionMatrix2D objects
55e05544 137
45e97e28 138 fTrack2ParticleCorrection ->DrawHistograms();
55e05544 139 fVertexRecoCorrection ->DrawHistograms();
140 fTriggerBiasCorrection ->DrawHistograms();
141
55e05544 142}