AliPhysics  608b256 (608b256)
AliAnalysisTaskChargedJetsHadronToy.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-2016, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Author: R. Haake. *
5  * Contributors are mentioned in the code where appropriate. *
6  * *
7  * Permission to use, copy, modify and distribute this software and its *
8  * documentation strictly for non-commercial purposes is hereby granted *
9  * without fee, provided that the above copyright notice appears in all *
10  * copies and that both the copyright notice and this permission notice *
11  * appear in the supporting documentation. The authors make no claims *
12  * about the suitability of this software for any purpose. It is *
13  * provided "as is" without express or implied warranty. *
14  **************************************************************************/
15 #include <iostream>
16 #include <TRandom3.h>
17 #include <AliLog.h>
18 #include <TString.h>
19 #include <TMath.h>
20 #include <TF1.h>
21 #include <AliEmcalJet.h>
22 #include <AliESDEvent.h>
23 #include <AliAODEvent.h>
24 #include "AliESDVertex.h"
25 #include "AliAODVertex.h"
26 #include <AliAODTrack.h>
27 #include <AliPicoTrack.h>
28 #include <TClonesArray.h>
29 #include <AliAODMCParticle.h>
30 
31 #include <TFile.h>
32 #include <TGrid.h>
33 #include <TSystem.h>
34 
37 
41 //_____________________________________________________________________________________________________
43  AliAnalysisTaskEmcalJet("AliAnalysisTaskChargedJetsHadronToy", kTRUE), fAddTracksFromInputEvent(0), fAddTracksFromPicoTracks(0), fAddTracksFromToy(0), fAddTracksFromMixedEvent(0), fTrackEfficiency_InputEvent(1.0), fTrackEfficiency_Toy(1.0), fTrackEfficiency_ME(1.0), fTrackEfficiency_PicoTracks(1.0), fLabelOffset_InputEvent(0), fLabelOffset_Toy(500000), fLabelOffset_ME(600000), fLabelOffset_PicoTracks(700000), fDistributionMultiplicity(0), fDistributionPt(0), fDistributionEtaPhi(0), fMinCentrality(0), fMaxCentrality(10), fMaxEta(0.9), fDistributionV2(0), fDistributionV3(0), fDistributionV4(0), fDistributionV5(0), fMixedEvent_Tree(0), fMixedEvent_CurrentFile(0), fMixedEvent_CurrentFileID(-1), fMixedEvent_BaseFolder(""), fMixedEvent_TreeName("ME_tree"), fMixedEvent_CurrentEventID(0), fMixedEvent_NumTotalFiles(30), fBuffer_NumTracks(0), fBuffer_TrackPt(0), fBuffer_TrackPhi(0), fBuffer_TrackEta(0), fBuffer_TrackCharge(0), fPicoTracksArrayName(""), fPicoTracksArray(0), fEventTracksArrayName(""), fEventTracksArray(0), fOutputArrayName(""), fOutputArray(0), fRandom(), fToyCent(0), fRandomPsi3(0), fRandomPsi4(0), fRandomPsi5(0)
44 {
45  // constructor
46  fBuffer_TrackPt = new Float_t[10000];
47  fBuffer_TrackPhi = new Float_t[10000];
48  fBuffer_TrackEta = new Float_t[10000];
49  fBuffer_TrackCharge = new Short_t[10000];
50 
51 }
52 
53 
54 //_____________________________________________________________________________________________________
56  AliAnalysisTaskEmcalJet(name, kTRUE), fAddTracksFromInputEvent(0), fAddTracksFromPicoTracks(0), fAddTracksFromToy(0), fAddTracksFromMixedEvent(0), fTrackEfficiency_InputEvent(1.0), fTrackEfficiency_Toy(1.0), fTrackEfficiency_ME(1.0), fTrackEfficiency_PicoTracks(1.0), fLabelOffset_InputEvent(0), fLabelOffset_Toy(500000), fLabelOffset_ME(600000), fLabelOffset_PicoTracks(700000), fDistributionMultiplicity(0), fDistributionPt(0), fDistributionEtaPhi(0), fMinCentrality(0), fMaxCentrality(10), fMaxEta(0.9), fDistributionV2(0), fDistributionV3(0), fDistributionV4(0), fDistributionV5(0), fMixedEvent_Tree(0), fMixedEvent_CurrentFile(0), fMixedEvent_CurrentFileID(-1), fMixedEvent_BaseFolder(""), fMixedEvent_TreeName("ME_tree"), fMixedEvent_CurrentEventID(0), fMixedEvent_NumTotalFiles(30), fBuffer_NumTracks(0), fBuffer_TrackPt(0), fBuffer_TrackPhi(0), fBuffer_TrackEta(0), fBuffer_TrackCharge(0), fPicoTracksArrayName(""), fPicoTracksArray(0), fEventTracksArrayName(""), fEventTracksArray(0), fOutputArrayName(""), fOutputArray(0), fRandom(), fToyCent(0), fRandomPsi3(0), fRandomPsi4(0), fRandomPsi5(0)
57 {
58  // constructor
59  fBuffer_TrackPt = new Float_t[10000];
60  fBuffer_TrackPhi = new Float_t[10000];
61  fBuffer_TrackEta = new Float_t[10000];
62  fBuffer_TrackCharge = new Short_t[10000];
63 }
64 
65 //_____________________________________________________________________________________________________
67 {
68  // destructor
71  if(fDistributionPt)
72  delete fDistributionPt;
74  delete fDistributionEtaPhi;
75 
76  delete fBuffer_TrackPt;
77  delete fBuffer_TrackPhi;
78  delete fBuffer_TrackEta;
79  delete fBuffer_TrackCharge;
80 
81 }
82 
83 
84 //_____________________________________________________________________________________________________
86 {
88 
89  fRandom = new TRandom3(0);
90  AddHistogram1D<TH1D>("hCombined_TrackPt", "Tracks p_{T} distribution", "", 300, 0., 300., "p_{T} (GeV/c)", "dN^{Tracks}/dp_{T}");
91  AddHistogram2D<TH2D>("hCombined_TrackPhiEta", "Track angular distribution #phi/#eta", "COLZ", 180, 0., 2*TMath::Pi(), 100, -2.5, 2.5, "#phi", "#eta", "dN^{Tracks}/d#phi d#eta");
92  AddHistogram1D<TH1D>("hCombined_Multiplicity", "Number of tracks in acceptance vs. centrality", "", 2000, 0., 20000., "N tracks","dN^{Events}/dN^{Tracks}");
93 
94  AddHistogram1D<TH1D>("hToy_TrackPt", "Tracks p_{T} distribution (toy)", "", 300, 0., 300., "p_{T} (GeV/c)", "dN^{Tracks}/dp_{T}");
95  AddHistogram2D<TH2D>("hToy_TrackPhiEta", "Track angular distribution #phi/#eta (toy)", "COLZ", 180, 0., 2*TMath::Pi(), 100, -2.5, 2.5, "#phi", "#eta", "dN^{Tracks}/d#phi d#eta");
96  AddHistogram1D<TH1D>("hToy_Multiplicity", "Number of tracks in acceptance vs. centrality (toy)", "", 2000, 0., 20000., "N tracks","dN^{Events}/dN^{Tracks}");
97 
98  AddHistogram1D<TH1D>("hInputTracks_TrackPt", "Tracks p_{T} distribution (input tracks)", "", 300, 0., 300., "p_{T} (GeV/c)", "dN^{Tracks}/dp_{T}");
99  AddHistogram2D<TH2D>("hInputTracks_TrackPhiEta", "Track angular distribution #phi/#eta (input tracks)", "COLZ", 180, 0., 2*TMath::Pi(), 100, -2.5, 2.5, "#phi", "#eta", "dN^{Tracks}/d#phi d#eta");
100  AddHistogram1D<TH1D>("hInputTracks_Multiplicity", "Number of tracks in acceptance vs. centrality (input tracks)", "", 2000, 0., 20000., "N tracks","dN^{Events}/dN^{Tracks}");
101 
102  AddHistogram1D<TH1D>("hPicoTracks_TrackPt", "Tracks p_{T} distribution (picotracks)", "", 300, 0., 300., "p_{T} (GeV/c)", "dN^{Tracks}/dp_{T}");
103  AddHistogram2D<TH2D>("hPicoTracks_TrackPhiEta", "Track angular distribution #phi/#eta (picotracks)", "COLZ", 180, 0., 2*TMath::Pi(), 100, -2.5, 2.5, "#phi", "#eta", "dN^{Tracks}/d#phi d#eta");
104  AddHistogram1D<TH1D>("hPicoTracks_Multiplicity", "Number of tracks in acceptance vs. centrality (picotracks)", "", 2000, 0., 20000., "N tracks","dN^{Events}/dN^{Tracks}");
105 
106  AddHistogram1D<TH1D>("hMixedEvent_TrackPt", "Tracks p_{T} distribution (ME)", "", 300, 0., 300., "p_{T} (GeV/c)", "dN^{Tracks}/dp_{T}");
107  AddHistogram2D<TH2D>("hMixedEvent_TrackPhiEta", "Track angular distribution #phi/#eta (ME)", "COLZ", 180, 0., 2*TMath::Pi(), 100, -2.5, 2.5, "#phi", "#eta", "dN^{Tracks}/d#phi d#eta");
108  AddHistogram1D<TH1D>("hMixedEvent_Multiplicity", "Number of tracks in acceptance vs. centrality (ME)", "", 2000, 0., 20000., "N tracks","dN^{Events}/dN^{Tracks}");
109 
110  PostData(1, fOutput);
111 }
112 
113 
114 //_____________________________________________________________________________________________________
116 {
118 
119  // Check if input array can be loaded
121  {
122  if(fEventTracksArrayName.IsNull())
123  AliFatal(Form("Input array name not given, although demanded"));
124 
125  fEventTracksArray = static_cast<TClonesArray*>(InputEvent()->FindListObject(Form("%s", fEventTracksArrayName.Data())));
126  if(!fEventTracksArray)
127  AliFatal(Form("Input array '%s' not found!", fEventTracksArrayName.Data()));
128  }
129 
130  // Check if input array (Picotracks) can be loaded
132  {
133  if(fPicoTracksArrayName.IsNull())
134  AliFatal(Form("Picotrack array name not given, although demanded"));
135 
136  fPicoTracksArray = static_cast<TClonesArray*>(InputEvent()->FindListObject(Form("%s", fPicoTracksArrayName.Data())));
137  if(!fPicoTracksArray)
138  AliFatal(Form("Picotrack array '%s' not found!", fPicoTracksArrayName.Data()));
139  }
140 
141  // Check if output arrays can be created
142  if((InputEvent()->FindListObject(Form("%s", fOutputArrayName.Data()))))
143  AliFatal(Form("Output array '%s' already exists in the event! Rename it.", fOutputArrayName.Data()));
144 
145  fOutputArray = new TClonesArray("AliAODTrack");
146  fOutputArray->SetName(fOutputArrayName.Data());
147  fInputEvent->AddObject(fOutputArray);
148 
149  // Check if necessary histograms are given
151  AliFatal("Demanded tracks from toy, but one of the necessary distribution was not given!");
152 
153 }
154 
155 //_____________________________________________________________________________________________________
157 {
158  AssembleEvent();
159  CreateQAPlots();
160  return kTRUE;
161 }
162 
163 //________________________________________________________________________
165 {
166  fRandomPsi3 = fRandom->Rndm()*TMath::Pi(); // once per event, create a random value dedicated for Psi3
167  fRandomPsi4 = fRandom->Rndm()*TMath::Pi(); // once per event, create a random value dedicated for Psi4
168  fRandomPsi5 = fRandom->Rndm()*TMath::Pi(); // once per event, create a random value dedicated for Psi5
169  fToyCent = fMinCentrality + (fMaxCentrality-fMinCentrality)*fRandom->Rndm(); // centrality value (flat from selected range)
170 
171  // ################# 1. Create a vertex if there is none (needed by some tasks)
172  if(dynamic_cast<AliESDEvent*>(InputEvent()))
173  {
174  if((dynamic_cast<AliESDEvent*>(InputEvent()))->GetPrimaryVertexTracks())
175  if(!(dynamic_cast<AliESDEvent*>(InputEvent()))->GetPrimaryVertexTracks()->GetNContributors())
176  static_cast<AliESDEvent*>(fInputEvent)->SetPrimaryVertexTracks(new AliESDVertex(0.,0., 100));
177  }
178  else if(dynamic_cast<AliAODEvent*>(InputEvent()))
179  {
180  if( (!(dynamic_cast<AliAODEvent*>(InputEvent()))->GetPrimaryVertex()) || (!(dynamic_cast<AliAODEvent*>(InputEvent()))->GetPrimaryVertex()->GetNContributors()) )
181  {
182  Double_t* p = new Double_t[3];
183  p[0] = 0.; p[1] = 0.; p[2] = 0.; // for backwards compatibility
184  AliAODVertex* vertex = new AliAODVertex(p,1.);
185  vertex->SetNContributors(100);
186  vertex->SetName("PrimaryVertex");
187  static_cast<AliAODEvent*>(fInputEvent)->AddVertex(vertex);
188  }
189  }
190 
191  Int_t numParticles_InputTracks = 0;
192  Int_t numParticles_Toy = 0;
193  Int_t numParticles_MixedEvent = 0;
194  Int_t numParticles_PicoTracks = 0;
195  Int_t particleCount = 0;
196 
197  // ################# 2. Add event tracks
199  {
200  for(Int_t i=0; i<fEventTracksArray->GetEntries(); i++)
201  {
202  // Discard tracks due to lowered tracking efficiency
203  if (fTrackEfficiency_InputEvent < 1.0)
204  if (fTrackEfficiency_InputEvent < fRandom->Rndm())
205  continue;
206 
207  // Load AOD tracks or AOD MC particles (for MC gen train)
208  AliAODTrack* aodTrack = dynamic_cast<AliAODTrack*>(fEventTracksArray->At(i));
209  AliAODMCParticle* aodMCParticle = dynamic_cast<AliAODMCParticle*>(fEventTracksArray->At(i));
210 
211  if(aodTrack)
212  {
213  if (TMath::Abs(aodTrack->Eta()) > fMaxEta)
214  continue;
215 
216  new ((*fOutputArray)[particleCount]) AliAODTrack(*aodTrack);
217  particleCount++;
218  if(aodTrack->IsHybridGlobalConstrainedGlobal())
219  {
220  FillHistogram("hInputTracks_TrackPt", aodTrack->Pt());
221  FillHistogram("hInputTracks_TrackPhiEta", aodTrack->Phi(), aodTrack->Eta());
222  numParticles_InputTracks++;
223  }
224  }
225  else if(aodMCParticle)
226  {
227  if (!aodMCParticle->IsPhysicalPrimary()) // only physical primaries
228  continue;
229  if (aodMCParticle->Charge() == 0) // only charged particles
230  continue;
231  if (TMath::Abs(aodMCParticle->Eta()) > fMaxEta)
232  continue;
233 
234  Float_t trackTheta = 2.*atan(exp(-aodMCParticle->Eta()));
235  new ((*fOutputArray)[particleCount]) AliAODTrack();
236  static_cast<AliAODTrack*>(fOutputArray->At(particleCount))->SetPt(aodMCParticle->Pt());
237  static_cast<AliAODTrack*>(fOutputArray->At(particleCount))->SetPhi(aodMCParticle->Phi());
238  static_cast<AliAODTrack*>(fOutputArray->At(particleCount))->SetTheta(trackTheta); // AliAODTrack cannot set eta directly
239  static_cast<AliAODTrack*>(fOutputArray->At(particleCount))->SetCharge(aodMCParticle->Charge());
240  static_cast<AliAODTrack*>(fOutputArray->At(particleCount))->SetLabel(aodMCParticle->GetLabel()+fLabelOffset_InputEvent);
241  static_cast<AliAODTrack*>(fOutputArray->At(particleCount))->SetIsHybridGlobalConstrainedGlobal();
242  particleCount++;
243  FillHistogram("hInputTracks_TrackPt", aodMCParticle->Pt());
244  FillHistogram("hInputTracks_TrackPhiEta", aodMCParticle->Phi(), aodMCParticle->Eta());
245  numParticles_InputTracks++;
246  }
247  }
248  }
249 
250  // ################# 3. Add tracks from mixed event trees
251  if(fAddTracksFromMixedEvent) // get underlying event from mixed event files
252  {
253  // if input tree not loaded or index at the end, get next tree file
255  {
257  if (!fMixedEvent_Tree)
258  {
259  AliError(Form("Could not get tree %s in file!", fMixedEvent_TreeName.Data()));
260  return;
261  }
262  }
263  fBuffer_NumTracks = 0; // Failsafe: Set num tracks to 0 if it is not read by GetEntry
265 
266  // Loop over tracks from event
267  for(Int_t i=0; i<fBuffer_NumTracks; i++)
268  {
269  // Discard tracks due to lowered tracking efficiency
270  if (fTrackEfficiency_ME < 1.0)
271  if (fTrackEfficiency_ME < fRandom->Rndm())
272  continue;
273 
274  if (TMath::Abs(fBuffer_TrackEta[i]) > fMaxEta)
275  continue;
276 
277  Float_t trackTheta = 2.*atan(exp(-fBuffer_TrackEta[i]));
278 
279  // Add basic particle to event
280  new ((*fOutputArray)[particleCount]) AliAODTrack();
281  static_cast<AliAODTrack*>(fOutputArray->At(particleCount))->SetPt(fBuffer_TrackPt[i]);
282  static_cast<AliAODTrack*>(fOutputArray->At(particleCount))->SetPhi(fBuffer_TrackPhi[i]);
283  static_cast<AliAODTrack*>(fOutputArray->At(particleCount))->SetTheta(trackTheta); // AliAODTrack cannot set eta directly
284  static_cast<AliAODTrack*>(fOutputArray->At(particleCount))->SetCharge(fBuffer_TrackCharge[i]);
285  static_cast<AliAODTrack*>(fOutputArray->At(particleCount))->SetLabel(i+fLabelOffset_ME);
286  static_cast<AliAODTrack*>(fOutputArray->At(particleCount))->SetIsHybridGlobalConstrainedGlobal();
287  particleCount++;
288  numParticles_MixedEvent++;
289  FillHistogram("hMixedEvent_TrackPt", fBuffer_TrackPt[i]);
290  FillHistogram("hMixedEvent_TrackPhiEta", fBuffer_TrackPhi[i], fBuffer_TrackEta[i]);
291  }
292 
294  }
295 
296  // ################# 4. Add tracks from toy
297  if(fAddTracksFromToy) // Simple toy
298  {
299  Int_t multiplicity = (Int_t)fDistributionMultiplicity->GetRandom();
300  for(Int_t i=0;i<multiplicity; i++)
301  {
302  // Discard tracks due to lowered tracking efficiency
303  if (fTrackEfficiency_Toy < 1.0)
304  if (fTrackEfficiency_Toy < fRandom->Rndm())
305  continue;
306 
307  Double_t trackPt = fDistributionPt->GetRandom();
308  Double_t trackEta = 0;
309  Double_t trackPhi = 0;
310  static_cast<TH2*>(fDistributionEtaPhi)->GetRandom2(trackPhi, trackEta);
311  Double_t trackTheta = 2.*atan(exp(-trackEta));
312  Double_t trackCharge = fRandom->Rndm() - 0.5;
313 
314  if (TMath::Abs(trackEta) > fMaxEta)
315  continue;
316  if(trackCharge>0) trackCharge = 1; else trackCharge = -1;
317 
318  // Add flow to particle
320  trackPhi = AddFlow(trackPhi, trackPt);
321 
322 
323  // Add basic particle to event
324  new ((*fOutputArray)[particleCount]) AliAODTrack();
325  static_cast<AliAODTrack*>(fOutputArray->At(particleCount))->SetPt(trackPt);
326  static_cast<AliAODTrack*>(fOutputArray->At(particleCount))->SetPhi(trackPhi);
327  static_cast<AliAODTrack*>(fOutputArray->At(particleCount))->SetTheta(trackTheta); // AliAODTrack cannot set eta directly
328  static_cast<AliAODTrack*>(fOutputArray->At(particleCount))->SetCharge(trackCharge);
329  static_cast<AliAODTrack*>(fOutputArray->At(particleCount))->SetLabel(i+fLabelOffset_Toy);
330  static_cast<AliAODTrack*>(fOutputArray->At(particleCount))->SetIsHybridGlobalConstrainedGlobal();
331  particleCount++;
332  numParticles_Toy++;
333  FillHistogram("hToy_TrackPt", trackPt);
334  FillHistogram("hToy_TrackPhiEta", trackPhi, trackEta);
335  }
336  }
337 
338  // ################# 5. Add further external tracks: Picotracks (from old embedding framework)
340  {
341  for(Int_t i=0; i<fPicoTracksArray->GetEntries(); i++)
342  {
343  // Discard tracks due to lowered tracking efficiency
344  if (fTrackEfficiency_PicoTracks < 1.0)
345  if (fTrackEfficiency_PicoTracks < fRandom->Rndm())
346  continue;
347  // Take only particles from the randomization acceptance
348  AliPicoTrack* inputParticle = static_cast<AliPicoTrack*>(fPicoTracksArray->At(i));
349  if (TMath::Abs(inputParticle->Eta()) > fMaxEta)
350  continue;
351 
352  // Add basic particle to event
353  new ((*fOutputArray)[particleCount]) AliAODTrack();
354  static_cast<AliAODTrack*>(fOutputArray->At(particleCount))->SetPt(inputParticle->Pt());
355  static_cast<AliAODTrack*>(fOutputArray->At(particleCount))->SetPhi(inputParticle->Phi());
356  static_cast<AliAODTrack*>(fOutputArray->At(particleCount))->SetTheta(2.*atan(exp(-inputParticle->Eta()))); // AliAODTrack cannot set eta directly
357  static_cast<AliAODTrack*>(fOutputArray->At(particleCount))->SetCharge(inputParticle->Charge());
358  static_cast<AliAODTrack*>(fOutputArray->At(particleCount))->SetLabel(i+fLabelOffset_PicoTracks);
359  static_cast<AliAODTrack*>(fOutputArray->At(particleCount))->SetIsHybridGlobalConstrainedGlobal();
360  particleCount++;
361  numParticles_PicoTracks++;
362  FillHistogram("hPicoTracks_TrackPt", inputParticle->Pt());
363  FillHistogram("hPicoTracks_TrackPhiEta", inputParticle->Phi(), inputParticle->Eta());
364  }
365  }
366 
367  FillHistogram("hInputTracks_Multiplicity", numParticles_InputTracks);
368  FillHistogram("hToy_Multiplicity", numParticles_Toy);
369  FillHistogram("hMixedEvent_Multiplicity", numParticles_MixedEvent);
370  FillHistogram("hPicoTracks_Multiplicity", numParticles_PicoTracks);
371 }
372 
373 //_____________________________________________________________________________________________________
375 {
376  Int_t hybridMult = 0;
377  for(Int_t iTrack=0; iTrack<fOutputArray->GetEntries(); iTrack++)
378  {
379  AliAODTrack* track = static_cast<AliAODTrack*>(fOutputArray->At(iTrack));
380  if(!track->IsHybridGlobalConstrainedGlobal())
381  continue;
382  hybridMult++;
383  FillHistogram("hCombined_TrackPt", track->Pt());
384  FillHistogram("hCombined_TrackPhiEta", track->Phi(), track->Eta());
385  }
386  FillHistogram("hCombined_Multiplicity", hybridMult);
387 }
388 
389 //_____________________________________________________________________________________________________
391 {
392  // ## Form file name
395  fileName = Form("%s%d.root", fMixedEvent_BaseFolder.Data(), fMixedEvent_CurrentFileID);
396 
397  AliInfo(Form("Opening mixed event file: %s", fileName.Data()));
398  // ## Check if file exists
399  if (fileName.BeginsWith("alien://") && !gGrid)
400  {
401  AliInfo("Trying to connect to AliEn ...");
402  TGrid::Connect("alien://");
403  }
404  if (gSystem->AccessPathName(fileName)) {
405  AliError(Form("File %s does not exist!", fileName.Data()));
406  return 0;
407  }
408 
409  // ## Open mixed event file and get tree object
411 
412  fMixedEvent_CurrentFile = TFile::Open(fileName);
414  {
415  AliError(Form("Unable to open file: %s!", fileName.Data()));
416  return 0;
417  }
418  TTree* tree = static_cast<TTree*>(fMixedEvent_CurrentFile->Get(fMixedEvent_TreeName.Data()));
419  if(tree)
420  {
421  tree->SetBranchAddress("NumTracks", &fBuffer_NumTracks);
422  tree->SetBranchAddress("Track_Pt", fBuffer_TrackPt);
423  tree->SetBranchAddress("Track_Phi", fBuffer_TrackPhi);
424  tree->SetBranchAddress("Track_Eta", fBuffer_TrackEta);
425  tree->SetBranchAddress("Track_Charge", fBuffer_TrackCharge);
426  }
427 
429 
430  return tree;
431 }
432 
433 //_____________________________________________________________________________________________________
435 {
436  // adapted from AliFlowTrackSimple
437  Double_t precisionPhi = 1e-10;
438  Int_t maxNumberOfIterations = 200;
439 
440  Double_t phi0=phi;
441  Double_t f=0.;
442  Double_t fp=0.;
443  Double_t phiprev=0.;
444  Int_t ptBin = 0;
445 
446  // Evaluate V2 for track pt/centrality
447  Double_t v2 = 0;
448  if(fDistributionV2)
449  {
450  ptBin = fDistributionV2->GetXaxis()->FindBin(pt);
451  if(ptBin>fDistributionV2->GetNbinsX())
452  v2 = fDistributionV2->GetBinContent(fDistributionV2->GetNbinsX(), fDistributionV2->GetYaxis()->FindBin(fToyCent));
453  else if(ptBin>0)
454  v2 = fDistributionV2->GetBinContent(ptBin, fDistributionV2->GetYaxis()->FindBin(fToyCent));
455  }
456 
457  // Evaluate V3 for track pt/centrality
458  Double_t v3 = 0;
459  if(fDistributionV3)
460  {
461  ptBin = fDistributionV3->GetXaxis()->FindBin(pt);
462  if(ptBin>fDistributionV3->GetNbinsX())
463  v3 = fDistributionV3->GetBinContent(fDistributionV3->GetNbinsX(), fDistributionV3->GetYaxis()->FindBin(fToyCent));
464  else if(ptBin>0)
465  v3 = fDistributionV3->GetBinContent(ptBin, fDistributionV3->GetYaxis()->FindBin(fToyCent));
466  }
467 
468  // Evaluate V4 for track pt/centrality
469  Double_t v4 = 0;
470  if(fDistributionV4)
471  {
472  ptBin = fDistributionV4->GetXaxis()->FindBin(pt);
473  if(ptBin>fDistributionV4->GetNbinsX())
474  v4 = fDistributionV4->GetBinContent(fDistributionV4->GetNbinsX(), fDistributionV4->GetYaxis()->FindBin(fToyCent));
475  else if(ptBin>0)
476  v4 = fDistributionV4->GetBinContent(ptBin, fDistributionV4->GetYaxis()->FindBin(fToyCent));
477  }
478 
479  // Evaluate V5 for track pt/centrality
480  Double_t v5 = 0;
481  if(fDistributionV5)
482  {
483  ptBin = fDistributionV5->GetXaxis()->FindBin(pt);
484  if(ptBin>fDistributionV5->GetNbinsX())
485  v5 = fDistributionV5->GetBinContent(fDistributionV5->GetNbinsX(), fDistributionV5->GetYaxis()->FindBin(fToyCent));
486  else if(ptBin>0)
487  v5 = fDistributionV5->GetBinContent(ptBin, fDistributionV5->GetYaxis()->FindBin(fToyCent));
488  }
489 
490  // Add all v's
491  for (Int_t i=0; i<maxNumberOfIterations; i++)
492  {
493  phiprev=phi; //store last value for comparison
494  f = phi-phi0
495  + v2*TMath::Sin(2.*(phi-(fEPV0+(TMath::Pi()/2.))))
496  +2./3.*v3*TMath::Sin(3.*(phi-fRandomPsi3))
497  +0.5 *v4*TMath::Sin(4.*(phi-fRandomPsi4))
498  +0.4 *v5*TMath::Sin(5.*(phi-fRandomPsi5));
499 
500  fp = 1.0+2.0*(
501  +v2*TMath::Cos(2.*(phi-(fEPV0+(TMath::Pi()/2.))))
502  +v3*TMath::Cos(3.*(phi-fRandomPsi3))
503  +v4*TMath::Cos(4.*(phi-fRandomPsi4))
504  +v5*TMath::Cos(5.*(phi-fRandomPsi5))); //first derivative
505 
506  phi -= f/fp;
507  if (TMath::AreEqualAbs(phiprev,phi,precisionPhi)) break;
508  }
509 
510  return phi;
511 }
512 
513 //________________________________________________________________________
515 {
516  fAddTracksFromToy = kTRUE;
517  TGrid::Connect("alien://");
518  TFile* fileInput = TFile::Open(configFileName);
519  if(!fileInput)
520  {
521  AliError("Toy distributions file not found!");
522  return;
523  }
524 
525  TH1* distPt = static_cast<TH1*>(fileInput->Get("Pt"));
526  TH1* distMult = static_cast<TH1*>(fileInput->Get("Multiplicity"));
527  TH1* distPhiEta = static_cast<TH1*>(fileInput->Get("PhiEta"));
528 
529  TH2* distV2 = static_cast<TH2*>(fileInput->Get("v2_EP_PbPb"));
530  TH2* distV3 = static_cast<TH2*>(fileInput->Get("v3_EP_PbPb"));
531  TH2* distV4 = static_cast<TH2*>(fileInput->Get("v4_EP_PbPb"));
532 
533  SetDistributionMultiplicity(distMult);
534  SetDistributionPt(distPt);
535  SetDistributionEtaPhi(distPhiEta);
536  SetDistributionV2(distV2);
537  SetDistributionV3(distV3);
538  SetDistributionV4(distV4);
539 }
540 
541 
542 //________________________________________________________________________
544 {
545  TH1* tmpHist = static_cast<TH1*>(fOutput->FindObject(key));
546  if(!tmpHist)
547  {
548  AliError(Form("Cannot find histogram <%s> ",key)) ;
549  return;
550  }
551 
552  tmpHist->Fill(x);
553 }
554 
555 //________________________________________________________________________
557 {
558  TH1* tmpHist = static_cast<TH1*>(fOutput->FindObject(key));
559  if(!tmpHist)
560  {
561  AliError(Form("Cannot find histogram <%s> ",key));
562  return;
563  }
564 
565  if (tmpHist->IsA()->GetBaseClass("TH1"))
566  static_cast<TH1*>(tmpHist)->Fill(x,y); // Fill x with y
567  else if (tmpHist->IsA()->GetBaseClass("TH2"))
568  static_cast<TH2*>(tmpHist)->Fill(x,y); // Fill x,y with 1
569 }
570 
571 //________________________________________________________________________
573 {
574  TH2* tmpHist = static_cast<TH2*>(fOutput->FindObject(key));
575  if(!tmpHist)
576  {
577  AliError(Form("Cannot find histogram <%s> ",key));
578  return;
579  }
580 
581  tmpHist->Fill(x,y,add);
582 }
583 
584 //________________________________________________________________________
585 template <class T> T* AliAnalysisTaskChargedJetsHadronToy::AddHistogram1D(const char* name, const char* title, const char* options, Int_t xBins, Double_t xMin, Double_t xMax, const char* xTitle, const char* yTitle)
586 {
587  T* tmpHist = new T(name, title, xBins, xMin, xMax);
588 
589  tmpHist->GetXaxis()->SetTitle(xTitle);
590  tmpHist->GetYaxis()->SetTitle(yTitle);
591  tmpHist->SetOption(options);
592  tmpHist->SetMarkerStyle(kFullCircle);
593  tmpHist->Sumw2();
594 
595  fOutput->Add(tmpHist);
596 
597  return tmpHist;
598 }
599 
600 //________________________________________________________________________
601 template <class T> T* AliAnalysisTaskChargedJetsHadronToy::AddHistogram2D(const char* name, const char* title, const char* options, Int_t xBins, Double_t xMin, Double_t xMax, Int_t yBins, Double_t yMin, Double_t yMax, const char* xTitle, const char* yTitle, const char* zTitle)
602 {
603  T* tmpHist = new T(name, title, xBins, xMin, xMax, yBins, yMin, yMax);
604  tmpHist->GetXaxis()->SetTitle(xTitle);
605  tmpHist->GetYaxis()->SetTitle(yTitle);
606  tmpHist->GetZaxis()->SetTitle(zTitle);
607  tmpHist->SetOption(options);
608  tmpHist->SetMarkerStyle(kFullCircle);
609  tmpHist->Sumw2();
610 
611  fOutput->Add(tmpHist);
612 
613  return tmpHist;
614 }
615 
616 
617 //________________________________________________________________________
619 {
620  // Called once at the end of the analysis.
621 }
TH2 * fDistributionV5
Distribution for v4 in bins of pt and centrality.
TH2 * fDistributionV3
Distribution for v2 in bins of pt and centrality.
double Double_t
Definition: External.C:58
Float_t * fBuffer_TrackPhi
buffer for track pt array
const char * title
Definition: MakeQAPdf.C:27
Short_t * fBuffer_TrackCharge
buffer for track eta array
TString fileName
TSystem * gSystem
Double_t fEPV0
!event plane V0
TString fPicoTracksArrayName
buffer for track charge array
TString fOutputArrayName
input array containing tracks from events
TString fEventTracksArrayName
input array containing pico tracks
T * AddHistogram1D(const char *name="CustomHistogram", const char *title="NO_TITLE", const char *options="", Int_t xBins=100, Double_t xMin=0.0, Double_t xMax=20.0, const char *xTitle="x axis", const char *yTitle="y axis")
UShort_t T(UShort_t m, UShort_t t)
Definition: RingBits.C:60
void AddTracksFromToy(const char *configFileName="alien:///alice/cern.ch/user/r/rhaake/Distributions_PbPb_1800.root")
Double_t Eta() const
Definition: AliPicoTrack.h:37
int Int_t
Definition: External.C:63
float Float_t
Definition: External.C:68
Double_t Phi() const
Definition: AliPicoTrack.h:33
TH2 * fDistributionV4
Distribution for v3 in bins of pt and centrality.
Double_t Pt() const
Definition: AliPicoTrack.h:23
short Short_t
Definition: External.C:23
AliEmcalList * fOutput
!output list
Definition: External.C:220
Base task in the EMCAL jet framework.
TFile * fMixedEvent_CurrentFile
ME: The tree of the mixed event.
T * AddHistogram2D(const char *name="CustomHistogram", const char *title="NO_TITLE", const char *options="", Int_t xBins=100, Double_t xMin=0.0, Double_t xMax=20.0, Int_t yBins=100, Double_t yMin=0.0, Double_t yMax=20.0, const char *xTitle="x axis", const char *yTitle="y axis", const char *zTitle="z axis")
const char Option_t
Definition: External.C:48
void UserCreateOutputObjects()
Main initialization function on the worker.
bool Bool_t
Definition: External.C:53
Double_t yMin
TTree * fMixedEvent_Tree
Distribution for v5 in bins of pt and centrality.
Definition: External.C:196
Double_t yMax
Short_t Charge() const
Definition: AliPicoTrack.h:39
void ExecOnce()
Perform steps needed to initialize the analysis.
Float_t * fBuffer_TrackEta
buffer for track phi array