1 //====================================================================
2 #include "AliForwarddNdetaTask.h"
9 #include <AliAnalysisManager.h>
10 #include <AliAODEvent.h>
11 #include <AliAODHandler.h>
12 #include <AliAODInputHandler.h>
13 #include "AliForwardUtil.h"
14 #include "AliAODForwardMult.h"
16 //____________________________________________________________________
17 AliForwarddNdetaTask::AliForwarddNdetaTask()
23 DGUARD(fDebug, 3, "Default CTOR of AliForwarddNdetaTask");
26 //____________________________________________________________________
27 AliForwarddNdetaTask::AliForwarddNdetaTask(const char* /* name */)
28 : AliBasedNdetaTask("Forward")
36 DGUARD(fDebug, 3, "Named CTOR of AliForwarddNdetaTask");
39 //____________________________________________________________________
40 AliForwarddNdetaTask::AliForwarddNdetaTask(const AliForwarddNdetaTask& o)
41 : AliBasedNdetaTask(o)
46 DGUARD(fDebug, 3, "Copy CTOR of AliForwarddNdetaTask");
49 //____________________________________________________________________
50 AliBasedNdetaTask::CentralityBin*
51 AliForwarddNdetaTask::MakeCentralityBin(const char* name, Short_t l, Short_t h)
55 // Make a new centrality bin
58 // name Histogram names
63 // Newly allocated object (of our type)
65 DGUARD(fDebug, 3,"Make a centrality bin for AliForwarddNdetaTask: %s [%d,%d]",
67 return new AliForwarddNdetaTask::CentralityBin(name, l, h);
71 //____________________________________________________________________
73 AliForwarddNdetaTask::GetHistogram(const AliAODEvent* aod, Bool_t mc)
76 // Retrieve the histogram
80 // mc Whether to get the MC histogram or not
83 // Retrieved histogram or null
86 if (mc) obj = aod->FindListObject("ForwardMC");
87 else obj = aod->FindListObject("Forward");
89 // We should have a forward object at least
91 if (!mc) AliWarning("No Forward object found AOD");
94 AliAODForwardMult* forward = static_cast<AliAODForwardMult*>(obj);
95 return &(forward->GetHistogram());
97 //____________________________________________________________________
99 AliForwarddNdetaTask::CheckEventData(Double_t vtx,
103 // Check if this is satellite
104 // if (!fSatelliteVertices) return;
105 Double_t aVtx = TMath::Abs(vtx);
106 if (aVtx < 37.5 || aVtx > 400) return;
108 TH2* hists[] = { data, dataMC };
110 // In satellite vertices FMD2i is cut away manually at this point
111 // for certain vertices. It could be done in the ESDs, but as of
112 // this writing not for specific vertices.
114 // cholm comment: It would be difficult to setup the filter in the
115 // reconstruction pass, but it could perhaps be done in the AOD
118 // This is what was done for
119 // the Pb-Pb paper (arXiv:1304.0347).
120 for (Int_t iX = 0; iX<=data->GetNbinsX(); iX++) {
121 // Do all checks up front - as soon as we can - branching is
123 Double_t x = data->GetXaxis()->GetBinCenter(iX);
125 if (((vtx > 60 && vtx < 90) && x < 3) ||
126 ((vtx > 330 && vtx < 350) && x > -2.5) ||
127 ((vtx < 100 || vtx > 305) && TMath::Abs(x) < 4.5) ||
128 (vtx < 50 && TMath::Abs(x) < 4.75))
132 for (Int_t iH = 0; iH < 2; iH++) {
133 if (!hists[iH]) continue;
134 // if (iX > hists[iH]->GetNbinsX()+1) continue;
135 // Also zero coverage and phi acceptance for this
136 for (Int_t iY = 0; iY<=hists[iH]->GetNbinsY()+1; iY++) {
137 hists[iH]->SetBinContent(iX, iY, 0);
138 hists[iH]->SetBinError(iX, iY, 0);
144 // Now, since we have some dead areas in FMD2i (sectors 16 and
145 // 17), we need to remove the corresponding bins from the
146 // histogram. However, it is not obvious which bins (in eta) to
147 // remove, so remove everything starting from the most negative to
148 // the middle of the histogram.
150 // This hack was first introduced by HHD, but was done at the end of
151 // the event processing (CentralityBin::MakeResults). That is,
152 // however, not very practical, as we'd like to normalize to the phi
153 // acceptance rather than the eta coverage and then correct for
154 // empty bins. Since the only way to really update the phi
155 // acceptance stored in the overflow bin is on the event level, we
156 // should really do it here.
157 const Int_t phiBin1 = 17; // Sector 16
158 const Int_t phiBin2 = 18; // Sector 17
159 for (Int_t iH = 0; iH < 2; iH++) {
160 if (!hists[iH]) continue;
162 Int_t midX = hists[iH]->GetNbinsX() / 2;
163 // Int_t nY = hists[iH]->GetNbinsY();
164 for (Int_t i = 1; i <= midX; i++) {
165 hists[iH]->SetBinContent(i, phiBin1, 0);
166 hists[iH]->SetBinContent(i, phiBin2, 0);
167 hists[iH]->SetBinError(i, phiBin1, 0);
168 hists[iH]->SetBinError(i, phiBin2, 0);
170 // Here, we should also modify the overflow bin to reflect the
171 // new phi acceptance. First get the old phi acceptance -
172 // then multiply this on the number of bins. This gives us -
173 // roughly - the number of sectors we had. Then take out two
174 // from that number, and then calculate the new phi
175 // Acceptance. Note, if the sectors where already taken out in
176 // the AOD production, we _will_ end up with a wrong number,
177 // so we should _not_ do that in the AOD production. This is
178 // tricky and may not work at all. For now, we should rely on
179 // the old way of correcting to the eta coverage and
180 // correcting for empty bins.
185 //========================================================================
187 AliForwarddNdetaTask::CentralityBin::End(TList* sums,
190 const TH2F* shapeCorr,
204 DGUARD(fDebug, 1, "In End of %s with corrEmpty=%d, cutEdges=%d, rootProj=%d",
205 GetName(), corrEmpty, cutEdges, rootProj);
206 AliBasedNdetaTask::CentralityBin::End(sums, results, scheme,
207 shapeCorr, trigEff, trigEff0,
209 rootProj, corrEmpty, cutEdges,
210 triggerMask, marker, color, mclist,
213 if (!IsAllBin()) return;
214 TFile* file = TFile::Open("forward.root", "READ");
217 TList* forward = static_cast<TList*>(file->Get("Forward"));
219 AliError("List Forward not found in forward.root");
222 TList* rings = static_cast<TList*>(forward->FindObject("ringResults"));
224 AliError("List ringResults not found in forward.root");
227 THStack* res = static_cast<THStack*>(rings->FindObject("all"));
229 AliError(Form("Stack all not found in %s", rings->GetName()));
233 AliError("Triggers histogram not set");
238 Double_t epsilonT = trigEff;
241 if (triggerMask == AliAODForwardMult::kNSD) {
242 // This is a local change
244 AliWarning(Form("Using hard-coded NSD trigger efficiency of %f",epsilonT));
247 AliInfo("Adding per-ring histograms to output");
249 Double_t scaler = Normalization(*fTriggers, scheme, epsilonT, ntotal, &text);
250 TIter next(res->GetHists());
252 while ((hist = static_cast<TH1*>(next()))) hist->Scale(scaler);
253 res->SetName("dndetaRings");
255 fOutput->Add(new TNamed("normCalc", text.Data()));
258 //________________________________________________________________________