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 **************************************************************************/
16 //_________________________________________________________________________
17 // Implementation version 1 of algorithm class to construct PHOS track segments
18 // Associates EMC and PPSD clusters
19 // Unfolds the EMC cluster
21 //*-- Author: Dmitri Peressounko (RRC Ki & SUBATECH)
24 // --- ROOT system ---
26 #include "TObjArray.h"
27 #include "TClonesArray.h"
28 #include "TObjectTable.h"
30 // --- Standard library ---
34 // --- AliRoot header files ---
36 #include "AliPHOSTrackSegmentMakerv1.h"
37 #include "AliPHOSIndexToObject.h"
38 #include "AliPHOSTrackSegment.h"
39 #include "AliPHOSCpvRecPoint.h"
40 #include "AliPHOSLink.h"
41 #include "AliPHOSv0.h"
44 extern void UnfoldingChiSquare(Int_t &nPar, Double_t *Grad, Double_t & fret, Double_t *x, Int_t iflag) ;
46 ClassImp( AliPHOSTrackSegmentMakerv1)
49 //____________________________________________________________________________
50 AliPHOSTrackSegmentMakerv1::AliPHOSTrackSegmentMakerv1() : AliPHOSTrackSegmentMaker()
55 //clusters are sorted in "rows" and "columns" of width geom->GetCrystalSize(0),
56 fDelta = fR0 + fGeom->GetCrystalSize(0) ;
57 if(!gMinuit) gMinuit = new TMinuit(100) ;
61 //____________________________________________________________________________
62 AliPHOSTrackSegmentMakerv1::~AliPHOSTrackSegmentMakerv1()
67 //____________________________________________________________________________
68 Bool_t AliPHOSTrackSegmentMakerv1::FindFit(AliPHOSEmcRecPoint * emcRP, int * maxAt, Float_t * maxAtEnergy,
69 Int_t nPar, Float_t * fitparameters)
71 // Calls TMinuit to fit the energy distribution of a cluster with several maxima
73 gMinuit->mncler(); // Reset Minuit list of paramters
74 gMinuit->SetPrintLevel(-1) ; // No Printout
75 gMinuit->SetFCN(UnfoldingChiSquare) ; // To set the address of the minimization function
76 gMinuit->SetObjectFit(emcRP) ; // To tranfer pointer to UnfoldingChiSquare
78 // filling initial values for fit parameters
79 AliPHOSDigit * digit ;
83 Int_t nDigits = (Int_t) nPar / 3 ;
88 for(iDigit = 0; iDigit < nDigits; iDigit++){
89 digit = (AliPHOSDigit *) maxAt[iDigit];
94 fGeom->AbsToRelNumbering(digit->GetId(), relid) ;
95 fGeom->RelPosInModule(relid, x, z) ;
97 Float_t energy = maxAtEnergy[iDigit] ;
99 gMinuit->mnparm(index, "x", x, 0.1, 0, 0, ierflg) ;
102 cout << "PHOS Unfolding> Unable to set initial value for fit procedure : x = " << x << endl ;
105 gMinuit->mnparm(index, "z", z, 0.1, 0, 0, ierflg) ;
108 cout << "PHOS Unfolding> Unable to set initial value for fit procedure : z = " << z << endl ;
111 gMinuit->mnparm(index, "Energy", energy , 0.05*energy, 0., 4.*energy, ierflg) ;
114 cout << "PHOS Unfolding> Unable to set initial value for fit procedure : energy = " << energy << endl ;
119 Double_t p0 = 0.1 ; // "Tolerance" Evaluation stops when EDM = 0.0001*p0 ; The number of function call slightly
124 gMinuit->mnexcm("SET STR", &p2, 0, ierflg) ; // force TMinuit to reduce function calls
125 gMinuit->mnexcm("SET GRA", &p1, 1, ierflg) ; // force TMinuit to use my gradient
126 gMinuit->SetMaxIterations(5);
127 gMinuit->mnexcm("SET NOW", &p2 , 0, ierflg) ; // No Warnings
129 gMinuit->mnexcm("MIGRAD", &p0, 0, ierflg) ; // minimize
131 if(ierflg == 4){ // Minimum not found
132 cout << "PHOS Unfolding> Fit not converged, cluster abandoned "<< endl ;
135 for(index = 0; index < nPar; index++){
138 gMinuit->GetParameter(index, val, err) ; // Returns value and error of parameter index
139 fitparameters[index] = val ;
146 //____________________________________________________________________________
147 void AliPHOSTrackSegmentMakerv1::FillOneModule(AliPHOSRecPoint::RecPointsList * emcIn,
149 AliPHOSRecPoint::RecPointsList * ppsdIn,
151 TArrayI * ppsdOutLow,
154 Int_t & ppsdStopedAt)
156 // Fill xxxOut arrays with clusters from one PHOS module
158 AliPHOSEmcRecPoint * emcRecPoint ;
159 AliPHOSPpsdRecPoint * ppsdRecPoint ;
162 Int_t nEmcUnfolded = emcIn->GetEntries() ;
163 emcOut->Set(nEmcUnfolded);
165 for(index = emcStopedAt; index < nEmcUnfolded; index++){
167 emcRecPoint = (AliPHOSEmcRecPoint *) emcIn->At(index) ;
169 if(emcRecPoint->GetPHOSMod() != phosmod )
172 emcOut->AddAt(emcRecPoint->GetIndexInList(),inEmcOut) ;
175 emcOut->Set(inEmcOut) ;
177 emcStopedAt = index ;
179 ppsdOutLow->Set(ppsdIn->GetEntries()) ;
180 ppsdOutUp->Set(ppsdIn->GetEntries()) ;
183 for(index = ppsdStopedAt; index < ppsdIn->GetEntries(); index++){
184 ppsdRecPoint = (AliPHOSPpsdRecPoint *) ppsdIn->At(index) ;
185 if(ppsdRecPoint->GetPHOSMod() != phosmod )
187 if(phosmod <= fGeom->GetNCPVModules()) //in CPV
188 ppsdOutUp->AddAt(index,inPpsdUp++) ;
190 if(ppsdRecPoint->GetUp() )
191 ppsdOutUp->AddAt(index,inPpsdUp++) ;
193 ppsdOutLow->AddAt(index,inPpsdLow++) ;
196 ppsdOutLow->Set(inPpsdLow);
197 ppsdOutUp->Set(inPpsdUp);
198 ppsdStopedAt = index ;
201 //____________________________________________________________________________
202 Float_t AliPHOSTrackSegmentMakerv1::GetDistanceInPHOSPlane(AliPHOSEmcRecPoint * emcclu,AliPHOSPpsdRecPoint * PpsdClu, Bool_t &toofar)
204 // Calculates the distance between the EMC RecPoint and the PPSD RecPoint
211 emcclu->GetLocalPosition(vecEmc) ;
212 PpsdClu->GetLocalPosition(vecPpsd) ;
213 if(emcclu->GetPHOSMod() == PpsdClu->GetPHOSMod()){
214 // if(vecPpsd.X() >= vecEmc.X() - fDelta ){
215 // if(vecPpsd.Z() >= vecEmc.Z() - fDelta ){
216 // Correct to difference in CPV and EMC position due to different distance to center.
217 // we assume, that particle moves from center
218 Float_t dCPV = fGeom->GetIPtoOuterCoverDistance();
219 Float_t dEMC = fGeom->GetIPtoCrystalSurface() ;
221 vecPpsd = dEMC * vecPpsd - vecEmc ;
223 // } // if zPpsd >= zEmc - fDelta
225 //} // if xPpsd >= xEmc - fDelta
238 //____________________________________________________________________________
239 void AliPHOSTrackSegmentMakerv1::MakeLinks(TArrayI * emcRecPoints, TArrayI * ppsdRecPointsUp,
240 TArrayI * ppsdRecPointsLow, TClonesArray * linklowArray,
241 TClonesArray *linkupArray)
243 // Finds distances (links) between all EMC and PPSD clusters, which are not further apart from each other than fR0
246 AliPHOSPpsdRecPoint * ppsdlow ;
247 AliPHOSPpsdRecPoint * ppsdup ;
248 AliPHOSEmcRecPoint * emcclu ;
255 for(iEmcRP = 0; iEmcRP < emcRecPoints->GetSize(); iEmcRP++ ) {
256 emcclu = (AliPHOSEmcRecPoint *) fPlease->GimeRecPoint(emcRecPoints->At(iEmcRP),"emc") ;
261 for(iPpsdLow = 0; iPpsdLow < ppsdRecPointsLow->GetSize();iPpsdLow++ ) {
263 ppsdlow = (AliPHOSPpsdRecPoint *) fPlease->GimeRecPoint(ppsdRecPointsLow->At(iPpsdLow),"ppsd") ;
264 Float_t r = GetDistanceInPHOSPlane(emcclu, ppsdlow, toofar) ;
269 new( (*linklowArray)[iLinkLow++]) AliPHOSLink(r, iEmcRP, iPpsdLow) ;
274 for(iPpsdUp = 0; iPpsdUp < ppsdRecPointsUp->GetSize();iPpsdUp++ ) {
276 ppsdup = (AliPHOSPpsdRecPoint *)fPlease->GimeRecPoint(ppsdRecPointsUp->At(iPpsdUp),"ppsd") ;
277 Float_t r = GetDistanceInPHOSPlane(emcclu, ppsdup, toofar) ;
282 new( (*linkupArray)[iLinkUp++]) AliPHOSLink(r, iEmcRP, iPpsdUp) ;
287 linklowArray->Sort() ; //first links with smallest distances
288 linkupArray->Sort() ;
291 //____________________________________________________________________________
292 void AliPHOSTrackSegmentMakerv1::MakePairs(TArrayI * emcRecPoints,
293 TArrayI * ppsdRecPointsUp,
294 TArrayI * ppsdRecPointsLow,
295 TClonesArray * linklowArray,
296 TClonesArray * linkupArray,
297 AliPHOSTrackSegment::TrackSegmentsList * trsl)
300 // Finds the smallest links and makes pairs of PPSD and EMC clusters with smallest distance
302 TIter nextLow(linklowArray) ;
303 TIter nextUp(linkupArray) ;
305 AliPHOSLink * linkLow ;
306 AliPHOSLink * linkUp ;
312 AliPHOSPpsdRecPoint * nullpointer = 0 ;
315 while ( (linkLow = (AliPHOSLink *)nextLow() ) ){
317 emc = emcRecPoints->At(linkLow->GetEmc()) ;
318 ppsdLow = ppsdRecPointsLow->At(linkLow->GetPpsd()) ;
320 if( (emc >= 0) && (ppsdLow >= 0) ){ // RecPoints not removed yet
322 new( (*trsl)[fNTrackSegments] ) AliPHOSTrackSegment((AliPHOSEmcRecPoint *)fPlease->GimeRecPoint(emc,"emc"),
324 (AliPHOSPpsdRecPoint *)fPlease->GimeRecPoint(ppsdLow,"ppsd") ) ;
325 ((AliPHOSTrackSegment* )trsl->At(fNTrackSegments))->SetIndexInList(fNTrackSegments);
326 //replace index of emc to negative and shifted index of TS
327 emcRecPoints->AddAt(-2 - fNTrackSegments,linkLow->GetEmc()) ;
328 //replace index of PPSD Low to negative and shifted index of TS
329 ppsdRecPointsLow->AddAt(-2 - fNTrackSegments,linkLow->GetPpsd()) ;
335 while ( (linkUp = (AliPHOSLink *)nextUp() ) ){
336 emc = emcRecPoints->At(linkUp->GetEmc()) ;
337 if(emc != -1){ //without ppsd Up yet
339 ppsdUp = ppsdRecPointsUp->At(linkUp->GetPpsd()) ;
340 if(ppsdUp >= 0){ //ppsdUp still exist
342 if(emc >= 0){ //without ppsd Low => create new TS
344 fNTrackSegments = trsl->GetEntries() ;
345 new( (*trsl)[fNTrackSegments] ) AliPHOSTrackSegment((AliPHOSEmcRecPoint *) fPlease->GimeRecPoint(emc,"emc"),
346 (AliPHOSPpsdRecPoint *)fPlease->GimeRecPoint(ppsdUp,"ppsd"),
348 ((AliPHOSTrackSegment *) trsl->At(fNTrackSegments))->SetIndexInList(fNTrackSegments);
351 else{ // append ppsd Up to existing TS
352 ((AliPHOSTrackSegment *)trsl->At(-2-emc))->SetPpsdUpRecPoint((AliPHOSPpsdRecPoint *)fPlease->GimeRecPoint(ppsdUp,"ppsd"));
355 emcRecPoints->AddAt(-1,linkUp->GetEmc()) ; //Mark that PPSD Up found
356 //replace index of PPSD Up to negative and shifted index of TS
357 ppsdRecPointsUp->AddAt(-2 - fNTrackSegments,linkUp->GetPpsd()) ;
358 } //if ppsdUp still exist
363 for(iEmcRP = 0; iEmcRP <emcRecPoints->GetSize() ; iEmcRP++ ){
364 emc = emcRecPoints->At(iEmcRP) ;
368 new( (*trsl)[fNTrackSegments] ) AliPHOSTrackSegment((AliPHOSEmcRecPoint *) fPlease->GimeRecPoint(emc,"emc"),
369 nullpointer, nullpointer ) ;
370 ((AliPHOSTrackSegment *) trsl->At(fNTrackSegments))->SetIndexInList(fNTrackSegments);
378 //____________________________________________________________________________
379 void AliPHOSTrackSegmentMakerv1::MakeTrackSegments(DigitsList * dl,
380 AliPHOSRecPoint::RecPointsList * emcl,
381 AliPHOSRecPoint::RecPointsList * ppsdl,
382 AliPHOSTrackSegment::TrackSegmentsList * trsl)
384 // Makes the track segments out of the list of EMC and PPSD Recpoints and stores them in a list
386 Int_t emcStopedAt = 0 ;
387 Int_t ppsdStopedAt = 0 ;
389 fNTrackSegments = 0 ;
391 TArrayI * emcRecPoints = new TArrayI(1000) ; // these arrays keep indexes
392 TArrayI * ppsdRecPointsUp = new TArrayI(1000) ; // of RecPoints, which are
393 TArrayI * ppsdRecPointsLow = new TArrayI(1000) ; // kept in TClonesArray's emcl, ppsdl, cpv
395 TClonesArray * linklowArray = new TClonesArray("AliPHOSLink", 1000);
396 TClonesArray * linkupArray = new TClonesArray("AliPHOSLink", 1000);
399 UnfoldAll(dl, emcl) ; // Unfolds all EMC clusters
400 UnfoldAll(dl, ppsdl) ; // Unfolds all CPV clusters
404 while(phosmod <= fGeom->GetNModules() ){
406 FillOneModule(emcl, emcRecPoints, ppsdl, ppsdRecPointsUp, ppsdRecPointsLow, phosmod, emcStopedAt, ppsdStopedAt) ;
408 MakeLinks(emcRecPoints, ppsdRecPointsUp, ppsdRecPointsLow, linklowArray, linkupArray) ;
410 MakePairs(emcRecPoints, ppsdRecPointsUp, ppsdRecPointsLow, linklowArray, linkupArray, trsl) ;
412 emcRecPoints->Reset() ;
414 ppsdRecPointsUp->Reset() ;
416 ppsdRecPointsLow->Reset() ;
418 linkupArray->Clear() ;
420 linklowArray->Clear() ;
425 delete emcRecPoints ;
428 delete ppsdRecPointsUp ;
429 ppsdRecPointsUp = 0 ;
431 delete ppsdRecPointsLow ;
432 ppsdRecPointsLow = 0 ;
437 delete linklowArray ;
441 //____________________________________________________________________________
442 void AliPHOSTrackSegmentMakerv1::MakeTrackSegmentsCPV(DigitsList * dl,
443 AliPHOSRecPoint::RecPointsList * emcl,
444 AliPHOSRecPoint::RecPointsList * cpvl)
446 // Unfold clusters in EMC and CPV and refill reconstructed point lists emcl and ppsdl
447 // Yuri Kharlov. 19 October 2000
449 fNTrackSegments = 0 ;
451 TArrayI * emcRecPoints = new TArrayI(1000) ; // these arrays keep indexes
452 TArrayI * cpvRecPoints = new TArrayI(1000) ; // of RecPoints, which are kept in emcl and ppsdl
455 UnfoldAll(dl, emcl) ; // Unfolds all EMC clusters
456 UnfoldAll(dl, cpvl) ; // Unfolds all CPV clusters
459 // Int_t phosmod = 1 ;
460 // Int_t emcStopedAt = 0 ;
461 // Int_t cpvStopedAt = 0 ;
462 // while(phosmod <= fGeom->GetNModules() ){
463 // FillOneModule(emcl, emcRecPoints, ppsdl, cpvRecPoints, phosmod, emcStopedAt, cpvStopedAt) ;
464 // emcRecPoints->Reset() ;
465 // cpvRecPoints->Reset() ;
469 delete emcRecPoints ; emcRecPoints = 0 ;
470 delete cpvRecPoints ; cpvRecPoints = 0 ;
473 //____________________________________________________________________________
474 Double_t AliPHOSTrackSegmentMakerv1::ShowerShape(Double_t r)
476 // Shape of the shower (see PHOS TDR)
477 // If you change this function, change also the gradien evaluation in ChiSquare()
479 Double_t r4 = r*r*r*r ;
480 Double_t r295 = TMath::Power(r, 2.95) ;
481 Double_t shape = TMath::Exp( -r4 * (1. / (2.32 + 0.26 * r4) + 0.0316 / (1 + 0.0652 * r295) ) ) ;
485 //____________________________________________________________________________
486 void AliPHOSTrackSegmentMakerv1::UnfoldAll(DigitsList * dl, AliPHOSRecPoint::RecPointsList * emcIn)
488 // Performs unfolding of all EMC/CPV but NOT ppsd clusters, sorts them and resets indexes in RecPoints
490 AliPHOSEmcRecPoint * emcRecPoint ;
492 Int_t nEmcUnfolded = emcIn->GetEntries() ;
494 Int_t nModulesToUnfold ;
496 if(emcIn->GetEntries() > 0){
498 if(((AliPHOSRecPoint *)emcIn->At(0))->IsEmc()){
499 nModulesToUnfold = fGeom->GetNModules() ;
502 nModulesToUnfold = fGeom->GetNCPVModules() ;
505 for(index = 0 ; index < nEmcUnfolded; index++){
507 emcRecPoint = (AliPHOSEmcRecPoint *) emcIn->At(index) ;
508 if(emcRecPoint->GetPHOSMod()> nModulesToUnfold)
511 Int_t nMultipl = emcRecPoint->GetMultiplicity() ;
512 Int_t * maxAt = new Int_t[nMultipl] ;
513 Float_t * maxAtEnergy = new Float_t[nMultipl] ;
514 Int_t nMax = emcRecPoint->GetNumberOfLocalMax(maxAt, maxAtEnergy) ;
516 if( nMax > 1 ) { // if cluster is very flat (no pronounced maximum) then nMax = 0
517 UnfoldClusters(dl, emcIn, emcRecPoint, nMax, maxAt, maxAtEnergy) ;
518 emcIn->Remove(emcRecPoint);
525 delete[] maxAtEnergy ;
526 } //Unfolding finished
530 // to set index to new and correct index of old RecPoints
531 for( index = 0 ; index < emcIn->GetEntries() ; index++)
532 ((AliPHOSEmcRecPoint *) emcIn->At(index))->SetIndexInList(index) ;
537 //____________________________________________________________________________
538 void AliPHOSTrackSegmentMakerv1::UnfoldClusters(DigitsList * dl,
539 AliPHOSRecPoint::RecPointsList * emcIn,
540 AliPHOSEmcRecPoint * iniEmc,
543 Float_t * maxAtEnergy)
545 // Performs the unfolding of a cluster with nMax overlapping showers
546 // This is time consuming (use the (Un)SetUnfolFlag() )
548 Int_t nPar = 3 * nMax ;
549 Float_t * fitparameters = new Float_t[nPar] ;
552 Bool_t rv = FindFit(iniEmc, maxAt, maxAtEnergy, nPar, fitparameters) ;
554 // Fit failed, return and remove cluster
555 delete[] fitparameters ;
563 Int_t nDigits = iniEmc->GetMultiplicity() ;
569 Float_t * efit = new Float_t[nDigits] ;
573 AliPHOSDigit * digit ;
574 Int_t * emcDigits = iniEmc->GetDigitsList() ;
575 Float_t * emcEnergies = iniEmc->GetEnergiesList() ;
577 Int_t iRecPoint = emcIn->GetEntries() ;
579 for(iDigit = 0 ; iDigit < nDigits ; iDigit ++){
580 digit = fPlease->GimeDigit( emcDigits[iDigit] ) ;
581 fGeom->AbsToRelNumbering(digit->GetId(), relid) ;
582 fGeom->RelPosInModule(relid, xDigit, zDigit) ;
586 while(iparam < nPar ){
587 xpar = fitparameters[iparam] ;
588 zpar = fitparameters[iparam+1] ;
589 epar = fitparameters[iparam+2] ;
591 distance = (xDigit - xpar) * (xDigit - xpar) + (zDigit - zpar) * (zDigit - zpar) ;
592 distance = TMath::Sqrt(distance) ;
593 efit[iDigit] += epar * AliPHOSTrackSegmentMakerv1::ShowerShape(distance) ;
601 while(iparam < nPar ){
602 xpar = fitparameters[iparam] ;
603 zpar = fitparameters[iparam+1] ;
604 epar = fitparameters[iparam+2] ;
607 if(iRecPoint >= emcIn->GetSize())
608 emcIn->Expand(2*iRecPoint) ;
611 (*emcIn)[iRecPoint] = new AliPHOSEmcRecPoint( iniEmc->GetLogWeightCut(), iniEmc->GetLocMaxCut() ) ;
613 AliPHOSEmcRecPoint * emcRP ;
614 emcRP = (AliPHOSEmcRecPoint *) emcIn->At(iRecPoint);
617 for(iDigit = 0 ; iDigit < nDigits ; iDigit ++){
618 digit = fPlease->GimeDigit( emcDigits[iDigit] ) ;
619 fGeom->AbsToRelNumbering(digit->GetId(), relid) ;
620 fGeom->RelPosInModule(relid, xDigit, zDigit) ;
621 distance = (xDigit - xpar) * (xDigit - xpar) + (zDigit - zpar) * (zDigit - zpar) ;
622 distance = TMath::Sqrt(distance) ;
623 ratio = epar * AliPHOSTrackSegmentMakerv1::ShowerShape(distance) / efit[iDigit] ;
624 eDigit = emcEnergies[iDigit] * ratio ;
625 emcRP->AddDigit( *digit, eDigit ) ;
629 (*emcIn)[iRecPoint] = new AliPHOSCpvRecPoint( iniEmc->GetLogWeightCut(), iniEmc->GetLocMaxCut() ) ;
631 AliPHOSCpvRecPoint * cpvRP ;
632 cpvRP = (AliPHOSCpvRecPoint *) emcIn->At(iRecPoint);
636 for(iDigit = 0 ; iDigit < nDigits ; iDigit ++){
637 digit = fPlease->GimeDigit( emcDigits[iDigit] ) ;
638 fGeom->AbsToRelNumbering(digit->GetId(), relid) ;
639 fGeom->RelPosInModule(relid, xDigit, zDigit) ;
640 distance = (xDigit - xpar) * (xDigit - xpar) + (zDigit - zpar) * (zDigit - zpar) ;
641 distance = TMath::Sqrt(distance) ;
642 ratio = epar * AliPHOSTrackSegmentMakerv1::ShowerShape(distance) / efit[iDigit] ;
643 eDigit = emcEnergies[iDigit] * ratio ;
644 cpvRP->AddDigit( *digit, eDigit ) ;
650 delete[] fitparameters ;
655 //______________________________________________________________________________
656 void UnfoldingChiSquare(Int_t & nPar, Double_t * Grad, Double_t & fret, Double_t * x, Int_t iflag)
658 // Calculates th Chi square for the cluster unfolding minimization
659 // Number of parameters, Gradient, Chi squared, parameters, what to do
661 AliPHOSEmcRecPoint * emcRP = (AliPHOSEmcRecPoint *) gMinuit->GetObjectFit() ; // EmcRecPoint to fit
663 Int_t * emcDigits = emcRP->GetDigitsList() ;
665 Int_t nOfDigits = emcRP->GetDigitsMultiplicity() ;
667 Float_t * emcEnergies = emcRP->GetEnergiesList() ;
669 AliPHOSGeometry * geom = AliPHOSGeometry::GetInstance() ;
671 AliPHOSIndexToObject * please = AliPHOSIndexToObject::GetInstance() ;
677 for(iparam = 0 ; iparam < nPar ; iparam++)
678 Grad[iparam] = 0 ; // Will evaluate gradient
682 AliPHOSDigit * digit ;
685 for( iDigit = 0 ; iDigit < nOfDigits ; iDigit++) {
687 digit = please->GimeDigit( emcDigits[iDigit] ) ;
693 geom->AbsToRelNumbering(digit->GetId(), relid) ;
695 geom->RelPosInModule(relid, xDigit, zDigit) ;
697 if(iflag == 2){ // calculate gradient
700 while(iParam < nPar ){
701 Double_t distance = (xDigit - x[iParam]) * (xDigit - x[iParam]) ;
703 distance += (zDigit - x[iParam]) * (zDigit - x[iParam]) ;
704 distance = TMath::Sqrt( distance ) ;
706 efit += x[iParam] * AliPHOSTrackSegmentMakerv1::ShowerShape(distance) ;
709 Double_t sum = 2. * (efit - emcEnergies[iDigit]) / emcEnergies[iDigit] ; // Here we assume, that sigma = sqrt(E)
711 while(iParam < nPar ){
712 Double_t xpar = x[iParam] ;
713 Double_t zpar = x[iParam+1] ;
714 Double_t epar = x[iParam+2] ;
715 Double_t dr = TMath::Sqrt( (xDigit - xpar) * (xDigit - xpar) + (zDigit - zpar) * (zDigit - zpar) );
716 Double_t shape = sum * AliPHOSTrackSegmentMakerv1::ShowerShape(dr) ;
717 Double_t r4 = dr*dr*dr*dr ;
718 Double_t r295 = TMath::Power(dr,2.95) ;
719 Double_t deriv =-4. * dr*dr * ( 2.32 / ( (2.32 + 0.26 * r4) * (2.32 + 0.26 * r4) ) +
720 0.0316 * (1. + 0.0171 * r295) / ( ( 1. + 0.0652 * r295) * (1. + 0.0652 * r295) ) ) ;
722 Grad[iParam] += epar * shape * deriv * (xpar - xDigit) ; // Derivative over x
724 Grad[iParam] += epar * shape * deriv * (zpar - zDigit) ; // Derivative over z
726 Grad[iParam] += shape ; // Derivative over energy
733 while(iparam < nPar ){
734 Double_t xpar = x[iparam] ;
735 Double_t zpar = x[iparam+1] ;
736 Double_t epar = x[iparam+2] ;
738 Double_t distance = (xDigit - xpar) * (xDigit - xpar) + (zDigit - zpar) * (zDigit - zpar) ;
739 distance = TMath::Sqrt(distance) ;
740 efit += epar * AliPHOSTrackSegmentMakerv1::ShowerShape(distance) ;
743 fret += (efit-emcEnergies[iDigit])*(efit-emcEnergies[iDigit])/emcEnergies[iDigit] ;
744 // Here we assume, that sigma = sqrt(E)