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 **************************************************************************/
19 //*-- Author: Boris Polichtchouk, IHEP
20 //////////////////////////////////////////////////////////////////////////////
21 // Reconstructed point operations for the Clusterization class for IHEP reconstruction.
22 // Performs clusterization (collects neighbouring active cells)
23 // It differs from AliPHOSClusterizerv1 in neighbour definition only
25 // ---- ROOT system ---
26 #include "TDirectory.h"
32 // --- AliRoot header files ---
33 #include "AliPHOSEvalRecPoint.h"
35 #include "AliPHOSGetter.h"
36 #include "AliPHOSRecCpvManager.h"
37 #include "AliPHOSRecEmcManager.h"
38 #include "AliPHOSDigitizer.h"
40 // --- Standard library ---
43 ClassImp(AliPHOSEvalRecPoint)
45 AliPHOSEvalRecPoint::AliPHOSEvalRecPoint(): AliPHOSCpvRecPoint()
54 AliPHOSEvalRecPoint::AliPHOSEvalRecPoint(Bool_t cpv, AliPHOSEvalRecPoint* parent) : AliPHOSCpvRecPoint()
61 TObjArray* wPool = (TObjArray*)GetWorkingPool();
63 Error("AliPHOSEvalRecPoint", "Couldn't find working pool. Exit.") ;
67 fParent = wPool->IndexOf((TObject*)parent);
68 fChi2Dof = parent->Chi2Dof();
79 // Add itself to working pool
80 AddToWorkingPool((TObject*)this);
84 AliPHOSEvalRecPoint::AliPHOSEvalRecPoint(Int_t i, Bool_t cpv) : AliPHOSCpvRecPoint()
90 AliPHOSEmcRecPoint* rp=0;
92 AliPHOSGetter* fGetter = AliPHOSGetter::GetInstance();
95 rp = (AliPHOSCpvRecPoint*)fGetter->CpvRecPoints()->At(i);
100 rp = (AliPHOSEmcRecPoint*)fGetter->EmcRecPoints()->At(i);
105 Int_t* digits = rp->GetDigitsList();
106 Float_t* energies = rp->GetEnergiesList();
107 Int_t nDigits = rp->GetMultiplicity();
109 for(Int_t iDigit=0; iDigit<nDigits; iDigit++) {
110 AliPHOSDigit* digit = (AliPHOSDigit*)fGetter->Digits()->At( digits[iDigit] );
111 Float_t eDigit = energies[iDigit];
112 this->AddDigit(*digit,eDigit);
116 rp->GetLocalPosition(locpos);
119 // Add itself to working pool
120 AddToWorkingPool((TObject*)this);
124 AliPHOSClusterizer* AliPHOSEvalRecPoint::GetClusterizer()
126 // returns clusterizer task
127 TFolder* aliceF = (TFolder*)gROOT->FindObjectAny("YSAlice");
128 TFolder* wPoolF = (TFolder*)aliceF->FindObject("WhiteBoard/RecPoints/PHOS/SmP");
129 AliPHOSClusterizer* clu = (AliPHOSClusterizer*)wPoolF->FindObject("PHOS:clu-v1");
131 Error("GetClusterizer", "Couldn't find Clusterizer. Exit.") ;
138 Bool_t AliPHOSEvalRecPoint::TooClose(AliPHOSRecPoint* pt) const
140 // check if a rec.point pt is too close to this one
143 pt->GetLocalPosition(herPos);
144 this->GetLocalPosition(myPos);
145 Float_t dx = herPos.X() - myPos.X();
146 Float_t dz = herPos.Z() - myPos.Z();
147 Float_t dr = TMath::Sqrt(dx*dx + dz*dz);
149 if(dr<GetReconstructionManager()->MergeGammasMinDistanceCut())
156 Bool_t AliPHOSEvalRecPoint::NeedToSplit() const
158 // rec.point needs to be split
162 void AliPHOSEvalRecPoint::DeleteParent()
168 void AliPHOSEvalRecPoint::UpdateWorkingPool()
170 // update pool of rec.points
171 Int_t i; //loop variable
173 for(i=0; i<this->InWorkingPool(); i++) {
174 AliPHOSEvalRecPoint* parent = (AliPHOSEvalRecPoint*)GetFromWorkingPool(i);
176 Int_t nChild = parent->HasChild(children);
177 for(Int_t iChild=0; iChild<nChild; iChild++)
179 ((AliPHOSEvalRecPoint*)children.At(iChild))->DeleteParent();
183 RemoveFromWorkingPool(parent);
189 for(i=0; i<this->InWorkingPool(); i++) {
190 AliPHOSEvalRecPoint* weak = (AliPHOSEvalRecPoint*)GetFromWorkingPool(i);
191 if (weak->KillWeakPoint()) delete weak;
194 for(i=0; i<this->InWorkingPool(); i++) {
195 AliPHOSEvalRecPoint* close = (AliPHOSEvalRecPoint*)GetFromWorkingPool(i);
196 close->MergeClosePoint();
199 for(i=0; i<this->InWorkingPool(); i++)
200 ((AliPHOSEvalRecPoint*)AliPHOSEvalRecPoint::GetFromWorkingPool(i))->SetIndexInList(i);
204 Int_t AliPHOSEvalRecPoint::HasChild(TObjArray& children)
206 // returns the number of children
207 for(Int_t iChild=0; iChild<InWorkingPool(); iChild++)
209 AliPHOSEvalRecPoint* child = (AliPHOSEvalRecPoint*)GetFromWorkingPool(iChild);
210 TObject* parent = (TObject*)child->Parent();
211 TObject* me = (TObject*)this;
212 if(parent==me) children.Add(child);
215 return children.GetEntries();
218 void AliPHOSEvalRecPoint::Init()
221 AliPHOSClusterizer* clusterizer = GetClusterizer();
223 Error("Init", "Cannot get clusterizer. Exit.") ;
227 TClonesArray* digits = AliPHOSGetter::GetInstance()->Digits();
231 logWeight = clusterizer->GetEmcLogWeight();
234 logWeight = clusterizer->GetCpvLogWeight();
237 EvalLocalPosition(logWeight,digits); // evaluate initial position
241 void AliPHOSEvalRecPoint::MakeJob()
243 // Reconstruction algoritm implementation.
245 AliPHOSRecManager* recMng = GetReconstructionManager();
252 Int_t nChild = HasChild(children);
256 if(Chi2Dof()>recMng->OneGamChisqCut()) SplitMergedShowers();
259 for(Int_t iChild=0; iChild<nChild; iChild++) {
260 AliPHOSEvalRecPoint* child = (AliPHOSEvalRecPoint*)children.At(iChild);
261 child->EvaluatePosition();
263 if(child->Chi2Dof()>recMng->OneGamChisqCut())
264 child->SplitMergedShowers();
269 void AliPHOSEvalRecPoint::InitTwoGam(Float_t* gamma1, Float_t* gamma2)
271 //Compute start values for two gamma fit algorithm.
272 // gamma1[0], gamma1[1], gamma1[2] are Energy,x,z of the reconstructed "gammas".
275 TVector3 lpos; // start point choosing.
276 GetLocalPosition(lpos);
277 Float_t xx = lpos.Z();
278 Float_t yy = lpos.X();
279 Float_t e = GetEnergy();
281 Info("InitTwoGam", "(x,z,e)[old] = (%f, %f, %f)", yy, xx, e) ;
288 AliPHOSDigit * digit ;
289 Int_t nDigits = GetMultiplicity();
290 Int_t * digits = GetDigitsList();
291 Float_t * energies = GetEnergiesList();
303 AliPHOSGetter* fGetter = AliPHOSGetter::GetInstance();
304 const AliPHOSGeometry* fGeom = fGetter->PHOSGeometry();
306 Int_t iDigit; //loop variable
308 for(iDigit = 0 ; iDigit < nDigits ; iDigit ++)
310 digit = (AliPHOSDigit*)fGetter->Digits()->At( digits[iDigit] );
311 eDigit = energies[iDigit];
312 fGeom->AbsToRelNumbering(digit->GetId(), relid) ;
313 fGeom->RelPosInModule(relid, iy, ix);
315 Float_t dx = ix - xx;
316 Float_t dy = iy - yy;
323 sqr = TMath::Sqrt(4.*exy*exy + (exx-eyy)*(exx-eyy));
324 Float_t euu = (exx+eyy+sqr)/2.;
325 if(sqr>1.e-10) cos2fi = (exx - eyy)/sqr;
326 Float_t cosfi = TMath::Sqrt((1.+cos2fi)/2.);
327 Float_t sinfi = TMath::Sqrt((1.-cos2fi)/2.);
328 if(exy<0) sinfi = -sinfi;
331 for(iDigit = 0 ; iDigit < nDigits ; iDigit ++)
333 digit = (AliPHOSDigit*)fGetter->Digits()->At( digits[iDigit] );
334 eDigit = energies[iDigit];
335 fGeom->AbsToRelNumbering(digit->GetId(), relid) ;
336 fGeom->RelPosInModule(relid, iy, ix);
338 Float_t dx = ix - xx;
339 Float_t dy = iy - yy;
340 Float_t du = dx*cosfi + dy*sinfi;
341 eu3 += eDigit*du*du*du;
344 Float_t c = e*eu3*eu3/(euu*euu*euu)/2.;
346 if(eu3<0) sign = -1.;
347 Float_t r = 1.+ c + sign*TMath::Sqrt(2.*c + c*c);
349 if(TMath::Abs(r-1.)>0.1) u = eu3/euu*(r+1.)/(r-1.);
350 if(TMath::Abs(r-1.)<0.1) u = TMath::Sqrt(sqr/e/r)*(1.+r);
352 Float_t e2c = e/(1.+r);
354 Float_t u1 = -u/(1.+r);
357 Float_t x1c = xx+u1*cosfi;
358 Float_t y1c = yy+u1*sinfi;
359 Float_t x2c = xx+u2*cosfi;
360 Float_t y2c = yy+u2*sinfi;
362 // printf("e1c -> %f\n",e1c);
363 // printf("x1c -> %f\n",x1c);
364 // printf("y1c -> %f\n",y1c);
365 // printf("e2c -> %f\n",e2c);
366 // printf("x2c -> %f\n",x2c);
367 // printf("y2c -> %f\n",y2c);
379 void AliPHOSEvalRecPoint::TwoGam(Float_t* gamma1, Float_t* gamma2)
381 //Fitting algorithm for the two very closed gammas
382 //that merged into the cluster with one maximum.
383 // Starting points gamma1 and gamma2 must be provided before ( see InitTwoGam)
384 //Set chisquare of the fit.
387 Float_t st0 = GetReconstructionManager()->TwoGamInitialStep();
388 Float_t chmin = GetReconstructionManager()->TwoGamChisqMin();
389 Float_t emin = GetReconstructionManager()->TwoGamEmin();
390 Float_t stpmin = GetReconstructionManager()->TwoGamStepMin();
391 Int_t nIter = GetReconstructionManager()->TwoGamNumOfIterations(); // Number of iterations.
393 Float_t chisq = 100.; //Initial chisquare.
395 Int_t nadc = GetMultiplicity();
399 Int_t dof = nadc - 5;
401 Float_t chstop = chmin*dof;
411 Float_t ee1=0,xx1=0,yy1=0,ee2=0,xx2=0,yy2=0,cosi;
413 Float_t e1c = gamma1[0];
414 Float_t y1c = gamma1[1];
415 Float_t x1c = gamma1[2];
417 Float_t e2c = gamma2[0];
418 Float_t y2c = gamma2[1];
419 Float_t x2c = gamma2[2];
421 Float_t e = GetEnergy();
424 AliPHOSDigit * digit ;
425 Int_t nDigits = GetMultiplicity();
426 Int_t * digits = GetDigitsList();
427 Float_t * energies = GetEnergiesList();
433 AliPHOSGetter* fGetter = AliPHOSGetter::GetInstance();
434 const AliPHOSGeometry* fGeom = fGetter->PHOSGeometry();
436 for(Int_t iter=0; iter<nIter; iter++)
445 for(Int_t iDigit = 0 ; iDigit < nDigits ; iDigit ++)
447 digit = (AliPHOSDigit*)fGetter->Digits()->At( digits[iDigit] );
448 eDigit = energies[iDigit];
449 fGeom->AbsToRelNumbering(digit->GetId(), relid) ;
450 fGeom->RelPosInModule(relid, iy, ix);
455 Float_t dx1 = x1c - ix;
456 Float_t dy1 = y1c - iy;
457 // Info("TwoGam", "Mult %d dx1 %f dy1 %f", nDigits, dx1, dy1) ;
458 // AG(e1c,dx1,dy1,a1,gx1,gy1);
459 GetReconstructionManager()->AG(e1c,dx1,dy1,a1,gx1,gy1);
461 Float_t dx2 = x2c - ix;
462 Float_t dy2 = y2c - iy;
463 // Info("TwoGam", " dx2 %f dy2 %f", dx2, dy2) ;
464 // AG(e2c,dx2,dy2,a2,gx2,gy2);
465 GetReconstructionManager()->AG(e2c,dx2,dy2,a2,gx2,gy2);
468 // Float_t D = Const*a*(1. - a/e);
471 // // D = 9.; // ????
473 // Float_t da = a - eDigit;
474 // chisqc += da*da/D;
475 // Float_t dd = da/D;
476 // dd = dd*(2.-dd*Const*(1.-2.*a/e));
479 chisqc += GetReconstructionManager()->TwoGamChi2(a,eDigit,e,dd);
485 grec += (a1/e1c - a2/e2c)*e*dd;
489 Float_t grc = TMath::Sqrt(grx1c*grx1c + gry1c*gry1c + grx2c*grx2c + gry2c*gry2c);
490 if(grc<1.e-10) grc=1.e-10;
492 Float_t sc = 1. + chisqc/ch;
497 cosi = (grx1*grx1c + gry1*gry1c + grx2*grx2c + gry2*gry2c + gre*grec)/gr/grc;
498 st = st*sc/(1.4 - cosi);
520 Float_t step = st*gr;
522 Info("TwoGam", "Iteration %d dof %d chisq/dof %f chstop/dof %f step %d stpmin %d",
523 iter, dof, ch/dof, chstop/dof, step, stpmin) ;
529 Float_t de = st*gre*e;
533 if( (e1c>emin) && (e2c>emin) )
549 // if(ch>chisq*(nadc-2)-delch)
569 message = " (x,z,e)[1 fit] = (%f, %f, %f)\n" ;
570 message = " (x,z,e)[2 fit] = (%f, %f, %f)\n" ;
571 Info("TwoGam", message.Data(),
573 x2New, z2New, e2New) ;
579 void AliPHOSEvalRecPoint::UnfoldTwoMergedPoints(Float_t* gamma1, Float_t* gamma2)
581 //Unfold TWO merged rec. points in the case when cluster has only one maximum,
582 //but it's fitting to the one gamma shower is too bad.
583 // Use TwoGam() to estimate the positions and energies of merged points.
589 Int_t* digits = GetDigitsList();
590 Int_t nDigits = GetMultiplicity();
591 Float_t* energies = GetEnergiesList();
592 Float_t* eFit = new Float_t[nDigits];
594 AliPHOSGetter* fGetter = AliPHOSGetter::GetInstance();
595 const AliPHOSGeometry* fGeom = fGetter->PHOSGeometry();
597 for(Int_t iDigit=0; iDigit<nDigits; iDigit++)
599 AliPHOSDigit* digit = (AliPHOSDigit*)fGetter->Digits()->At( digits[iDigit] );
601 fGeom->AbsToRelNumbering(digit->GetId(), relid) ;
603 fGeom->RelPosInModule(relid, x, z);
606 for(Int_t iMax=0; iMax<nMax; iMax++)
613 Float_t eMax = gamma[0];
614 Float_t xMax = gamma[1];
615 Float_t zMax = gamma[2];
617 Float_t dx = xMax - x;
618 Float_t dz = zMax - z;
620 GetReconstructionManager()->AG(eMax,dz,dx,amp,gx,gy);
628 for( Int_t iMax=0; iMax<nMax; iMax++)
635 Float_t eMax = gamma[0];
636 Float_t xMax = gamma[1];
637 Float_t zMax = gamma[2];
639 AliPHOSEvalRecPoint* newRP = new AliPHOSEvalRecPoint(IsCPV(),this);
640 TVector3 newpos(xMax,0,zMax);
641 newRP->SetLocalPosition(newpos);
643 for( Int_t iDigit = 0 ; iDigit < nDigits ; iDigit ++)
645 AliPHOSDigit* digit = (AliPHOSDigit*)fGetter->Digits()->At( digits[iDigit] );
646 Float_t eDigit = energies[iDigit];
648 fGeom->AbsToRelNumbering(digit->GetId(), relid) ;
650 fGeom->RelPosInModule(relid, ix, iz);
652 Float_t dx = xMax - ix;
653 Float_t dz = zMax - iz;
654 Float_t singleShowerGain,gxMax,gyMax;
655 GetReconstructionManager()->AG(eMax,dz,dx,singleShowerGain,gxMax,gyMax);
656 Float_t totalGain = eFit[iDigit];
657 Float_t ratio = singleShowerGain/totalGain;
658 eDigit = eDigit*ratio;
659 newRP->AddDigit(*digit,eDigit);
661 Info("UnfoldTwoMergedPoints", "======= Split: daughter rec point %d =================", iMax) ;
672 void AliPHOSEvalRecPoint::EvaluatePosition()
674 // One gamma fit algorithm.
675 // Set chisq/dof of the fit.
676 // gamma1[0], gamma1[1], gamma1[2] are Energy,x,z of the reconstructed gamma, respectively.
678 Int_t nDigits = GetMultiplicity();
682 Int_t nIter = GetReconstructionManager()->OneGamNumOfIterations(); // number of iterations
683 Float_t st0 = GetReconstructionManager()->OneGamInitialStep(); // initial step
684 // const Float_t stpMin = 0.005;
685 Float_t stpMin = GetReconstructionManager()->OneGamStepMin();
686 Float_t chmin = GetReconstructionManager()->OneGamChisqMin();
694 GetLocalPosition(locpos);
695 Float_t e = GetEnergy();
696 Float_t xc = locpos.Z();
697 Float_t yc = locpos.X();
698 Float_t dx,dy,gx,gy,grxc,gryc;
700 Float_t chisq = 1.e+20;
704 Int_t dof = GetMultiplicity() - 2;
707 Float_t chstop = chmin*dof;
708 Float_t cosi,x1=0,y1=0;
711 AliPHOSGetter* fGetter = AliPHOSGetter::GetInstance();
712 const AliPHOSGeometry* fGeom = fGetter->PHOSGeometry();
714 for(Int_t iter=0; iter<nIter; iter++)
720 for(Int_t iDigit = 0 ; iDigit < nDigits ; iDigit ++)
723 Float_t* energies = GetEnergiesList();
724 Int_t* digits = GetDigitsList();
725 digit = (AliPHOSDigit*)fGetter->Digits()->At( digits[iDigit] );
726 eDigit = energies[iDigit];
727 fGeom->AbsToRelNumbering(digit->GetId(), relid) ;
728 fGeom->RelPosInModule(relid, iy, ix);
737 GetReconstructionManager()->AG(e,dx,dy,a,gx,gy);
739 Info("EvaluatePosition", " (ix iy xc yc dx dy) %f %f %f %f %f %f", ix, iy, xc, yc, dx, dy) ;
740 Float_t chi2dg = GetReconstructionManager()->OneGamChi2(a,eDigit,e,dd);
742 // Exclude digit with too large chisquare.
743 if(chi2dg > 10) { continue; }
751 Float_t grc = TMath::Sqrt(grxc*grxc + gryc*gryc);
752 if(grc<1.e-10) grc=1.e-10;
753 Float_t sc = 1. + chisqc/chisq;
754 Info("EvaluatePosition", " chisq: %f", chisq) ;
758 cosi = (grx*grxc + gry*gryc)/gr/grc;
759 st = st*sc/(1.4 - cosi);
771 Float_t step = st*gr;
773 Info("EvaluatePosition", " Iteration %d dof %d chisq/dof %f chstop/dof %f step %d stpMin %d",
774 iter, dof, chisq/dof, chisq/dof, chstop/dof, step, stpMin) ;
799 TVector3 newpos(gamma1[1],0,gamma1[2]);
800 //SetLocalPosition(newpos);
806 // RP->GetLocalPosition(pos);
815 Bool_t AliPHOSEvalRecPoint::KillWeakPoint()
817 // Remove this point from further procession
818 // if it's energy is too small.
820 Float_t thr0 = GetReconstructionManager()->KillGamMinEnergy();
822 if(GetEnergy()<thr0) {
823 Info("KillWeakPoint", "+++++++ Killing this rec point ++++++++++") ;
824 RemoveFromWorkingPool(this);
832 void AliPHOSEvalRecPoint::SplitMergedShowers()
834 // Split two very close rec. points.
836 if(GetMultiplicity()<2)
842 InitTwoGam(gamma1,gamma2); // start points for fit
843 TwoGam(gamma1,gamma2); // evaluate the positions and energies
844 UnfoldTwoMergedPoints(gamma1,gamma2); // make the job
849 void AliPHOSEvalRecPoint::MergeClosePoint()
851 // merge rec.points if they are too close
852 AliPHOSGetter* fGetter = AliPHOSGetter::GetInstance();
853 // AliPHOSDigitizer* digitizer = fGetter->Digitizer();
854 // Float_t fPedestal = digitizer->GetPedestal(); // YVK 30.09.2001
855 // Float_t fSlope = digitizer->GetSlope();
857 for (Int_t i=0;i<InWorkingPool(); i++)
859 TObject* obj = GetFromWorkingPool(i);
860 if(!((TObject*)this)->IsEqual(obj))
862 AliPHOSRecPoint* rp = (AliPHOSRecPoint*)obj;
863 if(GetPHOSMod() == rp->GetPHOSMod())
867 Info("MergeClosePoint", "+++++++ Merging point 1: ++++++") ;
869 Info("MergeClosePoint", "+++++++ and point 2: ++++++++++") ;
870 ((AliPHOSEvalRecPoint*)rp)->Print("");
872 //merge two rec. points
875 this->GetLocalPosition(lpos1);
876 rp->GetLocalPosition(lpos2);
878 Int_t* digits = rp->GetDigitsList();
879 Float_t dE = rp->GetEnergy()/(rp->GetEnergy()+this->GetEnergy());
880 Float_t newX = lpos1.X()*dE + lpos2.X()*(1.-dE);
881 Float_t newZ = lpos1.Z()*dE + lpos2.Z()*(1.-dE);
882 Float_t newE = rp->GetEnergy()+this->GetEnergy();
883 Float_t* energies = ((AliPHOSEmcRecPoint*)rp)->GetEnergiesList();
885 for(Int_t iDigit=0; iDigit<rp->GetDigitsMultiplicity(); iDigit++)
887 AliPHOSDigit* digit = (AliPHOSDigit*)fGetter->Digits()->At(digits[iDigit]);
888 Float_t eDigit = energies[iDigit];
889 this->AddDigit(*digit,eDigit);
892 TVector3 newpos(newX,0,newZ);
895 RemoveFromWorkingPool(rp);
898 Info("MergeClosePoint", "++++++ Resulting point: ++++++++") ;
909 Int_t AliPHOSEvalRecPoint::UnfoldLocalMaxima()
911 // Make unfolding in the reconstruction point with several local maxima.
912 // Return the number of local maxima.
914 // if multiplicity less then 2 - nothing to unfold
915 if(GetMultiplicity()<2) return 1;
917 AliPHOSDigit * maxAt[1000];
918 Float_t maxAtEnergy[1000];
919 Float_t locMaxCut, logWeight;
924 // AliPHOSClusterizer* clusterizer = fGetter->Clusterizer("PHOSclu-v1");
925 AliPHOSClusterizer* clusterizer = GetClusterizer();
927 Error("UnfoldLocalMaxima", "Cannot get clusterizer. Exit.") ;
932 locMaxCut = clusterizer->GetEmcLocalMaxCut();
933 logWeight = clusterizer->GetEmcLogWeight();
936 locMaxCut = clusterizer->GetCpvLocalMaxCut();
937 logWeight = clusterizer->GetCpvLogWeight();
940 AliPHOSGetter* fGetter = AliPHOSGetter::GetInstance();
941 const AliPHOSGeometry* fGeom = fGetter->PHOSGeometry();
942 TClonesArray* digits = fGetter->Digits();
944 // if number of local maxima less then 2 - nothing to unfold
945 Int_t nMax = GetNumberOfLocalMax(maxAt,maxAtEnergy,locMaxCut,digits);
946 if(nMax<2) return nMax;
948 Int_t* digitsList = GetDigitsList();
949 Int_t nDigits = GetMultiplicity();
950 Float_t* energies = GetEnergiesList();
951 Float_t* eFit = new Float_t[nDigits];
953 Int_t iDigit; //loop variable
955 for(iDigit=0; iDigit<nDigits; iDigit++)
960 for(iDigit=0; iDigit<nDigits; iDigit++)
963 AliPHOSDigit* digit = (AliPHOSDigit*)fGetter->Digits()->At( digitsList[iDigit] );
964 fGeom->AbsToRelNumbering(digit->GetId(), relid) ;
966 fGeom->RelPosInModule(relid, x, z);
968 for(Int_t iMax=0; iMax<nMax; iMax++)
970 AliPHOSDigit* digitMax = maxAt[iMax];
971 Float_t eMax = maxAtEnergy[iMax];
972 fGeom->AbsToRelNumbering(digitMax->GetId(), relid) ;
973 fGeom->RelPosInModule(relid, xMax, zMax);
974 Float_t dx = xMax - x;
975 Float_t dz = zMax - z;
977 GetReconstructionManager()->AG(eMax,dz,dx,amp,gx,gy);
984 for(Int_t iMax=0; iMax<nMax; iMax++)
986 AliPHOSDigit* digitMax = maxAt[iMax];
987 fGeom->AbsToRelNumbering(digitMax->GetId(), relid) ;
988 fGeom->RelPosInModule(relid, xMax, zMax);
989 Float_t eMax = maxAtEnergy[iMax];
991 AliPHOSEvalRecPoint* newRP = new AliPHOSEvalRecPoint(IsCPV(),this);
992 newRP->AddDigit(*digitMax,maxAtEnergy[iMax]);
994 //Neighbous ( matrix 3x3 around the local maximum)
995 for(Int_t iDigit=0; iDigit<nDigits; iDigit++)
997 AliPHOSDigit* digit = (AliPHOSDigit*)fGetter->Digits()->At( digitsList[iDigit] );
998 Float_t eDigit = energies[iDigit];
999 fGeom->AbsToRelNumbering(digit->GetId(), relid) ;
1001 fGeom->RelPosInModule(relid, ix, iz);
1003 if(AreNeighbours(digitMax,digit))
1005 Float_t dx = xMax - ix;
1006 Float_t dz = zMax - iz;
1007 Float_t singleShowerGain,gxMax,gyMax;
1008 GetReconstructionManager()->AG(eMax,dz,dx,singleShowerGain,gxMax,gyMax);
1009 Float_t totalGain = eFit[iDigit];
1010 Float_t ratio = singleShowerGain/totalGain;
1011 Info("UnfoldLocalMaxima", " ratio -> %f", ratio) ;
1012 eDigit = eDigit*ratio;
1013 newRP->AddDigit(*digit,eDigit);
1017 newRP->EvalLocalPosition(logWeight,digits);
1018 Info("UnfoldLocalMaxima", "======= Unfold: daughter rec point %d =================", iMax) ;
1022 // RemoveFromWorkingPool(this);
1030 void AliPHOSEvalRecPoint::PrintPoint(Option_t* opt)
1032 // print rec.point to stdout
1033 AliPHOSCpvRecPoint::Print(opt);
1036 GetLocalPosition(lpos);
1039 message = " Chi2/dof = %f" ;
1040 message += " Local (x,z) = (%f, %f) in module %d" ;
1041 Info("Print", message.Data(), Chi2Dof(), lpos.X(), lpos.Z(), GetPHOSMod()) ;
1045 AliPHOSRecManager* AliPHOSEvalRecPoint::GetReconstructionManager() const
1047 // returns reconstruction manager
1048 TFolder* aliceF = (TFolder*)gROOT->FindObjectAny("YSAlice");
1049 TFolder* wPoolF = (TFolder*)aliceF->FindObject("WhiteBoard/RecPoints/PHOS/SmP");
1050 AliPHOSRecManager* recMng = (AliPHOSRecManager*)wPoolF->FindObject("AliPHOSRecManager");
1052 Error("GetReconstructionManager", "Couldn't find Reconstruction Manager. Exit.") ;
1060 AliPHOSRecPoint* AliPHOSEvalRecPoint::Parent()
1063 if(fParent<0) return NULL;
1065 return (AliPHOSRecPoint*)GetFromWorkingPool(fParent);
1069 Float_t AliPHOSEvalRecPoint::Chi2Dof() const
1071 // returns a chi^2 per degree of freedom
1075 const TObject* AliPHOSEvalRecPoint::GetWorkingPool()
1077 // returns a pool of rec.points
1078 TFolder* aliceF = (TFolder*)gROOT->FindObjectAny("YSAlice");
1079 TFolder* wPoolF = (TFolder*)aliceF->FindObject("WhiteBoard/RecPoints/PHOS/SmP");
1080 TObject* wPool = wPoolF->FindObject("SmartPoints");
1082 Error("GetWorkingPool", "Couldn't find Working Pool. Exit.") ;
1089 void AliPHOSEvalRecPoint::AddToWorkingPool(TObject* obj)
1091 // add a rec.point to a pool
1092 ((TObjArray*)GetWorkingPool())->Add(obj);
1095 TObject* AliPHOSEvalRecPoint::GetFromWorkingPool(Int_t i)
1097 // return a rec.point from a pool at an index i
1098 // return fWorkingPool->At(i);
1099 return ((TObjArray*)GetWorkingPool())->At(i);
1102 Int_t AliPHOSEvalRecPoint::InWorkingPool()
1104 // return the number of rec.points in a pool
1105 return ((TObjArray*)GetWorkingPool())->GetEntries();
1108 void AliPHOSEvalRecPoint::RemoveFromWorkingPool(TObject* obj)
1110 // remove a rec.point from a pool
1111 ((TObjArray*)GetWorkingPool())->Remove(obj);
1112 ((TObjArray*)GetWorkingPool())->Compress();
1115 void AliPHOSEvalRecPoint::PrintWorkingPool()
1117 // print pool of rec.points to stdout
1118 ((TObjArray*)GetWorkingPool())->Print("");