]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - HLT/PHOS/AliHLTPHOSClusterizerComponent.cxx
- handling of global AliHLTSystem singleton moved to BASE
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSClusterizerComponent.cxx
... / ...
CommitLineData
1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Authors: Oystein Djuvsland <oysteind@ift.uib.no> *
5 * *
6 * Permission to use, copy, modify and distribute this software and its *
7 * documentation strictly for non-commercial purposes is hereby granted *
8 * without fee, provided that the above copyright notice appears in all *
9 * copies and that both the copyright notice and this permission notice *
10 * appear in the supporting documentation. The authors make no claims *
11 * about the suitability of this software for any purpose. It is *
12 * provided "as is" without express or implied warranty. *
13 **************************************************************************/
14
15#include <iostream>
16
17#include "AliHLTPHOSClusterizerComponent.h"
18#include "AliHLTPHOSClusterizer.h"
19#include "AliHLTPHOSRecPointDataStruct.h"
20#include "AliHLTPHOSDigitContainerDataStruct.h"
21
22
23
24/** @file AliHLTPHOSClusterizerComponent.cxx
25 @author Oystein Djuvsland
26 @date
27 @brief A clusterizer component for PHOS HLT
28*/
29
30// see header file for class documentation
31// or
32// refer to README to build package
33// or
34// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
35
36#if __GNUC__>= 3
37using namespace std;
38#endif
39
40const AliHLTComponentDataType AliHLTPHOSClusterizerComponent::fgkInputDataTypes[]=
41 {
42 kAliHLTVoidDataType,{0,"",""}
43 };
44
45AliHLTPHOSClusterizerComponent gAliHLTPHOSClusterizerComponent;
46
47
48AliHLTPHOSClusterizerComponent::AliHLTPHOSClusterizerComponent():
49 AliHLTPHOSProcessor(),
50 fAllDigitsPtr(0),
51 fClusterizerPtr(0),
52 fRecPointStructArrayPtr(0),
53 fDigitCount(0),
54 fModuleClusterizationMode(false),
55 fNoCrazyness(0)
56{
57 //See headerfile for documentation
58}
59
60AliHLTPHOSClusterizerComponent::~AliHLTPHOSClusterizerComponent()
61{
62 //See headerfile for documentation
63
64 if(fClusterizerPtr)
65 {
66 delete fClusterizerPtr;
67 fClusterizerPtr = 0;
68 }
69 if(fRecPointStructArrayPtr)
70 {
71 for (int i = 0; i < 1000; i++)
72 {
73 // fRecPointStructArrayPtr[i].Del();
74 }
75 delete fRecPointStructArrayPtr;
76 fRecPointStructArrayPtr = 0;
77 }
78 if(fAllDigitsPtr)
79 {
80 delete fAllDigitsPtr;
81 fAllDigitsPtr = 0;
82 }
83}
84
85
86int
87AliHLTPHOSClusterizerComponent::Deinit()
88{
89 //See headerfile for documentation
90
91 if (fClusterizerPtr)
92 {
93 delete fClusterizerPtr;
94 fClusterizerPtr = 0;
95 }
96 for (int i = 0; i < 1000; i++)
97 {
98 // fRecPointStructArrayPtr[i].Del();
99 }
100
101 if (fRecPointStructArrayPtr)
102 {
103 for (int i = 0; i < 1000; i++)
104 {
105 // fRecPointStructArrayPtr[i].Del();
106 }
107 delete fRecPointStructArrayPtr;
108 fRecPointStructArrayPtr = 0;
109 }
110
111 return 0;
112}
113
114const Char_t*
115AliHLTPHOSClusterizerComponent::GetComponentID()
116{
117 //See headerfile for documentation
118
119 return "PhosClusterizer";
120}
121
122void
123AliHLTPHOSClusterizerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
124{
125 list.clear();
126 list.push_back(AliHLTPHOSDefinitions::fgkDigitDataType);
127}
128
129AliHLTComponentDataType
130AliHLTPHOSClusterizerComponent::GetOutputDataType()
131{
132 //See headerfile for documentation
133 return AliHLTPHOSDefinitions::fgkClusterDataType;
134}
135
136void
137AliHLTPHOSClusterizerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
138
139{
140 //See headerfile for documentation
141 constBase = 30;
142 inputMultiplier = 1;
143}
144
145int
146AliHLTPHOSClusterizerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
147 AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
148 std::vector<AliHLTComponentBlockData>& outputBlocks)
149{
150 //See headerfile for documentation
151 AliHLTComponentTriggerData &trDta = trigData;
152 trDta.fDataSize++;
153 trDta.fDataSize--; //shutting up the compiler, we dont use trigData now but will do in near future
154
155 UInt_t tSize = 0;
156 UInt_t offset = 0;
157 UInt_t mysize = 0;
158 Int_t nRecPoints = 0;
159 Int_t j =0;
160
161 AliHLTUInt8_t* outBPtr;
162 outBPtr = outputPtr;
163 const AliHLTComponentBlockData* iter = 0;
164 unsigned long ndx;
165
166 UInt_t specification = 0;
167
168 AliHLTPHOSDigitContainerDataStruct *digitContainerPtr = 0;
169 fClusterizerPtr->SetRecPointContainer((AliHLTPHOSRecPointContainerStruct*)outBPtr);
170
171 for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
172 {
173 iter = blocks+ndx;
174 if (iter->fDataType == AliHLTPHOSDefinitions::fgkDigitDataType)
175 {
176 specification = specification|iter->fSpecification;
177 digitContainerPtr = reinterpret_cast<AliHLTPHOSDigitContainerDataStruct*>(iter->fPtr);
178 if(fModuleClusterizationMode)
179 {
180 for (UInt_t i = 0; i < digitContainerPtr->fNDigits; i++)
181 {
182 fAllDigitsPtr->fDigitDataStruct[j].fX = digitContainerPtr->fDigitDataStruct[i].fX;
183 fAllDigitsPtr->fDigitDataStruct[j].fZ = digitContainerPtr->fDigitDataStruct[i].fZ;
184 fAllDigitsPtr->fDigitDataStruct[j].fAmplitude = digitContainerPtr->fDigitDataStruct[i].fAmplitude;
185 fAllDigitsPtr->fDigitDataStruct[j].fTime = digitContainerPtr->fDigitDataStruct[i].fTime;
186 fAllDigitsPtr->fDigitDataStruct[j].fCrazyness = digitContainerPtr->fDigitDataStruct[i].fCrazyness;
187 j++;
188 }
189
190 }
191 }
192 }
193 if(fModuleClusterizationMode && fAllDigitsPtr != 0)
194 {
195 fClusterizerPtr->SetDigitContainer(fAllDigitsPtr);
196 }
197 else if(digitContainerPtr != 0)
198 {
199 fClusterizerPtr->SetDigitContainer(digitContainerPtr);
200 }
201 if(digitContainerPtr != 0)
202 {
203 nRecPoints = fClusterizerPtr->ClusterizeEvent();
204
205 mysize = 0;
206 offset = tSize;
207
208 mysize += sizeof(AliHLTPHOSRecPointContainerStruct);
209
210 AliHLTComponentBlockData bd;
211 FillBlockData( bd );
212 bd.fOffset = offset;
213 bd.fSize = mysize;
214 bd.fDataType = AliHLTPHOSDefinitions::fgkClusterDataType;
215 bd.fSpecification = specification;
216 outputBlocks.push_back( bd );
217 tSize += mysize;
218 outBPtr += mysize;
219
220 }
221
222 if ( tSize > size )
223 {
224 Logging( kHLTLogFatal, "HLT::AliHLTPHOSClusterizerComponent::DoEvent", "Too much data",
225 "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu."
226 , tSize, size );
227 return EMSGSIZE;
228 }
229
230 return 0;
231
232
233}
234
235int
236AliHLTPHOSClusterizerComponent::DoInit(int argc, const char** argv )
237{
238 //See headerfile for documentation
239
240 fAllDigitsPtr = new AliHLTPHOSDigitContainerDataStruct();
241 fClusterizerPtr = new AliHLTPHOSClusterizer();
242 fClusterizerPtr->SetDigitContainer(fAllDigitsPtr);
243 fNoCrazyness = false;
244 //
245
246 ScanArguments(argc, argv);
247 for (int i = 0; i < argc; i++)
248 {
249 if(!strcmp("-digitthreshold", argv[i]))
250 {
251 fClusterizerPtr->SetEmcMinEnergyThreshold(atof(argv[i+1]));
252 }
253 if(!strcmp("-recpointthreshold", argv[i]))
254 {
255 fClusterizerPtr->SetEmcClusteringThreshold(atof(argv[i+1]));
256 }
257 if(!strcmp("-modulemode", argv[i]))
258 {
259 fModuleClusterizationMode = true;
260 }
261 }
262
263 return 0;
264}
265
266AliHLTComponent*
267AliHLTPHOSClusterizerComponent::Spawn()
268{
269 //See headerfile for documentation
270
271 return new AliHLTPHOSClusterizerComponent();
272}