]>
Commit | Line | Data |
---|---|---|
4d42193f | 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 | ||
4d42193f | 17 | #include "AliHLTCaloClusterizerComponent.h" |
18 | #include "AliHLTCaloClusterizer.h" | |
f92543f5 | 19 | #include "AliHLTCaloClusterAnalyser.h" |
4d42193f | 20 | #include "AliHLTCaloRecPointDataStruct.h" |
21 | #include "AliHLTCaloRecPointHeaderStruct.h" | |
22 | #include "AliHLTCaloDigitDataStruct.h" | |
23 | #include "AliHLTCaloDigitContainerDataStruct.h" | |
24 | #include "AliHLTCaloDefinitions.h" | |
7c80a370 | 25 | #include "AliHLTCaloClusterDataStruct.h" |
c1e4a18c | 26 | #include "AliHLTCaloRecoParamHandler.h" |
ad44d760 | 27 | #include "TString.h" |
4d42193f | 28 | |
29 | /** @file AliHLTCaloClusterizerComponent.cxx | |
30 | @author Oystein Djuvsland | |
f92543f5 | 31 | @date |
4d42193f | 32 | @brief A clusterizer component for PHOS HLT |
33 | */ | |
34 | ||
35 | // see header file for class documentation | |
36 | // or | |
37 | // refer to README to build package | |
38 | // or | |
39 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
40 | ||
c556a27e | 41 | ClassImp(AliHLTCaloClusterizerComponent); |
42 | ||
f92543f5 | 43 | AliHLTCaloClusterizerComponent::AliHLTCaloClusterizerComponent(TString det): |
44 | AliHLTCaloProcessor(), | |
45 | AliHLTCaloConstantsHandler(det), | |
46 | fDataOrigin('\0'), | |
47 | fAnalyserPtr(0), | |
48 | fRecoParamsPtr(0), | |
78943659 | 49 | fClusterizerPtr(0), |
f92543f5 | 50 | fDigitsPointerArray(0), |
51 | fOutputDigitsArray(0), | |
f92543f5 | 52 | fDigitCount(0), |
53 | fCopyDigitsToOuput(kTRUE) | |
4d42193f | 54 | { |
f92543f5 | 55 | //See headerfile for documentation |
56 | ||
57 | ||
58 | ||
4d42193f | 59 | } |
60 | ||
61 | AliHLTCaloClusterizerComponent::~AliHLTCaloClusterizerComponent() | |
62 | { | |
f92543f5 | 63 | //See headerfile for documentation |
78943659 | 64 | if(fAnalyserPtr) |
4d42193f | 65 | { |
78943659 | 66 | delete fAnalyserPtr; |
67 | fAnalyserPtr = 0; | |
4d42193f | 68 | } |
4d42193f | 69 | } |
70 | ||
4d42193f | 71 | int |
72 | AliHLTCaloClusterizerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, | |
73 | AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size, | |
74 | std::vector<AliHLTComponentBlockData>& outputBlocks) | |
75 | { | |
f92543f5 | 76 | //See headerfile for documentation |
77 | ||
78 | if (blocks == 0) return 0; | |
79 | ||
80 | UInt_t offset = 0; | |
81 | UInt_t mysize = 0; | |
82 | Int_t nRecPoints = 0; | |
83 | Int_t nDigits = 0; | |
84 | Int_t digCount = 0; | |
85 | ||
86 | UInt_t availableSize = size; | |
87 | AliHLTUInt8_t* outBPtr; | |
88 | outBPtr = outputPtr; | |
89 | const AliHLTComponentBlockData* iter = 0; | |
90 | unsigned long ndx; | |
91 | ||
92 | UInt_t specification = 0; | |
93 | ||
94 | AliHLTCaloDigitDataStruct *digitDataPtr = 0; | |
95 | ||
96 | // Adding together all the digits, should be put in standalone method | |
97 | for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ ) | |
4d42193f | 98 | { |
f92543f5 | 99 | iter = blocks+ndx; |
100 | ||
101 | if (iter->fDataType == (AliHLTCaloDefinitions::fgkDigitDataType|fDataOrigin)) | |
102 | { | |
103 | ||
104 | // Update the number of digits | |
105 | nDigits = iter->fSize/sizeof(AliHLTCaloDigitDataStruct); | |
106 | availableSize -= iter->fSize; | |
107 | ||
108 | specification = specification|iter->fSpecification; | |
109 | ||
110 | digitDataPtr = reinterpret_cast<AliHLTCaloDigitDataStruct*>(iter->fPtr); | |
111 | ||
112 | // We copy the digits to the digit buffer used by the clusterizer | |
113 | // This is convinient since we want the digits from all DDLs before starting | |
114 | // Could be changed if this is a bottle neck. | |
115 | for (Int_t i = 0; i < nDigits; i++) | |
116 | { | |
117 | fDigitsPointerArray[digCount] = digitDataPtr; | |
118 | digCount++; | |
119 | digitDataPtr++; | |
120 | } | |
121 | } | |
4d42193f | 122 | } |
4d42193f | 123 | |
f92543f5 | 124 | if (digCount > 0) |
4d42193f | 125 | { |
f92543f5 | 126 | |
127 | AliHLTCaloClusterHeaderStruct* caloClusterHeaderPtr = reinterpret_cast<AliHLTCaloClusterHeaderStruct*>(outBPtr); | |
128 | caloClusterHeaderPtr->fNDigits = digCount; | |
129 | ||
130 | outBPtr += sizeof(AliHLTCaloClusterHeaderStruct); | |
131 | mysize += sizeof(AliHLTCaloClusterHeaderStruct); | |
132 | ||
133 | // Sort the digit pointers | |
31b89da4 | 134 | // qsort(fDigitsPointerArray, digCount, sizeof(AliHLTCaloDigitDataStruct*), CompareDigits); |
4d42193f | 135 | |
f92543f5 | 136 | |
137 | if (fCopyDigitsToOuput) | |
138 | { | |
139 | // Copy the digits to the output | |
140 | fOutputDigitsArray = reinterpret_cast<AliHLTCaloDigitDataStruct*>(outBPtr); | |
141 | ||
142 | for (Int_t n = 0; n < digCount; n++) | |
143 | { | |
144 | memcpy(outBPtr, fDigitsPointerArray[n], sizeof(AliHLTCaloDigitDataStruct)); | |
145 | //fOutputDigitsArray[n] = reinterpret_cast<AliHLTCaloDigitDataStruct*>(outBPtr); | |
146 | outBPtr = outBPtr + sizeof(AliHLTCaloDigitDataStruct); | |
147 | } | |
148 | } | |
149 | ||
150 | // Update the size of the output we have used, needs to be removed if we don't push the digits | |
151 | mysize += digCount*sizeof(AliHLTCaloDigitDataStruct); | |
152 | ||
153 | // Do the clusterisation | |
154 | nRecPoints = fClusterizerPtr->ClusterizeEvent(digCount); | |
155 | ||
156 | HLTDebug("Number of rec points found: %d", nRecPoints); | |
157 | ||
158 | // Give the cluster output to the analyser | |
159 | fAnalyserPtr->SetCaloClusterData(reinterpret_cast<AliHLTCaloClusterDataStruct*>(outBPtr)); | |
160 | ||
161 | // Give the rec points to the analyser (input) | |
162 | fAnalyserPtr->SetRecPointArray(fClusterizerPtr->GetRecPoints(), nRecPoints); | |
163 | ||
164 | // Give the digits to the analyser | |
165 | //fAnalyserPtr->SetDigitDataArray(fOutputDigitsArray); | |
166 | fAnalyserPtr->SetDigitDataArray(fDigitsPointerArray); | |
167 | ||
168 | // Then we create the clusters | |
169 | Int_t nClusters = fAnalyserPtr->CreateClusters(nRecPoints, size, mysize); | |
170 | ||
171 | if (nClusters < 0) | |
172 | { | |
173 | HLTError("Error in clusterisation"); | |
174 | caloClusterHeaderPtr->fNClusters = 0; | |
175 | } | |
176 | else | |
177 | { | |
178 | caloClusterHeaderPtr->fNClusters = nClusters; | |
179 | } | |
180 | ||
181 | HLTDebug("Number of clusters: %d", nRecPoints); | |
182 | ||
183 | AliHLTComponentBlockData bd; | |
184 | FillBlockData( bd ); | |
185 | bd.fOffset = offset; | |
186 | bd.fSize = mysize; | |
187 | bd.fDataType = kAliHLTDataTypeCaloCluster | fDataOrigin; | |
188 | bd.fSpecification = specification; | |
189 | outputBlocks.push_back( bd ); | |
ad44d760 | 190 | } |
191 | ||
f92543f5 | 192 | size = mysize; |
193 | ||
194 | return 0; | |
4d42193f | 195 | } |
196 | ||
f92543f5 | 197 | int |
4d42193f | 198 | AliHLTCaloClusterizerComponent::Reconfigure(const char* cdbEntry, const char* /*chainId*/) |
f92543f5 | 199 | { |
200 | // see header file for class documentation | |
4d42193f | 201 | |
f92543f5 | 202 | const char* path="HLT/ConfigPHOS/ClusterizerComponent"; |
4d42193f | 203 | |
f92543f5 | 204 | if (cdbEntry) path = cdbEntry; |
4d42193f | 205 | |
f92543f5 | 206 | return ConfigureFromCDBTObjString(cdbEntry); |
4d42193f | 207 | } |
208 | ||
f92543f5 | 209 | int |
4d42193f | 210 | AliHLTCaloClusterizerComponent::ScanConfigurationArgument(int argc, const char **argv) |
211 | { | |
f92543f5 | 212 | //See header file for documentation |
4d42193f | 213 | |
f92543f5 | 214 | if (argc <= 0) return 0; |
4d42193f | 215 | |
f92543f5 | 216 | int i=0; |
4d42193f | 217 | |
f92543f5 | 218 | TString argument=argv[i]; |
4d42193f | 219 | |
f92543f5 | 220 | if (argument.CompareTo("-digitthreshold") == 0) |
4d42193f | 221 | { |
f92543f5 | 222 | if (++i >= argc) return -EPROTO; |
223 | argument = argv[i]; | |
224 | fClusterizerPtr->SetEmcMinEnergyThreshold(argument.Atof()); | |
225 | return 1; | |
4d42193f | 226 | } |
227 | ||
f92543f5 | 228 | if (argument.CompareTo("-recpointthreshold") == 0) |
4d42193f | 229 | { |
f92543f5 | 230 | if (++i >= argc) return -EPROTO; |
231 | argument = argv[i]; | |
232 | fClusterizerPtr->SetEmcClusteringThreshold(argument.Atof()); | |
233 | return 1; | |
4d42193f | 234 | } |
f92543f5 | 235 | |
236 | if (argument.CompareTo("-cutonsinglecell") == 0) | |
38a3b2ad | 237 | { |
f92543f5 | 238 | if (++i >= argc) return -EPROTO; |
239 | argument = argv[i]; | |
240 | fAnalyserPtr->SetCutOnSingleCellClusters(true, argument.Atof()); | |
241 | return 1; | |
38a3b2ad | 242 | } |
f92543f5 | 243 | if (argument.CompareTo("-sortbyposition") == 0) |
31b89da4 | 244 | { |
f92543f5 | 245 | fClusterizerPtr->SetSortDigitsByPosition(); |
246 | return 1; | |
31b89da4 | 247 | } |
f92543f5 | 248 | |
249 | return 0; | |
4d42193f | 250 | } |
251 | ||
252 | int | |
253 | AliHLTCaloClusterizerComponent::DoInit(int argc, const char** argv ) | |
254 | { | |
f92543f5 | 255 | //See headerfile for documentation |
256 | ||
257 | fDigitsPointerArray = new AliHLTCaloDigitDataStruct*[fCaloConstants->GetNXCOLUMNSMOD()*fCaloConstants->GetNZROWSMOD()]; | |
258 | ||
f92543f5 | 259 | fClusterizerPtr->SetDigitArray(fDigitsPointerArray); |
260 | ||
261 | fClusterizerPtr->SetSortDigitsByEnergy(); | |
262 | ||
263 | fAnalyserPtr = new AliHLTCaloClusterAnalyser(); | |
264 | ||
265 | if (fCaloConstants->GetDETNAME() == "PHOS") | |
266 | { | |
267 | fAnalyserPtr->SetClusterType(kPHOSCluster); | |
268 | } | |
269 | else if (fCaloConstants->GetDETNAME() == "EMCAL") | |
270 | { | |
271 | fAnalyserPtr->SetClusterType(kEMCALClusterv1); | |
272 | } | |
273 | else | |
274 | { | |
275 | fAnalyserPtr->SetClusterType(kUndef); | |
276 | } | |
277 | InitialiseGeometry(); | |
278 | if (fRecoParamsPtr) | |
4d42193f | 279 | { |
f92543f5 | 280 | if (!fRecoParamsPtr->GetParametersFromCDB()) |
281 | { | |
282 | fAnalyserPtr->SetRecoParamHandler(fRecoParamsPtr); | |
283 | fClusterizerPtr->SetEmcClusteringThreshold(fRecoParamsPtr->GetRecPointThreshold()); | |
284 | fClusterizerPtr->SetEmcMinEnergyThreshold(fRecoParamsPtr->GetRecPointMemberThreshold()); | |
285 | } | |
4d42193f | 286 | } |
f92543f5 | 287 | // |
4d42193f | 288 | |
f92543f5 | 289 | // const char *path = "HLT/ConfigPHOS/ClusterizerComponent"; |
290 | ||
291 | // ConfigureFromCDBTObjString(path); | |
292 | ||
293 | for (int i = 0; i < argc; i++) | |
294 | { | |
295 | ScanConfigurationArgument(i, argv); | |
296 | } | |
297 | ||
298 | return 0; | |
4d42193f | 299 | } |
427c373f | 300 | int AliHLTCaloClusterizerComponent::DoDeinit() |
301 | { | |
f92543f5 | 302 | // See header file for documentation |
303 | if (fDigitsPointerArray) | |
304 | { | |
305 | delete [] fDigitsPointerArray; | |
306 | fDigitsPointerArray = 0; | |
307 | } | |
308 | if (fClusterizerPtr) | |
309 | { | |
310 | delete fClusterizerPtr; | |
311 | fClusterizerPtr = 0; | |
312 | } | |
313 | if (fAnalyserPtr) | |
314 | { | |
315 | delete fAnalyserPtr; | |
316 | fAnalyserPtr = 0; | |
317 | } | |
318 | return 0; | |
427c373f | 319 | } |
4d42193f | 320 | |
f92543f5 | 321 | Int_t |
ad44d760 | 322 | AliHLTCaloClusterizerComponent::CompareDigits(const void *dig0, const void *dig1) |
4d42193f | 323 | { |
f92543f5 | 324 | // See header file for documentation |
325 | return (*((AliHLTCaloDigitDataStruct**)(dig0)))->fID - (*((AliHLTCaloDigitDataStruct**)(dig1)))->fID; | |
7c80a370 | 326 | |
f92543f5 | 327 | //return (*((AliHLTCaloDigitDataStruct**)(dig0)))->fID - (*((AliHLTCaloDigitDataStruct**)(dig1)))->fID; |
4d42193f | 328 | } |