]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliAODInputHandler.cxx
Added AddTrackParams() method for convenience + some comments
[u/mrichter/AliRoot.git] / STEER / AliAODInputHandler.cxx
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 AOD input 
20 //     Author: Andreas Morsch, CERN
21 //-------------------------------------------------------------------------
22
23 #include <TTree.h>
24 #include <TList.h>
25 #include <TNamed.h>
26
27 #include "AliAODInputHandler.h"
28 #include "AliAODEvent.h"
29
30 ClassImp(AliAODInputHandler)
31
32 static Option_t *gAODDataType = "AOD";
33
34 //______________________________________________________________________________
35 AliAODInputHandler::AliAODInputHandler() :
36     AliInputEventHandler(),
37     fEvent(0),
38     fFriends(new TList())
39 {
40   // Default constructor
41 }
42
43 //______________________________________________________________________________
44 AliAODInputHandler::AliAODInputHandler(const char* name, const char* title):
45   AliInputEventHandler(name, title),
46   fEvent(0),
47   fFriends(new TList())
48 {
49     // Constructor
50 }
51
52 //______________________________________________________________________________
53 AliAODInputHandler::~AliAODInputHandler() 
54 {
55 // Destructor
56     fFriends->Delete();
57 }
58
59
60 Bool_t AliAODInputHandler::Init(TTree* tree, Option_t* /*opt*/)
61 {
62     // Initialisation necessary for each new tree
63     fTree = tree;
64     TIter next(fFriends);
65     TNamed* obj;
66     
67     while((obj = (TNamed*)next())) {
68         if (fTree->GetTree()) {
69             (fTree->GetTree())->AddFriend("aodTree", obj->GetName());
70         } else {
71             fTree->AddFriend("aodTree", obj->GetName());
72         }
73     }
74     
75     if (!fTree) return kFALSE;
76     // Get pointer to AOD event
77     if (fEvent) {
78       delete fEvent;
79       fEvent = 0;
80     }
81     fEvent = new AliAODEvent();
82
83     fEvent->ReadFromTree(fTree);
84     return kTRUE;
85 }
86
87 Bool_t AliAODInputHandler::BeginEvent(Long64_t /*entry*/)
88 {
89     //
90     //if (fTree) fTree->BranchRef();
91     return kTRUE;
92 }
93
94 void AliAODInputHandler::AddFriend(char* filename)
95 {
96     // Add a friend tree 
97     TNamed* obj = new TNamed(filename, filename);
98     fFriends->Add(obj);
99 }
100
101 Option_t *AliAODInputHandler::GetDataType() const
102 {
103 // Returns handled data type.
104    return gAODDataType;
105 }