]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - HLT/PHOS/AliHLTPHOSClusterizerComponent.cxx
Components for selective readout of the DDL blocks
[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
16#include "AliHLTPHOSClusterizerComponent.h"
17#include "AliHLTPHOSClusterizer.h"
18#include "AliHLTPHOSRecPointDataStruct.h"
19#include "AliHLTPHOSDigitContainerDataStruct.h"
20
21
22
23/** @file AliHLTPHOSClusterizerComponent.cxx
24 @author Oystein Djuvsland
25 @date
26 @brief A clusterizer component for PHOS HLT
27*/
28
29// see header file for class documentation
30// or
31// refer to README to build package
32// or
33// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
34
35#if __GNUC__>= 3
36using namespace std;
37#endif
38
39const AliHLTComponentDataType AliHLTPHOSClusterizerComponent::fgkInputDataTypes[]=
40 {
41 kAliHLTVoidDataType,{0,"",""}
42 };
43
44AliHLTPHOSClusterizerComponent gAliHLTPHOSClusterizerComponent;
45
46
47AliHLTPHOSClusterizerComponent::AliHLTPHOSClusterizerComponent(): AliHLTPHOSProcessor(), fClusterizerPtr(0), fOutPtr(0),
48 fRecPointStructArrayPtr(0) //, fRecPointListPtr(0)
49{
50 //See headerfile for documentation
51}
52
53AliHLTPHOSClusterizerComponent::~AliHLTPHOSClusterizerComponent()
54{
55 //See headerfile for documentation
56
57 if (fClusterizerPtr)
58 {
59 delete fClusterizerPtr;
60 fClusterizerPtr = 0;
61 }
62 if (fRecPointStructArrayPtr)
63 {
64 for (int i = 0; i < 1000; i++)
65 {
66 // fRecPointStructArrayPtr[i].Del();
67 }
68 delete fRecPointStructArrayPtr;
69 fRecPointStructArrayPtr = 0;
70 }
71
72}
73
74
75int
76AliHLTPHOSClusterizerComponent::Deinit()
77{
78 //See headerfile for documentation
79
80 if (fClusterizerPtr)
81 {
82 delete fClusterizerPtr;
83 fClusterizerPtr = 0;
84 }
85 for (int i = 0; i < 1000; i++)
86 {
87 // fRecPointStructArrayPtr[i].Del();
88 }
89
90 if (fRecPointStructArrayPtr)
91 {
92 for (int i = 0; i < 1000; i++)
93 {
94 // fRecPointStructArrayPtr[i].Del();
95 }
96 delete fRecPointStructArrayPtr;
97 fRecPointStructArrayPtr = 0;
98 }
99
100 return 0;
101}
102
103const Char_t*
104AliHLTPHOSClusterizerComponent::GetComponentID()
105{
106 //See headerfile for documentation
107
108 return "AliHltPhosClusterizer";
109}
110
111void
112AliHLTPHOSClusterizerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
113{
114 //See headerfile for documentation
115
116 const AliHLTComponentDataType* pType=fgkInputDataTypes;
117 while (pType->fID!=0)
118 {
119 list.push_back(*pType);
120 pType++;
121 }
122}
123
124AliHLTComponentDataType
125AliHLTPHOSClusterizerComponent::GetOutputDataType()
126{
127 //See headerfile for documentation
128
129 return AliHLTPHOSDefinitions::fgkAliHLTClusterDataType;
130}
131
132void
133AliHLTPHOSClusterizerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
134
135{
136 //See headerfile for documentation
137
138 constBase = 30;
139 inputMultiplier = 0.2;
140}
141
142int
143AliHLTPHOSClusterizerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
144 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
145 std::vector<AliHLTComponentBlockData>& outputBlocks)
146{
147 //See headerfile for documentation
148
149 UInt_t tSize = 0;
150 UInt_t offset = 0;
151 UInt_t mysize = 0;
152 Int_t nRecPoints = 0;
153 Int_t nDigits = 0;
154 Int_t j =0;
155
156 AliHLTUInt8_t* outBPtr;
157 outBPtr = outputPtr;
158 const AliHLTComponentBlockData* iter = 0;
159 unsigned long ndx;
160
161 AliHLTPHOSDigitContainerDataStruct *digitContainerPtr = 0;
162 fClusterizerPtr->SetRecPointContainer((AliHLTPHOSRecPointContainerStruct*)outBPtr);
163
164 for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
165 {
166 iter = blocks+ndx;
167 digitContainerPtr = reinterpret_cast<AliHLTPHOSDigitContainerDataStruct*>(iter->fPtr);
168 if (iter->fDataType != AliHLTPHOSDefinitions::fgkAliHLTDigitDataType)
169 {
170 continue;
171 }
172 for (UInt_t i = 0; i < digitContainerPtr->fNDigits; i++)
173 {
174 if(fNoCrazyness && digitContainerPtr->fDigitDataStruct[i].fCrazyness)
175 continue;
176
177 fAllDigitsPtr->fDigitDataStruct[j+nDigits].fX = digitContainerPtr->fDigitDataStruct[i].fX;
178 fAllDigitsPtr->fDigitDataStruct[j+nDigits].fZ = digitContainerPtr->fDigitDataStruct[i].fZ;
179 fAllDigitsPtr->fDigitDataStruct[j+nDigits].fAmplitude = digitContainerPtr->fDigitDataStruct[i].fAmplitude;
180 fAllDigitsPtr->fDigitDataStruct[j+nDigits].fTime = digitContainerPtr->fDigitDataStruct[i].fTime;
181 j++;
182 }
183 nDigits++;
184 }
185
186 fOutPtr = (AliHLTPHOSRecPointContainerStruct*)outBPtr;
187 nRecPoints = fClusterizerPtr->ClusterizeEvent();
188 cout << "Number of clusters found: " << nRecPoints << " extracted from " << nDigits << " digits" << endl;
189
190 mysize = 0;
191 offset = tSize;
192
193 mysize += sizeof(AliHLTPHOSRecPointDataStruct);
194
195 AliHLTComponentBlockData bd;
196 FillBlockData( bd );
197 bd.fOffset = offset;
198 bd.fSize = mysize;
199 // PTH bd.fDataType = AliHLTPHOSPhysicsDefinitions::fgkAliHLTClusterDataType;
200 bd.fDataType = AliHLTPHOSDefinitions::fgkAliHLTClusterDataType;
201 bd.fSpecification = 0xFFFFFFFF;
202 outputBlocks.push_back( bd );
203
204 tSize += mysize;
205 outBPtr += mysize;
206
207 if ( tSize > size )
208 {
209 Logging( kHLTLogFatal, "HLT::AliHLTPHOSClusterizerComponent::DoEvent", "Too much data",
210 "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu."
211 , tSize, size );
212 return EMSGSIZE;
213 }
214
215
216 size = tSize;
217// fClusterizerPtr->ResetCellEnergyArray();
218
219 return 0;
220
221}
222
223int
224AliHLTPHOSClusterizerComponent::DoInit(int argc, const char** argv )
225{
226 //See headerfile for documentation
227
228 fAllDigitsPtr = new AliHLTPHOSDigitContainerDataStruct();
229 fClusterizerPtr = new AliHLTPHOSClusterizer();
230 //fClusterizerPtr->SetNoCrazyness(true);
231 //
232 for (int i = 0; i < argc; i++)
233 {
234 /*
235 if(!strcmp("-energythreshold", argv[i]))
236 fClusterizerPtr->SetThreshold(atof(argv[i+1]));
237 if(!strcmp("-clusterthreshold", argv[i]))
238 fClusterizerPtr->SetClusterThreshold(atof(argv[i+1]));
239 if(!strcmp("-highgain", argv[i]))
240 fClusterizerPtr->SetHighGainFactor(atof(argv[i+1]));
241 if(!strcmp("-lowgain", argv[i]))
242 fClusterizerPtr->SetLowGainFactor(atof(argv[i+1]));
243 if(!strcmp("-arraysize", argv[i]))
244 fClusterizerPtr->SetArraySize(atoi(argv[i+1]));*/
245 }
246 // fClusterizerPtr->ResetCellEnergyArray();
247
248
249 fRecPointStructArrayPtr = new AliHLTPHOSRecPointDataStruct[1000];
250 for (int i = 0; i < 1000; i++)
251 {
252 fRecPointStructArrayPtr[i].fMultiplicity = atoi(argv[4])* atoi(argv[4]);
253 // fRecPointStructArrayPtr[i].New();
254 }
255 /*
256 printf("Clusterizer component started with:\n");
257 printf(" Cell threshold: %f\n", fClusterizerPtr->GetThreshold());
258 printf(" Cluster threshold: %f\n", fClusterizerPtr->GetClusterThreshold());
259 printf(" High gain factor: %f\n", fClusterizerPtr->GetHighGainFactor());
260 printf(" Low gain factor: %f\n", fClusterizerPtr->GetLowGainFactor());
261 printf(" Cluster array size: %d\n\n", fClusterizerPtr->GetArraySize());
262 */
263 return 0;
264}
265
266AliHLTComponent*
267AliHLTPHOSClusterizerComponent::Spawn()
268{
269 //See headerfile for documentation
270
271 return new AliHLTPHOSClusterizerComponent();
272}