]>
Commit | Line | Data |
---|---|---|
b87234fd | 1 | // $Id: AliAnalysisTaskEmcal.cxx $ |
2 | // | |
42642780 | 3 | // Emcal base analysis task. |
b87234fd | 4 | // |
42642780 | 5 | // Author: S.Aiola |
6 | ||
7 | #include "AliAnalysisTaskEmcal.h" | |
b87234fd | 8 | |
9 | #include <TObject.h> | |
10 | #include <TChain.h> | |
11 | #include <TClonesArray.h> | |
12 | #include <TList.h> | |
13 | ||
14 | #include "AliAnalysisManager.h" | |
15 | #include "AliCentrality.h" | |
16 | #include "AliVCluster.h" | |
17 | #include "AliVParticle.h" | |
18 | #include "AliEmcalJet.h" | |
19 | #include "AliVEventHandler.h" | |
20 | #include "AliLog.h" | |
21 | #include "AliEMCALGeometry.h" | |
22 | ||
b87234fd | 23 | ClassImp(AliAnalysisTaskEmcal) |
24 | ||
25 | //________________________________________________________________________ | |
26 | AliAnalysisTaskEmcal::AliAnalysisTaskEmcal() : | |
27 | AliAnalysisTaskSE("AliAnalysisTaskEmcal"), | |
28 | fAnaType(kTPC), | |
29 | fInitialized(kFALSE), | |
30 | fMinEta(-0.9), | |
31 | fMaxEta(0.9), | |
32 | fMinPhi(-10), | |
33 | fMaxPhi(10), | |
34 | fJetRadius(0.4), | |
35 | fTracksName("Tracks"), | |
36 | fCaloName("CaloClusters"), | |
37 | fJetsName("Jets"), | |
38 | fNbins(500), | |
39 | fMinPt(0), | |
40 | fMaxPt(250), | |
41 | fPtCut(0.15), | |
42 | fPtBiasJetTrack(10), | |
43 | fPtBiasJetClus(10), | |
44 | fJetPtCut(1), | |
45 | fJetAreaCut(0.2), | |
46 | fTracks(0), | |
47 | fCaloClusters(0), | |
48 | fJets(0), | |
49 | fCent(0), | |
50 | fCentBin(-1), | |
51 | fOutput(0) | |
52 | { | |
53 | // Default constructor. | |
54 | ||
55 | fVertex[0] = 0; | |
56 | fVertex[1] = 0; | |
57 | fVertex[2] = 0; | |
b87234fd | 58 | } |
59 | ||
60 | //________________________________________________________________________ | |
61 | AliAnalysisTaskEmcal::AliAnalysisTaskEmcal(const char *name) : | |
62 | AliAnalysisTaskSE(name), | |
63 | fAnaType(kTPC), | |
64 | fInitialized(kFALSE), | |
65 | fMinEta(-0.9), | |
66 | fMaxEta(0.9), | |
67 | fMinPhi(-10), | |
68 | fMaxPhi(10), | |
69 | fJetRadius(0.4), | |
70 | fTracksName("Tracks"), | |
71 | fCaloName("CaloClusters"), | |
72 | fJetsName("Jets"), | |
73 | fNbins(500), | |
74 | fMinPt(0), | |
75 | fMaxPt(250), | |
76 | fPtCut(0.15), | |
77 | fPtBiasJetTrack(10), | |
78 | fPtBiasJetClus(10), | |
79 | fJetPtCut(1), | |
80 | fJetAreaCut(0.2), | |
81 | fTracks(0), | |
82 | fCaloClusters(0), | |
83 | fJets(0), | |
84 | fCent(0), | |
85 | fCentBin(-1), | |
86 | fOutput(0) | |
87 | { | |
88 | // Standard constructor. | |
89 | ||
90 | fVertex[0] = 0; | |
91 | fVertex[1] = 0; | |
92 | fVertex[2] = 0; | |
93 | ||
94 | // Output slot #1 writes into a TH1 container | |
95 | DefineOutput(1, TList::Class()); | |
96 | } | |
97 | ||
98 | //________________________________________________________________________ | |
99 | AliAnalysisTaskEmcal::~AliAnalysisTaskEmcal() | |
100 | { | |
101 | // Destructor | |
102 | } | |
103 | ||
104 | //________________________________________________________________________ | |
105 | void AliAnalysisTaskEmcal::UserCreateOutputObjects() | |
106 | { | |
42642780 | 107 | // User create outputs. |
b87234fd | 108 | } |
109 | ||
110 | //________________________________________________________________________ | |
111 | void AliAnalysisTaskEmcal::RetrieveEventObjects() | |
112 | { | |
42642780 | 113 | // Retrieve objects from event. |
114 | ||
b87234fd | 115 | fVertex[0] = 0; |
116 | fVertex[1] = 0; | |
117 | fVertex[2] = 0; | |
118 | InputEvent()->GetPrimaryVertex()->GetXYZ(fVertex); | |
119 | ||
120 | AliCentrality *aliCent = InputEvent()->GetCentrality(); | |
121 | if (aliCent) { | |
122 | fCent = aliCent->GetCentralityPercentile("V0M"); | |
123 | if (fCent >= 0 && fCent < 10) fCentBin = 0; | |
124 | else if (fCent >= 10 && fCent < 30) fCentBin = 1; | |
125 | else if (fCent >= 30 && fCent < 50) fCentBin = 2; | |
126 | else if (fCent >= 50 && fCent <= 100) fCentBin = 3; | |
127 | else { | |
128 | AliWarning(Form("Negative centrality: %f. Assuming 99", fCent)); | |
129 | fCentBin = 3; | |
130 | } | |
131 | } | |
132 | else { | |
133 | AliWarning(Form("Could not retrieve centrality information! Assuming 99")); | |
134 | fCentBin = 3; | |
135 | } | |
136 | ||
42642780 | 137 | if ((!fCaloName.IsNull()) && (fAnaType == kEMCAL)) { |
b87234fd | 138 | fCaloClusters = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fCaloName)); |
139 | if (!fCaloClusters) { | |
140 | AliWarning(Form("Could not retrieve clusters %s!", fCaloName.Data())); | |
141 | } | |
142 | } | |
143 | ||
42642780 | 144 | if (!fTracksName.IsNull()) { |
b87234fd | 145 | fTracks = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fTracksName)); |
146 | if (!fTracks) { | |
147 | AliWarning(Form("Could not retrieve tracks %s!", fTracksName.Data())); | |
148 | } | |
149 | } | |
150 | ||
42642780 | 151 | if (!fJetsName.IsNull()) { |
b87234fd | 152 | fJets = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fJetsName)); |
153 | if (!fJets) { | |
154 | AliWarning(Form("Could not retrieve jets %s!", fJetsName.Data())); | |
155 | } | |
156 | } | |
157 | } | |
158 | ||
159 | //________________________________________________________________________ | |
160 | void AliAnalysisTaskEmcal::Init() | |
161 | { | |
42642780 | 162 | // Init the analysis. |
163 | ||
b87234fd | 164 | if (fAnaType == kTPC) { |
165 | SetEtaLimits(-0.9, 0.9); | |
166 | SetPhiLimits(-10, 10); | |
167 | } | |
168 | else if (fAnaType == kEMCAL) { | |
169 | AliEMCALGeometry *geom = AliEMCALGeometry::GetInstance(); | |
170 | if (!geom) { | |
171 | AliFatal("Can not create geometry"); | |
172 | return; | |
173 | } | |
174 | SetEtaLimits(geom->GetArm1EtaMin(), geom->GetArm1EtaMax()); | |
175 | SetPhiLimits(geom->GetArm1PhiMin() * TMath::DegToRad(), geom->GetArm1PhiMax() * TMath::DegToRad()); | |
176 | } | |
177 | else { | |
178 | AliWarning("Analysis type not recognized! Assuming kTPC..."); | |
179 | SetAnaType(kTPC); | |
180 | Init(); | |
181 | } | |
182 | ||
183 | SetInitialized(); | |
184 | } | |
185 | ||
186 | //________________________________________________________________________ | |
187 | Bool_t AliAnalysisTaskEmcal::IsJetTrack(AliEmcalJet* jet, Int_t itrack, Bool_t sorted) const | |
188 | { | |
42642780 | 189 | // Return true if track is in jet. |
190 | ||
b87234fd | 191 | for (Int_t i = 0; i < jet->GetNumberOfTracks(); i++) { |
192 | Int_t ijettrack = jet->TrackAt(i); | |
193 | if (sorted && ijettrack > itrack) | |
194 | return kFALSE; | |
195 | if (ijettrack == itrack) | |
196 | return kTRUE; | |
197 | } | |
198 | return kFALSE; | |
199 | } | |
200 | ||
201 | //________________________________________________________________________ | |
202 | Bool_t AliAnalysisTaskEmcal::IsJetCluster(AliEmcalJet* jet, Int_t iclus, Bool_t sorted) const | |
203 | { | |
42642780 | 204 | // Return true if cluster is in jet. |
205 | ||
b87234fd | 206 | for (Int_t i = 0; i < jet->GetNumberOfClusters(); i++) { |
207 | Int_t ijetclus = jet->ClusterAt(i); | |
208 | if (sorted && ijetclus > iclus) | |
209 | return kFALSE; | |
210 | if (ijetclus == iclus) | |
211 | return kTRUE; | |
212 | } | |
213 | return kFALSE; | |
214 | } | |
215 | ||
216 | //________________________________________________________________________ | |
217 | Bool_t AliAnalysisTaskEmcal::AcceptJet(AliEmcalJet *jet) const | |
218 | { | |
42642780 | 219 | // Return true if jet is accepted. |
220 | ||
b87234fd | 221 | if (jet->Pt() <= fJetPtCut) |
222 | return kFALSE; | |
223 | if (jet->Area() <= fJetAreaCut) | |
224 | return kFALSE; | |
225 | if (fAnaType == kEMCAL && !jet->IsInsideEmcal()) | |
226 | return kFALSE; | |
227 | ||
228 | return (Bool_t)(jet->Eta() > fMinEta && jet->Eta() < fMaxEta && jet->Phi() > fMinPhi && jet->Phi() < fMaxPhi); | |
229 | } | |
230 | ||
231 | //________________________________________________________________________ | |
232 | Bool_t AliAnalysisTaskEmcal::AcceptCluster(AliVCluster* clus, Bool_t acceptMC) const | |
233 | { | |
42642780 | 234 | // Return true if cluster is accepted. |
235 | ||
b87234fd | 236 | if (!acceptMC && clus->Chi2() == 100) |
237 | return kFALSE; | |
238 | ||
239 | TLorentzVector nPart; | |
240 | clus->GetMomentum(nPart, const_cast<Double_t*>(fVertex)); | |
241 | ||
242 | if (nPart.Et() < fPtCut) | |
243 | return kFALSE; | |
244 | ||
245 | return kTRUE; | |
246 | } | |
247 | ||
248 | //________________________________________________________________________ | |
249 | Bool_t AliAnalysisTaskEmcal::AcceptTrack(AliVParticle* track, Bool_t acceptMC) const | |
250 | { | |
42642780 | 251 | // Return true if track is accepted. |
252 | ||
b87234fd | 253 | if (!acceptMC && track->GetLabel() == 100) |
254 | return kFALSE; | |
255 | ||
256 | if (track->Pt() < fPtCut) | |
257 | return kFALSE; | |
258 | ||
259 | return (Bool_t)(track->Eta() > fMinEta && track->Eta() < fMaxEta && track->Phi() > fMinPhi && track->Phi() < fMaxPhi); | |
260 | } | |
261 | ||
262 | //________________________________________________________________________ | |
263 | void AliAnalysisTaskEmcal::UserExec(Option_t *) | |
264 | { | |
265 | // Main loop, called for each event. | |
266 | ||
267 | if (!fInitialized) | |
268 | Init(); | |
269 | ||
270 | RetrieveEventObjects(); | |
271 | ||
272 | FillHistograms(); | |
273 | ||
274 | // information for this iteration of the UserExec in the container | |
275 | PostData(1, fOutput); | |
276 | } | |
277 | ||
278 | //________________________________________________________________________ | |
279 | void AliAnalysisTaskEmcal::Terminate(Option_t *) | |
280 | { | |
281 | // Called once at the end of the analysis. | |
282 | } |