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 Double_t AliPHOSTrackSegmentMakerv1::ShowerShape(Double_t r)
444 // Shape of the shower (see PHOS TDR)
445 // If you change this function, change also the gradien evaluation in ChiSquare()
447 Double_t r4 = r*r*r*r ;
448 Double_t r295 = TMath::Power(r, 2.95) ;
449 Double_t shape = TMath::Exp( -r4 * (1. / (2.32 + 0.26 * r4) + 0.0316 / (1 + 0.0652 * r295) ) ) ;
453 //____________________________________________________________________________
454 void AliPHOSTrackSegmentMakerv1::UnfoldAll(DigitsList * dl, AliPHOSRecPoint::RecPointsList * emcIn)
456 // Performs unfolding of all EMC/CPV but NOT ppsd clusters, sorts them and resets indexes in RecPoints
458 AliPHOSEmcRecPoint * emcRecPoint ;
460 Int_t nEmcUnfolded = emcIn->GetEntries() ;
462 Int_t nModulesToUnfold ;
464 if(emcIn->GetEntries() > 0){
466 if(((AliPHOSRecPoint *)emcIn->At(0))->IsEmc()){
467 nModulesToUnfold = fGeom->GetNModules() ;
470 nModulesToUnfold = fGeom->GetNCPVModules() ;
473 for(index = 0 ; index < nEmcUnfolded; index++){
475 emcRecPoint = (AliPHOSEmcRecPoint *) emcIn->At(index) ;
476 if(emcRecPoint->GetPHOSMod()> nModulesToUnfold)
479 Int_t nMultipl = emcRecPoint->GetMultiplicity() ;
480 Int_t * maxAt = new Int_t[nMultipl] ;
481 Float_t * maxAtEnergy = new Float_t[nMultipl] ;
482 Int_t nMax = emcRecPoint->GetNumberOfLocalMax(maxAt, maxAtEnergy) ;
484 if( nMax > 1 ) { // if cluster is very flat (no pronounced maximum) then nMax = 0
485 UnfoldClusters(dl, emcIn, emcRecPoint, nMax, maxAt, maxAtEnergy) ;
486 emcIn->Remove(emcRecPoint);
493 delete[] maxAtEnergy ;
494 } //Unfolding finished
498 // to set index to new and correct index of old RecPoints
499 for( index = 0 ; index < emcIn->GetEntries() ; index++)
500 ((AliPHOSEmcRecPoint *) emcIn->At(index))->SetIndexInList(index) ;
505 //____________________________________________________________________________
506 void AliPHOSTrackSegmentMakerv1::UnfoldClusters(DigitsList * dl,
507 AliPHOSRecPoint::RecPointsList * emcIn,
508 AliPHOSEmcRecPoint * iniEmc,
511 Float_t * maxAtEnergy)
513 // Performs the unfolding of a cluster with nMax overlapping showers
514 // This is time consuming (use the (Un)SetUnfolFlag() )
516 Int_t nPar = 3 * nMax ;
517 Float_t * fitparameters = new Float_t[nPar] ;
520 Bool_t rv = FindFit(iniEmc, maxAt, maxAtEnergy, nPar, fitparameters) ;
522 // Fit failed, return and remove cluster
523 delete[] fitparameters ;
531 Int_t nDigits = iniEmc->GetMultiplicity() ;
537 Float_t * efit = new Float_t[nDigits] ;
541 AliPHOSDigit * digit ;
542 Int_t * emcDigits = iniEmc->GetDigitsList() ;
543 Float_t * emcEnergies = iniEmc->GetEnergiesList() ;
545 Int_t iRecPoint = emcIn->GetEntries() ;
547 for(iDigit = 0 ; iDigit < nDigits ; iDigit ++){
548 digit = fPlease->GimeDigit( emcDigits[iDigit] ) ;
549 fGeom->AbsToRelNumbering(digit->GetId(), relid) ;
550 fGeom->RelPosInModule(relid, xDigit, zDigit) ;
554 while(iparam < nPar ){
555 xpar = fitparameters[iparam] ;
556 zpar = fitparameters[iparam+1] ;
557 epar = fitparameters[iparam+2] ;
559 distance = (xDigit - xpar) * (xDigit - xpar) + (zDigit - zpar) * (zDigit - zpar) ;
560 distance = TMath::Sqrt(distance) ;
561 efit[iDigit] += epar * AliPHOSTrackSegmentMakerv1::ShowerShape(distance) ;
569 while(iparam < nPar ){
570 xpar = fitparameters[iparam] ;
571 zpar = fitparameters[iparam+1] ;
572 epar = fitparameters[iparam+2] ;
575 if(iRecPoint >= emcIn->GetSize())
576 emcIn->Expand(2*iRecPoint) ;
579 (*emcIn)[iRecPoint] = new AliPHOSEmcRecPoint( iniEmc->GetLogWeightCut(), iniEmc->GetLocMaxCut() ) ;
581 AliPHOSEmcRecPoint * emcRP ;
582 emcRP = (AliPHOSEmcRecPoint *) emcIn->At(iRecPoint);
585 for(iDigit = 0 ; iDigit < nDigits ; iDigit ++){
586 digit = fPlease->GimeDigit( emcDigits[iDigit] ) ;
587 fGeom->AbsToRelNumbering(digit->GetId(), relid) ;
588 fGeom->RelPosInModule(relid, xDigit, zDigit) ;
589 distance = (xDigit - xpar) * (xDigit - xpar) + (zDigit - zpar) * (zDigit - zpar) ;
590 distance = TMath::Sqrt(distance) ;
591 ratio = epar * AliPHOSTrackSegmentMakerv1::ShowerShape(distance) / efit[iDigit] ;
592 eDigit = emcEnergies[iDigit] * ratio ;
593 emcRP->AddDigit( *digit, eDigit ) ;
598 (*emcIn)[iRecPoint] = new AliPHOSCpvRecPoint( iniEmc->GetLogWeightCut(), iniEmc->GetLocMaxCut() ) ;
600 AliPHOSCpvRecPoint * cpvRP ;
601 cpvRP = (AliPHOSCpvRecPoint *) emcIn->At(iRecPoint);
605 for(iDigit = 0 ; iDigit < nDigits ; iDigit ++){
606 digit = fPlease->GimeDigit( emcDigits[iDigit] ) ;
607 fGeom->AbsToRelNumbering(digit->GetId(), relid) ;
608 fGeom->RelPosInModule(relid, xDigit, zDigit) ;
609 distance = (xDigit - xpar) * (xDigit - xpar) + (zDigit - zpar) * (zDigit - zpar) ;
610 distance = TMath::Sqrt(distance) ;
611 ratio = epar * AliPHOSTrackSegmentMakerv1::ShowerShape(distance) / efit[iDigit] ;
612 eDigit = emcEnergies[iDigit] * ratio ;
613 cpvRP->AddDigit( *digit, eDigit ) ;
620 delete[] fitparameters ;
625 //______________________________________________________________________________
626 void UnfoldingChiSquare(Int_t & nPar, Double_t * Grad, Double_t & fret, Double_t * x, Int_t iflag)
628 // Calculates th Chi square for the cluster unfolding minimization
629 // Number of parameters, Gradient, Chi squared, parameters, what to do
631 AliPHOSEmcRecPoint * emcRP = (AliPHOSEmcRecPoint *) gMinuit->GetObjectFit() ; // EmcRecPoint to fit
633 Int_t * emcDigits = emcRP->GetDigitsList() ;
635 Int_t nOfDigits = emcRP->GetDigitsMultiplicity() ;
637 Float_t * emcEnergies = emcRP->GetEnergiesList() ;
639 AliPHOSGeometry * geom = AliPHOSGeometry::GetInstance() ;
641 AliPHOSIndexToObject * please = AliPHOSIndexToObject::GetInstance() ;
647 for(iparam = 0 ; iparam < nPar ; iparam++)
648 Grad[iparam] = 0 ; // Will evaluate gradient
652 AliPHOSDigit * digit ;
655 for( iDigit = 0 ; iDigit < nOfDigits ; iDigit++) {
657 digit = please->GimeDigit( emcDigits[iDigit] ) ;
663 geom->AbsToRelNumbering(digit->GetId(), relid) ;
665 geom->RelPosInModule(relid, xDigit, zDigit) ;
667 if(iflag == 2){ // calculate gradient
670 while(iParam < nPar ){
671 Double_t distance = (xDigit - x[iParam]) * (xDigit - x[iParam]) ;
673 distance += (zDigit - x[iParam]) * (zDigit - x[iParam]) ;
674 distance = TMath::Sqrt( distance ) ;
676 efit += x[iParam] * AliPHOSTrackSegmentMakerv1::ShowerShape(distance) ;
679 Double_t sum = 2. * (efit - emcEnergies[iDigit]) / emcEnergies[iDigit] ; // Here we assume, that sigma = sqrt(E)
681 while(iParam < nPar ){
682 Double_t xpar = x[iParam] ;
683 Double_t zpar = x[iParam+1] ;
684 Double_t epar = x[iParam+2] ;
685 Double_t dr = TMath::Sqrt( (xDigit - xpar) * (xDigit - xpar) + (zDigit - zpar) * (zDigit - zpar) );
686 Double_t shape = sum * AliPHOSTrackSegmentMakerv1::ShowerShape(dr) ;
687 Double_t r4 = dr*dr*dr*dr ;
688 Double_t r295 = TMath::Power(dr,2.95) ;
689 Double_t deriv =-4. * dr*dr * ( 2.32 / ( (2.32 + 0.26 * r4) * (2.32 + 0.26 * r4) ) +
690 0.0316 * (1. + 0.0171 * r295) / ( ( 1. + 0.0652 * r295) * (1. + 0.0652 * r295) ) ) ;
692 Grad[iParam] += epar * shape * deriv * (xpar - xDigit) ; // Derivative over x
694 Grad[iParam] += epar * shape * deriv * (zpar - zDigit) ; // Derivative over z
696 Grad[iParam] += shape ; // Derivative over energy
703 while(iparam < nPar ){
704 Double_t xpar = x[iparam] ;
705 Double_t zpar = x[iparam+1] ;
706 Double_t epar = x[iparam+2] ;
708 Double_t distance = (xDigit - xpar) * (xDigit - xpar) + (zDigit - zpar) * (zDigit - zpar) ;
709 distance = TMath::Sqrt(distance) ;
710 efit += epar * AliPHOSTrackSegmentMakerv1::ShowerShape(distance) ;
713 fret += (efit-emcEnergies[iDigit])*(efit-emcEnergies[iDigit])/emcEnergies[iDigit] ;
714 // Here we assume, that sigma = sqrt(E)