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