2 // This class calculates the exclusive charged particle density
3 // in each for the 5 FMD rings.
5 #include "AliFMDCorrector.h"
10 #include "AliForwardCorrectionManager.h"
17 ClassImp(AliFMDCorrector)
22 //____________________________________________________________________
23 AliFMDCorrector::AliFMDCorrector()
26 fUseMergingEfficiency(true),
32 //____________________________________________________________________
33 AliFMDCorrector::AliFMDCorrector(const char* title)
34 : TNamed("fmdCorrector", title),
36 fUseMergingEfficiency(true),
43 fRingHistos.SetName(GetName());
44 fRingHistos.Add(new RingHistos(1, 'I'));
45 fRingHistos.Add(new RingHistos(2, 'I'));
46 fRingHistos.Add(new RingHistos(2, 'O'));
47 fRingHistos.Add(new RingHistos(3, 'I'));
48 fRingHistos.Add(new RingHistos(3, 'O'));
51 //____________________________________________________________________
52 AliFMDCorrector::AliFMDCorrector(const AliFMDCorrector& o)
55 fUseMergingEfficiency(o.fUseMergingEfficiency),
61 // o Object to copy from
62 TIter next(&o.fRingHistos);
64 while ((obj = next())) fRingHistos.Add(obj);
67 //____________________________________________________________________
68 AliFMDCorrector::~AliFMDCorrector()
76 //____________________________________________________________________
78 AliFMDCorrector::operator=(const AliFMDCorrector& o)
80 // Assignment operator
83 // o Object to assign from
88 fUseMergingEfficiency = o.fUseMergingEfficiency;
89 TIter next(&o.fRingHistos);
91 while ((obj = next())) fRingHistos.Add(obj);
96 //____________________________________________________________________
97 AliFMDCorrector::RingHistos*
98 AliFMDCorrector::GetRingHistos(UShort_t d, Char_t r) const
101 // Get the ring histogram container
107 // Ring histogram container
111 case 1: idx = 0; break;
112 case 2: idx = 1 + (r == 'I' || r == 'i' ? 0 : 1); break;
113 case 3: idx = 3 + (r == 'I' || r == 'i' ? 0 : 1); break;
115 if (idx < 0 || idx >= fRingHistos.GetEntries()) return 0;
117 return static_cast<RingHistos*>(fRingHistos.At(idx));
120 //____________________________________________________________________
122 AliFMDCorrector::Correct(AliForwardUtil::Histos& hists,
126 // Do the calculations
128 // hists Cache of histograms
134 AliForwardCorrectionManager& fcm = AliForwardCorrectionManager::Instance();
136 UShort_t uvb = vtxbin;
137 for (UShort_t d=1; d<=3; d++) {
138 UShort_t nr = (d == 1 ? 1 : 2);
139 for (UShort_t q=0; q<nr; q++) {
140 Char_t r = (q == 0 ? 'I' : 'O');
141 TH2D* h = hists.Get(d,r);
142 RingHistos* rh = GetRingHistos(d,r);
143 TH2D* bg = fcm.GetSecondaryMap()->GetCorrection(d, r, uvb);
144 TH2D* ef = fcm.GetVertexBias()->GetCorrection(r, uvb);
145 TH2D* ac = fcm.GetAcceptance()->GetCorrection(d, r, uvb);
147 AliWarning(Form("No secondary correction for FMDM%d%c in vertex bin %d",
152 AliWarning(Form("No event %s vertex bias correction in vertex bin %d",
153 (r == 'I' || r == 'i' ? "inner" : "outer"), uvb));
157 AliWarning(Form("No acceptance correction for FMD%d%c in vertex bin %d",
162 // Divide by primary/total ratio
165 // Divide by the event selection efficiency
168 // Divide by the acceptance correction
171 if (fUseMergingEfficiency) {
172 if (!fcm.GetMergingEfficiency()) {
173 AliWarning("No merging efficiencies");
176 TH1D* sf = fcm.GetMergingEfficiency()->GetCorrection(d,r,uvb);
177 if (!fcm.GetMergingEfficiency()->GetCorrection(d,r,uvb)) {
178 AliWarning(Form("No merging efficiency for FMD%d%c at vertex bin %d",
184 for (Int_t ieta = 1; ieta <= h->GetNbinsX(); ieta++) {
185 Float_t c = sf->GetBinContent(ieta);
186 Float_t ec = sf->GetBinError(ieta);
188 if (c == 0) continue;
190 for (Int_t iphi = 1; iphi <= h->GetNbinsY(); iphi++) {
191 Double_t m = h->GetBinContent(ieta, iphi) / c;
192 Double_t em = h->GetBinError(ieta, iphi);
194 Double_t e = TMath::Sqrt(em * em + (m * ec) * (m * ec));
196 h->SetBinContent(ieta,iphi,m);
197 h->SetBinError(ieta,iphi,e);
201 rh->fDensity->Add(h);
208 //____________________________________________________________________
210 AliFMDCorrector::ScaleHistograms(TList* dir, Int_t nEvents)
213 // Scale the histograms to the total number of events
215 // dir Where the output is stored
216 // nEvents Number of events
218 if (nEvents <= 0) return;
219 TList* d = static_cast<TList*>(dir->FindObject(GetName()));
222 TIter next(&fRingHistos);
224 while ((o = static_cast<RingHistos*>(next())))
225 o->ScaleHistograms(d, nEvents);
227 //____________________________________________________________________
229 AliFMDCorrector::DefineOutput(TList* dir)
231 TList* d = new TList;
232 d->SetName(GetName());
234 TIter next(&fRingHistos);
236 while ((o = static_cast<RingHistos*>(next()))) {
241 //____________________________________________________________________
243 AliFMDCorrector::Print(Option_t* /* option */) const
250 char ind[gROOT->GetDirLevel()+1];
251 for (Int_t i = 0; i < gROOT->GetDirLevel(); i++) ind[i] = ' ';
252 ind[gROOT->GetDirLevel()] = '\0';
253 std::cout << ind << "AliFMDCorrector: " << GetName() << std::endl;
256 //====================================================================
257 AliFMDCorrector::RingHistos::RingHistos()
258 : AliForwardUtil::RingHistos(),
266 //____________________________________________________________________
267 AliFMDCorrector::RingHistos::RingHistos(UShort_t d, Char_t r)
268 : AliForwardUtil::RingHistos(d,r),
277 fDensity = new TH2D(Form("FMD%d%c_Primary_Density", d, r),
278 Form("in FMD%d%c", d, r),
279 200, -4, 6, (r == 'I' || r == 'i' ? 20 : 40),
281 fDensity->SetDirectory(0);
282 fDensity->SetXTitle("#eta");
283 fDensity->SetYTitle("#phi [radians]");
284 fDensity->SetZTitle("Primary N_{ch} density");
286 //____________________________________________________________________
287 AliFMDCorrector::RingHistos::RingHistos(const RingHistos& o)
288 : AliForwardUtil::RingHistos(o),
294 // o Object to copy from
298 //____________________________________________________________________
299 AliFMDCorrector::RingHistos&
300 AliFMDCorrector::RingHistos::operator=(const RingHistos& o)
303 // Assignment operator
305 // o Object to assign from
310 AliForwardUtil::RingHistos::operator=(o);
312 if (fDensity) delete fDensity;
314 fDensity = static_cast<TH2D*>(o.fDensity->Clone());
318 //____________________________________________________________________
319 AliFMDCorrector::RingHistos::~RingHistos()
324 if (fDensity) delete fDensity;
327 //____________________________________________________________________
329 AliFMDCorrector::RingHistos::Output(TList* dir)
334 // dir Where to put it
336 TList* d = DefineOutputList(dir);
340 //____________________________________________________________________
342 AliFMDCorrector::RingHistos::ScaleHistograms(TList* dir, Int_t nEvents)
345 // Scale the histograms to the total number of events
347 // dir where the output is stored
348 // nEvents Number of events
350 TList* l = GetOutputList(dir);
353 TH1* density = GetOutputHist(l,Form("%s_Primary_Density", fName.Data()));
354 if (density) density->Scale(1./nEvents);
357 //____________________________________________________________________