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 |
25 | using namespace std; |
26 | #endif |
27 | |
28 | #include "TTree.h" |
29 | #include "TMap.h" |
30 | #include "TObjString.h" |
9c4c66f7 |
31 | #include "TDatime.h" |
e7918895 |
32 | |
33 | #include "AliLog.h" |
34 | #include "AliRunInfo.h" |
35 | #include "AliGRPObject.h" |
36 | #include "AliRawReaderMemory.h" |
672f9506 |
37 | #include "AliGeomManager.h" |
e7918895 |
38 | |
39 | #include "AliVZERORecoParam.h" |
40 | #include "AliVZEROReconstructor.h" |
41 | |
42 | #include "AliHLTErrorGuard.h" |
43 | #include "AliHLTDataTypes.h" |
44 | #include "AliHLTVZERORecoComponent.h" |
45 | |
46 | /** ROOT macro for the implementation of ROOT specific class methods */ |
47 | ClassImp(AliHLTVZERORecoComponent) |
48 | |
49 | /* |
50 | * --------------------------------------------------------------------------------- |
51 | * Constructor / Destructor |
52 | * --------------------------------------------------------------------------------- |
53 | */ |
54 | |
55 | // ################################################################################# |
56 | AliHLTVZERORecoComponent::AliHLTVZERORecoComponent() : |
57 | AliHLTProcessor(), |
597007fa |
58 | fRunInfo(NULL), |
e7918895 |
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 | // ################################################################################# |
75 | AliHLTVZERORecoComponent::~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 | // ################################################################################# |
87 | const Char_t* AliHLTVZERORecoComponent::GetComponentID() { |
88 | // see header file for class documentation |
89 | return "VZEROReconstruction"; |
90 | } |
91 | |
92 | // ################################################################################# |
93 | void AliHLTVZERORecoComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) { |
94 | // see header file for class documentation |
95 | list.push_back(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginVZERO); |
96 | } |
97 | |
98 | // ################################################################################# |
99 | AliHLTComponentDataType AliHLTVZERORecoComponent::GetOutputDataType() { |
100 | // see header file for class documentation |
101 | return kAliHLTDataTypeESDContent|kAliHLTDataOriginVZERO; |
102 | } |
103 | |
104 | // ################################################################################# |
105 | void 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 | // ################################################################################# |
112 | void 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 | // ################################################################################# |
139 | AliHLTComponent* 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 | // ################################################################################# |
153 | Int_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 | |
e7918895 |
215 | fVZERORecoParam = new AliVZERORecoParam; |
216 | if (!fVZERORecoParam) { |
217 | iResult=-ENOMEM; |
218 | break; |
219 | } |
220 | |
221 | fVZEROReconstructor = new AliVZEROReconstructor; |
222 | if (!fVZEROReconstructor) { |
223 | iResult=-ENOMEM; |
224 | break; |
225 | } |
226 | |
227 | // implement further initialization |
228 | } while (0); |
229 | |
230 | if (iResult<0) { |
231 | // implement cleanup |
232 | |
233 | if (fRawReader) |
234 | delete fRawReader; |
235 | fRawReader = NULL; |
236 | |
e7918895 |
237 | if (fVZERORecoParam) |
238 | delete fVZERORecoParam; |
239 | fVZERORecoParam = NULL; |
240 | |
241 | if (fVZEROReconstructor) |
242 | delete fVZEROReconstructor; |
243 | fVZEROReconstructor = NULL; |
244 | |
245 | if (fRunInfo) |
246 | delete fRunInfo; |
247 | fRunInfo = NULL; |
248 | } |
249 | |
250 | if (iResult>=0) { |
251 | fVZEROReconstructor->SetRunInfo(fRunInfo); |
252 | fVZEROReconstructor->Init(); |
253 | |
254 | fVZEROReconstructor->SetRecoParam(fVZERORecoParam); |
255 | } |
256 | |
257 | return iResult; |
258 | } |
259 | |
260 | // ################################################################################# |
261 | Int_t AliHLTVZERORecoComponent::ScanConfigurationArgument(Int_t /*argc*/, const Char_t** argv) { |
262 | // Scan configuration arguments |
263 | // Return the number of processed arguments |
264 | // -EPROTO if argument format error (e.g. number expected but not found) |
265 | // |
266 | // The AliHLTComponent base class implements a parsing loop for argument strings and |
267 | // arrays of strings which is invoked by ConfigureFromArgumentString/ConfigureFromCDBTObjString |
268 | // The component needs to implement ScanConfigurationArgument in order to decode the arguments. |
269 | |
270 | Int_t ii =0; |
271 | TString argument=argv[ii]; |
272 | |
273 | if (argument.IsNull()) return 0; |
274 | |
275 | return 0; |
276 | } |
277 | |
278 | // ################################################################################# |
279 | Int_t AliHLTVZERORecoComponent::DoDeinit() { |
280 | // see header file for class documentation |
281 | |
282 | if (fRawReader) |
283 | delete fRawReader; |
284 | fRawReader = NULL; |
285 | |
e7918895 |
286 | if (fVZERORecoParam) |
287 | delete fVZERORecoParam; |
288 | fVZERORecoParam = NULL; |
289 | |
290 | if (fVZEROReconstructor) |
291 | delete fVZEROReconstructor; |
292 | fVZEROReconstructor = NULL; |
293 | |
294 | if (fRunInfo) |
295 | delete fRunInfo; |
296 | fRunInfo = NULL; |
297 | |
298 | return 0; |
299 | } |
300 | |
301 | // ################################################################################# |
302 | Int_t AliHLTVZERORecoComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/, |
303 | AliHLTComponentTriggerData& /*trigData*/) { |
304 | // see header file for class documentation |
305 | |
306 | Int_t iResult=0; |
307 | |
308 | // -- Only use data event |
309 | if (!IsDataEvent()) |
310 | return 0; |
311 | |
312 | // -- Get VZERO raw dat a input block and set up the rawreader |
313 | const AliHLTComponentBlockData* pBlock = GetFirstInputBlock(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginVZERO); |
314 | if (!pBlock) { |
672f9506 |
315 | HLTInfo("No VZERO input block !!!"); |
316 | return 0; |
e7918895 |
317 | } |
318 | |
319 | // -- Add input block to raw reader |
320 | if (!fRawReader->SetMemory((UChar_t*) pBlock->fPtr, pBlock->fSize )){ |
321 | HLTError("Could not add buffer of data block %s, 0x%08x to rawreader", |
322 | DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification); |
323 | iResult = -1; |
324 | } |
325 | |
597007fa |
326 | TTree *digitsTree = new TTree("D", "Digits Tree"); |
327 | if (!digitsTree) { |
328 | iResult=-ENOMEM; |
329 | } |
330 | |
e7918895 |
331 | if (iResult >= 0) { |
332 | |
333 | // -- Set VZERO EquipmentID |
334 | fRawReader->SetEquipmentID(3584); |
335 | |
336 | // -- 1. step VZERO reconstruction |
597007fa |
337 | fVZEROReconstructor->ConvertDigits(fRawReader, digitsTree); |
e7918895 |
338 | |
339 | // -- 2. step VZERO reconstruction -- fill AliESDVZERO object |
597007fa |
340 | fVZEROReconstructor->FillESD(digitsTree, NULL, NULL); |
e7918895 |
341 | |
748c0dde |
342 | AliESDVZERO *esdVZERO = fVZEROReconstructor->GetESDVZERO(); |
343 | |
9c4c66f7 |
344 | // Send info every 10 s |
345 | const TDatime time; |
346 | static UInt_t lastTime=0; |
347 | if (time.Get()-lastTime>10) { |
348 | lastTime=time.Get(); |
349 | HLTInfo("VZERO Multiplicity A %f - C %f", esdVZERO->GetMTotV0A(), esdVZERO->GetMTotV0A() ); |
350 | } |
748c0dde |
351 | |
e7918895 |
352 | // -- Send AliESDVZERO |
9c4c66f7 |
353 | PushBack(esdVZERO, kAliHLTDataTypeESDContent|kAliHLTDataOriginVZERO,0); |
e7918895 |
354 | } |
355 | |
356 | // -- Clean up |
597007fa |
357 | delete digitsTree; |
e7918895 |
358 | fRawReader->ClearBuffers(); |
359 | |
360 | return iResult; |
361 | } |
362 | |
363 | // ################################################################################# |
364 | Int_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 | // ################################################################################# |
383 | Int_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 | } |