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