]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ANALYSIS/AliAnalysisTaskME.cxx
Added support for strip range calib objects
[u/mrichter/AliRoot.git] / ANALYSIS / AliAnalysisTaskME.cxx
CommitLineData
b81460ad 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#include <TROOT.h>
19#include <TSystem.h>
20#include <TInterpreter.h>
21#include <TChain.h>
22#include <TFile.h>
23#include <TList.h>
24
25#include "AliAnalysisTaskME.h"
26#include "AliAnalysisManager.h"
27#include "AliAODEvent.h"
28#include "AliAODHandler.h"
29#include "AliMultiAODInputHandler.h"
30#include "AliLog.h"
31
32
33ClassImp(AliAnalysisTaskME)
34
35////////////////////////////////////////////////////////////////////////
36
37AliAnalysisTaskME::AliAnalysisTaskME():
38 AliAnalysisTask(),
39 fDebug(0),
40 fEntry(0),
41 fFreshBufferOnly(kFALSE),
42 fInputHandler(0x0),
43 fOutputAOD(0x0),
44 fTreeA(0x0)
45{
46 // Default constructor
47}
48
49AliAnalysisTaskME::AliAnalysisTaskME(const char* name):
50 AliAnalysisTask(name, "AnalysisTaskME"),
51 fDebug(0),
52 fEntry(0),
53 fFreshBufferOnly(kFALSE),
54 fInputHandler(0x0),
55 fOutputAOD(0x0),
56 fTreeA(0x0)
57{
58 // Default constructor
59 DefineInput (0, TChain::Class());
60 DefineOutput(0, TTree::Class());
61}
62
63AliAnalysisTaskME::AliAnalysisTaskME(const AliAnalysisTaskME& obj):
64 AliAnalysisTask(obj),
65 fDebug(0),
66 fEntry(0),
67 fFreshBufferOnly(kFALSE),
68 fInputHandler(0x0),
69 fOutputAOD(0x0),
70 fTreeA(0x0)
71{
72// Copy constructor
73 fDebug = obj.fDebug;
74 fEntry = obj.fEntry;
75 fInputHandler = obj.fInputHandler;
76 fOutputAOD = obj.fOutputAOD;
77 fTreeA = obj.fTreeA;
78}
79
80
81AliAnalysisTaskME& AliAnalysisTaskME::operator=(const AliAnalysisTaskME& other)
82{
83// Assignment
84 AliAnalysisTask::operator=(other);
85 fDebug = other.fDebug;
86 fEntry = other.fEntry;
87 fFreshBufferOnly = other.fFreshBufferOnly;
88 fInputHandler = other.fInputHandler;
89 fOutputAOD = other.fOutputAOD;
90 fTreeA = other.fTreeA;
91 return *this;
92}
93
94
95void AliAnalysisTaskME::ConnectInputData(Option_t* /*option*/)
96{
97// Connect the input data
98 if (fDebug > 1) printf("AnalysisTaskME::ConnectInputData() \n");
99//
100// Multi AOD
101//
102 fInputHandler = dynamic_cast<AliMultiAODInputHandler*>
103 ((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
104 if (fInputHandler == 0)
105 AliFatal("Event Handler has to be MultiAODHandler !");
106}
107
108void AliAnalysisTaskME::CreateOutputObjects()
109{
110// Create the output container
111//
112// Default AOD
113 if (fDebug > 1) printf("AnalysisTaskME::CreateOutPutData() \n");
114
115 AliAODHandler* handler = (AliAODHandler*)
116 ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
117
118 if (handler) {
119 fOutputAOD = handler->GetAOD();
120 fTreeA = handler->GetTree();
121 } else {
122 AliWarning("No AOD Event Handler connected.") ;
123 }
124 UserCreateOutputObjects();
125}
126
127void AliAnalysisTaskME::Exec(Option_t* option)
128{
129//
130// Exec analysis of one event
131 if (fDebug > 1) AliInfo("AliAnalysisTaskME::Exec() \n");
132 if( fInputHandler )
133 fEntry = fInputHandler->GetReadEntry();
134 if ( !((Entry()-1)%100) && fDebug > 0)
135 AliInfo(Form("%s ----> Processing event # %lld", CurrentFileName(), Entry()));
136
137// Call the user analysis
138 if (fInputHandler->IsBufferReady()) {
139 if ((fFreshBufferOnly && fInputHandler->IsFreshBuffer()) || !fFreshBufferOnly)
140 {
141 UserExec(option);
142 PostData(0, fTreeA);
143 }
144 }
145}
146
147const char* AliAnalysisTaskME::CurrentFileName()
148{
149// Returns the current file name
150 if(fInputHandler )
151 return fInputHandler->GetTree()->GetCurrentFile()->GetName();
152 else return "";
153}
154
155void AliAnalysisTaskME::AddAODBranch(const char* cname, void* addobj)
156{
157 // Add a new branch to the aod tree
158 AliAODHandler* handler = (AliAODHandler*)
159 ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
160 if (handler) {
161 handler->AddBranch(cname, addobj);
162 }
163}
164
165AliAODEvent* AliAnalysisTaskME::GetEvent(Int_t iev)
166{
167 // Get an event from the input handler
168 return (fInputHandler->GetEvent(iev));
169}
170