AliPhysics  96f6795 (96f6795)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliAnalysisTaskEmcalJetSparseMaker.cxx
Go to the documentation of this file.
1 #include <TH2D.h>
2 #include <TVector2.h>
3 #include <THnSparse.h>
4 #include <TLorentzVector.h>
5 
6 #include "AliLog.h"
7 #include "AliVTrack.h"
8 #include "AliVCluster.h"
9 #include "AliAODCaloCluster.h"
10 #include "AliESDCaloCluster.h"
11 #include "AliVParticle.h"
12 #include "AliPicoTrack.h"
13 #include "AliEmcalJet.h"
14 #include "AliRhoParameter.h"
15 #include "AliJetContainer.h"
16 #include "AliParticleContainer.h"
17 #include "AliClusterContainer.h"
18 
19 #include "AliVEventHandler.h"
20 #include "AliAnalysisManager.h"
21 
23 
25 
26 //_____________________________________________________________________________
29 fMtCh(0.),
30 fMtEm(0.),
31 fRhoV(0.),
32 fAPhi(0.),
33 fNameJet(""),
34 fContJets(0),
35 fContTrks(0),
36 fContClus(0),
37 fHnsEveH(0),
38 fHnsJets(0),
39 fListOutputEvH(0),
40 fListOutputJet(0)
41 {
42 //
43 // AliAnalysisTaskEmcalJetSparseMaker::AliAnalysisTaskEmcalJetSparseMaker
44 //
45 }
46 
47 //_____________________________________________________________________________
49 AliAnalysisTaskEmcalJet(name, bHistos),
50 fMtCh(0.),
51 fMtEm(0.),
52 fRhoV(0.),
53 fAPhi(0.),
54 fNameJet("cJets"),
55 fContJets(0),
56 fContTrks(0),
57 fContClus(0),
58 fHnsEveH(0),
59 fHnsJets(0),
60 fListOutputEvH(0),
61 fListOutputJet(0)
62 {
63 //
64 // AliAnalysisTaskEmcalJetSparseMaker::AliAnalysisTaskEmcalJetSparseMaker
65 //
66 
67  SetMakeGeneralHistograms(bHistos);
68 
69  DefineOutput(2, TList::Class());
70  DefineOutput(3, TList::Class());
71 }
72 
73 //_____________________________________________________________________________
75 {
76 //
77 // AliAnalysisTaskEmcalJetSparseMaker::~AliAnalysisTaskEmcalJetSparseMaker
78 //
79 
80  if (fContJets) { delete fContJets; fContJets = 0; }
81  if (fContTrks) { delete fContTrks; fContTrks = 0; }
82  if (fContClus) { delete fContClus; fContClus = 0; }
83 
84  if (fHnsEveH) { delete fHnsEveH; fHnsEveH = 0; }
85  if (fHnsJets) { delete fHnsJets; fHnsJets = 0; }
86 
87  if (fListOutputEvH) { delete fListOutputEvH; fListOutputEvH = 0; }
88  if (fListOutputJet) { delete fListOutputJet; fListOutputJet = 0; }
89 }
90 
91 //_____________________________________________________________________________
93 {
94 //
95 // AliAnalysisTaskEmcalJetSparseMaker::Init
96 //
97 
98  return;
99 }
100 
101 //_____________________________________________________________________________
103 {
104 //
105 // AliAnalysisTaskEmcalJetSparseMaker::UserCreateOutputObjects
106 //
107 
109 //=============================================================================
110 
112 
113  fContTrks = GetParticleContainer(0); if (fContTrks) fContTrks->SetClassName("AliVTrack");
114  fContClus = GetClusterContainer(0); if (fContClus) fContClus->SetClassName("AliVCluster");
115 //=============================================================================
116 
117  if (fListOutputEvH) { delete fListOutputEvH; fListOutputEvH = 0; } fListOutputEvH = new TList();
118  if (fListOutputJet) { delete fListOutputJet; fListOutputJet = 0; } fListOutputJet = new TList();
119 
120  Bool_t bStatusTmpH = TH1::AddDirectoryStatus();
121  TH1::AddDirectory(kFALSE);
122 
123  MakeSparse();
124 
125  TH1::AddDirectory(bStatusTmpH);
126 //=============================================================================
127 
128  PostData(2, fListOutputEvH);
129  PostData(3, fListOutputJet);
130 //=============================================================================
131 
132  return;
133 }
134 
135 //_____________________________________________________________________________
137 {
138 //
139 // AliAnalysisTaskEmcalJetSparseMaker::Terminate
140 //
141 
142  AliAnalysisTaskEmcalJet::Terminate(opt);
143 
144  return;
145 }
146 
147 //_____________________________________________________________________________
149 {
150 //
151 // AliAnalysisTaskEmcalJetSparseMaker::Run
152 //
153 
154  FillSparse();
155 //=============================================================================
156 
157  return kTRUE;
158 }
159 
160 //_____________________________________________________________________________
162 {
163 //
164 // AliAnalysisTaskEmcalJetSparseMaker::FillHistograms
165 //
166 
167  if (!AliAnalysisTaskEmcalJet::FillHistograms()) return kFALSE;
168 //=============================================================================
169 
170  return kTRUE;
171 }
172 
173 //_____________________________________________________________________________
175 {
176 //
177 // AliAnalysisTaskEmcalJetSparseMaker::FillGeneralHistograms
178 //
179 
181 
182  return kTRUE;
183 }
184 
185 //_____________________________________________________________________________
187 {
188 //
189 // AliAnalysisTaskEmcalJetSparseMaker::ExecOnce
190 //
191 
193  if (!fLocalInitialized) return;
194 //=============================================================================
195 
196  if (fContJets) if (fContJets->GetArray()==0) fContJets = 0x0;
197 
198  if (fContTrks) if (fContTrks->GetArray()==0) fContTrks = 0x0;
199  if (fContClus) if (fContClus->GetArray()==0) fContClus = 0x0;
200 
201  return;
202 }
203 
204 //_____________________________________________________________________________
206 {
207 //
208 // AliAnalysisTaskEmcalJetSparseMaker::RetrieveEventObjects
209 //
210 
211  if (!AliAnalysisTaskEmcalJet::RetrieveEventObjects()) return kFALSE;
212 //=============================================================================
213 
214  if (fContTrks) fAPhi = CalcAysPlane();
218 
219  return kTRUE;
220 }
221 
222 //_____________________________________________________________________________
224 {
225 //
226 // AliAnalysisTaskEmcalJetSparseMaker::IsEventSelected
227 //
228 
229  if (!AliAnalysisTaskEmcalJet::IsEventSelected()) return kFALSE;
230 
231  return kTRUE;
232 }
233 
234 //_____________________________________________________________________________
236 {
237 //
238 // AliAnalysisTaskEmcalJetSparseMaker::FillSparseJets
239 //
240 
241  if ((!fContJets) || (!fHnsEveH) || (!fHnsJets)) return;
242 //=============================================================================
243 
244  Bool_t bFillEH = kFALSE;
245  const Double_t dR = fContJets->GetJetRadius();
246  const Double_t dAreaRef = dR * dR * TMath::Pi();
247 
248  AliEmcalJet *pJet = 0;
249  fContJets->ResetCurrentID();
250  while ((pJet=fContJets->GetNextAcceptJet())) {
251  Double_t dJet[] = { fCent, fVertex[2], fEPV0, fAPhi,
252  CalcRelPhiEP(pJet->Phi()),
254  pJet->Pt(), fContJets->GetJetPtCorr(fContJets->GetCurrentID()),
255  pJet->Eta(), pJet->Phi(), pJet->Area()/dAreaRef };
256 
257  fHnsJets->Fill(dJet);
258  if (!bFillEH) bFillEH = kTRUE;
259  }
260 //=============================================================================
261 
262  if (bFillEH) {
263  Double_t dEve[] = { fCent, fMtCh, fMtEm, fVertex[2], fEPV0, fAPhi, fRhoV };
264  fHnsEveH->Fill(dEve);
265  }
266 //=============================================================================
267 
268  return;
269 }
270 
271 //_____________________________________________________________________________
273 {
274 //
275 // AliAnalysisTaskEmcalJetSparseMaker::MakeSparseJets
276 //
277 
278  if (!fListOutputEvH) return;
279  if (!fListOutputJet) return;
280 //=============================================================================
281 
282  const Int_t nEveV = 7;
283  const Double_t dPhiNeg = -1.*TMath::Pi();
284  const Double_t dPhiPos = 1.*TMath::Pi() + TMath::Pi()/50.;
285  const Double_t dPhiMax = TMath::TwoPi() + TMath::Pi()/50.;
286  const Double_t dPhiMin = TMath::PiOver2() + TMath::Pi()/50.;
287  const TString sEveBin[] = { "aCent", "aMtCh", "aMtEm", "aVz", "aEPhi", "aAPhi", "aRho" };
288  const Int_t nEveBin[] = { 100, 600, 600, 20, 101, 101, 500 };
289  const Double_t dEveMin[] = { 0., 0., 0., -10., dPhiNeg, 0., 0. };
290  const Double_t dEveMax[] = { 100., 3000., 3000., 10., dPhiPos, dPhiMax, 500. };
291 
292  if (fHnsEveH) { delete fHnsEveH; fHnsEveH = 0; }
293  fHnsEveH = new THnSparseD("hsEveH", "", nEveV, nEveBin, dEveMin, dEveMax);
294  for (Int_t i=0; i<nEveV; i++) fHnsEveH->GetAxis(i)->SetName(sEveBin[i]);
295  fListOutputEvH->Add(fHnsEveH);
296 //=============================================================================
297 
298  const Int_t nJetV = 11;
299  const TString sJetBin[] = { "aCent", "aVz", "aEPhi", "aAPhi", "aRPhi", "aLeading", "aPtb", "aPta", "aEta", "aPhi", "aArea" };
300  const Int_t nJetBin[] = { 100, 20, 101, 101, 26, 500, 500, 1000, 200, 101, 100 };
301  const Double_t dJetMin[] = { 0., -10., dPhiNeg, 0., 0., 0., 0., -500., -1., 0., 0. };
302  const Double_t dJetMax[] = { 100., 10., dPhiPos, dPhiMax, dPhiMin, 250., 500., 500., 1., dPhiMax, 5. };
303 
304  if (fHnsJets) { delete fHnsJets; fHnsJets = 0; }
305  fHnsJets = new THnSparseD("hsJets", "", nJetV, nJetBin, dJetMin, dJetMax);
306  for (Int_t i=0; i<nJetV; i++) fHnsJets->GetAxis(i)->SetName(sJetBin[i]);
307  fListOutputJet->Add(fHnsJets);
308 //=============================================================================
309 
310  return;
311 }
312 
313 //_____________________________________________________________________________
315 {
316 //
317 // AliAnalysisTaskEmcalJetSparseMaker::CalcRelPhiEP
318 //
319 
320  Double_t dPhiSA = TVector2::Phi_mpi_pi(dPhi);
321  Double_t dPhiEP = TVector2::Phi_mpi_pi(dPhiSA - fEPV0);
322 
323  dPhiEP = TMath::Abs(dPhiEP);
324  if (dPhiEP>TMath::PiOver2()) dPhiEP = TMath::Pi() - dPhiEP;
325 
326  return dPhiEP;
327 }
328 
329 //_____________________________________________________________________________
331 {
332 //
333 // AliAnalysisTaskEmcalJetSparseMaker::CalcAysPlane
334 //
335 
336  if (!fContTrks) return -9999.;
337 //=============================================================================
338 
339  AliVParticle *pTrk = 0;
340  Double_t dQx = 0, dQy = 0.;
341  fContTrks->ResetCurrentID();
342  while ((pTrk=fContTrks->GetNextAcceptParticle())) {
343  dQx += TMath::Cos(pTrk->Phi());
344  dQy += TMath::Sin(pTrk->Phi());
345  } TVector2 vQ(dQx,dQy);
346 
347  return (vQ.Phi());
348 }
Double_t Area() const
Definition: AliEmcalJet.h:123
virtual AliVParticle * GetNextAcceptParticle()
Double_t GetRhoVal() const
double Double_t
Definition: External.C:58
AliJetContainer * GetJetContainer(Int_t i=0) const
Double_t Eta() const
Definition: AliEmcalJet.h:114
Bool_t fLocalInitialized
whether or not the task has been already initialized
Double_t Phi() const
Definition: AliEmcalJet.h:110
Double_t fEPV0
!event plane V0
virtual Bool_t IsEventSelected()
Performing event selection.
virtual Bool_t FillGeneralHistograms()
Filling general histograms.
AliParticleContainer * GetParticleContainer(Int_t i=0) const
Get particle container attached to this task.
virtual Bool_t FillHistograms()
Function filling histograms.
int Int_t
Definition: External.C:63
Double_t GetLeadingHadronPt(const AliEmcalJet *jet) const
AliClusterContainer * GetClusterContainer(Int_t i=0) const
Get cluster container attached to this task.
virtual Bool_t FillGeneralHistograms()
Filling general histograms.
Int_t GetNAcceptedClusters() const
Double_t fCent
!event centrality
virtual Bool_t Run()
Run function. This is the core function of the analysis and contains the user code. Therefore users have to implement this function.
virtual Bool_t RetrieveEventObjects()
Retrieve common objects from event.
AliEmcalJet * GetNextAcceptJet()
Double_t Pt() const
Definition: AliEmcalJet.h:102
ClassImp(AliAnalysisTaskEmcalJetSparseMaker) AliAnalysisTaskEmcalJetSparseMaker
virtual Bool_t IsEventSelected()
Performing event selection.
Float_t GetJetRadius() const
Double_t fVertex[3]
!event vertex
void SetMakeGeneralHistograms(Bool_t g)
virtual void ExecOnce()
Perform steps needed to initialize the analysis.
Base task in the EMCAL jet framework.
Represent a jet reconstructed using the EMCal jet framework.
Definition: AliEmcalJet.h:44
const char Option_t
Definition: External.C:48
void UserCreateOutputObjects()
Main initialization function on the worker.
bool Bool_t
Definition: External.C:53
Int_t GetNAcceptedParticles() const
virtual Bool_t FillHistograms()
Function filling histograms.
Double_t GetJetPtCorr(Int_t i) const