]>
Commit | Line | Data |
---|---|---|
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 | |
32 | ClassImp(AliESDInputHandler) | |
33 | ||
34 | //______________________________________________________________________________ | |
6989bff3 | 35 | AliESDInputHandler::AliESDInputHandler() : |
36 | AliInputEventHandler(), | |
0cd61c1d | 37 | fEvent(0x0), |
38 | fBranches("") | |
d3dd3d14 | 39 | { |
40 | // default constructor | |
41 | } | |
42 | ||
43 | //______________________________________________________________________________ | |
44 | AliESDInputHandler::~AliESDInputHandler() | |
45 | { | |
6989bff3 | 46 | // destructor |
47 | // delete fEvent; | |
d3dd3d14 | 48 | } |
49 | ||
50 | //______________________________________________________________________________ | |
51 | AliESDInputHandler::AliESDInputHandler(const char* name, const char* title): | |
300d5701 | 52 | AliInputEventHandler(name, title), fEvent(0x0), fBranches("") |
d3dd3d14 | 53 | { |
54 | } | |
55 | ||
300d5701 | 56 | Bool_t AliESDInputHandler::Init(TTree* tree, Option_t* /*opt*/) |
d3dd3d14 | 57 | { |
300d5701 | 58 | // Initialisation necessary for each new tree |
59 | fTree = tree; | |
60 | ||
6073f8c9 | 61 | if (!fTree) return kFALSE; |
d3dd3d14 | 62 | // Get pointer to ESD event |
300d5701 | 63 | SwitchOffBranches(); |
64 | ||
60996693 | 65 | if (fEvent) { |
66 | delete fEvent; | |
67 | fEvent = 0; | |
6989bff3 | 68 | } |
60996693 | 69 | fEvent = new AliESDEvent(); |
70 | ||
71 | fEvent->ReadFromTree(fTree); | |
d3dd3d14 | 72 | return kTRUE; |
73 | } | |
74 | ||
ed97dc98 | 75 | Bool_t AliESDInputHandler::BeginEvent(Long64_t /*entry*/) |
d3dd3d14 | 76 | { |
77 | // Copy from old to new format if necessary | |
d7749dec | 78 | AliESD* old = ((AliESDEvent*) fEvent)->GetAliESDOld(); |
79 | if (old) { | |
d3dd3d14 | 80 | ((AliESDEvent*)fEvent)->CopyFromOldESD(); |
81 | old->Reset(); | |
d7749dec | 82 | } |
83 | return kTRUE; | |
d3dd3d14 | 84 | } |
85 | ||
6989bff3 | 86 | Bool_t AliESDInputHandler::FinishEvent(){ |
d7749dec | 87 | if(fEvent)fEvent->Reset(); |
6989bff3 | 88 | return kTRUE; |
89 | } | |
90 | ||
300d5701 | 91 | void AliESDInputHandler::SwitchOffBranches() const { |
92 | // | |
93 | // Switch of branches on user request | |
94 | TObjArray * tokens = fBranches.Tokenize(" "); | |
95 | Int_t ntok = tokens->GetEntries(); | |
96 | for (Int_t i = 0; i < ntok; i++) { | |
97 | TString str = ((TObjString*) tokens->At(i))->GetString(); | |
0cf1bd5a | 98 | if (str.Length() == 0) |
99 | continue; | |
300d5701 | 100 | fTree->SetBranchStatus(Form("%s%s%s","*", str.Data(), "*"), 0); |
101 | AliInfo(Form("Branch %s switched off \n", str.Data())); | |
102 | } | |
103 | } |