1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //*-- Author: Boris Polichtchouk, IHEP
19 //////////////////////////////////////////////////////////////////////////////
20 // Reconstructed point operations for the Clusterization class for IHEP reconstruction.
21 // Performs clusterization (collects neighbouring active cells)
22 // It differs from AliPHOSClusterizerv1 in neighbour definition only
24 // ---- ROOT system ---
26 #include <TDirectory.h>
32 // --- AliRoot header files ---
34 #include "AliConfig.h"
35 #include "AliPHOSDigit.h"
36 #include "AliPHOSClusterizer.h"
37 #include "AliPHOSEvalRecPoint.h"
39 #include "AliPHOSLoader.h"
40 #include "AliPHOSRecCpvManager.h"
41 #include "AliPHOSRecEmcManager.h"
42 #include "AliPHOSDigitizer.h"
43 #include "AliPHOSGeometry.h"
45 // --- Standard library ---
48 ClassImp(AliPHOSEvalRecPoint)
50 AliPHOSEvalRecPoint::AliPHOSEvalRecPoint() :
55 fEventFolderName(AliConfig::GetDefaultEventFolderName())
60 AliPHOSEvalRecPoint::AliPHOSEvalRecPoint(Bool_t cpv, AliPHOSEvalRecPoint* parent) :
72 TObjArray* wPool = (TObjArray*)GetWorkingPool();
74 Fatal("ctor", "Couldn't find working pool") ;
77 fParent = wPool->IndexOf((TObject*)parent);
78 fChi2Dof = parent->Chi2Dof();
89 // Add itself to working pool
90 AddToWorkingPool((TObject*)this);
94 AliPHOSEvalRecPoint::AliPHOSEvalRecPoint(Int_t i, Bool_t cpv) :
99 fEventFolderName(AliConfig::GetDefaultEventFolderName())
102 AliPHOSEmcRecPoint* rp=0;
104 AliPHOSLoader* fLoader = AliPHOSLoader::GetPHOSLoader(fEventFolderName);
107 rp = (AliPHOSCpvRecPoint*)fLoader->CpvRecPoints()->At(i);
112 rp = (AliPHOSEmcRecPoint*)fLoader->EmcRecPoints()->At(i);
117 Int_t* digits = rp->GetDigitsList();
118 Float_t* energies = rp->GetEnergiesList();
119 Int_t nDigits = rp->GetMultiplicity();
121 for(Int_t iDigit=0; iDigit<nDigits; iDigit++) {
122 AliPHOSDigit* digit = (AliPHOSDigit*)fLoader->Digits()->At( digits[iDigit] );
123 Float_t eDigit = energies[iDigit];
124 this->AddDigit(*digit,eDigit);
128 rp->GetLocalPosition(locpos);
131 // Add itself to working pool
132 AddToWorkingPool((TObject*)this);
136 AliPHOSClusterizer* AliPHOSEvalRecPoint::GetClusterizer()
138 // returns clusterizer task
139 TFolder* aliceF = (TFolder*)gROOT->FindObjectAny("YSAlice");
140 TFolder* wPoolF = (TFolder*)aliceF->FindObject("WhiteBoard/RecPoints/PHOS/SmP");
141 AliPHOSClusterizer* clu = (AliPHOSClusterizer*)wPoolF->FindObject("PHOS:clu-v1");
143 Fatal("GetClusterizer", "Couldn't find Clusterizer") ;
149 Bool_t AliPHOSEvalRecPoint::TooClose(AliPHOSRecPoint* pt) const
151 // check if a rec.point pt is too close to this one
154 pt->GetLocalPosition(herPos);
155 this->GetLocalPosition(myPos);
156 Float_t dx = herPos.X() - myPos.X();
157 Float_t dz = herPos.Z() - myPos.Z();
158 Float_t dr = TMath::Sqrt(dx*dx + dz*dz);
160 if(dr<GetReconstructionManager()->MergeGammasMinDistanceCut())
167 Bool_t AliPHOSEvalRecPoint::NeedToSplit() const
169 // rec.point needs to be split
173 void AliPHOSEvalRecPoint::DeleteParent()
179 void AliPHOSEvalRecPoint::UpdateWorkingPool()
181 // update pool of rec.points
182 Int_t i; //loop variable
184 for(i=0; i<this->InWorkingPool(); i++) {
185 AliPHOSEvalRecPoint* parent = (AliPHOSEvalRecPoint*)GetFromWorkingPool(i);
187 Int_t nChild = parent->HasChild(children);
188 for(Int_t iChild=0; iChild<nChild; iChild++)
190 ((AliPHOSEvalRecPoint*)children.At(iChild))->DeleteParent();
194 RemoveFromWorkingPool(parent);
200 for(i=0; i<this->InWorkingPool(); i++) {
201 AliPHOSEvalRecPoint* weak = (AliPHOSEvalRecPoint*)GetFromWorkingPool(i);
202 if (weak->KillWeakPoint()) delete weak;
205 for(i=0; i<this->InWorkingPool(); i++) {
206 AliPHOSEvalRecPoint* close = (AliPHOSEvalRecPoint*)GetFromWorkingPool(i);
207 close->MergeClosePoint();
210 for(i=0; i<this->InWorkingPool(); i++)
211 ((AliPHOSEvalRecPoint*)AliPHOSEvalRecPoint::GetFromWorkingPool(i))->SetIndexInList(i);
215 Int_t AliPHOSEvalRecPoint::HasChild(TObjArray& children)
217 // returns the number of children
218 for(Int_t iChild=0; iChild<InWorkingPool(); iChild++)
220 AliPHOSEvalRecPoint* child = (AliPHOSEvalRecPoint*)GetFromWorkingPool(iChild);
221 TObject* parent = (TObject*)child->Parent();
222 TObject* me = (TObject*)this;
223 if(parent==me) children.Add(child);
226 return children.GetEntries();
229 void AliPHOSEvalRecPoint::Init()
232 AliPHOSClusterizer* clusterizer = GetClusterizer();
234 Fatal("Init", "Cannot get clusterizer") ;
237 TClonesArray* digits = AliPHOSLoader::GetPHOSLoader(fEventFolderName)->Digits();
241 logWeight = clusterizer->GetEmcLogWeight();
244 logWeight = clusterizer->GetCpvLogWeight();
247 TVector3 vtx(0.,0.,0.) ;
248 TVector3 inc(0.,0.,0.) ;
249 EvalLocalPosition(logWeight,vtx,digits,inc); // evaluate initial position
253 void AliPHOSEvalRecPoint::MakeJob()
255 // Reconstruction algoritm implementation.
257 AliPHOSRecManager* recMng = GetReconstructionManager();
264 Int_t nChild = HasChild(children);
268 if(Chi2Dof()>recMng->OneGamChisqCut()) SplitMergedShowers();
271 for(Int_t iChild=0; iChild<nChild; iChild++) {
272 AliPHOSEvalRecPoint* child = (AliPHOSEvalRecPoint*)children.At(iChild);
273 child->EvaluatePosition();
275 if(child->Chi2Dof()>recMng->OneGamChisqCut())
276 child->SplitMergedShowers();
281 void AliPHOSEvalRecPoint::InitTwoGam(Float_t* gamma1, Float_t* gamma2)
283 //Compute start values for two gamma fit algorithm.
284 // gamma1[0], gamma1[1], gamma1[2] are Energy,x,z of the reconstructed "gammas".
287 TVector3 lpos; // start point choosing.
288 GetLocalPosition(lpos);
289 Float_t xx = lpos.Z();
290 Float_t yy = lpos.X();
291 Float_t e = GetEnergy();
293 AliInfo(Form("(x,z,e)[old] = (%f, %f, %f)", yy, xx, e)) ;
300 AliPHOSDigit * digit ;
301 Int_t nDigits = GetMultiplicity();
302 Int_t * digits = GetDigitsList();
303 Float_t * energies = GetEnergiesList();
315 AliPHOSLoader* fLoader = AliPHOSLoader::GetPHOSLoader(fEventFolderName);
316 AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance() ;
318 Int_t iDigit; //loop variable
320 for(iDigit = 0 ; iDigit < nDigits ; iDigit ++)
322 digit = (AliPHOSDigit*)fLoader->Digits()->At( digits[iDigit] );
323 eDigit = energies[iDigit];
324 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
325 phosgeom->RelPosInModule(relid, iy, ix);
327 Float_t dx = ix - xx;
328 Float_t dy = iy - yy;
335 sqr = TMath::Sqrt(4.*exy*exy + (exx-eyy)*(exx-eyy));
336 Float_t euu = (exx+eyy+sqr)/2.;
337 if(sqr>1.e-10) cos2fi = (exx - eyy)/sqr;
338 Float_t cosfi = TMath::Sqrt((1.+cos2fi)/2.);
339 Float_t sinfi = TMath::Sqrt((1.-cos2fi)/2.);
340 if(exy<0) sinfi = -sinfi;
343 for(iDigit = 0 ; iDigit < nDigits ; iDigit ++)
345 digit = (AliPHOSDigit*)fLoader->Digits()->At( digits[iDigit] );
346 eDigit = energies[iDigit];
347 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
348 phosgeom->RelPosInModule(relid, iy, ix);
350 Float_t dx = ix - xx;
351 Float_t dy = iy - yy;
352 Float_t du = dx*cosfi + dy*sinfi;
353 eu3 += eDigit*du*du*du;
356 Float_t c = e*eu3*eu3/(euu*euu*euu)/2.;
358 if(eu3<0) sign = -1.;
359 Float_t r = 1.+ c + sign*TMath::Sqrt(2.*c + c*c);
361 if(TMath::Abs(r-1.)>0.1) u = eu3/euu*(r+1.)/(r-1.);
362 if(TMath::Abs(r-1.)<0.1) u = TMath::Sqrt(sqr/e/r)*(1.+r);
364 Float_t e2c = e/(1.+r);
366 Float_t u1 = -u/(1.+r);
369 Float_t x1c = xx+u1*cosfi;
370 Float_t y1c = yy+u1*sinfi;
371 Float_t x2c = xx+u2*cosfi;
372 Float_t y2c = yy+u2*sinfi;
374 // printf("e1c -> %f\n",e1c);
375 // printf("x1c -> %f\n",x1c);
376 // printf("y1c -> %f\n",y1c);
377 // printf("e2c -> %f\n",e2c);
378 // printf("x2c -> %f\n",x2c);
379 // printf("y2c -> %f\n",y2c);
391 void AliPHOSEvalRecPoint::TwoGam(Float_t* gamma1, Float_t* gamma2)
393 //Fitting algorithm for the two very closed gammas
394 //that merged into the cluster with one maximum.
395 // Starting points gamma1 and gamma2 must be provided before ( see InitTwoGam)
396 //Set chisquare of the fit.
399 Float_t st0 = GetReconstructionManager()->TwoGamInitialStep();
400 Float_t chmin = GetReconstructionManager()->TwoGamChisqMin();
401 Float_t emin = GetReconstructionManager()->TwoGamEmin();
402 Float_t stpmin = GetReconstructionManager()->TwoGamStepMin();
403 Int_t nIter = GetReconstructionManager()->TwoGamNumOfIterations(); // Number of iterations.
405 Float_t chisq = 100.; //Initial chisquare.
407 Int_t nadc = GetMultiplicity();
411 Int_t dof = nadc - 5;
413 Float_t chstop = chmin*dof;
423 Float_t ee1=0,xx1=0,yy1=0,ee2=0,xx2=0,yy2=0,cosi;
425 Float_t e1c = gamma1[0];
426 Float_t y1c = gamma1[1];
427 Float_t x1c = gamma1[2];
429 Float_t e2c = gamma2[0];
430 Float_t y2c = gamma2[1];
431 Float_t x2c = gamma2[2];
433 Float_t e = GetEnergy();
436 AliPHOSDigit * digit ;
437 Int_t nDigits = GetMultiplicity();
438 Int_t * digits = GetDigitsList();
439 Float_t * energies = GetEnergiesList();
445 AliPHOSLoader* fLoader = AliPHOSLoader::GetPHOSLoader(fEventFolderName);
446 AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance() ;
448 for(Int_t iter=0; iter<nIter; iter++)
457 for(Int_t iDigit = 0 ; iDigit < nDigits ; iDigit ++)
459 digit = (AliPHOSDigit*)fLoader->Digits()->At( digits[iDigit] );
460 eDigit = energies[iDigit];
461 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
462 phosgeom->RelPosInModule(relid, iy, ix);
467 Float_t dx1 = x1c - ix;
468 Float_t dy1 = y1c - iy;
470 GetReconstructionManager()->AG(e1c,dx1,dy1,a1,gx1,gy1);
472 Float_t dx2 = x2c - ix;
473 Float_t dy2 = y2c - iy;
475 GetReconstructionManager()->AG(e2c,dx2,dy2,a2,gx2,gy2);
478 // Float_t D = Const*a*(1. - a/e);
481 // // D = 9.; // ????
483 // Float_t da = a - eDigit;
484 // chisqc += da*da/D;
485 // Float_t dd = da/D;
486 // dd = dd*(2.-dd*Const*(1.-2.*a/e));
489 chisqc += GetReconstructionManager()->TwoGamChi2(a,eDigit,e,dd);
495 grec += (a1/e1c - a2/e2c)*e*dd;
499 Float_t grc = TMath::Sqrt(grx1c*grx1c + gry1c*gry1c + grx2c*grx2c + gry2c*gry2c);
500 if(grc<1.e-10) grc=1.e-10;
502 Float_t sc = 1. + chisqc/ch;
507 cosi = (grx1*grx1c + gry1*gry1c + grx2*grx2c + gry2*gry2c + gre*grec)/gr/grc;
508 st = st*sc/(1.4 - cosi);
530 Float_t step = st*gr;
532 AliInfo(Form("Iteration %d dof %d chisq/dof %f chstop/dof %f step %d stpmin %d",
533 iter, dof, ch/dof, chstop/dof, step, stpmin)) ;
539 Float_t de = st*gre*e;
543 if( (e1c>emin) && (e2c>emin) )
559 // if(ch>chisq*(nadc-2)-delch)
579 message = " (x,z,e)[1 fit] = (%f, %f, %f)\n" ;
580 message = " (x,z,e)[2 fit] = (%f, %f, %f)\n" ;
581 AliInfo(Form(message.Data(),
583 x2New, z2New, e2New)) ;
589 void AliPHOSEvalRecPoint::UnfoldTwoMergedPoints(Float_t* gamma1, Float_t* gamma2)
591 //Unfold TWO merged rec. points in the case when cluster has only one maximum,
592 //but it's fitting to the one gamma shower is too bad.
593 // Use TwoGam() to estimate the positions and energies of merged points.
599 Int_t* digits = GetDigitsList();
600 Int_t nDigits = GetMultiplicity();
601 Float_t* energies = GetEnergiesList();
602 Float_t* eFit = new Float_t[nDigits];
604 AliPHOSLoader* fLoader = AliPHOSLoader::GetPHOSLoader(fEventFolderName);
605 AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance() ;
607 for(Int_t iDigit=0; iDigit<nDigits; iDigit++)
609 AliPHOSDigit* digit = (AliPHOSDigit*)fLoader->Digits()->At( digits[iDigit] );
611 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
613 phosgeom->RelPosInModule(relid, x, z);
616 for(Int_t iMax=0; iMax<nMax; iMax++)
623 Float_t eMax = gamma[0];
624 Float_t xMax = gamma[1];
625 Float_t zMax = gamma[2];
627 Float_t dx = xMax - x;
628 Float_t dz = zMax - z;
630 GetReconstructionManager()->AG(eMax,dz,dx,amp,gx,gy);
638 for( Int_t iMax=0; iMax<nMax; iMax++)
645 Float_t eMax = gamma[0];
646 Float_t xMax = gamma[1];
647 Float_t zMax = gamma[2];
649 AliPHOSEvalRecPoint* newRP = new AliPHOSEvalRecPoint(IsCPV(),this);
650 TVector3 newpos(xMax,0,zMax);
651 newRP->SetLocalPosition(newpos);
653 for( Int_t iDigit = 0 ; iDigit < nDigits ; iDigit ++)
655 AliPHOSDigit* digit = (AliPHOSDigit*)fLoader->Digits()->At( digits[iDigit] );
656 Float_t eDigit = energies[iDigit];
658 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
660 phosgeom->RelPosInModule(relid, ix, iz);
662 Float_t dx = xMax - ix;
663 Float_t dz = zMax - iz;
664 Float_t singleShowerGain,gxMax,gyMax;
665 GetReconstructionManager()->AG(eMax,dz,dx,singleShowerGain,gxMax,gyMax);
666 Float_t totalGain = eFit[iDigit];
667 Float_t ratio = singleShowerGain/totalGain;
668 eDigit = eDigit*ratio;
669 newRP->AddDigit(*digit,eDigit);
671 AliInfo(Form("======= Split: daughter rec point %d =================",
683 void AliPHOSEvalRecPoint::EvaluatePosition()
685 // One gamma fit algorithm.
686 // Set chisq/dof of the fit.
687 // gamma1[0], gamma1[1], gamma1[2] are Energy,x,z of the reconstructed gamma, respectively.
689 Int_t nDigits = GetMultiplicity();
693 Int_t nIter = GetReconstructionManager()->OneGamNumOfIterations(); // number of iterations
694 Float_t st0 = GetReconstructionManager()->OneGamInitialStep(); // initial step
695 // const Float_t stpMin = 0.005;
696 Float_t stpMin = GetReconstructionManager()->OneGamStepMin();
697 Float_t chmin = GetReconstructionManager()->OneGamChisqMin();
705 GetLocalPosition(locpos);
706 Float_t e = GetEnergy();
707 Float_t xc = locpos.Z();
708 Float_t yc = locpos.X();
709 Float_t dx,dy,gx,gy,grxc,gryc;
711 Float_t chisq = 1.e+20;
715 Int_t dof = GetMultiplicity() - 2;
718 Float_t chstop = chmin*dof;
719 Float_t cosi,x1=0,y1=0;
722 AliPHOSLoader* fLoader = AliPHOSLoader::GetPHOSLoader(fEventFolderName);
723 AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance() ;
725 for(Int_t iter=0; iter<nIter; iter++)
731 for(Int_t iDigit = 0 ; iDigit < nDigits ; iDigit ++)
734 Float_t* energies = GetEnergiesList();
735 Int_t* digits = GetDigitsList();
736 digit = (AliPHOSDigit*)fLoader->Digits()->At( digits[iDigit] );
737 eDigit = energies[iDigit];
738 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
739 phosgeom->RelPosInModule(relid, iy, ix);
748 GetReconstructionManager()->AG(e,dx,dy,a,gx,gy);
750 AliInfo(Form(" (ix iy xc yc dx dy) %f %f %f %f %f %f",
751 ix, iy, xc, yc, dx, dy)) ;
752 Float_t chi2dg = GetReconstructionManager()->OneGamChi2(a,eDigit,e,dd);
754 // Exclude digit with too large chisquare.
755 if(chi2dg > 10) { continue; }
763 Float_t grc = TMath::Sqrt(grxc*grxc + gryc*gryc);
764 if(grc<1.e-10) grc=1.e-10;
765 Float_t sc = 1. + chisqc/chisq;
766 AliInfo(Form(" chisq: %f", chisq)) ;
770 cosi = (grx*grxc + gry*gryc)/gr/grc;
771 st = st*sc/(1.4 - cosi);
783 Float_t step = st*gr;
785 AliInfo(Form(" Iteration %d dof %d chisq/dof %f chstop/dof %f step %d stpMin %d",
786 iter, dof, chisq/dof, chisq/dof, chstop/dof, step, stpMin)) ;
811 TVector3 newpos(gamma1[1],0,gamma1[2]);
812 //SetLocalPosition(newpos);
818 // RP->GetLocalPosition(pos);
827 Bool_t AliPHOSEvalRecPoint::KillWeakPoint()
829 // Remove this point from further procession
830 // if it's energy is too small.
832 Float_t thr0 = GetReconstructionManager()->KillGamMinEnergy();
834 if(GetEnergy()<thr0) {
835 AliInfo(Form("+++++++ Killing this rec point ++++++++++")) ;
836 RemoveFromWorkingPool(this);
844 void AliPHOSEvalRecPoint::SplitMergedShowers()
846 // Split two very close rec. points.
848 if(GetMultiplicity()<2)
854 InitTwoGam(gamma1,gamma2); // start points for fit
855 TwoGam(gamma1,gamma2); // evaluate the positions and energies
856 UnfoldTwoMergedPoints(gamma1,gamma2); // make the job
861 void AliPHOSEvalRecPoint::MergeClosePoint()
863 // merge rec.points if they are too close
864 AliPHOSLoader* fLoader = AliPHOSLoader::GetPHOSLoader(fEventFolderName);
865 // AliPHOSDigitizer* digitizer = fLoader->Digitizer();
866 // Float_t fPedestal = digitizer->GetPedestal(); // YVK 30.09.2001
867 // Float_t fSlope = digitizer->GetSlope();
869 for (Int_t i=0;i<InWorkingPool(); i++)
871 TObject* obj = GetFromWorkingPool(i);
872 if(!((TObject*)this)->IsEqual(obj))
874 AliPHOSRecPoint* rp = (AliPHOSRecPoint*)obj;
875 if(GetPHOSMod() == rp->GetPHOSMod())
879 AliInfo(Form("+++++++ Merging point 1: ++++++")) ;
881 AliInfo(Form("+++++++ and point 2: ++++++++++")) ;
882 ((AliPHOSEvalRecPoint*)rp)->Print();
884 //merge two rec. points
887 this->GetLocalPosition(lpos1);
888 rp->GetLocalPosition(lpos2);
890 Int_t* digits = rp->GetDigitsList();
891 Float_t dE = rp->GetEnergy()/(rp->GetEnergy()+this->GetEnergy());
892 Float_t newX = lpos1.X()*dE + lpos2.X()*(1.-dE);
893 Float_t newZ = lpos1.Z()*dE + lpos2.Z()*(1.-dE);
894 Float_t newE = rp->GetEnergy()+this->GetEnergy();
895 Float_t* energies = ((AliPHOSEmcRecPoint*)rp)->GetEnergiesList();
897 for(Int_t iDigit=0; iDigit<rp->GetDigitsMultiplicity(); iDigit++)
899 AliPHOSDigit* digit = (AliPHOSDigit*)fLoader->Digits()->At(digits[iDigit]);
900 Float_t eDigit = energies[iDigit];
901 this->AddDigit(*digit,eDigit);
904 TVector3 newpos(newX,0,newZ);
907 RemoveFromWorkingPool(rp);
910 AliInfo(Form("++++++ Resulting point: ++++++++")) ;
921 Int_t AliPHOSEvalRecPoint::UnfoldLocalMaxima()
923 // Make unfolding in the reconstruction point with several local maxima.
924 // Return the number of local maxima.
926 // if multiplicity less then 2 - nothing to unfold
927 if(GetMultiplicity()<2) return 1;
929 AliPHOSDigit * maxAt[1000];
930 Float_t maxAtEnergy[1000];
931 Float_t locMaxCut, logWeight;
936 AliPHOSClusterizer* clusterizer = GetClusterizer();
938 AliFatal(Form("Cannot get clusterizer")) ;
942 locMaxCut = clusterizer->GetEmcLocalMaxCut();
943 logWeight = clusterizer->GetEmcLogWeight();
946 locMaxCut = clusterizer->GetCpvLocalMaxCut();
947 logWeight = clusterizer->GetCpvLogWeight();
950 AliPHOSLoader* fLoader = AliPHOSLoader::GetPHOSLoader(fEventFolderName);
951 AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance() ;
952 TClonesArray* digits = fLoader->Digits();
954 // if number of local maxima less then 2 - nothing to unfold
955 Int_t nMax = GetNumberOfLocalMax(maxAt,maxAtEnergy,locMaxCut,digits);
956 if(nMax<2) return nMax;
958 Int_t* digitsList = GetDigitsList();
959 Int_t nDigits = GetMultiplicity();
960 Float_t* energies = GetEnergiesList();
961 Float_t* eFit = new Float_t[nDigits];
963 Int_t iDigit; //loop variable
965 for(iDigit=0; iDigit<nDigits; iDigit++)
970 for(iDigit=0; iDigit<nDigits; iDigit++)
973 AliPHOSDigit* digit = (AliPHOSDigit*)fLoader->Digits()->At( digitsList[iDigit] );
974 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
976 phosgeom->RelPosInModule(relid, x, z);
978 for(Int_t iMax=0; iMax<nMax; iMax++)
980 AliPHOSDigit* digitMax = maxAt[iMax];
981 Float_t eMax = maxAtEnergy[iMax];
982 phosgeom->AbsToRelNumbering(digitMax->GetId(), relid) ;
983 phosgeom->RelPosInModule(relid, xMax, zMax);
984 Float_t dx = xMax - x;
985 Float_t dz = zMax - z;
987 GetReconstructionManager()->AG(eMax,dz,dx,amp,gx,gy);
994 for(Int_t iMax=0; iMax<nMax; iMax++)
996 AliPHOSDigit* digitMax = maxAt[iMax];
997 phosgeom->AbsToRelNumbering(digitMax->GetId(), relid) ;
998 phosgeom->RelPosInModule(relid, xMax, zMax);
999 Float_t eMax = maxAtEnergy[iMax];
1001 AliPHOSEvalRecPoint* newRP = new AliPHOSEvalRecPoint(IsCPV(),this);
1002 newRP->AddDigit(*digitMax,maxAtEnergy[iMax]);
1004 //Neighbous ( matrix 3x3 around the local maximum)
1005 for(iDigit=0; iDigit<nDigits; iDigit++)
1007 AliPHOSDigit* digit = (AliPHOSDigit*)fLoader->Digits()->At( digitsList[iDigit] );
1008 Float_t eDigit = energies[iDigit];
1009 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
1011 phosgeom->RelPosInModule(relid, ix, iz);
1013 if(AreNeighbours(digitMax,digit))
1015 Float_t dx = xMax - ix;
1016 Float_t dz = zMax - iz;
1017 Float_t singleShowerGain,gxMax,gyMax;
1018 GetReconstructionManager()->AG(eMax,dz,dx,singleShowerGain,gxMax,gyMax);
1019 Float_t totalGain = eFit[iDigit];
1020 Float_t ratio = singleShowerGain/totalGain;
1021 AliInfo(Form(" ratio -> %f", ratio)) ;
1022 eDigit = eDigit*ratio;
1023 newRP->AddDigit(*digit,eDigit);
1027 TVector3 vtx(0.,0.,0.) ;
1028 TVector3 inc(0.,0.,0.) ;
1029 newRP->EvalLocalPosition(logWeight,vtx,digits,inc);
1030 AliInfo(Form("======= Unfold: daughter rec point %d =================",
1035 // RemoveFromWorkingPool(this);
1043 void AliPHOSEvalRecPoint::PrintPoint()
1045 // print rec.point to stdout
1046 AliPHOSCpvRecPoint::Print();
1049 GetLocalPosition(lpos);
1052 message = " Chi2/dof = %f" ;
1053 message += " Local (x,z) = (%f, %f) in module %d" ;
1054 AliInfo(Form(message.Data(), Chi2Dof(), lpos.X(), lpos.Z(), GetPHOSMod())) ;
1058 AliPHOSRecManager* AliPHOSEvalRecPoint::GetReconstructionManager() const
1060 // returns reconstruction manager
1061 TFolder* aliceF = (TFolder*)gROOT->FindObjectAny("YSAlice");
1062 TFolder* wPoolF = (TFolder*)aliceF->FindObject("WhiteBoard/RecPoints/PHOS/SmP");
1063 AliPHOSRecManager* recMng = (AliPHOSRecManager*)wPoolF->FindObject("AliPHOSRecManager");
1065 AliFatal(Form("Couldn't find Reconstruction Manager")) ;
1072 AliPHOSRecPoint* AliPHOSEvalRecPoint::Parent()
1075 if(fParent<0) return NULL;
1077 return (AliPHOSRecPoint*)GetFromWorkingPool(fParent);
1081 Float_t AliPHOSEvalRecPoint::Chi2Dof() const
1083 // returns a chi^2 per degree of freedom
1087 const TObject* AliPHOSEvalRecPoint::GetWorkingPool()
1089 // returns a pool of rec.points
1090 TFolder* aliceF = (TFolder*)gROOT->FindObjectAny("YSAlice");
1091 TFolder* wPoolF = (TFolder*)aliceF->FindObject("WhiteBoard/RecPoints/PHOS/SmP");
1092 TObject* wPool = wPoolF->FindObject("SmartPoints");
1094 AliFatal(Form("Couldn't find Working Pool")) ;
1100 void AliPHOSEvalRecPoint::AddToWorkingPool(TObject* obj)
1102 // add a rec.point to a pool
1103 ((TObjArray*)GetWorkingPool())->Add(obj);
1106 TObject* AliPHOSEvalRecPoint::GetFromWorkingPool(Int_t i)
1108 // return a rec.point from a pool at an index i
1109 // return fWorkingPool->At(i);
1110 return ((TObjArray*)GetWorkingPool())->At(i);
1113 Int_t AliPHOSEvalRecPoint::InWorkingPool()
1115 // return the number of rec.points in a pool
1116 return ((TObjArray*)GetWorkingPool())->GetEntries();
1119 void AliPHOSEvalRecPoint::RemoveFromWorkingPool(TObject* obj)
1121 // remove a rec.point from a pool
1122 ((TObjArray*)GetWorkingPool())->Remove(obj);
1123 ((TObjArray*)GetWorkingPool())->Compress();
1126 void AliPHOSEvalRecPoint::PrintWorkingPool()
1128 // print pool of rec.points to stdout
1129 ((TObjArray*)GetWorkingPool())->Print();