]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliESDInputHandler.cxx
remove bad modules BEFORE cleaning digits
[u/mrichter/AliRoot.git] / STEER / AliESDInputHandler.cxx
CommitLineData
d3dd3d14 1/**************************************************************************
2 * Copyright(c) 1998-2007, 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// Event handler for ESD input
20// Author: Andreas Morsch, CERN
21//-------------------------------------------------------------------------
22
933fd60f 23#include <TTree.h>
300d5701 24#include <TString.h>
25#include <TObjString.h>
d3dd3d14 26
27#include "AliESDInputHandler.h"
28#include "AliESDEvent.h"
29#include "AliESD.h"
300d5701 30#include "AliLog.h"
d3dd3d14 31
32ClassImp(AliESDInputHandler)
33
34//______________________________________________________________________________
6989bff3 35AliESDInputHandler::AliESDInputHandler() :
36 AliInputEventHandler(),
0cd61c1d 37 fEvent(0x0),
865d620a 38 fBranches(""),
39 fBranchesOn("")
d3dd3d14 40{
41 // default constructor
42}
43
44//______________________________________________________________________________
45AliESDInputHandler::~AliESDInputHandler()
46{
6989bff3 47 // destructor
48 // delete fEvent;
d3dd3d14 49}
50
51//______________________________________________________________________________
52AliESDInputHandler::AliESDInputHandler(const char* name, const char* title):
865d620a 53 AliInputEventHandler(name, title), fEvent(0x0), fBranches(""), fBranchesOn("")
d3dd3d14 54{
55}
56
300d5701 57Bool_t AliESDInputHandler::Init(TTree* tree, Option_t* /*opt*/)
d3dd3d14 58{
300d5701 59 // Initialisation necessary for each new tree
60 fTree = tree;
61
6073f8c9 62 if (!fTree) return kFALSE;
d3dd3d14 63 // Get pointer to ESD event
300d5701 64 SwitchOffBranches();
3858dd64 65 SwitchOnBranches();
300d5701 66
60996693 67 if (fEvent) {
68 delete fEvent;
69 fEvent = 0;
6989bff3 70 }
60996693 71 fEvent = new AliESDEvent();
72
73 fEvent->ReadFromTree(fTree);
d3dd3d14 74 return kTRUE;
75}
76
ed97dc98 77Bool_t AliESDInputHandler::BeginEvent(Long64_t /*entry*/)
d3dd3d14 78{
79 // Copy from old to new format if necessary
d7749dec 80 AliESD* old = ((AliESDEvent*) fEvent)->GetAliESDOld();
81 if (old) {
d3dd3d14 82 ((AliESDEvent*)fEvent)->CopyFromOldESD();
83 old->Reset();
d7749dec 84 }
85 return kTRUE;
d3dd3d14 86}
87
6989bff3 88Bool_t AliESDInputHandler::FinishEvent(){
d7749dec 89 if(fEvent)fEvent->Reset();
6989bff3 90 return kTRUE;
91}
92
300d5701 93void AliESDInputHandler::SwitchOffBranches() const {
94 //
95 // Switch of branches on user request
3858dd64 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)
101 continue;
102 fTree->SetBranchStatus(Form("%s%s%s","*", str.Data(), "*"), 0);
103 AliInfo(Form("Branch %s switched off \n", str.Data()));
104 }
105}
106
107void AliESDInputHandler::SwitchOnBranches() const {
108 //
109 // Switch of branches on user request
110 TObjArray * tokens = fBranchesOn.Tokenize(" ");
300d5701 111 Int_t ntok = tokens->GetEntries();
3858dd64 112
300d5701 113 for (Int_t i = 0; i < ntok; i++) {
3858dd64 114 TString str = ((TObjString*) tokens->At(i))->GetString();
115 if (str.Length() == 0)
116 continue;
117 fTree->SetBranchStatus(Form("%s%s%s","*", str.Data(), "*"), 1);
118 AliInfo(Form("Branch %s switched on \n", str.Data()));
300d5701 119 }
120}