LCOV - code coverage report
Current view: top level - HMPID/HMPIDbase - AliHMPIDCluster.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 181 214 84.6 %
Date: 2016-06-14 17:26:59 Functions: 10 12 83.3 %

          Line data    Source code
       1             : //  **************************************************************************
       2             : //  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
       3             : //  *                                                                        *
       4             : //  * Author: The ALICE Off-line Project.                                    *
       5             : //  * Contributors are mentioned in the code where appropriate.              *
       6             : //  *                                                                        *
       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             : //  **************************************************************************
      15             : 
      16             : #include "AliHMPIDCluster.h"  //class header
      17             : #include <TVirtualFitter.h>  //Solve()
      18             : #include <TMinuit.h>         //Solve()
      19             : #include <TClonesArray.h>    //Solve()
      20             : #include <TMarker.h>         //Draw()
      21             : 
      22             : #include "AliLog.h"          //FindCusterSize()
      23             : 
      24             : Bool_t AliHMPIDCluster::fgDoCorrSin=kTRUE;
      25             : 
      26          16 : ClassImp(AliHMPIDCluster)
      27             :     
      28             : 
      29             : void AliHMPIDCluster::SetClusterParams(Double_t xL,Double_t yL,Int_t iCh  )
      30             : {
      31             :   //------------------------------------------------------------------------
      32             :   //Set the cluster properties for the AliCluster3D part
      33             :   //------------------------------------------------------------------------
      34             : 
      35        1758 :   fParam = AliHMPIDParam::Instance();
      36             :     
      37         879 :   if(!fParam->GetInstType())               //if there is no geometry we cannot retrieve the volId (only for monitoring)
      38             :   {
      39           0 :     new(this) AliCluster3D(); return;
      40             :   }
      41             :   
      42             :   //Get the volume ID from the previously set PNEntry
      43         879 :   UShort_t volId=AliGeomManager::LayerToVolUID(AliGeomManager::kHMPID,iCh);
      44             : 
      45             :   
      46             :   //get L->T cs matrix for a given chamber
      47         879 :   const TGeoHMatrix *t2l= AliGeomManager::GetTracking2LocalMatrix(volId);
      48             : 
      49         879 :   fParam = AliHMPIDParam::Instance();
      50             : 
      51             :   //transformation from the pad cs to local
      52         879 :   xL -= 0.5*fParam->SizeAllX();      //size of all pads with dead zones included
      53         879 :   yL -= 0.5*fParam->SizeAllY();
      54             : 
      55             :   // Get the position in the tracking cs
      56         879 :   Double_t posL[3]={xL, yL, 0.};            //this is the LORS of HMPID
      57         879 :   Double_t posT[3];
      58         879 :   t2l->MasterToLocal(posL,posT);
      59             : 
      60             :  //Get the cluster covariance matrix in the tracking cs
      61         879 :   Double_t covL[9] = {
      62             :     0.8*0.8/12., 0.,            0.0,                 //pad size X
      63             :     0.,          0.84*0.84/12., 0.0,                 //pad size Y
      64             :     0.,          0.,            0.1,                 //just 1 , no Z dimension ???
      65             :   };
      66             :                 
      67         879 :   TGeoHMatrix m;
      68         879 :   m.SetRotation(covL);
      69         879 :   m.Multiply(t2l);
      70        1758 :   m.MultiplyLeft(&t2l->Inverse());
      71         879 :   Double_t *covT = m.GetRotationMatrix();
      72             : 
      73        2637 :   new(this) AliCluster3D(volId,            // Can be done safer
      74         879 :        posT[0],posT[1],posT[2],
      75         879 :        covT[0],covT[1],covT[2],
      76         879 :                covT[4],covT[5],
      77         879 :                        covT[8], 
      78             :                           0x0);            // No MC labels ?
      79        1758 : }
      80             : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
      81             : AliHMPIDCluster::~AliHMPIDCluster()
      82        3276 : {
      83        1120 :   if(fDigs)  delete fDigs; fDigs=0;
      84             :   //PH  if(fParam) delete fParam; fParam=0;
      85        1638 : }
      86             : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
      87             : void AliHMPIDCluster::CoG()
      88             : {
      89             : // Calculates naive cluster position as a center of gravity of its digits.
      90             : // Arguments: none 
      91             : //   Returns: none
      92             :   Int_t minPadX=999,minPadY=999,maxPadX=-1,maxPadY=-1;      //for box finding  
      93         848 :   if(fDigs==0) return;                                      //no digits in this cluster
      94         424 :   fXX=fYY=fQRaw=0;                                          //init summable parameters
      95         424 :   fCh = -1;                                                 //init chamber
      96             :   Int_t maxQpad=-1,maxQ=-1;                                 //to calculate the pad with the highest charge
      97             :   AliHMPIDDigit *pDig=0x0;
      98        2672 :   for(Int_t iDig=0;iDig<fDigs->GetEntriesFast();iDig++){    //digits loop
      99         912 :     pDig=(AliHMPIDDigit*)fDigs->At(iDig);                   //get pointer to next digit
     100         912 :     if(!pDig) continue;                                     //protection
     101        1568 :     if(pDig->PadPcX() > maxPadX) maxPadX = pDig->PadPcX();  // find the minimum box that contain the cluster  MaxX                            
     102        1457 :     if(pDig->PadPcY() > maxPadY) maxPadY = pDig->PadPcY();  //                                                MaxY
     103        1336 :     if(pDig->PadPcX() < minPadX) minPadX = pDig->PadPcX();  //                                                MinX   
     104        1396 :     if(pDig->PadPcY() < minPadY) minPadY = pDig->PadPcY();  //                                                MinY   
     105             :     
     106         912 :     Float_t q=pDig->Q();                                    //get QDC 
     107         912 :     fXX += pDig->LorsX()*q;fYY +=pDig->LorsY()*q;             //add digit center weighted by QDC
     108         912 :     fQRaw+=q;                                               //increment total charge 
     109        1482 :     if(q>maxQ) {maxQpad = pDig->Pad();maxQ=(Int_t)q;}       // to find pad with highest charge
     110         912 :     fCh=pDig->Ch();                                         //initialize chamber number
     111         912 :   }//digits loop
     112             :   
     113         424 :   fBox=(maxPadX-minPadX+1)*100+maxPadY-minPadY+1;           // dimension of the box: format Xdim*100+Ydim
     114             :   
     115         840 :   if ( fQRaw != 0 ) {fXX/=fQRaw;fYY/=fQRaw;}                //final center of gravity
     116             :    
     117         810 :   if(fDigs->GetEntriesFast()>1&&fgDoCorrSin)CorrSin();       //correct it by sinoid   
     118             :   
     119         424 :   fQ  = fQRaw;                                              // Before starting fit procedure, Q and QRaw must be equal
     120         424 :   fMaxQpad = maxQpad; fMaxQ=maxQ;                           //store max charge pad to the field
     121         424 :   fChi2=0;                                                  // no Chi2 to find
     122         424 :   fNlocMax=0;                                               // proper status from this method
     123         424 :   fSt=kCoG;
     124             :   
     125         424 :   SetClusterParams(fXX,fYY,fCh);                              //need to fill the AliCluster3D part
     126             :  
     127         848 : }//CoG()
     128             : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     129             : void AliHMPIDCluster::CorrSin() 
     130             : {
     131             : // Correction of cluster x position due to sinoid, see HMPID TDR  page 30
     132             : // Arguments: none
     133             : //   Returns: none
     134         386 :   Int_t pc,px,py;
     135         193 :   fParam->Lors2Pad(fXX,fYY,pc,px,py);             //tmp digit to get it center
     136         193 :   Float_t x=fXX-fParam->LorsX(pc,px);                    //diff between cluster x and center of the pad contaning this cluster   
     137         193 :   fXX+=3.31267e-2*TMath::Sin(2*TMath::Pi()/0.8*x)-2.66575e-3*TMath::Sin(4*TMath::Pi()/0.8*x)+2.80553e-3*TMath::Sin(6*TMath::Pi()/0.8*x)+0.0070;
     138         193 : }
     139             : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     140             : void AliHMPIDCluster::Draw(Option_t*)
     141             : {
     142           0 :   TMarker *pMark=new TMarker(X(),Y(),5); pMark->SetUniqueID(fSt);pMark->SetMarkerColor(kBlue); pMark->Draw();
     143           0 : }
     144             : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     145             : void AliHMPIDCluster::FitFunc(Int_t &iNpars, Double_t* deriv, Double_t &chi2, Double_t *par, Int_t iflag)
     146             : {
     147             : // Cluster fit function 
     148             : // par[0]=x par[1]=y par[2]=q for the first Mathieson shape
     149             : // par[3]=x par[4]=y par[5]=q for the second Mathieson shape and so on up to iNpars/3 Mathieson shapes
     150             : // For each pad of the cluster calculates the difference between actual pad charge and the charge induced to this pad by all Mathieson distributions
     151             : // Then the chi2 is calculated as the sum of this value squared for all pad in the cluster.  
     152             : // Arguments: iNpars - number of parameters which is number of local maxima of cluster * 3
     153             : //            chi2   - function result to be minimised 
     154             : //            par   - parameters array of size iNpars            
     155             : //   Returns: none  
     156             :   
     157       52190 :   AliHMPIDCluster *pClu=(AliHMPIDCluster*)TVirtualFitter::GetFitter()->GetObjectFit();
     158             : 
     159       26095 :   Int_t nPads = pClu->Size();  
     160             :   
     161       26095 :   chi2 = 0;
     162             :   
     163       26095 :   Int_t iNshape = iNpars/3;
     164             :   
     165      266766 :   for(Int_t i=0;i<nPads;i++){                                                          //loop on all pads of the cluster
     166             :     Double_t dQpadMath = 0;
     167      706936 :     for(Int_t j=0;j<iNshape;j++){                                                      //Mathiesons loop as all of them may contribute to this pad
     168      246180 :       Double_t fracMathi = pClu->Dig(i)->IntMathieson(par[3*j],par[3*j+1]);
     169      246180 :       dQpadMath+=par[3*j+2]*fracMathi;                                                 // par[3*j+2] is charge par[3*j] is x par[3*j+1] is y of current Mathieson
     170             :     }
     171      214576 :     if(dQpadMath>0 && pClu->Dig(i)->Q()>0) {
     172      107288 :       chi2 +=TMath::Power((pClu->Dig(i)->Q()-dQpadMath),2)/pClu->Dig(i)->Q();          //chi2 function to be minimized
     173      107288 :     }
     174             :   }
     175             : //---calculate gradients...  
     176       26095 :   if(iflag==2) {
     177             :     Double_t **derivPart;
     178             : 
     179         661 :     derivPart = new Double_t*[iNpars];
     180             : 
     181       10190 :     for(Int_t j=0;j<iNpars;j++){                                                      
     182        4434 :       deriv[j] = 0;
     183        4434 :       derivPart[j] = new Double_t[nPads];
     184       41454 :       for(Int_t i=0;i<nPads;i++){                                                          
     185       16293 :         derivPart[j][i] = 0;
     186             :       }
     187             :     }
     188             : 
     189        6046 :     for(Int_t i=0;i<nPads;i++){                                                          //loop on all pads of the cluster
     190       15586 :       for(Int_t j=0;j<iNshape;j++){                                                      //Mathiesons loop as all of them may contribute to this pad
     191        5431 :         Double_t fracMathi = pClu->Dig(i)->IntMathieson(par[3*j],par[3*j+1]);
     192       16293 :         derivPart[3*j  ][i] += par[3*j+2]*(pClu->Dig(i)->MathiesonX(par[3*j]-pClu->Dig(i)->LorsX()-0.5*AliHMPIDParam::SizePadX())-
     193       10862 :                                            pClu->Dig(i)->MathiesonX(par[3*j]-pClu->Dig(i)->LorsX()+0.5*AliHMPIDParam::SizePadX()))*
     194        5431 :                                            pClu->Dig(i)->IntPartMathiY(par[3*j+1]);
     195       16293 :         derivPart[3*j+1][i] += par[3*j+2]*(pClu->Dig(i)->MathiesonY(par[3*j+1]-pClu->Dig(i)->LorsY()-0.5*AliHMPIDParam::SizePadY())-
     196       10862 :                                            pClu->Dig(i)->MathiesonY(par[3*j+1]-pClu->Dig(i)->LorsY()+0.5*AliHMPIDParam::SizePadY()))*
     197        5431 :                                            pClu->Dig(i)->IntPartMathiX(par[3*j]);
     198        5431 :         derivPart[3*j+2][i] += fracMathi;
     199             :       }
     200             :     }
     201             :                                                                                          //loop on all pads of the cluster     
     202        6046 :     for(Int_t i=0;i<nPads;i++){                                                          //loop on all pads of the cluster
     203             :       Double_t dQpadMath = 0;                                                            //pad charge collector  
     204       15586 :       for(Int_t j=0;j<iNshape;j++){                                                      //Mathiesons loop as all of them may contribute to this pad
     205        5431 :         Double_t fracMathi = pClu->Dig(i)->IntMathieson(par[3*j],par[3*j+1]);
     206        5431 :         dQpadMath+=par[3*j+2]*fracMathi;                                                 
     207       10862 :         if(dQpadMath>0 && pClu->Dig(i)->Q()>0) {
     208        5431 :           deriv[3*j]   += 2/pClu->Dig(i)->Q()*(pClu->Dig(i)->Q()-dQpadMath)*derivPart[3*j  ][i];
     209        5431 :           deriv[3*j+1] += 2/pClu->Dig(i)->Q()*(pClu->Dig(i)->Q()-dQpadMath)*derivPart[3*j+1][i];
     210        5431 :           deriv[3*j+2] += 2/pClu->Dig(i)->Q()*(pClu->Dig(i)->Q()-dQpadMath)*derivPart[3*j+2][i];
     211        5431 :         }
     212             :       }
     213             :     }
     214             :     //delete array...
     215       20380 :     for(Int_t i=0;i<iNpars;i++) delete [] derivPart[i]; delete [] derivPart;
     216         661 :   }
     217             : //---gradient calculations ended
     218             : 
     219             : // fit ended. Final calculations
     220             :   
     221             :   
     222       26095 : }//FitFunction()
     223             : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     224             : void AliHMPIDCluster::Print(Option_t* opt)const
     225             : {
     226             : //Print current cluster  
     227             :   const char *status=0;
     228           0 :   switch(fSt){
     229           0 :     case        kFrm  : status="formed        "   ;break;
     230           0 :     case        kUnf  : status="unfolded (fit)"   ;break;
     231           0 :     case        kCoG  : status="coged         "   ;break;
     232           0 :     case        kLo1  : status="locmax 1 (fit)"   ;break;
     233           0 :     case        kMax  : status="exceeded (cog)"   ;break;
     234           0 :     case        kNot  : status="not done (cog)"   ;break;
     235           0 :     case        kEmp  : status="empty         "   ;break;
     236           0 :     case        kEdg  : status="edge     (fit)"   ;break;
     237           0 :     case        kSi1  : status="size 1   (cog)"   ;break;
     238           0 :     case        kNoLoc: status="no LocMax(fit)"   ;break;
     239           0 :     case        kAbn  : status="Abnormal fit  "   ;break;
     240           0 :     case        kBig  : status="Big Clu(>100) "   ;break;
     241             :     
     242           0 :     default:            status="??????"          ;break;   
     243             :   }
     244             :   Double_t ratio=0;
     245           0 :   if(Q()>0&&QRaw()>0) ratio = Q()/QRaw()*100;
     246           0 :   Printf("%sCLU: ch=%i  (%7.3f,%7.3f) Q=%8.3f Qraw=%8.3f(%3.0f%%) Size=%2i DimBox=%i LocMax=%i Chi2=%7.3f   %s",
     247           0 :          opt,Ch(),X(),Y(),Q(),QRaw(),ratio,Size(),fBox,fNlocMax,fChi2,status);
     248           0 :   if(fDigs) fDigs->Print();    
     249           0 : }//Print()
     250             : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     251             : Int_t AliHMPIDCluster::Solve(TClonesArray *pCluLst,Int_t *pSigmaCut, Bool_t isTryUnfold)
     252             : {
     253             : //This methode is invoked when the cluster is formed to solve it. Solve the cluster means to try to unfold the cluster
     254             : //into the local maxima number of clusters. This methode is invoked by AliHMPIDRconstructor::Dig2Clu() on cluster by cluster basis.  
     255             : //At this point, cluster contains a list of digits, cluster charge and size is precalculated in AddDigit(), position is preset to (-1,-1) in ctor,
     256             : //status is preset to kFormed in AddDigit(), chamber-sector info is preseted to actual values in AddDigit()
     257             : //Method first finds number of local maxima and if it's more then one tries to unfold this cluster into local maxima number of clusters
     258             : //Arguments: pCluLst     - cluster list pointer where to add new cluster(s)
     259             : //           isTryUnfold - flag to switch on/off unfolding   
     260             : //  Returns: number of local maxima of original cluster
     261             :   const Int_t kMaxLocMax=6;                                                              //max allowed number of loc max for fitting
     262             : //  
     263         424 :   CoG();                                                                                 //First calculate CoG for the given cluster
     264             :   
     265         424 :   Int_t iCluCnt=pCluLst->GetEntriesFast();                                               //get current number of clusters already stored in the list by previous operations
     266             :   
     267         424 :   Int_t rawSize = Size();                                                                //get current raw cluster size
     268             :   
     269         424 :   if(rawSize>100) {
     270           0 :     fSt = kBig;
     271         424 :   } else if(isTryUnfold==kFALSE) {
     272           0 :     fSt = kNot;
     273         424 :   } else if(rawSize==1) {
     274         231 :     fSt = kSi1;
     275         231 :   }
     276             :   
     277         848 :   if(rawSize>100 || isTryUnfold==kFALSE || rawSize==1) {                                 //No deconv if: 1 - big cluster (also avoid no zero suppression!)
     278             :                                                                                          //              2 - flag is set to FALSE
     279         231 :     SetClusterParams(fXX,fYY,fCh);                                                       //              3 - size = 1
     280         231 :     new ((*pCluLst)[iCluCnt++]) AliHMPIDCluster(*this);  //add this raw cluster 
     281         231 :     return 1;
     282             :     
     283             :   } 
     284             :   
     285             : //Phase 0. Initialise Fitter  
     286         193 :   Double_t arglist[10];
     287             :   Int_t ierflg = 0;
     288         193 :   TVirtualFitter* fitter = TVirtualFitter::Fitter(this,3*6);                       //initialize Fitter
     289             :   //
     290         193 :   arglist[0] = -1;
     291         193 :   ierflg = fitter->ExecuteCommand("SET PRI", arglist, 1);                               // no printout
     292         193 :   ierflg = fitter->ExecuteCommand("SET NOW", arglist, 0);                               //no warning messages
     293         193 :   arglist[0] =  1;
     294         193 :   ierflg = fitter->ExecuteCommand("SET GRA", arglist, 1);                               //force Fitter to use my gradient
     295             : 
     296         193 :   fitter->SetFCN(AliHMPIDCluster::FitFunc);
     297             : 
     298             : //  arglist[0] = 1;
     299             : //  ierflg = fitter->ExecuteCommand("SET ERR", arglist ,1);
     300             :   
     301             : // Set starting values and step sizes for parameters
     302             :     
     303             : //Phase 1. Find number of local maxima. Strategy is to check if the current pad has QDC more then all neigbours. Also find the box contaning the cluster   
     304         193 :   fNlocMax=0;
     305             : 
     306        1748 :   for(Int_t iDig1=0;iDig1<rawSize;iDig1++) {                                               //first digits loop
     307             :     
     308         681 :     AliHMPIDDigit *pDig1 = Dig(iDig1);                                                   //take next digit    
     309             :     Int_t iCnt = 0;                                                                      //counts how many neighbouring pads has QDC more then current one
     310             :     
     311        7644 :     for(Int_t iDig2=0;iDig2<rawSize;iDig2++) {                                            //loop on all digits again
     312             :       
     313        3141 :       if(iDig1==iDig2) continue;                                                         //the same digit, no need to compare 
     314        2460 :       AliHMPIDDigit *pDig2 = Dig(iDig2);                                                 //take second digit to compare with the first one
     315        2460 :       Int_t dist = TMath::Sign(Int_t(pDig1->PadChX()-pDig2->PadChX()),1)+TMath::Sign(Int_t(pDig1->PadChY()-pDig2->PadChY()),1);//distance between pads
     316        2460 :       if(dist==1)                                                                        //means dig2 is a neighbour of dig1
     317        1679 :          if(pDig2->Q()>=pDig1->Q()) iCnt++;                                              //count number of pads with Q more then Q of current pad
     318             :       
     319        2460 :     }//second digits loop
     320             :     
     321         901 :     if(iCnt==0&&fNlocMax<kMaxLocMax){                                                    //this pad has Q more then any neighbour so it's local maximum
     322             :       
     323         220 :       Double_t xStart=pDig1->LorsX();Double_t yStart=pDig1->LorsY();
     324         220 :       Double_t xMin=xStart-fParam->SizePadX();
     325         220 :       Double_t xMax=xStart+fParam->SizePadX();
     326         220 :       Double_t yMin=yStart-fParam->SizePadY();
     327         220 :       Double_t yMax=yStart+fParam->SizePadY();
     328             :       
     329         220 :       ierflg = fitter->SetParameter(3*fNlocMax  ,Form("x%i",fNlocMax),xStart,0.1,xMin,xMax);    // X,Y,Q initial values of the loc max pad
     330         220 :       ierflg = fitter->SetParameter(3*fNlocMax+1,Form("y%i",fNlocMax),yStart,0.1,yMin,yMax);    // X, Y constrained to be near the loc max
     331         220 :       ierflg = fitter->SetParameter(3*fNlocMax+2,Form("q%i",fNlocMax),pDig1->Q(),0.1,0,10000);  // Q constrained to be positive
     332             :       
     333         220 :       fNlocMax++;
     334             :       
     335         220 :     }//if this pad is local maximum
     336             :   }//first digits loop
     337             :   
     338             : //Phase 2. Fit loc max number of Mathiesons or add this current cluster to the list
     339             : // case 1 -> no loc max found
     340         193 :  if ( fNlocMax == 0) {                                                                       // case of no local maxima found: pads with same charge...
     341           4 :    fNlocMax = 1;
     342           4 :    fSt=kNoLoc;
     343           4 :    SetClusterParams(fXX,fYY,fCh);                                                          //need to fill the AliCluster3D part
     344           4 :    new ((*pCluLst)[iCluCnt++]) AliHMPIDCluster(*this);                                     //add new unfolded cluster
     345           4 :    return fNlocMax;
     346             :  }
     347             : 
     348             : // case 2 -> loc max found. Check # of loc maxima 
     349         189 :  if ( fNlocMax >= kMaxLocMax)  { 
     350           0 :    SetClusterParams(fXX,fYY,fCh);                                                           // if # of local maxima exceeds kMaxLocMax...
     351           0 :    fSt = kMax;   new ((*pCluLst)[iCluCnt++]) AliHMPIDCluster(*this);                      //...add this raw cluster  
     352             :  } else {                                                                               //or resonable number of local maxima to fit and user requested it
     353             :   // Now ready for minimization step
     354         189 :    arglist[0] = 500;                                                                      //number of steps and sigma on pads charges
     355         189 :    arglist[1] = 1.;                                                                       //
     356             : 
     357         189 :    ierflg = fitter->ExecuteCommand("SIMPLEX",arglist,2);                                  //start fitting with Simplex
     358         189 :    if (!ierflg)
     359         189 :      fitter->ExecuteCommand("MIGRAD" ,arglist,2);                                         //fitting improved by Migrad
     360         189 :    if(ierflg) {
     361           0 :      Double_t strategy=2;
     362           0 :      ierflg = fitter->ExecuteCommand("SET STR",&strategy,1);                              //change level of strategy 
     363           0 :      if(!ierflg) {
     364           0 :        ierflg = fitter->ExecuteCommand("SIMPLEX",arglist,2);                              //start fitting with Simplex
     365           0 :        if (!ierflg)
     366           0 :          fitter->ExecuteCommand("MIGRAD" ,arglist,2);                                     //fitting improved by Migrad
     367             :      }
     368           0 :    }        
     369         189 :    if(ierflg) fSt=kAbn;                                                                   //no convergence of the fit...
     370         189 :    Double_t dummy; char sName[80];                                                        //vars to get results from Minuit
     371         189 :    Double_t edm, errdef;
     372         189 :    Int_t nvpar, nparx;
     373             :    
     374         818 :    for(Int_t i=0;i<fNlocMax;i++){                                                        //store the local maxima parameters
     375         220 :      fitter->GetParameter(3*i   ,sName,  fXX, fErrX , dummy, dummy);                     // X
     376         220 :      fitter->GetParameter(3*i+1 ,sName,  fYY, fErrY , dummy, dummy);                     // Y
     377         220 :      fitter->GetParameter(3*i+2 ,sName,  fQ, fErrQ , dummy, dummy);                      // Q
     378         220 :      fitter->GetStats(fChi2, edm, errdef, nvpar, nparx);                                 //get fit infos
     379             : 
     380         279 :      if(fNlocMax>1)FindClusterSize(i,pSigmaCut);                                         //find clustersize for deconvoluted clusters
     381             :                                                                                          //after this call, fSi temporarly is the calculated size. Later is set again 
     382             :                                                                                          //to its original value
     383         220 :      if(fSt!=kAbn) {         
     384         279 :       if(fNlocMax!=1)fSt=kUnf;                                                           // if unfolded
     385         542 :       if(fNlocMax==1&&fSt!=kNoLoc) fSt=kLo1;                                             // if only 1 loc max
     386         220 :       if ( !IsInPc()) fSt = kEdg;                                                        // if Out of Pc
     387         220 :       if(fSt==kNoLoc) fNlocMax=0;                                                        // if with no loc max (pads with same charge..)
     388             :      }
     389         220 :      SetClusterParams(fXX,fYY,fCh);                                                      //need to fill the AliCluster3D part
     390         220 :      new ((*pCluLst)[iCluCnt++]) AliHMPIDCluster(*this);                                 //add new unfolded cluster
     391         279 :      if(fNlocMax>1)SetSize(rawSize);                                                     //Original raw size is set again to its proper value
     392             :    }
     393         189 :  }
     394             : 
     395         189 :  return fNlocMax;
     396             :  
     397         617 : }//Solve()
     398             : //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     399             : void AliHMPIDCluster::FindClusterSize(Int_t i,Int_t *pSigmaCut)
     400             : {
     401             : 
     402             : //Estimate of the clustersize for a deconvoluted cluster
     403             :   Int_t size = 0;
     404         975 :   for(Int_t iDig=0;iDig<Size();iDig++) {                                               //digits loop
     405         399 :     AliHMPIDDigit *pDig = Dig(iDig);                                                   //take digit
     406         399 :     Int_t iCh = pDig->Ch();
     407         399 :     Double_t qPad = Q()*pDig->IntMathieson(X(),Y());                                   //pad charge
     408        1197 :     AliDebug(1,Form("Chamber %i X %i Y %i SigmaCut %i pad %i qpadMath %8.2f qPadRaw %8.2f Qtotal %8.2f cluster n.%i",iCh,pDig->PadChX(),pDig->PadChY(),
     409             :         pSigmaCut[iCh],iDig,qPad,pDig->Q(),QRaw(),i));
     410         568 :     if(qPad>pSigmaCut[iCh]) size++;
     411             :    }
     412         177 :   AliDebug(1,Form(" Calculated size %i",size));
     413         118 :   if(size>0) SetSize(size);                                                            //in case of size == 0, original raw clustersize used 
     414          59 : }

Generated by: LCOV version 1.11