From 91bf40f8c336cc5c607234c0a70075c48c0d4eaf Mon Sep 17 00:00:00 2001 From: zampolli Date: Tue, 20 Apr 2010 10:08:35 +0000 Subject: [PATCH] First implementation of the task to perform filtering on the ESD friend tracks: - for randomly selected events + event 0 --> keep friend info for the tracks - for the remaining events, keep friend info for tracks with pT > pT_cut (M. Ivanov) --- ANALYSIS/ANALYSIScalibLinkDef.h | 1 + ANALYSIS/AliAnalysisTaskFilterSTEER.cxx | 182 ++++++++++++++++++++++++ ANALYSIS/AliAnalysisTaskFilterSTEER.h | 46 ++++++ ANALYSIS/libANALYSIScalib.pkg | 1 + 4 files changed, 230 insertions(+) create mode 100644 ANALYSIS/AliAnalysisTaskFilterSTEER.cxx create mode 100644 ANALYSIS/AliAnalysisTaskFilterSTEER.h diff --git a/ANALYSIS/ANALYSIScalibLinkDef.h b/ANALYSIS/ANALYSIScalibLinkDef.h index 57b4d2cf4d1..653cbb6a784 100644 --- a/ANALYSIS/ANALYSIScalibLinkDef.h +++ b/ANALYSIS/ANALYSIScalibLinkDef.h @@ -8,6 +8,7 @@ #pragma link C++ class AliAnalysisTaskFilter+; #pragma link C++ class AliAnalysisTaskFilterFriend+; #pragma link C++ class AliAnalysisTaskFilterFriendSecond+; +#pragma link C++ class AliAnalysisTaskFilterSTEER+; #pragma link C++ class AliAnalysisTaskAddObject+; #endif diff --git a/ANALYSIS/AliAnalysisTaskFilterSTEER.cxx b/ANALYSIS/AliAnalysisTaskFilterSTEER.cxx new file mode 100644 index 00000000000..d1419c80aaa --- /dev/null +++ b/ANALYSIS/AliAnalysisTaskFilterSTEER.cxx @@ -0,0 +1,182 @@ +/************************************************************************** + * Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/*$Id$ + +*/ + +///////////////////////////////////////////////////////////// +// +// Filtering task to be run on STEERING level +// 1. Select randomly the event to be kept fully 0 cuttof - fKeepFraction - +// gRandmom->Rndm() used. +// 2. Pt() cut used - fPtCut +// +// ///////////////////////////////////////////////////////////// + +#include +#include + +#include "AliLog.h" +#include "AliESDInputHandler.h" +#include "AliESDtrack.h" +#include "AliESDEvent.h" +#include "AliESDfriend.h" +#include "AliAnalysisTaskFilter.h" +#include "AliAnalysisManager.h" +#include "AliAnalysisTaskFilterSTEER.h" +#include "TRandom.h" + + +ClassImp(AliAnalysisTaskFilterSTEER) + + +//________________________________________________________________________ +AliAnalysisTaskFilterSTEER::AliAnalysisTaskFilterSTEER(): +AliAnalysisTaskFilter(), +fPtCut(0), +fKeepFraction(0), +fESDInput(0), +fESDfriendInput(0) +{ + // Constructor + + // Define input and output slots here + // Input slot #0 works with a TChain + DefineInput(0, TChain::Class()); + // Output slot #0 writes into a TTree + //DefineOutput(0,TTree::Class()); +} + +//________________________________________________________________________ +AliAnalysisTaskFilterSTEER::AliAnalysisTaskFilterSTEER(const char* name, Double_t ptCut, Double_t fractionCut): +AliAnalysisTaskFilter(name), +fPtCut(ptCut), +fKeepFraction(fractionCut), +fESDInput(0), +fESDfriendInput(0) +{ + // Constructor + + // Define input and output slots here + // Input slot #0 works with a TChain + DefineInput(0, TChain::Class()); + // Output slot #0 writes into a TTree + //DefineOutput(0,TTree::Class()); +} + +//________________________________________________________________________ +AliAnalysisTaskFilterSTEER::~AliAnalysisTaskFilterSTEER() +{ + + // dtor + +} + +//________________________________________________________________________ +void AliAnalysisTaskFilterSTEER::Init() +{ + // Initialization + + return; +} + +//________________________________________________________________________ +void AliAnalysisTaskFilterSTEER::UserCreateOutputObjects() +{ + // + // Create the output container + // + + return; +} + +//________________________________________________________________________ +void AliAnalysisTaskFilterSTEER::UserExec(Option_t */*option*/) +{ + + AliInfo("Filling Friends"); + + fESDInput = dynamic_cast(InputEvent()); // get the input ESD + fESDfriendInput = (AliESDfriend*)(fESDInput->FindListObject("AliESDfriend")); + if(!fESDInput) { + printf("AliAnalysisTaskFilterSTEER::Exec(): no ESD \n"); + return; + } + if(!fESDfriendInput) { + printf("AliAnalysisTaskFilterSTEER::Exec(): no ESDfriend \n"); + return; + } + // attach ESDfriend + + AliESDfriend* esdFriendOutput = (AliESDfriend*)ESDfriend(); + AliInfo(Form("Number of ESD tracks in input = %d ",fESDInput->GetNumberOfTracks())); + AliInfo(Form("Number of tracks in input friends = %d ",fESDfriendInput->GetNumberOfTracks())); + AliInfo(Form("Number of tracks in output friendsNew before filtering = %d ",esdFriendOutput->GetNumberOfTracks())); + + // + // select all for fraction of events - event selected randomly + // event number 0 always stored - to define the friends layout + // + AliESDfriendTrack* tNull = new AliESDfriendTrack(); + if (fESDInput->GetEventNumberInFile()==0 || gRandom->Rndm()GetEventNumberInFile())); + for (Int_t i = 0; i< fESDInput->GetNumberOfTracks(); i++){ + // keep friend + AliESDfriendTrack* tOld = (AliESDfriendTrack*)fESDfriendInput->GetTrack(i); + if (tOld) AddFriendTrackAt(tOld,i); + else AddFriendTrackAt(tNull,i); + } + } + // + // + // + for (Int_t i = 0; i< fESDInput->GetNumberOfTracks(); i++){ + // keep friend + AliESDfriendTrack* tOld = (AliESDfriendTrack*)fESDfriendInput->GetTrack(i); + Bool_t isOK=kFALSE; + if (tOld) + if (tOld->GetTPCOut()) + if (TMath::Abs(tOld->GetTPCOut()->Pt())>fPtCut) isOK=kTRUE; + if (isOK){ + AliInfo(Form("Keeping %d-th track",i)); + AddFriendTrackAt(tOld,i); + }else{ + AddFriendTrackAt(tNull,i); + } + } + AliInfo(Form("Number of tracks in output friendsNew after filtering = %d ",esdFriendOutput->GetNumberOfTracks())); + AliInfo(Form("Number of tracks in output friendsNew after filtering with GetEntries() = %d ",esdFriendOutput->GetEntriesInTracks())); + return; +} + +//________________________________________________________________________ +void AliAnalysisTaskFilterSTEER::Terminate(Option_t */*option*/) +{ + // Terminate analysis + // + AliDebug(2,"AliAnalysisTaskFilterSTEER: Terminate() \n"); + + return; +} +//________________________________________________________________________ +Bool_t AliAnalysisTaskFilterSTEER::UserSelectESDfriendForCurrentEvent() +{ + // + // Selecting or discarding current event + // + return kTRUE; +} diff --git a/ANALYSIS/AliAnalysisTaskFilterSTEER.h b/ANALYSIS/AliAnalysisTaskFilterSTEER.h new file mode 100644 index 00000000000..62afef299f2 --- /dev/null +++ b/ANALYSIS/AliAnalysisTaskFilterSTEER.h @@ -0,0 +1,46 @@ +#ifndef ALIANALYSISTASKFILTERSTEER_H +#define ALIANALYSISTASKFILTERSTEER_H + +/* Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/*$Id$*/ + +//************************************************************************* +// Class AliAnalysisTaskFilterSTEER +// +//************************************************************************* + +#include "AliAnalysisTaskFilter.h" + +class AliAnalysisTaskFilterSTEER : public AliAnalysisTaskFilter +{ + public: + + AliAnalysisTaskFilterSTEER(); + AliAnalysisTaskFilterSTEER(const char *name, Double_t ptCut, Double_t fractionCut); + virtual ~AliAnalysisTaskFilterSTEER(); + + // Implementation of interface methods + virtual void UserCreateOutputObjects(); + virtual Bool_t UserSelectESDfriendForCurrentEvent(); + virtual void Init(); + virtual void LocalInit() {Init();} + virtual void UserExec(Option_t *option); + virtual void Terminate(Option_t *option); + + private: + + AliAnalysisTaskFilterSTEER(const AliAnalysisTaskFilterSTEER &); + AliAnalysisTaskFilterSTEER& operator=(const AliAnalysisTaskFilterSTEER&); + + Double_t fPtCut; // pt cut + Double_t fKeepFraction; // fraction of tracks to keep + // + AliESDEvent *fESDInput; // ESD input object + AliESDfriend *fESDfriendInput; // ESD input friend object + ClassDef(AliAnalysisTaskFilterSTEER,1); +}; + +#endif + diff --git a/ANALYSIS/libANALYSIScalib.pkg b/ANALYSIS/libANALYSIScalib.pkg index 0f84553e914..9c381b1e487 100644 --- a/ANALYSIS/libANALYSIScalib.pkg +++ b/ANALYSIS/libANALYSIScalib.pkg @@ -4,6 +4,7 @@ SRCS = \ AliAnalysisTaskFilter.cxx \ AliAnalysisTaskFilterFriend.cxx \ AliAnalysisTaskFilterFriendSecond.cxx \ + AliAnalysisTaskFilterSTEER.cxx \ AliAnalysisTaskAddObject.cxx -- 2.43.0