1 //====================================================================
3 // Base class for classes that calculate the multiplicity in the
4 // central region event-by-event
10 // - AliAODCentralMult
15 #include "AliCentralMultiplicityTask.h"
16 #include "AliForwardCorrectionManager.h"
17 #include "AliForwardUtil.h"
19 #include "AliAODHandler.h"
20 #include "AliInputEventHandler.h"
21 #include "AliESDInputHandler.h"
22 #include "AliAnalysisManager.h"
23 #include "AliESDEvent.h"
24 #include "AliMultiplicity.h"
25 #include "AliFMDEventInspector.h"
32 //====================================================================
33 AliCentralMultiplicityTask::AliCentralMultiplicityTask(const char* name)
34 : AliAnalysisTaskSE(name),
43 DefineOutput(1, TList::Class());
45 //____________________________________________________________________
46 AliCentralMultiplicityTask::AliCentralMultiplicityTask()
47 : AliAnalysisTaskSE(),
56 //____________________________________________________________________
57 AliCentralMultiplicityTask::AliCentralMultiplicityTask(const AliCentralMultiplicityTask& o)
58 : AliAnalysisTaskSE(o),
61 fAODCentral(o.fAODCentral),
63 fUseSecondary(o.fUseSecondary),
64 firstEventSeen(o.firstEventSeen)
67 //____________________________________________________________________
68 AliCentralMultiplicityTask&
69 AliCentralMultiplicityTask::operator=(const AliCentralMultiplicityTask& o)
73 fAODCentral = o.fAODCentral;
74 fManager = o.fManager;
75 fUseSecondary = o.fUseSecondary;
76 firstEventSeen = o.firstEventSeen;
79 //____________________________________________________________________
80 void AliCentralMultiplicityTask::UserCreateOutputObjects()
83 AliAnalysisManager* am = AliAnalysisManager::GetAnalysisManager();
85 dynamic_cast<AliAODHandler*>(am->GetOutputEventHandler());
86 if (!ah) AliFatal("No AOD output handler set in analysis manager");
89 TObject* obj = &fAODCentral;
90 ah->AddBranch("AliAODCentralMult", &obj);
96 //____________________________________________________________________
97 void AliCentralMultiplicityTask::UserExec(Option_t* /*option*/)
100 AliESDInputHandler* eventHandler =
101 dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()
102 ->GetInputEventHandler());
104 AliWarning("No inputhandler found for this event!");
107 AliESDEvent* esd = eventHandler->GetEvent();
109 if(!GetManager().IsInit() && !firstEventSeen) {
110 AliFMDEventInspector inspector;
111 inspector.ReadRunDetails(esd);
112 GetManager().Init(inspector.GetCollisionSystem(),
113 inspector.GetEnergy(),
114 inspector.GetField());
116 //std::cout<<inspector.GetCollisionSystem()<<" "<<inspector.GetEnergy()<<" "<<inspector.GetField()<<std::endl;
117 AliInfo("Manager of corrections in AliCentralMultiplicityTask init");
118 firstEventSeen = kTRUE;
121 //Selecting only events with |valid vertex| < 10 cm
122 const AliESDVertex* vertex = esd->GetPrimaryVertexSPD();
124 if(!(vertex->GetStatus())) return;
125 if(vertex->GetNContributors() <= 0) return ;
126 if(vertex->GetZRes() > 0.1 ) return;
127 Double_t vertexXYZ[3]={0,0,0};
128 vertex->GetXYZ(vertexXYZ);
129 if(TMath::Abs(vertexXYZ[2]) > 10) return;
132 Double_t vertexBinDouble = (vertexXYZ[2] + 10) / delta;
133 //HHD: The vtxbins are 1-10, not 0-9
134 Int_t vtxbin = Int_t(vertexBinDouble + 1) ;
136 // Make sure AOD is filled
137 AliAnalysisManager* am = AliAnalysisManager::GetAnalysisManager();
139 dynamic_cast<AliAODHandler*>(am->GetOutputEventHandler());
141 AliFatal("No AOD output handler set in analysis manager");
143 ah->SetFillAOD(kTRUE);
146 fAODCentral.Clear("");
147 TH2D *aodHist = &(fAODCentral.GetHistogram());
149 const AliMultiplicity* spdmult = esd->GetMultiplicity();
150 //Filling clusters in layer 1 used for tracklets...
151 for(Int_t j = 0; j< spdmult->GetNumberOfTracklets();j++)
152 aodHist->Fill(spdmult->GetEta(j),spdmult->GetPhi(j));
154 //...and then the unused ones in layer 1
155 for(Int_t j = 0; j< spdmult->GetNumberOfSingleClusters();j++)
156 aodHist->Fill(-TMath::Log(TMath::Tan(spdmult->GetThetaSingle(j)/2.)),
157 spdmult->GetPhiSingle(j));
162 TH1D* hAcceptance = fManager.GetAcceptanceCorrection(vtxbin);
163 if (fUseSecondary) hSecMap = fManager.GetSecMapCorrection(vtxbin);
164 if (fUseSecondary && !hSecMap) AliFatal("No secondary map!");
165 if (!hAcceptance) AliFatal("No acceptance!");
167 if (hSecMap) aodHist->Divide(hSecMap);
169 for(Int_t nx = 1; nx <= aodHist->GetNbinsX(); nx++) {
170 Float_t accCor = hAcceptance->GetBinContent(nx);
172 Bool_t etabinSeen = kFALSE;
173 for(Int_t ny = 1; ny <= aodHist->GetNbinsY(); ny++) {
174 Float_t aodValue = aodHist->GetBinContent(nx,ny);
175 Float_t secCor = hSecMap->GetBinContent(nx,ny);
176 if (secCor > 0.5) etabinSeen = kTRUE;
177 if (aodValue < 0.000001) { aodHist->SetBinContent(nx,ny, 0); continue; }
178 if (accCor < 0.000001) accCor = 1;
179 Float_t aodNew = aodValue / accCor ;
180 aodHist->SetBinContent(nx,ny, aodNew);
181 Float_t aodErr = aodHist->GetBinError(nx,ny);
182 Float_t accErr = hAcceptance->GetBinError(nx);
183 Float_t error = aodNew *TMath::Sqrt(TMath::Power(aodErr/aodValue,2) +
184 TMath::Power(accErr/accCor,2) );
185 aodHist->SetBinError(nx,ny,error);
188 //Filling underflow bin if we eta bin is in range
189 if(etabinSeen) aodHist->SetBinContent(nx,0, 1.);
194 //____________________________________________________________________
195 void AliCentralMultiplicityTask::Terminate(Option_t* /*option*/)
198 //____________________________________________________________________
200 AliCentralMultiplicityTask::Print(Option_t* /*option*/) const
203 //====================================================================
204 AliCentralMultiplicityTask::Manager::Manager() :
205 fAcceptancePath("$ALICE_ROOT/PWG2/FORWARD/corrections/CentralAcceptance"),
206 fSecMapPath("$ALICE_ROOT/PWG2/FORWARD/corrections/CentralSecMap"),
209 fAcceptanceName("centralacceptance"),
210 fSecMapName("centralsecmap"),
216 //____________________________________________________________________
217 AliCentralMultiplicityTask::Manager::Manager(const Manager& o)
218 :fAcceptancePath(o.fAcceptancePath),
219 fSecMapPath(o.fSecMapPath),
220 fAcceptance(o.fAcceptance),
222 fAcceptanceName(o.fAcceptanceName),
223 fSecMapName(o.fSecMapName),
226 //____________________________________________________________________
227 AliCentralMultiplicityTask::Manager&
228 AliCentralMultiplicityTask::Manager::operator=(const Manager& o)
230 fAcceptancePath = o.fAcceptancePath;
231 fSecMapPath = o.fSecMapPath;
232 fAcceptance = o.fAcceptance;
234 fAcceptanceName = o.fAcceptanceName;
235 fSecMapName = o.fSecMapName;
240 //____________________________________________________________________
242 AliCentralMultiplicityTask::Manager::GetFullFileName(UShort_t what,
248 what == 0 ? GetSecMapPath() : GetAcceptancePath(),
249 GetFileName(what, sys, sNN, field));
252 //____________________________________________________________________
254 AliCentralMultiplicityTask::Manager::GetFileName(UShort_t what ,
259 // Must be static - otherwise the data may disappear on return from
260 // this member function
261 static TString fname = "";
265 case 0: fname.Append(fSecMapName.Data()); break;
266 case 1: fname.Append(fAcceptanceName.Data()); break;
268 ::Error("GetFileName",
269 "Invalid indentifier %d for central object, must be 0 or 1!", what);
272 fname.Append(Form("_%s_%04dGeV_%c%1dkG.root",
273 AliForwardUtil::CollisionSystemString(sys),
274 sNN, (field < 0 ? 'm' : 'p'), TMath::Abs(field)));
279 //____________________________________________________________________
281 AliCentralMultiplicityTask::Manager::GetSecMapCorrection(UShort_t vtxbin) const
284 ::Warning("GetSecMapCorrection","No secondary map defined");
287 return fSecmap->GetCorrection(vtxbin);
289 //____________________________________________________________________
291 AliCentralMultiplicityTask::Manager::GetAcceptanceCorrection(UShort_t vtxbin)
295 ::Warning("GetAcceptanceCorrection","No acceptance map defined");
298 return fAcceptance->GetCorrection(vtxbin);
301 //____________________________________________________________________
303 AliCentralMultiplicityTask::Manager::Init(UShort_t sys,
307 if(fIsInit) ::Warning("Init","Already initialised - overriding...");
309 TFile fsec(GetFullFileName(0,sys,sNN,field));
311 dynamic_cast<AliCentralCorrSecondaryMap*>(fsec.Get(fSecMapName.Data()));
313 ::Error("Init", "no central Secondary Map found!") ;
316 TFile facc(GetFullFileName(1,sys,sNN,field));
318 dynamic_cast<AliCentralCorrAcceptance*>(facc.Get(fAcceptanceName.Data()));
320 ::Error("Init", "no central Acceptance found!") ;
324 if(fSecmap && fAcceptance) {
327 "Central Manager initialised for sys %d, energy %d, field %d",sys,sNN,field);