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 //_________________________________________________________________________
19 // Implementation version 1 of algorithm class to construct PHOS track segments
20 // Associates EMC and PPSD clusters
21 // Unfolds the EMC cluster
23 //*-- Author: Dmitri Peressounko (RRC Ki & SUBATECH)
26 // --- ROOT system ---
28 #include "TObjArray.h"
29 #include "TClonesArray.h"
30 #include "TObjectTable.h"
32 // --- Standard library ---
36 // --- AliRoot header files ---
38 #include "AliPHOSTrackSegmentMakerv1.h"
39 #include "AliPHOSIndexToObject.h"
40 #include "AliPHOSTrackSegment.h"
41 #include "AliPHOSLink.h"
42 #include "AliPHOSv0.h"
45 extern void UnfoldingChiSquare(Int_t &nPar, Double_t *Grad, Double_t & fret, Double_t *x, Int_t iflag) ;
47 ClassImp( AliPHOSTrackSegmentMakerv1)
50 //____________________________________________________________________________
51 AliPHOSTrackSegmentMakerv1::AliPHOSTrackSegmentMakerv1() : AliPHOSTrackSegmentMaker()
56 //clusters are sorted in "rows" and "columns" of width geom->GetCrystalSize(0),
57 fDelta = fR0 + fGeom->GetCrystalSize(0) ;
58 fMinuit = new TMinuit(100) ;
62 //____________________________________________________________________________
63 AliPHOSTrackSegmentMakerv1::~AliPHOSTrackSegmentMakerv1()
70 //____________________________________________________________________________
71 Bool_t AliPHOSTrackSegmentMakerv1::FindFit(AliPHOSEmcRecPoint * emcRP, int * maxAt, Float_t * maxAtEnergy,
72 Int_t nPar, Float_t * fitparameters)
74 // Calls TMinuit to fit the energy distribution of a cluster with several maxima
76 gMinuit->SetPrintLevel(-1) ; // No Printout
77 gMinuit->SetFCN(UnfoldingChiSquare) ; // To set the address of the minimization function
78 gMinuit->SetObjectFit(emcRP) ; // To tranfer pointer to UnfoldingChiSquare
80 // filling initial values for fit parameters
81 AliPHOSDigit * digit ;
85 Int_t nDigits = (Int_t) nPar / 3 ;
90 for(iDigit = 0; iDigit < nDigits; iDigit++){
91 digit = (AliPHOSDigit *) maxAt[iDigit];
96 fGeom->AbsToRelNumbering(digit->GetId(), relid) ;
97 fGeom->RelPosInModule(relid, x, z) ;
99 Float_t energy = maxAtEnergy[iDigit] ;
101 gMinuit->mnparm(index, "x", x, 0.1, 0, 0, ierflg) ;
104 cout << "PHOS Unfolding> Unable to set initial value for fit procedure : x = " << x << endl ;
107 gMinuit->mnparm(index, "z", z, 0.1, 0, 0, ierflg) ;
110 cout << "PHOS Unfolding> Unable to set initial value for fit procedure : z = " << z << endl ;
113 gMinuit->mnparm(index, "Energy", energy , 0.05*energy, 0., 4.*energy, ierflg) ;
116 cout << "PHOS Unfolding> Unable to set initial value for fit procedure : energy = " << energy << endl ;
121 Double_t p0 = 0.1 ; // "Tolerance" Evaluation stops when EDM = 0.0001*p0 ; The number of function call slightly
126 gMinuit->mnexcm("SET STR", &p2, 0, ierflg) ; // force TgMinuit to reduce function calls
127 gMinuit->mnexcm("SET GRA", &p1, 1, ierflg) ; // force TMinuit to use my gradient
128 gMinuit->SetMaxIterations(5);
129 gMinuit->mnexcm("SET NOW", &p2 , 0, ierflg) ; // No Warnings
131 gMinuit->mnexcm("MIGRAD", &p0, 0, ierflg) ; // minimize
133 if(ierflg == 4){ // Minimum not found
134 cout << "PHOS Unfolding> Fit not converged, cluster abandoned "<< endl ;
137 for(index = 0; index < nPar; index++){
140 gMinuit->GetParameter(index, val, err) ; // Returns value and error of parameter index
141 fitparameters[index] = val ;
148 //____________________________________________________________________________
149 void AliPHOSTrackSegmentMakerv1::FillOneModule(AliPHOSRecPoint::RecPointsList * emcIn,
151 AliPHOSRecPoint::RecPointsList * ppsdIn,
153 TArrayI * ppsdOutLow,
156 Int_t & ppsdStopedAt)
158 // Fill xxxOut arrays with clusters from one PHOS module EMC+PPSD
160 AliPHOSEmcRecPoint * emcRecPoint ;
161 AliPHOSPpsdRecPoint * ppsdRecPoint ;
164 Int_t nEmcUnfolded = emcIn->GetEntries() ;
165 emcOut->Set(nEmcUnfolded);
167 for(index = emcStopedAt; index < nEmcUnfolded; index++){
169 emcRecPoint = (AliPHOSEmcRecPoint *) emcIn->At(index) ;
171 if(emcRecPoint->GetPHOSMod() != phosmod )
174 emcOut->AddAt(emcRecPoint->GetIndexInList(),inEmcOut) ;
177 emcOut->Set(inEmcOut) ;
179 emcStopedAt = index ;
181 ppsdOutLow->Set(ppsdIn->GetEntries()) ;
182 ppsdOutUp->Set(ppsdIn->GetEntries()) ;
185 for(index = ppsdStopedAt; index < ppsdIn->GetEntries(); index++){
186 ppsdRecPoint = (AliPHOSPpsdRecPoint *) ppsdIn->At(index) ;
187 if(ppsdRecPoint->GetPHOSMod() != phosmod )
189 if(ppsdRecPoint->GetUp() )
190 ppsdOutUp->AddAt(index,inPpsdUp++) ;
192 ppsdOutLow->AddAt(index,inPpsdLow++) ;
194 ppsdOutLow->Set(inPpsdLow);
195 ppsdOutUp->Set(inPpsdUp);
196 ppsdStopedAt = index ;
199 //____________________________________________________________________________
200 void AliPHOSTrackSegmentMakerv1::FillOneModule(AliPHOSRecPoint::RecPointsList * emcIn,
202 AliPHOSRecPoint::RecPointsList * cpvIn,
208 // Fill xxxOut arrays with clusters from one PHOS module EMC+CPV
210 AliPHOSEmcRecPoint * emcRecPoint ;
211 AliPHOSEmcRecPoint * cpvRecPoint ;
214 Int_t nEmcUnfolded = emcIn->GetEntries() ;
215 emcOut->Set(nEmcUnfolded);
217 for(index = emcStopedAt; index < nEmcUnfolded; index++){
218 emcRecPoint = (AliPHOSEmcRecPoint *) emcIn->At(index) ;
219 if(emcRecPoint->GetPHOSMod() != phosmod )
222 emcOut->AddAt(emcRecPoint->GetIndexInList(),inEmcOut) ;
225 emcOut->Set(inEmcOut) ;
226 emcStopedAt = index ;
228 cpvOut->Set(cpvIn->GetEntries()) ;
230 for(index = cpvStopedAt; index < cpvIn->GetEntries(); index++){
231 cpvRecPoint = (AliPHOSEmcRecPoint *) cpvIn->At(index) ;
232 if(cpvRecPoint->GetPHOSMod() != phosmod )
235 cpvOut->AddAt(index,inCpvOut++) ;
237 cpvOut->Set(inCpvOut);
238 cpvStopedAt = index ;
241 //____________________________________________________________________________
242 Float_t AliPHOSTrackSegmentMakerv1::GetDistanceInPHOSPlane(AliPHOSEmcRecPoint * emcclu,AliPHOSPpsdRecPoint * PpsdClu, Bool_t &toofar)
244 // Calculates the distance between the EMC RecPoint and the PPSD RecPoint
251 emcclu->GetLocalPosition(vecEmc) ;
252 PpsdClu->GetLocalPosition(vecPpsd) ;
253 if(emcclu->GetPHOSMod() == PpsdClu->GetPHOSMod()){
254 if(vecPpsd.X() >= vecEmc.X() - fDelta ){
255 if(vecPpsd.Z() >= vecEmc.Z() - fDelta ){
256 // Correct to difference in CPV and EMC position due to different distance to center.
257 // we assume, that particle moves from center
258 Float_t dCPV = fGeom->GetIPtoOuterCoverDistance();
259 Float_t dEMC = fGeom->GetIPtoCrystalSurface() ;
261 vecPpsd = dEMC * vecPpsd - vecEmc ;
263 } // if zPpsd >= zEmc - fDelta
265 } // if xPpsd >= xEmc - fDelta
275 //____________________________________________________________________________
276 void AliPHOSTrackSegmentMakerv1::MakeLinks(TArrayI * emcRecPoints, TArrayI * ppsdRecPointsUp,
277 TArrayI * ppsdRecPointsLow, TClonesArray * linklowArray,
278 TClonesArray *linkupArray)
280 // Finds distances (links) between all EMC and PPSD clusters, which are not further apart from each other than fR0
283 AliPHOSPpsdRecPoint * ppsdlow ;
284 AliPHOSPpsdRecPoint * ppsdup ;
285 AliPHOSEmcRecPoint * emcclu ;
292 for(iEmcRP = 0; iEmcRP < emcRecPoints->GetSize(); iEmcRP++ ) {
293 emcclu = (AliPHOSEmcRecPoint *) fPlease->GimeRecPoint(emcRecPoints->At(iEmcRP),"emc") ;
298 for(iPpsdLow = 0; iPpsdLow < ppsdRecPointsLow->GetSize();iPpsdLow++ ) {
300 ppsdlow = (AliPHOSPpsdRecPoint *) fPlease->GimeRecPoint(ppsdRecPointsLow->At(iPpsdLow),"ppsd") ;
301 Float_t r = GetDistanceInPHOSPlane(emcclu, ppsdlow, toofar) ;
306 new( (*linklowArray)[iLinkLow++]) AliPHOSLink(r, iEmcRP, iPpsdLow) ;
311 for(iPpsdUp = 0; iPpsdUp < ppsdRecPointsUp->GetSize();iPpsdUp++ ) {
313 ppsdup = (AliPHOSPpsdRecPoint *)fPlease->GimeRecPoint(ppsdRecPointsUp->At(iPpsdUp),"ppsd") ;
314 Float_t r = GetDistanceInPHOSPlane(emcclu, ppsdup, toofar) ;
319 new( (*linkupArray)[iLinkUp++]) AliPHOSLink(r, iEmcRP, iPpsdUp) ;
324 linklowArray->Sort() ; //first links with smallest distances
325 linkupArray->Sort() ;
328 //____________________________________________________________________________
329 void AliPHOSTrackSegmentMakerv1::MakePairs(TArrayI * emcRecPoints,
330 TArrayI * ppsdRecPointsUp,
331 TArrayI * ppsdRecPointsLow,
332 TClonesArray * linklowArray,
333 TClonesArray * linkupArray,
334 AliPHOSTrackSegment::TrackSegmentsList * trsl)
337 // Finds the smallest links and makes pairs of PPSD and EMC clusters with smallest distance
339 TIter nextLow(linklowArray) ;
340 TIter nextUp(linkupArray) ;
342 AliPHOSLink * linkLow ;
343 AliPHOSLink * linkUp ;
349 AliPHOSPpsdRecPoint * nullpointer = 0 ;
352 while ( (linkLow = (AliPHOSLink *)nextLow() ) ){
354 emc = emcRecPoints->At(linkLow->GetEmc()) ;
355 ppsdLow = ppsdRecPointsLow->At(linkLow->GetPpsd()) ;
356 if( (emc >= 0) && (ppsdLow >= 0) ){ // RecPoints not removed yet
358 new( (*trsl)[fNTrackSegments] ) AliPHOSTrackSegment((AliPHOSEmcRecPoint *)fPlease->GimeRecPoint(emc,"emc"),
360 (AliPHOSPpsdRecPoint *)fPlease->GimeRecPoint(ppsdLow,"ppsd") ) ;
361 ((AliPHOSTrackSegment* )trsl->At(fNTrackSegments))->SetIndexInList(fNTrackSegments);
362 //replace index of emc to negative and shifted index of TS
363 emcRecPoints->AddAt(-2 - fNTrackSegments,linkLow->GetEmc()) ;
364 //replace index of emc to negative and shifted index of TS
365 ppsdRecPointsLow->AddAt(-2 - fNTrackSegments,linkLow->GetPpsd()) ;
371 while ( (linkUp = (AliPHOSLink *)nextUp() ) ){
372 emc = emcRecPoints->At(linkUp->GetEmc()) ;
373 if(emc != -1){ //without ppsd Up yet
375 ppsdUp = ppsdRecPointsUp->At(linkUp->GetPpsd()) ;
377 if(emc >= 0){ //without ppsd Low => create new TS
379 fNTrackSegments = trsl->GetEntries() ;
380 new( (*trsl)[fNTrackSegments] ) AliPHOSTrackSegment((AliPHOSEmcRecPoint *) fPlease->GimeRecPoint(emc,"emc"),
381 (AliPHOSPpsdRecPoint *)fPlease->GimeRecPoint(ppsdUp,"ppsd"),
383 ((AliPHOSTrackSegment *) trsl->At(fNTrackSegments))->SetIndexInList(fNTrackSegments);
386 else{ // append ppsd Up to existing TS
387 ((AliPHOSTrackSegment *)trsl->At(-2-emc))->SetPpsdUpRecPoint((AliPHOSPpsdRecPoint *)fPlease->GimeRecPoint(ppsdUp,"ppsd"));
389 emcRecPoints->AddAt(-1,linkUp->GetEmc()) ; //Mark that PPSD Up found
395 for(iEmcRP = 0; iEmcRP <emcRecPoints->GetSize() ; iEmcRP++ ){
396 emc = emcRecPoints->At(iEmcRP) ;
400 new( (*trsl)[fNTrackSegments] ) AliPHOSTrackSegment((AliPHOSEmcRecPoint *) fPlease->GimeRecPoint(emc,"emc"),
401 nullpointer, nullpointer ) ;
402 ((AliPHOSTrackSegment *) trsl->At(fNTrackSegments))->SetIndexInList(fNTrackSegments);
410 //____________________________________________________________________________
411 void AliPHOSTrackSegmentMakerv1::MakeTrackSegments(DigitsList * dl,
412 AliPHOSRecPoint::RecPointsList * emcl,
413 AliPHOSRecPoint::RecPointsList * ppsdl,
414 AliPHOSTrackSegment::TrackSegmentsList * trsl)
416 // Makes the track segments out of the list of EMC and PPSD Recpoints and stores them in a list
419 Int_t emcStopedAt = 0 ;
420 Int_t ppsdStopedAt = 0 ;
422 fNTrackSegments = 0 ;
425 TArrayI * emcRecPoints = new TArrayI(1000) ; // these arrays keep indexes
426 TArrayI * ppsdRecPointsUp = new TArrayI(1000) ; // of RecPoints, which are
427 TArrayI * ppsdRecPointsLow = new TArrayI(1000) ; // kept in TClonesArray's emcl and ppsdl
430 TClonesArray * linklowArray = new TClonesArray("AliPHOSLink", 100);
431 TClonesArray * linkupArray = new TClonesArray("AliPHOSLink", 100);
435 UnfoldAll(dl, emcl) ; // Unfolds all EMC clusters
439 while(phosmod <= fGeom->GetNModules() ){
441 FillOneModule(emcl, emcRecPoints, ppsdl, ppsdRecPointsUp, ppsdRecPointsLow, phosmod, emcStopedAt, ppsdStopedAt) ;
443 MakeLinks(emcRecPoints, ppsdRecPointsUp, ppsdRecPointsLow, linklowArray, linkupArray) ;
445 MakePairs(emcRecPoints, ppsdRecPointsUp, ppsdRecPointsLow, linklowArray, linkupArray, trsl) ;
447 emcRecPoints->Reset() ;
449 ppsdRecPointsUp->Reset() ;
451 ppsdRecPointsLow->Reset() ;
453 linkupArray->Clear() ;
455 linklowArray->Clear() ;
460 delete emcRecPoints ;
463 delete ppsdRecPointsUp ;
464 ppsdRecPointsUp = 0 ;
466 delete ppsdRecPointsLow ;
467 ppsdRecPointsLow = 0 ;
472 delete linklowArray ;
476 //____________________________________________________________________________
477 void AliPHOSTrackSegmentMakerv1::MakeTrackSegmentsCPV(DigitsList * dl,
478 AliPHOSRecPoint::RecPointsList * emcl,
479 AliPHOSRecPoint::RecPointsList * cpvl)
481 // Unfold clusters in EMC and CPV and refill reconstructed point lists emcl and ppsdl
482 // Yuri Kharlov. 19 October 2000
484 fNTrackSegments = 0 ;
486 TArrayI * emcRecPoints = new TArrayI(1000) ; // these arrays keep indexes
487 TArrayI * cpvRecPoints = new TArrayI(1000) ; // of RecPoints, which are kept in emcl and ppsdl
490 UnfoldAll(dl, emcl) ; // Unfolds all EMC clusters
491 UnfoldAll(dl, cpvl) ; // Unfolds all CPV clusters
494 // Int_t phosmod = 1 ;
495 // Int_t emcStopedAt = 0 ;
496 // Int_t cpvStopedAt = 0 ;
497 // while(phosmod <= fGeom->GetNModules() ){
498 // FillOneModule(emcl, emcRecPoints, ppsdl, cpvRecPoints, phosmod, emcStopedAt, cpvStopedAt) ;
499 // emcRecPoints->Reset() ;
500 // cpvRecPoints->Reset() ;
504 delete emcRecPoints ; emcRecPoints = 0 ;
505 delete cpvRecPoints ; cpvRecPoints = 0 ;
508 //____________________________________________________________________________
509 Double_t AliPHOSTrackSegmentMakerv1::ShowerShape(Double_t r)
511 // Shape of the shower (see PHOS TDR)
512 // If you change this function, change also the gradien evaluation in ChiSquare()
514 Double_t r4 = r*r*r*r ;
515 Double_t r295 = TMath::Power(r, 2.95) ;
516 Double_t shape = TMath::Exp( -r4 * (1. / (2.32 + 0.26 * r4) + 0.0316 / (1 + 0.0652 * r295) ) ) ;
520 //____________________________________________________________________________
521 void AliPHOSTrackSegmentMakerv1::UnfoldAll(DigitsList * dl, AliPHOSRecPoint::RecPointsList * emcIn)
523 // Performs unfolding of all EMC clusters, sorts them and resets indexes in RecPoints
525 AliPHOSEmcRecPoint * emcRecPoint ;
527 Int_t nEmcUnfolded = emcIn->GetEntries() ;
529 for(index = 0 ; index < nEmcUnfolded; index++){
531 emcRecPoint = (AliPHOSEmcRecPoint *) emcIn->At(index) ;
533 Int_t nMultipl = emcRecPoint->GetMultiplicity() ;
534 Int_t * maxAt = new Int_t[nMultipl] ;
535 Float_t * maxAtEnergy = new Float_t[nMultipl] ;
536 Int_t nMax = emcRecPoint->GetNumberOfLocalMax(maxAt, maxAtEnergy) ;
538 if( nMax > 1 ) { // if cluster is very flat (no pronounced maximum) then nMax = 0
539 UnfoldClusters(dl, emcIn, emcRecPoint, nMax, maxAt, maxAtEnergy) ;
540 emcIn->Remove(emcRecPoint);
547 delete[] maxAtEnergy ;
548 } //Unfolding finished
552 // to set index to new and correct index of old RecPoints
553 for( index = 0 ; index < emcIn->GetEntries() ; index++){
554 ((AliPHOSEmcRecPoint *) emcIn->At(index))->SetIndexInList(index) ;
560 //____________________________________________________________________________
561 void AliPHOSTrackSegmentMakerv1::UnfoldClusters(DigitsList * dl,
562 AliPHOSRecPoint::RecPointsList * emcIn,
563 AliPHOSEmcRecPoint * iniEmc,
566 Float_t * maxAtEnergy)
568 // Performs the unfolding of a cluster with nMax overlapping showers
569 // This is time consuming (use the (Un)SetUnfolFlag() )
571 Int_t nPar = 3 * nMax ;
572 Float_t * fitparameters = new Float_t[nPar] ;
575 Bool_t rv = FindFit(iniEmc, maxAt, maxAtEnergy, nPar, fitparameters) ;
577 // Fit failed, return and remove cluster
578 delete[] fitparameters ;
587 Int_t nDigits = iniEmc->GetMultiplicity() ;
593 Float_t * efit = new Float_t[nDigits] ;
597 AliPHOSDigit * digit ;
598 AliPHOSEmcRecPoint * emcRP ;
599 Int_t * emcDigits = iniEmc->GetDigitsList() ;
600 Float_t * emcEnergies = iniEmc->GetEnergiesList() ;
602 Int_t iRecPoint = emcIn->GetEntries() ;
604 for(iDigit = 0 ; iDigit < nDigits ; iDigit ++){
605 digit = fPlease->GimeDigit( emcDigits[iDigit] ) ;
606 fGeom->AbsToRelNumbering(digit->GetId(), relid) ;
607 fGeom->RelPosInModule(relid, xDigit, zDigit) ;
611 while(iparam < nPar ){
612 xpar = fitparameters[iparam] ;
613 zpar = fitparameters[iparam+1] ;
614 epar = fitparameters[iparam+2] ;
616 distance = (xDigit - xpar) * (xDigit - xpar) + (zDigit - zpar) * (zDigit - zpar) ;
617 distance = TMath::Sqrt(distance) ;
618 efit[iDigit] += epar * AliPHOSTrackSegmentMakerv1::ShowerShape(distance) ;
626 while(iparam < nPar ){
627 xpar = fitparameters[iparam] ;
628 zpar = fitparameters[iparam+1] ;
629 epar = fitparameters[iparam+2] ;
632 if(iRecPoint >= emcIn->GetSize())
633 emcIn->Expand(2*iRecPoint) ;
634 (*emcIn)[iRecPoint] = new AliPHOSEmcRecPoint( iniEmc->GetLogWeightCut(), iniEmc->GetLocMaxCut() ) ;
636 emcRP = (AliPHOSEmcRecPoint *) emcIn->At(iRecPoint);
639 for(iDigit = 0 ; iDigit < nDigits ; iDigit ++){
640 digit = fPlease->GimeDigit( emcDigits[iDigit] ) ;
641 fGeom->AbsToRelNumbering(digit->GetId(), relid) ;
642 fGeom->RelPosInModule(relid, xDigit, zDigit) ;
643 distance = (xDigit - xpar) * (xDigit - xpar) + (zDigit - zpar) * (zDigit - zpar) ;
644 distance = TMath::Sqrt(distance) ;
645 ratio = epar * AliPHOSTrackSegmentMakerv1::ShowerShape(distance) / efit[iDigit] ;
646 eDigit = emcEnergies[iDigit] * ratio ;
647 emcRP->AddDigit( *digit, eDigit ) ;
652 delete[] fitparameters ;
657 //______________________________________________________________________________
658 void UnfoldingChiSquare(Int_t & nPar, Double_t * Grad, Double_t & fret, Double_t * x, Int_t iflag)
660 // Calculates th Chi square for the cluster unfolding minimization
661 // Number of parameters, Gradient, Chi squared, parameters, what to do
663 AliPHOSEmcRecPoint * emcRP = (AliPHOSEmcRecPoint *) gMinuit->GetObjectFit() ; // EmcRecPoint to fit
665 Int_t * emcDigits = emcRP->GetDigitsList() ;
667 Int_t nOfDigits = emcRP->GetDigitsMultiplicity() ;
669 Float_t * emcEnergies = emcRP->GetEnergiesList() ;
671 AliPHOSGeometry * geom = AliPHOSGeometry::GetInstance() ;
673 AliPHOSIndexToObject * please = AliPHOSIndexToObject::GetInstance() ;
679 for(iparam = 0 ; iparam < nPar ; iparam++)
680 Grad[iparam] = 0 ; // Will evaluate gradient
684 AliPHOSDigit * digit ;
687 for( iDigit = 0 ; iDigit < nOfDigits ; iDigit++) {
689 digit = please->GimeDigit( emcDigits[iDigit] ) ;
695 geom->AbsToRelNumbering(digit->GetId(), relid) ;
697 geom->RelPosInModule(relid, xDigit, zDigit) ;
699 if(iflag == 2){ // calculate gradient
702 while(iParam < nPar ){
703 Double_t distance = (xDigit - x[iParam]) * (xDigit - x[iParam]) ;
705 distance += (zDigit - x[iParam]) * (zDigit - x[iParam]) ;
706 distance = TMath::Sqrt( distance ) ;
708 efit += x[iParam] * AliPHOSTrackSegmentMakerv1::ShowerShape(distance) ;
711 Double_t sum = 2. * (efit - emcEnergies[iDigit]) / emcEnergies[iDigit] ; // Here we assume, that sigma = sqrt(E)
713 while(iParam < nPar ){
714 Double_t xpar = x[iParam] ;
715 Double_t zpar = x[iParam+1] ;
716 Double_t epar = x[iParam+2] ;
717 Double_t dr = TMath::Sqrt( (xDigit - xpar) * (xDigit - xpar) + (zDigit - zpar) * (zDigit - zpar) );
718 Double_t shape = sum * AliPHOSTrackSegmentMakerv1::ShowerShape(dr) ;
719 Double_t r4 = dr*dr*dr*dr ;
720 Double_t r295 = TMath::Power(dr,2.95) ;
721 Double_t deriv =-4. * dr*dr * ( 2.32 / ( (2.32 + 0.26 * r4) * (2.32 + 0.26 * r4) ) +
722 0.0316 * (1. + 0.0171 * r295) / ( ( 1. + 0.0652 * r295) * (1. + 0.0652 * r295) ) ) ;
724 Grad[iParam] += epar * shape * deriv * (xpar - xDigit) ; // Derivative over x
726 Grad[iParam] += epar * shape * deriv * (zpar - zDigit) ; // Derivative over z
728 Grad[iParam] += shape ; // Derivative over energy
735 while(iparam < nPar ){
736 Double_t xpar = x[iparam] ;
737 Double_t zpar = x[iparam+1] ;
738 Double_t epar = x[iparam+2] ;
740 Double_t distance = (xDigit - xpar) * (xDigit - xpar) + (zDigit - zpar) * (zDigit - zpar) ;
741 distance = TMath::Sqrt(distance) ;
742 efit += epar * AliPHOSTrackSegmentMakerv1::ShowerShape(distance) ;
745 fret += (efit-emcEnergies[iDigit])*(efit-emcEnergies[iDigit])/emcEnergies[iDigit] ;
746 // Here we assume, that sigma = sqrt(E)