1 /**************************************************************************
2 * Copyright(c) 1998-2007, 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 //-------------------------------------------------------------------------
19 // Event handler for ESD input
20 // Author: Andreas Morsch, CERN
21 //-------------------------------------------------------------------------
25 #include <TObjString.h>
27 #include "AliESDInputHandler.h"
28 #include "AliESDEvent.h"
32 ClassImp(AliESDInputHandler)
34 //______________________________________________________________________________
35 AliESDInputHandler::AliESDInputHandler() :
36 AliInputEventHandler(),
41 // default constructor
44 //______________________________________________________________________________
45 AliESDInputHandler::~AliESDInputHandler()
51 //______________________________________________________________________________
52 AliESDInputHandler::AliESDInputHandler(const char* name, const char* title):
53 AliInputEventHandler(name, title), fEvent(0x0), fBranches(""), fBranchesOn("")
57 Bool_t AliESDInputHandler::Init(TTree* tree, Option_t* /*opt*/)
59 // Initialisation necessary for each new tree
62 if (!fTree) return kFALSE;
63 // Get pointer to ESD event
71 fEvent = new AliESDEvent();
73 fEvent->ReadFromTree(fTree);
77 Bool_t AliESDInputHandler::BeginEvent(Long64_t /*entry*/)
79 // Copy from old to new format if necessary
80 AliESD* old = ((AliESDEvent*) fEvent)->GetAliESDOld();
82 ((AliESDEvent*)fEvent)->CopyFromOldESD();
88 Bool_t AliESDInputHandler::FinishEvent(){
89 if(fEvent)fEvent->Reset();
93 void AliESDInputHandler::SwitchOffBranches() const {
95 // Switch of branches on user request
96 TObjArray * tokens = fBranches.Tokenize(" ");
97 Int_t ntok = tokens->GetEntries();
98 for (Int_t i = 0; i < ntok; i++) {
99 TString str = ((TObjString*) tokens->At(i))->GetString();
100 if (str.Length() == 0)
102 fTree->SetBranchStatus(Form("%s%s%s","*", str.Data(), "*"), 0);
103 AliInfo(Form("Branch %s switched off \n", str.Data()));
107 void AliESDInputHandler::SwitchOnBranches() const {
109 // Switch of branches on user request
110 TObjArray * tokens = fBranchesOn.Tokenize(" ");
111 Int_t ntok = tokens->GetEntries();
113 for (Int_t i = 0; i < ntok; i++) {
114 TString str = ((TObjString*) tokens->At(i))->GetString();
115 if (str.Length() == 0)
117 fTree->SetBranchStatus(Form("%s%s%s","*", str.Data(), "*"), 1);
118 AliInfo(Form("Branch %s switched on \n", str.Data()));