JETAN module
[u/mrichter/AliRoot.git] / JETAN / JETAN / AliAnalysisTaskJetsReader.cxx
CommitLineData
d89b8229 1/**************************************************************************
2 * Copyright(c) 1998-1999, 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// Analysis task for interfacing the jet reader with the analysis framework
20//
21// Author: magali.estienne@subatech.in2p3.fr
22// alexandre.shabetai@cern.ch
23//----------------------------------------------------------------
24
25#include <Riostream.h>
26#include <TROOT.h>
27#include <TInterpreter.h>
28#include <TTree.h>
29
30#include "AliAnalysisTaskJetsReader.h"
31#include "AliAnalysisManager.h"
32#include "AliJetReader.h"
33#include "AliAODEvent.h"
34#include "AliMCEvent.h"
35#include "AliJetCalTrk.h"
36
37ClassImp(AliAnalysisTaskJetsReader)
38
39////////////////////////////////////////////////////////////////////////
40
41AliAnalysisTaskJetsReader::AliAnalysisTaskJetsReader():
42 AliAnalysisTaskSE(),
43 fConfigFile("ConfigJetReaderAnalysis.C"),
44 fJetReader(0x0),
45 fReadAODFromOutput(0),
46 fReaderEvent(0x0),
47 fExchangeTree(0x0)
48{
49 // Default constructor
50}
51
52//----------------------------------------------------------------
53AliAnalysisTaskJetsReader::AliAnalysisTaskJetsReader(const char* name):
54 AliAnalysisTaskSE(name),
55 fConfigFile("ConfigJetReaderAnalysis.C"),
56 fJetReader(0x0),
57 fReadAODFromOutput(0),
58 fReaderEvent(0x0),
59 fExchangeTree(0x0)
60{
61 // Default constructor
62 DefineOutput(1, TTree::Class());
63
64}
65
66//----------------------------------------------------------------
67AliAnalysisTaskJetsReader::~AliAnalysisTaskJetsReader()
68{
69 // Destructor
70
71 if (fExchangeTree)
72 delete fExchangeTree;
73
74}
75
76//----------------------------------------------------------------
77void AliAnalysisTaskJetsReader::UserCreateOutputObjects()
78{
79 // Create the TTree to be exchanged between the reader and finder
80 //
81
82 if (fDebug > 1) printf("AnalysisTaskJetsReader::CreateOutPutData() \n");
83
84 fExchangeTree = new TTree("jets_ExchangeContainer","ExchangeTree");
85
86 fJetReader->InitTasks();
87
88 fReaderEvent = fJetReader->GetCalTrkEvent();
89
90 fExchangeTree->Branch("AliJetCalTrkEvent", &fReaderEvent);
91
92 PostData(1, fExchangeTree);
93
94}
95
96//----------------------------------------------------------------
97void AliAnalysisTaskJetsReader::Init()
98{
99 // Initialization
100 if (fDebug > 1) printf("AnalysisTaskJets::Init() \n");
101
102 // Call configuration file
103 if (fConfigFile.Length()) {
104 gROOT->LoadMacro(fConfigFile);
105 fJetReader = (AliJetReader*) gInterpreter->ProcessLine("ConfigJetReaderAnalysis()");
106 }
107
108}
109
110//----------------------------------------------------------------
111void AliAnalysisTaskJetsReader::UserExec(Option_t */*option*/)
112{
113
114 // Execute analysis for current event
115 //
116
117 // Clear current CalTrkEvent
118 fReaderEvent->Clear();
119
120 fExchangeTree->Reset();
121
122 // Give InputEvent to the reader
123 if (dynamic_cast<AliAODEvent*>(InputEvent()) != 0 && !fReadAODFromOutput) {
124 // AOD is input event..........................................V
125 fJetReader->SetInputEvent(InputEvent(), InputEvent(), MCEvent());
126 } else {
127 // AOD is read from output ....................................V
128 fJetReader->SetInputEvent(InputEvent(), AODEvent(), MCEvent());
129 }
130
131 // Process current event
132 fJetReader->ProcessEvent();
133
134 // Fill object to be exchanged between reader and finder tasks
135 fExchangeTree->Fill();
136
137 // Post the data
138 PostData(1, fExchangeTree);
139
140 return;
141
142}
143
144//----------------------------------------------------------------
145void AliAnalysisTaskJetsReader::Terminate(Option_t */*option*/)
146{
147 // Terminate analysis
148 if (fDebug > 1) printf("AnalysisJets: Terminate() \n");
149
150}
151