]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ANALYSIS/AliAnalysisTaskFilterFriendSecond.cxx
fix for event mixing
[u/mrichter/AliRoot.git] / ANALYSIS / AliAnalysisTaskFilterFriendSecond.cxx
CommitLineData
6d3a7bbf 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// Test task
21//
22// /////////////////////////////////////////////////////////////
23
24#include <TTree.h>
25#include <TChain.h>
26
27#include "AliLog.h"
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"
35
36
37ClassImp(AliAnalysisTaskFilterFriendSecond)
38
39
40//________________________________________________________________________
41AliAnalysisTaskFilterFriendSecond::AliAnalysisTaskFilterFriendSecond():
42AliAnalysisTaskFilter(),
43fESDInput(0),
44fESDfriendInput(0)
45{
46 // Constructor
47
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());
53}
54
55//________________________________________________________________________
56AliAnalysisTaskFilterFriendSecond::AliAnalysisTaskFilterFriendSecond(const char* name):
57AliAnalysisTaskFilter(name),
58fESDInput(0),
59fESDfriendInput(0)
60{
61 // Constructor
62
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());
68}
69
70//________________________________________________________________________
71AliAnalysisTaskFilterFriendSecond::~AliAnalysisTaskFilterFriendSecond()
72{
73
74 // dtor
75
76}
77
78//________________________________________________________________________
79void AliAnalysisTaskFilterFriendSecond::Init()
80{
81 // Initialization
82
83 return;
84}
85
86//________________________________________________________________________
87void AliAnalysisTaskFilterFriendSecond::UserCreateOutputObjects()
88{
89 //
90 // Create the output container
91 //
92
93 return;
94}
95
96//________________________________________________________________________
97void AliAnalysisTaskFilterFriendSecond::UserExec(Option_t */*option*/)
98{
99
3e341ccb 100 //
101 // Filtering Friends
102 //
6d3a7bbf 103
104 fESDInput = dynamic_cast<AliESDEvent*>(InputEvent()); // get the input ESD
3e341ccb 105 fESDfriendInput = InputFriend(); // get the input friend
6d3a7bbf 106 if(!fESDInput) {
107 printf("AliAnalysisTaskFilterFriendSecond::Exec(): no ESD \n");
108 return;
109 }
110 if(!fESDfriendInput) {
111 printf("AliAnalysisTaskFilterFriendSecond::Exec(): no ESDfriend \n");
112 return;
113 }
114 // attach ESDfriend
6d3a7bbf 115
116 AliESDfriend* esdFriendOutput = (AliESDfriend*)ESDfriend();
3e341ccb 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()));
6d3a7bbf 120
6d3a7bbf 121 for (Int_t i = 0; i< fESDInput->GetNumberOfTracks(); i++){
122 if (i%3 == 0){
123 // keep friend
250e5362 124 AliDebug(2,Form("Keeping %d-th track",i));
6d3a7bbf 125 AliESDfriendTrack* tOld = (AliESDfriendTrack*)fESDfriendInput->GetTrack(i);
250e5362 126 // debugging printouts
127 AliDebug(3,Form("1P of the %d-th track = %f",i,tOld->Get1P()));
6d3a7bbf 128 AddFriendTrackAt(tOld,i);
129 // tOld->Dump();
130 }
131 else {
132 //discard friend
3e341ccb 133 SkipFriendTrackAt(i);
6d3a7bbf 134 }
135 }
250e5362 136 AliDebug(2,Form("Number of tracks in output friendsNew after filtering with GetEntries() = %d ",esdFriendOutput->GetEntriesInTracks()));
6d3a7bbf 137 return;
138}
139
140//________________________________________________________________________
141void AliAnalysisTaskFilterFriendSecond::Terminate(Option_t */*option*/)
142{
143 // Terminate analysis
144 //
145 AliDebug(2,"AliAnalysisTaskFilterFriendSecond: Terminate() \n");
146
147 return;
148}
149//________________________________________________________________________
150Bool_t AliAnalysisTaskFilterFriendSecond::UserSelectESDfriendForCurrentEvent()
151{
152 //
153 // Selecting or discarding current event
154 //
155
3e341ccb 156 /*
6d3a7bbf 157 fESDInput = dynamic_cast<AliESDEvent*>(InputEvent()); // get the input ESD
158 if ((fESDInput->GetNumberOfTracks())%2 == 1){
3e341ccb 159 AliDebug(2,"****************Selecting event");
6d3a7bbf 160 return kTRUE;
161 }
162
3e341ccb 163 AliDebug(2,"****************Discarding event");
6d3a7bbf 164 return kFALSE;
3e341ccb 165 */
166 AliDebug(2,"****************Selecting event");
167 return kTRUE;
6d3a7bbf 168}