]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/global/physics/AliHLTAnaManagerComponent.cxx
Fix for coverity 24987
[u/mrichter/AliRoot.git] / HLT / global / physics / AliHLTAnaManagerComponent.cxx
CommitLineData
b9f1d917 1//-*- Mode: C++ -*-
2// $Id: AliHLTAnaManagerComponent.cxx $
3/**************************************************************************
4 * This file is property of and copyright by the ALICE HLT Project *
5 * ALICE Experiment at CERN, All rights reserved. *
6 * *
7 * Primary Authors: David Rohr, Jens Wiechula, C. Zampolli *
8 * *
9 * Permission to use, copy, modify and distribute this software and its *
10 * documentation strictly for non-commercial purposes is hereby granted *
11 * without fee, provided that the above copyright notice appears in all *
12 * copies and that both the copyright notice and this permission notice *
13 * appear in the supporting documentation. The authors make no claims *
14 * about the suitability of this software for any purpose. It is *
15 * provided "as is" without express or implied warranty. *
16 **************************************************************************/
17
18/** @file AliHLTAnaManagerComponent.cxx
19 @author David Rohr, Jens Wiechula, C. Zampolli
20 @brief Component for Testing Analysis Manager inside HLT component
21*/
22
23#include "TMap.h"
24#include "TSystem.h"
25#include "TTimeStamp.h"
26#include "TObjString.h"
27#include "TH1F.h"
28#include "TList.h"
29#include "AliESDtrackCuts.h"
afdb0e0d 30#include "AliESDEvent.h"
b9f1d917 31#include "AliHLTErrorGuard.h"
32#include "AliHLTDataTypes.h"
33#include "AliHLTAnaManagerComponent.h"
34#include "AliHLTITSClusterDataFormat.h"
35#include "AliAnalysisManager.h"
36#include "AliHLTTestInputHandler.h"
37#include "AliAnalysisTaskPt.h"
38#include "AliAnalysisDataContainer.h"
39#include "TTree.h"
40
41using namespace std;
42
43/** ROOT macro for the implementation of ROOT specific class methods */
44ClassImp(AliHLTAnaManagerComponent)
45
46/*
47 * ---------------------------------------------------------------------------------
48 * Constructor / Destructor
49 * ---------------------------------------------------------------------------------
50 */
51
52// #################################################################################
53AliHLTAnaManagerComponent::AliHLTAnaManagerComponent() :
54 AliHLTProcessor(),
55 fUID(0),
56 fAnalysisManager(NULL),
afdb0e0d 57 fInputHandler(NULL){
b9f1d917 58 // an example component which implements the ALICE HLT processor
59 // interface and does some analysis on the input raw data
60 //
61 // see header file for class documentation
62 // or
63 // refer to README to build package
64 // or
65 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
66 //
67 // NOTE: all helper classes should be instantiated in DoInit()
68}
69
70// #################################################################################
71AliHLTAnaManagerComponent::~AliHLTAnaManagerComponent() {
72 // see header file for class documentation
73}
74
75/*
76 * ---------------------------------------------------------------------------------
77 * Public functions to implement AliHLTComponent's interface.
78 * These functions are required for the registration process
79 * ---------------------------------------------------------------------------------
80 */
81
82// #################################################################################
83const Char_t* AliHLTAnaManagerComponent::GetComponentID() {
84 // see header file for class documentation
85 return "AnaManagerComponent";
86}
87
88// #################################################################################
89void AliHLTAnaManagerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
90 // see header file for class documentation
91 list.push_back(kAliHLTDataTypeESDObject|kAliHLTDataOriginAny);
92 list.push_back(kAliHLTDataTypeClusters|kAliHLTDataOriginITSSPD);
93 list.push_back(kAliHLTDataTypeESDContent|kAliHLTDataOriginVZERO);
949fa831 94 list.push_back(kAliHLTDataTypeESDfriendObject|kAliHLTDataOriginAny);
b9f1d917 95}
96
97// #################################################################################
98AliHLTComponentDataType AliHLTAnaManagerComponent::GetOutputDataType() {
99 // see header file for class documentation
100 return kAliHLTDataTypeTObject|kAliHLTDataOriginHLT;
101}
102
103// #################################################################################
104void AliHLTAnaManagerComponent::GetOutputDataSize( ULong_t& constBase, Double_t& inputMultiplier ) {
105 // see header file for class documentation
106 constBase = 100000;
107 inputMultiplier = 0.5;
108}
109
110// #################################################################################
111void AliHLTAnaManagerComponent::GetOCDBObjectDescription( TMap* const targetMap) {
112 // see header file for class documentation
113
114 if (!targetMap) return;
949fa831 115 /* targetMap->Add(new TObjString("HLT/ConfigGlobal/MultiplicityCorrelations"),
b9f1d917 116 new TObjString("configuration object"));
117 targetMap->Add(new TObjString("HLT/ConfigGlobal/MultiplicityCorrelationsCentrality"),
118 new TObjString("centrality configuration object"));
949fa831 119 */
b9f1d917 120 return;
121}
122
123// #################################################################################
124AliHLTComponent* AliHLTAnaManagerComponent::Spawn() {
125 // see header file for class documentation
126 return new AliHLTAnaManagerComponent;
127}
128
129/*
130 * ---------------------------------------------------------------------------------
131 * Protected functions to implement AliHLTComponent's interface.
132 * These functions provide initialization as well as the actual processing
133 * capabilities of the component.
134 * ---------------------------------------------------------------------------------
135 */
136
137// #################################################################################
afdb0e0d 138Int_t AliHLTAnaManagerComponent::DoInit( Int_t /*argc*/, const Char_t** /*argv*/ ) {
b9f1d917 139 // see header file for class documentation
140 printf("AliHLTAnaManagerComponent::DoInit\n");
141
142 Int_t iResult=0;
143
afdb0e0d 144 Printf("----> AliHLTAnaManagerComponent::DoInit");
b9f1d917 145 fAnalysisManager = new AliAnalysisManager;
146 fInputHandler = new AliHLTTestInputHandler;
147 fAnalysisManager->SetInputEventHandler(fInputHandler);
148 fAnalysisManager->SetExternalLoop(kTRUE);
149
150 AliAnalysisTaskPt *task = new AliAnalysisTaskPt("TaskPt");
82245e04 151 printf("-----> AliHLTAnaManagerComponent: here we set the usage of the friends to %d\n", (Int_t)task->GetUseFriends());
828c4c08 152 task->SetUseFriends(kTRUE);
b9f1d917 153 fAnalysisManager->AddTask(task);
154 AliAnalysisDataContainer *cinput = fAnalysisManager->GetCommonInputContainer();
155 Printf("Defining output file");
949fa831 156 AliAnalysisDataContainer *coutput1 = fAnalysisManager->CreateContainer("pt", TList::Class(),
b9f1d917 157 AliAnalysisManager::kOutputContainer, "Pt.ESD.root");
158
159 // connect containers
afdb0e0d 160 Printf("---> Connecting input...");
161 fAnalysisManager->ConnectInput (task, 0, cinput );
162 Printf("---> ...connected.");
b9f1d917 163 Printf("---> Connecting output...");
164 fAnalysisManager->ConnectOutput (task, 0, coutput1);
165 Printf("---> ...connected.");
166
afdb0e0d 167 Printf("----> Calling InitAnalysis");
b9f1d917 168 fAnalysisManager->InitAnalysis();
afdb0e0d 169 Printf("----> Done.");
170 Printf("----> Calling StartAnalysis");
b9f1d917 171 fAnalysisManager->StartAnalysis("local", (TTree*)new TTree);
afdb0e0d 172 //fAnalysisManager->StartAnalysis("local", (TTree*)NULL);
173 Printf("----> Done.");
b9f1d917 174
175 return iResult;
176}
177
178
179
180// #################################################################################
181Int_t AliHLTAnaManagerComponent::DoDeinit() {
182 // see header file for class documentation
183
184 fUID = 0;
185 fAnalysisManager->SetSkipTerminate(kTRUE);
186 fAnalysisManager->Terminate();
187
188 delete fAnalysisManager;
189
190 return 0;
191}
192
193// #################################################################################
194Int_t AliHLTAnaManagerComponent::DoEvent(const AliHLTComponentEventData& evtData,
195 AliHLTComponentTriggerData& /*trigData*/) {
196 // see header file for class documentation
197
198 printf("AliHLTAnaManagerComponent::DoEvent\n");
199 Int_t iResult=0;
200
201 // -- Only use data event
202 if (!IsDataEvent())
203 return 0;
204
205 if( fUID == 0 ){
206 TTimeStamp t;
207 fUID = ( gSystem->GetPid() + t.GetNanoSec())*10 + evtData.fEventID;
208 }
209
210 // -- Get ESD object
211 // -------------------
212 AliESDEvent *esdEvent = NULL;
949fa831 213 AliESDfriend *esdFriend = NULL;
b9f1d917 214 for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDObject); iter != NULL; iter = GetNextInputObject() ) {
215 esdEvent = dynamic_cast<AliESDEvent*>(const_cast<TObject*>( iter ) );
216 if( !esdEvent ){
217 HLTWarning("Wrong ESDEvent object received");
218 iResult = -1;
219 continue;
220 }
221 esdEvent->GetStdContent();
222 }
46131ab0 223 if (esdEvent) printf("----> ESDEvent %p has %d tracks: \n", esdEvent, esdEvent->GetNumberOfTracks());
224 else printf("----> No ESDEvent found\n");
949fa831 225 for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDfriendObject); iter != NULL; iter = GetNextInputObject() ) {
226 esdFriend = dynamic_cast<AliESDfriend*>(const_cast<TObject*>( iter ) );
227 if( !esdFriend ){
228 HLTWarning("Wrong ESDFriend object received");
229 iResult = -1;
230 continue;
231 }
232 }
1c8c3a82 233 if (esdFriend) printf("----> ESDFriend %p has %d tracks: \n", esdFriend, esdFriend->GetNumberOfTracks());
234 else printf("----> No ESDFriend found\n");
b9f1d917 235
949fa831 236 fAnalysisManager->InitInputData(esdEvent, esdFriend);
afdb0e0d 237 // fInputHandler->BeginEvent(0);
b9f1d917 238 fAnalysisManager->ExecAnalysis();
239 fInputHandler->FinishEvent();
240
241
242 // -- Send histlist
243// PushBack(dynamic_cast<TObject*>(fCorrObj->GetHistList()),
244// kAliHLTDataTypeTObject|kAliHLTDataOriginHLT,fUID);
245
246 return iResult;
247}
248
249// #################################################################################
250Int_t AliHLTAnaManagerComponent::Reconfigure(const Char_t* cdbEntry, const Char_t* chainId) {
251 // see header file for class documentation
252
253 Int_t iResult=0;
254 TString cdbPath;
255 if (cdbEntry) {
256 cdbPath=cdbEntry;
257 } else {
258 cdbPath="HLT/ConfigGlobal/";
259 cdbPath+=GetComponentID();
260 }
261
262 AliInfoClass(Form("reconfigure '%s' from entry %s%s", chainId, cdbPath.Data(), cdbEntry?"":" (default)"));
263 iResult=ConfigureFromCDBTObjString(cdbPath);
264
265 return iResult;
266}
267
268// #################################################################################
269Int_t AliHLTAnaManagerComponent::ReadPreprocessorValues(const Char_t* /*modules*/) {
270 // see header file for class documentation
271 ALIHLTERRORGUARD(5, "ReadPreProcessorValues not implemented for this component");
272 return 0;
273}
274