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"
11 // #include "AliFMDCorrDoubleHit.h"
12 #include "AliFMDCorrVertexBias.h"
13 #include "AliFMDCorrMergingEfficiency.h"
14 #include "AliFMDCorrAcceptance.h"
21 ClassImp(AliFMDCorrector)
26 //____________________________________________________________________
27 AliFMDCorrector::AliFMDCorrector()
30 fUseSecondaryMap(true),
31 fUseVertexBias(false),
33 fUseMergingEfficiency(false),
39 //____________________________________________________________________
40 AliFMDCorrector::AliFMDCorrector(const char* title)
41 : TNamed("fmdCorrector", title),
43 fUseSecondaryMap(true),
44 fUseVertexBias(false),
46 fUseMergingEfficiency(false),
53 fRingHistos.SetName(GetName());
54 fRingHistos.Add(new RingHistos(1, 'I'));
55 fRingHistos.Add(new RingHistos(2, 'I'));
56 fRingHistos.Add(new RingHistos(2, 'O'));
57 fRingHistos.Add(new RingHistos(3, 'I'));
58 fRingHistos.Add(new RingHistos(3, 'O'));
61 //____________________________________________________________________
62 AliFMDCorrector::AliFMDCorrector(const AliFMDCorrector& o)
65 fUseSecondaryMap(o.fUseSecondaryMap),
66 fUseVertexBias(o.fUseVertexBias),
67 fUseAcceptance(o.fUseAcceptance),
68 fUseMergingEfficiency(o.fUseMergingEfficiency),
74 // o Object to copy from
75 TIter next(&o.fRingHistos);
77 while ((obj = next())) fRingHistos.Add(obj);
80 //____________________________________________________________________
81 AliFMDCorrector::~AliFMDCorrector()
89 //____________________________________________________________________
91 AliFMDCorrector::operator=(const AliFMDCorrector& o)
93 // Assignment operator
96 // o Object to assign from
100 fRingHistos.Delete();
101 fUseSecondaryMap = o.fUseSecondaryMap;
102 fUseVertexBias = o.fUseVertexBias;
103 fUseAcceptance = o.fUseAcceptance;
104 fUseMergingEfficiency = o.fUseMergingEfficiency;
105 TIter next(&o.fRingHistos);
107 while ((obj = next())) fRingHistos.Add(obj);
112 //____________________________________________________________________
114 AliFMDCorrector::Init(const TAxis&)
117 // Initialize this object
120 // etaAxis Eta axis to use
122 if (!fUseSecondaryMap)
123 AliWarning("Secondary maps not used - BE CAREFUL");
125 AliWarning("Vertex bias not used");
127 AliWarning("Acceptance from dead-channels not used");
130 //____________________________________________________________________
131 AliFMDCorrector::RingHistos*
132 AliFMDCorrector::GetRingHistos(UShort_t d, Char_t r) const
135 // Get the ring histogram container
141 // Ring histogram container
145 case 1: idx = 0; break;
146 case 2: idx = 1 + (r == 'I' || r == 'i' ? 0 : 1); break;
147 case 3: idx = 3 + (r == 'I' || r == 'i' ? 0 : 1); break;
149 if (idx < 0 || idx >= fRingHistos.GetEntries()) return 0;
151 return static_cast<RingHistos*>(fRingHistos.At(idx));
154 //____________________________________________________________________
156 AliFMDCorrector::Correct(AliForwardUtil::Histos& hists,
160 // Do the calculations
162 // hists Cache of histograms
168 AliForwardCorrectionManager& fcm = AliForwardCorrectionManager::Instance();
170 UShort_t uvb = vtxbin;
171 for (UShort_t d=1; d<=3; d++) {
172 UShort_t nr = (d == 1 ? 1 : 2);
173 for (UShort_t q=0; q<nr; q++) {
174 Char_t r = (q == 0 ? 'I' : 'O');
175 TH2D* h = hists.Get(d,r);
176 RingHistos* rh = GetRingHistos(d,r);
178 if (fUseSecondaryMap) {
179 TH2D* bg = fcm.GetSecondaryMap()->GetCorrection(d, r, uvb);
181 AliWarning(Form("No secondary correction for FMDM%d%c in vertex bin %d",
185 // Divide by primary/total ratio
188 if (fUseVertexBias) {
189 TH2D* ef = fcm.GetVertexBias()->GetCorrection(r, uvb);
191 AliWarning(Form("No event %s vertex bias correction in vertex bin %d",
192 (r == 'I' || r == 'i' ? "inner" : "outer"), uvb));
195 // Divide by the event selection efficiency
198 if (fUseAcceptance) {
199 TH2D* ac = fcm.GetAcceptance()->GetCorrection(d, r, uvb);
201 AliWarning(Form("No acceptance correction for FMD%d%c in vertex bin %d",
205 // Divide by the acceptance correction
213 if (fUseMergingEfficiency) {
214 if (!fcm.GetMergingEfficiency()) {
215 AliWarning("No merging efficiencies");
218 TH1D* sf = fcm.GetMergingEfficiency()->GetCorrection(d,r,uvb);
219 if (!fcm.GetMergingEfficiency()->GetCorrection(d,r,uvb)) {
220 AliWarning(Form("No merging efficiency for FMD%d%c at vertex bin %d",
226 for (Int_t ieta = 1; ieta <= h->GetNbinsX(); ieta++) {
227 Float_t c = sf->GetBinContent(ieta);
228 Float_t ec = sf->GetBinError(ieta);
230 if (c == 0) continue;
232 for (Int_t iphi = 1; iphi <= h->GetNbinsY(); iphi++) {
233 Double_t m = h->GetBinContent(ieta, iphi) / c;
234 Double_t em = h->GetBinError(ieta, iphi);
236 Double_t e = TMath::Sqrt(em * em + (m * ec) * (m * ec));
238 h->SetBinContent(ieta,iphi,m);
239 h->SetBinError(ieta,iphi,e);
243 rh->fDensity->Add(h);
250 //____________________________________________________________________
252 AliFMDCorrector::ScaleHistograms(const TList* dir, Int_t nEvents)
255 // Scale the histograms to the total number of events
257 // dir Where the output is stored
258 // nEvents Number of events
260 if (nEvents <= 0) return;
261 TList* d = static_cast<TList*>(dir->FindObject(GetName()));
264 TIter next(&fRingHistos);
266 while ((o = static_cast<RingHistos*>(next())))
267 o->ScaleHistograms(d, nEvents);
269 //____________________________________________________________________
271 AliFMDCorrector::DefineOutput(TList* dir)
274 // Output diagnostic histograms to directory
277 // dir List to write in
279 TList* d = new TList;
280 d->SetName(GetName());
282 TIter next(&fRingHistos);
284 while ((o = static_cast<RingHistos*>(next()))) {
289 //____________________________________________________________________
291 AliFMDCorrector::Print(Option_t* /* option */) const
298 char ind[gROOT->GetDirLevel()+1];
299 for (Int_t i = 0; i < gROOT->GetDirLevel(); i++) ind[i] = ' ';
300 ind[gROOT->GetDirLevel()] = '\0';
301 std::cout << ind << "AliFMDCorrector: " << GetName() << "\n"
303 << ind << " Use secondary maps: " << fUseSecondaryMap << "\n"
304 << ind << " Use vertex bias: " << fUseVertexBias << "\n"
305 << ind << " Use acceptance: " << fUseAcceptance << "\n"
306 << ind << " Use merging efficiency: " << fUseMergingEfficiency
307 << std::noboolalpha << std::endl;
310 //====================================================================
311 AliFMDCorrector::RingHistos::RingHistos()
312 : AliForwardUtil::RingHistos(),
320 //____________________________________________________________________
321 AliFMDCorrector::RingHistos::RingHistos(UShort_t d, Char_t r)
322 : AliForwardUtil::RingHistos(d,r),
331 fDensity = new TH2D(Form("FMD%d%c_Primary_Density", d, r),
332 Form("in FMD%d%c", d, r),
333 200, -4, 6, (r == 'I' || r == 'i' ? 20 : 40),
335 fDensity->SetDirectory(0);
336 fDensity->SetXTitle("#eta");
337 fDensity->SetYTitle("#phi [radians]");
338 fDensity->SetZTitle("Primary N_{ch} density");
340 //____________________________________________________________________
341 AliFMDCorrector::RingHistos::RingHistos(const RingHistos& o)
342 : AliForwardUtil::RingHistos(o),
348 // o Object to copy from
352 //____________________________________________________________________
353 AliFMDCorrector::RingHistos&
354 AliFMDCorrector::RingHistos::operator=(const RingHistos& o)
357 // Assignment operator
359 // o Object to assign from
364 AliForwardUtil::RingHistos::operator=(o);
366 if (fDensity) delete fDensity;
368 fDensity = static_cast<TH2D*>(o.fDensity->Clone());
372 //____________________________________________________________________
373 AliFMDCorrector::RingHistos::~RingHistos()
378 if (fDensity) delete fDensity;
381 //____________________________________________________________________
383 AliFMDCorrector::RingHistos::Output(TList* dir)
388 // dir Where to put it
390 TList* d = DefineOutputList(dir);
394 //____________________________________________________________________
396 AliFMDCorrector::RingHistos::ScaleHistograms(TList* dir, Int_t nEvents)
399 // Scale the histograms to the total number of events
401 // dir where the output is stored
402 // nEvents Number of events
404 TList* l = GetOutputList(dir);
407 TH1* density = GetOutputHist(l,Form("%s_Primary_Density", fName.Data()));
408 if (density) density->Scale(1./nEvents);
411 //____________________________________________________________________