]>
Commit | Line | Data |
---|---|---|
1 | // $Id: AliHLTCaloClusterizerComponent.cxx 36709 2009-11-12 16:57:55Z odjuvsla $ | |
2 | ||
3 | /************************************************************************** | |
4 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
5 | * * | |
6 | * Authors: Oystein Djuvsland <oysteind@ift.uib.no> * | |
7 | * * | |
8 | * Permission to use, copy, modify and distribute this software and its * | |
9 | * documentation strictly for non-commercial purposes is hereby granted * | |
10 | * without fee, provided that the above copyright notice appears in all * | |
11 | * copies and that both the copyright notice and this permission notice * | |
12 | * appear in the supporting documentation. The authors make no claims * | |
13 | * about the suitability of this software for any purpose. It is * | |
14 | * provided "as is" without express or implied warranty. * | |
15 | **************************************************************************/ | |
16 | ||
17 | #include "AliHLTCaloClusterizerComponent.h" | |
18 | #include "AliHLTCaloClusterizer.h" | |
19 | #include "AliHLTCaloClusterAnalyser.h" | |
20 | #include "AliHLTCaloRecPointDataStruct.h" | |
21 | #include "AliHLTCaloRecPointHeaderStruct.h" | |
22 | #include "AliHLTCaloDigitDataStruct.h" | |
23 | #include "AliHLTCaloDigitContainerDataStruct.h" | |
24 | #include "AliHLTCaloDefinitions.h" | |
25 | #include "AliHLTCaloClusterDataStruct.h" | |
26 | #include "TString.h" | |
27 | ||
28 | /** @file AliHLTCaloClusterizerComponent.cxx | |
29 | @author Oystein Djuvsland | |
30 | @date | |
31 | @brief A clusterizer component for PHOS HLT | |
32 | */ | |
33 | ||
34 | // see header file for class documentation | |
35 | // or | |
36 | // refer to README to build package | |
37 | // or | |
38 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
39 | ||
40 | AliHLTCaloClusterizerComponent::AliHLTCaloClusterizerComponent(TString det): | |
41 | AliHLTCaloProcessor(), | |
42 | AliHLTCaloConstantsHandler(det), | |
43 | fDigitsPointerArray(0), | |
44 | fClusterizerPtr(0), | |
45 | fAnalyserPtr(0), | |
46 | fDigitCount(0) | |
47 | { | |
48 | //See headerfile for documentation | |
49 | ||
50 | fDigitsPointerArray = new AliHLTCaloDigitDataStruct*[fCaloConstants->GetNXCOLUMNSRCU()*fCaloConstants->GetNZROWSRCU()]; | |
51 | ||
52 | fClusterizerPtr = new AliHLTCaloClusterizer(det); | |
53 | ||
54 | fClusterizerPtr->SetDigitArray(fDigitsPointerArray); | |
55 | ||
56 | fAnalyserPtr = new AliHLTCaloClusterAnalyser(); | |
57 | ||
58 | } | |
59 | ||
60 | AliHLTCaloClusterizerComponent::~AliHLTCaloClusterizerComponent() | |
61 | { | |
62 | //See headerfile for documentation | |
63 | ||
64 | if(fClusterizerPtr) | |
65 | { | |
66 | delete fClusterizerPtr; | |
67 | fClusterizerPtr = 0; | |
68 | } | |
69 | } | |
70 | ||
71 | ||
72 | int | |
73 | AliHLTCaloClusterizerComponent::Deinit() | |
74 | { | |
75 | //See headerfile for documentation | |
76 | ||
77 | if (fClusterizerPtr) | |
78 | { | |
79 | delete fClusterizerPtr; | |
80 | fClusterizerPtr = 0; | |
81 | } | |
82 | ||
83 | return 0; | |
84 | } | |
85 | ||
86 | // void | |
87 | // AliHLTCaloClusterizerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) | |
88 | // { | |
89 | // //See headerfile for documentation | |
90 | // list.clear(); | |
91 | // list.push_back(AliHLTCaloDefinitions::fgkDigitDataType|kAliHLTDataOriginPHOS); | |
92 | // } | |
93 | ||
94 | // AliHLTComponentDataType | |
95 | // AliHLTCaloClusterizerComponent::GetOutputDataType() | |
96 | // { | |
97 | // //See headerfile for documentation | |
98 | // return AliHLTCaloDefinitions::fgkRecPointDataType|kAliHLTDataOriginPHOS; | |
99 | // } | |
100 | ||
101 | // void | |
102 | // AliHLTCaloClusterizerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier ) | |
103 | ||
104 | // { | |
105 | // //See headerfile for documentation | |
106 | // constBase = sizeof(AliHLTCaloRecPointHeaderStruct) + sizeof(AliHLTCaloRecPointDataStruct) + (sizeof(AliHLTCaloDigitDataStruct) << 7); //Reasonable estimate... ; | |
107 | // inputMultiplier = 1.5; | |
108 | // } | |
109 | ||
110 | int | |
111 | AliHLTCaloClusterizerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, | |
112 | AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size, | |
113 | std::vector<AliHLTComponentBlockData>& outputBlocks) | |
114 | { | |
115 | //See headerfile for documentation | |
116 | ||
117 | if(blocks == 0) return 0; | |
118 | ||
119 | UInt_t offset = 0; | |
120 | UInt_t mysize = 0; | |
121 | Int_t nRecPoints = 0; | |
122 | Int_t nDigits = 0; | |
123 | Int_t digCount = 0; | |
124 | ||
125 | UInt_t availableSize = size; | |
126 | AliHLTUInt8_t* outBPtr; | |
127 | outBPtr = outputPtr; | |
128 | const AliHLTComponentBlockData* iter = 0; | |
129 | unsigned long ndx; | |
130 | ||
131 | UInt_t specification = 0; | |
132 | ||
133 | AliHLTCaloDigitDataStruct *digitDataPtr = 0; | |
134 | ||
135 | // delete fAnalyserPtr; | |
136 | // fAnalyserPtr = new AliHLTCaloClusterAnalyser(); | |
137 | // | |
138 | // Adding together all the digits, should be put in standalone method | |
139 | for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ ) | |
140 | { | |
141 | iter = blocks+ndx; | |
142 | // HLTError("Got block"); | |
143 | if (iter->fDataType == (AliHLTCaloDefinitions::fgkDigitDataType|fDataOrigin)) | |
144 | { | |
145 | ||
146 | // fDigitsPointerArray[digCount] = reinterpret_cast<AliHLTCaloDigitDataStruct*>(iter->fPtr); | |
147 | ||
148 | //cout << "Digits pointer array [" << digCount << "]: " << fDigitsPointerArray[digCount] << endl; | |
149 | // Update the number of digits | |
150 | nDigits = iter->fSize/sizeof(AliHLTCaloDigitDataStruct);; | |
151 | // digCount += nDigits; | |
152 | // HLTError("Got %d digits", nDigits); | |
153 | ||
154 | availableSize -= iter->fSize; | |
155 | ||
156 | specification = specification|iter->fSpecification; | |
157 | ||
158 | digitDataPtr = reinterpret_cast<AliHLTCaloDigitDataStruct*>(iter->fPtr); | |
159 | for (Int_t i = 0; i < nDigits; i++) | |
160 | { | |
161 | fDigitsPointerArray[digCount] = digitDataPtr; | |
162 | digCount++; | |
163 | digitDataPtr++; | |
164 | } | |
165 | } | |
166 | } | |
167 | ||
168 | if(digCount > 0) | |
169 | { | |
170 | ||
171 | AliHLTCaloClusterHeaderStruct* caloClusterHeaderPtr = reinterpret_cast<AliHLTCaloClusterHeaderStruct*>(outBPtr); | |
172 | caloClusterHeaderPtr->fNDigits = digCount; | |
173 | ||
174 | outBPtr += sizeof(AliHLTCaloClusterHeaderStruct); | |
175 | mysize += sizeof(AliHLTCaloClusterHeaderStruct); | |
176 | ||
177 | // Sort the digit pointers | |
178 | qsort(fDigitsPointerArray, digCount, sizeof(AliHLTCaloDigitDataStruct*), CompareDigits); | |
179 | ||
180 | // Copy the digits to the output | |
181 | fOutputDigitsArray = reinterpret_cast<AliHLTCaloDigitDataStruct*>(outBPtr); | |
182 | for(Int_t n = 0; n < digCount; n++) | |
183 | { | |
184 | memcpy(outBPtr, fDigitsPointerArray[n], sizeof(AliHLTCaloDigitDataStruct)); | |
185 | //fOutputDigitsArray[n] = reinterpret_cast<AliHLTCaloDigitDataStruct*>(outBPtr); | |
186 | outBPtr = outBPtr + sizeof(AliHLTCaloDigitDataStruct); | |
187 | printf("CL: digit energy: %f, ID: %d\n", fOutputDigitsArray[n].fEnergy, fOutputDigitsArray[n].fID); | |
188 | } | |
189 | ||
190 | mysize += digCount*sizeof(AliHLTCaloDigitDataStruct); | |
191 | ||
192 | // AliHLTComponentBlockData bdDigits; | |
193 | // FillBlockData( bdDigits ); | |
194 | // bdDigits.fOffset = offset; | |
195 | // bdDigits.fSize = mysize; | |
196 | // bdDigits.fDataType = iter->fDataType; | |
197 | // bdDigits.fSpecification = specification; | |
198 | // outputBlocks.push_back( bdDigits ); | |
199 | ||
200 | //HLTDebug("Total number of digits: %d", digCount ); | |
201 | ||
202 | nRecPoints = fClusterizerPtr->ClusterizeEvent(digCount); | |
203 | //fClusterizerPtr->CheckDigits(); | |
204 | //HLTDebug("Number of rec points found: %d", nRecPoints); | |
205 | ||
206 | fAnalyserPtr->SetCaloClusterData(reinterpret_cast<AliHLTCaloClusterDataStruct*>(outBPtr)); | |
207 | ||
208 | //fClusterizerPtr->CheckDigits(fClusterizerPtr->GetRecPoints(), fOutputDigitsArray, nRecPoints); | |
209 | ||
210 | fAnalyserPtr->SetRecPointArray(fClusterizerPtr->GetRecPoints(), nRecPoints); | |
211 | ||
212 | //fClusterizerPtr->CheckDigits(fClusterizerPtr->GetRecPoints(), fOutputDigitsArray, nRecPoints); | |
213 | ||
214 | fAnalyserPtr->SetDigitDataArray(fOutputDigitsArray); | |
215 | ||
216 | // fClusterizerPtr->CheckDigits(fClusterizerPtr->GetRecPoints(), fOutputDigitsArray, nRecPoints); | |
217 | ||
218 | Int_t nClusters = fAnalyserPtr->CreateClusters(nRecPoints, size, mysize); | |
219 | ||
220 | caloClusterHeaderPtr->fNClusters = nClusters; | |
221 | ||
222 | // HLTError("Number of clusters: %d", nRecPoints); | |
223 | ||
224 | AliHLTComponentBlockData bd; | |
225 | FillBlockData( bd ); | |
226 | bd.fOffset = offset; | |
227 | bd.fSize = mysize; | |
228 | bd.fDataType = kAliHLTDataTypeCaloCluster | kAliHLTDataOriginPHOS; | |
229 | bd.fSpecification = specification; | |
230 | outputBlocks.push_back( bd ); | |
231 | } | |
232 | ||
233 | size = mysize; | |
234 | ||
235 | return 0; | |
236 | } | |
237 | ||
238 | int | |
239 | AliHLTCaloClusterizerComponent::Reconfigure(const char* cdbEntry, const char* /*chainId*/) | |
240 | { | |
241 | // see header file for class documentation | |
242 | ||
243 | const char* path="HLT/ConfigPHOS/ClusterizerComponent"; | |
244 | ||
245 | if (cdbEntry) path = cdbEntry; | |
246 | ||
247 | return ConfigureFromCDBTObjString(cdbEntry); | |
248 | } | |
249 | ||
250 | int | |
251 | AliHLTCaloClusterizerComponent::ScanConfigurationArgument(int argc, const char **argv) | |
252 | { | |
253 | //See header file for documentation | |
254 | ||
255 | if(argc <= 0) return 0; | |
256 | ||
257 | int i=0; | |
258 | ||
259 | TString argument=argv[i]; | |
260 | ||
261 | if (argument.CompareTo("-digitthreshold") == 0) | |
262 | { | |
263 | if (++i >= argc) return -EPROTO; | |
264 | argument = argv[i]; | |
265 | fClusterizerPtr->SetEmcMinEnergyThreshold(argument.Atof()); | |
266 | return 1; | |
267 | } | |
268 | ||
269 | if (argument.CompareTo("-recpointthreshold") == 0) | |
270 | { | |
271 | if (++i >= argc) return -EPROTO; | |
272 | argument = argv[i]; | |
273 | fClusterizerPtr->SetEmcClusteringThreshold(argument.Atof()); | |
274 | return 1; | |
275 | } | |
276 | return 0; | |
277 | } | |
278 | ||
279 | int | |
280 | AliHLTCaloClusterizerComponent::DoInit(int argc, const char** argv ) | |
281 | { | |
282 | //See headerfile for documentation | |
283 | ||
284 | ||
285 | // | |
286 | ||
287 | // const char *path = "HLT/ConfigPHOS/ClusterizerComponent"; | |
288 | ||
289 | // ConfigureFromCDBTObjString(path); | |
290 | ||
291 | for (int i = 0; i < argc; i++) | |
292 | { | |
293 | ScanConfigurationArgument(i, argv); | |
294 | } | |
295 | ||
296 | return 0; | |
297 | } | |
298 | ||
299 | Int_t | |
300 | AliHLTCaloClusterizerComponent::CompareDigits(const void *dig0, const void *dig1) | |
301 | { | |
302 | // See header file for documentation | |
303 | return (*((AliHLTCaloDigitDataStruct**)(dig0)))->fID - (*((AliHLTCaloDigitDataStruct**)(dig1)))->fID; | |
304 | ||
305 | //return (*((AliHLTCaloDigitDataStruct**)(dig0)))->fID - (*((AliHLTCaloDigitDataStruct**)(dig1)))->fID; | |
306 | } |