]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG0/dNdEta/dNdEtaCorrection.cxx
adding vertex recon eff selector
[u/mrichter/AliRoot.git] / PWG0 / dNdEta / dNdEtaCorrection.cxx
1 /* $Id$ */
2
3 #include "dNdEtaCorrection.h"
4
5 #include <TCanvas.h>
6
7 //____________________________________________________________________
8 ClassImp(dNdEtaCorrection)
9
10 //____________________________________________________________________
11 dNdEtaCorrection::dNdEtaCorrection(Char_t* name) 
12   : TNamed(name, name)
13 {  
14   // constructor
15   //
16
17   fNtrackToNparticleCorrection = new CorrectionMatrix2D("nTrackToNPart", "nTrackToNPart",80,-20,20,120,-6,6);
18   fEventBiasCorrection         = new CorrectionMatrix2D("EventBias",    "EventBias ",80,-20,20,120,-6,6);
19
20   fNtrackToNparticleCorrection ->SetAxisTitles("vtx z [cm]", "#eta");
21   fEventBiasCorrection         ->SetAxisTitles("vtx z [cm]", "#eta");
22
23 }
24
25 //____________________________________________________________________
26 void
27 dNdEtaCorrection::Finish() {  
28   //
29   // finish method
30   //
31   // divide the histograms in the CorrectionMatrix2D objects to get the corrections
32
33
34   fNtrackToNparticleCorrection->Divide();
35   fEventBiasCorrection        ->Divide();
36
37 }
38
39 //____________________________________________________________________
40 Long64_t 
41 dNdEtaCorrection::Merge(TCollection* list) {
42   // Merge a list of dNdEtaCorrection objects with this (needed for
43   // PROOF). 
44   // Returns the number of merged objects (including this).
45
46   if (!list)
47     return 0;
48   
49   if (list->IsEmpty())
50     return 1;
51
52   TIterator* iter = list->MakeIterator();
53   TObject* obj;
54
55   // collections of measured and generated histograms
56   TList* collectionNtrackToNparticle = new TList;
57   TList* collectionEventBias         = new TList;
58   
59   Int_t count = 0;
60   while ((obj = iter->Next())) {
61     
62     dNdEtaCorrection* entry = dynamic_cast<dNdEtaCorrection*> (obj);
63     if (entry == 0) 
64       continue;
65
66     collectionNtrackToNparticle ->Add(entry->GetNtrackToNpraticleCorrection());
67     collectionEventBias         ->Add(entry->GetEventBiasCorrection());
68     
69     count++;
70   }
71   fNtrackToNparticleCorrection ->Merge(collectionNtrackToNparticle);
72   fEventBiasCorrection         ->Merge(collectionEventBias);
73   
74   delete collectionNtrackToNparticle;
75   delete collectionEventBias;
76
77   return count+1;
78 }
79
80
81
82
83 //____________________________________________________________________
84 void
85 dNdEtaCorrection::RemoveEdges(Float_t cut, Int_t nBinsVtx, Int_t nBinsEta) {
86   //
87   // removes the edges of the correction maps
88   //
89
90   fNtrackToNparticleCorrection ->RemoveEdges(cut, nBinsVtx, nBinsEta);
91   fEventBiasCorrection         ->RemoveEdges(cut, nBinsVtx, nBinsEta);
92 }
93
94 //____________________________________________________________________
95 Bool_t
96 dNdEtaCorrection::LoadHistograms(Char_t* fileName, Char_t* dir) {
97   //
98   // loads the histograms
99   //
100
101   fNtrackToNparticleCorrection ->LoadHistograms(fileName, dir);
102   fEventBiasCorrection         ->LoadHistograms(fileName, dir);
103   
104   return kTRUE;
105 }
106
107
108 //____________________________________________________________________
109 void
110 dNdEtaCorrection::SaveHistograms() {
111   //
112   // save the histograms
113   //
114
115   gDirectory->mkdir(fName.Data());
116   gDirectory->cd(fName.Data());
117
118   fNtrackToNparticleCorrection ->SaveHistograms();
119   fEventBiasCorrection         ->SaveHistograms();
120
121   gDirectory->cd("../");
122 }
123
124 //____________________________________________________________________
125 void dNdEtaCorrection::DrawHistograms()
126 {
127   //
128   // call the draw histogram method of the two CorrectionMatrix2D objects
129
130   fNtrackToNparticleCorrection ->DrawHistograms();
131   fEventBiasCorrection         ->DrawHistograms();
132
133   fEventBiasCorrection->Get1DCorrection("x")->Draw();
134   
135 }