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"
22 ClassImp(AliFMDCorrector)
27 //____________________________________________________________________
28 AliFMDCorrector::AliFMDCorrector()
31 fUseSecondaryMap(true),
32 fUseVertexBias(false),
34 fUseMergingEfficiency(false),
38 DGUARD(fDebug, 0, "Default CTOR of AliFMDCorrector");
41 //____________________________________________________________________
42 AliFMDCorrector::AliFMDCorrector(const char* title)
43 : TNamed("fmdCorrector", title),
45 fUseSecondaryMap(true),
46 fUseVertexBias(false),
48 fUseMergingEfficiency(false),
55 DGUARD(fDebug, 0, "Named CTOR of AliFMDCorrector: %s", title);
56 fRingHistos.SetName(GetName());
57 fRingHistos.Add(new RingHistos(1, 'I'));
58 fRingHistos.Add(new RingHistos(2, 'I'));
59 fRingHistos.Add(new RingHistos(2, 'O'));
60 fRingHistos.Add(new RingHistos(3, 'I'));
61 fRingHistos.Add(new RingHistos(3, 'O'));
64 //____________________________________________________________________
65 AliFMDCorrector::AliFMDCorrector(const AliFMDCorrector& o)
68 fUseSecondaryMap(o.fUseSecondaryMap),
69 fUseVertexBias(o.fUseVertexBias),
70 fUseAcceptance(o.fUseAcceptance),
71 fUseMergingEfficiency(o.fUseMergingEfficiency),
77 // o Object to copy from
78 DGUARD(fDebug, 0, "Copy CTOR of AliFMDCorrector");
79 TIter next(&o.fRingHistos);
81 while ((obj = next())) fRingHistos.Add(obj);
84 //____________________________________________________________________
85 AliFMDCorrector::~AliFMDCorrector()
90 DGUARD(fDebug, 3, "DTOR of AliFMDCorrector");
94 //____________________________________________________________________
96 AliFMDCorrector::operator=(const AliFMDCorrector& o)
98 // Assignment operator
101 // o Object to assign from
102 DGUARD(fDebug, 3, "Assignment of AliFMDCorrector");
103 if (&o == this) return *this;
104 TNamed::operator=(o);
107 fRingHistos.Delete();
108 fUseSecondaryMap = o.fUseSecondaryMap;
109 fUseVertexBias = o.fUseVertexBias;
110 fUseAcceptance = o.fUseAcceptance;
111 fUseMergingEfficiency = o.fUseMergingEfficiency;
112 TIter next(&o.fRingHistos);
114 while ((obj = next())) fRingHistos.Add(obj);
119 //____________________________________________________________________
121 AliFMDCorrector::Init(const TAxis&)
124 // Initialize this object
127 // etaAxis Eta axis to use
129 DGUARD(fDebug, 1, "Initialization of AliFMDCorrector");
130 if (!fUseSecondaryMap)
131 AliWarning("Secondary maps not used - BE CAREFUL");
133 AliWarning("Vertex bias not used");
135 AliWarning("Acceptance from dead-channels not used");
138 //____________________________________________________________________
139 AliFMDCorrector::RingHistos*
140 AliFMDCorrector::GetRingHistos(UShort_t d, Char_t r) const
143 // Get the ring histogram container
149 // Ring histogram container
153 case 1: idx = 0; break;
154 case 2: idx = 1 + (r == 'I' || r == 'i' ? 0 : 1); break;
155 case 3: idx = 3 + (r == 'I' || r == 'i' ? 0 : 1); break;
157 if (idx < 0 || idx >= fRingHistos.GetEntries()) return 0;
159 return static_cast<RingHistos*>(fRingHistos.At(idx));
162 //____________________________________________________________________
164 AliFMDCorrector::Correct(AliForwardUtil::Histos& hists,
168 // Do the calculations
170 // hists Cache of histograms
176 DGUARD(fDebug, 1, "Correct histograms of AliFMDCorrector");
177 AliForwardCorrectionManager& fcm = AliForwardCorrectionManager::Instance();
179 UShort_t uvb = vtxbin;
180 for (UShort_t d=1; d<=3; d++) {
181 UShort_t nr = (d == 1 ? 1 : 2);
182 for (UShort_t q=0; q<nr; q++) {
183 Char_t r = (q == 0 ? 'I' : 'O');
184 TH2D* h = hists.Get(d,r);
185 RingHistos* rh = GetRingHistos(d,r);
187 if (fUseSecondaryMap) {
188 TH2D* bg = fcm.GetSecondaryMap()->GetCorrection(d, r, uvb);
190 AliWarning(Form("No secondary correction for FMDM%d%c "
191 "in vertex bin %d", d, r, uvb));
194 // Divide by primary/total ratio
197 if (fUseVertexBias) {
198 TH2D* ef = fcm.GetVertexBias()->GetCorrection(r, uvb);
200 AliWarning(Form("No event %s vertex bias correction in vertex bin %d",
201 (r == 'I' || r == 'i' ? "inner" : "outer"), uvb));
204 // Divide by the event selection efficiency
207 if (fUseAcceptance) {
208 TH2D* ac = fcm.GetAcceptance()->GetCorrection(d, r, uvb);
210 AliWarning(Form("No acceptance correction for FMD%d%c in "
211 "vertex bin %d", d, r, uvb));
214 // Divide by the acceptance correction
218 if (fUseMergingEfficiency) {
219 if (!fcm.GetMergingEfficiency()) {
220 AliWarning("No merging efficiencies");
223 TH1D* sf = fcm.GetMergingEfficiency()->GetCorrection(d,r,uvb);
224 if (!fcm.GetMergingEfficiency()->GetCorrection(d,r,uvb)) {
225 AliWarning(Form("No merging efficiency for FMD%d%c at vertex bin %d",
231 for (Int_t ieta = 1; ieta <= h->GetNbinsX(); ieta++) {
232 Float_t c = sf->GetBinContent(ieta);
233 Float_t ec = sf->GetBinError(ieta);
235 if (c == 0) continue;
237 for (Int_t iphi = 1; iphi <= h->GetNbinsY(); iphi++) {
238 Double_t m = h->GetBinContent(ieta, iphi) / c;
239 Double_t em = h->GetBinError(ieta, iphi);
241 Double_t e = TMath::Sqrt(em * em + (m * ec) * (m * ec));
243 h->SetBinContent(ieta,iphi,m);
244 h->SetBinError(ieta,iphi,e);
250 TH2D* bg = fcm.GetSecondaryMap()->GetCorrection(d, r, uvb);
251 TH2D hRing("hring","hring",bg->GetNbinsX(),
252 bg->GetXaxis()->GetXmin(),
253 bg->GetXaxis()->GetXmax(),
255 bg->GetYaxis()->GetXmin(),
256 bg->GetYaxis()->GetXmax());
258 Int_t edgebin[4] = {0,0,0,0};
259 for(Int_t ii = 1; ii <=bg->GetNbinsX(); ii++) {
260 for(Int_t jj = 1; jj <=bg->GetNbinsY(); jj++) {
261 Float_t bgcor = bg->GetBinContent(ii,jj);
262 if(bgcor<0.1) continue;
263 if(edgebin[0] == 0) edgebin[0] = ii;
264 if(edgebin[0] == ii) continue;
265 if(edgebin[0] > 0 && edgebin[1] == 0) edgebin[1] = ii;
266 if(edgebin[0]>0 && edgebin[1]>0) break;
269 for(Int_t ii = bg->GetNbinsX(); ii >= 1; ii--) {
270 for(Int_t jj = 1; jj <=bg->GetNbinsY(); jj++) {
271 Float_t bgcor = bg->GetBinContent(ii,jj);
272 if(bgcor<0.1) continue;
273 if(edgebin[2] == 0) edgebin[2] = ii;
274 if(edgebin[2] == ii) continue;
275 if(edgebin[2] > 0 && edgebin[3] == 0) edgebin[3] = ii;
276 if(edgebin[2]>0 && edgebin[3]>0) break;
279 for(Int_t ii = 1; ii <=bg->GetNbinsX(); ii++) {
280 for(Int_t jj = 1; jj <=bg->GetNbinsY(); jj++) {
281 Float_t data = h->GetBinContent(ii,jj);
282 if(data <0.000001) continue;
283 if(edgebin[0] == ii || edgebin[1] == ii || edgebin[2] == ii || edgebin[3] == ii) continue;
284 hRing.SetBinContent(ii,jj,data);
285 hRing.SetBinError(ii,jj,h->GetBinError(ii,jj));
289 //std::cout<<edgebin[0]<<" "<<edgebin[1]<<" "<<edgebin[2]<<" "<<edgebin[3]<<std::endl;
292 rh->fDensity->Add(h);
299 //____________________________________________________________________
301 AliFMDCorrector::ScaleHistograms(const TList* dir, Int_t nEvents)
304 // Scale the histograms to the total number of events
306 // dir Where the output is stored
307 // nEvents Number of events
309 DGUARD(fDebug, 1, "Scale histograms of AliFMDCorrector");
310 if (nEvents <= 0) return;
311 TList* d = static_cast<TList*>(dir->FindObject(GetName()));
314 TIter next(&fRingHistos);
316 THStack* sums = new THStack("sums", "Sums of ring results");
317 while ((o = static_cast<RingHistos*>(next()))) {
318 o->ScaleHistograms(d, nEvents);
319 TH1D* sum = o->fDensity->ProjectionX(o->GetName(), 1,
320 o->fDensity->GetNbinsY(),"e");
321 sum->Scale(1., "width");
322 sum->SetTitle(o->GetName());
323 sum->SetDirectory(0);
324 sum->SetYTitle("#sum N_{ch,primary}");
330 //____________________________________________________________________
332 AliFMDCorrector::DefineOutput(TList* dir)
335 // Output diagnostic histograms to directory
338 // dir List to write in
340 DGUARD(fDebug, 1, "Define output of AliFMDCorrector");
341 TList* d = new TList;
342 d->SetName(GetName());
344 TIter next(&fRingHistos);
346 while ((o = static_cast<RingHistos*>(next()))) {
351 //____________________________________________________________________
353 AliFMDCorrector::Print(Option_t* /* option */) const
360 char ind[gROOT->GetDirLevel()+1];
361 for (Int_t i = 0; i < gROOT->GetDirLevel(); i++) ind[i] = ' ';
362 ind[gROOT->GetDirLevel()] = '\0';
363 std::cout << ind << ClassName() << ": " << GetName() << "\n"
365 << ind << " Use secondary maps: " << fUseSecondaryMap << "\n"
366 << ind << " Use vertex bias: " << fUseVertexBias << "\n"
367 << ind << " Use acceptance: " << fUseAcceptance << "\n"
368 << ind << " Use merging efficiency: " << fUseMergingEfficiency
369 << std::noboolalpha << std::endl;
372 //====================================================================
373 AliFMDCorrector::RingHistos::RingHistos()
374 : AliForwardUtil::RingHistos(),
382 //____________________________________________________________________
383 AliFMDCorrector::RingHistos::RingHistos(UShort_t d, Char_t r)
384 : AliForwardUtil::RingHistos(d,r),
393 fDensity = new TH2D("primaryDensity",
394 "#sum N_{ch,primary}/(#Delta#eta#Delta#phi)",
395 200, -4, 6, (r == 'I' || r == 'i' ? 20 : 40),
397 fDensity->SetDirectory(0);
398 fDensity->SetMarkerColor(Color());
400 fDensity->SetXTitle("#eta");
401 fDensity->SetYTitle("#phi [radians]");
402 fDensity->SetZTitle("Primary N_{ch} density");
404 //____________________________________________________________________
405 AliFMDCorrector::RingHistos::RingHistos(const RingHistos& o)
406 : AliForwardUtil::RingHistos(o),
412 // o Object to copy from
416 //____________________________________________________________________
417 AliFMDCorrector::RingHistos&
418 AliFMDCorrector::RingHistos::operator=(const RingHistos& o)
421 // Assignment operator
423 // o Object to assign from
428 if (&o == this) return *this;
429 AliForwardUtil::RingHistos::operator=(o);
431 if (fDensity) delete fDensity;
433 fDensity = static_cast<TH2D*>(o.fDensity->Clone());
437 //____________________________________________________________________
438 AliFMDCorrector::RingHistos::~RingHistos()
443 if (fDensity) delete fDensity;
446 //____________________________________________________________________
448 AliFMDCorrector::RingHistos::Output(TList* dir)
453 // dir Where to put it
455 TList* d = DefineOutputList(dir);
459 //____________________________________________________________________
461 AliFMDCorrector::RingHistos::ScaleHistograms(TList* dir, Int_t nEvents)
464 // Scale the histograms to the total number of events
466 // dir where the output is stored
467 // nEvents Number of events
469 TList* l = GetOutputList(dir);
472 TH1* density = GetOutputHist(l,"primaryDensity");
473 if (density) density->Scale(1./nEvents);
476 //____________________________________________________________________