]>
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; | |
6ce4e2ed | 179 | fCoreEnergy = rp.fCoreEnergy; |
180 | fDispersion = rp.fDispersion; | |
9aa6a5f6 | 181 | for(Int_t i = 0; i<fMaxDigit; i++) { |
182 | fEnergyList[i] = rp.fEnergyList[i]; | |
6ce4e2ed | 183 | fTimeList[i] = rp.fTimeList[i]; |
184 | fAbsIdList[i] = rp.fAbsIdList[i]; | |
9aa6a5f6 | 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 | //____________________________________________________________________________ | |
6ce4e2ed | 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 ; | |
6ce4e2ed | 225 | Int_t * tempo = new Int_t[fMaxDigit]; |
226 | Float_t * tempoE = new Float_t[fMaxDigit]; | |
227 | Float_t * tempoT = new Float_t[fMaxDigit]; | |
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; | |
6ce4e2ed | 245 | fTimeList = tempoT; |
246 | fAbsIdList = tempoId; | |
70a93198 | 247 | } // if |
248 | ||
249 | fDigitsList[fMulDigit] = digit.GetIndexInList() ; | |
6ce4e2ed | 250 | fEnergyList[fMulDigit] = energy ; |
94478418 | 251 | fTimeList[fMulDigit] = digit.GetTimeR() ; |
e52475ed | 252 | fAbsIdList[fMulDigit] = digit.GetId(); |
70a93198 | 253 | fMulDigit++ ; |
6ce4e2ed | 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 | ||
47583f1b | 274 | Bool_t areNeighbours = kFALSE ; |
275 | Int_t nSupMod=0, nModule=0, nIphi=0, nIeta=0; | |
276 | Int_t nSupMod1=0, nModule1=0, nIphi1=0, nIeta1=0; | |
277 | Int_t relid1[2] , relid2[2] ; // ieta, iphi | |
278 | 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 | //____________________________________________________________________________ |
0d0d6b98 | 444 | void AliEMCALRecPoint::EvalAll(Float_t logWeight,TClonesArray * digits, const Bool_t justClusters) |
70a93198 | 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. | |
6ce4e2ed | 450 | |
25bb3dcb | 451 | fDigitIndMax = GetMaximalEnergyIndex(); |
452 | fSuperModuleNumber = fGeomPtr->GetSuperModuleNumber(GetAbsIdMaxDigit()); | |
453 | ||
454 | //Evaluate global and local position | |
455 | EvalGlobalPosition(logWeight, digits) ; | |
70a93198 | 456 | EvalLocalPosition(logWeight, digits) ; |
25bb3dcb | 457 | |
458 | //Evaluate shower parameters | |
70a93198 | 459 | EvalElipsAxis(logWeight, digits) ; |
460 | EvalDispersion(logWeight, digits) ; | |
25bb3dcb | 461 | |
4635df1f | 462 | //EvalCoreEnergy(logWeight, digits); |
70a93198 | 463 | EvalTime(digits) ; |
87cdc3be | 464 | EvalPrimaries(digits) ; |
465 | EvalParents(digits); | |
40164976 | 466 | |
9aa6a5f6 | 467 | //Called last because it sets the global position of the cluster? |
0d0d6b98 | 468 | //Do not call it when recalculating clusters out of standard reconstruction |
92d9f317 | 469 | if(!justClusters){ |
470 | printf("NOT JUST CLUSTERS\n"); | |
471 | EvalLocal2TrackingCSTransform(); | |
472 | } | |
9aa6a5f6 | 473 | |
70a93198 | 474 | } |
475 | ||
476 | //____________________________________________________________________________ | |
477 | void AliEMCALRecPoint::EvalDispersion(Float_t logWeight, TClonesArray * digits) | |
478 | { | |
479 | // Calculates the dispersion of the shower at the origin of the RecPoint | |
1d46d1f6 | 480 | // in cell units - Nov 16,2006 |
70a93198 | 481 | |
1d46d1f6 | 482 | Double_t d = 0., wtot = 0., w = 0.; |
af5bdd85 | 483 | Int_t iDigit=0, nstat=0; |
53e430a3 | 484 | AliEMCALDigit * digit=0; |
25bb3dcb | 485 | |
1d46d1f6 | 486 | // Calculates the dispersion in cell units |
487 | Double_t etai, phii, etaMean=0.0, phiMean=0.0; | |
2bb3725c | 488 | int nSupMod=0, nModule=0, nIphi=0, nIeta=0; |
1d46d1f6 | 489 | int iphi=0, ieta=0; |
490 | // Calculate mean values | |
70a93198 | 491 | for(iDigit=0; iDigit < fMulDigit; iDigit++) { |
492 | digit = (AliEMCALDigit *) digits->At(fDigitsList[iDigit]) ; | |
1963b290 | 493 | |
1d46d1f6 | 494 | if (fAmp>0 && fEnergyList[iDigit]>0) { |
2bb3725c | 495 | fGeomPtr->GetCellIndex(digit->GetId(), nSupMod,nModule,nIphi,nIeta); |
496 | fGeomPtr->GetCellPhiEtaIndexInSModule(nSupMod,nModule,nIphi,nIeta, iphi,ieta); | |
25bb3dcb | 497 | |
498 | // In case of a shared cluster, index of SM in C side, columns start at 48 and ends at 48*2 | |
499 | // C Side impair SM, nSupMod%2=1; A side pair SM nSupMod%2=0 | |
500 | if(fSharedCluster && nSupMod%2) ieta+=AliEMCALGeoParams::fgkEMCALCols; | |
501 | ||
1d46d1f6 | 502 | etai=(Double_t)ieta; |
503 | phii=(Double_t)iphi; | |
504 | w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ; | |
505 | ||
506 | if(w>0.0) { | |
507 | phiMean += phii*w; | |
508 | etaMean += etai*w; | |
509 | wtot += w; | |
510 | } | |
511 | } | |
512 | } | |
513 | if (wtot>0) { | |
514 | phiMean /= wtot ; | |
515 | etaMean /= wtot ; | |
516 | } else AliError(Form("Wrong weight %f\n", wtot)); | |
70a93198 | 517 | |
1d46d1f6 | 518 | // Calculate dispersion |
519 | for(iDigit=0; iDigit < fMulDigit; iDigit++) { | |
520 | digit = (AliEMCALDigit *) digits->At(fDigitsList[iDigit]) ; | |
521 | ||
522 | if (fAmp>0 && fEnergyList[iDigit]>0) { | |
2bb3725c | 523 | fGeomPtr->GetCellIndex(digit->GetId(), nSupMod,nModule,nIphi,nIeta); |
524 | fGeomPtr->GetCellPhiEtaIndexInSModule(nSupMod,nModule,nIphi,nIeta, iphi,ieta); | |
25bb3dcb | 525 | |
526 | // In case of a shared cluster, index of SM in C side, columns start at 48 and ends at 48*2 | |
527 | // C Side impair SM, nSupMod%2=1; A side pair SM, nSupMod%2=0 | |
528 | if(fSharedCluster && nSupMod%2) ieta+=AliEMCALGeoParams::fgkEMCALCols; | |
529 | ||
1d46d1f6 | 530 | etai=(Double_t)ieta; |
531 | phii=(Double_t)iphi; | |
532 | w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ; | |
533 | ||
534 | if(w>0.0) { | |
535 | nstat++; | |
536 | d += w*((etai-etaMean)*(etai-etaMean)+(phii-phiMean)*(phii-phiMean)); | |
e52475ed | 537 | } |
538 | } | |
ab48128d | 539 | } |
70a93198 | 540 | |
e52475ed | 541 | if ( wtot > 0 && nstat>1) d /= wtot ; |
542 | else d = 0. ; | |
70a93198 | 543 | |
544 | fDispersion = TMath::Sqrt(d) ; | |
25bb3dcb | 545 | //printf("AliEMCALRecPoint::EvalDispersion() : Dispersion %f \n",fDispersion); |
ab48128d | 546 | } |
70a93198 | 547 | |
40164976 | 548 | //____________________________________________________________________________ |
549 | void AliEMCALRecPoint::EvalDistanceToBadChannels(AliCaloCalibPedestal* caloped) | |
550 | { | |
551 | //For each EMC rec. point set the distance to the nearest bad channel. | |
552 | //AliInfo(Form("%d bad channel(s) found.\n", caloped->GetDeadTowerCount())); | |
2ebdefe6 | 553 | //It is done in cell units and not in global or local position as before (Sept 2010) |
40164976 | 554 | |
555 | if(!caloped->GetDeadTowerCount()) return; | |
25bb3dcb | 556 | |
557 | //Get channels map of the supermodule where the cluster is. | |
558 | TH2D* hMap = caloped->GetDeadMap(fSuperModuleNumber); | |
40164976 | 559 | |
2ebdefe6 | 560 | Int_t dRrow, dReta; |
561 | Float_t minDist = 10000.; | |
562 | Float_t dist = 0.; | |
563 | Int_t nSupMod, nModule; | |
564 | Int_t nIphi, nIeta; | |
565 | Int_t iphi, ieta; | |
566 | fDigitIndMax = GetMaximalEnergyIndex(); | |
567 | fGeomPtr->GetCellIndex(fAbsIdList[fDigitIndMax], nSupMod,nModule,nIphi,nIeta); | |
568 | fGeomPtr->GetCellPhiEtaIndexInSModule(nSupMod,nModule,nIphi,nIeta, iphi,ieta); | |
569 | ||
570 | // TVector3 dR; | |
571 | // TVector3 cellpos; | |
572 | // Float_t minDist = 100000; | |
573 | // Float_t dist = 0; | |
574 | // Int_t absId = -1; | |
575 | ||
576 | //Loop on tower status map | |
40164976 | 577 | for(Int_t irow = 0; irow < AliEMCALGeoParams::fgkEMCALRows; irow++){ |
578 | for(Int_t icol = 0; icol < AliEMCALGeoParams::fgkEMCALCols; icol++){ | |
579 | //Check if tower is bad. | |
580 | if(hMap->GetBinContent(icol,irow)==AliCaloCalibPedestal::kAlive) continue; | |
2ebdefe6 | 581 | //printf("AliEMCALRecPoint::EvalDistanceToBadChannels() - Bad channel in SM %d, col %d, row %d\n",iSM,icol, irow); |
582 | ||
583 | dRrow=TMath::Abs(irow-iphi); | |
584 | dReta=TMath::Abs(icol-ieta); | |
585 | dist=TMath::Sqrt(dRrow*dRrow+dReta*dReta); | |
25bb3dcb | 586 | if(dist < minDist) minDist = dist; |
2ebdefe6 | 587 | |
588 | // //Tower is bad, get the absId of the index. | |
589 | // absId = fGeomPtr->GetAbsCellIdFromCellIndexes(fSuperModuleNumber, irow, icol); | |
590 | // | |
591 | // //Get the position of this tower. | |
592 | // | |
593 | // //Calculate the distance in local coordinates | |
594 | // //fGeomPtr->RelPosCellInSModule(absId,cellpos); | |
595 | // //Calculate distance between this tower and cluster, set if is smaller than previous. | |
596 | // //dR = cellpos-fLocPos; | |
597 | // | |
598 | // //Calculate the distance in global coordinates | |
599 | // fGeomPtr->GetGlobal(absId,cellpos); | |
600 | // //Calculate distance between this tower and cluster, set if it is smaller than previous. | |
601 | // dR = cellpos-fGlobPos; | |
602 | // | |
603 | // dist = dR.Mag(); | |
604 | // if(dist < minDist) minDist = dist; | |
605 | ||
40164976 | 606 | } |
89dc5acd | 607 | } |
2ebdefe6 | 608 | |
25bb3dcb | 609 | //In case the cluster is shared by 2 SuperModules, need to check the map of the second Super Module |
610 | if (fSharedCluster) { | |
611 | TH2D* hMap2 = 0; | |
612 | Int_t nSupMod2 = -1; | |
613 | ||
614 | //The only possible combinations are (0,1), (2,3) ... (10,11) | |
615 | if(fSuperModuleNumber%2) nSupMod2 = fSuperModuleNumber-1; | |
616 | else nSupMod2 = fSuperModuleNumber+1; | |
617 | hMap2 = caloped->GetDeadMap(nSupMod2); | |
2ebdefe6 | 618 | |
25bb3dcb | 619 | //Loop on tower status map of second super module |
620 | for(Int_t irow = 0; irow < AliEMCALGeoParams::fgkEMCALRows; irow++){ | |
621 | for(Int_t icol = 0; icol < AliEMCALGeoParams::fgkEMCALCols; icol++){ | |
622 | //Check if tower is bad. | |
623 | if(hMap2->GetBinContent(icol,irow)==AliCaloCalibPedestal::kAlive) continue; | |
624 | //printf("AliEMCALRecPoint::EvalDistanceToBadChannels() - Bad channel in SM %d, col %d, row %d\n",iSM,icol, irow); | |
2ebdefe6 | 625 | |
626 | dRrow=TMath::Abs(irow-iphi); | |
627 | ||
628 | if(fSuperModuleNumber%2) { | |
629 | dReta=TMath::Abs(icol-(AliEMCALGeoParams::fgkEMCALCols+ieta)); | |
630 | } | |
631 | else { | |
632 | dReta=TMath::Abs(AliEMCALGeoParams::fgkEMCALCols+icol-ieta); | |
633 | } | |
634 | ||
635 | dist=TMath::Sqrt(dRrow*dRrow+dReta*dReta); | |
636 | if(dist < minDist) minDist = dist; | |
637 | ||
638 | // | |
639 | // //Tower is bad, get the absId of the index. | |
640 | // absId = fGeomPtr->GetAbsCellIdFromCellIndexes(nSupMod2, irow, icol); | |
641 | // | |
642 | // //Get the position of this tower. | |
643 | // | |
644 | // //Calculate the distance in global coordinates | |
645 | // fGeomPtr->GetGlobal(absId,cellpos); | |
646 | // //Calculate distance between this tower and cluster, set if it is smaller than previous. | |
647 | // dR = cellpos-fGlobPos; | |
648 | // | |
649 | // dist = dR.Mag(); | |
650 | // if(dist < minDist) minDist = dist; | |
25bb3dcb | 651 | } |
652 | } | |
653 | ||
654 | }// shared cluster in 2 SuperModules | |
2ebdefe6 | 655 | |
40164976 | 656 | fDistToBadTower = minDist; |
25bb3dcb | 657 | //printf("AliEMCALRecPoint::EvalDistanceToBadChannel() - Distance to Bad is %f cm, shared cluster? %d \n",fDistToBadTower,fSharedCluster); |
40164976 | 658 | } |
659 | ||
660 | ||
ab48128d | 661 | //____________________________________________________________________________ |
70a93198 | 662 | void AliEMCALRecPoint::EvalLocalPosition(Float_t logWeight, TClonesArray * digits) |
88cb7938 | 663 | { |
25bb3dcb | 664 | // Calculates the center of gravity in the local EMCAL-module coordinates |
665 | // Info("Print", " logWeight %f : cluster energy %f ", logWeight, fAmp); // for testing | |
666 | ||
53e430a3 | 667 | AliEMCALDigit * digit=0; |
25bb3dcb | 668 | Int_t i=0, nstat=0; |
669 | ||
47583f1b | 670 | Double_t dist = TmaxInCm(Double_t(fAmp)); |
25bb3dcb | 671 | //Int_t idMax = GetAbsIdMaxDigit();// idMax is not used at all in RelPosCellInSModule, why use it? |
672 | ||
673 | Double_t clXYZ[3]={0.,0.,0.}, clRmsXYZ[3]={0.,0.,0.}, xyzi[3], wtot=0., w=0.; | |
674 | ||
675 | //printf(" dist : %f e : %f \n", dist, fAmp); | |
676 | for(Int_t iDigit=0; iDigit<fMulDigit; iDigit++) { | |
677 | digit = dynamic_cast<AliEMCALDigit *>(digits->At(fDigitsList[iDigit])) ; | |
678 | ||
2ebdefe6 | 679 | if(!digit) { |
680 | AliError("No Digit!!"); | |
681 | continue; | |
682 | } | |
683 | ||
25bb3dcb | 684 | //fGeomPtr->RelPosCellInSModule(digit->GetId(), idMax, dist, xyzi[0], xyzi[1], xyzi[2]); |
685 | fGeomPtr->RelPosCellInSModule(digit->GetId(), dist, xyzi[0], xyzi[1], xyzi[2]); | |
686 | ||
687 | //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 | |
688 | if(fSharedCluster && fSuperModuleNumber != fGeomPtr->GetSuperModuleNumber(digit->GetId())) xyzi[1]*=-1; | |
689 | ||
690 | //printf("EvalLocalPosition Cell: Id %i, SM %i : dist %f Local x,y,z %f %f %f \n", | |
691 | // digit->GetId(), fGeomPtr->GetSuperModuleNumber(digit->GetId()), dist, xyzi[0], xyzi[1], xyzi[2]); | |
692 | ||
693 | if(logWeight > 0.0) w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp )); | |
694 | else w = fEnergyList[iDigit]; // just energy | |
695 | ||
696 | if(w>0.0) { | |
697 | wtot += w ; | |
698 | nstat++; | |
699 | for(i=0; i<3; i++ ) { | |
700 | clXYZ[i] += (w*xyzi[i]); | |
701 | clRmsXYZ[i] += (w*xyzi[i]*xyzi[i]); | |
702 | } | |
703 | } | |
704 | } | |
705 | // cout << " wtot " << wtot << endl; | |
706 | if ( wtot > 0 ) { | |
707 | // xRMS = TMath::Sqrt(x2m - xMean*xMean); | |
708 | for(i=0; i<3; i++ ) { | |
709 | clXYZ[i] /= wtot; | |
710 | if(nstat>1) { | |
711 | clRmsXYZ[i] /= (wtot*wtot); | |
712 | clRmsXYZ[i] = clRmsXYZ[i] - clXYZ[i]*clXYZ[i]; | |
713 | if(clRmsXYZ[i] > 0.0) { | |
714 | clRmsXYZ[i] = TMath::Sqrt(clRmsXYZ[i]); | |
715 | } else clRmsXYZ[i] = 0; | |
716 | } else clRmsXYZ[i] = 0; | |
717 | } | |
718 | } else { | |
719 | for(i=0; i<3; i++ ) { | |
720 | clXYZ[i] = clRmsXYZ[i] = -1.; | |
721 | } | |
722 | } | |
723 | // clRmsXYZ[i] ?? | |
724 | ||
725 | // // Cluster of one single digit, smear the position to avoid discrete position | |
726 | // // smear x and z with +- 3 cm to uniform (avoid discrete effects). Tower size is approx 6 cm. | |
727 | // // Rndm generates a number in ]0,1] | |
728 | // if (fMulDigit==1) { | |
729 | // clXYZ[0] += fGeomPtr->GetPhiTileSize()*(0.5 - gRandom->Rndm()); | |
730 | // clXYZ[2] += fGeomPtr->GetEtaTileSize()*(0.5 - gRandom->Rndm()); | |
731 | // } | |
732 | ||
733 | //Set position in local vector | |
734 | fLocPos.SetX(clXYZ[0]); | |
735 | fLocPos.SetY(clXYZ[1]); | |
736 | fLocPos.SetZ(clXYZ[2]); | |
737 | ||
738 | if (gDebug==2) | |
739 | printf("EvalLocalPosition Cluster: Local (x,y,z) = (%f,%f,%f) \n", fLocPos.X(), fLocPos.Y(), fLocPos.Z()) ; | |
740 | ||
741 | } | |
742 | ||
743 | ||
744 | //____________________________________________________________________________ | |
745 | void AliEMCALRecPoint::EvalGlobalPosition(Float_t logWeight, TClonesArray * digits) | |
746 | { | |
747 | // Calculates the center of gravity in the global ALICE coordinates | |
e52475ed | 748 | // Info("Print", " logWeight %f : cluster energy %f ", logWeight, fAmp); // for testing |
70a93198 | 749 | |
53e430a3 | 750 | AliEMCALDigit * digit=0; |
25bb3dcb | 751 | Int_t i=0, nstat=0; |
752 | ||
47583f1b | 753 | Double_t dist = TmaxInCm(Double_t(fAmp)); |
25bb3dcb | 754 | //Int_t idMax = GetAbsIdMaxDigit();// idMax is not used at all in RelPosCellInSModule, why use it? |
755 | ||
756 | Double_t clXYZ[3]={0.,0.,0.}, clRmsXYZ[3]={0.,0.,0.}, lxyzi[3], xyzi[3], wtot=0., w=0.; | |
70a93198 | 757 | |
1ae500a2 | 758 | //printf(" dist : %f e : %f \n", dist, fAmp); |
e52475ed | 759 | for(Int_t iDigit=0; iDigit<fMulDigit; iDigit++) { |
70a93198 | 760 | digit = dynamic_cast<AliEMCALDigit *>(digits->At(fDigitsList[iDigit])) ; |
e52475ed | 761 | |
2ebdefe6 | 762 | if(!digit) { |
763 | AliError("No Digit!!"); | |
764 | continue; | |
765 | } | |
766 | ||
25bb3dcb | 767 | //Get the local coordinates of the cell |
768 | //fGeomPtr->RelPosCellInSModule(digit->GetId(), idMax, dist, lxyzi[0], lxyzi[1], lxyzi[2]); | |
769 | fGeomPtr->RelPosCellInSModule(digit->GetId(), dist, lxyzi[0], lxyzi[1], lxyzi[2]); | |
770 | ||
771 | //Now get the global coordinate | |
772 | fGeomPtr->GetGlobal(lxyzi,xyzi, fGeomPtr->GetSuperModuleNumber(digit->GetId())); | |
773 | //TVector3 pos(xyzi[0], xyzi[1], xyzi[2]); | |
774 | //printf("EvalGlobalPosition Cell: Id %i, SM %i : dist %f Local (x,y,z) = (%f %f %f), eta %f, phi%f \n", | |
775 | // digit->GetId(), fGeomPtr->GetSuperModuleNumber(digit->GetId()),dist, xyzi[0], xyzi[1], xyzi[2],pos.Eta(),pos.Phi()*TMath::RadToDeg()); | |
776 | ||
af5bdd85 | 777 | if(logWeight > 0.0) w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp )); |
778 | else w = fEnergyList[iDigit]; // just energy | |
ab48128d | 779 | |
e52475ed | 780 | if(w>0.0) { |
781 | wtot += w ; | |
782 | nstat++; | |
783 | for(i=0; i<3; i++ ) { | |
784 | clXYZ[i] += (w*xyzi[i]); | |
785 | clRmsXYZ[i] += (w*xyzi[i]*xyzi[i]); | |
786 | } | |
787 | } | |
788 | } | |
789 | // cout << " wtot " << wtot << endl; | |
70a93198 | 790 | if ( wtot > 0 ) { |
e52475ed | 791 | // xRMS = TMath::Sqrt(x2m - xMean*xMean); |
792 | for(i=0; i<3; i++ ) { | |
793 | clXYZ[i] /= wtot; | |
794 | if(nstat>1) { | |
795 | clRmsXYZ[i] /= (wtot*wtot); | |
796 | clRmsXYZ[i] = clRmsXYZ[i] - clXYZ[i]*clXYZ[i]; | |
797 | if(clRmsXYZ[i] > 0.0) { | |
798 | clRmsXYZ[i] = TMath::Sqrt(clRmsXYZ[i]); | |
799 | } else clRmsXYZ[i] = 0; | |
800 | } else clRmsXYZ[i] = 0; | |
801 | } | |
70a93198 | 802 | } else { |
e52475ed | 803 | for(i=0; i<3; i++ ) { |
804 | clXYZ[i] = clRmsXYZ[i] = -1.; | |
805 | } | |
70a93198 | 806 | } |
e52475ed | 807 | // clRmsXYZ[i] ?? |
25bb3dcb | 808 | |
809 | // // Cluster of one single digit, smear the position to avoid discrete position | |
810 | // // smear x and z with +- 3 cm to uniform (avoid discrete effects). Tower size is approx 6 cm. | |
811 | // // Rndm generates a number in ]0,1] | |
812 | // if (fMulDigit==1) { | |
813 | // clXYZ[0] += fGeomPtr->GetPhiTileSize()*(0.5 - gRandom->Rndm()); | |
814 | // clXYZ[2] += fGeomPtr->GetEtaTileSize()*(0.5 - gRandom->Rndm()); | |
815 | // } | |
816 | ||
817 | //Set position in global vector | |
818 | fGlobPos.SetX(clXYZ[0]); | |
819 | fGlobPos.SetY(clXYZ[1]); | |
820 | fGlobPos.SetZ(clXYZ[2]); | |
821 | ||
822 | if (gDebug==2) | |
823 | printf("EvalGlobalPosition Cluster: (x ,y ,z) = (%f,%f,%f), eta %f,phi %f\n", | |
824 | fGlobPos.X(), fGlobPos.Y(), fGlobPos.Z(),fGlobPos.Eta(),fGlobPos.Phi()*TMath::RadToDeg()) ; | |
ab48128d | 825 | } |
826 | ||
1ae500a2 | 827 | //____________________________________________________________________________ |
828 | void AliEMCALRecPoint::EvalLocalPositionFit(Double_t deff, Double_t logWeight, | |
829 | Double_t phiSlope, TClonesArray * digits) | |
830 | { | |
47583f1b | 831 | // Evaluates local position of clusters in SM |
832 | ||
833 | Double_t ycorr=0; | |
834 | AliEMCALDigit *digit=0; | |
25bb3dcb | 835 | Int_t i=0, nstat=0; |
1ae500a2 | 836 | Double_t clXYZ[3]={0.,0.,0.}, clRmsXYZ[3]={0.,0.,0.}, xyzi[3], wtot=0., w=0.; |
837 | ||
47583f1b | 838 | Double_t dist = TmaxInCm(Double_t(fAmp)); |
25bb3dcb | 839 | //Int_t idMax = GetAbsIdMaxDigit();// idMax is not used at all in RelPosCellInSModule, why use it? |
840 | ||
1ae500a2 | 841 | for(Int_t iDigit=0; iDigit<digits->GetEntries(); iDigit++) { |
842 | digit = dynamic_cast<AliEMCALDigit *>(digits->At(fDigitsList[iDigit])) ; | |
a51e676d | 843 | if(digit){ |
844 | dist = deff; | |
845 | //fGeomPtr->RelPosCellInSModule(digit->GetId(), idMax, dist, xyzi[0], xyzi[1], xyzi[2]); | |
846 | fGeomPtr->RelPosCellInSModule(digit->GetId(), dist, xyzi[0], xyzi[1], xyzi[2]); | |
847 | ||
848 | if(logWeight > 0.0) w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp )); | |
849 | else w = fEnergyList[iDigit]; // just energy | |
850 | ||
851 | if(w>0.0) { | |
852 | wtot += w ; | |
853 | nstat++; | |
854 | for(i=0; i<3; i++ ) { | |
855 | clXYZ[i] += (w*xyzi[i]); | |
856 | clRmsXYZ[i] += (w*xyzi[i]*xyzi[i]); | |
857 | } | |
1ae500a2 | 858 | } |
a51e676d | 859 | }else AliError("Digit null"); |
860 | }//loop | |
1ae500a2 | 861 | // cout << " wtot " << wtot << endl; |
862 | if ( wtot > 0 ) { | |
863 | // xRMS = TMath::Sqrt(x2m - xMean*xMean); | |
864 | for(i=0; i<3; i++ ) { | |
865 | clXYZ[i] /= wtot; | |
866 | if(nstat>1) { | |
867 | clRmsXYZ[i] /= (wtot*wtot); | |
868 | clRmsXYZ[i] = clRmsXYZ[i] - clXYZ[i]*clXYZ[i]; | |
869 | if(clRmsXYZ[i] > 0.0) { | |
870 | clRmsXYZ[i] = TMath::Sqrt(clRmsXYZ[i]); | |
871 | } else clRmsXYZ[i] = 0; | |
872 | } else clRmsXYZ[i] = 0; | |
873 | } | |
874 | } else { | |
875 | for(i=0; i<3; i++ ) { | |
876 | clXYZ[i] = clRmsXYZ[i] = -1.; | |
877 | } | |
878 | } | |
879 | // clRmsXYZ[i] ?? | |
880 | if(phiSlope != 0.0 && logWeight > 0.0 && wtot) { | |
881 | // Correction in phi direction (y - coords here); Aug 16; | |
882 | // May be put to global level or seperate method | |
883 | ycorr = clXYZ[1] * (1. + phiSlope); | |
884 | //printf(" y %f : ycorr %f : slope %f \n", clXYZ[1], ycorr, phiSlope); | |
885 | clXYZ[1] = ycorr; | |
886 | } | |
25bb3dcb | 887 | |
1ae500a2 | 888 | fLocPos.SetX(clXYZ[0]); |
889 | fLocPos.SetY(clXYZ[1]); | |
890 | fLocPos.SetZ(clXYZ[2]); | |
891 | ||
892 | // if (gDebug==2) | |
893 | // printf("EvalLocalPosition: eta,phi,r = %f,%f,%f", fLocPos.X(), fLocPos.Y(), fLocPos.Z()) ; | |
1ae500a2 | 894 | } |
895 | ||
9aa6a5f6 | 896 | //_____________________________________________________________________________ |
1ae500a2 | 897 | Bool_t AliEMCALRecPoint::EvalLocalPosition2(TClonesArray * digits, TArrayD &ed) |
898 | { | |
899 | // Evaluated local position of rec.point using digits | |
900 | // and parametrisation of w0 and deff | |
901 | //printf(" <I> AliEMCALRecPoint::EvalLocalPosition2() \n"); | |
902 | return AliEMCALRecPoint::EvalLocalPositionFromDigits(digits, ed, fLocPos); | |
903 | } | |
904 | ||
9aa6a5f6 | 905 | //_____________________________________________________________________________ |
1ae500a2 | 906 | Bool_t AliEMCALRecPoint::EvalLocalPositionFromDigits(TClonesArray *digits, TArrayD &ed, TVector3 &locPos) |
907 | { | |
908 | // Used when digits should be recalibrated | |
47583f1b | 909 | Double_t deff=0, w0=0, esum=0; |
910 | Int_t iDigit=0; | |
911 | // AliEMCALDigit *digit; | |
1ae500a2 | 912 | |
913 | if(ed.GetSize() && (digits->GetEntries()!=ed.GetSize())) return kFALSE; | |
914 | ||
915 | // Calculate sum energy of digits | |
916 | esum = 0.0; | |
917 | for(iDigit=0; iDigit<ed.GetSize(); iDigit++) esum += ed[iDigit]; | |
918 | ||
919 | GetDeffW0(esum, deff, w0); | |
920 | ||
921 | return EvalLocalPositionFromDigits(esum, deff, w0, digits, ed, locPos); | |
922 | } | |
923 | ||
9aa6a5f6 | 924 | //_____________________________________________________________________________ |
925 | Bool_t AliEMCALRecPoint::EvalLocalPositionFromDigits(const Double_t esum, const Double_t deff, const Double_t w0, TClonesArray *digits, TArrayD &ed, TVector3 &locPos) | |
1ae500a2 | 926 | { |
40164976 | 927 | //Evaluate position of digits in supermodule. |
47583f1b | 928 | AliEMCALDigit *digit=0; |
1ae500a2 | 929 | |
25bb3dcb | 930 | Int_t i=0, nstat=0; |
1ae500a2 | 931 | Double_t clXYZ[3]={0.,0.,0.}, xyzi[3], wtot=0., w=0.; |
25bb3dcb | 932 | //Int_t idMax = GetAbsIdMaxDigit();// idMax is not used at all in RelPosCellInSModule, why use it? |
933 | ||
9aa6a5f6 | 934 | // Get pointer to EMCAL geometry |
935 | // (can't use fGeomPtr in static method) | |
936 | AliEMCALGeometry* geo = AliEMCALGeometry::GetInstance(); | |
937 | ||
1ae500a2 | 938 | for(Int_t iDigit=0; iDigit<digits->GetEntries(); iDigit++) { |
939 | digit = dynamic_cast<AliEMCALDigit *>(digits->At(iDigit)); | |
a51e676d | 940 | if(digit){ |
941 | //geo->RelPosCellInSModule(digit->GetId(), idMax, deff, xyzi[0], xyzi[1], xyzi[2]); | |
942 | geo->RelPosCellInSModule(digit->GetId(), deff, xyzi[0], xyzi[1], xyzi[2]); | |
943 | ||
944 | if(w0 > 0.0) w = TMath::Max( 0., w0 + TMath::Log(ed[iDigit] / esum)); | |
945 | else w = ed[iDigit]; // just energy | |
946 | ||
947 | if(w>0.0) { | |
948 | wtot += w ; | |
949 | nstat++; | |
950 | for(i=0; i<3; i++ ) { | |
951 | clXYZ[i] += (w*xyzi[i]); | |
952 | } | |
1ae500a2 | 953 | } |
a51e676d | 954 | }else AliError("Digit null"); |
955 | }//loop | |
1ae500a2 | 956 | // cout << " wtot " << wtot << endl; |
957 | if (wtot > 0) { | |
958 | for(i=0; i<3; i++ ) { | |
959 | clXYZ[i] /= wtot; | |
960 | } | |
961 | locPos.SetX(clXYZ[0]); | |
962 | locPos.SetY(clXYZ[1]); | |
963 | locPos.SetZ(clXYZ[2]); | |
964 | return kTRUE; | |
965 | } else { | |
966 | return kFALSE; | |
967 | } | |
968 | ||
969 | } | |
970 | ||
9aa6a5f6 | 971 | //_____________________________________________________________________________ |
1ae500a2 | 972 | void AliEMCALRecPoint::GetDeffW0(const Double_t esum , Double_t &deff, Double_t &w0) |
973 | { | |
974 | // | |
975 | // Aug 31, 2001 | |
976 | // Applied for simulation data with threshold 3 adc | |
977 | // Calculate efective distance (deff) and weigh parameter (w0) | |
978 | // for coordinate calculation; 0.5 GeV < esum <100 GeV. | |
979 | // Look to: http://rhic.physics.wayne.edu/~pavlinov/ALICE/SHISHKEBAB/RES/CALIB/GEOMCORR/deffandW0VaEgamma_2.gif | |
980 | // | |
47583f1b | 981 | Double_t e=0.0; |
37890aaf | 982 | const Double_t kdp0=9.25147, kdp1=1.16700; // Hard coded now |
983 | const Double_t kwp0=4.83713, kwp1=-2.77970e-01, kwp2 = 4.41116; | |
1ae500a2 | 984 | |
985 | // No extrapolation here | |
986 | e = esum<0.5?0.5:esum; | |
987 | e = e>100.?100.:e; | |
988 | ||
37890aaf | 989 | deff = kdp0 + kdp1*TMath::Log(e); |
990 | w0 = kwp0 / (1. + TMath::Exp(kwp1*(e+kwp2))); | |
1ae500a2 | 991 | //printf("<I> AliEMCALRecPoint::GetDeffW0 esum %5.2f : deff %5.2f : w0 %5.2f \n", esum, deff, w0); |
992 | } | |
e52475ed | 993 | |
70a93198 | 994 | //______________________________________________________________________________ |
995 | void AliEMCALRecPoint::EvalCoreEnergy(Float_t logWeight, TClonesArray * digits) | |
996 | { | |
997 | // This function calculates energy in the core, | |
4635df1f | 998 | // i.e. within a radius rad = fCoreEnergy around the center. Beyond this radius |
70a93198 | 999 | // in accordance with shower profile the energy deposition |
1000 | // should be less than 2% | |
1d46d1f6 | 1001 | // Unfinished - Nov 15,2006 |
1002 | // Distance is calculate in (phi,eta) units | |
70a93198 | 1003 | |
53e430a3 | 1004 | AliEMCALDigit * digit = 0 ; |
5dee926e | 1005 | |
53e430a3 | 1006 | Int_t iDigit=0; |
70a93198 | 1007 | |
e52475ed | 1008 | if (!fLocPos.Mag()) { |
70a93198 | 1009 | EvalLocalPosition(logWeight, digits); |
1010 | } | |
1011 | ||
1d46d1f6 | 1012 | Double_t phiPoint = fLocPos.Phi(), etaPoint = fLocPos.Eta(); |
1013 | Double_t eta, phi, distance; | |
70a93198 | 1014 | for(iDigit=0; iDigit < fMulDigit; iDigit++) { |
1015 | digit = (AliEMCALDigit *) ( digits->At(fDigitsList[iDigit]) ) ; | |
4635df1f | 1016 | |
1d46d1f6 | 1017 | eta = phi = 0.0; |
1018 | fGeomPtr->EtaPhiFromIndex(digit->GetId(),eta, phi) ; | |
1019 | phi = phi * TMath::DegToRad(); | |
70a93198 | 1020 | |
1d46d1f6 | 1021 | distance = TMath::Sqrt((eta-etaPoint)*(eta-etaPoint)+(phi-phiPoint)*(phi-phiPoint)); |
70a93198 | 1022 | if(distance < fCoreRadius) |
1023 | fCoreEnergy += fEnergyList[iDigit] ; | |
1024 | } | |
1025 | ||
1026 | } | |
ab48128d | 1027 | //____________________________________________________________________________ |
70a93198 | 1028 | void AliEMCALRecPoint::EvalElipsAxis(Float_t logWeight,TClonesArray * digits) |
ab48128d | 1029 | { |
70a93198 | 1030 | // Calculates the axis of the shower ellipsoid in eta and phi |
1d46d1f6 | 1031 | // in cell units |
ab48128d | 1032 | |
47583f1b | 1033 | TString gn(fGeomPtr->GetName()); |
1d46d1f6 | 1034 | |
1035 | Double_t wtot = 0.; | |
70a93198 | 1036 | Double_t x = 0.; |
1037 | Double_t z = 0.; | |
1038 | Double_t dxx = 0.; | |
1039 | Double_t dzz = 0.; | |
1040 | Double_t dxz = 0.; | |
ab48128d | 1041 | |
1d46d1f6 | 1042 | AliEMCALDigit * digit = 0; |
25bb3dcb | 1043 | |
53e430a3 | 1044 | Double_t etai =0, phii=0, w=0; |
2bb3725c | 1045 | int nSupMod=0, nModule=0, nIphi=0, nIeta=0; |
1d46d1f6 | 1046 | int iphi=0, ieta=0; |
1047 | for(Int_t iDigit=0; iDigit<fMulDigit; iDigit++) { | |
70a93198 | 1048 | digit = (AliEMCALDigit *) digits->At(fDigitsList[iDigit]) ; |
1d46d1f6 | 1049 | etai = phii = 0.; |
1d46d1f6 | 1050 | // Nov 15,2006 - use cell numbers as coordinates |
1051 | // Copied for shish-kebab geometry, ieta,iphi is cast as double as eta,phi | |
1052 | // We can use the eta,phi(or coordinates) of cell | |
dc77cc84 | 1053 | nSupMod = nModule = nIphi = nIeta = iphi = ieta = 0; |
1d46d1f6 | 1054 | |
dc77cc84 | 1055 | fGeomPtr->GetCellIndex(digit->GetId(), nSupMod,nModule,nIphi,nIeta); |
1056 | fGeomPtr->GetCellPhiEtaIndexInSModule(nSupMod,nModule,nIphi,nIeta, iphi,ieta); | |
25bb3dcb | 1057 | |
1058 | // In case of a shared cluster, index of SM in C side, columns start at 48 and ends at 48*2 | |
1059 | // C Side impair SM, nSupMod%2=1; A side pair SM, nSupMod%2=0 | |
1060 | if(fSharedCluster && nSupMod%2) ieta+=AliEMCALGeoParams::fgkEMCALCols; | |
1061 | ||
dc77cc84 | 1062 | etai=(Double_t)ieta; |
1063 | phii=(Double_t)iphi; | |
25bb3dcb | 1064 | |
1d46d1f6 | 1065 | w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ; |
1066 | // fAmp summed amplitude of digits, i.e. energy of recpoint | |
1067 | // Gives smaller value of lambda than log weight | |
1068 | // w = fEnergyList[iDigit] / fAmp; // Nov 16, 2006 - try just energy | |
ff1e7e2f | 1069 | |
70a93198 | 1070 | dxx += w * etai * etai ; |
1071 | x += w * etai ; | |
1072 | dzz += w * phii * phii ; | |
1073 | z += w * phii ; | |
1963b290 | 1074 | |
ff1e7e2f | 1075 | dxz += w * etai * phii ; |
1963b290 | 1076 | |
70a93198 | 1077 | wtot += w ; |
1078 | } | |
ff1e7e2f | 1079 | |
70a93198 | 1080 | if ( wtot > 0 ) { |
1081 | dxx /= wtot ; | |
1082 | x /= wtot ; | |
1083 | dxx -= x * x ; | |
1084 | dzz /= wtot ; | |
1085 | z /= wtot ; | |
1086 | dzz -= z * z ; | |
1087 | dxz /= wtot ; | |
1088 | dxz -= x * z ; | |
ab48128d | 1089 | |
70a93198 | 1090 | fLambda[0] = 0.5 * (dxx + dzz) + TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ; |
1091 | if(fLambda[0] > 0) | |
1092 | fLambda[0] = TMath::Sqrt(fLambda[0]) ; | |
1093 | else | |
1094 | fLambda[0] = 0; | |
1095 | ||
1096 | fLambda[1] = 0.5 * (dxx + dzz) - TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ; | |
ff1e7e2f | 1097 | |
70a93198 | 1098 | if(fLambda[1] > 0) //To avoid exception if numerical errors lead to negative lambda. |
1099 | fLambda[1] = TMath::Sqrt(fLambda[1]) ; | |
1100 | else | |
1101 | fLambda[1]= 0. ; | |
1102 | } else { | |
1103 | fLambda[0]= 0. ; | |
1104 | fLambda[1]= 0. ; | |
ab48128d | 1105 | } |
ff1e7e2f | 1106 | |
25bb3dcb | 1107 | //printf("AliEMCALRecPoint::EvalElipsAxis() lambdas = %f,%f \n", fLambda[0],fLambda[1]) ; |
ff1e7e2f | 1108 | |
ab48128d | 1109 | } |
1110 | ||
1111 | //______________________________________________________________________________ | |
1112 | void AliEMCALRecPoint::EvalPrimaries(TClonesArray * digits) | |
1113 | { | |
af5bdd85 | 1114 | // Constructs the list of primary particles (tracks) which |
1115 | // have contributed to this RecPoint and calculate deposited energy | |
1116 | // for each track | |
ab48128d | 1117 | |
53e430a3 | 1118 | AliEMCALDigit * digit =0; |
af5bdd85 | 1119 | Int_t * primArray = new Int_t[fMaxTrack] ; |
7f3091e7 | 1120 | memset(primArray,-1,sizeof(Int_t)*fMaxTrack); |
af5bdd85 | 1121 | Float_t * dEPrimArray = new Float_t[fMaxTrack] ; |
7f3091e7 | 1122 | memset(dEPrimArray,-1,sizeof(Int_t)*fMaxTrack); |
2ebdefe6 | 1123 | |
ab48128d | 1124 | Int_t index ; |
1125 | for ( index = 0 ; index < GetDigitsMultiplicity() ; index++ ) { // all digits | |
1126 | digit = dynamic_cast<AliEMCALDigit *>(digits->At( fDigitsList[index] )) ; | |
2ebdefe6 | 1127 | if(!digit) { |
1128 | AliError("No Digit!!"); | |
1129 | continue; | |
1130 | } | |
1131 | ||
ab48128d | 1132 | Int_t nprimaries = digit->GetNprimary() ; |
5c0368b8 | 1133 | if ( nprimaries == 0 ) continue ; |
ab48128d | 1134 | Int_t jndex ; |
1135 | for ( jndex = 0 ; jndex < nprimaries ; jndex++ ) { // all primaries in digit | |
1136 | if ( fMulTrack > fMaxTrack ) { | |
2ebdefe6 | 1137 | fMulTrack = fMaxTrack ; |
1138 | Error("EvalPrimaries", "increase fMaxTrack ") ; | |
1139 | break ; | |
ab48128d | 1140 | } |
af5bdd85 | 1141 | Int_t newPrimary = digit->GetPrimary(jndex+1); |
1142 | Float_t dEPrimary = digit->GetDEPrimary(jndex+1); | |
ab48128d | 1143 | Int_t kndex ; |
1144 | Bool_t already = kFALSE ; | |
1145 | for ( kndex = 0 ; kndex < fMulTrack ; kndex++ ) { //check if not already stored | |
2ebdefe6 | 1146 | if ( newPrimary == primArray[kndex] ){ |
1147 | already = kTRUE ; | |
1148 | dEPrimArray[kndex] += dEPrimary; | |
1149 | break ; | |
1150 | } | |
ab48128d | 1151 | } // end of check |
5c0368b8 | 1152 | if ( !already && (fMulTrack < fMaxTrack)) { // store it |
2ebdefe6 | 1153 | primArray[fMulTrack] = newPrimary ; |
1154 | dEPrimArray[fMulTrack] = dEPrimary ; | |
1155 | fMulTrack++ ; | |
ab48128d | 1156 | } // store it |
1157 | } // all primaries in digit | |
ab48128d | 1158 | } // all digits |
2ebdefe6 | 1159 | |
af5bdd85 | 1160 | Int_t *sortIdx = new Int_t[fMulTrack]; |
1161 | TMath::Sort(fMulTrack,dEPrimArray,sortIdx); | |
1162 | for(index = 0; index < fMulTrack; index++) { | |
1163 | fTracksList[index] = primArray[sortIdx[index]] ; | |
1164 | fDETracksList[index] = dEPrimArray[sortIdx[index]] ; | |
1165 | } | |
1166 | delete [] sortIdx; | |
1167 | delete [] primArray ; | |
1168 | delete [] dEPrimArray ; | |
2ebdefe6 | 1169 | |
ab48128d | 1170 | } |
7ee5c5be | 1171 | |
87cdc3be | 1172 | //______________________________________________________________________________ |
1173 | void AliEMCALRecPoint::EvalParents(TClonesArray * digits) | |
1174 | { | |
1175 | // Constructs the list of parent particles (tracks) which have contributed to this RecPoint | |
2ebdefe6 | 1176 | |
53e430a3 | 1177 | AliEMCALDigit * digit=0 ; |
af5bdd85 | 1178 | Int_t * parentArray = new Int_t[fMaxTrack] ; |
7f3091e7 | 1179 | memset(parentArray,-1,sizeof(Int_t)*fMaxTrack); |
af5bdd85 | 1180 | Float_t * dEParentArray = new Float_t[fMaxTrack] ; |
7f3091e7 | 1181 | memset(dEParentArray,-1,sizeof(Int_t)*fMaxTrack); |
2ebdefe6 | 1182 | |
87cdc3be | 1183 | Int_t index ; |
1184 | for ( index = 0 ; index < GetDigitsMultiplicity() ; index++ ) { // all digits | |
94478418 | 1185 | if (fDigitsList[index] >= digits->GetEntries() || fDigitsList[index] < 0) |
2ebdefe6 | 1186 | AliError(Form("Trying to get invalid digit %d (idx in WriteRecPoint %d)",fDigitsList[index],index)); |
87cdc3be | 1187 | digit = dynamic_cast<AliEMCALDigit *>(digits->At( fDigitsList[index] )) ; |
2ebdefe6 | 1188 | if(!digit) { |
1189 | AliError("No Digit!!"); | |
1190 | continue; | |
1191 | } | |
1192 | ||
87cdc3be | 1193 | Int_t nparents = digit->GetNiparent() ; |
5c0368b8 | 1194 | if ( nparents == 0 ) continue ; |
2ebdefe6 | 1195 | |
87cdc3be | 1196 | Int_t jndex ; |
1197 | for ( jndex = 0 ; jndex < nparents ; jndex++ ) { // all primaries in digit | |
1198 | if ( fMulParent > fMaxParent ) { | |
2ebdefe6 | 1199 | fMulTrack = - 1 ; |
1200 | Error("EvalParents", "increase fMaxParent") ; | |
1201 | break ; | |
87cdc3be | 1202 | } |
af5bdd85 | 1203 | Int_t newParent = digit->GetIparent(jndex+1) ; |
1204 | Float_t newdEParent = digit->GetDEParent(jndex+1) ; | |
87cdc3be | 1205 | Int_t kndex ; |
1206 | Bool_t already = kFALSE ; | |
f1d429fd | 1207 | for ( kndex = 0 ; kndex < fMulParent ; kndex++ ) { //check if not already stored |
2ebdefe6 | 1208 | if ( newParent == parentArray[kndex] ){ |
1209 | dEParentArray[kndex] += newdEParent; | |
1210 | already = kTRUE ; | |
1211 | break ; | |
1212 | } | |
87cdc3be | 1213 | } // end of check |
94478418 | 1214 | if ( !already && (fMulParent < fMaxParent)) { // store it |
2ebdefe6 | 1215 | parentArray[fMulParent] = newParent ; |
1216 | dEParentArray[fMulParent] = newdEParent ; | |
1217 | fMulParent++ ; | |
87cdc3be | 1218 | } // store it |
1219 | } // all parents in digit | |
87cdc3be | 1220 | } // all digits |
2ebdefe6 | 1221 | |
27e2a47c | 1222 | if (fMulParent>0) { |
af5bdd85 | 1223 | Int_t *sortIdx = new Int_t[fMulParent]; |
1224 | TMath::Sort(fMulParent,dEParentArray,sortIdx); | |
1225 | for(index = 0; index < fMulParent; index++) { | |
1226 | fParentsList[index] = parentArray[sortIdx[index]] ; | |
1227 | fDEParentsList[index] = dEParentArray[sortIdx[index]] ; | |
1228 | } | |
1229 | delete [] sortIdx; | |
27e2a47c | 1230 | } |
2ebdefe6 | 1231 | |
af5bdd85 | 1232 | delete [] parentArray; |
1233 | delete [] dEParentArray; | |
87cdc3be | 1234 | } |
1235 | ||
70a93198 | 1236 | //____________________________________________________________________________ |
1237 | void AliEMCALRecPoint::GetLocalPosition(TVector3 & lpos) const | |
1238 | { | |
9aa6a5f6 | 1239 | // returns the position of the cluster in the local reference system |
1240 | // of the sub-detector | |
70a93198 | 1241 | |
9aa6a5f6 | 1242 | lpos = fLocPos; |
70a93198 | 1243 | } |
1244 | ||
ab48128d | 1245 | //____________________________________________________________________________ |
1246 | void AliEMCALRecPoint::GetGlobalPosition(TVector3 & gpos) const | |
1247 | { | |
1248 | // returns the position of the cluster in the global reference system of ALICE | |
70a93198 | 1249 | // These are now the Cartesian X, Y and Z |
e52475ed | 1250 | // cout<<" geom "<<geom<<endl; |
25bb3dcb | 1251 | // fGeomPtr->GetGlobal(fLocPos, gpos, fSuperModuleNumber); |
1252 | gpos = fGlobPos; | |
1253 | ||
9aa6a5f6 | 1254 | } |
1255 | ||
1256 | //____________________________________________________________________________ | |
7cfcebd3 | 1257 | //void AliEMCALRecPoint::GetGlobalPosition(TVector3 & gpos, TMatrixF & gmat) const |
1258 | //{ | |
1259 | // // returns the position of the cluster in the global reference system of ALICE | |
1260 | // // These are now the Cartesian X, Y and Z | |
1261 | // // cout<<" geom "<<geom<<endl; | |
1262 | // | |
1263 | // //To be implemented | |
1264 | // fGeomPtr->GetGlobalEMCAL(this, gpos, gmat); | |
1265 | // | |
1266 | //} | |
9aa6a5f6 | 1267 | |
1268 | //_____________________________________________________________________________ | |
1269 | void AliEMCALRecPoint::EvalLocal2TrackingCSTransform() | |
1270 | { | |
1271 | //Evaluates local to "tracking" c.s. transformation (B.P.). | |
1272 | //All evaluations should be completed before calling for this | |
1273 | //function. | |
1274 | //See ALICE PPR Chapter 5 p.18 for "tracking" c.s. definition, | |
1275 | //or just ask Jouri Belikov. :) | |
1276 | ||
1277 | SetVolumeId(AliGeomManager::LayerToVolUID(AliGeomManager::kEMCAL,GetSuperModuleNumber())); | |
1278 | ||
1279 | const TGeoHMatrix* tr2loc = GetTracking2LocalMatrix(); | |
1280 | if(!tr2loc) AliFatal(Form("No Tracking2LocalMatrix found.")); | |
1281 | ||
1282 | Double_t lxyz[3] = {fLocPos.X(),fLocPos.Y(),fLocPos.Z()}; | |
1283 | Double_t txyz[3] = {0,0,0}; | |
1284 | ||
1285 | tr2loc->MasterToLocal(lxyz,txyz); | |
1286 | SetX(txyz[0]); SetY(txyz[1]); SetZ(txyz[2]); | |
1287 | ||
1288 | if(AliLog::GetGlobalDebugLevel()>0) { | |
7cfcebd3 | 1289 | TVector3 gpos; //TMatrixF gmat; |
1290 | //GetGlobalPosition(gpos,gmat); //Not doing anythin special, replace by next line. | |
1291 | fGeomPtr->GetGlobal(fLocPos, gpos, GetSuperModuleNumber()); | |
1292 | ||
9aa6a5f6 | 1293 | Float_t gxyz[3]; |
1294 | GetGlobalXYZ(gxyz); | |
1295 | AliInfo(Form("lCS-->(%.3f,%.3f,%.3f), tCS-->(%.3f,%.3f,%.3f), gCS-->(%.3f,%.3f,%.3f), gCScalc-\ | |
1296 | ->(%.3f,%.3f,%.3f), supermodule %d", | |
1297 | fLocPos.X(),fLocPos.Y(),fLocPos.Z(), | |
1298 | GetX(),GetY(),GetZ(), | |
1299 | gpos.X(),gpos.Y(),gpos.Z(), | |
1300 | gxyz[0],gxyz[1],gxyz[2],GetSuperModuleNumber())); | |
1301 | } | |
1302 | ||
70a93198 | 1303 | } |
1304 | ||
1305 | //____________________________________________________________________________ | |
1306 | Float_t AliEMCALRecPoint::GetMaximalEnergy(void) const | |
1307 | { | |
1308 | // Finds the maximum energy in the cluster | |
ab48128d | 1309 | |
70a93198 | 1310 | Float_t menergy = 0. ; |
1311 | ||
1312 | Int_t iDigit; | |
70a93198 | 1313 | for(iDigit=0; iDigit<fMulDigit; iDigit++) { |
1314 | ||
1315 | if(fEnergyList[iDigit] > menergy) | |
1316 | menergy = fEnergyList[iDigit] ; | |
1317 | } | |
1318 | return menergy ; | |
ab48128d | 1319 | } |
1320 | ||
25bb3dcb | 1321 | //____________________________________________________________________________ |
1322 | Int_t AliEMCALRecPoint::GetMaximalEnergyIndex(void) const | |
1323 | { | |
1324 | // Finds the maximum energy in the cluster | |
1325 | ||
1326 | Float_t menergy = 0. ; | |
44fe3410 | 1327 | Int_t mid = 0 ; |
25bb3dcb | 1328 | Int_t iDigit; |
1329 | ||
1330 | for(iDigit=0; iDigit<fMulDigit; iDigit++) { | |
1331 | ||
1332 | if(fEnergyList[iDigit] > menergy){ | |
1333 | menergy = fEnergyList[iDigit] ; | |
1334 | mid = iDigit ; | |
1335 | } | |
1336 | }//loop on cluster digits | |
1337 | ||
1338 | return mid ; | |
1339 | } | |
1340 | ||
1341 | ||
aad8e277 | 1342 | //____________________________________________________________________________ |
70a93198 | 1343 | Int_t AliEMCALRecPoint::GetMultiplicityAtLevel(Float_t H) const |
aad8e277 | 1344 | { |
70a93198 | 1345 | // Calculates the multiplicity of digits with energy larger than H*energy |
1346 | ||
1347 | Int_t multipl = 0 ; | |
1348 | Int_t iDigit ; | |
1349 | for(iDigit=0; iDigit<fMulDigit; iDigit++) { | |
1350 | ||
1351 | if(fEnergyList[iDigit] > H * fAmp) | |
1352 | multipl++ ; | |
1353 | } | |
1354 | return multipl ; | |
1355 | } | |
1356 | ||
1357 | //____________________________________________________________________________ | |
1358 | Int_t AliEMCALRecPoint::GetNumberOfLocalMax(AliEMCALDigit ** maxAt, Float_t * maxAtEnergy, | |
1359 | Float_t locMaxCut,TClonesArray * digits) const | |
1360 | { | |
1361 | // Calculates the number of local maxima in the cluster using fLocalMaxCut as the minimum | |
1362 | // energy difference between two local maxima | |
1363 | ||
53e430a3 | 1364 | AliEMCALDigit * digit = 0; |
1365 | AliEMCALDigit * digitN = 0; | |
70a93198 | 1366 | |
53e430a3 | 1367 | Int_t iDigitN = 0 ; |
1368 | Int_t iDigit = 0 ; | |
70a93198 | 1369 | |
1370 | for(iDigit = 0; iDigit < fMulDigit; iDigit++) | |
1371 | maxAt[iDigit] = (AliEMCALDigit*) digits->At(fDigitsList[iDigit]) ; | |
1372 | ||
1373 | for(iDigit = 0 ; iDigit < fMulDigit; iDigit++) { | |
1374 | if(maxAt[iDigit]) { | |
1375 | digit = maxAt[iDigit] ; | |
1376 | ||
1377 | for(iDigitN = 0; iDigitN < fMulDigit; iDigitN++) { | |
53e430a3 | 1378 | digitN = (AliEMCALDigit *) digits->At(fDigitsList[iDigitN]) ; |
70a93198 | 1379 | |
1380 | if ( AreNeighbours(digit, digitN) ) { | |
1381 | if (fEnergyList[iDigit] > fEnergyList[iDigitN] ) { | |
1382 | maxAt[iDigitN] = 0 ; | |
1383 | // but may be digit too is not local max ? | |
1384 | if(fEnergyList[iDigit] < fEnergyList[iDigitN] + locMaxCut) | |
1385 | maxAt[iDigit] = 0 ; | |
1386 | } | |
1387 | else { | |
1388 | maxAt[iDigit] = 0 ; | |
1389 | // but may be digitN too is not local max ? | |
1390 | if(fEnergyList[iDigit] > fEnergyList[iDigitN] - locMaxCut) | |
1391 | maxAt[iDigitN] = 0 ; | |
1392 | } | |
1393 | } // if Areneighbours | |
1394 | } // while digitN | |
1395 | } // slot not empty | |
1396 | } // while digit | |
1397 | ||
1398 | iDigitN = 0 ; | |
1399 | for(iDigit = 0; iDigit < fMulDigit; iDigit++) { | |
1400 | if(maxAt[iDigit] ){ | |
1401 | maxAt[iDigitN] = maxAt[iDigit] ; | |
1402 | maxAtEnergy[iDigitN] = fEnergyList[iDigit] ; | |
1403 | iDigitN++ ; | |
1404 | } | |
1405 | } | |
1406 | return iDigitN ; | |
1407 | } | |
4635df1f | 1408 | |
1409 | //____________________________________________________________________________ | |
1410 | Int_t AliEMCALRecPoint::GetPrimaryIndex() const | |
1411 | { | |
1412 | // Get the primary track index in TreeK which deposits the most energy | |
af5bdd85 | 1413 | // in Digits which forms RecPoint. |
4635df1f | 1414 | |
af5bdd85 | 1415 | if (fMulTrack) |
1416 | return fTracksList[0]; | |
1417 | return -12345; | |
4635df1f | 1418 | } |
1419 | ||
70a93198 | 1420 | //____________________________________________________________________________ |
1421 | void AliEMCALRecPoint::EvalTime(TClonesArray * digits){ | |
1422 | // time is set to the time of the digit with the maximum energy | |
1423 | ||
53e430a3 | 1424 | Float_t maxE = 0; |
1425 | Int_t maxAt = 0; | |
70a93198 | 1426 | for(Int_t idig=0; idig < fMulDigit; idig++){ |
1427 | if(fEnergyList[idig] > maxE){ | |
53e430a3 | 1428 | maxE = fEnergyList[idig] ; |
70a93198 | 1429 | maxAt = idig; |
1430 | } | |
1431 | } | |
1432 | fTime = ((AliEMCALDigit*) digits->At(fDigitsList[maxAt]))->GetTime() ; | |
aad8e277 | 1433 | |
aad8e277 | 1434 | } |
ab48128d | 1435 | |
1436 | //______________________________________________________________________________ | |
1437 | void AliEMCALRecPoint::Paint(Option_t *) | |
1438 | { | |
1439 | // Paint this ALiRecPoint as a TMarker with its current attributes | |
1440 | ||
1441 | TVector3 pos(0.,0.,0.) ; | |
1442 | GetLocalPosition(pos) ; | |
1443 | Coord_t x = pos.X() ; | |
1444 | Coord_t y = pos.Z() ; | |
1445 | Color_t markercolor = 1 ; | |
53e430a3 | 1446 | Size_t markersize = 1.; |
ab48128d | 1447 | Style_t markerstyle = 5 ; |
1448 | ||
1449 | if (!gPad->IsBatch()) { | |
1450 | gVirtualX->SetMarkerColor(markercolor) ; | |
1451 | gVirtualX->SetMarkerSize (markersize) ; | |
1452 | gVirtualX->SetMarkerStyle(markerstyle) ; | |
1453 | } | |
1454 | gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ; | |
1455 | gPad->PaintPolyMarker(1,&x,&y,"") ; | |
1456 | } | |
70a93198 | 1457 | |
9aa6a5f6 | 1458 | //_____________________________________________________________________ |
1ae500a2 | 1459 | Double_t AliEMCALRecPoint::TmaxInCm(const Double_t e , const Int_t key) |
1460 | { | |
9aa6a5f6 | 1461 | // e energy in GeV) |
1ae500a2 | 1462 | // key = 0(gamma, default) |
1463 | // != 0(electron) | |
47583f1b | 1464 | const Double_t ca = 4.82; // shower max parameter - first guess; ca=TMath::Log(1000./8.07) |
47583f1b | 1465 | Double_t tmax = 0.; // position of electromagnetic shower max in cm |
1ae500a2 | 1466 | |
171d2441 | 1467 | Double_t x0 = 1.31; // radiation lenght (cm) |
1468 | //If old geometry in use | |
1469 | if(!((fGeomPtr->GetEMCGeometry()->GetGeoName()).Contains("V1"))) x0 = 1.28; | |
1470 | ||
1ae500a2 | 1471 | if(e>0.1) { |
1472 | tmax = TMath::Log(e) + ca; | |
1473 | if (key==0) tmax += 0.5; | |
1474 | else tmax -= 0.5; | |
37890aaf | 1475 | tmax *= x0; // convert to cm |
1ae500a2 | 1476 | } |
1477 | return tmax; | |
1478 | } | |
1479 | ||
70a93198 | 1480 | //______________________________________________________________________________ |
1481 | Float_t AliEMCALRecPoint::EtaToTheta(Float_t arg) const | |
1482 | { | |
1483 | //Converts Theta (Radians) to Eta(Radians) | |
1484 | return (2.*TMath::ATan(TMath::Exp(-arg))); | |
1485 | } | |
1486 | ||
1487 | //______________________________________________________________________________ | |
1488 | Float_t AliEMCALRecPoint::ThetaToEta(Float_t arg) const | |
1489 | { | |
1490 | //Converts Eta (Radians) to Theta(Radians) | |
1491 | return (-1 * TMath::Log(TMath::Tan(0.5 * arg))); | |
1492 | } | |
261b1065 | 1493 | |
1494 | //____________________________________________________________________________ | |
e1a51e6e | 1495 | void AliEMCALRecPoint::Print(Option_t *opt) const |
261b1065 | 1496 | { |
1497 | // Print the list of digits belonging to the cluster | |
e1a51e6e | 1498 | if(strlen(opt)==0) return; |
261b1065 | 1499 | TString message ; |
4800667c | 1500 | message = "AliEMCALRecPoint:\n" ; |
261b1065 | 1501 | message += " digits # = " ; |
d8c2bd69 | 1502 | AliInfo(message.Data()) ; |
261b1065 | 1503 | |
1504 | Int_t iDigit; | |
1505 | for(iDigit=0; iDigit<fMulDigit; iDigit++) | |
1506 | printf(" %d ", fDigitsList[iDigit] ) ; | |
e52475ed | 1507 | printf("\n"); |
1508 | ||
d8c2bd69 | 1509 | AliInfo(" Energies = ") ; |
261b1065 | 1510 | for(iDigit=0; iDigit<fMulDigit; iDigit++) |
1511 | printf(" %f ", fEnergyList[iDigit] ) ; | |
e52475ed | 1512 | printf("\n"); |
1513 | ||
d8c2bd69 | 1514 | AliInfo("\n Abs Ids = ") ; |
e52475ed | 1515 | for(iDigit=0; iDigit<fMulDigit; iDigit++) |
1516 | printf(" %i ", fAbsIdList[iDigit] ) ; | |
1517 | printf("\n"); | |
1518 | ||
d8c2bd69 | 1519 | AliInfo(" Primaries ") ; |
261b1065 | 1520 | for(iDigit = 0;iDigit < fMulTrack; iDigit++) |
1521 | printf(" %d ", fTracksList[iDigit]) ; | |
e52475ed | 1522 | |
1523 | printf("\n Local x %6.2f y %7.2f z %7.1f \n", fLocPos[0], fLocPos[1], fLocPos[2]); | |
1524 | ||
85c60a8e | 1525 | message = " ClusterType = %d" ; |
1526 | message += " Multiplicity = %d" ; | |
261b1065 | 1527 | message += " Cluster Energy = %f" ; |
1528 | message += " Core energy = %f" ; | |
1529 | message += " Core radius = %f" ; | |
1530 | message += " Number of primaries %d" ; | |
1531 | message += " Stored at position %d" ; | |
d8c2bd69 | 1532 | AliInfo(Form(message.Data(), fClusterType, fMulDigit, fAmp, fCoreEnergy, fCoreRadius, fMulTrack, GetIndexInList()) ) ; |
261b1065 | 1533 | } |
1d46d1f6 | 1534 | |
9aa6a5f6 | 1535 | //___________________________________________________________ |
1d46d1f6 | 1536 | Double_t AliEMCALRecPoint::GetPointEnergy() const |
1537 | { | |
37890aaf | 1538 | //Returns energy .... |
47583f1b | 1539 | Double_t e=0.0; |
1d46d1f6 | 1540 | for(int ic=0; ic<GetMultiplicity(); ic++) e += double(fEnergyList[ic]); |
1541 | return e; | |
1542 | } |