]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/ZDC/AliHLTZDCESDRecoComponent.cxx
Corrected list of libraries and additional files to resolve all symbols
[u/mrichter/AliRoot.git] / HLT / ZDC / AliHLTZDCESDRecoComponent.cxx
1 //-*- Mode: C++ -*-
2 // $Id$
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: Chiara Oppedisano <Chiara.Oppedisano@to.infn.it>      *
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    AliHLTZDCESDRecoComponent.cxx
20     @author  Chiara Oppedisano <Chiara.Oppedisano@to.infn.it>
21     @brief   ZDC reconstruction component
22 */
23
24 #include "AliHLTErrorGuard.h"
25 #include "AliHLTSystem.h"
26 #include "AliHLTZDCESDRecoComponent.h"
27 #include "AliHLTDefinitions.h"
28 #include "AliRawReaderMemory.h"
29 #include "AliGeomManager.h"
30 #include "AliGRPObject.h"
31 #include "AliZDCReconstructor.h"
32 #include "AliZDCRecoParam.h"
33 #include "AliZDCRecoParampp.h"
34 #include "AliZDCRecoParamPbPb.h"
35 #include "AliESDEvent.h"
36 #include "AliESDZDC.h"
37 #include "AliCDBManager.h"
38 #include "AliHLTDataTypes.h"
39 #include <cstdlib>
40 #include <cerrno>
41
42 using namespace std;
43
44 ClassImp(AliHLTZDCESDRecoComponent)
45     
46 //_____________________________________________________________________
47 AliHLTZDCESDRecoComponent::AliHLTZDCESDRecoComponent()
48   : AliHLTProcessor(),    
49     fRawReader(NULL),
50     fReconstructor(NULL)
51 {
52 }
53
54 //_____________________________________________________________________
55 AliHLTZDCESDRecoComponent::~AliHLTZDCESDRecoComponent()
56 {
57     // see header file for class documentation
58 }
59
60 //_____________________________________________________________________
61 const char* AliHLTZDCESDRecoComponent::GetComponentID()
62 {
63     // see header file for class documentation
64     return "ZDCESDReco"; // The ID of this component
65 }
66
67 //_____________________________________________________________________
68 void AliHLTZDCESDRecoComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
69 {
70     // see header file for class documentation
71       list.push_back(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginZDC);
72 }
73
74 //_____________________________________________________________________
75 AliHLTComponentDataType AliHLTZDCESDRecoComponent::GetOutputDataType()
76 {
77       return kAliHLTDataTypeESDContent|kAliHLTDataOriginZDC;
78 }
79
80 //_____________________________________________________________________
81 void AliHLTZDCESDRecoComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
82 {
83     // see header file for class documentation
84     constBase = 1000;
85     inputMultiplier = 0;
86 }
87
88 //_____________________________________________________________________
89 AliHLTComponent* AliHLTZDCESDRecoComponent::Spawn()
90 {
91     // see header file for class documentation
92     return new AliHLTZDCESDRecoComponent;
93 }
94
95 //_____________________________________________________________________
96 int AliHLTZDCESDRecoComponent::DoInit( int argc, const char** argv )
97 {
98   // see header file for class documentation
99   int iResult=0;
100
101   // -- Load GeomManager
102   if(AliGeomManager::GetGeometry()==NULL){
103     AliGeomManager::LoadGeometry();
104   }
105   
106   // read configuration object : HLT/ConfigZDC/
107   TString cdbPath="HLT/ConfigZDC/";
108   cdbPath+=GetComponentID();
109   iResult=ConfigureFromCDBTObjString(cdbPath);
110
111   // init stage 3: read the component arguments
112   if (iResult>=0) {
113     iResult=ConfigureFromArgumentString(argc, argv);
114   }
115
116   // init stage 1: default values for all data members
117   
118   TObject* pOCDBEntry = LoadAndExtractOCDBObject("GRP/GRP/Data");
119   AliGRPObject* pGRP = pOCDBEntry?dynamic_cast<AliGRPObject*>(pOCDBEntry):NULL;
120   Float_t  beamEnergy=0.;
121   if(pGRP) beamEnergy = pGRP->GetBeamEnergy(); 
122
123   TString beamType="";
124   if(pGRP) beamType = pGRP->GetBeamType();
125
126   //!!! set the beam type and the energy explicitly
127
128   beamType="A-A"; 
129   beamEnergy = 2760.;
130
131   // implement the component initialization
132   do {
133     if (iResult<0) break;
134
135     fReconstructor = new AliZDCReconstructor;
136     if (!fReconstructor) {
137       iResult=-ENOMEM;
138       break;
139     }
140
141     fRawReader = new AliRawReaderMemory;
142     if (!fRawReader) {
143       iResult=-ENOMEM;
144       break;
145     }
146
147     // implement further initialization
148   } while (0);
149
150   if (iResult<0) {
151     // implement cleanup
152
153     if (fRawReader) delete fRawReader;
154     fRawReader = NULL;
155     
156     if (fReconstructor) delete fReconstructor;
157     fReconstructor = NULL;
158   }
159
160   if (iResult>=0) {
161
162    if((beamType.CompareTo("p-p"))==0) fReconstructor->SetRecoParam(AliZDCRecoParampp::GetLowFluxParam());
163     else if((beamType.CompareTo("A-A"))==0) fReconstructor->SetRecoParam(AliZDCRecoParamPbPb::GetHighFluxParam(beamEnergy));
164     else HLTWarning(" Beam type not known by ZDC!");
165   
166
167     fReconstructor->Init(beamType, beamEnergy);
168   }
169
170   return iResult;
171 }
172
173 //_____________________________________________________________________
174 int AliHLTZDCESDRecoComponent::ScanConfigurationArgument(int /*argc*/, const char** argv)
175 {
176   // Scan configuration arguments
177   // Return the number of processed arguments
178   //        -EPROTO if argument format error (e.g. number expected but not found)
179   //
180   // The AliHLTComponent base class implements a parsing loop for argument strings and
181   // arrays of strings which is invoked by ConfigureFromArgumentString/ConfigureFromCDBTObjString
182   // The component needs to implement ScanConfigurationArgument in order to decode the arguments.
183
184   int i=0;
185   TString argument=argv[i];
186
187   if (argument.IsNull()) return 0;
188
189   return 0;
190 }
191
192 //_____________________________________________________________________
193 int AliHLTZDCESDRecoComponent::DoDeinit()
194 {
195     if(fRawReader) delete fRawReader;
196     fRawReader=NULL;
197     if(fReconstructor) delete fReconstructor;
198     fReconstructor=NULL;
199     return 0;
200 }
201
202 //_____________________________________________________________________
203 int AliHLTZDCESDRecoComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/,
204                                        AliHLTComponentTriggerData& /*trigData*/)
205 {
206   // event processing function
207   int iResult=0;
208   
209   // check if this is a data event, there are a couple of special events
210   // which should be ignored for normal processing
211   if (!IsDataEvent()) return 0;
212   
213   // get ZDC raw input data block and set up the rawreader
214   const AliHLTComponentBlockData* pBlock = GetFirstInputBlock(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginZDC);
215   if (!pBlock) {
216     ALIHLTERRORGUARD(1, "No ZDC input block at event %d", GetEventCount());
217     return 0;
218   }
219
220   // add input block to raw reader
221   if (!fRawReader->SetMemory((UChar_t*) pBlock->fPtr, pBlock->fSize )){
222     HLTError("Could not add buffer of data block  %s, 0x%08x to rawreader",
223              DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification);
224     iResult = -1;
225   }
226   
227   TTree *clusterTree = new TTree();
228   if (!clusterTree) {
229     iResult=-ENOMEM;
230   }
231
232   if (iResult >= 0) {
233
234     // set ZDC EquipmentID
235     fRawReader->SetEquipmentID(3840);
236
237     fReconstructor->Reconstruct(fRawReader, clusterTree);
238
239     fReconstructor->FillZDCintoESD(clusterTree, (AliESDEvent *) NULL);
240
241     // send AliESDZDC
242     PushBack(static_cast<TObject*>(fReconstructor->GetZDCESDData()), 
243              kAliHLTDataTypeESDContent|kAliHLTDataOriginZDC,0);
244    
245   }
246
247   delete clusterTree;
248
249   // clear the rawreader
250   fRawReader->ClearBuffers();    
251   
252   return iResult;
253 }
254
255
256 //_____________________________________________________________________
257 int AliHLTZDCESDRecoComponent::Reconfigure(const char* cdbEntry, const char* chainId)
258 {
259   // reconfigure the component from the specified CDB entry, or default CDB entry
260   // function is invoked by the framework if a reconfigure command was received.
261   // 
262   int iResult=0;
263   TString cdbPath;
264   if (cdbEntry) {
265     cdbPath=cdbEntry;
266   } else {
267     cdbPath="HLT/ConfigZDC/";
268     cdbPath+=GetComponentID();
269   }
270   AliInfoClass(Form("reconfigure '%s' from entry %s%s", chainId, cdbPath.Data(), cdbEntry?"":" (default)"));
271   iResult=ConfigureFromCDBTObjString(cdbPath);
272
273   return iResult;
274 }
275
276
277 //_____________________________________________________________________
278 int AliHLTZDCESDRecoComponent::ReadPreprocessorValues(const char* /*modules*/)
279 {
280   // see header file for class documentation
281   return 0;
282 }