1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
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
22 //-----------------------------------------------------------------------
23 // Author : Marta Verweij - UU
24 //-----------------------------------------------------------------------
27 #ifndef ALIPWG4HighPtSpectra_CXX
28 #define ALIPWG4HighPtSpectra_CXX
30 #include "AliPWG4HighPtSpectra.h"
33 #include "TParticle.h"
35 #include "AliMCEvent.h"
36 #include "AliMCEventHandler.h"
37 #include "AliAnalysisManager.h"
38 #include "AliCFContainer.h"
40 #include "AliESDtrack.h"
41 #include "AliESDtrackCuts.h"
42 #include "AliExternalTrackParam.h"
43 #include "AliESDInputHandler.h"
45 using namespace std; //required for resolving the 'cout' symbol
47 ClassImp(AliPWG4HighPtSpectra)
49 //__________________________________________________________________________
50 AliPWG4HighPtSpectra::AliPWG4HighPtSpectra() : AliAnalysisTask("AliPWG4HighPtSpectra", ""),
56 fHistEventsProcessed(0x0)
62 //___________________________________________________________________________
63 AliPWG4HighPtSpectra::AliPWG4HighPtSpectra(const Char_t* name) :
64 AliAnalysisTask(name,""),
68 fTrackCuts(),//new AliESDtrackCuts),
70 fHistEventsProcessed(0x0)
73 // Constructor. Initialization of Inputs and Outputs
75 AliDebug(2,Form("AliPWG4HighPtQAMC","Calling Constructor"));
76 // Input slot #0 works with a TChain ESD
77 DefineInput(0, TChain::Class());
78 DefineOutput(0,TList::Class());
79 DefineOutput(1,AliCFContainer::Class());
82 //___________________________________________________________________________
83 AliPWG4HighPtSpectra& AliPWG4HighPtSpectra::operator=(const AliPWG4HighPtSpectra& c)
86 // Assignment operator
89 AliAnalysisTask::operator=(c) ;
90 fReadAODData = c.fReadAODData ;
91 fCFManager = c.fCFManager;
92 fHistList = c.fHistList;
93 fHistEventsProcessed = c.fHistEventsProcessed;
98 //___________________________________________________________________________
99 AliPWG4HighPtSpectra::AliPWG4HighPtSpectra(const AliPWG4HighPtSpectra& c) :
101 fReadAODData(c.fReadAODData),
102 fCFManager(c.fCFManager),
104 fTrackCuts(c.fTrackCuts),
105 fHistList(c.fHistList),
106 fHistEventsProcessed(c.fHistEventsProcessed)
113 //___________________________________________________________________________
114 AliPWG4HighPtSpectra::~AliPWG4HighPtSpectra() {
118 Info("~AliPWG4HighPtSpectra","Calling Destructor");
119 if (fCFManager) delete fCFManager ;
120 if (fHistEventsProcessed) delete fHistEventsProcessed ;
122 //________________________________________________________________________
123 void AliPWG4HighPtSpectra::ConnectInputData(Option_t *)
127 AliDebug(2,Form(">> AliPWG4HighPtSpectra::ConnectInputData \n"));
128 // printf(">> AliPWG4HighPtSpectra::ConnectInputData \n");
130 TTree* tree = dynamic_cast<TTree*> (GetInputData(0));
132 AliDebug(2,Form("ERROR: Could not read chain from input slot 0"));
135 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
138 AliDebug(2,Form("ERROR: Could not get ESDInputHandler"));
140 fESD = esdH->GetEvent();
144 //_________________________________________________
145 void AliPWG4HighPtSpectra::Exec(Option_t *)//UserExec(Option_t *)
148 // Main loop function
150 AliDebug(2,Form(">> AliPWG4HighPtSpectra::Exec \n"));
153 AliDebug(2,Form("ERROR: fESD not available"));
157 // Process MC truth, therefore we receive the AliAnalysisManager and ask it for the AliMCEventHandler
158 // This handler can return the current MC event
159 AliMCEventHandler* eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
160 AliStack* stack = 0x0;
161 AliMCEvent* mcEvent = 0x0;
164 mcEvent = eventHandler->MCEvent();
166 AliDebug(2,Form("ERROR: Could not retrieve MC event"));
170 AliDebug(2,Form("MC particles: %d", mcEvent->GetNumberOfTracks()));
172 stack = mcEvent->Stack(); //Particles Stack
174 AliDebug(2,Form("MC particles stack: %d", stack->GetNtrack()));
178 AliDebug(2,Form("ERROR: fESD not available"));
182 const AliESDVertex *vtx = fESD->GetPrimaryVertex();
185 if (vtx->GetNContributors() < 2) return;
188 if(TMath::Abs(pvtx[2])>10.) return;
190 AliDebug(2,Form("Vertex title %s, status %d, nCont %d\n",vtx->GetTitle(), vtx->GetStatus(), vtx->GetNContributors()));
191 // Need to keep track of evts without vertex
193 Int_t nTracks = fESD->GetNumberOfTracks();
194 AliDebug(2,Form("nTracks %d", nTracks));
196 Double_t containerInputRec[1] ;
197 Double_t containerInputTPConly[1] ;
198 Double_t containerInputMC[1] ;
199 //Now go to rec level
200 for (Int_t iTrack = 0; iTrack<nTracks; iTrack++)
202 if(!fESD->GetTrack(iTrack) ) continue;
203 AliESDtrack* track = fESD->GetTrack(iTrack);
204 if(!(AliExternalTrackParam *)track->GetTPCInnerParam()) continue;
205 AliExternalTrackParam *trackTPC = (AliExternalTrackParam *)track->GetTPCInnerParam();
206 if(!track || !trackTPC) continue;
210 containerInputRec[0] = track->Pt();
211 containerInputTPConly[0] = trackTPC->Pt();
213 if (fTrackCuts->AcceptTrack(track)) {
214 fCFManager->GetParticleContainer()->Fill(containerInputRec,kStepReconstructed);
215 fCFManager->GetParticleContainer()->Fill(containerInputTPConly,kStepReconstructedTPCOnly);
217 //Only fill the secondary particle container if MC information is available
219 Int_t label = TMath::Abs(track->GetLabel());
220 TParticle *particle = stack->Particle(label) ;
221 if(!particle) continue;
222 containerInputMC[0] = particle->Pt();
223 fCFManager->GetParticleContainer()->Fill(containerInputMC,kStepReconstructedMC);
224 if (!stack->IsPhysicalPrimary(label) ) {
225 fCFManager->GetParticleContainer()->Fill(containerInputRec,kStepSecondaries);
233 for(int iPart = 1; iPart<(mcEvent->GetNumberOfTracks()); iPart++)//stack->GetNprimary();
235 AliMCParticle *mcPart = (AliMCParticle*)mcEvent->GetTrack(iPart);
236 if(!mcPart) continue;
239 containerInputMC[0] = mcPart->Pt();
241 if (!fCFManager->CheckParticleCuts(3,mcPart)) continue ;
245 Float_t trackLengthTPC = mcPart->GetTPCTrackLength(fESD->GetMagneticField(),0.1,counter,3.0);
247 if(trackLengthTPC>80.) fCFManager->GetParticleContainer()->Fill(containerInputMC,kStepMCtrackable) ;
252 fHistEventsProcessed->Fill(0);
253 PostData(0,fHistList);
254 PostData(1,fCFManager->GetParticleContainer());
259 //___________________________________________________________________________
260 void AliPWG4HighPtSpectra::Terminate(Option_t*)
262 // The Terminate() function is the last function to be called during
263 // a query. It always runs on the client, it can be used to present
264 // the results graphically or save the results to file.
269 //___________________________________________________________________________
270 void AliPWG4HighPtSpectra::CreateOutputObjects() {
271 //HERE ONE CAN CREATE OUTPUT OBJECTS, IN PARTICULAR IF THE OBJECT PARAMETERS DON'T NEED
272 //TO BE SET BEFORE THE EXECUTION OF THE TASK
274 AliDebug(2,Form("CreateOutputObjects","CreateOutputObjects of task %s", GetName()));
277 fHistList = new TList();
280 fHistEventsProcessed = new TH1I("fHistEventsProcessed","",1,0,1) ;
281 fHistList->Add(fHistEventsProcessed);