]>
Commit | Line | Data |
---|---|---|
ec4af4c1 | 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 | // Implementation of the Virtual Event Handler Interface for AOD | |
20 | // Author: Andreas Morsch, CERN | |
21 | //------------------------------------------------------------------------- | |
22 | ||
052994fb | 23 | |
ec4af4c1 | 24 | #include <TTree.h> |
e910dd36 | 25 | #include <TFile.h> |
26 | ||
ec4af4c1 | 27 | #include "AliAODHandler.h" |
28 | #include "AliAODEvent.h" | |
29 | ||
30 | ClassImp(AliAODHandler) | |
31 | ||
32 | //______________________________________________________________________________ | |
33 | AliAODHandler::AliAODHandler() : | |
f3214a54 | 34 | AliVEventHandler(), |
ec4af4c1 | 35 | fAODEvent(NULL), |
e910dd36 | 36 | fTreeA(NULL), |
37 | fFileA(NULL), | |
38 | fName("") | |
ec4af4c1 | 39 | { |
40 | // default constructor | |
41 | } | |
42 | ||
43 | //______________________________________________________________________________ | |
44 | AliAODHandler::AliAODHandler(const char* name, const char* title): | |
f3214a54 | 45 | AliVEventHandler(name, title), |
ec4af4c1 | 46 | fAODEvent(NULL), |
e910dd36 | 47 | fTreeA(NULL), |
48 | fFileA(NULL), | |
49 | fName("") | |
ec4af4c1 | 50 | { |
51 | } | |
52 | ||
53 | //______________________________________________________________________________ | |
54 | AliAODHandler::~AliAODHandler() | |
55 | { | |
56 | // destructor | |
57 | } | |
58 | ||
59 | ||
e910dd36 | 60 | Bool_t AliAODHandler::InitIO(Option_t* opt) |
ec4af4c1 | 61 | { |
62 | // Initialize IO | |
e910dd36 | 63 | // |
64 | // Create the AODevent object | |
ec4af4c1 | 65 | fAODEvent = new AliAODEvent(); |
66 | fAODEvent->CreateStdContent(); | |
e910dd36 | 67 | // |
68 | // File opening according to execution mode | |
69 | ||
70 | if (!(strcmp(opt, "proof"))) { | |
71 | // proof | |
954526ed | 72 | CreateTree(0); |
e910dd36 | 73 | } else { |
74 | // local and grid | |
75 | fFileA = new TFile(fName, "RECREATE"); | |
954526ed | 76 | CreateTree(1); |
e910dd36 | 77 | } |
ec4af4c1 | 78 | return kTRUE; |
79 | } | |
80 | ||
5f380da9 | 81 | Bool_t AliAODHandler::FinishEvent() |
ec4af4c1 | 82 | { |
83 | // Fill data structures | |
ec4af4c1 | 84 | FillTree(); |
85 | fAODEvent->ClearStd(); | |
86 | ||
87 | return kTRUE; | |
88 | } | |
89 | ||
90 | Bool_t AliAODHandler::Terminate() | |
91 | { | |
92 | // Terminate | |
93 | AddAODtoTreeUserInfo(); | |
94 | return kTRUE; | |
95 | } | |
96 | ||
97 | Bool_t AliAODHandler::TerminateIO() | |
98 | { | |
99 | // Terminate IO | |
21501411 | 100 | if (fFileA) { |
101 | fFileA->Close(); | |
102 | delete fFileA; | |
103 | } | |
ec4af4c1 | 104 | return kTRUE; |
105 | } | |
106 | ||
107 | ||
954526ed | 108 | void AliAODHandler::CreateTree(Int_t flag) |
ec4af4c1 | 109 | { |
110 | // Creates the AOD Tree | |
f3214a54 | 111 | fTreeA = new TTree("aodTree", "AliAOD tree"); |
ec4af4c1 | 112 | fTreeA->Branch(fAODEvent->GetList()); |
954526ed | 113 | if (flag == 0) fTreeA->SetDirectory(0); |
ec4af4c1 | 114 | } |
115 | ||
116 | void AliAODHandler::FillTree() | |
117 | { | |
118 | // Fill the AOD Tree | |
119 | fTreeA->Fill(); | |
120 | } | |
121 | ||
122 | ||
123 | void AliAODHandler::AddAODtoTreeUserInfo() | |
124 | { | |
125 | // Add aod event to tree user info | |
126 | fTreeA->GetUserInfo()->Add(fAODEvent); | |
127 | } |