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);
245 TH2D* bg = fcm.GetSecondaryMap()->GetCorrection(d, r, uvb);
246 TH2D hRing("hring","hring",bg->GetNbinsX(),
247 bg->GetXaxis()->GetXmin(),
248 bg->GetXaxis()->GetXmax(),
250 bg->GetYaxis()->GetXmin(),
251 bg->GetYaxis()->GetXmax());
253 Int_t edgebin[4] = {0,0,0,0};
254 for(Int_t ii = 1; ii <=bg->GetNbinsX(); ii++) {
255 for(Int_t jj = 1; jj <=bg->GetNbinsY(); jj++) {
256 Float_t bgcor = bg->GetBinContent(ii,jj);
257 if(bgcor<0.1) continue;
258 if(edgebin[0] == 0) edgebin[0] = ii;
259 if(edgebin[0] == ii) continue;
260 if(edgebin[0] > 0 && edgebin[1] == 0) edgebin[1] = ii;
261 if(edgebin[0]>0 && edgebin[1]>0) break;
264 for(Int_t ii = bg->GetNbinsX(); ii >= 1; ii--) {
265 for(Int_t jj = 1; jj <=bg->GetNbinsY(); jj++) {
266 Float_t bgcor = bg->GetBinContent(ii,jj);
267 if(bgcor<0.1) continue;
268 if(edgebin[2] == 0) edgebin[2] = ii;
269 if(edgebin[2] == ii) continue;
270 if(edgebin[2] > 0 && edgebin[3] == 0) edgebin[3] = ii;
271 if(edgebin[2]>0 && edgebin[3]>0) break;
274 for(Int_t ii = 1; ii <=bg->GetNbinsX(); ii++) {
275 for(Int_t jj = 1; jj <=bg->GetNbinsY(); jj++) {
276 Float_t data = h->GetBinContent(ii,jj);
277 if(data <0.000001) continue;
278 if(edgebin[0] == ii || edgebin[1] == ii || edgebin[2] == ii || edgebin[3] == ii) continue;
279 hRing.SetBinContent(ii,jj,data);
280 hRing.SetBinError(ii,jj,h->GetBinError(ii,jj));
284 //std::cout<<edgebin[0]<<" "<<edgebin[1]<<" "<<edgebin[2]<<" "<<edgebin[3]<<std::endl;
287 rh->fDensity->Add(h);
294 //____________________________________________________________________
296 AliFMDCorrector::ScaleHistograms(const TList* dir, Int_t nEvents)
299 // Scale the histograms to the total number of events
301 // dir Where the output is stored
302 // nEvents Number of events
304 if (nEvents <= 0) return;
305 TList* d = static_cast<TList*>(dir->FindObject(GetName()));
308 TIter next(&fRingHistos);
310 while ((o = static_cast<RingHistos*>(next())))
311 o->ScaleHistograms(d, nEvents);
313 //____________________________________________________________________
315 AliFMDCorrector::DefineOutput(TList* dir)
318 // Output diagnostic histograms to directory
321 // dir List to write in
323 TList* d = new TList;
324 d->SetName(GetName());
326 TIter next(&fRingHistos);
328 while ((o = static_cast<RingHistos*>(next()))) {
333 //____________________________________________________________________
335 AliFMDCorrector::Print(Option_t* /* option */) const
342 char ind[gROOT->GetDirLevel()+1];
343 for (Int_t i = 0; i < gROOT->GetDirLevel(); i++) ind[i] = ' ';
344 ind[gROOT->GetDirLevel()] = '\0';
345 std::cout << ind << ClassName() << ": " << GetName() << "\n"
347 << ind << " Use secondary maps: " << fUseSecondaryMap << "\n"
348 << ind << " Use vertex bias: " << fUseVertexBias << "\n"
349 << ind << " Use acceptance: " << fUseAcceptance << "\n"
350 << ind << " Use merging efficiency: " << fUseMergingEfficiency
351 << std::noboolalpha << std::endl;
354 //====================================================================
355 AliFMDCorrector::RingHistos::RingHistos()
356 : AliForwardUtil::RingHistos(),
364 //____________________________________________________________________
365 AliFMDCorrector::RingHistos::RingHistos(UShort_t d, Char_t r)
366 : AliForwardUtil::RingHistos(d,r),
375 fDensity = new TH2D(Form("FMD%d%c_Primary_Density", d, r),
376 Form("in FMD%d%c", d, r),
377 200, -4, 6, (r == 'I' || r == 'i' ? 20 : 40),
379 fDensity->SetDirectory(0);
380 fDensity->SetXTitle("#eta");
381 fDensity->SetYTitle("#phi [radians]");
382 fDensity->SetZTitle("Primary N_{ch} density");
384 //____________________________________________________________________
385 AliFMDCorrector::RingHistos::RingHistos(const RingHistos& o)
386 : AliForwardUtil::RingHistos(o),
392 // o Object to copy from
396 //____________________________________________________________________
397 AliFMDCorrector::RingHistos&
398 AliFMDCorrector::RingHistos::operator=(const RingHistos& o)
401 // Assignment operator
403 // o Object to assign from
408 AliForwardUtil::RingHistos::operator=(o);
410 if (fDensity) delete fDensity;
412 fDensity = static_cast<TH2D*>(o.fDensity->Clone());
416 //____________________________________________________________________
417 AliFMDCorrector::RingHistos::~RingHistos()
422 if (fDensity) delete fDensity;
425 //____________________________________________________________________
427 AliFMDCorrector::RingHistos::Output(TList* dir)
432 // dir Where to put it
434 TList* d = DefineOutputList(dir);
438 //____________________________________________________________________
440 AliFMDCorrector::RingHistos::ScaleHistograms(TList* dir, Int_t /*nEvents*/)
443 // Scale the histograms to the total number of events
445 // dir where the output is stored
446 // nEvents Number of events
448 TList* l = GetOutputList(dir);
451 //TH1* density = GetOutputHist(l,Form("%s_Primary_Density", fName.Data()));
452 //if (density) density->Scale(1./nEvents);
455 //____________________________________________________________________