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 **************************************************************************/
20 /////////////////////////////////////////////////////////////
23 // Selection of only 1% of the events for which to keep
26 // /////////////////////////////////////////////////////////////
32 #include "AliESDInputHandler.h"
33 #include "AliESDtrack.h"
34 #include "AliESDEvent.h"
35 #include "AliESDfriend.h"
36 #include "AliAnalysisTaskFilter.h"
37 #include "AliAnalysisManager.h"
38 #include "AliAnalysisTaskFilterSteer.h"
42 ClassImp(AliAnalysisTaskFilterSteer)
45 //________________________________________________________________________
46 AliAnalysisTaskFilterSteer::AliAnalysisTaskFilterSteer():
47 AliAnalysisTaskFilter(),
54 // Define input and output slots here
55 // Input slot #0 works with a TChain
56 DefineInput(0, TChain::Class());
57 // Output slot #0 writes into a TTree
58 //DefineOutput(0,TTree::Class());
61 //________________________________________________________________________
62 AliAnalysisTaskFilterSteer::AliAnalysisTaskFilterSteer(const char* name):
63 AliAnalysisTaskFilter(name),
70 // Define input and output slots here
71 // Input slot #0 works with a TChain
72 DefineInput(0, TChain::Class());
73 // Output slot #0 writes into a TTree
74 //DefineOutput(0,TTree::Class());
77 //________________________________________________________________________
78 AliAnalysisTaskFilterSteer::~AliAnalysisTaskFilterSteer()
85 //________________________________________________________________________
86 void AliAnalysisTaskFilterSteer::Init()
93 //________________________________________________________________________
94 void AliAnalysisTaskFilterSteer::UserCreateOutputObjects()
97 // Create the output container
103 //________________________________________________________________________
104 void AliAnalysisTaskFilterSteer::UserExec(Option_t */*option*/)
108 // Applying random selection of the events
110 fESDInput = dynamic_cast<AliESDEvent*>(InputEvent()); // get the input ESD
111 fESDfriendInput = InputFriend(); // get the input friend
113 printf("AliAnalysisTaskFilterSteer::Exec(): no ESD \n");
116 if(!fESDfriendInput) {
117 printf("AliAnalysisTaskFilterSteer::Exec(): no ESDfriend \n");
123 AliESDfriend* esdFriendOutput = (AliESDfriend*)ESDfriend();
124 AliDebug(3,Form("Number of ESD tracks in input = %d ",fESDInput->GetNumberOfTracks()));
125 AliDebug(3,Form("Number of tracks in input friends = %d ",fESDfriendInput->GetNumberOfTracks()));
126 AliDebug(3,Form("Number of tracks in output friendsNew before filtering = %d ",esdFriendOutput->GetNumberOfTracks()));
129 // keeping all the tracks for the randomly "fFraction" of the total number of events
132 for (Int_t i = 0; i< fESDInput->GetNumberOfTracks(); i++){
133 AliESDfriendTrack* tOld = (AliESDfriendTrack*)fESDfriendInput->GetTrack(i);
134 AddFriendTrackAt(tOld,i);
136 AliDebug(2,Form("Number of tracks in output friendsNew after filtering = %d ",esdFriendOutput->GetNumberOfTracks()));
137 AliDebug(2,Form("Number of tracks in output friendsNew after filtering with GetEntries() = %d ",esdFriendOutput->GetEntriesInTracks()));
142 //________________________________________________________________________
143 void AliAnalysisTaskFilterSteer::Terminate(Option_t */*option*/)
145 // Terminate analysis
147 AliDebug(2,"AliAnalysisTaskFilterSteer: Terminate() \n");
151 //________________________________________________________________________
152 Bool_t AliAnalysisTaskFilterSteer::UserSelectESDfriendForCurrentEvent()
155 // Selecting or discarding current event
157 Double_t number = gRandom->Rndm();
158 if (number<fFraction){
160 AliDebug(2,Form("*****************Selecting event (number = %f)",number));
163 AliDebug(2,Form("*****************Skipping event (number = %f)",number));