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};
42 Float_t binLimitsVtx[] = {-20,-15,-10,-8,-6,-4,-2,0,2,4,6,8,10,15,20};
44 fEventCorr = new AliCorrectionMatrix2D("EventCorrection", Form("%s EventCorrection", title), 14, binLimitsVtx, 22, binLimitsN);
45 fTrackCorr = new AliCorrectionMatrix3D("TrackCorrection", Form("%s TrackCorrection", title), 14, binLimitsVtx, 40, -2, 2, 28, binLimitsPt);
47 fEventCorr->SetAxisTitles("vtx z [cm]", "Ntracks");
48 fTrackCorr->SetAxisTitles("vtx z [cm]", "#eta", "p_{T} [GeV/c]");
51 //____________________________________________________________________
52 AliCorrection::AliCorrection(const AliCorrection& c) : TNamed(c),
57 ((AliCorrection &)c).Copy(*this);
60 //____________________________________________________________________
61 AliCorrection::~AliCorrection()
80 //____________________________________________________________________
81 AliCorrection &AliCorrection::operator=(const AliCorrection &c)
86 ((AliCorrection &) c).Copy(*this);
91 //____________________________________________________________________
92 void AliCorrection::Copy(TObject& c) const
96 AliCorrection& target = (AliCorrection &) c;
99 target.fEventCorr = dynamic_cast<AliCorrectionMatrix2D*> (fEventCorr->Clone());
102 target.fTrackCorr = dynamic_cast<AliCorrectionMatrix3D*> (fTrackCorr->Clone());
105 //____________________________________________________________________
106 Long64_t AliCorrection::Merge(TCollection* list)
108 // Merge a list of AliCorrection objects with this (needed for
110 // Returns the number of merged objects (including this).
118 TIterator* iter = list->MakeIterator();
121 // collections of measured and generated histograms
122 TList* collectionEvent = new TList;
123 TList* collectionTrack = new TList;
126 while ((obj = iter->Next())) {
128 AliCorrection* entry = dynamic_cast<AliCorrection*> (obj);
132 collectionEvent->Add(entry->fEventCorr);
133 collectionTrack->Add(entry->fTrackCorr);
137 fEventCorr->Merge(collectionEvent);
138 fTrackCorr->Merge(collectionTrack);
140 delete collectionEvent;
141 delete collectionTrack;
146 //____________________________________________________________________
147 void AliCorrection::Divide()
150 // divide the histograms to get the correction
153 if (!fEventCorr || !fTrackCorr)
156 fEventCorr->Divide();
157 fTrackCorr->Divide();
159 Int_t emptyBins = fTrackCorr->CheckEmptyBins(-9.99, 9.99, -0.79, 0.79, 0.3, 9.9);
160 printf("INFO: In the central region the track correction of %s has %d empty bins\n", GetName(), emptyBins);
163 //____________________________________________________________________
164 void AliCorrection::Add(AliCorrection* aCorrectionToAdd, Float_t c)
167 // add to measured and generated the measured and generated of aCorrectionToAdd
170 fEventCorr->Add(aCorrectionToAdd->GetEventCorrection(),c);
171 fTrackCorr->Add(aCorrectionToAdd->GetTrackCorrection(),c);
175 //____________________________________________________________________
176 Bool_t AliCorrection::LoadHistograms(const Char_t* dir)
179 // loads the histograms from a file
180 // if dir is empty a directory with the name of this object is taken (like in SaveHistogram)
183 if (!fEventCorr || !fTrackCorr)
189 if (!gDirectory->cd(dir))
192 Bool_t success = fEventCorr->LoadHistograms();
193 success &= fTrackCorr->LoadHistograms();
195 gDirectory->cd("..");
200 //____________________________________________________________________
201 void AliCorrection::SaveHistograms()
204 // saves the histograms in a directory with the name of this object (GetName)
207 gDirectory->mkdir(GetName());
208 gDirectory->cd(GetName());
211 fEventCorr->SaveHistograms();
214 fTrackCorr->SaveHistograms();
216 gDirectory->cd("..");
219 //____________________________________________________________________
220 void AliCorrection::ReduceInformation()
222 // this function deletes the measured and generated histograms to reduce the amount of data
225 if (!fEventCorr || !fTrackCorr)
228 fEventCorr->ReduceInformation();
229 fTrackCorr->ReduceInformation();
232 //____________________________________________________________________
233 void AliCorrection::Reset(Option_t* option)
235 // resets the histograms
238 fEventCorr->Reset(option);
241 fTrackCorr->Reset(option);
244 //____________________________________________________________________
245 void AliCorrection::DrawHistograms(const Char_t* name)
247 // draws the corrections
253 fEventCorr->DrawHistograms(Form("%s event", name));
256 fTrackCorr->DrawHistograms(Form("%s track", name));
259 //____________________________________________________________________
260 void AliCorrection::SetCorrectionToUnity()
262 // set the corrections to unity
265 fEventCorr->SetCorrectionToUnity();
268 fTrackCorr->SetCorrectionToUnity();
271 //____________________________________________________________________
272 void AliCorrection::Multiply()
278 fEventCorr->Multiply();
279 // now we manually copy the overflow bin of the y axis (multiplicity) over. This is important to get the event count correct
280 TH2F* hist = fEventCorr->GetMeasuredHistogram();
281 for (Int_t x = 1; x <= hist->GetNbinsX(); ++x)
282 fEventCorr->GetGeneratedHistogram()->SetBinContent(x, hist->GetNbinsY() + 1, hist->GetBinContent(x, hist->GetNbinsY() + 1));
286 fTrackCorr->Multiply();