delete the temporary tree of clusters instead of Reset().
[u/mrichter/AliRoot.git] / HLT / VZERO / AliHLTVZERORecoComponent.cxx
CommitLineData
e7918895 1//-*- Mode: C++ -*-
2// $Id: AliHLTVZERORecoComponent.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: Jochen Thaeder <jochen@thaeder.de> *
8 * for The ALICE HLT Project. *
9 * *
10 * Permission to use, copy, modify and distribute this software and its *
11 * documentation strictly for non-commercial purposes is hereby granted *
12 * without fee, provided that the above copyright notice appears in all *
13 * copies and that both the copyright notice and this permission notice *
14 * appear in the supporting documentation. The authors make no claims *
15 * about the suitability of this software for any purpose. It is *
16 * provided "as is" without express or implied warranty. *
17 **************************************************************************/
18
19/** @file AliHLTVZERORecoComponent.cxx
20 @author Jochen Thaeder <jochen@thaeder.de>
21 @brief VZERO reconstruction component
22*/
23
24#if __GNUC__>= 3
25using namespace std;
26#endif
27
28#include "TTree.h"
29#include "TMap.h"
30#include "TObjString.h"
31
32#include "AliLog.h"
33#include "AliRunInfo.h"
34#include "AliGRPObject.h"
35#include "AliRawReaderMemory.h"
672f9506 36#include "AliGeomManager.h"
e7918895 37
38#include "AliVZERORecoParam.h"
39#include "AliVZEROReconstructor.h"
40
41#include "AliHLTErrorGuard.h"
42#include "AliHLTDataTypes.h"
43#include "AliHLTVZERORecoComponent.h"
44
45/** ROOT macro for the implementation of ROOT specific class methods */
46ClassImp(AliHLTVZERORecoComponent)
47
48/*
49 * ---------------------------------------------------------------------------------
50 * Constructor / Destructor
51 * ---------------------------------------------------------------------------------
52 */
53
54// #################################################################################
55AliHLTVZERORecoComponent::AliHLTVZERORecoComponent() :
56 AliHLTProcessor(),
57 fRunInfo(NULL),
58 fDigitsTree(NULL),
59 fVZERORecoParam(NULL),
60 fVZEROReconstructor(NULL),
61 fRawReader(NULL) {
62 // an example component which implements the ALICE HLT processor
63 // interface and does some analysis on the input raw data
64 //
65 // see header file for class documentation
66 // or
67 // refer to README to build package
68 // or
69 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
70 //
71 // NOTE: all helper classes should be instantiated in DoInit()
72}
73
74// #################################################################################
75AliHLTVZERORecoComponent::~AliHLTVZERORecoComponent() {
76 // see header file for class documentation
77}
78
79/*
80 * ---------------------------------------------------------------------------------
81 * Public functions to implement AliHLTComponent's interface.
82 * These functions are required for the registration process
83 * ---------------------------------------------------------------------------------
84 */
85
86// #################################################################################
87const Char_t* AliHLTVZERORecoComponent::GetComponentID() {
88 // see header file for class documentation
89 return "VZEROReconstruction";
90}
91
92// #################################################################################
93void AliHLTVZERORecoComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
94 // see header file for class documentation
95 list.push_back(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginVZERO);
96}
97
98// #################################################################################
99AliHLTComponentDataType AliHLTVZERORecoComponent::GetOutputDataType() {
100 // see header file for class documentation
101 return kAliHLTDataTypeESDContent|kAliHLTDataOriginVZERO;
102}
103
104// #################################################################################
105void AliHLTVZERORecoComponent::GetOutputDataSize( ULong_t& constBase, Double_t& inputMultiplier ) {
106 // see header file for class documentation
107 constBase = 1000;
108 inputMultiplier = 0.5;
109}
110
111// #################################################################################
112void AliHLTVZERORecoComponent::GetOCDBObjectDescription( TMap* const targetMap) {
113 // see header file for class documentation
114
115 if (!targetMap) return;
116 targetMap->Add(new TObjString("HLT/ConfigVZERO/VZEROReconstruction"),
117 new TObjString("configuration object"));
118
119 targetMap->Add(new TObjString("GRP/GRP/Data"),
120 new TObjString("GRP object - run information"));
121 targetMap->Add(new TObjString("GRP/CTP/CTPtiming"),
122 new TObjString("GRP object - CTP information"));
123 targetMap->Add(new TObjString("GRP/CTP/TimeAlign"),
124 new TObjString("GRP object - CTP information"));
125 targetMap->Add(new TObjString("GRP/Calib/LHCClockPhase"),
126 new TObjString("GRP object - time calibration"));
127
128 targetMap->Add(new TObjString("VZERO/Calib/Data"),
129 new TObjString("VZERO calibration object"));
130 targetMap->Add(new TObjString("VZERO/Calib/TimeDelays"),
131 new TObjString("VZERO calibration object"));
132 targetMap->Add(new TObjString("VZERO/Calib/TimeSlewing"),
133 new TObjString("VZERO calibration object"));
134
135 return;
136}
137
138// #################################################################################
139AliHLTComponent* AliHLTVZERORecoComponent::Spawn() {
140 // see header file for class documentation
141 return new AliHLTVZERORecoComponent;
142}
143
144/*
145 * ---------------------------------------------------------------------------------
146 * Protected functions to implement AliHLTComponent's interface.
147 * These functions provide initialization as well as the actual processing
148 * capabilities of the component.
149 * ---------------------------------------------------------------------------------
150 */
151
152// #################################################################################
153Int_t AliHLTVZERORecoComponent::DoInit( Int_t argc, const Char_t** argv ) {
154 // see header file for class documentation
155
156 Int_t iResult=0;
157
672f9506 158 // -- Load GeomManager
159 if(AliGeomManager::GetGeometry()==NULL){
160 AliGeomManager::LoadGeometry();
161 }
162
e7918895 163 // -- Read configuration object : HLT/ConfigVZERO/VZEROReconstruction
164 TString cdbPath="HLT/ConfigVZERO/";
165 cdbPath+=GetComponentID();
166 iResult=ConfigureFromCDBTObjString(cdbPath);
167
168 // -- Read the component arguments
169 if (iResult>=0) {
170 iResult=ConfigureFromArgumentString(argc, argv);
171 }
172
173 // -- Get AliRunInfo variables
174 // -----------------------------
175 TObject* pOCDBEntry=LoadAndExtractOCDBObject("GRP/GRP/Data");
176 AliGRPObject* pGRP=pOCDBEntry?dynamic_cast<AliGRPObject*>(pOCDBEntry):NULL;
177
178 TString beamType = "";
179 TString lhcState = "";
180 TString runType = "";
181 Float_t beamEnergy = 0.;
182 UInt_t activeDetectors = 0;
183
184 if (pGRP) {
185 lhcState = pGRP->GetLHCState();
186 beamType = pGRP->GetBeamType();
187 runType = pGRP->GetRunType();
188 beamEnergy = pGRP->GetBeamEnergy();
189 activeDetectors = pGRP->GetDetectorMask();
190 }
191
192 // -- Initialize members
193 // -----------------------
194 do {
195 if (iResult<0) break;
196
197 fRawReader = new AliRawReaderMemory;
198 if (!fRawReader) {
199 iResult=-ENOMEM;
200 break;
201 }
202
203 // AliGRPManager grpMan;
204 // Bool_t status = grpMan.ReadGRPEntry(); // Read the corresponding OCDB entry
205 // status = grpMan.SetMagField(); // Set global field instanton
206 // AliRunInfo *runInfo = grpMan.GetRunInfo(); // Get instance of run info
207
208 fRunInfo = new AliRunInfo(lhcState.Data(), beamType.Data(),
209 beamEnergy, runType.Data(), activeDetectors);
210 if (!fRunInfo) {
211 iResult=-ENOMEM;
212 break;
213 }
214
215 fDigitsTree = new TTree("D", "Digits Tree");
216 if (!fDigitsTree) {
217 iResult=-ENOMEM;
218 break;
219 }
220
221 fVZERORecoParam = new AliVZERORecoParam;
222 if (!fVZERORecoParam) {
223 iResult=-ENOMEM;
224 break;
225 }
226
227 fVZEROReconstructor = new AliVZEROReconstructor;
228 if (!fVZEROReconstructor) {
229 iResult=-ENOMEM;
230 break;
231 }
232
233 // implement further initialization
234 } while (0);
235
236 if (iResult<0) {
237 // implement cleanup
238
239 if (fRawReader)
240 delete fRawReader;
241 fRawReader = NULL;
242
243 if (!fDigitsTree)
244 delete fDigitsTree;
245 fDigitsTree = NULL;
246
247 if (fVZERORecoParam)
248 delete fVZERORecoParam;
249 fVZERORecoParam = NULL;
250
251 if (fVZEROReconstructor)
252 delete fVZEROReconstructor;
253 fVZEROReconstructor = NULL;
254
255 if (fRunInfo)
256 delete fRunInfo;
257 fRunInfo = NULL;
258 }
259
260 if (iResult>=0) {
261 fVZEROReconstructor->SetRunInfo(fRunInfo);
262 fVZEROReconstructor->Init();
263
264 fVZEROReconstructor->SetRecoParam(fVZERORecoParam);
265 }
266
267 return iResult;
268}
269
270// #################################################################################
271Int_t AliHLTVZERORecoComponent::ScanConfigurationArgument(Int_t /*argc*/, const Char_t** argv) {
272 // Scan configuration arguments
273 // Return the number of processed arguments
274 // -EPROTO if argument format error (e.g. number expected but not found)
275 //
276 // The AliHLTComponent base class implements a parsing loop for argument strings and
277 // arrays of strings which is invoked by ConfigureFromArgumentString/ConfigureFromCDBTObjString
278 // The component needs to implement ScanConfigurationArgument in order to decode the arguments.
279
280 Int_t ii =0;
281 TString argument=argv[ii];
282
283 if (argument.IsNull()) return 0;
284
285 return 0;
286}
287
288// #################################################################################
289Int_t AliHLTVZERORecoComponent::DoDeinit() {
290 // see header file for class documentation
291
292 if (fRawReader)
293 delete fRawReader;
294 fRawReader = NULL;
295
296 if (!fDigitsTree)
297 delete fDigitsTree;
298 fDigitsTree = NULL;
299
300 if (fVZERORecoParam)
301 delete fVZERORecoParam;
302 fVZERORecoParam = NULL;
303
304 if (fVZEROReconstructor)
305 delete fVZEROReconstructor;
306 fVZEROReconstructor = NULL;
307
308 if (fRunInfo)
309 delete fRunInfo;
310 fRunInfo = NULL;
311
312 return 0;
313}
314
315// #################################################################################
316Int_t AliHLTVZERORecoComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/,
317 AliHLTComponentTriggerData& /*trigData*/) {
318 // see header file for class documentation
319
320 Int_t iResult=0;
321
322 // -- Only use data event
323 if (!IsDataEvent())
324 return 0;
325
326 // -- Get VZERO raw dat a input block and set up the rawreader
327 const AliHLTComponentBlockData* pBlock = GetFirstInputBlock(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginVZERO);
328 if (!pBlock) {
672f9506 329 HLTInfo("No VZERO input block !!!");
330 return 0;
e7918895 331 }
332
333 // -- Add input block to raw reader
334 if (!fRawReader->SetMemory((UChar_t*) pBlock->fPtr, pBlock->fSize )){
335 HLTError("Could not add buffer of data block %s, 0x%08x to rawreader",
336 DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification);
337 iResult = -1;
338 }
339
340 if (iResult >= 0) {
341
342 // -- Set VZERO EquipmentID
343 fRawReader->SetEquipmentID(3584);
344
345 // -- 1. step VZERO reconstruction
346 fVZEROReconstructor->ConvertDigits(fRawReader, fDigitsTree);
347
348 // -- 2. step VZERO reconstruction -- fill AliESDVZERO object
349 fVZEROReconstructor->FillESD(fDigitsTree, NULL, NULL);
350
351 // -- Send AliESDVZERO
352 PushBack(static_cast<TObject*>(fVZEROReconstructor->GetESDVZERO()),
353 kAliHLTDataTypeESDContent|kAliHLTDataOriginVZERO,0);
354 }
355
356 // -- Clean up
357 fDigitsTree->Reset();
358 fRawReader->ClearBuffers();
359
360 return iResult;
361}
362
363// #################################################################################
364Int_t AliHLTVZERORecoComponent::Reconfigure(const Char_t* cdbEntry, const Char_t* chainId) {
365 // see header file for class documentation
366
367 Int_t iResult=0;
368 TString cdbPath;
369 if (cdbEntry) {
370 cdbPath=cdbEntry;
371 } else {
372 cdbPath="HLT/ConfigVZERO/";
373 cdbPath+=GetComponentID();
374 }
375
376 AliInfoClass(Form("reconfigure '%s' from entry %s%s", chainId, cdbPath.Data(), cdbEntry?"":" (default)"));
377 iResult=ConfigureFromCDBTObjString(cdbPath);
378
379 return iResult;
380}
381
382// #################################################################################
383Int_t AliHLTVZERORecoComponent::ReadPreprocessorValues(const Char_t* /*modules*/) {
384 // see header file for class documentation
385 ALIHLTERRORGUARD(5, "ReadPreProcessorValues not implemented for this component");
386 return 0;
387}