]>
Commit | Line | Data |
---|---|---|
fdceab34 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
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 | ||
16 | //----------------------------------------------------------------------- | |
17 | // Example of task (running locally, on AliEn and CAF), | |
18 | // which provides standard way of calculating acceptance and efficiency | |
19 | // between different steps of the procedure. | |
20 | // The ouptut of the task is a AliCFContainer from which the efficiencies | |
21 | // can be calculated | |
22 | //----------------------------------------------------------------------- | |
23 | // Author : Marta Verweij - UU | |
24 | //----------------------------------------------------------------------- | |
25 | ||
26 | ||
67ebd013 | 27 | #ifndef ALIPWG4HIGHPTSPECTRA_CXX |
28 | #define ALIPWG4HIGHPTSPECTRA_CXX | |
fdceab34 | 29 | |
30 | #include "AliPWG4HighPtSpectra.h" | |
31 | ||
67ebd013 | 32 | #include "TVector3.h" |
33 | #include <iostream> | |
34 | #include "TH1.h" | |
35 | #include "TH2.h" | |
36 | #include "TH3.h" | |
37 | #include "TList.h" | |
38 | #include "TChain.h" | |
67ebd013 | 39 | |
40 | #include "AliAnalysisManager.h" | |
41 | #include "AliESDInputHandler.h" | |
42 | #include "AliESDtrack.h" | |
43 | #include "AliESDtrackCuts.h" | |
44 | #include "AliExternalTrackParam.h" | |
65e8ecdd | 45 | |
67ebd013 | 46 | #include "AliLog.h" |
47 | ||
fdceab34 | 48 | #include "AliStack.h" |
49 | #include "TParticle.h" | |
fdceab34 | 50 | #include "AliMCEvent.h" |
51 | #include "AliMCEventHandler.h" | |
fdceab34 | 52 | #include "AliCFContainer.h" |
fdceab34 | 53 | |
67ebd013 | 54 | //#include "$ALICE_ROOT/PWG4/JetTasks/AliAnalysisHelperJetTasks.h" |
55 | ||
56 | //#include <iostream> | |
fdceab34 | 57 | using namespace std; //required for resolving the 'cout' symbol |
58 | ||
59 | ClassImp(AliPWG4HighPtSpectra) | |
60 | ||
61 | //__________________________________________________________________________ | |
62 | AliPWG4HighPtSpectra::AliPWG4HighPtSpectra() : AliAnalysisTask("AliPWG4HighPtSpectra", ""), | |
63 | fReadAODData(0), | |
67ebd013 | 64 | fCFManagerPos(0x0), |
65 | fCFManagerNeg(0x0), | |
fdceab34 | 66 | fESD(0), |
67 | fTrackCuts(0), | |
b5cc0c6d | 68 | fTrigger(0), |
fdceab34 | 69 | fHistList(0), |
b5cc0c6d | 70 | fNEventAll(0), |
71 | fNEventSel(0) | |
fdceab34 | 72 | { |
73 | // | |
74 | //Default ctor | |
75 | // | |
76 | } | |
77 | //___________________________________________________________________________ | |
78 | AliPWG4HighPtSpectra::AliPWG4HighPtSpectra(const Char_t* name) : | |
79 | AliAnalysisTask(name,""), | |
80 | fReadAODData(0), | |
67ebd013 | 81 | fCFManagerPos(0x0), |
82 | fCFManagerNeg(0x0), | |
fdceab34 | 83 | fESD(0), |
67ebd013 | 84 | fTrackCuts(), |
b5cc0c6d | 85 | fTrigger(0), |
fdceab34 | 86 | fHistList(0), |
b5cc0c6d | 87 | fNEventAll(0), |
88 | fNEventSel(0) | |
fdceab34 | 89 | { |
90 | // | |
91 | // Constructor. Initialization of Inputs and Outputs | |
92 | // | |
67ebd013 | 93 | AliDebug(2,Form("AliPWG4HighPtSpectra","Calling Constructor")); |
fdceab34 | 94 | // Input slot #0 works with a TChain ESD |
95 | DefineInput(0, TChain::Class()); | |
96 | DefineOutput(0,TList::Class()); | |
97 | DefineOutput(1,AliCFContainer::Class()); | |
67ebd013 | 98 | DefineOutput(2,AliCFContainer::Class()); |
fdceab34 | 99 | } |
100 | ||
67ebd013 | 101 | // //___________________________________________________________________________ |
102 | // AliPWG4HighPtSpectra& AliPWG4HighPtSpectra::operator=(const AliPWG4HighPtSpectra& c) | |
103 | // { | |
104 | // // | |
105 | // // Assignment operator | |
106 | // // | |
107 | // if (this!=&c) { | |
108 | // AliAnalysisTask::operator=(c) ; | |
109 | // fReadAODData = c.fReadAODData ; | |
110 | // fCFManagerPos = c.fCFManagerPos; | |
111 | // fCFManagerNeg = c.fCFManagerNeg; | |
112 | // fHistList = c.fHistList; | |
113 | // fNEventAll = c.fNEventAll; | |
114 | // fNEventSel = c.fNEventSel; | |
115 | // } | |
116 | // return *this; | |
117 | // } | |
118 | ||
119 | // //___________________________________________________________________________ | |
120 | // AliPWG4HighPtSpectra::AliPWG4HighPtSpectra(const AliPWG4HighPtSpectra& c) : | |
121 | // AliAnalysisTask(c), | |
122 | // fReadAODData(c.fReadAODData), | |
123 | // fCFManagerPos(c.fCFManagerPos), | |
124 | // fCFManagerNeg(c.fCFManagerNeg), | |
125 | // fESD(c.fESD), | |
126 | // fTrackCuts(c.fTrackCuts), | |
127 | // fTrigger(c.fTrigger), | |
128 | // fHistList(c.fHistList), | |
129 | // fNEventAll(c.fNEventAll), | |
130 | // fNEventSel(c.fNEventSel) | |
131 | // { | |
132 | // // | |
133 | // // Copy Constructor | |
134 | // // | |
135 | // } | |
136 | ||
137 | // //___________________________________________________________________________ | |
138 | // AliPWG4HighPtSpectra::~AliPWG4HighPtSpectra() { | |
139 | // // | |
140 | // //destructor | |
141 | // // | |
142 | // Info("~AliPWG4HighPtSpectra","Calling Destructor"); | |
143 | // if (fCFManagerPos) delete fCFManagerPos ; | |
144 | // if (fCFManagerNeg) delete fCFManagerNeg ; | |
145 | // if (fNEventAll) delete fNEventAll ; | |
146 | // if (fNEventSel) delete fNEventSel ; | |
147 | // } | |
fdceab34 | 148 | //________________________________________________________________________ |
149 | void AliPWG4HighPtSpectra::ConnectInputData(Option_t *) | |
150 | { | |
151 | // Connect ESD here | |
152 | // Called once | |
df943115 | 153 | AliDebug(2,Form(">> AliPWG4HighPtSpectra::ConnectInputData \n")); |
67ebd013 | 154 | // cout << "cout >> AliPWG4HighPtSpectra::ConnectInputData" << endl; |
155 | printf(">> AliPWG4HighPtSpectra::ConnectInputData \n"); | |
fdceab34 | 156 | |
157 | TTree* tree = dynamic_cast<TTree*> (GetInputData(0)); | |
158 | if (!tree) { | |
df943115 | 159 | AliDebug(2,Form("ERROR: Could not read chain from input slot 0")); |
fdceab34 | 160 | } else { |
161 | ||
162 | AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()); | |
163 | ||
164 | if (!esdH) { | |
df943115 | 165 | AliDebug(2,Form("ERROR: Could not get ESDInputHandler")); |
67ebd013 | 166 | } else { |
fdceab34 | 167 | fESD = esdH->GetEvent(); |
67ebd013 | 168 | } |
fdceab34 | 169 | } |
67ebd013 | 170 | |
fdceab34 | 171 | } |
172 | //_________________________________________________ | |
67ebd013 | 173 | void AliPWG4HighPtSpectra::Exec(Option_t *) |
fdceab34 | 174 | { |
175 | // | |
176 | // Main loop function | |
177 | // | |
df943115 | 178 | AliDebug(2,Form(">> AliPWG4HighPtSpectra::Exec \n")); |
fdceab34 | 179 | |
b5cc0c6d | 180 | // All events without selection |
181 | fNEventAll->Fill(0.); | |
182 | ||
fdceab34 | 183 | if (!fESD) { |
df943115 | 184 | AliDebug(2,Form("ERROR: fESD not available")); |
67ebd013 | 185 | PostData(0,fHistList); |
186 | PostData(1,fCFManagerPos->GetParticleContainer()); | |
187 | PostData(2,fCFManagerNeg->GetParticleContainer()); | |
fdceab34 | 188 | return; |
189 | } | |
190 | ||
67ebd013 | 191 | Bool_t isSelected = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected(); |
192 | if(!isSelected) { //Select collison candidates | |
b5cc0c6d | 193 | AliDebug(2,Form(" Trigger Selection: event REJECTED ... ")); |
cd9a6fa2 | 194 | PostData(0,fHistList); |
67ebd013 | 195 | PostData(1,fCFManagerPos->GetParticleContainer()); |
196 | PostData(2,fCFManagerNeg->GetParticleContainer()); | |
b5cc0c6d | 197 | return; |
67ebd013 | 198 | } |
b5cc0c6d | 199 | |
fdceab34 | 200 | // Process MC truth, therefore we receive the AliAnalysisManager and ask it for the AliMCEventHandler |
201 | // This handler can return the current MC event | |
67ebd013 | 202 | |
203 | AliMCEventHandler *eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()); | |
204 | // AliMCEventHandler* eventHandler = (AliMCEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()); | |
205 | ||
0cc50ca6 | 206 | AliStack* stack = 0x0; |
207 | AliMCEvent* mcEvent = 0x0; | |
67ebd013 | 208 | |
0cc50ca6 | 209 | if(eventHandler) { |
210 | mcEvent = eventHandler->MCEvent(); | |
211 | if (!mcEvent) { | |
212 | AliDebug(2,Form("ERROR: Could not retrieve MC event")); | |
67ebd013 | 213 | PostData(0,fHistList); |
214 | PostData(1,fCFManagerPos->GetParticleContainer()); | |
215 | PostData(2,fCFManagerNeg->GetParticleContainer()); | |
216 | return; | |
0cc50ca6 | 217 | } |
218 | ||
219 | AliDebug(2,Form("MC particles: %d", mcEvent->GetNumberOfTracks())); | |
220 | ||
221 | stack = mcEvent->Stack(); //Particles Stack | |
222 | ||
223 | AliDebug(2,Form("MC particles stack: %d", stack->GetNtrack())); | |
fdceab34 | 224 | } |
0cc50ca6 | 225 | |
fdceab34 | 226 | const AliESDVertex *vtx = fESD->GetPrimaryVertex(); |
67ebd013 | 227 | AliDebug(2,Form("Vertex title %s, status %d, nCont %d\n",vtx->GetTitle(), vtx->GetStatus(), vtx->GetNContributors())); |
fdceab34 | 228 | // Need vertex cut |
67ebd013 | 229 | if (vtx->GetNContributors() < 2) { |
cd9a6fa2 | 230 | PostData(0,fHistList); |
67ebd013 | 231 | PostData(1,fCFManagerPos->GetParticleContainer()); |
232 | PostData(2,fCFManagerNeg->GetParticleContainer()); | |
cd9a6fa2 | 233 | return; |
234 | } | |
67ebd013 | 235 | |
b5cc0c6d | 236 | double primVtx[3]; |
237 | vtx->GetXYZ(primVtx); | |
67ebd013 | 238 | if(TMath::Sqrt(primVtx[0]*primVtx[0] + primVtx[1]*primVtx[1])>1. || TMath::Abs(primVtx[2]>10.)){ |
cd9a6fa2 | 239 | PostData(0,fHistList); |
67ebd013 | 240 | PostData(1,fCFManagerPos->GetParticleContainer()); |
241 | PostData(2,fCFManagerNeg->GetParticleContainer()); | |
242 | return; | |
243 | } | |
244 | ||
245 | if(!fESD->GetNumberOfTracks() || fESD->GetNumberOfTracks()<2){ | |
246 | // Post output data | |
247 | PostData(0,fHistList); | |
248 | PostData(1,fCFManagerPos->GetParticleContainer()); | |
249 | PostData(2,fCFManagerNeg->GetParticleContainer()); | |
cd9a6fa2 | 250 | return; |
251 | } | |
fdceab34 | 252 | Int_t nTracks = fESD->GetNumberOfTracks(); |
253 | AliDebug(2,Form("nTracks %d", nTracks)); | |
fdceab34 | 254 | |
67ebd013 | 255 | if(!fTrackCuts) { |
256 | // Post output data | |
257 | PostData(0,fHistList); | |
258 | PostData(1,fCFManagerPos->GetParticleContainer()); | |
259 | PostData(2,fCFManagerNeg->GetParticleContainer()); | |
260 | return; | |
261 | } | |
262 | ||
b5cc0c6d | 263 | // Selected events for analysis |
264 | fNEventSel->Fill(0.); | |
67ebd013 | 265 | |
266 | ||
267 | Double_t containerInputRec[5] ; | |
268 | Double_t containerInputTPConly[5]; | |
269 | Double_t containerInputMC[5]; | |
fdceab34 | 270 | //Now go to rec level |
271 | for (Int_t iTrack = 0; iTrack<nTracks; iTrack++) | |
272 | { | |
273 | if(!fESD->GetTrack(iTrack) ) continue; | |
274 | AliESDtrack* track = fESD->GetTrack(iTrack); | |
275 | if(!(AliExternalTrackParam *)track->GetTPCInnerParam()) continue; | |
276 | AliExternalTrackParam *trackTPC = (AliExternalTrackParam *)track->GetTPCInnerParam(); | |
277 | if(!track || !trackTPC) continue; | |
278 | ||
67ebd013 | 279 | Float_t dca2D, dcaZ; |
280 | track->GetImpactParameters(dca2D,dcaZ); | |
281 | Float_t dca2DTPC, dcaZTPC; | |
282 | track->GetImpactParametersTPC(dca2DTPC,dcaZTPC); | |
283 | Float_t chi2PerClusterTPC = -1.; | |
284 | Float_t nClustersTPC = track->GetTPCNcls();//track->GetTPCclusters(0); | |
38ecb6a5 | 285 | if(nClustersTPC>0.) chi2PerClusterTPC = track->GetTPCchi2()/(2.*nClustersTPC-5.); |
286 | Float_t chi2PerClusterTPCIter1 = -1.; | |
287 | Float_t nClustersTPCIter1 = track->GetTPCNclsIter1(); | |
288 | if(nClustersTPCIter1>0.) chi2PerClusterTPCIter1 = track->GetTPCchi2Iter1()/(2.*nClustersTPCIter1-5.); | |
67ebd013 | 289 | |
fdceab34 | 290 | //fill the container |
291 | containerInputRec[0] = track->Pt(); | |
67ebd013 | 292 | containerInputRec[1] = track->Phi(); |
293 | containerInputRec[2] = track->Eta(); | |
294 | containerInputRec[3] = dca2D; | |
295 | containerInputRec[4] = chi2PerClusterTPC; | |
296 | ||
fdceab34 | 297 | containerInputTPConly[0] = trackTPC->Pt(); |
67ebd013 | 298 | containerInputTPConly[1] = trackTPC->Phi(); |
299 | containerInputTPConly[2] = trackTPC->Eta(); | |
add06ceb | 300 | containerInputTPConly[3] = dca2DTPC/10.; //Divide by 10 in order to store in same container. Should be corrected back when looking at output. |
38ecb6a5 | 301 | containerInputTPConly[4] = chi2PerClusterTPCIter1;//TPC; |
0cc50ca6 | 302 | |
fdceab34 | 303 | if (fTrackCuts->AcceptTrack(track)) { |
67ebd013 | 304 | if(track->GetSign()>0.) { |
305 | fCFManagerPos->GetParticleContainer()->Fill(containerInputRec,kStepReconstructed); | |
306 | fCFManagerPos->GetParticleContainer()->Fill(containerInputTPConly,kStepReconstructedTPCOnly); | |
307 | } | |
308 | if(track->GetSign()<0.) { | |
309 | fCFManagerNeg->GetParticleContainer()->Fill(containerInputRec,kStepReconstructed); | |
310 | fCFManagerNeg->GetParticleContainer()->Fill(containerInputTPConly,kStepReconstructedTPCOnly); | |
311 | } | |
0cc50ca6 | 312 | |
67ebd013 | 313 | |
0cc50ca6 | 314 | //Only fill the secondary particle container if MC information is available |
315 | if(eventHandler) { | |
316 | Int_t label = TMath::Abs(track->GetLabel()); | |
317 | TParticle *particle = stack->Particle(label) ; | |
318 | if(!particle) continue; | |
65e8ecdd | 319 | |
0cc50ca6 | 320 | containerInputMC[0] = particle->Pt(); |
67ebd013 | 321 | containerInputMC[1] = particle->Phi(); |
322 | containerInputMC[2] = particle->Eta(); | |
323 | containerInputMC[3] = 0.0; | |
324 | containerInputMC[4] = 0.0; | |
325 | ||
326 | if(particle->GetPDG()->Charge()>0.) { | |
327 | fCFManagerPos->GetParticleContainer()->Fill(containerInputMC,kStepReconstructedMC); | |
328 | } | |
329 | if(particle->GetPDG()->Charge()<0.) { | |
330 | fCFManagerNeg->GetParticleContainer()->Fill(containerInputMC,kStepReconstructedMC); | |
331 | } | |
332 | ||
0cc50ca6 | 333 | if (!stack->IsPhysicalPrimary(label) ) { |
67ebd013 | 334 | if(particle->GetPDG()->Charge()>0.) { |
335 | fCFManagerPos->GetParticleContainer()->Fill(containerInputRec,kStepSecondaries); | |
336 | } | |
337 | if(particle->GetPDG()->Charge()<0.) { | |
338 | fCFManagerNeg->GetParticleContainer()->Fill(containerInputRec,kStepSecondaries); | |
339 | } | |
0cc50ca6 | 340 | } |
341 | } | |
67ebd013 | 342 | |
fdceab34 | 343 | } |
344 | ||
345 | } | |
67ebd013 | 346 | |
fdceab34 | 347 | |
65e8ecdd | 348 | //Fill MC containters if particles are findable |
0cc50ca6 | 349 | if(eventHandler) { |
350 | for(int iPart = 1; iPart<(mcEvent->GetNumberOfTracks()); iPart++)//stack->GetNprimary(); | |
351 | { | |
352 | AliMCParticle *mcPart = (AliMCParticle*)mcEvent->GetTrack(iPart); | |
353 | if(!mcPart) continue; | |
354 | ||
355 | //fill the container | |
356 | containerInputMC[0] = mcPart->Pt(); | |
67ebd013 | 357 | containerInputMC[1] = mcPart->Phi(); |
358 | containerInputMC[2] = mcPart->Eta(); | |
359 | containerInputMC[3] = 0.0; | |
360 | containerInputMC[4] = 0.0; | |
361 | ||
0cc50ca6 | 362 | int counter; |
65e8ecdd | 363 | Float_t trackLengthTPC = 0.; |
67ebd013 | 364 | if(mcPart->Charge()>0. && fCFManagerPos->CheckParticleCuts(3,mcPart)) { |
e7b49043 | 365 | fCFManagerPos->GetParticleContainer()->Fill(containerInputMC,kStepMCAcceptance) ; |
65e8ecdd | 366 | trackLengthTPC = mcPart->GetTPCTrackLength(fESD->GetMagneticField(),0.1,counter,3.0); |
367 | if(trackLengthTPC > (float)fTrackCuts->GetMinNClusterTPC()) fCFManagerPos->GetParticleContainer()->Fill(containerInputMC,kStepMCtrackable) ; | |
67ebd013 | 368 | } |
369 | if(mcPart->Charge()<0. && fCFManagerNeg->CheckParticleCuts(3,mcPart)) { | |
e7b49043 | 370 | fCFManagerNeg->GetParticleContainer()->Fill(containerInputMC,kStepMCAcceptance) ; |
65e8ecdd | 371 | trackLengthTPC = mcPart->GetTPCTrackLength(fESD->GetMagneticField(),0.1,counter,3.0); |
372 | if(trackLengthTPC > (float)fTrackCuts->GetMinNClusterTPC()) fCFManagerNeg->GetParticleContainer()->Fill(containerInputMC,kStepMCtrackable) ; | |
67ebd013 | 373 | } |
0cc50ca6 | 374 | } |
375 | } | |
67ebd013 | 376 | |
67ebd013 | 377 | PostData(0,fHistList); |
378 | PostData(1,fCFManagerPos->GetParticleContainer()); | |
379 | PostData(2,fCFManagerNeg->GetParticleContainer()); | |
380 | ||
fdceab34 | 381 | } |
382 | ||
383 | ||
384 | //___________________________________________________________________________ | |
385 | void AliPWG4HighPtSpectra::Terminate(Option_t*) | |
386 | { | |
387 | // The Terminate() function is the last function to be called during | |
388 | // a query. It always runs on the client, it can be used to present | |
389 | // the results graphically or save the results to file. | |
fdceab34 | 390 | } |
391 | ||
fdceab34 | 392 | //___________________________________________________________________________ |
393 | void AliPWG4HighPtSpectra::CreateOutputObjects() { | |
394 | //HERE ONE CAN CREATE OUTPUT OBJECTS, IN PARTICULAR IF THE OBJECT PARAMETERS DON'T NEED | |
395 | //TO BE SET BEFORE THE EXECUTION OF THE TASK | |
396 | // | |
df943115 | 397 | AliDebug(2,Form("CreateOutputObjects","CreateOutputObjects of task %s", GetName())); |
398 | ||
67ebd013 | 399 | Bool_t oldStatus = TH1::AddDirectoryStatus(); |
400 | TH1::AddDirectory(kFALSE); | |
401 | ||
fdceab34 | 402 | //slot #1 |
b5cc0c6d | 403 | OpenFile(0); |
404 | fHistList = new TList(); | |
405 | fNEventAll = new TH1F("fNEventAll","NEventAll",1,-0.5,0.5); | |
406 | fHistList->Add(fNEventAll); | |
407 | fNEventSel = new TH1F("fNEventSel","NEvent Selected for analysis",1,-0.5,0.5); | |
408 | fHistList->Add(fNEventSel); | |
fdceab34 | 409 | |
67ebd013 | 410 | TH1::AddDirectory(oldStatus); |
411 | ||
fdceab34 | 412 | } |
413 | ||
414 | #endif |