1 // This task finds the eventplane
4 #include "AliFMDEventPlaneFinder.h"
15 #include "AliOADBContainer.h"
16 #include "AliAnalysisManager.h"
17 #include "AliVEvent.h"
18 #include "AliEventplane.h"
19 #include "AliCentrality.h"
20 #include "AliAODForwardEP.h"
21 #include "AliAODForwardMult.h"
22 #include "AliAODEvent.h"
24 ClassImp(AliFMDEventPlaneFinder)
29 //____________________________________________________________________
30 AliFMDEventPlaneFinder::AliFMDEventPlaneFinder()
40 fHistFMDEventplane(0),
41 fHistFMDEventplaneA(0),
42 fHistFMDEventplaneC(0),
43 fHistFMDEventplane1(0),
44 fHistFMDEventplane2(0),
63 //____________________________________________________________________
64 AliFMDEventPlaneFinder::AliFMDEventPlaneFinder(const char* title)
65 : TNamed("fmdEventPlaneFinder", title),
74 fHistFMDEventplane(0),
75 fHistFMDEventplaneA(0),
76 fHistFMDEventplaneC(0),
77 fHistFMDEventplane1(0),
78 fHistFMDEventplane2(0),
95 // name Name of object
99 //____________________________________________________________________
100 AliFMDEventPlaneFinder::AliFMDEventPlaneFinder(const
101 AliFMDEventPlaneFinder& o)
111 fHistFMDEventplane(o.fHistFMDEventplane),
112 fHistFMDEventplaneA(o.fHistFMDEventplaneA),
113 fHistFMDEventplaneC(o.fHistFMDEventplaneC),
114 fHistFMDEventplane1(o.fHistFMDEventplane1),
115 fHistFMDEventplane2(o.fHistFMDEventplane2),
116 fHistPhiDist(o.fHistPhiDist),
117 fHistFMDmTPCep(o.fHistFMDmTPCep),
118 fHistFMDvsTPCep(o.fHistFMDvsTPCep),
119 fHistFMDmVZEROep(o.fHistFMDmVZEROep),
120 fHistFMDvsVZEROep(o.fHistFMDvsVZEROep),
122 fOADBFileName(o.fOADBFileName),
123 fOADBContainer(o.fOADBContainer),
124 fPhiDist(o.fPhiDist),
125 fRunNumber(o.fRunNumber),
126 fUsePhiWeights(o.fUsePhiWeights)
132 // o Object to copy from
136 //____________________________________________________________________
137 AliFMDEventPlaneFinder::~AliFMDEventPlaneFinder()
144 //____________________________________________________________________
145 AliFMDEventPlaneFinder&
146 AliFMDEventPlaneFinder::operator=(const AliFMDEventPlaneFinder& o)
149 // Assignement operator
152 // o Object to assign from
155 // Reference to this object
157 if (&o == this) return *this;
158 TNamed::operator=(o);
168 fHistFMDEventplane = o.fHistFMDEventplane;
169 fHistFMDEventplaneA = o.fHistFMDEventplaneA;
170 fHistFMDEventplaneC = o.fHistFMDEventplaneC;
171 fHistFMDEventplane1 = o.fHistFMDEventplane1;
172 fHistFMDEventplane2 = o.fHistFMDEventplane2;
173 fHistPhiDist = o.fHistPhiDist;
174 fHistFMDmTPCep = o.fHistFMDmTPCep;
175 fHistFMDvsTPCep = o.fHistFMDvsTPCep;
176 fHistFMDmVZEROep = o.fHistFMDmVZEROep;
177 fHistFMDvsVZEROep = o.fHistFMDvsVZEROep;
179 fOADBFileName = o.fOADBFileName;
180 fOADBContainer = o.fOADBContainer;
181 fPhiDist = o.fPhiDist;
182 fRunNumber = o.fRunNumber;
183 fUsePhiWeights = o.fUsePhiWeights;
188 //____________________________________________________________________
190 AliFMDEventPlaneFinder::Init(const TAxis& etaAxis)
192 // Intialize this sub-algorithm
195 // etaAxis fmd eta axis binning
197 fHistFMDEventplane = new TH1D("hFMDEventplane", "FMD eventplane",
198 100, 0., TMath::Pi());
199 fHistFMDEventplane->Sumw2();
200 fHistFMDEventplane->SetDirectory(0);
201 fList->Add(fHistFMDEventplane);
204 fHistFMDEventplaneA = new TH1D("hFMDEventplaneA", "FMD eventplaneA",
205 100, 0., TMath::Pi());
206 fHistFMDEventplaneA->Sumw2();
207 fHistFMDEventplaneA->SetDirectory(0);
208 fList->Add(fHistFMDEventplaneA);
211 fHistFMDEventplaneC = new TH1D("hFMDEventplaneC", "FMD eventplaneC",
212 100, 0., TMath::Pi());
213 fHistFMDEventplaneC->Sumw2();
214 fHistFMDEventplaneC->SetDirectory(0);
215 fList->Add(fHistFMDEventplaneC);
218 fHistFMDEventplane1 = new TH1D("hFMDEventplane1", "FMD eventplane1",
219 100, 0., TMath::Pi());
220 fHistFMDEventplane1->Sumw2();
221 fHistFMDEventplane1->SetDirectory(0);
222 fList->Add(fHistFMDEventplane1);
225 fHistFMDEventplane2 = new TH1D("hFMDEventplane2", "FMD eventplane2",
226 100, 0., TMath::Pi());
227 fHistFMDEventplane2->Sumw2();
228 fHistFMDEventplane2->SetDirectory(0);
229 fList->Add(fHistFMDEventplane2);
232 fHistPhiDist = new TH2D("hPhiDist", "Phi distribution in FMD",
233 etaAxis.GetNbins(), etaAxis.GetXmin(), etaAxis.GetXmax(),
234 20, 0., TMath::TwoPi());
235 fHistPhiDist->Sumw2();
236 fHistPhiDist->SetDirectory(0);
237 fList->Add(fHistPhiDist);
240 fHistFMDmTPCep = new TH1D("hFMDmTPCep",
241 "Eventplane from FMD - TPC",
242 100, -TMath::Pi()/2., TMath::Pi()/2.);
243 fHistFMDmTPCep->Sumw2();
244 fHistFMDmTPCep->SetDirectory(0);
245 fList->Add(fHistFMDmTPCep);
248 fHistFMDvsTPCep = new TH2F("hFMDvsTPCep",
249 "Eventplane from FMD vs. TPC",
250 100, 0., TMath::Pi(),
251 100, 0., TMath::Pi());
252 fHistFMDvsTPCep->Sumw2();
253 fHistFMDvsTPCep->SetDirectory(0);
254 fList->Add(fHistFMDvsTPCep);
257 fHistFMDmVZEROep = new TH1D("hFMDmVZEROep",
258 "Eventplane from FMD - VZERO",
259 100, -TMath::Pi()/2., TMath::Pi()/2.);
260 fHistFMDmVZEROep->Sumw2();
261 fHistFMDmVZEROep->SetDirectory(0);
262 fList->Add(fHistFMDmVZEROep);
265 fHistFMDvsVZEROep = new TH2F("hFMDvsVZEROep",
266 "Eventplane from FMD vs. VZERO",
267 100, 0., TMath::Pi(),
268 100, 0., TMath::Pi());
269 fHistFMDvsVZEROep->Sumw2();
270 fHistFMDvsVZEROep->SetDirectory(0);
271 fList->Add(fHistFMDvsVZEROep);
273 if (!fUsePhiWeights) return;
275 if (fOADBFileName.Length()==0)
276 fOADBFileName = Form("%s/PWGLF/FORWARD/FMDEVENTPLANE/data/fmdEPoadb.root",
277 AliAnalysisManager::GetOADBPath());
279 TFile foadb(fOADBFileName);
280 if(!foadb.IsOpen()) {
281 AliError(Form("Cannot open OADB file %s", fOADBFileName.Data()));
284 fOADBContainer = (AliOADBContainer*)foadb.Get("FMDphidist");
285 if (!fOADBContainer) AliError(Form("No OADB container found in %s", fOADBFileName.Data()));
291 //_____________________________________________________________________
293 AliFMDEventPlaneFinder::DefineOutput(TList* dir)
296 // Output diagnostic histograms to directory
299 // dir List to write in
303 fList->SetName(GetName());
309 //____________________________________________________________________
311 AliFMDEventPlaneFinder::FindEventplane(AliVEvent* ev,
312 AliAODForwardEP& aodep,
314 AliForwardUtil::Histos* hists)
317 // Do the calculations
320 // hists Histogram cache
321 // ep calculated eventplane
332 TH1D epEtaHist = aodep.GetHistogram();
336 for (UShort_t d=1; d<=3; d++) {
337 UShort_t nr = (d == 1 ? 1 : 2);
338 for (UShort_t q=0; q<nr; q++) {
339 Char_t r = (q == 0 ? 'I' : 'O');
340 CalcQVectors(hists->Get(d,r), &epEtaHist);
345 CalcQVectors(h, &epEtaHist);
348 aodep.SetEventplane(CalcEventplane(fQt));
349 aodep.SetEventplaneA(CalcEventplane(fQa));
350 aodep.SetEventplaneC(CalcEventplane(fQc));
351 // aodep.SetEventplane1(CalcEventplane(fQ1));
352 // aodep.SetEventplane2(CalcEventplane(fQ2));
359 //_____________________________________________________________________
361 AliFMDEventPlaneFinder::CalcQVectors(TH2D* h, TH1D* eHist)
364 // Calculate the Q vectors
366 Double_t phi = 0, eta = 0, weight = 0;
367 for (Int_t e = 1; e <= h->GetNbinsX(); e++) {
368 Double_t qx = 0, qy = 0;
369 eta = h->GetXaxis()->GetBinCenter(e);
370 for (Int_t p = 1; p <= h->GetNbinsY(); p++) {
371 phi = h->GetYaxis()->GetBinCenter(p);
372 weight = h->GetBinContent(e, p);
373 if (fUsePhiWeights) weight *= GetPhiWeight(e, p);
375 if (e > 168 && p == 14) {
376 h->GetBinContent(e, 4);
377 if (fUsePhiWeights) weight *= GetPhiWeight(e, 4);
379 fHistPhiDist->Fill(eta, phi, weight);
380 // for underflowbin total Nch/eta
381 fHistPhiDist->Fill(eta, -1., weight);
383 // increment Q vectors
384 qx += weight*TMath::Cos(2.*phi);
385 qy += weight*TMath::Sin(2.*phi);
387 TVector2 qVec = TVector2(qx, qy);
389 if (eta < 0) fQa += qVec;
390 if (eta > 0) fQc += qVec;
391 // TODO: Add random ep increments
394 eHist->Fill(eta, CalcEventplane(fQeta));
402 //_____________________________________________________________________
404 AliFMDEventPlaneFinder::CalcEventplane(TVector2 v) const
407 // Calculate the eventplane
411 if (v.Mod() == 0.) return ep;
417 AliInfo(Form("Eventplane found to be: %f", ep));
422 //_____________________________________________________________________
424 AliFMDEventPlaneFinder::FillHists(AliAODForwardEP* fmdEP)
427 // Fill diagnostics histograms
429 Double_t fmdEPt = fmdEP->GetEventplane();
430 Double_t fmdEPa = fmdEP->GetEventplaneA();
431 Double_t fmdEPc = fmdEP->GetEventplaneC();
432 // Double_t fmdEP1 = fmdEP->GetEventplane1();
433 // Double_t fmdEP2 = fmdEP->GetEventplane2();
436 fHistFMDEventplane->Fill(fmdEPt);
437 fHistFMDEventplaneA->Fill(fmdEPa);
438 fHistFMDEventplaneC->Fill(fmdEPc);
439 // fHistFMDEventplane1->Fill(fmdEP1);
440 // fHistFMDEventplane2->Fill(fmdEP2);
443 AliEventplane* ep = fEvent->GetEventplane();
445 if (ep) ep->GetEventplane("Q");
447 Double_t diffTPC = fmdEPt - tpcEP;
449 if (diffTPC < TMath::Pi()/2.) diffTPC = TMath::Pi() - diffTPC;
450 if (diffTPC >= TMath::Pi()/2.) diffTPC = TMath::Pi() - diffTPC;
452 fHistFMDmTPCep->Fill(diffTPC);
454 // if (fmdEPt >= TMath::Pi()/2. && fmdEPt - tpcEP >= TMath::Pi()/2.) tpcEP = TMath::Pi()-tpcEP;
455 // if (fmdEPt < TMath::Pi()/2. && tpcEP - fmdEPt >= TMath::Pi()/2.) tpcEP = TMath::Pi()-tpcEP;
457 fHistFMDvsTPCep->Fill(fmdEPt, tpcEP);
460 Double_t vzeroEP = -1;
461 if (ep) ep->GetEventplane("V0");
463 Double_t diffVZERO = fmdEPt - vzeroEP;
465 if (diffVZERO < TMath::Pi()/2.) diffVZERO = TMath::Pi() - diffVZERO;
466 if (diffVZERO >= TMath::Pi()/2.) diffVZERO = TMath::Pi() - diffVZERO;
468 fHistFMDmVZEROep->Fill(diffVZERO);
470 // if (fmdEPt >= TMath::Pi()/2. && fmdEPt - vzeroEP >= TMath::Pi()/2.) vzeroEP = TMath::Pi()-vzeroEP;
471 // if (fmdEPt < TMath::Pi()/2. && vzeroEP - fmdEPt >= TMath::Pi()/2.) vzeroEP = TMath::Pi()-vzeroEP;
473 fHistFMDvsVZEROep->Fill(fmdEPt, vzeroEP);
477 //_____________________________________________________________________
479 AliFMDEventPlaneFinder::GetPhiWeight(Int_t etaBin, Int_t phiBin) const
482 // Get phi weight for flattening
484 Double_t phiWeight = 1;
487 Double_t nParticles = fPhiDist->GetBinContent(etaBin, 0);
488 Double_t nPhiBins = fPhiDist->GetNbinsY();
489 Double_t phiDistValue = fPhiDist->GetBinContent(etaBin, phiBin);
491 if (phiDistValue > 0) phiWeight = nParticles/nPhiBins/phiDistValue;
497 //____________________________________________________________________
499 AliFMDEventPlaneFinder::SetRunNumber(Int_t run)
504 if (fRunNumber == run) return;
507 if (fUsePhiWeights) GetPhiDist();
512 //____________________________________________________________________
514 AliFMDEventPlaneFinder::GetPhiDist()
517 // Get phi dist from OADB
519 if (!fOADBContainer) return;
521 fPhiDist = (TH2D*)fOADBContainer->GetObject(fRunNumber, "Default")->Clone(Form("fPhiDist_%d", fRunNumber));
522 fList->Add(fPhiDist);
527 //____________________________________________________________________
529 AliFMDEventPlaneFinder::Print(Option_t* /*option*/) const
537 char ind[gROOT->GetDirLevel()+3];
538 for (Int_t i = 0; i < gROOT->GetDirLevel(); i++) ind[i] = ' ';
539 ind[gROOT->GetDirLevel()] = '\0';
540 std::cout << ind << ClassName() << ": " << GetName() << '\n'
542 << ind << "Eventplane finder active!" << '\n'
543 << ind << "Loading OADB object for run number: " << fRunNumber << '\n'
544 << ind << "Using phi weights: " << (fUsePhiWeights ? "true" : "false") << '\n'
547 std::cout << std::endl;
549 //____________________________________________________________________