]>
Commit | Line | Data |
---|---|---|
ea367f6a | 1 | // $Id: AliHLTCaloClusterAnalyser.cxx 35107 2009-09-30 01:45:06Z phille $ |
2 | ||
3 | /************************************************************************** | |
4 | * This file is property of and copyright by the ALICE HLT Project * | |
5 | * All rights reserved. * | |
6 | * * | |
7 | * Primary Authors: Oystein Djuvsland * | |
8 | * * | |
9 | * Permission to use, copy, modify and distribute this software and its * | |
10 | * documentation strictly for non-commercial purposes is hereby granted * | |
11 | * without fee, provided that the above copyright notice appears in all * | |
12 | * copies and that both the copyright notice and this permission notice * | |
13 | * appear in the supporting documentation. The authors make no claims * | |
14 | * about the suitability of this software for any purpose. It is * | |
15 | * provided "as is" without express or implied warranty. * | |
16 | **************************************************************************/ | |
17 | ||
18 | /** | |
19 | * @file AliHLTCaloClusterAnalyser.cxx | |
20 | * @author Oystein Djuvsland | |
21 | * @date | |
22 | * @brief Cluster analyser for Calo HLT | |
23 | */ | |
24 | ||
25 | // see header file for class documentation | |
26 | // or | |
27 | // refer to README to build package | |
28 | // or | |
29 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
30 | ||
31 | #include "AliHLTCaloClusterAnalyser.h" | |
32 | #include "AliHLTCaloRecPointHeaderStruct.h" | |
33 | #include "AliHLTCaloRecPointDataStruct.h" | |
34 | #include "AliHLTCaloClusterDataStruct.h" | |
35 | //#include "AliHLTCaloPhysicsAnalyzer.h" | |
7c80a370 | 36 | #include "AliHLTCaloGeometry.h" |
ea367f6a | 37 | #include "AliESDCaloCluster.h" |
38 | #include "TMath.h" | |
39 | #include "TVector3.h" | |
73d6f579 | 40 | #include "TH1F.h" |
41 | #include "TFile.h" | |
c1e4a18c | 42 | #include "AliHLTCaloRecoParamHandler.h" |
ea367f6a | 43 | |
44 | ClassImp(AliHLTCaloClusterAnalyser); | |
45 | ||
7c80a370 | 46 | AliHLTCaloClusterAnalyser::AliHLTCaloClusterAnalyser() : |
ea367f6a | 47 | // AliHLTCaloBase(), |
7c80a370 | 48 | fLogWeight(4.5), |
49 | fRecPointArray(0), | |
50 | fDigitDataArray(0), | |
ea367f6a | 51 | fNRecPoints(0), |
52 | fCaloClusterDataPtr(0), | |
53 | fCaloClusterHeaderPtr(0), | |
ea367f6a | 54 | //fAnalyzerPtr(0), |
55 | fDoClusterFit(false), | |
56 | fHaveCPVInfo(false), | |
57 | fDoPID(false), | |
7c80a370 | 58 | fHaveDistanceToBadChannel(false), |
73d6f579 | 59 | fGeometry(0), |
4b759e43 | 60 | #ifndef HAVE_NOT_ALIVCLUSTER // backward compatibility for r42844 |
c8fe2783 | 61 | fClusterType(AliVCluster::kPHOSNeutral), |
4b759e43 | 62 | #else |
63 | fClusterType(AliESDCaloCluster::kPHOSCluster), | |
64 | #endif | |
38a3b2ad | 65 | fRecoParamsPtr(0), |
66 | fCutOnSingleCellClusters(false), | |
67 | fSingleCellEnergyCut(0.5) | |
ea367f6a | 68 | { |
69 | //See header file for documentation | |
ea367f6a | 70 | } |
71 | ||
72 | AliHLTCaloClusterAnalyser::~AliHLTCaloClusterAnalyser() | |
73 | { | |
98baf84d | 74 | // See header file for class documentation |
ea367f6a | 75 | } |
76 | ||
77 | void | |
7c80a370 | 78 | AliHLTCaloClusterAnalyser::SetCaloClusterData(AliHLTCaloClusterDataStruct *caloClusterDataPtr) |
ea367f6a | 79 | { |
80 | //see header file for documentation | |
81 | fCaloClusterDataPtr = caloClusterDataPtr; | |
82 | } | |
7c80a370 | 83 | |
ea367f6a | 84 | void |
7c80a370 | 85 | AliHLTCaloClusterAnalyser::SetRecPointArray(AliHLTCaloRecPointDataStruct **recPointDataPtr, Int_t nRecPoints) |
ea367f6a | 86 | { |
7c80a370 | 87 | fRecPointArray = recPointDataPtr; |
88 | fNRecPoints = nRecPoints; | |
89 | } | |
90 | ||
91 | void | |
f92543f5 | 92 | AliHLTCaloClusterAnalyser::SetDigitDataArray(AliHLTCaloDigitDataStruct **digits) |
7c80a370 | 93 | { |
94 | // AliHLTCaloClusterizer cl("PHOS"); | |
95 | // cl.CheckDigits(fRecPointArray, digits, fNRecPoints); | |
96 | fDigitDataArray = digits; | |
97 | //cl.CheckDigits(fRecPointArray, fDigitDataArray, fNRecPoints); | |
ea367f6a | 98 | } |
99 | ||
100 | Int_t | |
101 | AliHLTCaloClusterAnalyser::CalculateCenterOfGravity() | |
102 | { | |
103 | //see header file for documentation | |
104 | Float_t wtot = 0.; | |
105 | Float_t x = 0.; | |
106 | Float_t z = 0.; | |
107 | Float_t xi = 0.; | |
108 | Float_t zi = 0.; | |
109 | ||
110 | AliHLTCaloDigitDataStruct *digit = 0; | |
ea367f6a | 111 | |
112 | UInt_t iDigit = 0; | |
113 | ||
114 | for(Int_t iRecPoint=0; iRecPoint < fNRecPoints; iRecPoint++) | |
115 | { | |
7c80a370 | 116 | AliHLTCaloRecPointDataStruct *recPoint = fRecPointArray[iRecPoint]; |
ad44d760 | 117 | // digit = &(recPoint->fDigits); |
98baf84d | 118 | |
7c80a370 | 119 | Int_t *digitIndexPtr = &(recPoint->fDigits); |
256f1bf0 | 120 | wtot = 0; |
121 | x = 0; | |
122 | z = 0; | |
123 | ||
c1e4a18c | 124 | /* Float_t maxAmp = 0; |
256f1bf0 | 125 | Int_t maxX = 0; |
c1e4a18c | 126 | Int_t maxZ = 0;*/ |
127 | for(iDigit = 0; iDigit < recPoint->fMultiplicity; iDigit++) | |
ea367f6a | 128 | { |
7c80a370 | 129 | |
f92543f5 | 130 | digit = fDigitDataArray[*digitIndexPtr]; |
98baf84d | 131 | |
a6db7bcd | 132 | xi = digit->fX+0.5; |
133 | zi = digit->fZ+0.5; | |
98baf84d | 134 | |
ea367f6a | 135 | if (recPoint->fAmp > 0 && digit->fEnergy > 0) |
136 | { | |
137 | Float_t w = TMath::Max( 0., fLogWeight + TMath::Log( digit->fEnergy / recPoint->fAmp ) ) ; | |
138 | x += xi * w ; | |
139 | z += zi * w ; | |
140 | wtot += w ; | |
256f1bf0 | 141 | /* if(digit->fEnergy > maxAmp) |
142 | { | |
143 | maxAmp = digit->fEnergy; | |
c1e4a18c | 144 | maxX = digit->fX;// + 0.5; |
145 | maxZ = digit->fZ;// + 0.5; | |
256f1bf0 | 146 | }*/ |
ea367f6a | 147 | } |
7c80a370 | 148 | digitIndexPtr++; |
ea367f6a | 149 | } |
98baf84d | 150 | |
ea367f6a | 151 | if (wtot>0) |
152 | { | |
153 | recPoint->fX = x/wtot ; | |
154 | recPoint->fZ = z/wtot ; | |
155 | } | |
156 | else | |
157 | { | |
158 | recPoint->fAmp = 0; | |
159 | } | |
256f1bf0 | 160 | // printf("Max digit: E = %f, x = %d, z= %d, cluster: E = %f, x = %f, z = %f\n" , maxAmp, maxX, maxZ, recPoint->fAmp, recPoint->fX, recPoint->fZ); |
ea367f6a | 161 | } |
162 | return 0; | |
163 | } | |
164 | ||
165 | ||
166 | Int_t | |
167 | AliHLTCaloClusterAnalyser::CalculateRecPointMoments() | |
cd9e2797 | 168 | { |
ea367f6a | 169 | //See header file for documentation |
170 | return 0; | |
171 | } | |
172 | ||
173 | Int_t | |
174 | AliHLTCaloClusterAnalyser::CalculateClusterMoments(AliHLTCaloRecPointDataStruct */*recPointPtr*/, AliHLTCaloClusterDataStruct* /*clusterPtr*/) | |
175 | { | |
176 | //See header file for documentation | |
177 | return 0; | |
178 | } | |
179 | ||
180 | ||
181 | Int_t | |
182 | AliHLTCaloClusterAnalyser::DeconvoluteClusters() | |
183 | { | |
184 | //See header file for documentation | |
185 | return 0; | |
186 | } | |
187 | ||
188 | Int_t | |
7c80a370 | 189 | AliHLTCaloClusterAnalyser::CreateClusters(Int_t nRecPoints, UInt_t availableSize, UInt_t& totSize) |
ea367f6a | 190 | { |
191 | //See header file for documentation | |
192 | ||
c1e4a18c | 193 | if(fRecoParamsPtr) |
194 | { | |
195 | fLogWeight = fRecoParamsPtr->GetLogWeight(); | |
196 | } | |
73d6f579 | 197 | |
7c80a370 | 198 | fNRecPoints = nRecPoints; |
199 | ||
200 | if(fGeometry == 0) | |
201 | { | |
202 | HLTError("No geometry object is initialised, creation of clusters stopped"); | |
73cdb797 | 203 | return -1; |
7c80a370 | 204 | } |
205 | ||
206 | CalculateCenterOfGravity(); | |
207 | ||
ad44d760 | 208 | // AliHLTCaloDigitDataStruct* digitPtr = &(recPointPtr->fDigits); |
209 | AliHLTCaloDigitDataStruct* digitPtr = 0; | |
210 | ||
73d6f579 | 211 | AliHLTCaloClusterDataStruct* caloClusterPtr = 0; |
7fdb2519 | 212 | |
213 | // Int_t id = -1; | |
ea367f6a | 214 | TVector3 globalPos; |
215 | ||
216 | for(Int_t i = 0; i < fNRecPoints; i++) //TODO needs fix when we start unfolding (number of clusters not necessarily same as number of recpoints gotten from the clusterizer | |
217 | { | |
73d6f579 | 218 | if((availableSize - totSize) < sizeof(AliHLTCaloClusterDataStruct)) |
219 | { | |
9a0cbaba | 220 | HLTError("Out of buffer: available size is: %d, total size used: %d", availableSize, totSize); |
73d6f579 | 221 | return -ENOBUFS; |
222 | } | |
38a3b2ad | 223 | |
224 | AliHLTCaloRecPointDataStruct *recPointPtr = fRecPointArray[i]; | |
225 | ||
226 | if(fCutOnSingleCellClusters && recPointPtr->fAmp > fSingleCellEnergyCut && recPointPtr->fMultiplicity == 1) continue; | |
227 | ||
7fdb2519 | 228 | totSize += sizeof(AliHLTCaloClusterDataStruct); |
73d6f579 | 229 | |
230 | caloClusterPtr = fCaloClusterDataPtr; | |
34eb3256 | 231 | caloClusterPtr->fChi2 = 0; |
232 | caloClusterPtr->fClusterType = kUndef; | |
233 | caloClusterPtr->fDispersion = 0; | |
234 | caloClusterPtr->fDistanceToBadChannel = 0; | |
235 | caloClusterPtr->fDistToBadChannel = 0; | |
236 | caloClusterPtr->fEmcCpvDistance = 0; | |
237 | caloClusterPtr->fEnergy = 0; | |
238 | caloClusterPtr->fFitQuality = 0; | |
239 | caloClusterPtr->fID = 0; | |
240 | caloClusterPtr->fM02 = 0; | |
241 | caloClusterPtr->fM20 = 0; | |
242 | caloClusterPtr->fNCells = 0; | |
243 | caloClusterPtr->fNExMax = 0; | |
244 | caloClusterPtr->fTOF = 0; | |
fe1a0255 | 245 | caloClusterPtr->fTrackDx = -999; |
246 | caloClusterPtr->fTrackDz = -999; | |
7c80a370 | 247 | |
248 | AliHLTCaloGlobalCoordinate globalCoord; | |
249 | fGeometry->GetGlobalCoordinates(*recPointPtr, globalCoord); | |
ea367f6a | 250 | |
353c33d3 | 251 | caloClusterPtr->fModule = recPointPtr->fModule; |
a6db7bcd | 252 | caloClusterPtr->fGlobalPos[0] = globalCoord.fX; |
cd9e2797 | 253 | caloClusterPtr->fGlobalPos[1] = globalCoord.fY; |
a6db7bcd | 254 | caloClusterPtr->fGlobalPos[2] = globalCoord.fZ; |
ea367f6a | 255 | |
5259027d | 256 | HLTDebug("Cluster local position: x = %f, z = %f, module = %d", recPointPtr->fX, recPointPtr->fZ, recPointPtr->fModule); |
257 | HLTDebug("Cluster global position: x = %f, y = %f, z = %f", globalCoord.fX, globalCoord.fY, globalCoord.fZ); | |
ee72b4e5 | 258 | |
7fdb2519 | 259 | //caloClusterPtr->fNCells = 0;//recPointPtr->fMultiplicity; |
260 | caloClusterPtr->fNCells = recPointPtr->fMultiplicity; | |
cd9e2797 | 261 | |
a6db7bcd | 262 | caloClusterPtr->fClusterType = fClusterType; |
7fdb2519 | 263 | // Int_t tmpSize = 0;//totSize + (caloClusterPtr->fNCells-1)*(sizeof(Short_t) + sizeof(Float_t)); |
a6db7bcd | 264 | |
2a24cbbe | 265 | //TODO remove hardcoded 10; |
266 | memset(caloClusterPtr->fTracksMatched, 0xff, sizeof(Int_t)*10); | |
267 | ||
9a0cbaba | 268 | //Int_t tmpSize = totSize + (caloClusterPtr->fNCells-1)*(sizeof(Short_t) + sizeof(Float_t)); |
cefad3b2 | 269 | UInt_t tmpSize = (caloClusterPtr->fNCells-1)*sizeof(AliHLTCaloCellDataStruct); |
cd9e2797 | 270 | |
73d6f579 | 271 | if((availableSize - totSize) < tmpSize) |
272 | { | |
9a0cbaba | 273 | HLTError("Out of buffer, available size is: %d, total size used: %d, extra size needed: %d", availableSize, totSize, tmpSize); |
73d6f579 | 274 | return -ENOBUFS; |
275 | } | |
c1e4a18c | 276 | |
cd9e2797 | 277 | Int_t *digitIndexPtr = &(recPointPtr->fDigits); |
278 | Int_t id = 0; | |
279 | ||
7fdb2519 | 280 | AliHLTCaloCellDataStruct *cellPtr = &(caloClusterPtr->fCaloCells); |
281 | ||
ea367f6a | 282 | for(UInt_t j = 0; j < caloClusterPtr->fNCells; j++) |
283 | { | |
f92543f5 | 284 | digitPtr = fDigitDataArray[*digitIndexPtr]; |
936dbe15 | 285 | fGeometry->GetCellAbsId(recPointPtr->fModule, digitPtr->fX, digitPtr->fZ, id); |
7fdb2519 | 286 | |
287 | cellPtr->fCellsAbsId= id; | |
288 | cellPtr->fCellsAmpFraction = digitPtr->fEnergy/recPointPtr->fAmp; | |
cd9e2797 | 289 | //printf("Cell ID pointer: %x\n", cellIDPtr); |
290 | //printf("Cell Amp Pointer: %x\n", cellAmpFracPtr); | |
9a0cbaba | 291 | //printf("Cell pos: x = %d, z = %d\n", digitPtr->fX, digitPtr->fZ); |
34eb3256 | 292 | // printf("Cell ID: %d\n", cellPtr->fCellsAbsId); |
9a0cbaba | 293 | //printf("Cell Amp: %f, pointer: %x\n", *cellAmpFracPtr, cellAmpFracPtr); |
7fdb2519 | 294 | cellPtr++; |
cd9e2797 | 295 | digitIndexPtr++; |
296 | ||
ea367f6a | 297 | } |
298 | ||
73d6f579 | 299 | totSize += tmpSize; |
300 | ||
c1e4a18c | 301 | if(fRecoParamsPtr) |
302 | { | |
303 | caloClusterPtr->fEnergy = fRecoParamsPtr->GetCorrectedEnergy(recPointPtr->fAmp); | |
304 | } | |
305 | else | |
306 | { | |
307 | caloClusterPtr->fEnergy = recPointPtr->fAmp; | |
308 | } | |
34eb3256 | 309 | |
7fdb2519 | 310 | HLTDebug("Cluster global position: x = %f, y = %f, z = %f, energy: %f, number of cells: %d, cluster pointer: %x", globalCoord.fX, globalCoord.fY, globalCoord.fZ, caloClusterPtr->fEnergy, caloClusterPtr->fNCells, caloClusterPtr); |
311 | ||
ea367f6a | 312 | if(fDoClusterFit) |
313 | { | |
314 | FitCluster(recPointPtr); | |
315 | } | |
316 | else | |
317 | { | |
318 | caloClusterPtr->fDispersion = 0; | |
319 | caloClusterPtr->fFitQuality = 0; | |
320 | caloClusterPtr->fM20 = 0; | |
321 | caloClusterPtr->fM02 = 0; | |
322 | ||
323 | } | |
324 | if(fHaveCPVInfo) | |
325 | { | |
326 | caloClusterPtr->fEmcCpvDistance = GetCPVDistance(recPointPtr); | |
327 | } | |
328 | else | |
329 | { | |
330 | caloClusterPtr->fEmcCpvDistance = -1; | |
331 | } | |
332 | if(fDoPID) | |
333 | { | |
334 | DoParticleIdentification(caloClusterPtr); | |
335 | } | |
336 | else | |
337 | { | |
338 | for(Int_t k = 0; k < AliPID::kSPECIESN; k++) | |
339 | { | |
340 | caloClusterPtr->fPID[k] = 0; | |
341 | } | |
342 | } | |
343 | if(fHaveDistanceToBadChannel) | |
344 | { | |
345 | caloClusterPtr->fDistanceToBadChannel = GetDistanceToBadChannel(caloClusterPtr); | |
346 | } | |
347 | else | |
348 | { | |
349 | caloClusterPtr->fDistanceToBadChannel = -1; | |
350 | } | |
351 | ||
73d6f579 | 352 | caloClusterPtr->fClusterType = fClusterType; |
cd9e2797 | 353 | //totSize += sizeof(AliHLTCaloClusterDataStruct) + (caloClusterPtr->fNCells)*(sizeof(Short_t) +sizeof(Float_t)-1); |
73d6f579 | 354 | //totSize += sizeof(AliHLTCaloClusterDataStruct) + (caloClusterPtr->fNCells-1)*(sizeof(Short_t) + sizeof(Float_t)); |
cd9e2797 | 355 | //printf("CaloClusterPtr: %x, energy: %f\n", caloClusterPtr, caloClusterPtr->fEnergy); |
356 | ||
ea367f6a | 357 | // caloClusterPtr = reinterpret_cast<AliHLTCaloClusterDataStruct*>(cellAmpFracPtr); |
cd9e2797 | 358 | //caloClusterPtr = reinterpret_cast<AliHLTCaloClusterDataStruct*>(cellIDPtr); |
7fdb2519 | 359 | fCaloClusterDataPtr = reinterpret_cast<AliHLTCaloClusterDataStruct*>(cellPtr); |
ea367f6a | 360 | recPointPtr = reinterpret_cast<AliHLTCaloRecPointDataStruct*>(digitPtr); |
73d6f579 | 361 | //digitPtr = &(recPointPtr->fDigits); |
ea367f6a | 362 | } |
98baf84d | 363 | |
364 | return fNRecPoints; | |
ea367f6a | 365 | |
366 | } | |
367 |