]>
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; | |
341aab10 | 75 | |
e304ea31 | 76 | fRecPointDataPtr = reinterpret_cast<AliHLTPHOSRecPointDataStruct*>(reinterpret_cast<Char_t*>(recPointDataPtr)+sizeof(AliHLTPHOSRecPointHeaderStruct)); |
0dc57e1b | 77 | fDigitHeaderPtr = digitHeaderPtr; |
25b7f84c | 78 | } |
79 | ||
fa0a9bec | 80 | Int_t |
81 | AliHLTPHOSClusterAnalyser::CalculateCenterOfGravity() | |
82 | { | |
83 | //see header file for documentation | |
fa0a9bec | 84 | Float_t wtot = 0.; |
fa0a9bec | 85 | Float_t x = 0.; |
86 | Float_t z = 0.; | |
87 | Float_t xi = 0.; | |
88 | Float_t zi = 0.; | |
e304ea31 | 89 | |
fa0a9bec | 90 | AliHLTPHOSDigitDataStruct *digit = 0; |
fa0a9bec | 91 | //AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance() ; |
92 | ||
e304ea31 | 93 | AliHLTPHOSRecPointDataStruct *recPoint = fRecPointDataPtr; |
c375e15d | 94 | // UInt_t iDigit = 0; |
341aab10 | 95 | if(!recPoint) return 0; |
e304ea31 | 96 | for(Int_t iRecPoint=0; iRecPoint < fNRecPoints; iRecPoint++) |
fa0a9bec | 97 | { |
341aab10 | 98 | // cout << "CA: start digit offset: " << recPoint->fStartDigitOffset << endl; |
99 | digit = reinterpret_cast<AliHLTPHOSDigitDataStruct*>(reinterpret_cast<UChar_t*>(fDigitHeaderPtr) + recPoint->fStartDigitOffset); | |
100 | // cout << "CA: digit offset: " << digit->fMemOffsetNext << endl; | |
0dc57e1b | 101 | AliHLTPHOSDigitReader reader; |
341aab10 | 102 | reader.SetNextDigit(digit); |
0dc57e1b | 103 | while(digit) |
fa0a9bec | 104 | { |
fa0a9bec | 105 | xi = digit->fX; |
106 | zi = digit->fZ; | |
341aab10 | 107 | // cout << "COG digits (x:z:E:time): " << xi << " : " << zi << " : " << digit->fEnergy << " : " << digit->fTime << endl; |
fa0a9bec | 108 | if (recPoint->fAmp > 0 && digit->fEnergy > 0) |
109 | { | |
110 | Float_t w = TMath::Max( 0., fLogWeight + TMath::Log( digit->fEnergy / recPoint->fAmp ) ) ; | |
111 | x += xi * w ; | |
112 | z += zi * w ; | |
113 | wtot += w ; | |
114 | } | |
933eb3ed | 115 | digit = reader.NextDigit(); |
fa0a9bec | 116 | } |
fa0a9bec | 117 | if (wtot>0) |
118 | { | |
119 | recPoint->fX = x/wtot ; | |
120 | recPoint->fZ = z/wtot ; | |
121 | } | |
341aab10 | 122 | |
fa0a9bec | 123 | else |
124 | { | |
125 | recPoint->fAmp = 0; | |
126 | } | |
341aab10 | 127 | recPoint++; |
128 | } | |
129 | ||
130 | ||
fa0a9bec | 131 | return 0; |
132 | } | |
133 | ||
134 | ||
135 | Int_t | |
136 | AliHLTPHOSClusterAnalyser::CalculateRecPointMoments() | |
137 | { | |
138 | //See header file for documentation | |
139 | return 0; | |
140 | } | |
141 | ||
142 | Int_t | |
7fc04b67 | 143 | AliHLTPHOSClusterAnalyser::CalculateClusterMoments(AliHLTPHOSRecPointDataStruct */*recPointPtr*/, AliHLTCaloClusterDataStruct* /*clusterPtr*/) |
fa0a9bec | 144 | { |
145 | //See header file for documentation | |
146 | return 0; | |
147 | } | |
148 | ||
149 | ||
150 | Int_t | |
151 | AliHLTPHOSClusterAnalyser::DeconvoluteClusters() | |
152 | { | |
153 | //See header file for documentation | |
154 | return 0; | |
155 | } | |
156 | ||
157 | Int_t | |
e304ea31 | 158 | AliHLTPHOSClusterAnalyser::CreateClusters(UInt_t availableSize, UInt_t& totSize) |
fa0a9bec | 159 | { |
160 | //See header file for documentation | |
fa0a9bec | 161 | |
7fc04b67 | 162 | UInt_t maxClusterSize = sizeof(AliHLTCaloClusterDataStruct) + (6 << 7); //Reasonable estimate... (6 = sizeof(Short_t) + sizeof(Float_t) |
e304ea31 | 163 | |
164 | AliHLTPHOSRecPointDataStruct* recPointPtr = fRecPointDataPtr; | |
933eb3ed | 165 | AliHLTPHOSDigitDataStruct* digitPtr = 0; |
0dc57e1b | 166 | |
933eb3ed | 167 | AliHLTPHOSDigitReader reader; |
e304ea31 | 168 | |
7fc04b67 | 169 | AliHLTCaloClusterDataStruct* caloClusterPtr = fCaloClusterDataPtr; |
e304ea31 | 170 | |
cefad3b2 | 171 | //Int_t id = -1; |
87434909 | 172 | TVector3 globalPos; |
fa0a9bec | 173 | |
87434909 | 174 | 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 | 175 | { |
933eb3ed | 176 | digitPtr = reinterpret_cast<AliHLTPHOSDigitDataStruct*>(reinterpret_cast<Long_t>(fDigitHeaderPtr) + recPointPtr->fStartDigitOffset); |
341aab10 | 177 | reader.SetNextDigit(digitPtr); |
933eb3ed | 178 | |
e304ea31 | 179 | if(availableSize < (totSize + maxClusterSize)) |
180 | { | |
181 | return -1; //Might get out of buffer, exiting | |
182 | } | |
947064ec | 183 | fPHOSGeometry->Local2Global(recPointPtr->fModule, recPointPtr->fX, recPointPtr->fZ, globalPos); |
fa0a9bec | 184 | |
185 | caloClusterPtr->fGlobalPos[0] = globalPos[0]; | |
186 | caloClusterPtr->fGlobalPos[1] = globalPos[1]; | |
187 | caloClusterPtr->fGlobalPos[2] = globalPos[2]; | |
341aab10 | 188 | cout << "Global position: " << globalPos[0] << ", " << globalPos[1] << ", " << globalPos[2] << endl; |
fa0a9bec | 189 | caloClusterPtr->fNCells = recPointPtr->fMultiplicity; |
8efbf5fe | 190 | |
0dc57e1b | 191 | while(digitPtr) |
fa0a9bec | 192 | { |
fa0a9bec | 193 | } |
e304ea31 | 194 | |
fa0a9bec | 195 | caloClusterPtr->fEnergy = recPointPtr->fAmp; |
947064ec | 196 | |
fa0a9bec | 197 | if(fDoClusterFit) |
198 | { | |
199 | FitCluster(recPointPtr); | |
200 | } | |
201 | else | |
202 | { | |
203 | caloClusterPtr->fDispersion = 0; | |
204 | caloClusterPtr->fFitQuality = 0; | |
205 | caloClusterPtr->fM20 = 0; | |
206 | caloClusterPtr->fM02 = 0; | |
947064ec | 207 | |
fa0a9bec | 208 | } |
209 | if(fHaveCPVInfo) | |
210 | { | |
211 | caloClusterPtr->fEmcCpvDistance = GetCPVDistance(recPointPtr); | |
212 | } | |
213 | else | |
214 | { | |
215 | caloClusterPtr->fEmcCpvDistance = -1; | |
216 | } | |
217 | if(fDoPID) | |
218 | { | |
219 | DoParticleIdentification(caloClusterPtr); | |
220 | } | |
221 | else | |
222 | { | |
223 | for(Int_t k = 0; k < AliPID::kSPECIESN; k++) | |
224 | { | |
225 | caloClusterPtr->fPID[k] = 0; | |
226 | } | |
227 | } | |
fa0a9bec | 228 | if(fHaveDistanceToBadChannel) |
229 | { | |
230 | caloClusterPtr->fDistanceToBadChannel = GetDistanceToBadChannel(caloClusterPtr); | |
231 | } | |
232 | else | |
233 | { | |
234 | caloClusterPtr->fDistanceToBadChannel = -1; | |
235 | } | |
236 | ||
947064ec | 237 | caloClusterPtr->fClusterType = (AliESDCaloCluster::kPHOSCluster); |
b2faa1a0 | 238 | |
7fc04b67 | 239 | totSize += sizeof(AliHLTCaloClusterDataStruct) + (caloClusterPtr->fNCells-1)*(sizeof(Short_t) + sizeof(Float_t)); |
8efbf5fe | 240 | |
341aab10 | 241 | // recPointPtr = reinterpret_cast<AliHLTPHOSRecPointDataStruct*>(digitPtr); |
242 | recPointPtr++; | |
933eb3ed | 243 | |
e304ea31 | 244 | } |
b2faa1a0 | 245 | |
e304ea31 | 246 | return fNRecPoints; |
fa0a9bec | 247 | |
248 | } | |
249 |