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 : R. Vernet, Consorzio Cometa - Catania (it)
24 //-----------------------------------------------------------------------
27 #ifndef ALIPROTONCORRECTIONTASK_CXX
28 #define ALIPROTONCORRECTIONTASK_CXX
30 #include "AliProtonCorrectionTask.h"
33 #include "TParticle.h"
35 #include "AliMCEvent.h"
36 #include "AliAnalysisManager.h"
37 #include "AliESDEvent.h"
38 #include "AliAODEvent.h"
39 #include "AliCFManager.h"
40 #include "AliCFCutBase.h"
41 #include "AliCFContainer.h"
43 #include "AliESDtrack.h"
45 //#include "AliTPCtrack.h"
47 ClassImp(AliProtonCorrectionTask)
49 //__________________________________________________________________________
50 AliProtonCorrectionTask::AliProtonCorrectionTask() :
53 fCFManagerProtons(0x0),
54 fCFManagerAntiProtons(0x0),
56 fHistEventsProcessed(0x0)
62 //___________________________________________________________________________
63 AliProtonCorrectionTask::AliProtonCorrectionTask(const Char_t* name) :
64 AliAnalysisTaskSE(name),
67 fCFManagerProtons(0x0),
68 fCFManagerAntiProtons(0x0),
70 fHistEventsProcessed(0x0) {
72 // Constructor. Initialization of Inputs and Outputs
74 Info("AliProtonCorrectionTask","Calling Constructor");
77 DefineInput(0) and DefineOutput(0)
78 are taken care of by AliAnalysisTaskSE constructor
80 DefineOutput(1,TH1I::Class());
81 DefineOutput(2,AliCFContainer::Class());
82 DefineOutput(3,AliCFContainer::Class());
83 DefineOutput(4,TList::Class());
86 //___________________________________________________________________________
87 AliProtonCorrectionTask& AliProtonCorrectionTask::operator=(const AliProtonCorrectionTask& c) {
89 // Assignment operator
92 AliAnalysisTaskSE::operator=(c) ;
93 fReadTPCTracks = c.fReadTPCTracks ;
94 fReadAODData = c.fReadAODData ;
95 fCFManagerProtons = c.fCFManagerProtons;
96 fCFManagerAntiProtons = c.fCFManagerAntiProtons;
97 fQAHistList = c.fQAHistList ;
98 fHistEventsProcessed = c.fHistEventsProcessed;
103 //___________________________________________________________________________
104 AliProtonCorrectionTask::AliProtonCorrectionTask(const AliProtonCorrectionTask& c) :
105 AliAnalysisTaskSE(c),
106 fReadTPCTracks(c.fReadTPCTracks),
107 fReadAODData(c.fReadAODData),
108 fCFManagerProtons(c.fCFManagerProtons),
109 fCFManagerAntiProtons(c.fCFManagerAntiProtons),
110 fQAHistList(c.fQAHistList),
111 fHistEventsProcessed(c.fHistEventsProcessed) {
117 //___________________________________________________________________________
118 AliProtonCorrectionTask::~AliProtonCorrectionTask() {
122 Info("~AliProtonCorrectionTask","Calling Destructor");
123 if (fCFManagerProtons) delete fCFManagerProtons ;
124 if (fCFManagerAntiProtons) delete fCFManagerAntiProtons ;
125 if (fHistEventsProcessed) delete fHistEventsProcessed ;
126 if (fQAHistList) {fQAHistList->Clear(); delete fQAHistList;}
129 //_________________________________________________
130 void AliProtonCorrectionTask::UserExec(Option_t *) {
132 // Main loop function
134 Info("UserExec","") ;
136 AliVEvent* fEvent = fInputEvent ;
137 AliVParticle* track ;
140 Error("UserExec","NO EVENT FOUND!");
144 if (!fMCEvent) Error("UserExec","NO MC INFO FOUND");
146 //pass the MC evt handler to the cuts that need it
147 fCFManagerProtons->SetEventInfo(fMCEvent);
148 fCFManagerAntiProtons->SetEventInfo(fMCEvent);
150 // MC-event selection
151 Double_t containerInput[2] ;
153 //__________________________________________________________//
154 //loop on the MC event
155 for (Int_t ipart=0; ipart<fMCEvent->GetNumberOfTracks(); ipart++) {
156 AliMCParticle *mcPart = fMCEvent->GetTrack(ipart);
158 //check the MC-level cuts
159 if (!fCFManagerProtons->CheckParticleCuts(AliCFManager::kPartGenCuts,mcPart)) continue;
161 containerInput[0] = Rapidity(mcPart->Px(),
164 containerInput[1] = (Float_t)mcPart->Pt();
165 //fill the container for Gen-level selection
166 fCFManagerProtons->GetParticleContainer()->Fill(containerInput,kStepGenerated);
168 //check the Acceptance-level cuts
169 if (!fCFManagerProtons->CheckParticleCuts(AliCFManager::kPartAccCuts,mcPart)) continue;
170 //fill the container for Acceptance-level selection
171 fCFManagerProtons->GetParticleContainer()->Fill(containerInput,kStepReconstructible);
172 }//loop over MC particles (protons)
173 //__________________________________________________________//
174 //loop on the MC event
175 for (Int_t ipart=0; ipart<fMCEvent->GetNumberOfTracks(); ipart++) {
176 AliMCParticle *mcPart = fMCEvent->GetTrack(ipart);
178 //check the MC-level cuts
179 if (!fCFManagerAntiProtons->CheckParticleCuts(AliCFManager::kPartGenCuts,mcPart)) continue;
181 containerInput[0] = Rapidity(mcPart->Px(),
184 containerInput[1] = (Float_t)mcPart->Pt();
185 //fill the container for Gen-level selection
186 fCFManagerAntiProtons->GetParticleContainer()->Fill(containerInput,kStepGenerated);
188 //check the Acceptance-level cuts
189 if (!fCFManagerAntiProtons->CheckParticleCuts(AliCFManager::kPartAccCuts,mcPart)) continue;
190 //fill the container for Acceptance-level selection
191 fCFManagerAntiProtons->GetParticleContainer()->Fill(containerInput,kStepReconstructible);
192 }//loop over MC particles (antiprotons)
194 //__________________________________________________________//
196 for (Int_t iTrack = 0; iTrack<fEvent->GetNumberOfTracks(); iTrack++) {
197 track = fEvent->GetTrack(iTrack);
199 if (fReadTPCTracks) {
201 Error("UserExec","TPC-only tracks are not supported with AOD");
204 AliESDtrack* esdTrack = (AliESDtrack*) track;
205 AliESDtrack* esdTrackTPC = new AliESDtrack();
206 if (!esdTrack->FillTPCOnlyTrack(*esdTrackTPC)) {
207 Error("UserExec","Could not retrieve TPC info");
210 track = esdTrackTPC ;
213 if (!fCFManagerProtons->CheckParticleCuts(AliCFManager::kPartRecCuts,track)) continue;
215 // is track associated to particle ?
216 Int_t label = track->GetLabel();
217 if (label<0) continue;
218 AliMCParticle *mcPart = fMCEvent->GetTrack(label);
220 // check if this track was part of the signal
221 if (!fCFManagerProtons->CheckParticleCuts(AliCFManager::kPartGenCuts,mcPart)) continue;
224 containerInput[0] = Rapidity(track->Px(),
227 containerInput[1] = track->Pt();
228 fCFManagerProtons->GetParticleContainer()->Fill(containerInput,kStepReconstructed) ;
230 if (!fCFManagerProtons->CheckParticleCuts(AliCFManager::kPartSelCuts,track)) continue ;
231 fCFManagerProtons->GetParticleContainer()->Fill(containerInput,kStepSelected);
233 if (fReadTPCTracks) delete track;
235 //__________________________________________________________//
237 for (Int_t iTrack = 0; iTrack<fEvent->GetNumberOfTracks(); iTrack++) {
238 track = fEvent->GetTrack(iTrack);
240 if (fReadTPCTracks) {
242 Error("UserExec","TPC-only tracks are not supported with AOD");
245 AliESDtrack* esdTrack = (AliESDtrack*) track;
246 AliESDtrack* esdTrackTPC = new AliESDtrack();
247 if (!esdTrack->FillTPCOnlyTrack(*esdTrackTPC)) {
248 Error("UserExec","Could not retrieve TPC info");
251 track = esdTrackTPC ;
254 if (!fCFManagerAntiProtons->CheckParticleCuts(AliCFManager::kPartRecCuts,track)) continue;
256 // is track associated to particle ?
257 Int_t label = track->GetLabel();
258 if (label<0) continue;
259 AliMCParticle *mcPart = fMCEvent->GetTrack(label);
261 // check if this track was part of the signal
262 if (!fCFManagerAntiProtons->CheckParticleCuts(AliCFManager::kPartGenCuts,mcPart)) continue;
265 containerInput[0] = Rapidity(track->Px(),
268 containerInput[1] = track->Pt();
269 fCFManagerAntiProtons->GetParticleContainer()->Fill(containerInput,kStepReconstructed) ;
271 if (!fCFManagerAntiProtons->CheckParticleCuts(AliCFManager::kPartSelCuts,track)) continue ;
272 fCFManagerAntiProtons->GetParticleContainer()->Fill(containerInput,kStepSelected);
274 if (fReadTPCTracks) delete track;
277 fHistEventsProcessed->Fill(0);
279 /* PostData(0) is taken care of by AliAnalysisTaskSE */
280 PostData(1,fHistEventsProcessed) ;
281 PostData(2,fCFManagerProtons->GetParticleContainer()) ;
282 PostData(3,fCFManagerAntiProtons->GetParticleContainer()) ;
283 PostData(4,fQAHistList) ;
287 //___________________________________________________________________________
288 void AliProtonCorrectionTask::Terminate(Option_t*) {
289 // The Terminate() function is the last function to be called during
290 // a query. It always runs on the client, it can be used to present
291 // the results graphically or save the results to file.
293 Info("Terminate","");
294 AliAnalysisTaskSE::Terminate();
296 //draw some example plots....
298 AliCFContainer *cont= dynamic_cast<AliCFContainer*> (GetOutputData(2));
300 TH1D* h00 = cont->ShowProjection(0,0) ;
301 TH1D* h01 = cont->ShowProjection(0,1) ;
302 TH1D* h02 = cont->ShowProjection(0,2) ;
303 TH1D* h03 = cont->ShowProjection(0,3) ;
305 TH1D* h10 = cont->ShowProjection(1,0) ;
306 TH1D* h11 = cont->ShowProjection(1,1) ;
307 TH1D* h12 = cont->ShowProjection(1,2) ;
308 TH1D* h13 = cont->ShowProjection(1,3) ;
310 TCanvas * c =new TCanvas("c","",1400,800);
313 c->cd(1); h00->Draw("p");
314 c->cd(2); h01->Draw("p");
315 c->cd(3); h02->Draw("p");
316 c->cd(4); h03->Draw("p");
317 c->cd(5); h10->Draw("p");
318 c->cd(6); h11->Draw("p");
319 c->cd(7); h12->Draw("p");
320 c->cd(8); h13->Draw("p");
322 c->SaveAs("plots.eps");
326 //___________________________________________________________________________
327 void AliProtonCorrectionTask::UserCreateOutputObjects() {
328 //HERE ONE CAN CREATE OUTPUT OBJECTS, IN PARTICULAR IF THE OBJECT PARAMETERS DON'T NEED
329 //TO BE SET BEFORE THE EXECUTION OF THE TASK
331 Info("CreateOutputObjects","CreateOutputObjects of task %s", GetName());
335 fHistEventsProcessed = new TH1I("fHistEventsProcessed","",1,0,1) ;
341 //___________________________________________________________________________
342 Double_t AliProtonCorrectionTask::Rapidity(Double_t Px, Double_t Py, Double_t Pz) {
343 //returns the rapidity of the (anti)proton
344 Double_t fMass = 9.38270000000000048e-01;
346 Double_t P = TMath::Sqrt(TMath::Power(Px,2) +
349 Double_t energy = TMath::Sqrt(P*P + fMass*fMass);
352 y = 0.5*TMath::Log((energy + Pz)/(energy - Pz));