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 "AliAnalysisTaskFilterFriendSecond.h"
37 ClassImp(AliAnalysisTaskFilterFriendSecond)
40 //________________________________________________________________________
41 AliAnalysisTaskFilterFriendSecond::AliAnalysisTaskFilterFriendSecond():
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 AliAnalysisTaskFilterFriendSecond::AliAnalysisTaskFilterFriendSecond(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 AliAnalysisTaskFilterFriendSecond::~AliAnalysisTaskFilterFriendSecond()
78 //________________________________________________________________________
79 void AliAnalysisTaskFilterFriendSecond::Init()
86 //________________________________________________________________________
87 void AliAnalysisTaskFilterFriendSecond::UserCreateOutputObjects()
90 // Create the output container
96 //________________________________________________________________________
97 void AliAnalysisTaskFilterFriendSecond::UserExec(Option_t */*option*/)
104 fESDInput = dynamic_cast<AliESDEvent*>(InputEvent()); // get the input ESD
105 fESDfriendInput = InputFriend(); // get the input friend
107 printf("AliAnalysisTaskFilterFriendSecond::Exec(): no ESD \n");
110 if(!fESDfriendInput) {
111 printf("AliAnalysisTaskFilterFriendSecond::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 // debugging printouts
127 AliDebug(3,Form("1P of the %d-th track = %f",i,tOld->Get1P()));
128 AddFriendTrackAt(tOld,i);
133 SkipFriendTrackAt(i);
136 AliDebug(2,Form("Number of tracks in output friendsNew after filtering with GetEntries() = %d ",esdFriendOutput->GetEntriesInTracks()));
140 //________________________________________________________________________
141 void AliAnalysisTaskFilterFriendSecond::Terminate(Option_t */*option*/)
143 // Terminate analysis
145 AliDebug(2,"AliAnalysisTaskFilterFriendSecond: Terminate() \n");
149 //________________________________________________________________________
150 Bool_t AliAnalysisTaskFilterFriendSecond::UserSelectESDfriendForCurrentEvent()
153 // Selecting or discarding current event
157 fESDInput = dynamic_cast<AliESDEvent*>(InputEvent()); // get the input ESD
158 if ((fESDInput->GetNumberOfTracks())%2 == 1){
159 AliDebug(2,"****************Selecting event");
163 AliDebug(2,"****************Discarding event");
166 AliDebug(2,"****************Selecting event");