]>
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 | |
d64c959b | 19 | //*-- Author: Yves Schutz (SUBATECH) |
70a93198 | 20 | //*-- Author: Dmitri Peressounko (RRC KI & SUBATECH) |
21 | //*-- Author: Heather Gray (LBL) merged AliEMCALRecPoint and AliEMCALTowerRecPoint 02/04 | |
ab48128d | 22 | |
23 | // --- ROOT system --- | |
24 | #include "TPad.h" | |
d64c959b | 25 | #include "TGraph.h" |
26 | #include "TPaveText.h" | |
ab48128d | 27 | #include "TClonesArray.h" |
ff1e7e2f | 28 | #include "TMath.h" |
ab48128d | 29 | |
30 | // --- Standard library --- | |
ab48128d | 31 | |
32 | // --- AliRoot header files --- | |
70a93198 | 33 | #include "AliGenerator.h" |
ab48128d | 34 | #include "AliEMCALGeometry.h" |
35 | #include "AliEMCALDigit.h" | |
36 | #include "AliEMCALRecPoint.h" | |
37 | #include "AliEMCALGetter.h" | |
38 | ||
39 | ClassImp(AliEMCALRecPoint) | |
40 | ||
41 | ||
42 | //____________________________________________________________________________ | |
43 | AliEMCALRecPoint::AliEMCALRecPoint() | |
44 | : AliRecPoint() | |
45 | { | |
46 | // ctor | |
692088ae | 47 | fMaxTrack = 0 ; |
70a93198 | 48 | fMulDigit = 0 ; |
87cdc3be | 49 | fMaxParent = 0; |
50 | fMulParent = 0; | |
70a93198 | 51 | fAmp = 0. ; |
52 | fCoreEnergy = 0 ; | |
53 | fEnergyList = 0 ; | |
87cdc3be | 54 | fParentsList = 0; |
70a93198 | 55 | fTime = 0. ; |
56 | fLocPos.SetX(0.) ; //Local position should be evaluated | |
57 | fCoreRadius = 10; //HG Check this | |
ab48128d | 58 | } |
59 | ||
60 | //____________________________________________________________________________ | |
61 | AliEMCALRecPoint::AliEMCALRecPoint(const char * opt) : AliRecPoint(opt) | |
62 | { | |
63 | // ctor | |
ff1e7e2f | 64 | fMaxTrack = 1000 ; |
65 | fMaxParent = 1000; | |
87cdc3be | 66 | fMulDigit = 0 ; |
67 | fMulParent = 0; | |
70a93198 | 68 | fAmp = 0. ; |
69 | fCoreEnergy = 0 ; | |
70 | fEnergyList = 0 ; | |
87cdc3be | 71 | fParentsList = new Int_t[fMaxParent]; |
70a93198 | 72 | fTime = -1. ; |
73 | fLocPos.SetX(1000000.) ; //Local position should be evaluated | |
74 | fCoreRadius = 10; //HG Check this | |
75 | } | |
76 | //____________________________________________________________________________ | |
77 | AliEMCALRecPoint::~AliEMCALRecPoint() | |
78 | { | |
79 | // dtor | |
80 | if ( fEnergyList ) | |
81 | delete[] fEnergyList ; | |
87cdc3be | 82 | if ( fParentsList) |
83 | delete[] fParentsList; | |
70a93198 | 84 | } |
85 | ||
86 | //____________________________________________________________________________ | |
87 | void AliEMCALRecPoint::AddDigit(AliEMCALDigit & digit, Float_t Energy) | |
88 | { | |
89 | // Adds a digit to the RecPoint | |
90 | // and accumulates the total amplitude and the multiplicity | |
91 | ||
92 | if(fEnergyList == 0) | |
93 | fEnergyList = new Float_t[fMaxDigit]; | |
94 | ||
95 | if ( fMulDigit >= fMaxDigit ) { // increase the size of the lists | |
96 | fMaxDigit*=2 ; | |
a64a06d6 | 97 | Int_t * tempo = new Int_t[fMaxDigit]; |
98 | Float_t * tempoE = new Float_t[fMaxDigit]; | |
70a93198 | 99 | |
100 | Int_t index ; | |
101 | for ( index = 0 ; index < fMulDigit ; index++ ){ | |
102 | tempo[index] = fDigitsList[index] ; | |
103 | tempoE[index] = fEnergyList[index] ; | |
104 | } | |
105 | ||
106 | delete [] fDigitsList ; | |
a64a06d6 | 107 | fDigitsList = new Int_t[fMaxDigit]; |
70a93198 | 108 | |
109 | delete [] fEnergyList ; | |
a64a06d6 | 110 | fEnergyList = new Float_t[fMaxDigit]; |
70a93198 | 111 | |
112 | for ( index = 0 ; index < fMulDigit ; index++ ){ | |
113 | fDigitsList[index] = tempo[index] ; | |
114 | fEnergyList[index] = tempoE[index] ; | |
115 | } | |
116 | ||
117 | delete [] tempo ; | |
118 | delete [] tempoE ; | |
119 | } // if | |
120 | ||
121 | fDigitsList[fMulDigit] = digit.GetIndexInList() ; | |
122 | fEnergyList[fMulDigit] = Energy ; | |
123 | fMulDigit++ ; | |
124 | fAmp += Energy ; | |
125 | ||
126 | } | |
127 | //____________________________________________________________________________ | |
128 | Bool_t AliEMCALRecPoint::AreNeighbours(AliEMCALDigit * digit1, AliEMCALDigit * digit2 ) const | |
129 | { | |
130 | // Tells if (true) or not (false) two digits are neighbours | |
131 | // A neighbour is defined as being two digits which share a corner | |
132 | ||
133 | Bool_t areNeighbours = kFALSE ; | |
134 | ||
135 | AliEMCALGeometry * geom = (AliEMCALGetter::Instance())->EMCALGeometry(); | |
136 | ||
137 | Int_t relid1[2] ; | |
138 | geom->AbsToRelNumbering(digit1->GetId(), relid1) ; | |
139 | ||
140 | Int_t relid2[2] ; | |
141 | geom->AbsToRelNumbering(digit2->GetId(), relid2) ; | |
142 | ||
143 | Int_t rowdiff = TMath::Abs( relid1[0] - relid2[0] ) ; | |
144 | Int_t coldiff = TMath::Abs( relid1[1] - relid2[1] ) ; | |
145 | ||
146 | if (( coldiff <= 1 ) && ( rowdiff <= 1 ) && (coldiff + rowdiff > 0)) | |
147 | areNeighbours = kTRUE ; | |
ab48128d | 148 | |
70a93198 | 149 | return areNeighbours; |
150 | } | |
151 | ||
152 | //____________________________________________________________________________ | |
153 | Int_t AliEMCALRecPoint::Compare(const TObject * obj) const | |
154 | { | |
155 | // Compares two RecPoints according to their position in the EMCAL modules | |
156 | ||
157 | Float_t delta = 1 ; //Width of "Sorting row". If you change this | |
158 | //value (what is senseless) change as well delta in | |
159 | //AliEMCALTrackSegmentMakerv* and other RecPoints... | |
160 | Int_t rv ; | |
161 | ||
162 | AliEMCALRecPoint * clu = (AliEMCALRecPoint *)obj ; | |
163 | ||
164 | TVector3 locpos1; | |
165 | GetLocalPosition(locpos1); | |
166 | TVector3 locpos2; | |
167 | clu->GetLocalPosition(locpos2); | |
168 | ||
169 | Int_t rowdif = (Int_t)TMath::Ceil(locpos1.X()/delta)-(Int_t)TMath::Ceil(locpos2.X()/delta) ; | |
170 | if (rowdif> 0) | |
171 | rv = 1 ; | |
172 | else if(rowdif < 0) | |
173 | rv = -1 ; | |
174 | else if(locpos1.Y()>locpos2.Y()) | |
175 | rv = -1 ; | |
176 | else | |
177 | rv = 1 ; | |
178 | ||
179 | return rv ; | |
ab48128d | 180 | } |
181 | ||
182 | //____________________________________________________________________________ | |
183 | Int_t AliEMCALRecPoint::DistancetoPrimitive(Int_t px, Int_t py) | |
184 | { | |
185 | // Compute distance from point px,py to a AliEMCALRecPoint considered as a Tmarker | |
186 | // Compute the closest distance of approach from point px,py to this marker. | |
187 | // The distance is computed in pixels units. | |
70a93198 | 188 | // HG Still need to update -> Not sure what this should achieve |
ab48128d | 189 | |
190 | TVector3 pos(0.,0.,0.) ; | |
70a93198 | 191 | GetLocalPosition(pos) ; |
ab48128d | 192 | Float_t x = pos.X() ; |
70a93198 | 193 | Float_t y = pos.Y() ; |
ab48128d | 194 | const Int_t kMaxDiff = 10; |
195 | Int_t pxm = gPad->XtoAbsPixel(x); | |
196 | Int_t pym = gPad->YtoAbsPixel(y); | |
197 | Int_t dist = (px-pxm)*(px-pxm) + (py-pym)*(py-pym); | |
198 | ||
199 | if (dist > kMaxDiff) return 9999; | |
200 | return dist; | |
201 | } | |
202 | ||
203 | //___________________________________________________________________________ | |
204 | void AliEMCALRecPoint::Draw(Option_t *option) | |
205 | { | |
206 | // Draw this AliEMCALRecPoint with its current attributes | |
207 | ||
208 | AppendPad(option); | |
209 | } | |
210 | ||
211 | //______________________________________________________________________________ | |
70a93198 | 212 | void AliEMCALRecPoint::ExecuteEvent(Int_t /*event*/, Int_t, Int_t) |
ab48128d | 213 | { |
214 | // Execute action corresponding to one event | |
215 | // This member function is called when a AliEMCALRecPoint is clicked with the locator | |
216 | // | |
217 | // If Left button is clicked on AliEMCALRecPoint, the digits are switched on | |
218 | // and switched off when the mouse button is released. | |
219 | ||
220 | // static Int_t pxold, pyold; | |
221 | ||
70a93198 | 222 | /* static TGraph * digitgraph = 0 ; |
ab48128d | 223 | static TPaveText* clustertext = 0 ; |
224 | ||
225 | if (!gPad->IsEditable()) return; | |
226 | ||
227 | switch (event) { | |
228 | ||
229 | ||
230 | case kButton1Down:{ | |
231 | AliEMCALDigit * digit ; | |
88cb7938 | 232 | AliEMCALGeometry * emcalgeom = (AliEMCALGetter::Instance())->EMCALGeometry() ; |
ab48128d | 233 | |
234 | Int_t iDigit; | |
70a93198 | 235 | Int_t relid[2] ; |
ab48128d | 236 | |
237 | const Int_t kMulDigit=AliEMCALRecPoint::GetDigitsMultiplicity() ; | |
238 | Float_t * xi = new Float_t [kMulDigit] ; | |
239 | Float_t * zi = new Float_t [kMulDigit] ; | |
240 | ||
241 | for(iDigit = 0; iDigit < kMulDigit; iDigit++) { | |
242 | Fatal("AliEMCALRecPoint::ExecuteEvent", " -> Something wrong with the code"); | |
243 | digit = 0 ; //dynamic_cast<AliEMCALDigit *>((fDigitsList)[iDigit]); | |
244 | emcalgeom->AbsToRelNumbering(digit->GetId(), relid) ; | |
245 | emcalgeom->PosInAlice(relid, xi[iDigit], zi[iDigit]) ; | |
246 | } | |
247 | ||
248 | if (!digitgraph) { | |
249 | digitgraph = new TGraph(fMulDigit,xi,zi); | |
250 | digitgraph-> SetMarkerStyle(5) ; | |
251 | digitgraph-> SetMarkerSize(1.) ; | |
252 | digitgraph-> SetMarkerColor(1) ; | |
253 | digitgraph-> Draw("P") ; | |
254 | } | |
255 | if (!clustertext) { | |
256 | ||
257 | TVector3 pos(0.,0.,0.) ; | |
258 | GetLocalPosition(pos) ; | |
259 | clustertext = new TPaveText(pos.X()-10,pos.Z()+10,pos.X()+50,pos.Z()+35,"") ; | |
260 | Text_t line1[40] ; | |
261 | Text_t line2[40] ; | |
262 | sprintf(line1,"Energy=%1.2f GeV",GetEnergy()) ; | |
263 | sprintf(line2,"%d Digits",GetDigitsMultiplicity()) ; | |
264 | clustertext ->AddText(line1) ; | |
265 | clustertext ->AddText(line2) ; | |
266 | clustertext ->Draw(""); | |
267 | } | |
268 | gPad->Update() ; | |
9e5d2067 | 269 | Print("") ; |
ab48128d | 270 | delete[] xi ; |
271 | delete[] zi ; | |
272 | } | |
273 | ||
274 | break; | |
275 | ||
276 | case kButton1Up: | |
277 | if (digitgraph) { | |
278 | delete digitgraph ; | |
279 | digitgraph = 0 ; | |
280 | } | |
281 | if (clustertext) { | |
282 | delete clustertext ; | |
283 | clustertext = 0 ; | |
284 | } | |
285 | ||
286 | break; | |
287 | ||
70a93198 | 288 | }*/ |
289 | } | |
290 | //____________________________________________________________________________ | |
291 | void AliEMCALRecPoint::EvalAll(Float_t logWeight,TClonesArray * digits) | |
292 | { | |
293 | // Evaluates all shower parameters | |
294 | ||
295 | EvalLocalPosition(logWeight, digits) ; | |
296 | EvalElipsAxis(logWeight, digits) ; | |
297 | EvalDispersion(logWeight, digits) ; | |
298 | EvalCoreEnergy(logWeight, digits); | |
299 | EvalTime(digits) ; | |
300 | ||
87cdc3be | 301 | EvalPrimaries(digits) ; |
302 | EvalParents(digits); | |
70a93198 | 303 | } |
304 | ||
305 | //____________________________________________________________________________ | |
306 | void AliEMCALRecPoint::EvalDispersion(Float_t logWeight, TClonesArray * digits) | |
307 | { | |
308 | // Calculates the dispersion of the shower at the origin of the RecPoint | |
309 | ||
310 | Float_t d = 0. ; | |
311 | Float_t wtot = 0. ; | |
312 | ||
313 | AliEMCALDigit * digit ; | |
314 | ||
315 | AliEMCALGeometry * geom = (AliEMCALGetter::Instance())->EMCALGeometry(); | |
316 | ||
317 | // Calculates the centre of gravity in the local EMCAL-module coordinates | |
318 | Int_t iDigit; | |
319 | ||
320 | if (!fLocPos.X() || !fLocPos.Y()) | |
321 | EvalLocalPosition(logWeight, digits) ; | |
322 | ||
323 | const Float_t kDeg2Rad = TMath::DegToRad() ; | |
324 | ||
325 | Float_t cluEta = fLocPos.X() ; | |
326 | Float_t cluPhi = fLocPos.Y() ; | |
327 | Float_t cluR = fLocPos.Z() ; | |
328 | ||
329 | if (gDebug == 2) | |
330 | printf("EvalDispersion: eta,phi,r = %f,%f,%f", cluEta, cluPhi, cluR) ; | |
331 | ||
332 | // Calculates the dispersion in coordinates | |
333 | wtot = 0.; | |
334 | for(iDigit=0; iDigit < fMulDigit; iDigit++) { | |
335 | digit = (AliEMCALDigit *) digits->At(fDigitsList[iDigit]) ; | |
336 | Float_t etai = 0.; | |
337 | Float_t phii = 0.; | |
338 | geom->EtaPhiFromIndex(digit->GetId(), etai, phii); | |
339 | phii = phii * kDeg2Rad; | |
340 | if (gDebug == 2) | |
341 | printf("EvalDispersion: id = %d, etai,phii = %f,%f", digit->GetId(), etai, phii) ; | |
342 | ||
343 | Float_t w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ; | |
344 | d += w * ( (etai-cluEta)*(etai-cluEta) + (phii-cluPhi)*(phii-cluPhi) ) ; | |
345 | wtot+=w ; | |
ab48128d | 346 | } |
70a93198 | 347 | |
348 | if ( wtot > 0 ) | |
349 | d /= wtot ; | |
350 | else | |
351 | d = 0. ; | |
352 | ||
353 | fDispersion = TMath::Sqrt(d) ; | |
354 | ||
ab48128d | 355 | } |
70a93198 | 356 | |
ab48128d | 357 | //____________________________________________________________________________ |
70a93198 | 358 | void AliEMCALRecPoint::EvalLocalPosition(Float_t logWeight, TClonesArray * digits) |
88cb7938 | 359 | { |
70a93198 | 360 | // Calculates the center of gravity in the local EMCAL-module coordinates |
361 | Float_t wtot = 0. ; | |
362 | ||
363 | // Int_t relid[3] ; | |
364 | ||
365 | AliEMCALDigit * digit ; | |
366 | AliEMCALGeometry * geom = (AliEMCALGetter::Instance())->EMCALGeometry(); | |
367 | Int_t iDigit; | |
368 | Float_t cluEta = 0; | |
369 | Float_t cluPhi = 0; | |
370 | const Float_t kDeg2Rad = TMath::DegToRad(); | |
371 | ||
372 | for(iDigit=0; iDigit<fMulDigit; iDigit++) { | |
373 | digit = dynamic_cast<AliEMCALDigit *>(digits->At(fDigitsList[iDigit])) ; | |
374 | ||
375 | Float_t etai ; | |
376 | Float_t phii ; | |
377 | geom->EtaPhiFromIndex(digit->GetId(), etai, phii); | |
378 | phii = phii * kDeg2Rad; | |
379 | Float_t w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp ) ) ; | |
380 | cluEta += (etai * w) ; | |
381 | cluPhi += (phii * w ); | |
382 | wtot += w ; | |
383 | } | |
ab48128d | 384 | |
70a93198 | 385 | if ( wtot > 0 ) { |
386 | cluEta /= wtot ; | |
387 | cluPhi /= wtot ; | |
388 | } else { | |
389 | cluEta = -1 ; | |
390 | cluPhi = -1.; | |
391 | } | |
392 | ||
393 | fLocPos.SetX(cluEta); | |
394 | fLocPos.SetY(cluPhi); | |
395 | fLocPos.SetZ(geom->GetIP2ECASection()); | |
396 | ||
397 | if (gDebug==2) | |
398 | printf("EvalLocalPosition: eta,phi,r = %f,%f,%f", fLocPos.X(), fLocPos.Y(), fLocPos.Z()) ; | |
399 | fLocPosM = 0 ; | |
ab48128d | 400 | } |
401 | ||
70a93198 | 402 | //______________________________________________________________________________ |
403 | void AliEMCALRecPoint::EvalCoreEnergy(Float_t logWeight, TClonesArray * digits) | |
404 | { | |
405 | // This function calculates energy in the core, | |
406 | // i.e. within a radius rad = 3cm around the center. Beyond this radius | |
407 | // in accordance with shower profile the energy deposition | |
408 | // should be less than 2% | |
409 | ||
410 | AliEMCALDigit * digit ; | |
411 | const Float_t kDeg2Rad = TMath::DegToRad() ; | |
412 | AliEMCALGeometry * geom = (AliEMCALGetter::Instance())->EMCALGeometry(); | |
413 | Int_t iDigit; | |
414 | ||
415 | if (!fLocPos.X() || !fLocPos.Y() ) { | |
416 | EvalLocalPosition(logWeight, digits); | |
417 | } | |
418 | ||
419 | for(iDigit=0; iDigit < fMulDigit; iDigit++) { | |
420 | digit = (AliEMCALDigit *) ( digits->At(fDigitsList[iDigit]) ) ; | |
421 | Float_t etai = 0. ; | |
422 | Float_t phii = 0. ; | |
423 | geom->PosInAlice(digit->GetId(), etai, phii); | |
424 | phii = phii * kDeg2Rad; | |
425 | ||
426 | Float_t distance = TMath::Sqrt((etai-fLocPos.X())*(etai-fLocPos.X())+(phii-fLocPos.Y())*(phii-fLocPos.Y())) ; | |
427 | if(distance < fCoreRadius) | |
428 | fCoreEnergy += fEnergyList[iDigit] ; | |
429 | } | |
430 | ||
431 | } | |
ab48128d | 432 | //____________________________________________________________________________ |
70a93198 | 433 | void AliEMCALRecPoint::EvalElipsAxis(Float_t logWeight,TClonesArray * digits) |
ab48128d | 434 | { |
70a93198 | 435 | // Calculates the axis of the shower ellipsoid in eta and phi |
ab48128d | 436 | |
70a93198 | 437 | Double_t wtot = 0. ; |
438 | Double_t x = 0.; | |
439 | Double_t z = 0.; | |
440 | Double_t dxx = 0.; | |
441 | Double_t dzz = 0.; | |
442 | Double_t dxz = 0.; | |
ab48128d | 443 | |
ff1e7e2f | 444 | const Float_t kDeg2Rad = TMath::DegToRad(); |
70a93198 | 445 | AliEMCALDigit * digit ; |
446 | ||
447 | AliEMCALGeometry * geom = (AliEMCALGetter::Instance())->EMCALGeometry(); | |
448 | ||
449 | Int_t iDigit; | |
ab48128d | 450 | |
70a93198 | 451 | for(iDigit=0; iDigit<fMulDigit; iDigit++) { |
452 | digit = (AliEMCALDigit *) digits->At(fDigitsList[iDigit]) ; | |
453 | Float_t etai = 0. ; | |
454 | Float_t phii = 0. ; | |
455 | geom->EtaPhiFromIndex(digit->GetId(), etai, phii); | |
ff1e7e2f | 456 | phii = phii * kDeg2Rad; |
70a93198 | 457 | Double_t w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ; |
ff1e7e2f | 458 | |
70a93198 | 459 | dxx += w * etai * etai ; |
460 | x += w * etai ; | |
461 | dzz += w * phii * phii ; | |
462 | z += w * phii ; | |
ff1e7e2f | 463 | dxz += w * etai * phii ; |
70a93198 | 464 | wtot += w ; |
465 | } | |
ff1e7e2f | 466 | |
70a93198 | 467 | if ( wtot > 0 ) { |
468 | dxx /= wtot ; | |
469 | x /= wtot ; | |
470 | dxx -= x * x ; | |
471 | dzz /= wtot ; | |
472 | z /= wtot ; | |
473 | dzz -= z * z ; | |
474 | dxz /= wtot ; | |
475 | dxz -= x * z ; | |
ab48128d | 476 | |
70a93198 | 477 | fLambda[0] = 0.5 * (dxx + dzz) + TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ; |
478 | if(fLambda[0] > 0) | |
479 | fLambda[0] = TMath::Sqrt(fLambda[0]) ; | |
480 | else | |
481 | fLambda[0] = 0; | |
482 | ||
483 | fLambda[1] = 0.5 * (dxx + dzz) - TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ; | |
ff1e7e2f | 484 | |
70a93198 | 485 | if(fLambda[1] > 0) //To avoid exception if numerical errors lead to negative lambda. |
486 | fLambda[1] = TMath::Sqrt(fLambda[1]) ; | |
487 | else | |
488 | fLambda[1]= 0. ; | |
489 | } else { | |
490 | fLambda[0]= 0. ; | |
491 | fLambda[1]= 0. ; | |
ab48128d | 492 | } |
ff1e7e2f | 493 | |
494 | ||
ab48128d | 495 | } |
496 | ||
497 | //______________________________________________________________________________ | |
498 | void AliEMCALRecPoint::EvalPrimaries(TClonesArray * digits) | |
499 | { | |
500 | // Constructs the list of primary particles (tracks) which have contributed to this RecPoint | |
501 | ||
502 | AliEMCALDigit * digit ; | |
503 | Int_t * tempo = new Int_t[fMaxTrack] ; | |
504 | ||
505 | Int_t index ; | |
506 | for ( index = 0 ; index < GetDigitsMultiplicity() ; index++ ) { // all digits | |
507 | digit = dynamic_cast<AliEMCALDigit *>(digits->At( fDigitsList[index] )) ; | |
508 | Int_t nprimaries = digit->GetNprimary() ; | |
5c0368b8 | 509 | if ( nprimaries == 0 ) continue ; |
ab48128d | 510 | Int_t * newprimaryarray = new Int_t[nprimaries] ; |
511 | Int_t ii ; | |
512 | for ( ii = 0 ; ii < nprimaries ; ii++) | |
513 | newprimaryarray[ii] = digit->GetPrimary(ii+1) ; | |
514 | ||
515 | Int_t jndex ; | |
516 | for ( jndex = 0 ; jndex < nprimaries ; jndex++ ) { // all primaries in digit | |
517 | if ( fMulTrack > fMaxTrack ) { | |
f792c312 | 518 | fMulTrack = fMaxTrack ; |
9859bfc0 | 519 | Error("GetNprimaries", "increase fMaxTrack ") ; |
ab48128d | 520 | break ; |
521 | } | |
522 | Int_t newprimary = newprimaryarray[jndex] ; | |
523 | Int_t kndex ; | |
524 | Bool_t already = kFALSE ; | |
525 | for ( kndex = 0 ; kndex < fMulTrack ; kndex++ ) { //check if not already stored | |
526 | if ( newprimary == tempo[kndex] ){ | |
527 | already = kTRUE ; | |
528 | break ; | |
529 | } | |
530 | } // end of check | |
5c0368b8 | 531 | if ( !already && (fMulTrack < fMaxTrack)) { // store it |
ab48128d | 532 | tempo[fMulTrack] = newprimary ; |
533 | fMulTrack++ ; | |
534 | } // store it | |
535 | } // all primaries in digit | |
f792c312 | 536 | delete [] newprimaryarray ; |
ab48128d | 537 | } // all digits |
538 | ||
539 | ||
540 | fTracksList = new Int_t[fMulTrack] ; | |
541 | for(index = 0; index < fMulTrack; index++) | |
542 | fTracksList[index] = tempo[index] ; | |
543 | ||
f792c312 | 544 | delete [] tempo ; |
ab48128d | 545 | |
546 | } | |
7ee5c5be | 547 | |
87cdc3be | 548 | //______________________________________________________________________________ |
549 | void AliEMCALRecPoint::EvalParents(TClonesArray * digits) | |
550 | { | |
551 | // Constructs the list of parent particles (tracks) which have contributed to this RecPoint | |
552 | ||
553 | AliEMCALDigit * digit ; | |
554 | Int_t * tempo = new Int_t[fMaxParent] ; | |
555 | ||
556 | Int_t index ; | |
557 | for ( index = 0 ; index < GetDigitsMultiplicity() ; index++ ) { // all digits | |
558 | digit = dynamic_cast<AliEMCALDigit *>(digits->At( fDigitsList[index] )) ; | |
559 | Int_t nparents = digit->GetNiparent() ; | |
5c0368b8 | 560 | if ( nparents == 0 ) continue ; |
87cdc3be | 561 | Int_t * newparentarray = new Int_t[nparents] ; |
562 | Int_t ii ; | |
563 | for ( ii = 0 ; ii < nparents ; ii++) | |
564 | newparentarray[ii] = digit->GetIparent(ii+1) ; | |
565 | ||
566 | Int_t jndex ; | |
567 | for ( jndex = 0 ; jndex < nparents ; jndex++ ) { // all primaries in digit | |
568 | if ( fMulParent > fMaxParent ) { | |
569 | fMulTrack = - 1 ; | |
570 | Error("GetNiparent", "increase fMaxParent") ; | |
571 | break ; | |
572 | } | |
573 | Int_t newparent = newparentarray[jndex] ; | |
574 | Int_t kndex ; | |
575 | Bool_t already = kFALSE ; | |
f1d429fd | 576 | for ( kndex = 0 ; kndex < fMulParent ; kndex++ ) { //check if not already stored |
87cdc3be | 577 | if ( newparent == tempo[kndex] ){ |
578 | already = kTRUE ; | |
579 | break ; | |
580 | } | |
581 | } // end of check | |
5c0368b8 | 582 | if ( !already && (fMulTrack < fMaxTrack)) { // store it |
87cdc3be | 583 | tempo[fMulParent] = newparent ; |
584 | fMulParent++ ; | |
585 | } // store it | |
586 | } // all parents in digit | |
27e2a47c | 587 | delete [] newparentarray ; |
87cdc3be | 588 | } // all digits |
589 | ||
27e2a47c | 590 | if (fMulParent>0) { |
591 | fParentsList = new Int_t[fMulParent] ; | |
592 | for(index = 0; index < fMulParent; index++) | |
593 | fParentsList[index] = tempo[index] ; | |
594 | } | |
87cdc3be | 595 | |
27e2a47c | 596 | delete [] tempo ; |
87cdc3be | 597 | |
598 | } | |
599 | ||
70a93198 | 600 | //____________________________________________________________________________ |
601 | void AliEMCALRecPoint::GetLocalPosition(TVector3 & lpos) const | |
602 | { | |
603 | // returns the position of the cluster in the local reference system of ALICE | |
604 | // X = eta, Y = phi, Z = r (a constant for the EMCAL) | |
605 | ||
606 | lpos.SetX(fLocPos.X()) ; | |
607 | lpos.SetY(fLocPos.Y()) ; | |
608 | lpos.SetZ(fLocPos.Z()) ; | |
609 | } | |
610 | ||
ab48128d | 611 | //____________________________________________________________________________ |
612 | void AliEMCALRecPoint::GetGlobalPosition(TVector3 & gpos) const | |
613 | { | |
614 | // returns the position of the cluster in the global reference system of ALICE | |
70a93198 | 615 | // These are now the Cartesian X, Y and Z |
616 | ||
617 | AliEMCALGeometry * geom = (AliEMCALGetter::Instance())->EMCALGeometry(); | |
618 | Int_t absid = geom->TowerIndexFromEtaPhi(fLocPos.X(), TMath::RadToDeg()*fLocPos.Y()); | |
619 | geom->XYZFromIndex(absid, gpos); | |
620 | } | |
621 | ||
622 | //____________________________________________________________________________ | |
623 | Float_t AliEMCALRecPoint::GetMaximalEnergy(void) const | |
624 | { | |
625 | // Finds the maximum energy in the cluster | |
ab48128d | 626 | |
70a93198 | 627 | Float_t menergy = 0. ; |
628 | ||
629 | Int_t iDigit; | |
630 | ||
631 | for(iDigit=0; iDigit<fMulDigit; iDigit++) { | |
632 | ||
633 | if(fEnergyList[iDigit] > menergy) | |
634 | menergy = fEnergyList[iDigit] ; | |
635 | } | |
636 | return menergy ; | |
ab48128d | 637 | } |
638 | ||
aad8e277 | 639 | //____________________________________________________________________________ |
70a93198 | 640 | Int_t AliEMCALRecPoint::GetMultiplicityAtLevel(Float_t H) const |
aad8e277 | 641 | { |
70a93198 | 642 | // Calculates the multiplicity of digits with energy larger than H*energy |
643 | ||
644 | Int_t multipl = 0 ; | |
645 | Int_t iDigit ; | |
646 | for(iDigit=0; iDigit<fMulDigit; iDigit++) { | |
647 | ||
648 | if(fEnergyList[iDigit] > H * fAmp) | |
649 | multipl++ ; | |
650 | } | |
651 | return multipl ; | |
652 | } | |
653 | ||
654 | //____________________________________________________________________________ | |
655 | Int_t AliEMCALRecPoint::GetNumberOfLocalMax(AliEMCALDigit ** maxAt, Float_t * maxAtEnergy, | |
656 | Float_t locMaxCut,TClonesArray * digits) const | |
657 | { | |
658 | // Calculates the number of local maxima in the cluster using fLocalMaxCut as the minimum | |
659 | // energy difference between two local maxima | |
660 | ||
661 | AliEMCALDigit * digit ; | |
662 | AliEMCALDigit * digitN ; | |
663 | ||
664 | Int_t iDigitN ; | |
665 | Int_t iDigit ; | |
666 | ||
667 | for(iDigit = 0; iDigit < fMulDigit; iDigit++) | |
668 | maxAt[iDigit] = (AliEMCALDigit*) digits->At(fDigitsList[iDigit]) ; | |
669 | ||
670 | for(iDigit = 0 ; iDigit < fMulDigit; iDigit++) { | |
671 | if(maxAt[iDigit]) { | |
672 | digit = maxAt[iDigit] ; | |
673 | ||
674 | for(iDigitN = 0; iDigitN < fMulDigit; iDigitN++) { | |
675 | digitN = (AliEMCALDigit *) digits->At(fDigitsList[iDigitN]) ; | |
676 | ||
677 | if ( AreNeighbours(digit, digitN) ) { | |
678 | if (fEnergyList[iDigit] > fEnergyList[iDigitN] ) { | |
679 | maxAt[iDigitN] = 0 ; | |
680 | // but may be digit too is not local max ? | |
681 | if(fEnergyList[iDigit] < fEnergyList[iDigitN] + locMaxCut) | |
682 | maxAt[iDigit] = 0 ; | |
683 | } | |
684 | else { | |
685 | maxAt[iDigit] = 0 ; | |
686 | // but may be digitN too is not local max ? | |
687 | if(fEnergyList[iDigit] > fEnergyList[iDigitN] - locMaxCut) | |
688 | maxAt[iDigitN] = 0 ; | |
689 | } | |
690 | } // if Areneighbours | |
691 | } // while digitN | |
692 | } // slot not empty | |
693 | } // while digit | |
694 | ||
695 | iDigitN = 0 ; | |
696 | for(iDigit = 0; iDigit < fMulDigit; iDigit++) { | |
697 | if(maxAt[iDigit] ){ | |
698 | maxAt[iDigitN] = maxAt[iDigit] ; | |
699 | maxAtEnergy[iDigitN] = fEnergyList[iDigit] ; | |
700 | iDigitN++ ; | |
701 | } | |
702 | } | |
703 | return iDigitN ; | |
704 | } | |
705 | //____________________________________________________________________________ | |
706 | void AliEMCALRecPoint::EvalTime(TClonesArray * digits){ | |
707 | // time is set to the time of the digit with the maximum energy | |
708 | ||
709 | Float_t maxE = 0; | |
710 | Int_t maxAt = 0; | |
711 | for(Int_t idig=0; idig < fMulDigit; idig++){ | |
712 | if(fEnergyList[idig] > maxE){ | |
713 | maxE = fEnergyList[idig] ; | |
714 | maxAt = idig; | |
715 | } | |
716 | } | |
717 | fTime = ((AliEMCALDigit*) digits->At(fDigitsList[maxAt]))->GetTime() ; | |
aad8e277 | 718 | |
aad8e277 | 719 | } |
ab48128d | 720 | |
721 | //______________________________________________________________________________ | |
722 | void AliEMCALRecPoint::Paint(Option_t *) | |
723 | { | |
724 | // Paint this ALiRecPoint as a TMarker with its current attributes | |
725 | ||
726 | TVector3 pos(0.,0.,0.) ; | |
727 | GetLocalPosition(pos) ; | |
728 | Coord_t x = pos.X() ; | |
729 | Coord_t y = pos.Z() ; | |
730 | Color_t markercolor = 1 ; | |
731 | Size_t markersize = 1. ; | |
732 | Style_t markerstyle = 5 ; | |
733 | ||
734 | if (!gPad->IsBatch()) { | |
735 | gVirtualX->SetMarkerColor(markercolor) ; | |
736 | gVirtualX->SetMarkerSize (markersize) ; | |
737 | gVirtualX->SetMarkerStyle(markerstyle) ; | |
738 | } | |
739 | gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ; | |
740 | gPad->PaintPolyMarker(1,&x,&y,"") ; | |
741 | } | |
70a93198 | 742 | |
743 | //______________________________________________________________________________ | |
744 | Float_t AliEMCALRecPoint::EtaToTheta(Float_t arg) const | |
745 | { | |
746 | //Converts Theta (Radians) to Eta(Radians) | |
747 | return (2.*TMath::ATan(TMath::Exp(-arg))); | |
748 | } | |
749 | ||
750 | //______________________________________________________________________________ | |
751 | Float_t AliEMCALRecPoint::ThetaToEta(Float_t arg) const | |
752 | { | |
753 | //Converts Eta (Radians) to Theta(Radians) | |
754 | return (-1 * TMath::Log(TMath::Tan(0.5 * arg))); | |
755 | } | |
261b1065 | 756 | |
757 | //____________________________________________________________________________ | |
758 | void AliEMCALRecPoint::Print(Option_t *) const | |
759 | { | |
760 | // Print the list of digits belonging to the cluster | |
761 | ||
762 | TString message ; | |
763 | message = "AliPHOSEmcRecPoint:\n" ; | |
764 | message += " digits # = " ; | |
765 | Info("Print", message.Data()) ; | |
766 | ||
767 | Int_t iDigit; | |
768 | for(iDigit=0; iDigit<fMulDigit; iDigit++) | |
769 | printf(" %d ", fDigitsList[iDigit] ) ; | |
770 | ||
771 | Info("Print", " Energies = ") ; | |
772 | for(iDigit=0; iDigit<fMulDigit; iDigit++) | |
773 | printf(" %f ", fEnergyList[iDigit] ) ; | |
774 | printf("\n") ; | |
775 | Info("Print", " Primaries ") ; | |
776 | for(iDigit = 0;iDigit < fMulTrack; iDigit++) | |
777 | printf(" %d ", fTracksList[iDigit]) ; | |
778 | printf("\n") ; | |
779 | message = " Multiplicity = %d" ; | |
780 | message += " Cluster Energy = %f" ; | |
781 | message += " Core energy = %f" ; | |
782 | message += " Core radius = %f" ; | |
783 | message += " Number of primaries %d" ; | |
784 | message += " Stored at position %d" ; | |
785 | ||
786 | Info("Print", message.Data(), fMulDigit, fAmp, fCoreEnergy, fCoreRadius, fMulTrack, GetIndexInList() ) ; | |
787 | } |