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