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