]>
Commit | Line | Data |
---|---|---|
ab38011b | 1 | /************************************************************************** |
2 | * This file is property of and copyright by the ALICE HLT Project * | |
3 | * All rights reserved. * | |
4 | * * | |
1804b020 | 5 | * Primary Authors: Oystein Djuvsland * |
ab38011b | 6 | * * |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
aac22523 | 15 | |
16 | ||
aac22523 | 17 | #include "AliHLTPHOSClusterizer.h" |
9cc0deb1 | 18 | #include "AliHLTPHOSBase.h" |
aac22523 | 19 | #include "TMath.h" |
9cc0deb1 | 20 | #include "AliHLTPHOSRecPointContainerStruct.h" |
91b95d47 | 21 | #include "AliHLTPHOSRecPointDataStruct.h" |
9cc0deb1 | 22 | #include "AliHLTPHOSDigitDataStruct.h" |
23 | #include "AliHLTPHOSDigitContainerDataStruct.h" | |
24 | #include "TClonesArray.h" | |
25 | #include "AliPHOSGeometry.h" | |
26 | #include "AliPHOSDigit.h" | |
27 | #include "AliPHOSRecoParamEmc.h" | |
28 | ||
29 | ClassImp(AliHLTPHOSClusterizer); | |
30 | ||
31 | AliHLTPHOSClusterizer::AliHLTPHOSClusterizer(): | |
32 | AliHLTPHOSBase(), | |
33 | fEmcClusteringThreshold(0), | |
34 | fEmcMinEnergyThreshold(0), | |
35 | fEmcTimeGate(0), | |
36 | fLogWeight(0), | |
37 | fDigitsInCluster(0), | |
38 | fOnlineMode(true), | |
39 | fDigitArrayPtr(0), | |
40 | fEmcRecPointsPtr(0), | |
41 | fDigitPtr(0), | |
42 | fDigitContainerPtr(0), | |
43 | fRecPointContainerPtr(0), | |
44 | fPHOSGeometry(0), | |
45 | fGetterPtr(0) | |
aac22523 | 46 | { |
6e709a0d | 47 | //See header file for documentation |
9cc0deb1 | 48 | fPHOSGeometry = AliPHOSGeometry::GetInstance("noCPV"); |
49 | fEmcClusteringThreshold = 0.2; | |
50 | fEmcMinEnergyThreshold = 0.03; | |
51 | fEmcTimeGate = 1.e-8 ; | |
52 | fLogWeight = 4.5; | |
aac22523 | 53 | |
9cc0deb1 | 54 | |
aac22523 | 55 | }//end |
56 | ||
9c9d15d6 | 57 | |
1804b020 | 58 | AliHLTPHOSClusterizer::AliHLTPHOSClusterizer(const AliHLTPHOSClusterizer &) : AliHLTPHOSBase() |
9cc0deb1 | 59 | { |
91b95d47 | 60 | //Copy constructor, not implemented |
9cc0deb1 | 61 | }//end |
aac22523 | 62 | |
9cc0deb1 | 63 | AliHLTPHOSClusterizer::~AliHLTPHOSClusterizer() |
aac22523 | 64 | { |
91b95d47 | 65 | //Destructor |
aac22523 | 66 | } |
67 | ||
9cc0deb1 | 68 | void |
69 | AliHLTPHOSClusterizer::SetRecoParameters(AliPHOSRecoParamEmc* params) | |
70 | { | |
ab38011b | 71 | //comment |
9cc0deb1 | 72 | fEmcClusteringThreshold = params->GetClusteringThreshold(); |
73 | fEmcMinEnergyThreshold = params->GetMinE(); | |
74 | fLogWeight = params->GetLogWeight(); | |
75 | } | |
aac22523 | 76 | |
9cc0deb1 | 77 | void |
78 | AliHLTPHOSClusterizer::SetOfflineMode(AliPHOSGetter* getter) | |
aac22523 | 79 | { |
ab38011b | 80 | //comment |
9cc0deb1 | 81 | fRecPointContainerPtr = new AliHLTPHOSRecPointContainerStruct(); |
82 | fDigitContainerPtr = new AliHLTPHOSDigitContainerDataStruct(); | |
83 | fGetterPtr = getter; | |
84 | fDigitArrayPtr = fGetterPtr->Digits(); | |
85 | fEmcRecPointsPtr = fGetterPtr->EmcRecPoints(); | |
86 | fOnlineMode = false; | |
87 | } | |
aac22523 | 88 | |
9cc0deb1 | 89 | Int_t |
90 | AliHLTPHOSClusterizer::GetEvent(Int_t i) | |
91 | { | |
ab38011b | 92 | //comment |
9cc0deb1 | 93 | Int_t coord[4]; |
aac22523 | 94 | |
9cc0deb1 | 95 | fGetterPtr->Event(i, "D"); |
96 | for(Int_t j = 0; j < fDigitArrayPtr->GetEntries(); j++) | |
aac22523 | 97 | { |
9cc0deb1 | 98 | fDigitPtr = (AliPHOSDigit*)fDigitArrayPtr->At(j); |
99 | fPHOSGeometry->AbsToRelNumbering(fDigitPtr->GetId(), coord); | |
100 | fDigitContainerPtr->fDigitDataStruct[j].fX = coord[3]; | |
101 | fDigitContainerPtr->fDigitDataStruct[j].fZ = coord[2]; | |
102 | fDigitContainerPtr->fDigitDataStruct[j].fModule = coord[0]; | |
103 | fDigitContainerPtr->fDigitDataStruct[j].fEnergy = fDigitPtr->GetEnergy(); | |
104 | fDigitContainerPtr->fDigitDataStruct[j].fTime = fDigitPtr->GetTime(); | |
105 | } | |
106 | fDigitContainerPtr->fNDigits = fDigitArrayPtr->GetEntriesFast(); | |
107 | return 0; | |
108 | } | |
aac22523 | 109 | |
9cc0deb1 | 110 | Int_t |
111 | AliHLTPHOSClusterizer::GetNEvents() | |
112 | { | |
ab38011b | 113 | //comment |
9cc0deb1 | 114 | if(fOnlineMode) |
115 | { | |
116 | printf("Number of events not available in online mode!\n"); | |
117 | return -1; | |
118 | } | |
119 | return fGetterPtr->MaxEvent(); | |
120 | } | |
aac22523 | 121 | |
aac22523 | 122 | |
9cc0deb1 | 123 | Int_t |
124 | AliHLTPHOSClusterizer::ClusterizeEvent() | |
aac22523 | 125 | { |
ab38011b | 126 | //comment |
aac22523 | 127 | Int_t nRecPoints = 0; |
9cc0deb1 | 128 | UInt_t i = 0; |
aac22523 | 129 | |
6e709a0d | 130 | |
9cc0deb1 | 131 | AliHLTPHOSRecPointDataStruct *recPoint = 0; |
132 | ||
133 | //Clusterization starts | |
134 | for(i = 0; i < fDigitContainerPtr->fNDigits; i++) | |
135 | { | |
136 | ||
137 | fDigitsInCluster = 0; | |
aac22523 | 138 | |
9cc0deb1 | 139 | if(fDigitContainerPtr->fDigitDataStruct[i].fEnergy < fEmcClusteringThreshold) |
aac22523 | 140 | { |
9cc0deb1 | 141 | continue; |
aac22523 | 142 | } |
aac22523 | 143 | |
9cc0deb1 | 144 | recPoint = &(fRecPointContainerPtr->fRecPointArray[nRecPoints]); |
145 | recPoint->fAmp = 0; | |
146 | //recPoint-> | |
147 | recPoint->fDigitsList[fDigitsInCluster] = fDigitContainerPtr->fDigitDataStruct[i]; | |
148 | recPoint->fAmp += fDigitContainerPtr->fDigitDataStruct[i].fEnergy; | |
149 | fDigitContainerPtr->fDigitDataStruct[i].fEnergy = 0; | |
150 | fDigitsInCluster++; | |
151 | nRecPoints++; | |
152 | ScanForNeighbourDigits(i, recPoint); | |
153 | ||
154 | recPoint->fMultiplicity = fDigitsInCluster; | |
155 | }//end of clusterization | |
156 | fRecPointContainerPtr->fNRecPoints = nRecPoints; | |
aac22523 | 157 | |
9cc0deb1 | 158 | return nRecPoints; |
159 | } | |
aac22523 | 160 | |
9cc0deb1 | 161 | void |
162 | AliHLTPHOSClusterizer::ScanForNeighbourDigits(Int_t index, AliHLTPHOSRecPointDataStruct* recPoint) | |
aac22523 | 163 | |
aac22523 | 164 | { |
ab38011b | 165 | //comment |
9cc0deb1 | 166 | |
167 | for(UInt_t j = 0; j < fDigitContainerPtr->fNDigits; j++) | |
aac22523 | 168 | { |
9cc0deb1 | 169 | if(fDigitContainerPtr->fDigitDataStruct[j].fEnergy > fEmcMinEnergyThreshold) |
170 | { | |
171 | switch(AreNeighbours(&(fDigitContainerPtr->fDigitDataStruct[index]), | |
172 | &(fDigitContainerPtr->fDigitDataStruct[j]))) | |
173 | { | |
174 | case 0: | |
175 | break; | |
176 | case 1: | |
177 | recPoint->fDigitsList[fDigitsInCluster] = fDigitContainerPtr->fDigitDataStruct[j]; | |
178 | recPoint->fAmp += fDigitContainerPtr->fDigitDataStruct[j].fEnergy; | |
179 | fDigitContainerPtr->fDigitDataStruct[j].fEnergy = 0; | |
180 | fDigitsInCluster++; | |
181 | ScanForNeighbourDigits(j, recPoint); | |
182 | break; | |
183 | case 2: | |
184 | break; | |
185 | } | |
aac22523 | 186 | } |
9cc0deb1 | 187 | } |
188 | return; | |
189 | } | |
6e709a0d | 190 | |
aac22523 | 191 | |
9cc0deb1 | 192 | Int_t |
193 | AliHLTPHOSClusterizer::AreNeighbours(AliHLTPHOSDigitDataStruct* digit1, | |
194 | AliHLTPHOSDigitDataStruct* digit2) | |
6e709a0d | 195 | { |
ab38011b | 196 | //comment |
9cc0deb1 | 197 | //Int_t coord1[4]; |
198 | //Int_t coord2[4]; | |
6e709a0d | 199 | |
9cc0deb1 | 200 | // fPHOSGeometry->AbsToRelNumbering(digit1->fID, coord1); |
201 | //fPHOSGeometry->AbsToRelNumbering(digit2->fID, coord2); | |
6e709a0d | 202 | |
d2b84453 | 203 | |
9cc0deb1 | 204 | if ( (digit1->fModule == digit2->fModule) /*&& (coord1[1]==coord2[1])*/ ) // inside the same PHOS module |
205 | { | |
d2b84453 | 206 | |
9cc0deb1 | 207 | Int_t rowdiff = TMath::Abs( digit1->fZ - digit2->fZ ); |
208 | Int_t coldiff = TMath::Abs( digit1->fX - digit2->fX ); | |
209 | ||
210 | if (( coldiff <= 1 ) && ( rowdiff <= 1 )) | |
6e709a0d | 211 | { |
9cc0deb1 | 212 | if(TMath::Abs(digit1->fTime - digit2->fTime ) < fEmcTimeGate) |
213 | return 1; | |
6e709a0d | 214 | } |
6e709a0d | 215 | } |
216 | return 0; | |
217 | } | |
aac22523 | 218 | |
9cc0deb1 | 219 | void |
220 | AliHLTPHOSClusterizer::CalculateCenterOfGravity() | |
aac22523 | 221 | { |
ab38011b | 222 | //comment |
9cc0deb1 | 223 | // Calculates the center of gravity in the local PHOS-module coordinates |
224 | Float_t wtot = 0.; | |
225 | ||
1804b020 | 226 | //Int_t relid[4]; |
aac22523 | 227 | |
9cc0deb1 | 228 | Float_t x = 0.; |
229 | Float_t z = 0.; | |
230 | Float_t xi = 0.; | |
231 | Float_t zi = 0.; | |
aac22523 | 232 | |
9cc0deb1 | 233 | AliHLTPHOSRecPointDataStruct *recPoint = 0; |
234 | AliHLTPHOSDigitDataStruct *digit = 0; | |
aac22523 | 235 | |
1804b020 | 236 | //AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance() ; |
aac22523 | 237 | |
1804b020 | 238 | UInt_t iDigit = 0; |
239 | UInt_t iRecPoint = 0; | |
91b95d47 | 240 | |
9cc0deb1 | 241 | for(iRecPoint=0; iRecPoint<fRecPointContainerPtr->fNRecPoints; iRecPoint++) |
aac22523 | 242 | { |
9cc0deb1 | 243 | recPoint = &(fRecPointContainerPtr->fRecPointArray[iRecPoint]); |
244 | for(iDigit = 0; iDigit < recPoint->fMultiplicity; iDigit++) | |
aac22523 | 245 | { |
9cc0deb1 | 246 | digit = &(recPoint->fDigitsList[iDigit]); |
247 | ||
248 | //fPHOSGeometry->AbsToRelNumbering(digit->fID, relid) ; | |
249 | // fPHOSGeometry->RelPosInModule(relid, xi, zi); | |
250 | xi = digit->fX; | |
251 | zi = digit->fZ; | |
252 | ||
253 | if (recPoint->fAmp > 0 && digit->fEnergy > 0) | |
254 | { | |
255 | Float_t w = TMath::Max( 0., fLogWeight + TMath::Log( digit->fEnergy / recPoint->fAmp ) ) ; | |
256 | x += xi * w ; | |
257 | z += zi * w ; | |
258 | wtot += w ; | |
259 | } | |
260 | } | |
261 | ||
262 | if (wtot>0) | |
263 | { | |
264 | recPoint->fX = x/wtot ; | |
265 | recPoint->fZ = z/wtot ; | |
266 | } | |
267 | else | |
268 | { | |
269 | recPoint->fAmp = 0; | |
aac22523 | 270 | } |
271 | } | |
9cc0deb1 | 272 | |
273 | } | |
aac22523 | 274 | |
aac22523 | 275 |