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