]>
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 "AliHLTCaloRecoParamHandler.h" | |
27 | #include "TString.h" | |
28 | ||
29 | /** @file AliHLTCaloClusterizerComponent.cxx | |
30 | @author Oystein Djuvsland | |
31 | @date | |
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 | ||
41 | AliHLTCaloClusterizerComponent::AliHLTCaloClusterizerComponent(TString det): | |
42 | AliHLTCaloProcessor(), | |
43 | AliHLTCaloConstantsHandler(det), | |
44 | fDataOrigin('\0'), | |
45 | fAnalyserPtr(0), | |
46 | fRecoParamsPtr(0), | |
47 | fDigitsPointerArray(0), | |
48 | fOutputDigitsArray(0), | |
49 | fClusterizerPtr(0), | |
50 | fDigitCount(0), | |
51 | fGeometryInitialised(true) | |
52 | { | |
53 | //See headerfile for documentation | |
54 | ||
55 | fDigitsPointerArray = new AliHLTCaloDigitDataStruct*[fCaloConstants->GetNXCOLUMNSMOD()*fCaloConstants->GetNZROWSMOD()]; | |
56 | ||
57 | fClusterizerPtr = new AliHLTCaloClusterizer(det); | |
58 | ||
59 | fClusterizerPtr->SetDigitArray(fDigitsPointerArray); | |
60 | ||
61 | fAnalyserPtr = new AliHLTCaloClusterAnalyser(); | |
62 | ||
63 | if(det == "PHOS") | |
64 | { | |
65 | fAnalyserPtr->SetClusterType(kPHOSCluster); | |
66 | } | |
67 | else if(det == "EMCAL") | |
68 | { | |
69 | fAnalyserPtr->SetClusterType(kEMCALClusterv1); | |
70 | } | |
71 | else | |
72 | { | |
73 | fAnalyserPtr->SetClusterType(kUndef); | |
74 | } | |
75 | ||
76 | ||
77 | } | |
78 | ||
79 | AliHLTCaloClusterizerComponent::~AliHLTCaloClusterizerComponent() | |
80 | { | |
81 | //See headerfile for documentation | |
82 | delete fAnalyserPtr; | |
83 | if(fClusterizerPtr) | |
84 | { | |
85 | delete fClusterizerPtr; | |
86 | fClusterizerPtr = 0; | |
87 | } | |
88 | } | |
89 | ||
90 | ||
91 | int | |
92 | AliHLTCaloClusterizerComponent::Deinit() | |
93 | { | |
94 | //See headerfile for documentation | |
95 | ||
96 | if (fClusterizerPtr) | |
97 | { | |
98 | delete fClusterizerPtr; | |
99 | fClusterizerPtr = 0; | |
100 | } | |
101 | ||
102 | return 0; | |
103 | } | |
104 | ||
105 | int | |
106 | AliHLTCaloClusterizerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, | |
107 | AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size, | |
108 | std::vector<AliHLTComponentBlockData>& outputBlocks) | |
109 | { | |
110 | //See headerfile for documentation | |
111 | ||
112 | if(blocks == 0) return 0; | |
113 | ||
114 | UInt_t offset = 0; | |
115 | UInt_t mysize = 0; | |
116 | Int_t nRecPoints = 0; | |
117 | Int_t nDigits = 0; | |
118 | Int_t digCount = 0; | |
119 | ||
120 | UInt_t availableSize = size; | |
121 | AliHLTUInt8_t* outBPtr; | |
122 | outBPtr = outputPtr; | |
123 | const AliHLTComponentBlockData* iter = 0; | |
124 | unsigned long ndx; | |
125 | ||
126 | UInt_t specification = 0; | |
127 | ||
128 | AliHLTCaloDigitDataStruct *digitDataPtr = 0; | |
129 | if(fGeometryInitialised == false) InitialiseGeometry(); | |
130 | // Adding together all the digits, should be put in standalone method | |
131 | for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ ) | |
132 | { | |
133 | iter = blocks+ndx; | |
134 | // HLTError("Got block"); | |
135 | if (iter->fDataType == (AliHLTCaloDefinitions::fgkDigitDataType|fDataOrigin)) | |
136 | { | |
137 | ||
138 | // Update the number of digits | |
139 | nDigits = iter->fSize/sizeof(AliHLTCaloDigitDataStruct); | |
140 | availableSize -= iter->fSize; | |
141 | ||
142 | specification = specification|iter->fSpecification; | |
143 | ||
144 | digitDataPtr = reinterpret_cast<AliHLTCaloDigitDataStruct*>(iter->fPtr); | |
145 | for (Int_t i = 0; i < nDigits; i++) | |
146 | { | |
147 | fDigitsPointerArray[digCount] = digitDataPtr; | |
148 | digCount++; | |
149 | digitDataPtr++; | |
150 | } | |
151 | } | |
152 | } | |
153 | ||
154 | if(digCount > 0) | |
155 | { | |
156 | ||
157 | AliHLTCaloClusterHeaderStruct* caloClusterHeaderPtr = reinterpret_cast<AliHLTCaloClusterHeaderStruct*>(outBPtr); | |
158 | caloClusterHeaderPtr->fNDigits = digCount; | |
159 | ||
160 | outBPtr += sizeof(AliHLTCaloClusterHeaderStruct); | |
161 | mysize += sizeof(AliHLTCaloClusterHeaderStruct); | |
162 | ||
163 | // Sort the digit pointers | |
164 | qsort(fDigitsPointerArray, digCount, sizeof(AliHLTCaloDigitDataStruct*), CompareDigits); | |
165 | ||
166 | // Copy the digits to the output | |
167 | fOutputDigitsArray = reinterpret_cast<AliHLTCaloDigitDataStruct*>(outBPtr); | |
168 | for(Int_t n = 0; n < digCount; n++) | |
169 | { | |
170 | memcpy(outBPtr, fDigitsPointerArray[n], sizeof(AliHLTCaloDigitDataStruct)); | |
171 | //fOutputDigitsArray[n] = reinterpret_cast<AliHLTCaloDigitDataStruct*>(outBPtr); | |
172 | outBPtr = outBPtr + sizeof(AliHLTCaloDigitDataStruct); | |
173 | } | |
174 | ||
175 | mysize += digCount*sizeof(AliHLTCaloDigitDataStruct); | |
176 | ||
177 | //HLTDebug("Total number of digits: %d", digCount ); | |
178 | ||
179 | nRecPoints = fClusterizerPtr->ClusterizeEvent(digCount); | |
180 | ||
181 | //HLTDebug("Number of rec points found: %d", nRecPoints); | |
182 | fAnalyserPtr->SetCaloClusterData(reinterpret_cast<AliHLTCaloClusterDataStruct*>(outBPtr)); | |
183 | ||
184 | fAnalyserPtr->SetRecPointArray(fClusterizerPtr->GetRecPoints(), nRecPoints); | |
185 | ||
186 | fAnalyserPtr->SetDigitDataArray(fOutputDigitsArray); | |
187 | ||
188 | Int_t nClusters = fAnalyserPtr->CreateClusters(nRecPoints, size, mysize); | |
189 | ||
190 | if (nClusters < 0) | |
191 | { | |
192 | caloClusterHeaderPtr->fNClusters = 0; | |
193 | } | |
194 | else | |
195 | { | |
196 | caloClusterHeaderPtr->fNClusters = nClusters; | |
197 | } | |
198 | ||
199 | //HLTDebug("Number of clusters: %d", nRecPoints); | |
200 | ||
201 | AliHLTComponentBlockData bd; | |
202 | FillBlockData( bd ); | |
203 | bd.fOffset = offset; | |
204 | bd.fSize = mysize; | |
205 | bd.fDataType = kAliHLTDataTypeCaloCluster | fDataOrigin; | |
206 | bd.fSpecification = specification; | |
207 | outputBlocks.push_back( bd ); | |
208 | } | |
209 | ||
210 | size = mysize; | |
211 | ||
212 | return 0; | |
213 | } | |
214 | ||
215 | int | |
216 | AliHLTCaloClusterizerComponent::Reconfigure(const char* cdbEntry, const char* /*chainId*/) | |
217 | { | |
218 | // see header file for class documentation | |
219 | ||
220 | const char* path="HLT/ConfigPHOS/ClusterizerComponent"; | |
221 | ||
222 | if (cdbEntry) path = cdbEntry; | |
223 | ||
224 | return ConfigureFromCDBTObjString(cdbEntry); | |
225 | } | |
226 | ||
227 | int | |
228 | AliHLTCaloClusterizerComponent::ScanConfigurationArgument(int argc, const char **argv) | |
229 | { | |
230 | //See header file for documentation | |
231 | ||
232 | if(argc <= 0) return 0; | |
233 | ||
234 | int i=0; | |
235 | ||
236 | TString argument=argv[i]; | |
237 | ||
238 | if (argument.CompareTo("-digitthreshold") == 0) | |
239 | { | |
240 | if (++i >= argc) return -EPROTO; | |
241 | argument = argv[i]; | |
242 | fClusterizerPtr->SetEmcMinEnergyThreshold(argument.Atof()); | |
243 | return 1; | |
244 | } | |
245 | ||
246 | if (argument.CompareTo("-recpointthreshold") == 0) | |
247 | { | |
248 | if (++i >= argc) return -EPROTO; | |
249 | argument = argv[i]; | |
250 | fClusterizerPtr->SetEmcClusteringThreshold(argument.Atof()); | |
251 | return 1; | |
252 | } | |
253 | return 0; | |
254 | } | |
255 | ||
256 | int | |
257 | AliHLTCaloClusterizerComponent::DoInit(int argc, const char** argv ) | |
258 | { | |
259 | //See headerfile for documentation | |
260 | ||
261 | if(fRecoParamsPtr) | |
262 | { | |
263 | if(!fRecoParamsPtr->GetParametersFromCDB()) | |
264 | { | |
265 | fAnalyserPtr->SetRecoParamHandler(fRecoParamsPtr); | |
266 | fClusterizerPtr->SetEmcClusteringThreshold(fRecoParamsPtr->GetRecPointThreshold()); | |
267 | fClusterizerPtr->SetEmcMinEnergyThreshold(fRecoParamsPtr->GetRecPointMemberThreshold()); | |
268 | } | |
269 | } | |
270 | // | |
271 | ||
272 | // const char *path = "HLT/ConfigPHOS/ClusterizerComponent"; | |
273 | ||
274 | // ConfigureFromCDBTObjString(path); | |
275 | ||
276 | for (int i = 0; i < argc; i++) | |
277 | { | |
278 | ScanConfigurationArgument(i, argv); | |
279 | } | |
280 | ||
281 | return 0; | |
282 | } | |
283 | ||
284 | Int_t | |
285 | AliHLTCaloClusterizerComponent::CompareDigits(const void *dig0, const void *dig1) | |
286 | { | |
287 | // See header file for documentation | |
288 | return (*((AliHLTCaloDigitDataStruct**)(dig0)))->fID - (*((AliHLTCaloDigitDataStruct**)(dig1)))->fID; | |
289 | ||
290 | //return (*((AliHLTCaloDigitDataStruct**)(dig0)))->fID - (*((AliHLTCaloDigitDataStruct**)(dig1)))->fID; | |
291 | } |