]>
Commit | Line | Data |
---|---|---|
1b41ab20 | 1 | // $Id$ |
2 | ||
fa0a9bec | 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 AliHLTPHOSClusterAnalyser.cxx | |
20 | * @author Oystein Djuvsland | |
21 | * @date | |
22 | * @brief Cluster analyser for PHOS 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 "AliHLTPHOSClusterAnalyser.h" | |
e304ea31 | 32 | #include "AliHLTPHOSRecPointHeaderStruct.h" |
fa0a9bec | 33 | #include "AliHLTPHOSRecPointDataStruct.h" |
7fc04b67 | 34 | #include "AliHLTCaloClusterDataStruct.h" |
18af2efc | 35 | #include "AliHLTPHOSPhysicsAnalyzer.h" |
933eb3ed | 36 | #include "AliHLTPHOSDigitReader.h" |
87434909 | 37 | #include "AliPHOSGeoUtils.h" |
947064ec | 38 | #include "AliESDCaloCluster.h" |
fa0a9bec | 39 | #include "TMath.h" |
87434909 | 40 | #include "TVector3.h" |
fa0a9bec | 41 | |
42 | ClassImp(AliHLTPHOSClusterAnalyser); | |
43 | ||
44 | AliHLTPHOSClusterAnalyser::AliHLTPHOSClusterAnalyser() : | |
9f050726 | 45 | // AliHLTPHOSBase(), |
b2faa1a0 | 46 | fLogWeight(4.5), |
e304ea31 | 47 | fRecPointDataPtr(0), |
48 | fNRecPoints(0), | |
49 | fCaloClusterDataPtr(0), | |
50 | fCaloClusterHeaderPtr(0), | |
fa0a9bec | 51 | fPHOSGeometry(0), |
fa0a9bec | 52 | fDoClusterFit(false), |
53 | fHaveCPVInfo(false), | |
54 | fDoPID(false), | |
f1bfc65f | 55 | fHaveDistanceToBadChannel(false), |
56 | fDigitHeaderPtr(0) | |
fa0a9bec | 57 | { |
58 | //See header file for documentation | |
fa0a9bec | 59 | } |
60 | ||
61 | AliHLTPHOSClusterAnalyser::~AliHLTPHOSClusterAnalyser() | |
62 | { | |
63 | } | |
64 | ||
25b7f84c | 65 | void |
7fc04b67 | 66 | AliHLTPHOSClusterAnalyser::SetCaloClusterDataPtr(AliHLTCaloClusterDataStruct *caloClusterDataPtr) |
25b7f84c | 67 | { |
68 | //see header file for documentation | |
e304ea31 | 69 | fCaloClusterDataPtr = caloClusterDataPtr; |
70 | } | |
71 | void | |
0dc57e1b | 72 | AliHLTPHOSClusterAnalyser::SetRecPointDataPtr(AliHLTPHOSRecPointHeaderStruct *recPointDataPtr, AliHLTPHOSDigitHeaderStruct *digitHeaderPtr) |
e304ea31 | 73 | { |
74 | fNRecPoints = recPointDataPtr->fNRecPoints; | |
75 | fRecPointDataPtr = reinterpret_cast<AliHLTPHOSRecPointDataStruct*>(reinterpret_cast<Char_t*>(recPointDataPtr)+sizeof(AliHLTPHOSRecPointHeaderStruct)); | |
0dc57e1b | 76 | fDigitHeaderPtr = digitHeaderPtr; |
25b7f84c | 77 | } |
78 | ||
fa0a9bec | 79 | Int_t |
80 | AliHLTPHOSClusterAnalyser::CalculateCenterOfGravity() | |
81 | { | |
82 | //see header file for documentation | |
fa0a9bec | 83 | Float_t wtot = 0.; |
fa0a9bec | 84 | Float_t x = 0.; |
85 | Float_t z = 0.; | |
86 | Float_t xi = 0.; | |
87 | Float_t zi = 0.; | |
e304ea31 | 88 | |
fa0a9bec | 89 | AliHLTPHOSDigitDataStruct *digit = 0; |
fa0a9bec | 90 | //AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance() ; |
91 | ||
e304ea31 | 92 | AliHLTPHOSRecPointDataStruct *recPoint = fRecPointDataPtr; |
93 | ||
f1bfc65f | 94 | // UInt_t iDigit = 0; |
fa0a9bec | 95 | |
e304ea31 | 96 | for(Int_t iRecPoint=0; iRecPoint < fNRecPoints; iRecPoint++) |
fa0a9bec | 97 | { |
933eb3ed | 98 | digit = reinterpret_cast<AliHLTPHOSDigitDataStruct*>(reinterpret_cast<Long_t>(fDigitHeaderPtr) + recPoint->fStartDigitOffset); |
0dc57e1b | 99 | AliHLTPHOSDigitReader reader; |
933eb3ed | 100 | reader.SetCurrentDigit(digit); |
0dc57e1b | 101 | while(digit) |
fa0a9bec | 102 | { |
fa0a9bec | 103 | xi = digit->fX; |
104 | zi = digit->fZ; | |
87434909 | 105 | // cout << "COG digits (x:z:E:time): " << xi << " : " << zi << " : " << digit->fEnergy << " : " << digit->fTime << endl; |
fa0a9bec | 106 | if (recPoint->fAmp > 0 && digit->fEnergy > 0) |
107 | { | |
108 | Float_t w = TMath::Max( 0., fLogWeight + TMath::Log( digit->fEnergy / recPoint->fAmp ) ) ; | |
109 | x += xi * w ; | |
110 | z += zi * w ; | |
111 | wtot += w ; | |
112 | } | |
933eb3ed | 113 | digit = reader.NextDigit(); |
fa0a9bec | 114 | } |
fa0a9bec | 115 | if (wtot>0) |
116 | { | |
117 | recPoint->fX = x/wtot ; | |
118 | recPoint->fZ = z/wtot ; | |
119 | } | |
120 | else | |
121 | { | |
122 | recPoint->fAmp = 0; | |
123 | } | |
e304ea31 | 124 | recPoint = reinterpret_cast<AliHLTPHOSRecPointDataStruct*>(digit); |
fa0a9bec | 125 | } |
126 | return 0; | |
127 | } | |
128 | ||
129 | ||
130 | Int_t | |
131 | AliHLTPHOSClusterAnalyser::CalculateRecPointMoments() | |
132 | { | |
133 | //See header file for documentation | |
134 | return 0; | |
135 | } | |
136 | ||
137 | Int_t | |
7fc04b67 | 138 | AliHLTPHOSClusterAnalyser::CalculateClusterMoments(AliHLTPHOSRecPointDataStruct */*recPointPtr*/, AliHLTCaloClusterDataStruct* /*clusterPtr*/) |
fa0a9bec | 139 | { |
140 | //See header file for documentation | |
141 | return 0; | |
142 | } | |
143 | ||
144 | ||
145 | Int_t | |
146 | AliHLTPHOSClusterAnalyser::DeconvoluteClusters() | |
147 | { | |
148 | //See header file for documentation | |
149 | return 0; | |
150 | } | |
151 | ||
152 | Int_t | |
e304ea31 | 153 | AliHLTPHOSClusterAnalyser::CreateClusters(UInt_t availableSize, UInt_t& totSize) |
fa0a9bec | 154 | { |
155 | //See header file for documentation | |
fa0a9bec | 156 | |
7fc04b67 | 157 | UInt_t maxClusterSize = sizeof(AliHLTCaloClusterDataStruct) + (6 << 7); //Reasonable estimate... (6 = sizeof(Short_t) + sizeof(Float_t) |
e304ea31 | 158 | |
159 | AliHLTPHOSRecPointDataStruct* recPointPtr = fRecPointDataPtr; | |
933eb3ed | 160 | AliHLTPHOSDigitDataStruct* digitPtr = 0; |
0dc57e1b | 161 | |
933eb3ed | 162 | AliHLTPHOSDigitReader reader; |
e304ea31 | 163 | |
7fc04b67 | 164 | AliHLTCaloClusterDataStruct* caloClusterPtr = fCaloClusterDataPtr; |
e304ea31 | 165 | UShort_t* cellIDPtr = &(caloClusterPtr->fCellsAbsId); |
166 | Float_t* cellAmpFracPtr = &(caloClusterPtr->fCellsAmpFraction); | |
167 | ||
fa0a9bec | 168 | Int_t id = -1; |
87434909 | 169 | TVector3 globalPos; |
fa0a9bec | 170 | |
87434909 | 171 | 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 |
fa0a9bec | 172 | { |
933eb3ed | 173 | digitPtr = reinterpret_cast<AliHLTPHOSDigitDataStruct*>(reinterpret_cast<Long_t>(fDigitHeaderPtr) + recPointPtr->fStartDigitOffset); |
174 | reader.SetCurrentDigit(digitPtr); | |
175 | ||
e304ea31 | 176 | if(availableSize < (totSize + maxClusterSize)) |
177 | { | |
178 | return -1; //Might get out of buffer, exiting | |
179 | } | |
947064ec | 180 | fPHOSGeometry->Local2Global(recPointPtr->fModule, recPointPtr->fX, recPointPtr->fZ, globalPos); |
fa0a9bec | 181 | |
182 | caloClusterPtr->fGlobalPos[0] = globalPos[0]; | |
183 | caloClusterPtr->fGlobalPos[1] = globalPos[1]; | |
184 | caloClusterPtr->fGlobalPos[2] = globalPos[2]; | |
185 | ||
186 | caloClusterPtr->fNCells = recPointPtr->fMultiplicity; | |
8efbf5fe | 187 | |
e304ea31 | 188 | cellIDPtr = &(caloClusterPtr->fCellsAbsId); |
189 | cellAmpFracPtr = &(caloClusterPtr->fCellsAmpFraction); | |
190 | ||
0dc57e1b | 191 | while(digitPtr) |
fa0a9bec | 192 | { |
947064ec | 193 | fPHOSGeometry->RelPosToAbsId((Int_t)(recPointPtr->fModule), (double)(digitPtr->fX), (double)(digitPtr->fZ), id); |
e304ea31 | 194 | *cellIDPtr = id; |
195 | *cellAmpFracPtr = digitPtr->fEnergy/recPointPtr->fAmp; | |
e304ea31 | 196 | cellIDPtr = reinterpret_cast<UShort_t*>(reinterpret_cast<char*>(cellAmpFracPtr) + sizeof(Float_t)); |
197 | cellAmpFracPtr = reinterpret_cast<Float_t*>(reinterpret_cast<char*>(cellIDPtr) + sizeof(Short_t)); | |
933eb3ed | 198 | digitPtr = reader.NextDigit(); |
fa0a9bec | 199 | } |
e304ea31 | 200 | |
fa0a9bec | 201 | caloClusterPtr->fEnergy = recPointPtr->fAmp; |
947064ec | 202 | |
fa0a9bec | 203 | if(fDoClusterFit) |
204 | { | |
205 | FitCluster(recPointPtr); | |
206 | } | |
207 | else | |
208 | { | |
209 | caloClusterPtr->fDispersion = 0; | |
210 | caloClusterPtr->fFitQuality = 0; | |
211 | caloClusterPtr->fM20 = 0; | |
212 | caloClusterPtr->fM02 = 0; | |
947064ec | 213 | |
fa0a9bec | 214 | } |
215 | if(fHaveCPVInfo) | |
216 | { | |
217 | caloClusterPtr->fEmcCpvDistance = GetCPVDistance(recPointPtr); | |
218 | } | |
219 | else | |
220 | { | |
221 | caloClusterPtr->fEmcCpvDistance = -1; | |
222 | } | |
223 | if(fDoPID) | |
224 | { | |
225 | DoParticleIdentification(caloClusterPtr); | |
226 | } | |
227 | else | |
228 | { | |
229 | for(Int_t k = 0; k < AliPID::kSPECIESN; k++) | |
230 | { | |
231 | caloClusterPtr->fPID[k] = 0; | |
232 | } | |
233 | } | |
fa0a9bec | 234 | if(fHaveDistanceToBadChannel) |
235 | { | |
236 | caloClusterPtr->fDistanceToBadChannel = GetDistanceToBadChannel(caloClusterPtr); | |
237 | } | |
238 | else | |
239 | { | |
240 | caloClusterPtr->fDistanceToBadChannel = -1; | |
241 | } | |
242 | ||
947064ec | 243 | caloClusterPtr->fClusterType = (AliESDCaloCluster::kPHOSCluster); |
b2faa1a0 | 244 | |
7fc04b67 | 245 | totSize += sizeof(AliHLTCaloClusterDataStruct) + (caloClusterPtr->fNCells-1)*(sizeof(Short_t) + sizeof(Float_t)); |
8efbf5fe | 246 | |
7fc04b67 | 247 | caloClusterPtr = reinterpret_cast<AliHLTCaloClusterDataStruct*>(cellIDPtr); |
e304ea31 | 248 | recPointPtr = reinterpret_cast<AliHLTPHOSRecPointDataStruct*>(digitPtr); |
933eb3ed | 249 | |
e304ea31 | 250 | } |
b2faa1a0 | 251 | |
e304ea31 | 252 | return fNRecPoints; |
fa0a9bec | 253 | |
254 | } | |
255 |