3 // ------------------------------------------------------
5 // Class to handle corrections.
7 // ------------------------------------------------------
15 #include "AliCorrectionMatrix2D.h"
16 #include "AliCorrectionMatrix3D.h"
18 #include "AliCorrection.h"
20 //____________________________________________________________________
21 ClassImp(AliCorrection)
23 //____________________________________________________________________
24 AliCorrection::AliCorrection() : TNamed(),
28 // default constructor
31 //____________________________________________________________________
32 AliCorrection::AliCorrection(const Char_t* name, const Char_t* title) : TNamed(name, title),
36 // constructor initializing tnamed
38 Float_t binLimitsPt[] = {0.0, 0.05, 0.1, 0.125, 0.15, 0.175, 0.2, 0.225, 0.25, 0.275, 0.3, 0.325, 0.35, 0.375, 0.4, 0.425, 0.45, 0.475, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.5, 2.0, 5.0, 10.0, 100.0};
39 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, 10.5, 12.5, 14.5, 16.5, 18.5, 20.5, 25.5, 30.5, 40.5, 50.5, 100.5, 300.5};
40 //Float_t binLimitsVtx[] = {-20,-15,-10,-6,-3,0,3,6,10,15,20};
41 Float_t binLimitsVtx[] = {-20,-19,-18,-17,-16,-15,-14,-13,-12,-11,-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};
43 fEventCorr = new AliCorrectionMatrix2D("EventCorrection", Form("%s EventCorrection", title), 40, binLimitsVtx, 22, binLimitsN);
44 fTrackCorr = new AliCorrectionMatrix3D("TrackCorrection", Form("%s TrackCorrection", title), 40, -20, 20, 20, -2, 2, 28, binLimitsPt);
46 fEventCorr->SetAxisTitles("vtx z [cm]", "Ntracks");
47 fTrackCorr->SetAxisTitles("vtx z [cm]", "#eta", "p_{T} [GeV/c]");
50 //____________________________________________________________________
51 AliCorrection::AliCorrection(const AliCorrection& c) : TNamed(c),
56 ((AliCorrection &)c).Copy(*this);
59 //____________________________________________________________________
60 AliCorrection::~AliCorrection()
79 //____________________________________________________________________
80 AliCorrection &AliCorrection::operator=(const AliCorrection &c)
85 ((AliCorrection &) c).Copy(*this);
90 //____________________________________________________________________
91 void AliCorrection::Copy(TObject& c) const
95 AliCorrection& target = (AliCorrection &) c;
98 target.fEventCorr = dynamic_cast<AliCorrectionMatrix2D*> (fEventCorr->Clone());
101 target.fTrackCorr = dynamic_cast<AliCorrectionMatrix3D*> (fTrackCorr->Clone());
104 //____________________________________________________________________
105 Long64_t AliCorrection::Merge(TCollection* list)
107 // Merge a list of AliCorrection objects with this (needed for
109 // Returns the number of merged objects (including this).
117 TIterator* iter = list->MakeIterator();
120 // collections of measured and generated histograms
121 TList* collectionEvent = new TList;
122 TList* collectionTrack = new TList;
125 while ((obj = iter->Next())) {
127 AliCorrection* entry = dynamic_cast<AliCorrection*> (obj);
131 collectionEvent->Add(entry->fEventCorr);
132 collectionTrack->Add(entry->fTrackCorr);
136 fEventCorr->Merge(collectionEvent);
137 fTrackCorr->Merge(collectionTrack);
139 delete collectionEvent;
140 delete collectionTrack;
145 //____________________________________________________________________
146 void AliCorrection::Divide()
149 // divide the histograms to get the correction
152 if (!fEventCorr || !fTrackCorr)
155 fEventCorr->Divide();
156 fTrackCorr->Divide();
158 Int_t emptyBins = fTrackCorr->CheckEmptyBins(-9.99, 9.99, -0.79, 0.79, 0.3, 9.9);
159 printf("INFO: In the central region the track correction of %s has %d empty bins\n", GetName(), emptyBins);
162 //____________________________________________________________________
163 Bool_t AliCorrection::LoadHistograms(const Char_t* dir)
166 // loads the histograms from a file
167 // if dir is empty a directory with the name of this object is taken (like in SaveHistogram)
170 if (!fEventCorr || !fTrackCorr)
176 if (!gDirectory->cd(dir))
179 Bool_t success = fEventCorr->LoadHistograms();
180 success &= fTrackCorr->LoadHistograms();
182 gDirectory->cd("..");
187 //____________________________________________________________________
188 void AliCorrection::SaveHistograms()
191 // saves the histograms in a directory with the name of this object (GetName)
194 gDirectory->mkdir(GetName());
195 gDirectory->cd(GetName());
198 fEventCorr->SaveHistograms();
201 fTrackCorr->SaveHistograms();
203 gDirectory->cd("..");
206 //____________________________________________________________________
207 void AliCorrection::ReduceInformation()
209 // this function deletes the measured and generated histograms to reduce the amount of data
212 if (!fEventCorr || !fTrackCorr)
215 fEventCorr->ReduceInformation();
216 fTrackCorr->ReduceInformation();
219 //____________________________________________________________________
220 void AliCorrection::Reset(Option_t* option)
222 // resets the histograms
225 fEventCorr->Reset(option);
228 fTrackCorr->Reset(option);
231 //____________________________________________________________________
232 void AliCorrection::DrawHistograms(const Char_t* name)
234 // draws the corrections
240 fEventCorr->DrawHistograms(Form("%s event", name));
243 fTrackCorr->DrawHistograms(Form("%s track", name));
246 //____________________________________________________________________
247 void AliCorrection::SetCorrectionToUnity()
249 // set the corrections to unity
252 fEventCorr->SetCorrectionToUnity();
255 fTrackCorr->SetCorrectionToUnity();
258 //____________________________________________________________________
259 void AliCorrection::Multiply()
265 fEventCorr->Multiply();
266 // now we manually copy the overflow bin of the y axis (multiplicity) over. This is important to get the event count correct
267 TH2F* hist = fEventCorr->GetMeasuredHistogram();
268 for (Int_t x = 1; x <= hist->GetNbinsX(); ++x)
269 fEventCorr->GetGeneratedHistogram()->SetBinContent(x, hist->GetNbinsY() + 1, hist->GetBinContent(x, hist->GetNbinsY() + 1));
273 fTrackCorr->Multiply();