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*/)
104 fESDInput = dynamic_cast<AliESDEvent*>(InputEvent()); // get the input ESD
105 fESDfriendInput = InputFriend(); // get the input friend
107 printf("AliAnalysisTaskFilterFriend::Exec(): no ESD \n");
110 if(!fESDfriendInput) {
111 printf("AliAnalysisTaskFilterFriend::Exec(): no ESDfriend \n");
116 AliESDfriend* esdFriendOutput = (AliESDfriend*)ESDfriend();
117 AliDebug(3,Form("Number of ESD tracks in input = %d ",fESDInput->GetNumberOfTracks()));
118 AliDebug(3,Form("Number of tracks in input friends = %d ",fESDfriendInput->GetNumberOfTracks()));
119 AliDebug(3,Form("Number of tracks in output friendsNew before filtering = %d ",esdFriendOutput->GetNumberOfTracks()));
121 for (Int_t i = 0; i< fESDInput->GetNumberOfTracks(); i++){
124 AliDebug(2,Form("Keeping %d-th track",i));
125 AliESDfriendTrack* tOld = (AliESDfriendTrack*)fESDfriendInput->GetTrack(i);
126 AliDebug(3,Form("1P of the %d-th track = %f",i,tOld->Get1P()));
127 AliDebug(3,Form("MaxITScluster %d-th track = %d",i,tOld->GetMaxITScluster()));
129 AddFriendTrackAt(tOld,i);
134 SkipFriendTrackAt(i);
138 AliDebug(2,Form("Number of tracks in output friendsNew after filtering with GetEntries() = %d ",esdFriendOutput->GetEntriesInTracks()));
142 //________________________________________________________________________
143 void AliAnalysisTaskFilterFriend::Terminate(Option_t */*option*/)
145 // Terminate analysis
147 AliDebug(2,"AliAnalysisTaskFilterFriend: Terminate() \n");
151 //________________________________________________________________________
152 Bool_t AliAnalysisTaskFilterFriend::UserSelectESDfriendForCurrentEvent()
155 // Selecting or discarding current event
159 fESDInput = dynamic_cast<AliESDEvent*>(InputEvent()); // get the input ESD
161 AliError("No ESD Input, discarding event...");
164 if ((fESDInput->GetNumberOfTracks())%2 == 0) {
165 AliDebug(2,"******************Selecting event");
168 AliDebug(2,"*******************Discarding event");