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>
26 #include <TProcessID.h>
28 #include "AliESDInputHandler.h"
29 #include "AliESDEvent.h"
33 ClassImp(AliESDInputHandler)
35 //______________________________________________________________________________
36 AliESDInputHandler::AliESDInputHandler() :
37 AliInputEventHandler(),
42 // default constructor
45 //______________________________________________________________________________
46 AliESDInputHandler::~AliESDInputHandler()
52 //______________________________________________________________________________
53 AliESDInputHandler::AliESDInputHandler(const char* name, const char* title):
54 AliInputEventHandler(name, title), fEvent(0x0), fBranches(""), fBranchesOn("")
59 Bool_t AliESDInputHandler::Init(TTree* tree, Option_t* /*opt*/)
61 // Initialisation necessary for each new tree
64 if (!fTree) return kFALSE;
65 // Get pointer to ESD event
73 fEvent = new AliESDEvent();
75 fEvent->ReadFromTree(fTree);
79 Bool_t AliESDInputHandler::BeginEvent(Long64_t /*entry*/)
81 // Copy from old to new format if necessary
82 AliESD* old = ((AliESDEvent*) fEvent)->GetAliESDOld();
84 ((AliESDEvent*)fEvent)->CopyFromOldESD();
90 Bool_t AliESDInputHandler::FinishEvent()
93 if(fEvent)fEvent->Reset();
97 void AliESDInputHandler::SwitchOffBranches() const {
99 // Switch of branches on user request
100 TObjArray * tokens = fBranches.Tokenize(" ");
101 Int_t ntok = tokens->GetEntries();
102 for (Int_t i = 0; i < ntok; i++) {
103 TString str = ((TObjString*) tokens->At(i))->GetString();
104 if (str.Length() == 0)
106 fTree->SetBranchStatus(Form("%s%s%s","*", str.Data(), "*"), 0);
107 AliInfo(Form("Branch %s switched off \n", str.Data()));
111 void AliESDInputHandler::SwitchOnBranches() const {
113 // Switch of branches on user request
114 TObjArray * tokens = fBranchesOn.Tokenize(" ");
115 Int_t ntok = tokens->GetEntries();
117 for (Int_t i = 0; i < ntok; i++) {
118 TString str = ((TObjString*) tokens->At(i))->GetString();
119 if (str.Length() == 0)
121 fTree->SetBranchStatus(Form("%s%s%s","*", str.Data(), "*"), 1);
122 AliInfo(Form("Branch %s switched on \n", str.Data()));