]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/ZDC/AliHLTZDCESDRecoComponent.cxx
excluding D0Trigger from the inputs of the HLTGlobalTrigger because of a rare segfaul...
[u/mrichter/AliRoot.git] / HLT / ZDC / AliHLTZDCESDRecoComponent.cxx
CommitLineData
9e239e96 1//-*- Mode: C++ -*-
2// $Id: AliHLTZDCESDRecoComponent.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: 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"
33#include "AliGRPObject.h"
34#include "AliZDCReconstructor.h"
35#include "AliZDCRecoParam.h"
36#include "AliZDCRecoParampp.h"
37#include "AliZDCRecoParamPbPb.h"
38#include "AliESDEvent.h"
39#include "AliESDZDC.h"
40#include "AliCDBManager.h"
41#include "AliHLTDataTypes.h"
42#include <cstdlib>
43#include <cerrno>
44
45ClassImp(AliHLTZDCESDRecoComponent)
46
47//_____________________________________________________________________
48AliHLTZDCESDRecoComponent::AliHLTZDCESDRecoComponent()
49 : AliHLTProcessor(),
50 fClusterTree(NULL),
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
103 // read configuration object : HLT/ConfigZDC/
104 TString cdbPath="HLT/ConfigZDC/";
105 cdbPath+=GetComponentID();
106 iResult=ConfigureFromCDBTObjString(cdbPath);
107
108 // init stage 3: read the component arguments
109 if (iResult>=0) {
110 iResult=ConfigureFromArgumentString(argc, argv);
111 }
112
113 // init stage 1: default values for all data members
114
115 TObject* pOCDBEntry = LoadAndExtractOCDBObject("GRP/GRP/Data");
116 AliGRPObject* pGRP = pOCDBEntry?dynamic_cast<AliGRPObject*>(pOCDBEntry):NULL;
117 Float_t beamEnergy=0.;
118 if(pGRP) beamEnergy = pGRP->GetBeamEnergy();
119 TString beamType="";
120 if(pGRP) beamType = pGRP->GetBeamType();
121
122 // implement the component initialization
123 do {
124 if (iResult<0) break;
125
126 fReconstructor = new AliZDCReconstructor;
127 if (!fReconstructor) {
128 iResult=-ENOMEM;
129 break;
130 }
131
132 fRawReader = new AliRawReaderMemory;
133 if (!fRawReader) {
134 iResult=-ENOMEM;
135 break;
136 }
137
138 fClusterTree = new TTree("TreeR", "Tree for reco points in HLT");;
139 if (!fClusterTree) {
140 iResult=-ENOMEM;
141 break;
142 }
143
144 // implement further initialization
145 } while (0);
146
147 if (iResult<0) {
148 // implement cleanup
149
150 if (fClusterTree) delete fClusterTree;
151 fClusterTree = NULL;
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 if((beamType.CompareTo("p-p"))==0) fReconstructor->SetRecoParam(AliZDCRecoParampp::GetLowFluxParam());
162 else if((beamType.CompareTo("A-A"))==0) fReconstructor->SetRecoParam(AliZDCRecoParamPbPb::GetHighFluxParam(2*beamEnergy));
163 else HLTWarning(" Beam type not known by ZDC!");
164
165 fReconstructor->Init(beamType, beamEnergy);
166 }
167
168 return iResult;
169}
170
171//_____________________________________________________________________
172int AliHLTZDCESDRecoComponent::ScanConfigurationArgument(int /*argc*/, const char** argv)
173{
174 // Scan configuration arguments
175 // Return the number of processed arguments
176 // -EPROTO if argument format error (e.g. number expected but not found)
177 //
178 // The AliHLTComponent base class implements a parsing loop for argument strings and
179 // arrays of strings which is invoked by ConfigureFromArgumentString/ConfigureFromCDBTObjString
180 // The component needs to implement ScanConfigurationArgument in order to decode the arguments.
181
182 int i=0;
183 TString argument=argv[i];
184
185 if (argument.IsNull()) return 0;
186
187 return 0;
188}
189
190//_____________________________________________________________________
191int AliHLTZDCESDRecoComponent::DoDeinit()
192{
193 if(fRawReader) delete fRawReader;
194 if(fReconstructor) delete fReconstructor;
195 if(fClusterTree) delete fClusterTree;
196 return 0;
197}
198
199//_____________________________________________________________________
200int AliHLTZDCESDRecoComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/,
201 AliHLTComponentTriggerData& /*trigData*/)
202{
203 // event processing function
204 int iResult=0;
205
206 // check if this is a data event, there are a couple of special events
207 // which should be ignored for normal processing
208 if (!IsDataEvent()) return 0;
209
210 // get ZDC raw input data block and set up the rawreader
211 const AliHLTComponentBlockData* pBlock = GetFirstInputBlock(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginZDC);
212 if (!pBlock) {
213 HLTError("No ZDC input block !!!");
214 return -1;
215 }
216
217 // add input block to raw reader
218 if (!fRawReader->SetMemory((UChar_t*) pBlock->fPtr, pBlock->fSize )){
219 HLTError("Could not add buffer of data block %s, 0x%08x to rawreader",
220 DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification);
221 iResult = -1;
222 }
223
224 if (iResult >= 0) {
225
226 // set ZDC EquipmentID
227 fRawReader->SetEquipmentID(3840);
228
229 fReconstructor->Reconstruct(fRawReader, fClusterTree);
230
231 fReconstructor->FillZDCintoESD(fClusterTree, (AliESDEvent *) NULL);
232
233 // send AliESDZDC
234 PushBack(static_cast<TObject*>(fReconstructor->GetZDCESDData()),
235 kAliHLTDataTypeESDContent|kAliHLTDataOriginZDC,0);
236
237 }
238
239 // clear the rawreader
240 fClusterTree->Reset();
241 fRawReader->ClearBuffers();
242
243 return iResult;
244}
245
246
247//_____________________________________________________________________
248int AliHLTZDCESDRecoComponent::Reconfigure(const char* cdbEntry, const char* chainId)
249{
250 // reconfigure the component from the specified CDB entry, or default CDB entry
251 // function is invoked by the framework if a reconfigure command was received.
252 //
253 int iResult=0;
254 TString cdbPath;
255 if (cdbEntry) {
256 cdbPath=cdbEntry;
257 } else {
258 cdbPath="HLT/ConfigZDC/";
259 cdbPath+=GetComponentID();
260 }
261 AliInfoClass(Form("reconfigure '%s' from entry %s%s", chainId, cdbPath.Data(), cdbEntry?"":" (default)"));
262 iResult=ConfigureFromCDBTObjString(cdbPath);
263
264 return iResult;
265}
266
267
268//_____________________________________________________________________
269int AliHLTZDCESDRecoComponent::ReadPreprocessorValues(const char* /*modules*/)
270{
271 // see header file for class documentation
272 ALIHLTERRORGUARD(5, "ReadPreProcessorValues not implemented for this component");
273 return 0;
274}