]>
Commit | Line | Data |
---|---|---|
91bf40f8 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
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 | **************************************************************************/ | |
15 | ||
16 | /*$Id$ | |
17 | ||
18 | */ | |
19 | ||
20 | ///////////////////////////////////////////////////////////// | |
21 | // | |
22 | // Filtering task to be run on STEERING level | |
23 | // 1. Select randomly the event to be kept fully 0 cuttof - fKeepFraction - | |
24 | // gRandmom->Rndm() used. | |
25 | // 2. Pt() cut used - fPtCut | |
26 | // | |
27 | // ///////////////////////////////////////////////////////////// | |
28 | ||
29 | #include <TTree.h> | |
30 | #include <TChain.h> | |
31 | ||
32 | #include "AliLog.h" | |
33 | #include "AliESDInputHandler.h" | |
34 | #include "AliESDtrack.h" | |
35 | #include "AliESDEvent.h" | |
36 | #include "AliESDfriend.h" | |
37 | #include "AliAnalysisTaskFilter.h" | |
38 | #include "AliAnalysisManager.h" | |
39 | #include "AliAnalysisTaskFilterSTEER.h" | |
40 | #include "TRandom.h" | |
41 | ||
42 | ||
43 | ClassImp(AliAnalysisTaskFilterSTEER) | |
44 | ||
45 | ||
46 | //________________________________________________________________________ | |
47 | AliAnalysisTaskFilterSTEER::AliAnalysisTaskFilterSTEER(): | |
48 | AliAnalysisTaskFilter(), | |
49 | fPtCut(0), | |
50 | fKeepFraction(0), | |
51 | fESDInput(0), | |
52 | fESDfriendInput(0) | |
53 | { | |
54 | // Constructor | |
55 | ||
56 | // Define input and output slots here | |
57 | // Input slot #0 works with a TChain | |
58 | DefineInput(0, TChain::Class()); | |
59 | // Output slot #0 writes into a TTree | |
60 | //DefineOutput(0,TTree::Class()); | |
61 | } | |
62 | ||
63 | //________________________________________________________________________ | |
64 | AliAnalysisTaskFilterSTEER::AliAnalysisTaskFilterSTEER(const char* name, Double_t ptCut, Double_t fractionCut): | |
65 | AliAnalysisTaskFilter(name), | |
66 | fPtCut(ptCut), | |
67 | fKeepFraction(fractionCut), | |
68 | fESDInput(0), | |
69 | fESDfriendInput(0) | |
70 | { | |
71 | // Constructor | |
72 | ||
73 | // Define input and output slots here | |
74 | // Input slot #0 works with a TChain | |
75 | DefineInput(0, TChain::Class()); | |
76 | // Output slot #0 writes into a TTree | |
77 | //DefineOutput(0,TTree::Class()); | |
78 | } | |
79 | ||
80 | //________________________________________________________________________ | |
81 | AliAnalysisTaskFilterSTEER::~AliAnalysisTaskFilterSTEER() | |
82 | { | |
83 | ||
84 | // dtor | |
85 | ||
86 | } | |
87 | ||
88 | //________________________________________________________________________ | |
89 | void AliAnalysisTaskFilterSTEER::Init() | |
90 | { | |
91 | // Initialization | |
92 | ||
93 | return; | |
94 | } | |
95 | ||
96 | //________________________________________________________________________ | |
97 | void AliAnalysisTaskFilterSTEER::UserCreateOutputObjects() | |
98 | { | |
99 | // | |
100 | // Create the output container | |
101 | // | |
102 | ||
103 | return; | |
104 | } | |
105 | ||
106 | //________________________________________________________________________ | |
107 | void AliAnalysisTaskFilterSTEER::UserExec(Option_t */*option*/) | |
108 | { | |
109 | ||
110 | AliInfo("Filling Friends"); | |
111 | ||
112 | fESDInput = dynamic_cast<AliESDEvent*>(InputEvent()); // get the input ESD | |
113 | fESDfriendInput = (AliESDfriend*)(fESDInput->FindListObject("AliESDfriend")); | |
114 | if(!fESDInput) { | |
115 | printf("AliAnalysisTaskFilterSTEER::Exec(): no ESD \n"); | |
116 | return; | |
117 | } | |
118 | if(!fESDfriendInput) { | |
119 | printf("AliAnalysisTaskFilterSTEER::Exec(): no ESDfriend \n"); | |
120 | return; | |
121 | } | |
122 | // attach ESDfriend | |
123 | ||
124 | AliESDfriend* esdFriendOutput = (AliESDfriend*)ESDfriend(); | |
125 | AliInfo(Form("Number of ESD tracks in input = %d ",fESDInput->GetNumberOfTracks())); | |
126 | AliInfo(Form("Number of tracks in input friends = %d ",fESDfriendInput->GetNumberOfTracks())); | |
127 | AliInfo(Form("Number of tracks in output friendsNew before filtering = %d ",esdFriendOutput->GetNumberOfTracks())); | |
128 | ||
129 | // | |
130 | // select all for fraction of events - event selected randomly | |
131 | // event number 0 always stored - to define the friends layout | |
132 | // | |
133 | AliESDfriendTrack* tNull = new AliESDfriendTrack(); | |
134 | if (fESDInput->GetEventNumberInFile()==0 || gRandom->Rndm()<fKeepFraction){ | |
135 | //select all tracks for slected fraction | |
136 | AliInfo(Form("Keeping Event number %d",fESDInput->GetEventNumberInFile())); | |
137 | for (Int_t i = 0; i< fESDInput->GetNumberOfTracks(); i++){ | |
138 | // keep friend | |
139 | AliESDfriendTrack* tOld = (AliESDfriendTrack*)fESDfriendInput->GetTrack(i); | |
140 | if (tOld) AddFriendTrackAt(tOld,i); | |
141 | else AddFriendTrackAt(tNull,i); | |
142 | } | |
143 | } | |
144 | // | |
145 | // | |
146 | // | |
147 | for (Int_t i = 0; i< fESDInput->GetNumberOfTracks(); i++){ | |
148 | // keep friend | |
149 | AliESDfriendTrack* tOld = (AliESDfriendTrack*)fESDfriendInput->GetTrack(i); | |
150 | Bool_t isOK=kFALSE; | |
151 | if (tOld) | |
152 | if (tOld->GetTPCOut()) | |
153 | if (TMath::Abs(tOld->GetTPCOut()->Pt())>fPtCut) isOK=kTRUE; | |
154 | if (isOK){ | |
155 | AliInfo(Form("Keeping %d-th track",i)); | |
156 | AddFriendTrackAt(tOld,i); | |
157 | }else{ | |
158 | AddFriendTrackAt(tNull,i); | |
159 | } | |
160 | } | |
161 | AliInfo(Form("Number of tracks in output friendsNew after filtering = %d ",esdFriendOutput->GetNumberOfTracks())); | |
162 | AliInfo(Form("Number of tracks in output friendsNew after filtering with GetEntries() = %d ",esdFriendOutput->GetEntriesInTracks())); | |
163 | return; | |
164 | } | |
165 | ||
166 | //________________________________________________________________________ | |
167 | void AliAnalysisTaskFilterSTEER::Terminate(Option_t */*option*/) | |
168 | { | |
169 | // Terminate analysis | |
170 | // | |
171 | AliDebug(2,"AliAnalysisTaskFilterSTEER: Terminate() \n"); | |
172 | ||
173 | return; | |
174 | } | |
175 | //________________________________________________________________________ | |
176 | Bool_t AliAnalysisTaskFilterSTEER::UserSelectESDfriendForCurrentEvent() | |
177 | { | |
178 | // | |
179 | // Selecting or discarding current event | |
180 | // | |
181 | return kTRUE; | |
182 | } |