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