1 /**************************************************************************
2 * Copyright(c) 1998-2009, 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 **************************************************************************/
18 /////////////////////////////////////////////////////////////
22 // /////////////////////////////////////////////////////////////
28 #include "AliESDInputHandler.h"
29 #include "AliESDtrack.h"
30 #include "AliESDEvent.h"
31 #include "AliESDfriend.h"
32 #include "AliAnalysisTaskFilter.h"
33 #include "AliAnalysisManager.h"
34 #include "AliAnalysisTaskFilterFriend.h"
37 ClassImp(AliAnalysisTaskFilterFriend)
40 //________________________________________________________________________
41 AliAnalysisTaskFilterFriend::AliAnalysisTaskFilterFriend():
42 AliAnalysisTaskFilter(),
48 // Define input and output slots here
49 // Input slot #0 works with a TChain
50 DefineInput(0, TChain::Class());
51 // Output slot #0 writes into a TTree
52 //DefineOutput(0,TTree::Class());
55 //________________________________________________________________________
56 AliAnalysisTaskFilterFriend::AliAnalysisTaskFilterFriend(const char* name):
57 AliAnalysisTaskFilter(name),
63 // Define input and output slots here
64 // Input slot #0 works with a TChain
65 DefineInput(0, TChain::Class());
66 // Output slot #0 writes into a TTree
67 //DefineOutput(0,TTree::Class());
70 //________________________________________________________________________
71 AliAnalysisTaskFilterFriend::~AliAnalysisTaskFilterFriend()
78 //________________________________________________________________________
79 void AliAnalysisTaskFilterFriend::Init()
86 //________________________________________________________________________
87 void AliAnalysisTaskFilterFriend::UserCreateOutputObjects()
90 // Create the output container
96 //________________________________________________________________________
97 void AliAnalysisTaskFilterFriend::UserExec(Option_t */*option*/)
100 AliInfo("Filling Friends");
102 fESDInput = dynamic_cast<AliESDEvent*>(InputEvent()); // get the input ESD
103 fESDfriendInput = (AliESDfriend*)(fESDInput->FindListObject("AliESDfriend"));
105 printf("AliAnalysisTaskFilterFriend::Exec(): no ESD \n");
108 if(!fESDfriendInput) {
109 printf("AliAnalysisTaskFilterFriend::Exec(): no ESDfriend \n");
113 AliESDEvent* esdEventOutput = (AliESDEvent*)ESDEvent();
115 AliESDfriend* esdFriendOutput = (AliESDfriend*)ESDfriend();
116 AliInfo(Form("Number of ESD tracks in input = %d ",fESDInput->GetNumberOfTracks()));
117 AliInfo(Form("Number of ESD tracks in output = %d ",esdEventOutput->GetNumberOfTracks()));
118 AliInfo(Form("Number of tracks in input friends = %d ",fESDfriendInput->GetNumberOfTracks()));
119 AliInfo(Form("Number of tracks in output friendsNew before filtering = %d ",esdFriendOutput->GetNumberOfTracks()));
121 AliESDfriendTrack* tNull = new AliESDfriendTrack();
123 for (Int_t i = 0; i< fESDInput->GetNumberOfTracks(); i++){
126 AliInfo(Form("Keeping %d-th track",i));
127 esdEventOutput->GetTrack(i);
128 AliESDfriendTrack* tOld = (AliESDfriendTrack*)fESDfriendInput->GetTrack(i);
129 AliDebug(2,Form("1P of the %d-th track = %f",i,tOld->Get1P()));
130 AliInfo(Form("1P of the %d-th track = %f",i,tOld->Get1P()));
131 AliInfo(Form("MaxITScluster %d-th track = %d",i,tOld->GetMaxITScluster()));
133 AddFriendTrackAt(tOld,i);
138 AddFriendTrackAt(tNull,i);
142 AliInfo(Form("Number of tracks in output friendsNew after filtering = %d ",esdFriendOutput->GetNumberOfTracks()));
143 AliInfo(Form("Number of tracks in output friendsNew after filtering with GetEntries() = %d ",esdFriendOutput->GetEntriesInTracks()));
147 //________________________________________________________________________
148 void AliAnalysisTaskFilterFriend::Terminate(Option_t */*option*/)
150 // Terminate analysis
152 AliDebug(2,"AliAnalysisTaskFilterFriend: Terminate() \n");
156 //________________________________________________________________________
157 Bool_t AliAnalysisTaskFilterFriend::UserSelectESDfriendForCurrentEvent()
160 // Selecting or discarding current event
164 fESDInput = dynamic_cast<AliESDEvent*>(InputEvent()); // get the input ESD
165 if ((fESDInput->GetNumberOfTracks())%2 == 0) {
166 AliInfo("Selecting event");
169 AliInfo("Discarding event");