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);
97 //____________________________________________________________________
98 void AliCentralMultiplicityTask::UserExec(Option_t* /*option*/)
101 AliESDInputHandler* eventHandler =
102 dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()
103 ->GetInputEventHandler());
105 AliWarning("No inputhandler found for this event!");
108 AliESDEvent* esd = eventHandler->GetEvent();
110 if(!GetManager().IsInit() && !firstEventSeen) {
111 AliFMDEventInspector inspector;
112 inspector.ReadRunDetails(esd);
113 GetManager().Init(inspector.GetCollisionSystem(),
114 inspector.GetEnergy(),
115 inspector.GetField());
117 //std::cout<<inspector.GetCollisionSystem()<<" "<<inspector.GetEnergy()<<" "<<inspector.GetField()<<std::endl;
118 AliInfo("Manager of corrections in AliCentralMultiplicityTask init");
119 firstEventSeen = kTRUE;
122 //Selecting only events with |valid vertex| < 10 cm
123 const AliESDVertex* vertex = esd->GetPrimaryVertexSPD();
125 if(!(vertex->GetStatus())) return;
126 if(vertex->GetNContributors() <= 0) return ;
127 if(vertex->GetZRes() > 0.1 ) return;
128 Double_t vertexXYZ[3]={0,0,0};
129 vertex->GetXYZ(vertexXYZ);
130 if(TMath::Abs(vertexXYZ[2]) > 10) return;
133 Double_t vertexBinDouble = (vertexXYZ[2] + 10) / delta;
134 //HHD: The vtxbins are 1-10, not 0-9
135 Int_t vtxbin = Int_t(vertexBinDouble + 1) ;
137 // Make sure AOD is filled
138 AliAnalysisManager* am = AliAnalysisManager::GetAnalysisManager();
140 dynamic_cast<AliAODHandler*>(am->GetOutputEventHandler());
142 AliFatal("No AOD output handler set in analysis manager");
144 ah->SetFillAOD(kTRUE);
147 fAODCentral.Clear("");
148 TH2D *aodHist = &(fAODCentral.GetHistogram());
150 const AliMultiplicity* spdmult = esd->GetMultiplicity();
151 //Filling clusters in layer 1 used for tracklets...
152 for(Int_t j = 0; j< spdmult->GetNumberOfTracklets();j++)
153 aodHist->Fill(spdmult->GetEta(j),spdmult->GetPhi(j));
155 //...and then the unused ones in layer 1
156 for(Int_t j = 0; j< spdmult->GetNumberOfSingleClusters();j++)
157 aodHist->Fill(-TMath::Log(TMath::Tan(spdmult->GetThetaSingle(j)/2.)),
158 spdmult->GetPhiSingle(j));
163 TH1D* hAcceptance = fManager.GetAcceptanceCorrection(vtxbin);
164 if (fUseSecondary) hSecMap = fManager.GetSecMapCorrection(vtxbin);
165 if (fUseSecondary && !hSecMap) AliFatal("No secondary map!");
166 if (!hAcceptance) AliFatal("No acceptance!");
168 if (hSecMap) aodHist->Divide(hSecMap);
170 for(Int_t nx = 1; nx <= aodHist->GetNbinsX(); nx++) {
171 Float_t accCor = hAcceptance->GetBinContent(nx);
173 Bool_t etabinSeen = kFALSE;
174 for(Int_t ny = 1; ny <= aodHist->GetNbinsY(); ny++) {
175 Float_t aodValue = aodHist->GetBinContent(nx,ny);
176 Float_t secCor = hSecMap->GetBinContent(nx,ny);
177 if (secCor > 0.5) etabinSeen = kTRUE;
178 if (aodValue < 0.000001) { aodHist->SetBinContent(nx,ny, 0); continue; }
179 if (accCor < 0.000001) accCor = 1;
180 Float_t aodNew = aodValue / accCor ;
181 aodHist->SetBinContent(nx,ny, aodNew);
182 Float_t aodErr = aodHist->GetBinError(nx,ny);
183 Float_t accErr = hAcceptance->GetBinError(nx);
184 Float_t error = aodNew *TMath::Sqrt(TMath::Power(aodErr/aodValue,2) +
185 TMath::Power(accErr/accCor,2) );
186 aodHist->SetBinError(nx,ny,error);
189 //Filling underflow bin if we eta bin is in range
190 if(etabinSeen) aodHist->SetBinContent(nx,0, 1.);
195 //____________________________________________________________________
196 void AliCentralMultiplicityTask::Terminate(Option_t* /*option*/)
199 //____________________________________________________________________
201 AliCentralMultiplicityTask::Print(Option_t* /*option*/) const
204 //====================================================================
205 AliCentralMultiplicityTask::Manager::Manager() :
206 fAcceptancePath("$ALICE_ROOT/PWG2/FORWARD/corrections/CentralAcceptance"),
207 fSecMapPath("$ALICE_ROOT/PWG2/FORWARD/corrections/CentralSecMap"),
210 fAcceptanceName("centralacceptance"),
211 fSecMapName("centralsecmap"),
217 //____________________________________________________________________
218 AliCentralMultiplicityTask::Manager::Manager(const Manager& o)
219 :fAcceptancePath(o.fAcceptancePath),
220 fSecMapPath(o.fSecMapPath),
221 fAcceptance(o.fAcceptance),
223 fAcceptanceName(o.fAcceptanceName),
224 fSecMapName(o.fSecMapName),
227 //____________________________________________________________________
228 AliCentralMultiplicityTask::Manager&
229 AliCentralMultiplicityTask::Manager::operator=(const Manager& o)
231 fAcceptancePath = o.fAcceptancePath;
232 fSecMapPath = o.fSecMapPath;
233 fAcceptance = o.fAcceptance;
235 fAcceptanceName = o.fAcceptanceName;
236 fSecMapName = o.fSecMapName;
241 //____________________________________________________________________
243 AliCentralMultiplicityTask::Manager::GetFullFileName(UShort_t what,
249 what == 0 ? GetSecMapPath() : GetAcceptancePath(),
250 GetFileName(what, sys, sNN, field));
253 //____________________________________________________________________
255 AliCentralMultiplicityTask::Manager::GetFileName(UShort_t what ,
260 // Must be static - otherwise the data may disappear on return from
261 // this member function
262 static TString fname = "";
266 case 0: fname.Append(fSecMapName.Data()); break;
267 case 1: fname.Append(fAcceptanceName.Data()); break;
269 ::Error("GetFileName",
270 "Invalid indentifier %d for central object, must be 0 or 1!", what);
273 fname.Append(Form("_%s_%04dGeV_%c%1dkG.root",
274 AliForwardUtil::CollisionSystemString(sys),
275 sNN, (field < 0 ? 'm' : 'p'), TMath::Abs(field)));
280 //____________________________________________________________________
282 AliCentralMultiplicityTask::Manager::GetSecMapCorrection(UShort_t vtxbin) const
285 ::Warning("GetSecMapCorrection","No secondary map defined");
288 return fSecmap->GetCorrection(vtxbin);
290 //____________________________________________________________________
292 AliCentralMultiplicityTask::Manager::GetAcceptanceCorrection(UShort_t vtxbin)
296 ::Warning("GetAcceptanceCorrection","No acceptance map defined");
299 return fAcceptance->GetCorrection(vtxbin);
302 //____________________________________________________________________
304 AliCentralMultiplicityTask::Manager::Init(UShort_t sys,
308 if(fIsInit) ::Warning("Init","Already initialised - overriding...");
310 TFile fsec(GetFullFileName(0,sys,sNN,field));
312 dynamic_cast<AliCentralCorrSecondaryMap*>(fsec.Get(fSecMapName.Data()));
314 ::Error("Init", "no central Secondary Map found!") ;
317 TFile facc(GetFullFileName(1,sys,sNN,field));
319 dynamic_cast<AliCentralCorrAcceptance*>(facc.Get(fAcceptanceName.Data()));
321 ::Error("Init", "no central Acceptance found!") ;
325 if(fSecmap && fAcceptance) {
328 "Central Manager initialised for sys %d, energy %d, field %d",sys,sNN,field);