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") ;
78 fParent = wPool->IndexOf((TObject*)parent);
80 fChi2Dof = parent->Chi2Dof();
91 // Add itself to working pool
92 AddToWorkingPool((TObject*)this);
96 AliPHOSEvalRecPoint::AliPHOSEvalRecPoint(Int_t i, Bool_t cpv) :
101 fEventFolderName(AliConfig::GetDefaultEventFolderName())
104 AliPHOSEmcRecPoint* rp=0;
106 AliPHOSLoader* fLoader = AliPHOSLoader::GetPHOSLoader(fEventFolderName);
109 rp = (AliPHOSCpvRecPoint*)fLoader->CpvRecPoints()->At(i);
114 rp = (AliPHOSEmcRecPoint*)fLoader->EmcRecPoints()->At(i);
119 Int_t* digits = rp->GetDigitsList();
120 Float_t* energies = rp->GetEnergiesList();
121 Int_t nDigits = rp->GetMultiplicity();
123 for(Int_t iDigit=0; iDigit<nDigits; iDigit++) {
124 AliPHOSDigit* digit = (AliPHOSDigit*)fLoader->Digits()->At( digits[iDigit] );
125 Float_t eDigit = energies[iDigit];
126 this->AddDigit(*digit,eDigit);
130 rp->GetLocalPosition(locpos);
133 // Add itself to working pool
134 AddToWorkingPool((TObject*)this);
138 AliPHOSClusterizer* AliPHOSEvalRecPoint::GetClusterizer()
140 // returns clusterizer task
141 TFolder* aliceF = (TFolder*)gROOT->FindObjectAny("YSAlice");
142 TFolder* wPoolF = (TFolder*)aliceF->FindObject("WhiteBoard/RecPoints/PHOS/SmP");
143 AliPHOSClusterizer* clu = (AliPHOSClusterizer*)wPoolF->FindObject("PHOS:clu-v1");
145 Fatal("GetClusterizer", "Couldn't find Clusterizer") ;
151 Bool_t AliPHOSEvalRecPoint::TooClose(AliPHOSRecPoint* pt) const
153 // check if a rec.point pt is too close to this one
156 pt->GetLocalPosition(herPos);
157 this->GetLocalPosition(myPos);
158 Float_t dx = herPos.X() - myPos.X();
159 Float_t dz = herPos.Z() - myPos.Z();
160 Float_t dr = TMath::Sqrt(dx*dx + dz*dz);
162 if(dr<GetReconstructionManager()->MergeGammasMinDistanceCut())
169 Bool_t AliPHOSEvalRecPoint::NeedToSplit() const
171 // rec.point needs to be split
175 void AliPHOSEvalRecPoint::DeleteParent()
181 void AliPHOSEvalRecPoint::UpdateWorkingPool()
183 // update pool of rec.points
184 Int_t i; //loop variable
186 for(i=0; i<this->InWorkingPool(); i++) {
187 AliPHOSEvalRecPoint* parent = (AliPHOSEvalRecPoint*)GetFromWorkingPool(i);
189 Int_t nChild = parent->HasChild(children);
190 for(Int_t iChild=0; iChild<nChild; iChild++)
192 ((AliPHOSEvalRecPoint*)children.At(iChild))->DeleteParent();
196 RemoveFromWorkingPool(parent);
202 for(i=0; i<this->InWorkingPool(); i++) {
203 AliPHOSEvalRecPoint* weak = (AliPHOSEvalRecPoint*)GetFromWorkingPool(i);
204 if (weak->KillWeakPoint()) delete weak;
207 for(i=0; i<this->InWorkingPool(); i++) {
208 AliPHOSEvalRecPoint* close = (AliPHOSEvalRecPoint*)GetFromWorkingPool(i);
209 close->MergeClosePoint();
212 for(i=0; i<this->InWorkingPool(); i++)
213 ((AliPHOSEvalRecPoint*)AliPHOSEvalRecPoint::GetFromWorkingPool(i))->SetIndexInList(i);
217 Int_t AliPHOSEvalRecPoint::HasChild(TObjArray& children)
219 // returns the number of children
220 for(Int_t iChild=0; iChild<InWorkingPool(); iChild++)
222 AliPHOSEvalRecPoint* child = (AliPHOSEvalRecPoint*)GetFromWorkingPool(iChild);
223 TObject* parent = (TObject*)child->Parent();
224 TObject* me = (TObject*)this;
225 if(parent==me) children.Add(child);
228 return children.GetEntries();
231 void AliPHOSEvalRecPoint::Init()
234 AliPHOSClusterizer* clusterizer = GetClusterizer();
236 AliFatal("Cannot get clusterizer") ;
239 TClonesArray* digits = AliPHOSLoader::GetPHOSLoader(fEventFolderName)->Digits();
243 logWeight = clusterizer->GetEmcLogWeight();
246 logWeight = clusterizer->GetCpvLogWeight();
249 TVector3 vtx(0.,0.,0.) ;
250 TVector3 inc(0.,0.,0.) ;
251 EvalLocalPosition(logWeight,vtx,digits,inc); // evaluate initial position
255 void AliPHOSEvalRecPoint::MakeJob()
257 // Reconstruction algoritm implementation.
259 AliPHOSRecManager* recMng = GetReconstructionManager();
266 Int_t nChild = HasChild(children);
270 if(Chi2Dof()>recMng->OneGamChisqCut()) SplitMergedShowers();
273 for(Int_t iChild=0; iChild<nChild; iChild++) {
274 AliPHOSEvalRecPoint* child = (AliPHOSEvalRecPoint*)children.At(iChild);
275 child->EvaluatePosition();
277 if(child->Chi2Dof()>recMng->OneGamChisqCut())
278 child->SplitMergedShowers();
283 void AliPHOSEvalRecPoint::InitTwoGam(Float_t* gamma1, Float_t* gamma2)
285 //Compute start values for two gamma fit algorithm.
286 // gamma1[0], gamma1[1], gamma1[2] are Energy,x,z of the reconstructed "gammas".
289 TVector3 lpos; // start point choosing.
290 GetLocalPosition(lpos);
291 Float_t xx = lpos.Z();
292 Float_t yy = lpos.X();
293 Float_t e = GetEnergy();
295 AliInfo(Form("(x,z,e)[old] = (%f, %f, %f)", yy, xx, e)) ;
302 AliPHOSDigit * digit ;
303 Int_t nDigits = GetMultiplicity();
304 Int_t * digits = GetDigitsList();
305 Float_t * energies = GetEnergiesList();
317 AliPHOSLoader* fLoader = AliPHOSLoader::GetPHOSLoader(fEventFolderName);
318 AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance() ;
320 Int_t iDigit; //loop variable
322 for(iDigit = 0 ; iDigit < nDigits ; iDigit ++)
324 digit = (AliPHOSDigit*)fLoader->Digits()->At( digits[iDigit] );
325 eDigit = energies[iDigit];
326 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
327 phosgeom->RelPosInModule(relid, iy, ix);
329 Float_t dx = ix - xx;
330 Float_t dy = iy - yy;
337 sqr = TMath::Sqrt(4.*exy*exy + (exx-eyy)*(exx-eyy));
338 Float_t euu = (exx+eyy+sqr)/2.;
339 if(sqr>1.e-10) cos2fi = (exx - eyy)/sqr;
340 Float_t cosfi = TMath::Sqrt((1.+cos2fi)/2.);
341 Float_t sinfi = TMath::Sqrt((1.-cos2fi)/2.);
342 if(exy<0) sinfi = -sinfi;
345 for(iDigit = 0 ; iDigit < nDigits ; iDigit ++)
347 digit = (AliPHOSDigit*)fLoader->Digits()->At( digits[iDigit] );
348 eDigit = energies[iDigit];
349 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
350 phosgeom->RelPosInModule(relid, iy, ix);
352 Float_t dx = ix - xx;
353 Float_t dy = iy - yy;
354 Float_t du = dx*cosfi + dy*sinfi;
355 eu3 += eDigit*du*du*du;
358 Float_t c = e*eu3*eu3/(euu*euu*euu)/2.;
360 if(eu3<0) sign = -1.;
361 Float_t r = 1.+ c + sign*TMath::Sqrt(2.*c + c*c);
363 if(TMath::Abs(r-1.)>0.1) u = eu3/euu*(r+1.)/(r-1.);
364 if(TMath::Abs(r-1.)<0.1) u = TMath::Sqrt(sqr/e/r)*(1.+r);
366 Float_t e2c = e/(1.+r);
368 Float_t u1 = -u/(1.+r);
371 Float_t x1c = xx+u1*cosfi;
372 Float_t y1c = yy+u1*sinfi;
373 Float_t x2c = xx+u2*cosfi;
374 Float_t y2c = yy+u2*sinfi;
376 // printf("e1c -> %f\n",e1c);
377 // printf("x1c -> %f\n",x1c);
378 // printf("y1c -> %f\n",y1c);
379 // printf("e2c -> %f\n",e2c);
380 // printf("x2c -> %f\n",x2c);
381 // printf("y2c -> %f\n",y2c);
393 void AliPHOSEvalRecPoint::TwoGam(Float_t* gamma1, Float_t* gamma2)
395 //Fitting algorithm for the two very closed gammas
396 //that merged into the cluster with one maximum.
397 // Starting points gamma1 and gamma2 must be provided before ( see InitTwoGam)
398 //Set chisquare of the fit.
401 Float_t st0 = GetReconstructionManager()->TwoGamInitialStep();
402 Float_t chmin = GetReconstructionManager()->TwoGamChisqMin();
403 Float_t emin = GetReconstructionManager()->TwoGamEmin();
404 Float_t stpmin = GetReconstructionManager()->TwoGamStepMin();
405 Int_t nIter = GetReconstructionManager()->TwoGamNumOfIterations(); // Number of iterations.
407 Float_t chisq = 100.; //Initial chisquare.
409 Int_t nadc = GetMultiplicity();
413 Int_t dof = nadc - 5;
415 Float_t chstop = chmin*dof;
425 Float_t ee1=0,xx1=0,yy1=0,ee2=0,xx2=0,yy2=0,cosi;
427 Float_t e1c = gamma1[0];
428 Float_t y1c = gamma1[1];
429 Float_t x1c = gamma1[2];
431 Float_t e2c = gamma2[0];
432 Float_t y2c = gamma2[1];
433 Float_t x2c = gamma2[2];
435 Float_t e = GetEnergy();
438 AliPHOSDigit * digit ;
439 Int_t nDigits = GetMultiplicity();
440 Int_t * digits = GetDigitsList();
441 Float_t * energies = GetEnergiesList();
447 AliPHOSLoader* fLoader = AliPHOSLoader::GetPHOSLoader(fEventFolderName);
448 AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance() ;
450 for(Int_t iter=0; iter<nIter; iter++)
459 for(Int_t iDigit = 0 ; iDigit < nDigits ; iDigit ++)
461 digit = (AliPHOSDigit*)fLoader->Digits()->At( digits[iDigit] );
462 eDigit = energies[iDigit];
463 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
464 phosgeom->RelPosInModule(relid, iy, ix);
469 Float_t dx1 = x1c - ix;
470 Float_t dy1 = y1c - iy;
472 GetReconstructionManager()->AG(e1c,dx1,dy1,a1,gx1,gy1);
474 Float_t dx2 = x2c - ix;
475 Float_t dy2 = y2c - iy;
477 GetReconstructionManager()->AG(e2c,dx2,dy2,a2,gx2,gy2);
480 // Float_t D = Const*a*(1. - a/e);
483 // // D = 9.; // ????
485 // Float_t da = a - eDigit;
486 // chisqc += da*da/D;
487 // Float_t dd = da/D;
488 // dd = dd*(2.-dd*Const*(1.-2.*a/e));
491 chisqc += GetReconstructionManager()->TwoGamChi2(a,eDigit,e,dd);
497 grec += (a1/e1c - a2/e2c)*e*dd;
501 Float_t grc = TMath::Sqrt(grx1c*grx1c + gry1c*gry1c + grx2c*grx2c + gry2c*gry2c);
502 if(grc<1.e-10) grc=1.e-10;
504 Float_t sc = 1. + chisqc/ch;
509 cosi = (grx1*grx1c + gry1*gry1c + grx2*grx2c + gry2*gry2c + gre*grec)/gr/grc;
510 st = st*sc/(1.4 - cosi);
532 Float_t step = st*gr;
534 AliInfo(Form("Iteration %d dof %d chisq/dof %f chstop/dof %f step %f stpmin %f",
535 iter, dof, ch/dof, chstop/dof, step, stpmin)) ;
541 Float_t de = st*gre*e;
545 if( (e1c>emin) && (e2c>emin) )
561 // if(ch>chisq*(nadc-2)-delch)
581 message = " (x,z,e)[1 fit] = (%f, %f, %f)\n" ;
582 message = " (x,z,e)[2 fit] = (%f, %f, %f)\n" ;
583 AliInfo(Form(message.Data(),
585 x2New, z2New, e2New)) ;
591 void AliPHOSEvalRecPoint::UnfoldTwoMergedPoints(Float_t* gamma1, Float_t* gamma2)
593 //Unfold TWO merged rec. points in the case when cluster has only one maximum,
594 //but it's fitting to the one gamma shower is too bad.
595 // Use TwoGam() to estimate the positions and energies of merged points.
601 Int_t* digits = GetDigitsList();
602 Int_t nDigits = GetMultiplicity();
603 Float_t* energies = GetEnergiesList();
604 Float_t* eFit = new Float_t[nDigits];
606 AliPHOSLoader* fLoader = AliPHOSLoader::GetPHOSLoader(fEventFolderName);
607 AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance() ;
609 for(Int_t iDigit=0; iDigit<nDigits; iDigit++)
611 AliPHOSDigit* digit = (AliPHOSDigit*)fLoader->Digits()->At( digits[iDigit] );
613 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
615 phosgeom->RelPosInModule(relid, x, z);
618 for(Int_t iMax=0; iMax<nMax; iMax++)
625 Float_t eMax = gamma[0];
626 Float_t xMax = gamma[1];
627 Float_t zMax = gamma[2];
629 Float_t dx = xMax - x;
630 Float_t dz = zMax - z;
632 GetReconstructionManager()->AG(eMax,dz,dx,amp,gx,gy);
640 for( Int_t iMax=0; iMax<nMax; iMax++)
647 Float_t eMax = gamma[0];
648 Float_t xMax = gamma[1];
649 Float_t zMax = gamma[2];
651 AliPHOSEvalRecPoint* newRP = new AliPHOSEvalRecPoint(IsCPV(),this);
652 TVector3 newpos(xMax,0,zMax);
653 newRP->SetLocalPosition(newpos);
655 for( Int_t iDigit = 0 ; iDigit < nDigits ; iDigit ++)
657 AliPHOSDigit* digit = (AliPHOSDigit*)fLoader->Digits()->At( digits[iDigit] );
658 Float_t eDigit = energies[iDigit];
660 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
662 phosgeom->RelPosInModule(relid, ix, iz);
664 Float_t dx = xMax - ix;
665 Float_t dz = zMax - iz;
666 Float_t singleShowerGain,gxMax,gyMax;
667 GetReconstructionManager()->AG(eMax,dz,dx,singleShowerGain,gxMax,gyMax);
668 Float_t totalGain = eFit[iDigit];
669 Float_t ratio = singleShowerGain/totalGain;
670 eDigit = eDigit*ratio;
671 newRP->AddDigit(*digit,eDigit);
673 AliInfo(Form("======= Split: daughter rec point %d =================",
685 void AliPHOSEvalRecPoint::EvaluatePosition()
687 // One gamma fit algorithm.
688 // Set chisq/dof of the fit.
689 // gamma1[0], gamma1[1], gamma1[2] are Energy,x,z of the reconstructed gamma, respectively.
691 Int_t nDigits = GetMultiplicity();
695 Int_t nIter = GetReconstructionManager()->OneGamNumOfIterations(); // number of iterations
696 Float_t st0 = GetReconstructionManager()->OneGamInitialStep(); // initial step
697 // const Float_t stpMin = 0.005;
698 Float_t stpMin = GetReconstructionManager()->OneGamStepMin();
699 Float_t chmin = GetReconstructionManager()->OneGamChisqMin();
707 GetLocalPosition(locpos);
708 Float_t e = GetEnergy();
709 Float_t xc = locpos.Z();
710 Float_t yc = locpos.X();
711 Float_t dx,dy,gx,gy,grxc,gryc;
713 Float_t chisq = 1.e+20;
717 Int_t dof = GetMultiplicity() - 2;
720 Float_t chstop = chmin*dof;
721 Float_t cosi,x1=0,y1=0;
724 AliPHOSLoader* fLoader = AliPHOSLoader::GetPHOSLoader(fEventFolderName);
725 AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance() ;
727 for(Int_t iter=0; iter<nIter; iter++)
733 for(Int_t iDigit = 0 ; iDigit < nDigits ; iDigit ++)
736 Float_t* energies = GetEnergiesList();
737 Int_t* digits = GetDigitsList();
738 digit = (AliPHOSDigit*)fLoader->Digits()->At( digits[iDigit] );
739 eDigit = energies[iDigit];
740 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
741 phosgeom->RelPosInModule(relid, iy, ix);
750 GetReconstructionManager()->AG(e,dx,dy,a,gx,gy);
752 AliInfo(Form(" (ix iy xc yc dx dy) %f %f %f %f %f %f",
753 ix, iy, xc, yc, dx, dy)) ;
754 Float_t chi2dg = GetReconstructionManager()->OneGamChi2(a,eDigit,e,dd);
756 // Exclude digit with too large chisquare.
757 if(chi2dg > 10) { continue; }
765 Float_t grc = TMath::Sqrt(grxc*grxc + gryc*gryc);
766 if(grc<1.e-10) grc=1.e-10;
767 Float_t sc = 1. + chisqc/chisq;
768 AliInfo(Form(" chisq: %f", chisq)) ;
772 cosi = (grx*grxc + gry*gryc)/gr/grc;
773 st = st*sc/(1.4 - cosi);
785 Float_t step = st*gr;
787 AliInfo(Form(" Iteration %d dof %d chisq/dof %f chstop/dof %f step %f stpMin %f",
788 iter, dof, chisq/dof, chstop/dof, step, stpMin)) ;
813 TVector3 newpos(gamma1[1],0,gamma1[2]);
814 //SetLocalPosition(newpos);
820 // RP->GetLocalPosition(pos);
829 Bool_t AliPHOSEvalRecPoint::KillWeakPoint()
831 // Remove this point from further procession
832 // if it's energy is too small.
834 Float_t thr0 = GetReconstructionManager()->KillGamMinEnergy();
836 if(GetEnergy()<thr0) {
837 AliInfo(Form("+++++++ Killing this rec point ++++++++++")) ;
838 RemoveFromWorkingPool(this);
846 void AliPHOSEvalRecPoint::SplitMergedShowers()
848 // Split two very close rec. points.
850 if(GetMultiplicity()<2)
856 InitTwoGam(gamma1,gamma2); // start points for fit
857 TwoGam(gamma1,gamma2); // evaluate the positions and energies
858 UnfoldTwoMergedPoints(gamma1,gamma2); // make the job
863 void AliPHOSEvalRecPoint::MergeClosePoint()
865 // merge rec.points if they are too close
866 AliPHOSLoader* fLoader = AliPHOSLoader::GetPHOSLoader(fEventFolderName);
867 // AliPHOSDigitizer* digitizer = fLoader->Digitizer();
868 // Float_t fPedestal = digitizer->GetPedestal(); // YVK 30.09.2001
869 // Float_t fSlope = digitizer->GetSlope();
871 for (Int_t i=0;i<InWorkingPool(); i++)
873 TObject* obj = GetFromWorkingPool(i);
874 if(!((TObject*)this)->IsEqual(obj))
876 AliPHOSRecPoint* rp = (AliPHOSRecPoint*)obj;
877 if(GetPHOSMod() == rp->GetPHOSMod())
881 AliInfo(Form("+++++++ Merging point 1: ++++++")) ;
883 AliInfo(Form("+++++++ and point 2: ++++++++++")) ;
884 ((AliPHOSEvalRecPoint*)rp)->Print();
886 //merge two rec. points
889 this->GetLocalPosition(lpos1);
890 rp->GetLocalPosition(lpos2);
892 Int_t* digits = rp->GetDigitsList();
893 Float_t dE = rp->GetEnergy()/(rp->GetEnergy()+this->GetEnergy());
894 Float_t newX = lpos1.X()*dE + lpos2.X()*(1.-dE);
895 Float_t newZ = lpos1.Z()*dE + lpos2.Z()*(1.-dE);
896 Float_t newE = rp->GetEnergy()+this->GetEnergy();
897 Float_t* energies = ((AliPHOSEmcRecPoint*)rp)->GetEnergiesList();
899 for(Int_t iDigit=0; iDigit<rp->GetDigitsMultiplicity(); iDigit++)
901 AliPHOSDigit* digit = (AliPHOSDigit*)fLoader->Digits()->At(digits[iDigit]);
902 Float_t eDigit = energies[iDigit];
903 this->AddDigit(*digit,eDigit);
906 TVector3 newpos(newX,0,newZ);
909 RemoveFromWorkingPool(rp);
912 AliInfo(Form("++++++ Resulting point: ++++++++")) ;
923 Int_t AliPHOSEvalRecPoint::UnfoldLocalMaxima()
925 // Make unfolding in the reconstruction point with several local maxima.
926 // Return the number of local maxima.
928 // if multiplicity less then 2 - nothing to unfold
929 if(GetMultiplicity()<2) return 1;
931 AliPHOSDigit * maxAt[1000];
932 Float_t maxAtEnergy[1000];
933 Float_t locMaxCut, logWeight;
938 AliPHOSClusterizer* clusterizer = GetClusterizer();
940 AliFatal(Form("Cannot get clusterizer")) ;
944 locMaxCut = clusterizer->GetEmcLocalMaxCut();
945 logWeight = clusterizer->GetEmcLogWeight();
948 locMaxCut = clusterizer->GetCpvLocalMaxCut();
949 logWeight = clusterizer->GetCpvLogWeight();
952 AliPHOSLoader* fLoader = AliPHOSLoader::GetPHOSLoader(fEventFolderName);
953 AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance() ;
954 TClonesArray* digits = fLoader->Digits();
956 // if number of local maxima less then 2 - nothing to unfold
957 Int_t nMax = GetNumberOfLocalMax(maxAt,maxAtEnergy,locMaxCut,digits);
958 if(nMax<2) return nMax;
960 Int_t* digitsList = GetDigitsList();
961 Int_t nDigits = GetMultiplicity();
962 Float_t* energies = GetEnergiesList();
963 Float_t* eFit = new Float_t[nDigits];
965 Int_t iDigit; //loop variable
967 for(iDigit=0; iDigit<nDigits; iDigit++)
972 for(iDigit=0; iDigit<nDigits; iDigit++)
975 AliPHOSDigit* digit = (AliPHOSDigit*)fLoader->Digits()->At( digitsList[iDigit] );
976 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
978 phosgeom->RelPosInModule(relid, x, z);
980 for(Int_t iMax=0; iMax<nMax; iMax++)
982 AliPHOSDigit* digitMax = maxAt[iMax];
983 Float_t eMax = maxAtEnergy[iMax];
984 phosgeom->AbsToRelNumbering(digitMax->GetId(), relid) ;
985 phosgeom->RelPosInModule(relid, xMax, zMax);
986 Float_t dx = xMax - x;
987 Float_t dz = zMax - z;
989 GetReconstructionManager()->AG(eMax,dz,dx,amp,gx,gy);
996 for(Int_t iMax=0; iMax<nMax; iMax++)
998 AliPHOSDigit* digitMax = maxAt[iMax];
999 phosgeom->AbsToRelNumbering(digitMax->GetId(), relid) ;
1000 phosgeom->RelPosInModule(relid, xMax, zMax);
1001 Float_t eMax = maxAtEnergy[iMax];
1003 AliPHOSEvalRecPoint* newRP = new AliPHOSEvalRecPoint(IsCPV(),this);
1004 newRP->AddDigit(*digitMax,maxAtEnergy[iMax]);
1006 //Neighbous ( matrix 3x3 around the local maximum)
1007 for(iDigit=0; iDigit<nDigits; iDigit++)
1009 AliPHOSDigit* digit = (AliPHOSDigit*)fLoader->Digits()->At( digitsList[iDigit] );
1010 Float_t eDigit = energies[iDigit];
1011 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
1013 phosgeom->RelPosInModule(relid, ix, iz);
1015 if(AreNeighbours(digitMax,digit))
1017 Float_t dx = xMax - ix;
1018 Float_t dz = zMax - iz;
1019 Float_t singleShowerGain,gxMax,gyMax;
1020 GetReconstructionManager()->AG(eMax,dz,dx,singleShowerGain,gxMax,gyMax);
1021 Float_t totalGain = eFit[iDigit];
1022 Float_t ratio = singleShowerGain/totalGain;
1023 AliInfo(Form(" ratio -> %f", ratio)) ;
1024 eDigit = eDigit*ratio;
1025 newRP->AddDigit(*digit,eDigit);
1029 TVector3 vtx(0.,0.,0.) ;
1030 TVector3 inc(0.,0.,0.) ;
1031 newRP->EvalLocalPosition(logWeight,vtx,digits,inc);
1032 AliInfo(Form("======= Unfold: daughter rec point %d =================",
1037 // RemoveFromWorkingPool(this);
1045 void AliPHOSEvalRecPoint::PrintPoint()
1047 // print rec.point to stdout
1048 AliPHOSCpvRecPoint::Print();
1051 GetLocalPosition(lpos);
1054 message = " Chi2/dof = %f" ;
1055 message += " Local (x,z) = (%f, %f) in module %d" ;
1056 AliInfo(Form(message.Data(), Chi2Dof(), lpos.X(), lpos.Z(), GetPHOSMod())) ;
1060 AliPHOSRecManager* AliPHOSEvalRecPoint::GetReconstructionManager() const
1062 // returns reconstruction manager
1063 TFolder* aliceF = (TFolder*)gROOT->FindObjectAny("YSAlice");
1064 TFolder* wPoolF = (TFolder*)aliceF->FindObject("WhiteBoard/RecPoints/PHOS/SmP");
1065 AliPHOSRecManager* recMng = (AliPHOSRecManager*)wPoolF->FindObject("AliPHOSRecManager");
1067 AliFatal(Form("Couldn't find Reconstruction Manager")) ;
1074 AliPHOSRecPoint* AliPHOSEvalRecPoint::Parent()
1077 if(fParent<0) return NULL;
1079 return (AliPHOSRecPoint*)GetFromWorkingPool(fParent);
1083 Float_t AliPHOSEvalRecPoint::Chi2Dof() const
1085 // returns a chi^2 per degree of freedom
1089 const TObject* AliPHOSEvalRecPoint::GetWorkingPool()
1091 // returns a pool of rec.points
1092 TFolder* aliceF = (TFolder*)gROOT->FindObjectAny("YSAlice");
1093 TFolder* wPoolF = (TFolder*)aliceF->FindObject("WhiteBoard/RecPoints/PHOS/SmP");
1094 TObject* wPool = wPoolF->FindObject("SmartPoints");
1096 AliFatal(Form("Couldn't find Working Pool")) ;
1102 void AliPHOSEvalRecPoint::AddToWorkingPool(TObject* obj)
1104 // add a rec.point to a pool
1105 ((TObjArray*)GetWorkingPool())->Add(obj);
1108 TObject* AliPHOSEvalRecPoint::GetFromWorkingPool(Int_t i)
1110 // return a rec.point from a pool at an index i
1111 // return fWorkingPool->At(i);
1112 return ((TObjArray*)GetWorkingPool())->At(i);
1115 Int_t AliPHOSEvalRecPoint::InWorkingPool()
1117 // return the number of rec.points in a pool
1118 return ((TObjArray*)GetWorkingPool())->GetEntries();
1121 void AliPHOSEvalRecPoint::RemoveFromWorkingPool(TObject* obj)
1123 // remove a rec.point from a pool
1124 ((TObjArray*)GetWorkingPool())->Remove(obj);
1125 ((TObjArray*)GetWorkingPool())->Compress();
1128 void AliPHOSEvalRecPoint::PrintWorkingPool()
1130 // print pool of rec.points to stdout
1131 ((TObjArray*)GetWorkingPool())->Print();