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