]>
Commit | Line | Data |
---|---|---|
ab48128d | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
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 | **************************************************************************/ | |
15 | /* $Id$ */ | |
16 | //_________________________________________________________________________ | |
70a93198 | 17 | // Reconstructed Points for the EMCAL |
18 | // A RecPoint is a cluster of digits | |
40164976 | 19 | // |
20 | // | |
d64c959b | 21 | //*-- Author: Yves Schutz (SUBATECH) |
70a93198 | 22 | //*-- Author: Dmitri Peressounko (RRC KI & SUBATECH) |
23 | //*-- Author: Heather Gray (LBL) merged AliEMCALRecPoint and AliEMCALTowerRecPoint 02/04 | |
ab48128d | 24 | |
25 | // --- ROOT system --- | |
9aa6a5f6 | 26 | #include "TPad.h" |
27 | #include "TGraph.h" | |
28 | #include "TPaveText.h" | |
29 | #include "TClonesArray.h" | |
30 | #include "TMath.h" | |
31 | #include "TGeoMatrix.h" | |
32 | #include "TGeoManager.h" | |
33 | #include "TGeoPhysicalNode.h" | |
25bb3dcb | 34 | #include "TRandom.h" |
ab48128d | 35 | |
36 | // --- Standard library --- | |
9aa6a5f6 | 37 | #include <Riostream.h> |
ab48128d | 38 | |
39 | // --- AliRoot header files --- | |
1d59832c | 40 | //#include "AliGenerator.h" |
41 | class AliGenerator; | |
1d59832c | 42 | class AliEMCAL; |
9aa6a5f6 | 43 | #include "AliLog.h" |
44 | #include "AliGeomManager.h" | |
ab48128d | 45 | #include "AliEMCALGeometry.h" |
4635df1f | 46 | #include "AliEMCALHit.h" |
ab48128d | 47 | #include "AliEMCALDigit.h" |
48 | #include "AliEMCALRecPoint.h" | |
40164976 | 49 | #include "AliCaloCalibPedestal.h" |
50 | #include "AliEMCALGeoParams.h" | |
ab48128d | 51 | |
52 | ClassImp(AliEMCALRecPoint) | |
53 | ||
ab48128d | 54 | //____________________________________________________________________________ |
55 | AliEMCALRecPoint::AliEMCALRecPoint() | |
9aa6a5f6 | 56 | : AliCluster(), fGeomPtr(0), |
57 | fAmp(0), fIndexInList(-1), //to be set when the point is already stored | |
25bb3dcb | 58 | fGlobPos(0,0,0),fLocPos(0,0,0), |
9aa6a5f6 | 59 | fMaxDigit(100), fMulDigit(0), fMaxTrack(200), |
60 | fMulTrack(0), fDigitsList(0), fTracksList(0), | |
61 | fClusterType(-1), fCoreEnergy(0), fDispersion(0), | |
62 | fEnergyList(0), fTimeList(0), fAbsIdList(0), | |
0561e246 | 63 | fTime(0.), fNExMax(0), fCoreRadius(10), //HG check this |
9aa6a5f6 | 64 | fDETracksList(0), fMulParent(0), fMaxParent(0), |
65 | fParentsList(0), fDEParentsList(0), fSuperModuleNumber(0), | |
25bb3dcb | 66 | fDigitIndMax(-1), fDistToBadTower(-1), fSharedCluster(kFALSE) |
ab48128d | 67 | { |
68 | // ctor | |
9aa6a5f6 | 69 | fGeomPtr = AliEMCALGeometry::GetInstance(); |
70 | ||
706863b6 | 71 | fLambda[0] = 0; |
72 | fLambda[1] = 0; | |
9aa6a5f6 | 73 | |
ab48128d | 74 | } |
75 | ||
76 | //____________________________________________________________________________ | |
9aa6a5f6 | 77 | AliEMCALRecPoint::AliEMCALRecPoint(const char *) |
78 | : AliCluster(), fGeomPtr(0), | |
79 | fAmp(0), fIndexInList(-1), //to be set when the point is already stored | |
25bb3dcb | 80 | fGlobPos(0,0,0), fLocPos(0,0,0), |
9aa6a5f6 | 81 | fMaxDigit(100), fMulDigit(0), fMaxTrack(1000), fMulTrack(0), |
82 | fDigitsList(new Int_t[fMaxDigit]), fTracksList(new Int_t[fMaxTrack]), | |
83 | fClusterType(-1), fCoreEnergy(0), fDispersion(0), | |
84 | fEnergyList(new Float_t[fMaxDigit]), fTimeList(new Float_t[fMaxDigit]), | |
0561e246 | 85 | fAbsIdList(new Int_t[fMaxDigit]), fTime(-1.), fNExMax(0), fCoreRadius(10), |
9aa6a5f6 | 86 | fDETracksList(new Float_t[fMaxTrack]), fMulParent(0), fMaxParent(1000), |
87 | fParentsList(new Int_t[fMaxParent]), fDEParentsList(new Float_t[fMaxParent]), | |
25bb3dcb | 88 | fSuperModuleNumber(0), fDigitIndMax(-1), fDistToBadTower(-1),fSharedCluster(kFALSE) |
ab48128d | 89 | { |
90 | // ctor | |
af5bdd85 | 91 | for (Int_t i = 0; i < fMaxTrack; i++) |
92 | fDETracksList[i] = 0; | |
94478418 | 93 | for (Int_t i = 0; i < fMaxParent; i++) { |
94 | fParentsList[i] = -1; | |
af5bdd85 | 95 | fDEParentsList[i] = 0; |
94478418 | 96 | } |
18a21c7c | 97 | |
9aa6a5f6 | 98 | fGeomPtr = AliEMCALGeometry::GetInstance(); |
706863b6 | 99 | fLambda[0] = 0; |
100 | fLambda[1] = 0; | |
70a93198 | 101 | } |
18a21c7c | 102 | |
70a93198 | 103 | //____________________________________________________________________________ |
18a21c7c | 104 | AliEMCALRecPoint::AliEMCALRecPoint(const AliEMCALRecPoint & rp) |
9aa6a5f6 | 105 | : AliCluster(rp), fGeomPtr(rp.fGeomPtr), |
106 | fAmp(rp.fAmp), fIndexInList(rp.fIndexInList), | |
25bb3dcb | 107 | fGlobPos(rp.fGlobPos),fLocPos(rp.fLocPos), |
9aa6a5f6 | 108 | fMaxDigit(rp.fMaxDigit), fMulDigit(rp.fMulDigit), |
109 | fMaxTrack(rp.fMaxTrack), fMulTrack(rp.fMaxTrack), | |
110 | fDigitsList(new Int_t[rp.fMaxDigit]), fTracksList(new Int_t[rp.fMaxTrack]), | |
111 | fClusterType(rp.fClusterType), fCoreEnergy(rp.fCoreEnergy), | |
18a21c7c | 112 | fDispersion(rp.fDispersion), |
9aa6a5f6 | 113 | fEnergyList(new Float_t[rp.fMaxDigit]), fTimeList(new Float_t[rp.fMaxDigit]), |
0561e246 | 114 | fAbsIdList(new Int_t[rp.fMaxDigit]), fTime(rp.fTime), fNExMax(rp.fNExMax),fCoreRadius(rp.fCoreRadius), |
9aa6a5f6 | 115 | fDETracksList(new Float_t[rp.fMaxTrack]), fMulParent(rp.fMulParent), |
116 | fMaxParent(rp.fMaxParent), fParentsList(new Int_t[rp.fMaxParent]), | |
117 | fDEParentsList(new Float_t[rp.fMaxParent]), | |
40164976 | 118 | fSuperModuleNumber(rp.fSuperModuleNumber), fDigitIndMax(rp.fDigitIndMax), |
25bb3dcb | 119 | fDistToBadTower(rp.fDistToBadTower), fSharedCluster(rp.fSharedCluster) |
0a4cb131 | 120 | { |
121 | //copy ctor | |
0a4cb131 | 122 | fLambda[0] = rp.fLambda[0]; |
123 | fLambda[1] = rp.fLambda[1]; | |
18a21c7c | 124 | |
0a4cb131 | 125 | for(Int_t i = 0; i < rp.fMulDigit; i++) { |
126 | fEnergyList[i] = rp.fEnergyList[i]; | |
127 | fTimeList[i] = rp.fTimeList[i]; | |
128 | fAbsIdList[i] = rp.fAbsIdList[i]; | |
129 | } | |
9aa6a5f6 | 130 | |
af5bdd85 | 131 | for(Int_t i = 0; i < rp.fMulTrack; i++) fDETracksList[i] = rp.fDETracksList[i]; |
9aa6a5f6 | 132 | |
133 | for(Int_t i = 0; i < rp.fMulParent; i++) { | |
134 | fParentsList[i] = rp.fParentsList[i]; | |
135 | fDEParentsList[i] = rp.fDEParentsList[i]; | |
136 | } | |
0a4cb131 | 137 | |
138 | } | |
139 | //____________________________________________________________________________ | |
70a93198 | 140 | AliEMCALRecPoint::~AliEMCALRecPoint() |
141 | { | |
142 | // dtor | |
143 | if ( fEnergyList ) | |
144 | delete[] fEnergyList ; | |
85c60a8e | 145 | if ( fTimeList ) |
146 | delete[] fTimeList ; | |
e52475ed | 147 | if ( fAbsIdList ) |
148 | delete[] fAbsIdList ; | |
af5bdd85 | 149 | if ( fDETracksList) |
150 | delete[] fDETracksList; | |
87cdc3be | 151 | if ( fParentsList) |
152 | delete[] fParentsList; | |
af5bdd85 | 153 | if ( fDEParentsList) |
154 | delete[] fDEParentsList; | |
25bb3dcb | 155 | |
9aa6a5f6 | 156 | delete [] fDigitsList ; |
157 | delete [] fTracksList ; | |
158 | } | |
159 | ||
160 | //____________________________________________________________________________ | |
161 | AliEMCALRecPoint& AliEMCALRecPoint::operator= (const AliEMCALRecPoint &rp) | |
162 | { | |
37890aaf | 163 | // assignment operator |
164 | ||
9aa6a5f6 | 165 | if(&rp == this) return *this; |
166 | ||
167 | fGeomPtr = rp.fGeomPtr; | |
168 | fAmp = rp.fAmp; | |
169 | fIndexInList = rp.fIndexInList; | |
25bb3dcb | 170 | fGlobPos = rp.fGlobPos; |
171 | fLocPos = rp.fLocPos; | |
9aa6a5f6 | 172 | fMaxDigit = rp.fMaxDigit; |
173 | fMulDigit = rp.fMulDigit; | |
174 | fMaxTrack = rp.fMaxTrack; | |
175 | fMulTrack = rp.fMaxTrack; | |
176 | for(Int_t i = 0; i<fMaxDigit; i++) fDigitsList[i] = rp.fDigitsList[i]; | |
177 | for(Int_t i = 0; i<fMaxTrack; i++) fTracksList[i] = rp.fTracksList[i]; | |
178 | fClusterType = rp.fClusterType; | |
179 | fCoreEnergy = rp.fCoreEnergy; | |
180 | fDispersion = rp.fDispersion; | |
181 | for(Int_t i = 0; i<fMaxDigit; i++) { | |
182 | fEnergyList[i] = rp.fEnergyList[i]; | |
183 | fTimeList[i] = rp.fTimeList[i]; | |
184 | fAbsIdList[i] = rp.fAbsIdList[i]; | |
185 | } | |
186 | fTime = rp.fTime; | |
0561e246 | 187 | fNExMax = rp.fNExMax; |
9aa6a5f6 | 188 | fCoreRadius = rp.fCoreRadius; |
189 | for(Int_t i = 0; i < fMaxTrack; i++) fDETracksList[i] = rp.fDETracksList[i]; | |
190 | fMulParent = rp.fMulParent; | |
191 | fMaxParent = rp.fMaxParent; | |
192 | for(Int_t i = 0; i < fMaxParent; i++) { | |
193 | fParentsList[i] = rp.fParentsList[i]; | |
194 | fDEParentsList[i] = rp.fDEParentsList[i]; | |
195 | } | |
196 | fSuperModuleNumber = rp.fSuperModuleNumber; | |
197 | fDigitIndMax = rp.fDigitIndMax; | |
198 | ||
199 | fLambda[0] = rp.fLambda[0]; | |
200 | fLambda[1] = rp.fLambda[1]; | |
40164976 | 201 | |
202 | fDistToBadTower = rp.fDistToBadTower; | |
25bb3dcb | 203 | fSharedCluster = rp.fSharedCluster; |
40164976 | 204 | |
9aa6a5f6 | 205 | return *this; |
206 | ||
70a93198 | 207 | } |
208 | ||
209 | //____________________________________________________________________________ | |
25bb3dcb | 210 | void AliEMCALRecPoint::AddDigit(AliEMCALDigit & digit, Float_t Energy, Bool_t shared) |
70a93198 | 211 | { |
212 | // Adds a digit to the RecPoint | |
213 | // and accumulates the total amplitude and the multiplicity | |
214 | ||
215 | if(fEnergyList == 0) | |
216 | fEnergyList = new Float_t[fMaxDigit]; | |
85c60a8e | 217 | if(fTimeList == 0) |
218 | fTimeList = new Float_t[fMaxDigit]; | |
e52475ed | 219 | if(fAbsIdList == 0) { |
220 | fAbsIdList = new Int_t[fMaxDigit]; | |
e52475ed | 221 | } |
70a93198 | 222 | |
223 | if ( fMulDigit >= fMaxDigit ) { // increase the size of the lists | |
224 | fMaxDigit*=2 ; | |
a64a06d6 | 225 | Int_t * tempo = new Int_t[fMaxDigit]; |
226 | Float_t * tempoE = new Float_t[fMaxDigit]; | |
85c60a8e | 227 | Float_t * tempoT = new Float_t[fMaxDigit]; |
e52475ed | 228 | Int_t * tempoId = new Int_t[fMaxDigit]; |
70a93198 | 229 | |
230 | Int_t index ; | |
231 | for ( index = 0 ; index < fMulDigit ; index++ ){ | |
e52475ed | 232 | tempo[index] = fDigitsList[index] ; |
233 | tempoE[index] = fEnergyList[index] ; | |
85c60a8e | 234 | tempoT[index] = fTimeList[index] ; |
e52475ed | 235 | tempoId[index] = fAbsIdList[index] ; |
70a93198 | 236 | } |
237 | ||
94478418 | 238 | delete [] fDigitsList ; |
70a93198 | 239 | delete [] fEnergyList ; |
85c60a8e | 240 | delete [] fTimeList ; |
e52475ed | 241 | delete [] fAbsIdList ; |
e52475ed | 242 | |
94478418 | 243 | fDigitsList = tempo; |
244 | fEnergyList = tempoE; | |
245 | fTimeList = tempoT; | |
246 | fAbsIdList = tempoId; | |
70a93198 | 247 | } // if |
248 | ||
249 | fDigitsList[fMulDigit] = digit.GetIndexInList() ; | |
250 | fEnergyList[fMulDigit] = Energy ; | |
94478418 | 251 | fTimeList[fMulDigit] = digit.GetTimeR() ; |
e52475ed | 252 | fAbsIdList[fMulDigit] = digit.GetId(); |
70a93198 | 253 | fMulDigit++ ; |
254 | fAmp += Energy ; | |
25bb3dcb | 255 | |
256 | if(shared) fSharedCluster = kTRUE; | |
257 | ||
258 | //GCB, May-2010, setting moved to EvalAll method, set the super module number for the largest energy digit position. | |
9aa6a5f6 | 259 | //JLK 10-Oct-2007 this hasn't been filled before because it was in |
260 | //the wrong place in previous versions. | |
261 | //Now we evaluate it only if the supermodulenumber for this recpoint | |
262 | //has not yet been set (or is the 0th one) | |
25bb3dcb | 263 | //if(fSuperModuleNumber == 0) |
264 | //fSuperModuleNumber = fGeomPtr->GetSuperModuleNumber(digit.GetId()); | |
9aa6a5f6 | 265 | |
70a93198 | 266 | } |
267 | //____________________________________________________________________________ | |
268 | Bool_t AliEMCALRecPoint::AreNeighbours(AliEMCALDigit * digit1, AliEMCALDigit * digit2 ) const | |
269 | { | |
270 | // Tells if (true) or not (false) two digits are neighbours | |
271 | // A neighbour is defined as being two digits which share a corner | |
25bb3dcb | 272 | // ONLY USED IN CASE OF UNFOLDING |
273 | ||
e52475ed | 274 | static Bool_t areNeighbours = kFALSE ; |
2bb3725c | 275 | static Int_t nSupMod=0, nModule=0, nIphi=0, nIeta=0; |
276 | static int nSupMod1=0, nModule1=0, nIphi1=0, nIeta1=0; | |
e52475ed | 277 | static Int_t relid1[2] , relid2[2] ; // ieta, iphi |
278 | static Int_t rowdiff=0, coldiff=0; | |
70a93198 | 279 | |
e52475ed | 280 | areNeighbours = kFALSE ; |
281 | ||
2bb3725c | 282 | fGeomPtr->GetCellIndex(digit1->GetId(), nSupMod,nModule,nIphi,nIeta); |
283 | fGeomPtr->GetCellPhiEtaIndexInSModule(nSupMod,nModule,nIphi,nIeta, relid1[0],relid1[1]); | |
e52475ed | 284 | |
2bb3725c | 285 | fGeomPtr->GetCellIndex(digit2->GetId(), nSupMod1,nModule1,nIphi1,nIeta1); |
286 | fGeomPtr->GetCellPhiEtaIndexInSModule(nSupMod1,nModule1,nIphi1,nIeta1, relid2[0],relid2[1]); | |
70a93198 | 287 | |
25bb3dcb | 288 | // In case of a shared cluster, index of SM in C side, columns start at 48 and ends at 48*2-1 |
289 | // C Side impair SM, nSupMod%2=1; A side pair SM nSupMod%2=0 | |
290 | if(fSharedCluster){ | |
291 | if(nSupMod1%2) relid1[1]+=AliEMCALGeoParams::fgkEMCALCols; | |
292 | else relid2[1]+=AliEMCALGeoParams::fgkEMCALCols; | |
293 | } | |
294 | ||
e52475ed | 295 | rowdiff = TMath::Abs( relid1[0] - relid2[0] ) ; |
296 | coldiff = TMath::Abs( relid1[1] - relid2[1] ) ; | |
70a93198 | 297 | |
298 | if (( coldiff <= 1 ) && ( rowdiff <= 1 ) && (coldiff + rowdiff > 0)) | |
e52475ed | 299 | areNeighbours = kTRUE ; |
ab48128d | 300 | |
70a93198 | 301 | return areNeighbours; |
302 | } | |
303 | ||
304 | //____________________________________________________________________________ | |
305 | Int_t AliEMCALRecPoint::Compare(const TObject * obj) const | |
306 | { | |
307 | // Compares two RecPoints according to their position in the EMCAL modules | |
308 | ||
25bb3dcb | 309 | Float_t delta = 1 ; //Width of "Sorting row". |
310 | ||
53e430a3 | 311 | Int_t rv = 2 ; |
70a93198 | 312 | |
313 | AliEMCALRecPoint * clu = (AliEMCALRecPoint *)obj ; | |
314 | ||
315 | TVector3 locpos1; | |
316 | GetLocalPosition(locpos1); | |
317 | TVector3 locpos2; | |
318 | clu->GetLocalPosition(locpos2); | |
319 | ||
9848d950 | 320 | Int_t rowdif = (Int_t)(TMath::Ceil(locpos1.X()/delta)-TMath::Ceil(locpos2.X()/delta)) ; |
70a93198 | 321 | if (rowdif> 0) |
322 | rv = 1 ; | |
323 | else if(rowdif < 0) | |
324 | rv = -1 ; | |
325 | else if(locpos1.Y()>locpos2.Y()) | |
326 | rv = -1 ; | |
327 | else | |
328 | rv = 1 ; | |
329 | ||
330 | return rv ; | |
ab48128d | 331 | } |
332 | ||
25bb3dcb | 333 | // GCB, May-2010, Method not used, just comment it but remove? |
ab48128d | 334 | //____________________________________________________________________________ |
25bb3dcb | 335 | //Int_t AliEMCALRecPoint::DistancetoPrimitive(Int_t px, Int_t py) |
336 | //{ | |
337 | // // Compute distance from point px,py to a AliEMCALRecPoint considered as a Tmarker | |
338 | // // Compute the closest distance of approach from point px,py to this marker. | |
339 | // // The distance is computed in pixels units. | |
340 | // // HG Still need to update -> Not sure what this should achieve | |
341 | // | |
342 | // TVector3 pos(0.,0.,0.) ; | |
343 | // GetLocalPosition(pos) ; | |
344 | // Float_t x = pos.X() ; | |
345 | // Float_t y = pos.Y() ; | |
346 | // const Int_t kMaxDiff = 10; | |
347 | // Int_t pxm = gPad->XtoAbsPixel(x); | |
348 | // Int_t pym = gPad->YtoAbsPixel(y); | |
349 | // Int_t dist = (px-pxm)*(px-pxm) + (py-pym)*(py-pym); | |
350 | // | |
351 | // if (dist > kMaxDiff) return 9999; | |
352 | // return dist; | |
353 | //} | |
ab48128d | 354 | |
355 | //___________________________________________________________________________ | |
356 | void AliEMCALRecPoint::Draw(Option_t *option) | |
357 | { | |
358 | // Draw this AliEMCALRecPoint with its current attributes | |
359 | ||
360 | AppendPad(option); | |
361 | } | |
362 | ||
25bb3dcb | 363 | // GCB, May-2010, Method not used, just comment it but remove? |
ab48128d | 364 | //______________________________________________________________________________ |
25bb3dcb | 365 | //void AliEMCALRecPoint::ExecuteEvent(Int_t /*event*/, Int_t, Int_t) |
366 | //{ | |
367 | // // Execute action corresponding to one event | |
368 | // // This member function is called when a AliEMCALRecPoint is clicked with the locator | |
369 | // // | |
370 | // // If Left button is clicked on AliEMCALRecPoint, the digits are switched on | |
371 | // // and switched off when the mouse button is released. | |
372 | // | |
373 | // // static Int_t pxold, pyold; | |
374 | // | |
375 | // /* static TGraph * digitgraph = 0 ; | |
376 | // static TPaveText* clustertext = 0 ; | |
377 | // | |
378 | // if (!gPad->IsEditable()) return; | |
379 | // | |
380 | // switch (event) { | |
381 | // | |
382 | // | |
383 | // case kButton1Down:{ | |
384 | // AliEMCALDigit * digit ; | |
385 | // | |
386 | // Int_t iDigit; | |
387 | // Int_t relid[2] ; | |
388 | // | |
389 | // const Int_t kMulDigit=AliEMCALRecPoint::GetDigitsMultiplicity() ; | |
390 | // Float_t * xi = new Float_t [kMulDigit] ; | |
391 | // Float_t * zi = new Float_t [kMulDigit] ; | |
392 | // | |
393 | // for(iDigit = 0; iDigit < kMulDigit; iDigit++) { | |
394 | // Fatal("AliEMCALRecPoint::ExecuteEvent", " -> Something wrong with the code"); | |
395 | // digit = 0 ; //dynamic_cast<AliEMCALDigit *>((fDigitsList)[iDigit]); | |
396 | // fGeomPtr->AbsToRelNumbering(digit->GetId(), relid) ; | |
397 | // fGeomPtr->PosInAlice(relid, xi[iDigit], zi[iDigit]) ; | |
398 | // } | |
399 | // | |
400 | // if (!digitgraph) { | |
401 | // digitgraph = new TGraph(fMulDigit,xi,zi); | |
402 | // digitgraph-> SetMarkerStyle(5) ; | |
403 | // digitgraph-> SetMarkerSize(1.) ; | |
404 | // digitgraph-> SetMarkerColor(1) ; | |
405 | // digitgraph-> Draw("P") ; | |
406 | // } | |
407 | // if (!clustertext) { | |
408 | // | |
409 | // TVector3 pos(0.,0.,0.) ; | |
410 | // GetLocalPosition(pos) ; | |
411 | // clustertext = new TPaveText(pos.X()-10,pos.Z()+10,pos.X()+50,pos.Z()+35,"") ; | |
412 | // Text_t line1[40] ; | |
413 | // Text_t line2[40] ; | |
414 | // sprintf(line1,"Energy=%1.2f GeV",GetEnergy()) ; | |
415 | // sprintf(line2,"%d Digits",GetDigitsMultiplicity()) ; | |
416 | // clustertext ->AddText(line1) ; | |
417 | // clustertext ->AddText(line2) ; | |
418 | // clustertext ->Draw(""); | |
419 | // } | |
420 | // gPad->Update() ; | |
421 | // Print("") ; | |
422 | // delete[] xi ; | |
423 | // delete[] zi ; | |
424 | // } | |
425 | // | |
426 | //break; | |
427 | // | |
428 | // case kButton1Up: | |
429 | // if (digitgraph) { | |
430 | // delete digitgraph ; | |
431 | // digitgraph = 0 ; | |
432 | // } | |
433 | // if (clustertext) { | |
434 | // delete clustertext ; | |
435 | // clustertext = 0 ; | |
436 | // } | |
437 | // | |
438 | // break; | |
439 | // | |
440 | // }*/ | |
441 | //} | |
ab48128d | 442 | |
70a93198 | 443 | //____________________________________________________________________________ |
444 | void AliEMCALRecPoint::EvalAll(Float_t logWeight,TClonesArray * digits) | |
445 | { | |
25bb3dcb | 446 | // Evaluates cluster parameters |
447 | ||
448 | // First calculate the index of digit with maximum amplitude and get | |
449 | // the supermodule number where it sits. | |
450 | fDigitIndMax = GetMaximalEnergyIndex(); | |
451 | fSuperModuleNumber = fGeomPtr->GetSuperModuleNumber(GetAbsIdMaxDigit()); | |
452 | ||
453 | //Evaluate global and local position | |
454 | EvalGlobalPosition(logWeight, digits) ; | |
70a93198 | 455 | EvalLocalPosition(logWeight, digits) ; |
25bb3dcb | 456 | |
457 | //Evaluate shower parameters | |
70a93198 | 458 | EvalElipsAxis(logWeight, digits) ; |
459 | EvalDispersion(logWeight, digits) ; | |
25bb3dcb | 460 | |
4635df1f | 461 | //EvalCoreEnergy(logWeight, digits); |
70a93198 | 462 | EvalTime(digits) ; |
87cdc3be | 463 | EvalPrimaries(digits) ; |
464 | EvalParents(digits); | |
40164976 | 465 | |
9aa6a5f6 | 466 | //Called last because it sets the global position of the cluster? |
467 | EvalLocal2TrackingCSTransform(); | |
468 | ||
70a93198 | 469 | } |
470 | ||
471 | //____________________________________________________________________________ | |
472 | void AliEMCALRecPoint::EvalDispersion(Float_t logWeight, TClonesArray * digits) | |
473 | { | |
474 | // Calculates the dispersion of the shower at the origin of the RecPoint | |
1d46d1f6 | 475 | // in cell units - Nov 16,2006 |
70a93198 | 476 | |
1d46d1f6 | 477 | Double_t d = 0., wtot = 0., w = 0.; |
af5bdd85 | 478 | Int_t iDigit=0, nstat=0; |
53e430a3 | 479 | AliEMCALDigit * digit=0; |
25bb3dcb | 480 | |
1d46d1f6 | 481 | // Calculates the dispersion in cell units |
482 | Double_t etai, phii, etaMean=0.0, phiMean=0.0; | |
2bb3725c | 483 | int nSupMod=0, nModule=0, nIphi=0, nIeta=0; |
1d46d1f6 | 484 | int iphi=0, ieta=0; |
485 | // Calculate mean values | |
70a93198 | 486 | for(iDigit=0; iDigit < fMulDigit; iDigit++) { |
487 | digit = (AliEMCALDigit *) digits->At(fDigitsList[iDigit]) ; | |
1963b290 | 488 | |
1d46d1f6 | 489 | if (fAmp>0 && fEnergyList[iDigit]>0) { |
2bb3725c | 490 | fGeomPtr->GetCellIndex(digit->GetId(), nSupMod,nModule,nIphi,nIeta); |
491 | fGeomPtr->GetCellPhiEtaIndexInSModule(nSupMod,nModule,nIphi,nIeta, iphi,ieta); | |
25bb3dcb | 492 | |
493 | // In case of a shared cluster, index of SM in C side, columns start at 48 and ends at 48*2 | |
494 | // C Side impair SM, nSupMod%2=1; A side pair SM nSupMod%2=0 | |
495 | if(fSharedCluster && nSupMod%2) ieta+=AliEMCALGeoParams::fgkEMCALCols; | |
496 | ||
1d46d1f6 | 497 | etai=(Double_t)ieta; |
498 | phii=(Double_t)iphi; | |
499 | w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ; | |
500 | ||
501 | if(w>0.0) { | |
502 | phiMean += phii*w; | |
503 | etaMean += etai*w; | |
504 | wtot += w; | |
505 | } | |
506 | } | |
507 | } | |
508 | if (wtot>0) { | |
509 | phiMean /= wtot ; | |
510 | etaMean /= wtot ; | |
511 | } else AliError(Form("Wrong weight %f\n", wtot)); | |
70a93198 | 512 | |
1d46d1f6 | 513 | // Calculate dispersion |
514 | for(iDigit=0; iDigit < fMulDigit; iDigit++) { | |
515 | digit = (AliEMCALDigit *) digits->At(fDigitsList[iDigit]) ; | |
516 | ||
517 | if (fAmp>0 && fEnergyList[iDigit]>0) { | |
2bb3725c | 518 | fGeomPtr->GetCellIndex(digit->GetId(), nSupMod,nModule,nIphi,nIeta); |
519 | fGeomPtr->GetCellPhiEtaIndexInSModule(nSupMod,nModule,nIphi,nIeta, iphi,ieta); | |
25bb3dcb | 520 | |
521 | // In case of a shared cluster, index of SM in C side, columns start at 48 and ends at 48*2 | |
522 | // C Side impair SM, nSupMod%2=1; A side pair SM, nSupMod%2=0 | |
523 | if(fSharedCluster && nSupMod%2) ieta+=AliEMCALGeoParams::fgkEMCALCols; | |
524 | ||
1d46d1f6 | 525 | etai=(Double_t)ieta; |
526 | phii=(Double_t)iphi; | |
527 | w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ; | |
528 | ||
529 | if(w>0.0) { | |
530 | nstat++; | |
531 | d += w*((etai-etaMean)*(etai-etaMean)+(phii-phiMean)*(phii-phiMean)); | |
e52475ed | 532 | } |
533 | } | |
ab48128d | 534 | } |
70a93198 | 535 | |
e52475ed | 536 | if ( wtot > 0 && nstat>1) d /= wtot ; |
537 | else d = 0. ; | |
70a93198 | 538 | |
539 | fDispersion = TMath::Sqrt(d) ; | |
25bb3dcb | 540 | //printf("AliEMCALRecPoint::EvalDispersion() : Dispersion %f \n",fDispersion); |
ab48128d | 541 | } |
70a93198 | 542 | |
40164976 | 543 | //____________________________________________________________________________ |
544 | void AliEMCALRecPoint::EvalDistanceToBadChannels(AliCaloCalibPedestal* caloped) | |
545 | { | |
546 | //For each EMC rec. point set the distance to the nearest bad channel. | |
547 | //AliInfo(Form("%d bad channel(s) found.\n", caloped->GetDeadTowerCount())); | |
2ebdefe6 | 548 | //It is done in cell units and not in global or local position as before (Sept 2010) |
40164976 | 549 | |
550 | if(!caloped->GetDeadTowerCount()) return; | |
25bb3dcb | 551 | |
552 | //Get channels map of the supermodule where the cluster is. | |
553 | TH2D* hMap = caloped->GetDeadMap(fSuperModuleNumber); | |
40164976 | 554 | |
2ebdefe6 | 555 | Int_t dRrow, dReta; |
556 | Float_t minDist = 10000.; | |
557 | Float_t dist = 0.; | |
558 | Int_t nSupMod, nModule; | |
559 | Int_t nIphi, nIeta; | |
560 | Int_t iphi, ieta; | |
561 | fDigitIndMax = GetMaximalEnergyIndex(); | |
562 | fGeomPtr->GetCellIndex(fAbsIdList[fDigitIndMax], nSupMod,nModule,nIphi,nIeta); | |
563 | fGeomPtr->GetCellPhiEtaIndexInSModule(nSupMod,nModule,nIphi,nIeta, iphi,ieta); | |
564 | ||
565 | // TVector3 dR; | |
566 | // TVector3 cellpos; | |
567 | // Float_t minDist = 100000; | |
568 | // Float_t dist = 0; | |
569 | // Int_t absId = -1; | |
570 | ||
571 | //Loop on tower status map | |
40164976 | 572 | for(Int_t irow = 0; irow < AliEMCALGeoParams::fgkEMCALRows; irow++){ |
573 | for(Int_t icol = 0; icol < AliEMCALGeoParams::fgkEMCALCols; icol++){ | |
574 | //Check if tower is bad. | |
575 | if(hMap->GetBinContent(icol,irow)==AliCaloCalibPedestal::kAlive) continue; | |
2ebdefe6 | 576 | //printf("AliEMCALRecPoint::EvalDistanceToBadChannels() - Bad channel in SM %d, col %d, row %d\n",iSM,icol, irow); |
577 | ||
578 | dRrow=TMath::Abs(irow-iphi); | |
579 | dReta=TMath::Abs(icol-ieta); | |
580 | dist=TMath::Sqrt(dRrow*dRrow+dReta*dReta); | |
25bb3dcb | 581 | if(dist < minDist) minDist = dist; |
2ebdefe6 | 582 | |
583 | // //Tower is bad, get the absId of the index. | |
584 | // absId = fGeomPtr->GetAbsCellIdFromCellIndexes(fSuperModuleNumber, irow, icol); | |
585 | // | |
586 | // //Get the position of this tower. | |
587 | // | |
588 | // //Calculate the distance in local coordinates | |
589 | // //fGeomPtr->RelPosCellInSModule(absId,cellpos); | |
590 | // //Calculate distance between this tower and cluster, set if is smaller than previous. | |
591 | // //dR = cellpos-fLocPos; | |
592 | // | |
593 | // //Calculate the distance in global coordinates | |
594 | // fGeomPtr->GetGlobal(absId,cellpos); | |
595 | // //Calculate distance between this tower and cluster, set if it is smaller than previous. | |
596 | // dR = cellpos-fGlobPos; | |
597 | // | |
598 | // dist = dR.Mag(); | |
599 | // if(dist < minDist) minDist = dist; | |
600 | ||
40164976 | 601 | } |
89dc5acd | 602 | } |
2ebdefe6 | 603 | |
25bb3dcb | 604 | //In case the cluster is shared by 2 SuperModules, need to check the map of the second Super Module |
605 | if (fSharedCluster) { | |
606 | TH2D* hMap2 = 0; | |
607 | Int_t nSupMod2 = -1; | |
608 | ||
609 | //The only possible combinations are (0,1), (2,3) ... (10,11) | |
610 | if(fSuperModuleNumber%2) nSupMod2 = fSuperModuleNumber-1; | |
611 | else nSupMod2 = fSuperModuleNumber+1; | |
612 | hMap2 = caloped->GetDeadMap(nSupMod2); | |
2ebdefe6 | 613 | |
25bb3dcb | 614 | //Loop on tower status map of second super module |
615 | for(Int_t irow = 0; irow < AliEMCALGeoParams::fgkEMCALRows; irow++){ | |
616 | for(Int_t icol = 0; icol < AliEMCALGeoParams::fgkEMCALCols; icol++){ | |
617 | //Check if tower is bad. | |
618 | if(hMap2->GetBinContent(icol,irow)==AliCaloCalibPedestal::kAlive) continue; | |
619 | //printf("AliEMCALRecPoint::EvalDistanceToBadChannels() - Bad channel in SM %d, col %d, row %d\n",iSM,icol, irow); | |
2ebdefe6 | 620 | |
621 | dRrow=TMath::Abs(irow-iphi); | |
622 | ||
623 | if(fSuperModuleNumber%2) { | |
624 | dReta=TMath::Abs(icol-(AliEMCALGeoParams::fgkEMCALCols+ieta)); | |
625 | } | |
626 | else { | |
627 | dReta=TMath::Abs(AliEMCALGeoParams::fgkEMCALCols+icol-ieta); | |
628 | } | |
629 | ||
630 | dist=TMath::Sqrt(dRrow*dRrow+dReta*dReta); | |
631 | if(dist < minDist) minDist = dist; | |
632 | ||
633 | // | |
634 | // //Tower is bad, get the absId of the index. | |
635 | // absId = fGeomPtr->GetAbsCellIdFromCellIndexes(nSupMod2, irow, icol); | |
636 | // | |
637 | // //Get the position of this tower. | |
638 | // | |
639 | // //Calculate the distance in global coordinates | |
640 | // fGeomPtr->GetGlobal(absId,cellpos); | |
641 | // //Calculate distance between this tower and cluster, set if it is smaller than previous. | |
642 | // dR = cellpos-fGlobPos; | |
643 | // | |
644 | // dist = dR.Mag(); | |
645 | // if(dist < minDist) minDist = dist; | |
25bb3dcb | 646 | } |
647 | } | |
648 | ||
649 | }// shared cluster in 2 SuperModules | |
2ebdefe6 | 650 | |
40164976 | 651 | fDistToBadTower = minDist; |
25bb3dcb | 652 | //printf("AliEMCALRecPoint::EvalDistanceToBadChannel() - Distance to Bad is %f cm, shared cluster? %d \n",fDistToBadTower,fSharedCluster); |
40164976 | 653 | } |
654 | ||
655 | ||
ab48128d | 656 | //____________________________________________________________________________ |
70a93198 | 657 | void AliEMCALRecPoint::EvalLocalPosition(Float_t logWeight, TClonesArray * digits) |
88cb7938 | 658 | { |
25bb3dcb | 659 | // Calculates the center of gravity in the local EMCAL-module coordinates |
660 | // Info("Print", " logWeight %f : cluster energy %f ", logWeight, fAmp); // for testing | |
661 | ||
53e430a3 | 662 | AliEMCALDigit * digit=0; |
25bb3dcb | 663 | Int_t i=0, nstat=0; |
664 | ||
665 | static Double_t dist = TmaxInCm(Double_t(fAmp)); | |
666 | //Int_t idMax = GetAbsIdMaxDigit();// idMax is not used at all in RelPosCellInSModule, why use it? | |
667 | ||
668 | Double_t clXYZ[3]={0.,0.,0.}, clRmsXYZ[3]={0.,0.,0.}, xyzi[3], wtot=0., w=0.; | |
669 | ||
670 | //printf(" dist : %f e : %f \n", dist, fAmp); | |
671 | for(Int_t iDigit=0; iDigit<fMulDigit; iDigit++) { | |
672 | digit = dynamic_cast<AliEMCALDigit *>(digits->At(fDigitsList[iDigit])) ; | |
673 | ||
2ebdefe6 | 674 | if(!digit) { |
675 | AliError("No Digit!!"); | |
676 | continue; | |
677 | } | |
678 | ||
25bb3dcb | 679 | //fGeomPtr->RelPosCellInSModule(digit->GetId(), idMax, dist, xyzi[0], xyzi[1], xyzi[2]); |
680 | fGeomPtr->RelPosCellInSModule(digit->GetId(), dist, xyzi[0], xyzi[1], xyzi[2]); | |
681 | ||
682 | //Temporal patch, due to mapping problem, need to swap "y" in one of the 2 SM, although no effect in position calculation. GCB 05/2010 | |
683 | if(fSharedCluster && fSuperModuleNumber != fGeomPtr->GetSuperModuleNumber(digit->GetId())) xyzi[1]*=-1; | |
684 | ||
685 | //printf("EvalLocalPosition Cell: Id %i, SM %i : dist %f Local x,y,z %f %f %f \n", | |
686 | // digit->GetId(), fGeomPtr->GetSuperModuleNumber(digit->GetId()), dist, xyzi[0], xyzi[1], xyzi[2]); | |
687 | ||
688 | if(logWeight > 0.0) w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp )); | |
689 | else w = fEnergyList[iDigit]; // just energy | |
690 | ||
691 | if(w>0.0) { | |
692 | wtot += w ; | |
693 | nstat++; | |
694 | for(i=0; i<3; i++ ) { | |
695 | clXYZ[i] += (w*xyzi[i]); | |
696 | clRmsXYZ[i] += (w*xyzi[i]*xyzi[i]); | |
697 | } | |
698 | } | |
699 | } | |
700 | // cout << " wtot " << wtot << endl; | |
701 | if ( wtot > 0 ) { | |
702 | // xRMS = TMath::Sqrt(x2m - xMean*xMean); | |
703 | for(i=0; i<3; i++ ) { | |
704 | clXYZ[i] /= wtot; | |
705 | if(nstat>1) { | |
706 | clRmsXYZ[i] /= (wtot*wtot); | |
707 | clRmsXYZ[i] = clRmsXYZ[i] - clXYZ[i]*clXYZ[i]; | |
708 | if(clRmsXYZ[i] > 0.0) { | |
709 | clRmsXYZ[i] = TMath::Sqrt(clRmsXYZ[i]); | |
710 | } else clRmsXYZ[i] = 0; | |
711 | } else clRmsXYZ[i] = 0; | |
712 | } | |
713 | } else { | |
714 | for(i=0; i<3; i++ ) { | |
715 | clXYZ[i] = clRmsXYZ[i] = -1.; | |
716 | } | |
717 | } | |
718 | // clRmsXYZ[i] ?? | |
719 | ||
720 | // // Cluster of one single digit, smear the position to avoid discrete position | |
721 | // // smear x and z with +- 3 cm to uniform (avoid discrete effects). Tower size is approx 6 cm. | |
722 | // // Rndm generates a number in ]0,1] | |
723 | // if (fMulDigit==1) { | |
724 | // clXYZ[0] += fGeomPtr->GetPhiTileSize()*(0.5 - gRandom->Rndm()); | |
725 | // clXYZ[2] += fGeomPtr->GetEtaTileSize()*(0.5 - gRandom->Rndm()); | |
726 | // } | |
727 | ||
728 | //Set position in local vector | |
729 | fLocPos.SetX(clXYZ[0]); | |
730 | fLocPos.SetY(clXYZ[1]); | |
731 | fLocPos.SetZ(clXYZ[2]); | |
732 | ||
733 | if (gDebug==2) | |
734 | printf("EvalLocalPosition Cluster: Local (x,y,z) = (%f,%f,%f) \n", fLocPos.X(), fLocPos.Y(), fLocPos.Z()) ; | |
735 | ||
736 | } | |
737 | ||
738 | ||
739 | //____________________________________________________________________________ | |
740 | void AliEMCALRecPoint::EvalGlobalPosition(Float_t logWeight, TClonesArray * digits) | |
741 | { | |
742 | // Calculates the center of gravity in the global ALICE coordinates | |
e52475ed | 743 | // Info("Print", " logWeight %f : cluster energy %f ", logWeight, fAmp); // for testing |
70a93198 | 744 | |
53e430a3 | 745 | AliEMCALDigit * digit=0; |
25bb3dcb | 746 | Int_t i=0, nstat=0; |
747 | ||
748 | static Double_t dist = TmaxInCm(Double_t(fAmp)); | |
749 | //Int_t idMax = GetAbsIdMaxDigit();// idMax is not used at all in RelPosCellInSModule, why use it? | |
750 | ||
751 | Double_t clXYZ[3]={0.,0.,0.}, clRmsXYZ[3]={0.,0.,0.}, lxyzi[3], xyzi[3], wtot=0., w=0.; | |
70a93198 | 752 | |
1ae500a2 | 753 | //printf(" dist : %f e : %f \n", dist, fAmp); |
e52475ed | 754 | for(Int_t iDigit=0; iDigit<fMulDigit; iDigit++) { |
70a93198 | 755 | digit = dynamic_cast<AliEMCALDigit *>(digits->At(fDigitsList[iDigit])) ; |
e52475ed | 756 | |
2ebdefe6 | 757 | if(!digit) { |
758 | AliError("No Digit!!"); | |
759 | continue; | |
760 | } | |
761 | ||
25bb3dcb | 762 | //Get the local coordinates of the cell |
763 | //fGeomPtr->RelPosCellInSModule(digit->GetId(), idMax, dist, lxyzi[0], lxyzi[1], lxyzi[2]); | |
764 | fGeomPtr->RelPosCellInSModule(digit->GetId(), dist, lxyzi[0], lxyzi[1], lxyzi[2]); | |
765 | ||
766 | //Now get the global coordinate | |
767 | fGeomPtr->GetGlobal(lxyzi,xyzi, fGeomPtr->GetSuperModuleNumber(digit->GetId())); | |
768 | //TVector3 pos(xyzi[0], xyzi[1], xyzi[2]); | |
769 | //printf("EvalGlobalPosition Cell: Id %i, SM %i : dist %f Local (x,y,z) = (%f %f %f), eta %f, phi%f \n", | |
770 | // digit->GetId(), fGeomPtr->GetSuperModuleNumber(digit->GetId()),dist, xyzi[0], xyzi[1], xyzi[2],pos.Eta(),pos.Phi()*TMath::RadToDeg()); | |
771 | ||
af5bdd85 | 772 | if(logWeight > 0.0) w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp )); |
773 | else w = fEnergyList[iDigit]; // just energy | |
ab48128d | 774 | |
e52475ed | 775 | if(w>0.0) { |
776 | wtot += w ; | |
777 | nstat++; | |
778 | for(i=0; i<3; i++ ) { | |
779 | clXYZ[i] += (w*xyzi[i]); | |
780 | clRmsXYZ[i] += (w*xyzi[i]*xyzi[i]); | |
781 | } | |
782 | } | |
783 | } | |
784 | // cout << " wtot " << wtot << endl; | |
70a93198 | 785 | if ( wtot > 0 ) { |
e52475ed | 786 | // xRMS = TMath::Sqrt(x2m - xMean*xMean); |
787 | for(i=0; i<3; i++ ) { | |
788 | clXYZ[i] /= wtot; | |
789 | if(nstat>1) { | |
790 | clRmsXYZ[i] /= (wtot*wtot); | |
791 | clRmsXYZ[i] = clRmsXYZ[i] - clXYZ[i]*clXYZ[i]; | |
792 | if(clRmsXYZ[i] > 0.0) { | |
793 | clRmsXYZ[i] = TMath::Sqrt(clRmsXYZ[i]); | |
794 | } else clRmsXYZ[i] = 0; | |
795 | } else clRmsXYZ[i] = 0; | |
796 | } | |
70a93198 | 797 | } else { |
e52475ed | 798 | for(i=0; i<3; i++ ) { |
799 | clXYZ[i] = clRmsXYZ[i] = -1.; | |
800 | } | |
70a93198 | 801 | } |
e52475ed | 802 | // clRmsXYZ[i] ?? |
25bb3dcb | 803 | |
804 | // // Cluster of one single digit, smear the position to avoid discrete position | |
805 | // // smear x and z with +- 3 cm to uniform (avoid discrete effects). Tower size is approx 6 cm. | |
806 | // // Rndm generates a number in ]0,1] | |
807 | // if (fMulDigit==1) { | |
808 | // clXYZ[0] += fGeomPtr->GetPhiTileSize()*(0.5 - gRandom->Rndm()); | |
809 | // clXYZ[2] += fGeomPtr->GetEtaTileSize()*(0.5 - gRandom->Rndm()); | |
810 | // } | |
811 | ||
812 | //Set position in global vector | |
813 | fGlobPos.SetX(clXYZ[0]); | |
814 | fGlobPos.SetY(clXYZ[1]); | |
815 | fGlobPos.SetZ(clXYZ[2]); | |
816 | ||
817 | if (gDebug==2) | |
818 | printf("EvalGlobalPosition Cluster: (x ,y ,z) = (%f,%f,%f), eta %f,phi %f\n", | |
819 | fGlobPos.X(), fGlobPos.Y(), fGlobPos.Z(),fGlobPos.Eta(),fGlobPos.Phi()*TMath::RadToDeg()) ; | |
ab48128d | 820 | } |
821 | ||
1ae500a2 | 822 | //____________________________________________________________________________ |
823 | void AliEMCALRecPoint::EvalLocalPositionFit(Double_t deff, Double_t logWeight, | |
824 | Double_t phiSlope, TClonesArray * digits) | |
825 | { | |
826 | // Aug 14-16, 2007 - for fit | |
827 | // Aug 31 - should be static ?? | |
53e430a3 | 828 | static Double_t ycorr=0; |
829 | static AliEMCALDigit *digit=0; | |
25bb3dcb | 830 | Int_t i=0, nstat=0; |
1ae500a2 | 831 | Double_t clXYZ[3]={0.,0.,0.}, clRmsXYZ[3]={0.,0.,0.}, xyzi[3], wtot=0., w=0.; |
832 | ||
25bb3dcb | 833 | static Double_t dist = TmaxInCm(Double_t(fAmp)); |
834 | //Int_t idMax = GetAbsIdMaxDigit();// idMax is not used at all in RelPosCellInSModule, why use it? | |
835 | ||
1ae500a2 | 836 | for(Int_t iDigit=0; iDigit<digits->GetEntries(); iDigit++) { |
837 | digit = dynamic_cast<AliEMCALDigit *>(digits->At(fDigitsList[iDigit])) ; | |
25bb3dcb | 838 | |
1ae500a2 | 839 | dist = deff; |
25bb3dcb | 840 | //fGeomPtr->RelPosCellInSModule(digit->GetId(), idMax, dist, xyzi[0], xyzi[1], xyzi[2]); |
841 | fGeomPtr->RelPosCellInSModule(digit->GetId(), dist, xyzi[0], xyzi[1], xyzi[2]); | |
842 | ||
1ae500a2 | 843 | if(logWeight > 0.0) w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp )); |
844 | else w = fEnergyList[iDigit]; // just energy | |
25bb3dcb | 845 | |
1ae500a2 | 846 | if(w>0.0) { |
847 | wtot += w ; | |
848 | nstat++; | |
849 | for(i=0; i<3; i++ ) { | |
850 | clXYZ[i] += (w*xyzi[i]); | |
851 | clRmsXYZ[i] += (w*xyzi[i]*xyzi[i]); | |
852 | } | |
853 | } | |
854 | } | |
855 | // cout << " wtot " << wtot << endl; | |
856 | if ( wtot > 0 ) { | |
857 | // xRMS = TMath::Sqrt(x2m - xMean*xMean); | |
858 | for(i=0; i<3; i++ ) { | |
859 | clXYZ[i] /= wtot; | |
860 | if(nstat>1) { | |
861 | clRmsXYZ[i] /= (wtot*wtot); | |
862 | clRmsXYZ[i] = clRmsXYZ[i] - clXYZ[i]*clXYZ[i]; | |
863 | if(clRmsXYZ[i] > 0.0) { | |
864 | clRmsXYZ[i] = TMath::Sqrt(clRmsXYZ[i]); | |
865 | } else clRmsXYZ[i] = 0; | |
866 | } else clRmsXYZ[i] = 0; | |
867 | } | |
868 | } else { | |
869 | for(i=0; i<3; i++ ) { | |
870 | clXYZ[i] = clRmsXYZ[i] = -1.; | |
871 | } | |
872 | } | |
873 | // clRmsXYZ[i] ?? | |
874 | if(phiSlope != 0.0 && logWeight > 0.0 && wtot) { | |
875 | // Correction in phi direction (y - coords here); Aug 16; | |
876 | // May be put to global level or seperate method | |
877 | ycorr = clXYZ[1] * (1. + phiSlope); | |
878 | //printf(" y %f : ycorr %f : slope %f \n", clXYZ[1], ycorr, phiSlope); | |
879 | clXYZ[1] = ycorr; | |
880 | } | |
25bb3dcb | 881 | |
1ae500a2 | 882 | fLocPos.SetX(clXYZ[0]); |
883 | fLocPos.SetY(clXYZ[1]); | |
884 | fLocPos.SetZ(clXYZ[2]); | |
885 | ||
886 | // if (gDebug==2) | |
887 | // printf("EvalLocalPosition: eta,phi,r = %f,%f,%f", fLocPos.X(), fLocPos.Y(), fLocPos.Z()) ; | |
1ae500a2 | 888 | } |
889 | ||
9aa6a5f6 | 890 | //_____________________________________________________________________________ |
1ae500a2 | 891 | Bool_t AliEMCALRecPoint::EvalLocalPosition2(TClonesArray * digits, TArrayD &ed) |
892 | { | |
893 | // Evaluated local position of rec.point using digits | |
894 | // and parametrisation of w0 and deff | |
895 | //printf(" <I> AliEMCALRecPoint::EvalLocalPosition2() \n"); | |
896 | return AliEMCALRecPoint::EvalLocalPositionFromDigits(digits, ed, fLocPos); | |
897 | } | |
898 | ||
9aa6a5f6 | 899 | //_____________________________________________________________________________ |
1ae500a2 | 900 | Bool_t AliEMCALRecPoint::EvalLocalPositionFromDigits(TClonesArray *digits, TArrayD &ed, TVector3 &locPos) |
901 | { | |
902 | // Used when digits should be recalibrated | |
53e430a3 | 903 | static Double_t deff=0, w0=0, esum=0; |
904 | static Int_t iDigit=0; | |
9aa6a5f6 | 905 | // static AliEMCALDigit *digit; |
1ae500a2 | 906 | |
907 | if(ed.GetSize() && (digits->GetEntries()!=ed.GetSize())) return kFALSE; | |
908 | ||
909 | // Calculate sum energy of digits | |
910 | esum = 0.0; | |
911 | for(iDigit=0; iDigit<ed.GetSize(); iDigit++) esum += ed[iDigit]; | |
912 | ||
913 | GetDeffW0(esum, deff, w0); | |
914 | ||
915 | return EvalLocalPositionFromDigits(esum, deff, w0, digits, ed, locPos); | |
916 | } | |
917 | ||
9aa6a5f6 | 918 | //_____________________________________________________________________________ |
919 | Bool_t AliEMCALRecPoint::EvalLocalPositionFromDigits(const Double_t esum, const Double_t deff, const Double_t w0, TClonesArray *digits, TArrayD &ed, TVector3 &locPos) | |
1ae500a2 | 920 | { |
40164976 | 921 | //Evaluate position of digits in supermodule. |
53e430a3 | 922 | static AliEMCALDigit *digit=0; |
1ae500a2 | 923 | |
25bb3dcb | 924 | Int_t i=0, nstat=0; |
1ae500a2 | 925 | Double_t clXYZ[3]={0.,0.,0.}, xyzi[3], wtot=0., w=0.; |
25bb3dcb | 926 | //Int_t idMax = GetAbsIdMaxDigit();// idMax is not used at all in RelPosCellInSModule, why use it? |
927 | ||
9aa6a5f6 | 928 | // Get pointer to EMCAL geometry |
929 | // (can't use fGeomPtr in static method) | |
930 | AliEMCALGeometry* geo = AliEMCALGeometry::GetInstance(); | |
931 | ||
1ae500a2 | 932 | for(Int_t iDigit=0; iDigit<digits->GetEntries(); iDigit++) { |
933 | digit = dynamic_cast<AliEMCALDigit *>(digits->At(iDigit)); | |
934 | ||
25bb3dcb | 935 | //geo->RelPosCellInSModule(digit->GetId(), idMax, deff, xyzi[0], xyzi[1], xyzi[2]); |
936 | geo->RelPosCellInSModule(digit->GetId(), deff, xyzi[0], xyzi[1], xyzi[2]); | |
1ae500a2 | 937 | |
938 | if(w0 > 0.0) w = TMath::Max( 0., w0 + TMath::Log(ed[iDigit] / esum)); | |
939 | else w = ed[iDigit]; // just energy | |
940 | ||
941 | if(w>0.0) { | |
942 | wtot += w ; | |
943 | nstat++; | |
944 | for(i=0; i<3; i++ ) { | |
945 | clXYZ[i] += (w*xyzi[i]); | |
946 | } | |
947 | } | |
948 | } | |
949 | // cout << " wtot " << wtot << endl; | |
950 | if (wtot > 0) { | |
951 | for(i=0; i<3; i++ ) { | |
952 | clXYZ[i] /= wtot; | |
953 | } | |
954 | locPos.SetX(clXYZ[0]); | |
955 | locPos.SetY(clXYZ[1]); | |
956 | locPos.SetZ(clXYZ[2]); | |
957 | return kTRUE; | |
958 | } else { | |
959 | return kFALSE; | |
960 | } | |
961 | ||
962 | } | |
963 | ||
9aa6a5f6 | 964 | //_____________________________________________________________________________ |
1ae500a2 | 965 | void AliEMCALRecPoint::GetDeffW0(const Double_t esum , Double_t &deff, Double_t &w0) |
966 | { | |
967 | // | |
968 | // Aug 31, 2001 | |
969 | // Applied for simulation data with threshold 3 adc | |
970 | // Calculate efective distance (deff) and weigh parameter (w0) | |
971 | // for coordinate calculation; 0.5 GeV < esum <100 GeV. | |
972 | // Look to: http://rhic.physics.wayne.edu/~pavlinov/ALICE/SHISHKEBAB/RES/CALIB/GEOMCORR/deffandW0VaEgamma_2.gif | |
973 | // | |
974 | static Double_t e=0.0; | |
37890aaf | 975 | const Double_t kdp0=9.25147, kdp1=1.16700; // Hard coded now |
976 | const Double_t kwp0=4.83713, kwp1=-2.77970e-01, kwp2 = 4.41116; | |
1ae500a2 | 977 | |
978 | // No extrapolation here | |
979 | e = esum<0.5?0.5:esum; | |
980 | e = e>100.?100.:e; | |
981 | ||
37890aaf | 982 | deff = kdp0 + kdp1*TMath::Log(e); |
983 | w0 = kwp0 / (1. + TMath::Exp(kwp1*(e+kwp2))); | |
1ae500a2 | 984 | //printf("<I> AliEMCALRecPoint::GetDeffW0 esum %5.2f : deff %5.2f : w0 %5.2f \n", esum, deff, w0); |
985 | } | |
e52475ed | 986 | |
70a93198 | 987 | //______________________________________________________________________________ |
988 | void AliEMCALRecPoint::EvalCoreEnergy(Float_t logWeight, TClonesArray * digits) | |
989 | { | |
990 | // This function calculates energy in the core, | |
4635df1f | 991 | // i.e. within a radius rad = fCoreEnergy around the center. Beyond this radius |
70a93198 | 992 | // in accordance with shower profile the energy deposition |
993 | // should be less than 2% | |
1d46d1f6 | 994 | // Unfinished - Nov 15,2006 |
995 | // Distance is calculate in (phi,eta) units | |
70a93198 | 996 | |
53e430a3 | 997 | AliEMCALDigit * digit = 0 ; |
5dee926e | 998 | |
53e430a3 | 999 | Int_t iDigit=0; |
70a93198 | 1000 | |
e52475ed | 1001 | if (!fLocPos.Mag()) { |
70a93198 | 1002 | EvalLocalPosition(logWeight, digits); |
1003 | } | |
1004 | ||
1d46d1f6 | 1005 | Double_t phiPoint = fLocPos.Phi(), etaPoint = fLocPos.Eta(); |
1006 | Double_t eta, phi, distance; | |
70a93198 | 1007 | for(iDigit=0; iDigit < fMulDigit; iDigit++) { |
1008 | digit = (AliEMCALDigit *) ( digits->At(fDigitsList[iDigit]) ) ; | |
4635df1f | 1009 | |
1d46d1f6 | 1010 | eta = phi = 0.0; |
1011 | fGeomPtr->EtaPhiFromIndex(digit->GetId(),eta, phi) ; | |
1012 | phi = phi * TMath::DegToRad(); | |
70a93198 | 1013 | |
1d46d1f6 | 1014 | distance = TMath::Sqrt((eta-etaPoint)*(eta-etaPoint)+(phi-phiPoint)*(phi-phiPoint)); |
70a93198 | 1015 | if(distance < fCoreRadius) |
1016 | fCoreEnergy += fEnergyList[iDigit] ; | |
1017 | } | |
1018 | ||
1019 | } | |
ab48128d | 1020 | //____________________________________________________________________________ |
70a93198 | 1021 | void AliEMCALRecPoint::EvalElipsAxis(Float_t logWeight,TClonesArray * digits) |
ab48128d | 1022 | { |
70a93198 | 1023 | // Calculates the axis of the shower ellipsoid in eta and phi |
1d46d1f6 | 1024 | // in cell units |
ab48128d | 1025 | |
1d46d1f6 | 1026 | static TString gn(fGeomPtr->GetName()); |
1027 | ||
1028 | Double_t wtot = 0.; | |
70a93198 | 1029 | Double_t x = 0.; |
1030 | Double_t z = 0.; | |
1031 | Double_t dxx = 0.; | |
1032 | Double_t dzz = 0.; | |
1033 | Double_t dxz = 0.; | |
ab48128d | 1034 | |
1d46d1f6 | 1035 | AliEMCALDigit * digit = 0; |
25bb3dcb | 1036 | |
53e430a3 | 1037 | Double_t etai =0, phii=0, w=0; |
2bb3725c | 1038 | int nSupMod=0, nModule=0, nIphi=0, nIeta=0; |
1d46d1f6 | 1039 | int iphi=0, ieta=0; |
1040 | for(Int_t iDigit=0; iDigit<fMulDigit; iDigit++) { | |
70a93198 | 1041 | digit = (AliEMCALDigit *) digits->At(fDigitsList[iDigit]) ; |
1d46d1f6 | 1042 | etai = phii = 0.; |
1d46d1f6 | 1043 | // Nov 15,2006 - use cell numbers as coordinates |
1044 | // Copied for shish-kebab geometry, ieta,iphi is cast as double as eta,phi | |
1045 | // We can use the eta,phi(or coordinates) of cell | |
dc77cc84 | 1046 | nSupMod = nModule = nIphi = nIeta = iphi = ieta = 0; |
1d46d1f6 | 1047 | |
dc77cc84 | 1048 | fGeomPtr->GetCellIndex(digit->GetId(), nSupMod,nModule,nIphi,nIeta); |
1049 | fGeomPtr->GetCellPhiEtaIndexInSModule(nSupMod,nModule,nIphi,nIeta, iphi,ieta); | |
25bb3dcb | 1050 | |
1051 | // In case of a shared cluster, index of SM in C side, columns start at 48 and ends at 48*2 | |
1052 | // C Side impair SM, nSupMod%2=1; A side pair SM, nSupMod%2=0 | |
1053 | if(fSharedCluster && nSupMod%2) ieta+=AliEMCALGeoParams::fgkEMCALCols; | |
1054 | ||
dc77cc84 | 1055 | etai=(Double_t)ieta; |
1056 | phii=(Double_t)iphi; | |
25bb3dcb | 1057 | |
1d46d1f6 | 1058 | w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ; |
1059 | // fAmp summed amplitude of digits, i.e. energy of recpoint | |
1060 | // Gives smaller value of lambda than log weight | |
1061 | // w = fEnergyList[iDigit] / fAmp; // Nov 16, 2006 - try just energy | |
ff1e7e2f | 1062 | |
70a93198 | 1063 | dxx += w * etai * etai ; |
1064 | x += w * etai ; | |
1065 | dzz += w * phii * phii ; | |
1066 | z += w * phii ; | |
1963b290 | 1067 | |
ff1e7e2f | 1068 | dxz += w * etai * phii ; |
1963b290 | 1069 | |
70a93198 | 1070 | wtot += w ; |
1071 | } | |
ff1e7e2f | 1072 | |
70a93198 | 1073 | if ( wtot > 0 ) { |
1074 | dxx /= wtot ; | |
1075 | x /= wtot ; | |
1076 | dxx -= x * x ; | |
1077 | dzz /= wtot ; | |
1078 | z /= wtot ; | |
1079 | dzz -= z * z ; | |
1080 | dxz /= wtot ; | |
1081 | dxz -= x * z ; | |
ab48128d | 1082 | |
70a93198 | 1083 | fLambda[0] = 0.5 * (dxx + dzz) + TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ; |
1084 | if(fLambda[0] > 0) | |
1085 | fLambda[0] = TMath::Sqrt(fLambda[0]) ; | |
1086 | else | |
1087 | fLambda[0] = 0; | |
1088 | ||
1089 | fLambda[1] = 0.5 * (dxx + dzz) - TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ; | |
ff1e7e2f | 1090 | |
70a93198 | 1091 | if(fLambda[1] > 0) //To avoid exception if numerical errors lead to negative lambda. |
1092 | fLambda[1] = TMath::Sqrt(fLambda[1]) ; | |
1093 | else | |
1094 | fLambda[1]= 0. ; | |
1095 | } else { | |
1096 | fLambda[0]= 0. ; | |
1097 | fLambda[1]= 0. ; | |
ab48128d | 1098 | } |
ff1e7e2f | 1099 | |
25bb3dcb | 1100 | //printf("AliEMCALRecPoint::EvalElipsAxis() lambdas = %f,%f \n", fLambda[0],fLambda[1]) ; |
ff1e7e2f | 1101 | |
ab48128d | 1102 | } |
1103 | ||
1104 | //______________________________________________________________________________ | |
1105 | void AliEMCALRecPoint::EvalPrimaries(TClonesArray * digits) | |
1106 | { | |
af5bdd85 | 1107 | // Constructs the list of primary particles (tracks) which |
1108 | // have contributed to this RecPoint and calculate deposited energy | |
1109 | // for each track | |
ab48128d | 1110 | |
53e430a3 | 1111 | AliEMCALDigit * digit =0; |
af5bdd85 | 1112 | Int_t * primArray = new Int_t[fMaxTrack] ; |
1113 | Float_t * dEPrimArray = new Float_t[fMaxTrack] ; | |
2ebdefe6 | 1114 | |
ab48128d | 1115 | Int_t index ; |
1116 | for ( index = 0 ; index < GetDigitsMultiplicity() ; index++ ) { // all digits | |
1117 | digit = dynamic_cast<AliEMCALDigit *>(digits->At( fDigitsList[index] )) ; | |
2ebdefe6 | 1118 | if(!digit) { |
1119 | AliError("No Digit!!"); | |
1120 | continue; | |
1121 | } | |
1122 | ||
ab48128d | 1123 | Int_t nprimaries = digit->GetNprimary() ; |
5c0368b8 | 1124 | if ( nprimaries == 0 ) continue ; |
ab48128d | 1125 | Int_t jndex ; |
1126 | for ( jndex = 0 ; jndex < nprimaries ; jndex++ ) { // all primaries in digit | |
1127 | if ( fMulTrack > fMaxTrack ) { | |
2ebdefe6 | 1128 | fMulTrack = fMaxTrack ; |
1129 | Error("EvalPrimaries", "increase fMaxTrack ") ; | |
1130 | break ; | |
ab48128d | 1131 | } |
af5bdd85 | 1132 | Int_t newPrimary = digit->GetPrimary(jndex+1); |
1133 | Float_t dEPrimary = digit->GetDEPrimary(jndex+1); | |
ab48128d | 1134 | Int_t kndex ; |
1135 | Bool_t already = kFALSE ; | |
1136 | for ( kndex = 0 ; kndex < fMulTrack ; kndex++ ) { //check if not already stored | |
2ebdefe6 | 1137 | if ( newPrimary == primArray[kndex] ){ |
1138 | already = kTRUE ; | |
1139 | dEPrimArray[kndex] += dEPrimary; | |
1140 | break ; | |
1141 | } | |
ab48128d | 1142 | } // end of check |
5c0368b8 | 1143 | if ( !already && (fMulTrack < fMaxTrack)) { // store it |
2ebdefe6 | 1144 | primArray[fMulTrack] = newPrimary ; |
1145 | dEPrimArray[fMulTrack] = dEPrimary ; | |
1146 | fMulTrack++ ; | |
ab48128d | 1147 | } // store it |
1148 | } // all primaries in digit | |
ab48128d | 1149 | } // all digits |
2ebdefe6 | 1150 | |
af5bdd85 | 1151 | Int_t *sortIdx = new Int_t[fMulTrack]; |
1152 | TMath::Sort(fMulTrack,dEPrimArray,sortIdx); | |
1153 | for(index = 0; index < fMulTrack; index++) { | |
1154 | fTracksList[index] = primArray[sortIdx[index]] ; | |
1155 | fDETracksList[index] = dEPrimArray[sortIdx[index]] ; | |
1156 | } | |
1157 | delete [] sortIdx; | |
1158 | delete [] primArray ; | |
1159 | delete [] dEPrimArray ; | |
2ebdefe6 | 1160 | |
ab48128d | 1161 | } |
7ee5c5be | 1162 | |
87cdc3be | 1163 | //______________________________________________________________________________ |
1164 | void AliEMCALRecPoint::EvalParents(TClonesArray * digits) | |
1165 | { | |
1166 | // Constructs the list of parent particles (tracks) which have contributed to this RecPoint | |
2ebdefe6 | 1167 | |
53e430a3 | 1168 | AliEMCALDigit * digit=0 ; |
af5bdd85 | 1169 | Int_t * parentArray = new Int_t[fMaxTrack] ; |
1170 | Float_t * dEParentArray = new Float_t[fMaxTrack] ; | |
2ebdefe6 | 1171 | |
87cdc3be | 1172 | Int_t index ; |
1173 | for ( index = 0 ; index < GetDigitsMultiplicity() ; index++ ) { // all digits | |
94478418 | 1174 | if (fDigitsList[index] >= digits->GetEntries() || fDigitsList[index] < 0) |
2ebdefe6 | 1175 | AliError(Form("Trying to get invalid digit %d (idx in WriteRecPoint %d)",fDigitsList[index],index)); |
87cdc3be | 1176 | digit = dynamic_cast<AliEMCALDigit *>(digits->At( fDigitsList[index] )) ; |
2ebdefe6 | 1177 | if(!digit) { |
1178 | AliError("No Digit!!"); | |
1179 | continue; | |
1180 | } | |
1181 | ||
87cdc3be | 1182 | Int_t nparents = digit->GetNiparent() ; |
5c0368b8 | 1183 | if ( nparents == 0 ) continue ; |
2ebdefe6 | 1184 | |
87cdc3be | 1185 | Int_t jndex ; |
1186 | for ( jndex = 0 ; jndex < nparents ; jndex++ ) { // all primaries in digit | |
1187 | if ( fMulParent > fMaxParent ) { | |
2ebdefe6 | 1188 | fMulTrack = - 1 ; |
1189 | Error("EvalParents", "increase fMaxParent") ; | |
1190 | break ; | |
87cdc3be | 1191 | } |
af5bdd85 | 1192 | Int_t newParent = digit->GetIparent(jndex+1) ; |
1193 | Float_t newdEParent = digit->GetDEParent(jndex+1) ; | |
87cdc3be | 1194 | Int_t kndex ; |
1195 | Bool_t already = kFALSE ; | |
f1d429fd | 1196 | for ( kndex = 0 ; kndex < fMulParent ; kndex++ ) { //check if not already stored |
2ebdefe6 | 1197 | if ( newParent == parentArray[kndex] ){ |
1198 | dEParentArray[kndex] += newdEParent; | |
1199 | already = kTRUE ; | |
1200 | break ; | |
1201 | } | |
87cdc3be | 1202 | } // end of check |
94478418 | 1203 | if ( !already && (fMulParent < fMaxParent)) { // store it |
2ebdefe6 | 1204 | parentArray[fMulParent] = newParent ; |
1205 | dEParentArray[fMulParent] = newdEParent ; | |
1206 | fMulParent++ ; | |
87cdc3be | 1207 | } // store it |
1208 | } // all parents in digit | |
87cdc3be | 1209 | } // all digits |
2ebdefe6 | 1210 | |
27e2a47c | 1211 | if (fMulParent>0) { |
af5bdd85 | 1212 | Int_t *sortIdx = new Int_t[fMulParent]; |
1213 | TMath::Sort(fMulParent,dEParentArray,sortIdx); | |
1214 | for(index = 0; index < fMulParent; index++) { | |
1215 | fParentsList[index] = parentArray[sortIdx[index]] ; | |
1216 | fDEParentsList[index] = dEParentArray[sortIdx[index]] ; | |
1217 | } | |
1218 | delete [] sortIdx; | |
27e2a47c | 1219 | } |
2ebdefe6 | 1220 | |
af5bdd85 | 1221 | delete [] parentArray; |
1222 | delete [] dEParentArray; | |
87cdc3be | 1223 | } |
1224 | ||
70a93198 | 1225 | //____________________________________________________________________________ |
1226 | void AliEMCALRecPoint::GetLocalPosition(TVector3 & lpos) const | |
1227 | { | |
9aa6a5f6 | 1228 | // returns the position of the cluster in the local reference system |
1229 | // of the sub-detector | |
70a93198 | 1230 | |
9aa6a5f6 | 1231 | lpos = fLocPos; |
70a93198 | 1232 | } |
1233 | ||
ab48128d | 1234 | //____________________________________________________________________________ |
1235 | void AliEMCALRecPoint::GetGlobalPosition(TVector3 & gpos) const | |
1236 | { | |
1237 | // returns the position of the cluster in the global reference system of ALICE | |
70a93198 | 1238 | // These are now the Cartesian X, Y and Z |
e52475ed | 1239 | // cout<<" geom "<<geom<<endl; |
25bb3dcb | 1240 | // fGeomPtr->GetGlobal(fLocPos, gpos, fSuperModuleNumber); |
1241 | gpos = fGlobPos; | |
1242 | ||
9aa6a5f6 | 1243 | } |
1244 | ||
1245 | //____________________________________________________________________________ | |
7cfcebd3 | 1246 | //void AliEMCALRecPoint::GetGlobalPosition(TVector3 & gpos, TMatrixF & gmat) const |
1247 | //{ | |
1248 | // // returns the position of the cluster in the global reference system of ALICE | |
1249 | // // These are now the Cartesian X, Y and Z | |
1250 | // // cout<<" geom "<<geom<<endl; | |
1251 | // | |
1252 | // //To be implemented | |
1253 | // fGeomPtr->GetGlobalEMCAL(this, gpos, gmat); | |
1254 | // | |
1255 | //} | |
9aa6a5f6 | 1256 | |
1257 | //_____________________________________________________________________________ | |
1258 | void AliEMCALRecPoint::EvalLocal2TrackingCSTransform() | |
1259 | { | |
1260 | //Evaluates local to "tracking" c.s. transformation (B.P.). | |
1261 | //All evaluations should be completed before calling for this | |
1262 | //function. | |
1263 | //See ALICE PPR Chapter 5 p.18 for "tracking" c.s. definition, | |
1264 | //or just ask Jouri Belikov. :) | |
1265 | ||
1266 | SetVolumeId(AliGeomManager::LayerToVolUID(AliGeomManager::kEMCAL,GetSuperModuleNumber())); | |
1267 | ||
1268 | const TGeoHMatrix* tr2loc = GetTracking2LocalMatrix(); | |
1269 | if(!tr2loc) AliFatal(Form("No Tracking2LocalMatrix found.")); | |
1270 | ||
1271 | Double_t lxyz[3] = {fLocPos.X(),fLocPos.Y(),fLocPos.Z()}; | |
1272 | Double_t txyz[3] = {0,0,0}; | |
1273 | ||
1274 | tr2loc->MasterToLocal(lxyz,txyz); | |
1275 | SetX(txyz[0]); SetY(txyz[1]); SetZ(txyz[2]); | |
1276 | ||
1277 | if(AliLog::GetGlobalDebugLevel()>0) { | |
7cfcebd3 | 1278 | TVector3 gpos; //TMatrixF gmat; |
1279 | //GetGlobalPosition(gpos,gmat); //Not doing anythin special, replace by next line. | |
1280 | fGeomPtr->GetGlobal(fLocPos, gpos, GetSuperModuleNumber()); | |
1281 | ||
9aa6a5f6 | 1282 | Float_t gxyz[3]; |
1283 | GetGlobalXYZ(gxyz); | |
1284 | AliInfo(Form("lCS-->(%.3f,%.3f,%.3f), tCS-->(%.3f,%.3f,%.3f), gCS-->(%.3f,%.3f,%.3f), gCScalc-\ | |
1285 | ->(%.3f,%.3f,%.3f), supermodule %d", | |
1286 | fLocPos.X(),fLocPos.Y(),fLocPos.Z(), | |
1287 | GetX(),GetY(),GetZ(), | |
1288 | gpos.X(),gpos.Y(),gpos.Z(), | |
1289 | gxyz[0],gxyz[1],gxyz[2],GetSuperModuleNumber())); | |
1290 | } | |
1291 | ||
70a93198 | 1292 | } |
1293 | ||
1294 | //____________________________________________________________________________ | |
1295 | Float_t AliEMCALRecPoint::GetMaximalEnergy(void) const | |
1296 | { | |
1297 | // Finds the maximum energy in the cluster | |
ab48128d | 1298 | |
70a93198 | 1299 | Float_t menergy = 0. ; |
1300 | ||
1301 | Int_t iDigit; | |
70a93198 | 1302 | for(iDigit=0; iDigit<fMulDigit; iDigit++) { |
1303 | ||
1304 | if(fEnergyList[iDigit] > menergy) | |
1305 | menergy = fEnergyList[iDigit] ; | |
1306 | } | |
1307 | return menergy ; | |
ab48128d | 1308 | } |
1309 | ||
25bb3dcb | 1310 | //____________________________________________________________________________ |
1311 | Int_t AliEMCALRecPoint::GetMaximalEnergyIndex(void) const | |
1312 | { | |
1313 | // Finds the maximum energy in the cluster | |
1314 | ||
1315 | Float_t menergy = 0. ; | |
44fe3410 | 1316 | Int_t mid = 0 ; |
25bb3dcb | 1317 | Int_t iDigit; |
1318 | ||
1319 | for(iDigit=0; iDigit<fMulDigit; iDigit++) { | |
1320 | ||
1321 | if(fEnergyList[iDigit] > menergy){ | |
1322 | menergy = fEnergyList[iDigit] ; | |
1323 | mid = iDigit ; | |
1324 | } | |
1325 | }//loop on cluster digits | |
1326 | ||
1327 | return mid ; | |
1328 | } | |
1329 | ||
1330 | ||
aad8e277 | 1331 | //____________________________________________________________________________ |
70a93198 | 1332 | Int_t AliEMCALRecPoint::GetMultiplicityAtLevel(Float_t H) const |
aad8e277 | 1333 | { |
70a93198 | 1334 | // Calculates the multiplicity of digits with energy larger than H*energy |
1335 | ||
1336 | Int_t multipl = 0 ; | |
1337 | Int_t iDigit ; | |
1338 | for(iDigit=0; iDigit<fMulDigit; iDigit++) { | |
1339 | ||
1340 | if(fEnergyList[iDigit] > H * fAmp) | |
1341 | multipl++ ; | |
1342 | } | |
1343 | return multipl ; | |
1344 | } | |
1345 | ||
1346 | //____________________________________________________________________________ | |
1347 | Int_t AliEMCALRecPoint::GetNumberOfLocalMax(AliEMCALDigit ** maxAt, Float_t * maxAtEnergy, | |
1348 | Float_t locMaxCut,TClonesArray * digits) const | |
1349 | { | |
1350 | // Calculates the number of local maxima in the cluster using fLocalMaxCut as the minimum | |
1351 | // energy difference between two local maxima | |
1352 | ||
53e430a3 | 1353 | AliEMCALDigit * digit = 0; |
1354 | AliEMCALDigit * digitN = 0; | |
70a93198 | 1355 | |
53e430a3 | 1356 | Int_t iDigitN = 0 ; |
1357 | Int_t iDigit = 0 ; | |
70a93198 | 1358 | |
1359 | for(iDigit = 0; iDigit < fMulDigit; iDigit++) | |
1360 | maxAt[iDigit] = (AliEMCALDigit*) digits->At(fDigitsList[iDigit]) ; | |
1361 | ||
1362 | for(iDigit = 0 ; iDigit < fMulDigit; iDigit++) { | |
1363 | if(maxAt[iDigit]) { | |
1364 | digit = maxAt[iDigit] ; | |
1365 | ||
1366 | for(iDigitN = 0; iDigitN < fMulDigit; iDigitN++) { | |
53e430a3 | 1367 | digitN = (AliEMCALDigit *) digits->At(fDigitsList[iDigitN]) ; |
70a93198 | 1368 | |
1369 | if ( AreNeighbours(digit, digitN) ) { | |
1370 | if (fEnergyList[iDigit] > fEnergyList[iDigitN] ) { | |
1371 | maxAt[iDigitN] = 0 ; | |
1372 | // but may be digit too is not local max ? | |
1373 | if(fEnergyList[iDigit] < fEnergyList[iDigitN] + locMaxCut) | |
1374 | maxAt[iDigit] = 0 ; | |
1375 | } | |
1376 | else { | |
1377 | maxAt[iDigit] = 0 ; | |
1378 | // but may be digitN too is not local max ? | |
1379 | if(fEnergyList[iDigit] > fEnergyList[iDigitN] - locMaxCut) | |
1380 | maxAt[iDigitN] = 0 ; | |
1381 | } | |
1382 | } // if Areneighbours | |
1383 | } // while digitN | |
1384 | } // slot not empty | |
1385 | } // while digit | |
1386 | ||
1387 | iDigitN = 0 ; | |
1388 | for(iDigit = 0; iDigit < fMulDigit; iDigit++) { | |
1389 | if(maxAt[iDigit] ){ | |
1390 | maxAt[iDigitN] = maxAt[iDigit] ; | |
1391 | maxAtEnergy[iDigitN] = fEnergyList[iDigit] ; | |
1392 | iDigitN++ ; | |
1393 | } | |
1394 | } | |
1395 | return iDigitN ; | |
1396 | } | |
4635df1f | 1397 | |
1398 | //____________________________________________________________________________ | |
1399 | Int_t AliEMCALRecPoint::GetPrimaryIndex() const | |
1400 | { | |
1401 | // Get the primary track index in TreeK which deposits the most energy | |
af5bdd85 | 1402 | // in Digits which forms RecPoint. |
4635df1f | 1403 | |
af5bdd85 | 1404 | if (fMulTrack) |
1405 | return fTracksList[0]; | |
1406 | return -12345; | |
4635df1f | 1407 | } |
1408 | ||
70a93198 | 1409 | //____________________________________________________________________________ |
1410 | void AliEMCALRecPoint::EvalTime(TClonesArray * digits){ | |
1411 | // time is set to the time of the digit with the maximum energy | |
1412 | ||
53e430a3 | 1413 | Float_t maxE = 0; |
1414 | Int_t maxAt = 0; | |
70a93198 | 1415 | for(Int_t idig=0; idig < fMulDigit; idig++){ |
1416 | if(fEnergyList[idig] > maxE){ | |
53e430a3 | 1417 | maxE = fEnergyList[idig] ; |
70a93198 | 1418 | maxAt = idig; |
1419 | } | |
1420 | } | |
1421 | fTime = ((AliEMCALDigit*) digits->At(fDigitsList[maxAt]))->GetTime() ; | |
aad8e277 | 1422 | |
aad8e277 | 1423 | } |
ab48128d | 1424 | |
1425 | //______________________________________________________________________________ | |
1426 | void AliEMCALRecPoint::Paint(Option_t *) | |
1427 | { | |
1428 | // Paint this ALiRecPoint as a TMarker with its current attributes | |
1429 | ||
1430 | TVector3 pos(0.,0.,0.) ; | |
1431 | GetLocalPosition(pos) ; | |
1432 | Coord_t x = pos.X() ; | |
1433 | Coord_t y = pos.Z() ; | |
1434 | Color_t markercolor = 1 ; | |
53e430a3 | 1435 | Size_t markersize = 1.; |
ab48128d | 1436 | Style_t markerstyle = 5 ; |
1437 | ||
1438 | if (!gPad->IsBatch()) { | |
1439 | gVirtualX->SetMarkerColor(markercolor) ; | |
1440 | gVirtualX->SetMarkerSize (markersize) ; | |
1441 | gVirtualX->SetMarkerStyle(markerstyle) ; | |
1442 | } | |
1443 | gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ; | |
1444 | gPad->PaintPolyMarker(1,&x,&y,"") ; | |
1445 | } | |
70a93198 | 1446 | |
9aa6a5f6 | 1447 | //_____________________________________________________________________ |
1ae500a2 | 1448 | Double_t AliEMCALRecPoint::TmaxInCm(const Double_t e , const Int_t key) |
1449 | { | |
9aa6a5f6 | 1450 | // e energy in GeV) |
1ae500a2 | 1451 | // key = 0(gamma, default) |
1452 | // != 0(electron) | |
53e430a3 | 1453 | static Double_t ca = 4.82; // shower max parameter - first guess; ca=TMath::Log(1000./8.07) |
1454 | static Double_t x0 = 1.23; // radiation lenght (cm) | |
1455 | static Double_t tmax = 0.; // position of electromagnetic shower max in cm | |
1ae500a2 | 1456 | |
1ae500a2 | 1457 | if(e>0.1) { |
1458 | tmax = TMath::Log(e) + ca; | |
1459 | if (key==0) tmax += 0.5; | |
1460 | else tmax -= 0.5; | |
37890aaf | 1461 | tmax *= x0; // convert to cm |
1ae500a2 | 1462 | } |
1463 | return tmax; | |
1464 | } | |
1465 | ||
70a93198 | 1466 | //______________________________________________________________________________ |
1467 | Float_t AliEMCALRecPoint::EtaToTheta(Float_t arg) const | |
1468 | { | |
1469 | //Converts Theta (Radians) to Eta(Radians) | |
1470 | return (2.*TMath::ATan(TMath::Exp(-arg))); | |
1471 | } | |
1472 | ||
1473 | //______________________________________________________________________________ | |
1474 | Float_t AliEMCALRecPoint::ThetaToEta(Float_t arg) const | |
1475 | { | |
1476 | //Converts Eta (Radians) to Theta(Radians) | |
1477 | return (-1 * TMath::Log(TMath::Tan(0.5 * arg))); | |
1478 | } | |
261b1065 | 1479 | |
1480 | //____________________________________________________________________________ | |
e1a51e6e | 1481 | void AliEMCALRecPoint::Print(Option_t *opt) const |
261b1065 | 1482 | { |
1483 | // Print the list of digits belonging to the cluster | |
e1a51e6e | 1484 | if(strlen(opt)==0) return; |
261b1065 | 1485 | TString message ; |
4800667c | 1486 | message = "AliEMCALRecPoint:\n" ; |
261b1065 | 1487 | message += " digits # = " ; |
1488 | Info("Print", message.Data()) ; | |
1489 | ||
1490 | Int_t iDigit; | |
1491 | for(iDigit=0; iDigit<fMulDigit; iDigit++) | |
1492 | printf(" %d ", fDigitsList[iDigit] ) ; | |
e52475ed | 1493 | printf("\n"); |
1494 | ||
261b1065 | 1495 | Info("Print", " Energies = ") ; |
1496 | for(iDigit=0; iDigit<fMulDigit; iDigit++) | |
1497 | printf(" %f ", fEnergyList[iDigit] ) ; | |
e52475ed | 1498 | printf("\n"); |
1499 | ||
1500 | Info("Print", "\n Abs Ids = ") ; | |
1501 | for(iDigit=0; iDigit<fMulDigit; iDigit++) | |
1502 | printf(" %i ", fAbsIdList[iDigit] ) ; | |
1503 | printf("\n"); | |
1504 | ||
1505 | Info("Print", " Primaries ") ; | |
261b1065 | 1506 | for(iDigit = 0;iDigit < fMulTrack; iDigit++) |
1507 | printf(" %d ", fTracksList[iDigit]) ; | |
e52475ed | 1508 | |
1509 | printf("\n Local x %6.2f y %7.2f z %7.1f \n", fLocPos[0], fLocPos[1], fLocPos[2]); | |
1510 | ||
85c60a8e | 1511 | message = " ClusterType = %d" ; |
1512 | message += " Multiplicity = %d" ; | |
261b1065 | 1513 | message += " Cluster Energy = %f" ; |
1514 | message += " Core energy = %f" ; | |
1515 | message += " Core radius = %f" ; | |
1516 | message += " Number of primaries %d" ; | |
1517 | message += " Stored at position %d" ; | |
85c60a8e | 1518 | Info("Print", message.Data(), fClusterType, fMulDigit, fAmp, fCoreEnergy, fCoreRadius, fMulTrack, GetIndexInList() ) ; |
261b1065 | 1519 | } |
1d46d1f6 | 1520 | |
9aa6a5f6 | 1521 | //___________________________________________________________ |
1d46d1f6 | 1522 | Double_t AliEMCALRecPoint::GetPointEnergy() const |
1523 | { | |
37890aaf | 1524 | //Returns energy .... |
53e430a3 | 1525 | static double e=0.0; |
1d46d1f6 | 1526 | for(int ic=0; ic<GetMultiplicity(); ic++) e += double(fEnergyList[ic]); |
1527 | return e; | |
1528 | } |