]>
Commit | Line | Data |
---|---|---|
1 | // $Id$ | |
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 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" | |
32 | #include "AliHLTPHOSRecPointHeaderStruct.h" | |
33 | #include "AliHLTPHOSRecPointDataStruct.h" | |
34 | #include "AliHLTCaloClusterDataStruct.h" | |
35 | #include "AliHLTPHOSPhysicsAnalyzer.h" | |
36 | #include "AliHLTPHOSDigitReader.h" | |
37 | #include "AliPHOSGeoUtils.h" | |
38 | #include "AliESDCaloCluster.h" | |
39 | #include "TMath.h" | |
40 | #include "TVector3.h" | |
41 | ||
42 | ClassImp(AliHLTPHOSClusterAnalyser); | |
43 | ||
44 | AliHLTPHOSClusterAnalyser::AliHLTPHOSClusterAnalyser() : | |
45 | // AliHLTPHOSBase(), | |
46 | fLogWeight(4.5), | |
47 | fRecPointDataPtr(0), | |
48 | fNRecPoints(0), | |
49 | fCaloClusterDataPtr(0), | |
50 | fCaloClusterHeaderPtr(0), | |
51 | fPHOSGeometry(0), | |
52 | fDoClusterFit(false), | |
53 | fHaveCPVInfo(false), | |
54 | fDoPID(false), | |
55 | fHaveDistanceToBadChannel(false), | |
56 | fDigitHeaderPtr(0) | |
57 | { | |
58 | //See header file for documentation | |
59 | } | |
60 | ||
61 | AliHLTPHOSClusterAnalyser::~AliHLTPHOSClusterAnalyser() | |
62 | { | |
63 | } | |
64 | ||
65 | void | |
66 | AliHLTPHOSClusterAnalyser::SetCaloClusterDataPtr(AliHLTCaloClusterDataStruct *caloClusterDataPtr) | |
67 | { | |
68 | //see header file for documentation | |
69 | fCaloClusterDataPtr = caloClusterDataPtr; | |
70 | } | |
71 | void | |
72 | AliHLTPHOSClusterAnalyser::SetRecPointDataPtr(AliHLTPHOSRecPointHeaderStruct *recPointDataPtr, AliHLTPHOSDigitHeaderStruct *digitHeaderPtr) | |
73 | { | |
74 | fNRecPoints = recPointDataPtr->fNRecPoints; | |
75 | ||
76 | fRecPointDataPtr = reinterpret_cast<AliHLTPHOSRecPointDataStruct*>(reinterpret_cast<Char_t*>(recPointDataPtr)+sizeof(AliHLTPHOSRecPointHeaderStruct)); | |
77 | fDigitHeaderPtr = digitHeaderPtr; | |
78 | } | |
79 | ||
80 | Int_t | |
81 | AliHLTPHOSClusterAnalyser::CalculateCenterOfGravity() | |
82 | { | |
83 | //see header file for documentation | |
84 | Float_t wtot = 0.; | |
85 | Float_t x = 0.; | |
86 | Float_t z = 0.; | |
87 | Float_t xi = 0.; | |
88 | Float_t zi = 0.; | |
89 | ||
90 | AliHLTPHOSDigitDataStruct *digit = 0; | |
91 | //AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance() ; | |
92 | ||
93 | AliHLTPHOSRecPointDataStruct *recPoint = fRecPointDataPtr; | |
94 | // UInt_t iDigit = 0; | |
95 | if(!recPoint) return 0; | |
96 | for(Int_t iRecPoint=0; iRecPoint < fNRecPoints; iRecPoint++) | |
97 | { | |
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; | |
101 | AliHLTPHOSDigitReader reader; | |
102 | reader.SetNextDigit(digit); | |
103 | while(digit) | |
104 | { | |
105 | xi = digit->fX; | |
106 | zi = digit->fZ; | |
107 | // cout << "COG digits (x:z:E:time): " << xi << " : " << zi << " : " << digit->fEnergy << " : " << digit->fTime << endl; | |
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 | } | |
115 | digit = reader.NextDigit(); | |
116 | } | |
117 | if (wtot>0) | |
118 | { | |
119 | recPoint->fX = x/wtot ; | |
120 | recPoint->fZ = z/wtot ; | |
121 | } | |
122 | ||
123 | else | |
124 | { | |
125 | recPoint->fAmp = 0; | |
126 | } | |
127 | recPoint++; | |
128 | } | |
129 | ||
130 | ||
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 | |
143 | AliHLTPHOSClusterAnalyser::CalculateClusterMoments(AliHLTPHOSRecPointDataStruct */*recPointPtr*/, AliHLTCaloClusterDataStruct* /*clusterPtr*/) | |
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 | |
158 | AliHLTPHOSClusterAnalyser::CreateClusters(UInt_t availableSize, UInt_t& totSize) | |
159 | { | |
160 | //See header file for documentation | |
161 | ||
162 | UInt_t maxClusterSize = sizeof(AliHLTCaloClusterDataStruct) + (6 << 7); //Reasonable estimate... (6 = sizeof(Short_t) + sizeof(Float_t) | |
163 | ||
164 | AliHLTPHOSRecPointDataStruct* recPointPtr = fRecPointDataPtr; | |
165 | AliHLTPHOSDigitDataStruct* digitPtr = 0; | |
166 | ||
167 | AliHLTPHOSDigitReader reader; | |
168 | ||
169 | AliHLTCaloClusterDataStruct* caloClusterPtr = fCaloClusterDataPtr; | |
170 | ||
171 | //Int_t id = -1; | |
172 | TVector3 globalPos; | |
173 | ||
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 | |
175 | { | |
176 | digitPtr = reinterpret_cast<AliHLTPHOSDigitDataStruct*>(reinterpret_cast<Long_t>(fDigitHeaderPtr) + recPointPtr->fStartDigitOffset); | |
177 | reader.SetNextDigit(digitPtr); | |
178 | ||
179 | if(availableSize < (totSize + maxClusterSize)) | |
180 | { | |
181 | return -1; //Might get out of buffer, exiting | |
182 | } | |
183 | fPHOSGeometry->Local2Global(recPointPtr->fModule, recPointPtr->fX, recPointPtr->fZ, globalPos); | |
184 | ||
185 | caloClusterPtr->fGlobalPos[0] = globalPos[0]; | |
186 | caloClusterPtr->fGlobalPos[1] = globalPos[1]; | |
187 | caloClusterPtr->fGlobalPos[2] = globalPos[2]; | |
188 | cout << "Global position: " << globalPos[0] << ", " << globalPos[1] << ", " << globalPos[2] << endl; | |
189 | caloClusterPtr->fNCells = recPointPtr->fMultiplicity; | |
190 | ||
191 | while(digitPtr) | |
192 | { | |
193 | } | |
194 | ||
195 | caloClusterPtr->fEnergy = recPointPtr->fAmp; | |
196 | ||
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; | |
207 | ||
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::kSPECIESCN; k++) | |
224 | { | |
225 | caloClusterPtr->fPID[k] = 0; | |
226 | } | |
227 | } | |
228 | if(fHaveDistanceToBadChannel) | |
229 | { | |
230 | caloClusterPtr->fDistanceToBadChannel = GetDistanceToBadChannel(caloClusterPtr); | |
231 | } | |
232 | else | |
233 | { | |
234 | caloClusterPtr->fDistanceToBadChannel = -1; | |
235 | } | |
236 | ||
237 | caloClusterPtr->fClusterType = (AliESDCaloCluster::kPHOSCluster); | |
238 | ||
239 | totSize += sizeof(AliHLTCaloClusterDataStruct) + (caloClusterPtr->fNCells-1)*(sizeof(Short_t) + sizeof(Float_t)); | |
240 | ||
241 | // recPointPtr = reinterpret_cast<AliHLTPHOSRecPointDataStruct*>(digitPtr); | |
242 | recPointPtr++; | |
243 | ||
244 | } | |
245 | ||
246 | return fNRecPoints; | |
247 | ||
248 | } | |
249 |