]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSClusterFinderSDD.cxx
Updating CMake files
[u/mrichter/AliRoot.git] / ITS / AliITSClusterFinderSDD.cxx
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   $Id$
17  */
18 /////////////////////////////////////////////////////////////////////////// 
19 //  Cluster finder                                                       //
20 //  for Silicon                                                          //
21 //  Drift Detector                                                       //
22 ////////////////////////////////////////////////////////////////////////// 
23
24
25 #include "AliITSClusterFinderSDD.h"
26 #include "AliITSMapA1.h"
27 #include "AliITSRawClusterSDD.h"
28 #include "AliITSRecPoint.h"
29 #include "AliITSdigitSDD.h"
30 #include "AliITSDetTypeRec.h"
31 #include "AliITSCalibrationSDD.h"
32 #include "AliITSsegmentationSDD.h"
33 #include "AliITSgeom.h"
34 #include "AliLog.h"
35
36 ClassImp(AliITSClusterFinderSDD)
37
38 //______________________________________________________________________
39 AliITSClusterFinderSDD::AliITSClusterFinderSDD():
40 AliITSClusterFinder(),
41 fNclusters(0),
42 fDAnode(0.0),
43 fDTime(0.0),
44 fTimeCorr(0.0),
45 fCutAmplitude(0),
46 fMinPeak(0),
47 fMinCharge(0),
48 fMinNCells(0),
49 fMaxNCells(0){
50     // default constructor
51 }
52 //______________________________________________________________________
53 AliITSClusterFinderSDD::AliITSClusterFinderSDD(AliITSDetTypeRec* dettyp,
54                                                TClonesArray *digits,
55                                                TClonesArray *recp):
56 AliITSClusterFinder(dettyp),
57 fNclusters(0),
58 fDAnode(0.0),
59 fDTime(0.0),
60 fTimeCorr(0.0),
61 fCutAmplitude(0),
62 fMinPeak(0),
63 fMinCharge(0),
64 fMinNCells(0),
65 fMaxNCells(0){
66     // standard constructor
67
68     SetDigits(digits);
69     SetClusters(recp);
70     SetCutAmplitude(fDetTypeRec->GetITSgeom()->GetStartSDD());
71     SetDAnode();
72     SetDTime();
73     SetMinPeak((Int_t)((AliITSCalibrationSDD*)GetResp(fDetTypeRec->GetITSgeom()->GetStartSDD()))->GetNoiseAfterElectronics(0)*5);
74     SetMinNCells();
75     SetMaxNCells();
76     SetTimeCorr();
77     SetMinCharge();
78     SetMap(new AliITSMapA1(GetSeg(),Digits(),fCutAmplitude));
79 }
80 //______________________________________________________________________
81 void AliITSClusterFinderSDD::SetCutAmplitude(Int_t mod,Double_t nsigma){
82     // set the signal threshold for cluster finder
83     Double_t baseline,noiseAfterEl;
84
85     Bool_t isZeroSupp=GetResp(mod)->GetZeroSupp();
86     Int_t nanodes = GetResp(mod)->Wings()*GetResp(mod)->Channels()*GetResp(mod)->Chips();
87     fCutAmplitude.Set(nanodes);
88     for(Int_t ian=0;ian<nanodes;ian++){
89       noiseAfterEl = ((AliITSCalibrationSDD*)GetResp(mod))->GetNoiseAfterElectronics(ian);
90       if(isZeroSupp){
91         fCutAmplitude[ian] = (Int_t)(nsigma*noiseAfterEl);
92       }
93       else{
94         baseline=GetResp(mod)->GetBaseline(ian);
95         fCutAmplitude[ian] = (Int_t)((baseline + nsigma*noiseAfterEl));
96       } 
97     }
98 }
99 //______________________________________________________________________
100 void AliITSClusterFinderSDD::Find1DClusters(){
101     // find 1D clusters
102   
103     // retrieve the parameters 
104     Int_t fNofMaps       = GetSeg()->Npz();
105     Int_t fMaxNofSamples = GetSeg()->Npx();
106     Int_t fNofAnodes     = fNofMaps/2;
107     Int_t dummy          = 0;
108     Double_t fTimeStep    = GetSeg()->Dpx(dummy);
109     Double_t fSddLength   = GetSeg()->Dx();
110     AliITSCalibrationSDD* cal = (AliITSCalibrationSDD*)GetResp(fModule);
111     Bool_t isZeroSupp=cal->GetZeroSupp();
112
113     // map the signal
114     Map()->ClearMap();
115     Map()->SetThresholdArr(fCutAmplitude);
116     Map()->FillMap2();
117   
118     Int_t nofFoundClusters = 0;
119     Int_t i;
120     Double_t **dfadc = new Double_t*[fNofAnodes];
121     for(i=0;i<fNofAnodes;i++) dfadc[i] = new Double_t[fMaxNofSamples];
122     Double_t fadc  = 0.;
123     Double_t fadc1 = 0.;
124     Double_t fadc2 = 0.;
125     Int_t j,k,idx,l,m;
126     for(j=0;j<2;j++) {
127         for(k=0;k<fNofAnodes;k++) {
128             idx = j*fNofAnodes+k;
129             // signal (fadc) & derivative (dfadc)
130             dfadc[k][255]=0.;
131             for(l=0; l<fMaxNofSamples; l++) {
132                 fadc2=(Double_t)Map()->GetSignal(idx,l);
133                 if(l>0) fadc1=(Double_t)Map()->GetSignal(idx,l-1);
134                 if(l>0) dfadc[k][l-1] = fadc2-fadc1;
135             } // samples
136         } // anodes
137
138         for(k=0;k<fNofAnodes;k++) {
139             AliDebug(5,Form("Anode: %d, Wing: %d",k+1,j+1));
140             idx = j*fNofAnodes+k;
141             Int_t imax  = 0;
142             Int_t imaxd = 0;
143             Int_t it    = 0;
144             while(it <= fMaxNofSamples-3) {
145                 imax  = it;
146                 imaxd = it;
147                 // maximum of signal          
148                 Double_t fadcmax  = 0.;
149                 Double_t dfadcmax = 0.;
150                 Int_t lthrmina   = 1;
151                 Int_t lthrmint   = 3;
152                 Int_t lthra      = 1;
153                 Int_t lthrt      = 0;
154                 for(m=0;m<20;m++) {
155                     Int_t id = it+m;
156                     if(id>=fMaxNofSamples) break;
157                     fadc=(float)Map()->GetSignal(idx,id);
158                     if(fadc > fadcmax) { fadcmax = fadc; imax = id;}
159                     if(fadc > (float)fCutAmplitude[idx])lthrt++; 
160                     if(dfadc[k][id] > dfadcmax) {
161                         dfadcmax = dfadc[k][id];
162                         imaxd    = id;
163                     } // end if
164                 } // end for m
165                 it = imaxd;
166                 if(Map()->TestHit(idx,imax) == kEmpty) {it++; continue;}
167                 // cluster charge
168                 Int_t tstart = it-2;
169                 if(tstart < 0) tstart = 0;
170                 Bool_t ilcl = 0;
171                 if(lthrt >= lthrmint && lthra >= lthrmina) ilcl = 1;
172                 if(ilcl) {
173                     nofFoundClusters++;
174                     Int_t tstop      = tstart;
175                     Double_t dfadcmin = 10000.;
176                     Int_t ij;
177                     for(ij=0; ij<20; ij++) {
178                         if(tstart+ij > 255) { tstop = 255; break; }
179                         fadc=(float)Map()->GetSignal(idx,tstart+ij);
180                         if((dfadc[k][tstart+ij] < dfadcmin) && 
181                            (fadc > fCutAmplitude[idx])) {
182                             tstop = tstart+ij+5;
183                             if(tstop > 255) tstop = 255;
184                             dfadcmin = dfadc[k][it+ij];
185                         } // end if
186                     } // end for ij
187
188                     Double_t clusterCharge = 0.;
189                     Double_t clusterAnode  = k+0.5;
190                     Double_t clusterTime   = 0.;
191                     Int_t   clusterMult   = 0;
192                     Double_t clusterPeakAmplitude = 0.;
193                     Int_t its,peakpos     = -1;
194                                    
195                     for(its=tstart; its<=tstop; its++) {
196                         fadc=(float)Map()->GetSignal(idx,its);
197                         if(!isZeroSupp){
198                           Double_t baseline=GetResp(fModule)->GetBaseline(idx);
199                           if(fadc>baseline) fadc -= baseline;
200                           else fadc = 0.;
201                         }
202                         clusterCharge += fadc;
203                         // as a matter of fact we should take the peak
204                         // pos before FFT
205                         // to get the list of tracks !!!
206                         if(fadc > clusterPeakAmplitude) {
207                             clusterPeakAmplitude = fadc;
208                             //peakpos=Map()->GetHitIndex(idx,its);
209                             Int_t shift = (int)(fTimeCorr/fTimeStep);
210                             if(its>shift && its<(fMaxNofSamples-shift))
211                                 peakpos  = Map()->GetHitIndex(idx,its+shift);
212                             else peakpos = Map()->GetHitIndex(idx,its);
213                             if(peakpos<0) peakpos =Map()->GetHitIndex(idx,its);
214                         } // end if
215                         clusterTime += fadc*its;
216                         if(fadc > 0) clusterMult++;
217                         if(its == tstop) {
218                             clusterTime /= (clusterCharge/fTimeStep);   // ns
219                             if(clusterTime>fTimeCorr) clusterTime -=fTimeCorr;
220                             //ns
221                         } // end if
222                     } // end for its
223                     Float_t theAnode=clusterAnode+j*fNofAnodes;
224                     Double_t clusteranodePath = GetSeg()->GetLocalZFromAnode(theAnode);
225                     Double_t clusterDriftPath = (Double_t)cal->GetDriftPath(clusterTime,clusteranodePath);
226                     clusterDriftPath = fSddLength-clusterDriftPath;
227                     if(clusterCharge <= 0.) break;
228                     AliITSRawClusterSDD clust(j+1,//i
229                                               clusterAnode,clusterTime,//ff
230                                               clusterCharge, //f
231                                               clusterPeakAmplitude, //f
232                                               peakpos, //i
233                                               0.,0.,clusterDriftPath,//fff
234                                               clusteranodePath, //f
235                                               clusterMult, //i
236                                               0,0,0,0,0,0,0);//7*i
237                     fDetTypeRec->AddCluster(1,&clust);
238                     it = tstop;
239                 } // ilcl
240                 it++;
241             } // while (samples)
242         } // anodes
243     } // detectors (2)
244
245     for(i=0;i<fNofAnodes;i++) delete[] dfadc[i];
246     delete [] dfadc;
247
248     return;
249 }
250 //______________________________________________________________________
251 void AliITSClusterFinderSDD::Find1DClustersE(){
252     // find 1D clusters
253     // retrieve the parameters 
254     Int_t fNofMaps = GetSeg()->Npz();
255     Int_t fMaxNofSamples = GetSeg()->Npx();
256     Int_t fNofAnodes = fNofMaps/2;
257     Int_t dummy=0;
258     Double_t fTimeStep = GetSeg()->Dpx( dummy );
259     Double_t fSddLength = GetSeg()->Dx();
260     AliITSCalibrationSDD* cal = (AliITSCalibrationSDD*)GetResp(fModule);
261     Map()->ClearMap();
262     Map()->SetThresholdArr( fCutAmplitude );
263     Map()->FillMap2();
264     Bool_t isZeroSupp=cal->GetZeroSupp();
265
266     Int_t nClu = 0;
267     //        cout << "Search  cluster... "<< endl;
268     for( Int_t j=0; j<2; j++ ){
269         for( Int_t k=0; k<fNofAnodes; k++ ){
270             Int_t idx = j*fNofAnodes+k;     
271             Bool_t on = kFALSE;
272             Int_t start = 0;
273             Int_t nTsteps = 0;
274             Double_t fmax = 0.;
275             Int_t lmax = 0;
276             Double_t charge = 0.;
277             Double_t time = 0.;
278             Double_t anode = k+0.5;
279             Int_t peakpos = -1;
280             for( Int_t l=0; l<fMaxNofSamples; l++ ){
281                 Double_t fadc = (Double_t)Map()->GetSignal( idx, l );
282                 if( fadc > 0.0 ){
283                     if( on == kFALSE && l<fMaxNofSamples-4){
284                         // star RawCluster (reset var.)
285                         Double_t fadc1 = (Double_t)Map()->GetSignal( idx, l+1 );
286                         if( fadc1 < fadc ) continue;
287                         start = l;
288                         fmax = 0.;
289                         lmax = 0;
290                         time = 0.;
291                         charge = 0.; 
292                         on = kTRUE; 
293                         nTsteps = 0;
294                     } // end if on...
295                     nTsteps++ ;
296                     if(!isZeroSupp){
297                       Double_t baseline=GetResp(fModule)->GetBaseline(idx);
298                       if( fadc > baseline ) fadc -= baseline;
299                       else fadc=0.;
300                     }
301                     charge += fadc;
302                     time += fadc*l;
303                     if( fadc > fmax ){ 
304                         fmax = fadc; 
305                         lmax = l; 
306                         Int_t shift = (Int_t)(fTimeCorr/fTimeStep + 0.5);
307                         if( l > shift && l < (fMaxNofSamples-shift) )  
308                             peakpos = Map()->GetHitIndex( idx, l+shift );
309                         else
310                             peakpos = Map()->GetHitIndex( idx, l );
311                         if( peakpos < 0) peakpos = Map()->GetHitIndex(idx,l);
312                     } // end if fadc
313                 }else{ // end fadc>0
314                     if( on == kTRUE ){        
315                         if( nTsteps > 2 ){
316                             //  min # of timesteps for a RawCluster
317                             // Found a RawCluster...
318                             Int_t stop = l-1;
319                             time /= (charge/fTimeStep);   // ns
320                                 // time = lmax*fTimeStep;   // ns
321                             if( time > fTimeCorr ) time -= fTimeCorr;   // ns
322                             Float_t theAnode=anode+j*fNofAnodes;
323                             Double_t anodePath =GetSeg()->GetLocalZFromAnode(theAnode);
324                             Double_t driftPath = (Double_t)cal->GetDriftPath(time,anode);
325                             driftPath = fSddLength-driftPath;
326                             AliITSRawClusterSDD clust(j+1,anode,time,charge,
327                                                       fmax, peakpos,0.,0.,
328                                                       driftPath,anodePath,
329                                                       nTsteps,start,stop,
330                                                       start, stop, 1, k, k );
331                             fDetTypeRec->AddCluster( 1, &clust );
332                             if(AliDebugLevel()>=5) clust.PrintInfo();
333                             nClu++;
334                         } // end if nTsteps
335                         on = kFALSE;
336                     } // end if on==kTRUE
337                 } // end if fadc>0
338             } // samples
339         } // anodes
340     } // wings
341     AliDebug(3,Form("# Rawclusters %d",nClu));         
342     return; 
343 }
344 //_______________________________________________________________________
345 Int_t AliITSClusterFinderSDD::SearchPeak(Double_t *spect,Int_t xdim,Int_t zdim,
346                                          Int_t *peakX, Int_t *peakZ, 
347                                          Double_t *peakAmp, Double_t minpeak ){
348     // search peaks on a 2D cluster
349     Int_t npeak = 0;    // # peaks
350     Int_t i,j;
351     // search peaks
352     for( Int_t z=1; z<zdim-1; z++ ){
353         for( Int_t x=1; x<xdim-2; x++ ){
354             Double_t sxz = spect[x*zdim+z];
355             Double_t sxz1 = spect[(x+1)*zdim+z];
356             Double_t sxz2 = spect[(x-1)*zdim+z];
357             // search a local max. in s[x,z]
358             if( sxz < minpeak || sxz1 <= 0 || sxz2 <= 0 ) continue;
359             if( sxz >= spect[(x+1)*zdim+z  ] && sxz >= spect[(x-1)*zdim+z  ] &&
360                 sxz >= spect[x*zdim    +z+1] && sxz >= spect[x*zdim    +z-1] &&
361                 sxz >= spect[(x+1)*zdim+z+1] && sxz >= spect[(x+1)*zdim+z-1] &&
362                 sxz >= spect[(x-1)*zdim+z+1] && sxz >= spect[(x-1)*zdim+z-1] ){
363                 // peak found
364                 peakX[npeak] = x;
365                 peakZ[npeak] = z;
366                 peakAmp[npeak] = sxz;
367                 npeak++;
368             } // end if ....
369         } // end for x
370     } // end for z
371     // search groups of peaks with same amplitude.
372     Int_t *flag = new Int_t[npeak];
373     for( i=0; i<npeak; i++ ) flag[i] = 0;
374     for( i=0; i<npeak; i++ ){
375         for( j=0; j<npeak; j++ ){
376             if( i==j) continue;
377             if( flag[j] > 0 ) continue;
378             if( peakAmp[i] == peakAmp[j] && 
379                 TMath::Abs(peakX[i]-peakX[j])<=1 && 
380                 TMath::Abs(peakZ[i]-peakZ[j])<=1 ){
381                 if( flag[i] == 0) flag[i] = i+1;
382                 flag[j] = flag[i];
383             } // end if ...
384         } // end for j
385     } // end for i
386     // make average of peak groups        
387     for( i=0; i<npeak; i++ ){
388         Int_t nFlag = 1;
389         if( flag[i] <= 0 ) continue;
390         for( j=0; j<npeak; j++ ){
391             if( i==j ) continue;
392             if( flag[j] != flag[i] ) continue;
393             peakX[i] += peakX[j];
394             peakZ[i] += peakZ[j];
395             nFlag++;
396             npeak--;
397             for( Int_t k=j; k<npeak; k++ ){
398                 peakX[k] = peakX[k+1];
399                 peakZ[k] = peakZ[k+1];
400                 peakAmp[k] = peakAmp[k+1];
401                 flag[k] = flag[k+1];
402             } // end for k        
403             j--;
404         } // end for j
405         if( nFlag > 1 ){
406             peakX[i] /= nFlag;
407             peakZ[i] /= nFlag;
408         } // end fi nFlag
409     } // end for i
410     delete [] flag;
411     return( npeak );
412 }
413 //______________________________________________________________________
414 void AliITSClusterFinderSDD::PeakFunc( Int_t xdim, Int_t zdim, Double_t *par,
415                                        Double_t *spe, Double_t *integral){
416     // function used to fit the clusters
417     // par -> parameters..
418     // par[0]  number of peaks.
419     // for each peak i=1, ..., par[0]
420     //                 par[i] = Ampl.
421     //                 par[i+1] = xpos
422     //                 par[i+2] = zpos
423     //                 par[i+3] = tau
424     //                 par[i+4] = sigma.
425     Int_t electronics = 1; // 1 = PASCAL, 2 = OLA
426     const Int_t knParam = 5;
427     Int_t npeak = (Int_t)par[0];
428
429     memset( spe, 0, sizeof( Double_t )*zdim*xdim );
430
431     Int_t k = 1;
432     for( Int_t i=0; i<npeak; i++ ){
433         if( integral != 0 ) integral[i] = 0.;
434         Double_t sigmaA2 = par[k+4]*par[k+4]*2.;
435         Double_t t2 = par[k+3];   // PASCAL
436         if( electronics == 2 ) { t2 *= t2; t2 *= 2; } // OLA
437         for( Int_t z=0; z<zdim; z++ ){
438             for( Int_t x=0; x<xdim; x++ ){
439                 Double_t z2 = (z-par[k+2])*(z-par[k+2])/sigmaA2;
440                 Double_t x2 = 0.;
441                 Double_t signal = 0.;
442                 if( electronics == 1 ){ // PASCAL
443                     x2 = (x-par[k+1]+t2)/t2;
444                     signal = (x2>0.) ? par[k]*x2*exp(-x2+1.-z2) :0.0; // RCCR2
445                 //  signal =(x2>0.) ? par[k]*x2*x2*exp(-2*x2+2.-z2 ):0.0;//RCCR
446                 }else if( electronics == 2 ) { // OLA
447                     x2 = (x-par[k+1])*(x-par[k+1])/t2;
448                     signal = par[k]  * exp( -x2 - z2 );
449                 } else {
450                     Warning("PeakFunc","Wrong SDD Electronics = %d",
451                             electronics);
452                     // exit( 1 );
453                 } // end if electronicx
454                 spe[x*zdim+z] += signal;
455                 if( integral != 0 ) integral[i] += signal;
456             } // end for x
457         } // end for z
458         k += knParam;
459     } // end for i
460     return;
461 }
462 //__________________________________________________________________________
463 Double_t AliITSClusterFinderSDD::ChiSqr( Int_t xdim, Int_t zdim, Double_t *spe,
464                                         Double_t *speFit ) const{
465     // EVALUATES UNNORMALIZED CHI-SQUARED
466     Double_t chi2 = 0.;
467     for( Int_t z=0; z<zdim; z++ ){
468         for( Int_t x=1; x<xdim-1; x++ ){
469             Int_t index = x*zdim+z;
470             Double_t tmp = spe[index] - speFit[index];
471             chi2 += tmp*tmp;
472         } // end for x
473     } // end for z
474     return( chi2 );
475 }
476 //_______________________________________________________________________
477 void AliITSClusterFinderSDD::Minim( Int_t xdim, Int_t zdim, Double_t *param,
478                                     Double_t *prm0,Double_t *steprm,
479                                     Double_t *chisqr,Double_t *spe,
480                                     Double_t *speFit ){
481     // 
482     Int_t   k, nnn, mmm, i;
483     Double_t p1, delta, d1, chisq1, p2, chisq2, t, p3, chisq3, a, b, p0, chisqt;
484     const Int_t knParam = 5;
485     Int_t npeak = (Int_t)param[0];
486     for( k=1; k<(npeak*knParam+1); k++ ) prm0[k] = param[k];
487     for( k=1; k<(npeak*knParam+1); k++ ){
488         p1 = param[k];
489         delta = steprm[k];
490         d1 = delta;
491         // ENSURE THAT STEP SIZE IS SENSIBLY LARGER THAN MACHINE ROUND OFF
492         if( TMath::Abs( p1 ) > 1.0E-6 ) 
493             if ( TMath::Abs( delta/p1 ) < 1.0E-4 ) delta = p1/1000;
494             else  delta = (Double_t)1.0E-4;
495         //  EVALUATE CHI-SQUARED AT FIRST TWO SEARCH POINTS
496         PeakFunc( xdim, zdim, param, speFit );
497         chisq1 = ChiSqr( xdim, zdim, spe, speFit );
498         p2 = p1+delta;
499         param[k] = p2;
500         PeakFunc( xdim, zdim, param, speFit );
501         chisq2 = ChiSqr( xdim, zdim, spe, speFit );
502         if( chisq1 < chisq2 ){
503             // REVERSE DIRECTION OF SEARCH IF CHI-SQUARED IS INCREASING
504             delta = -delta;
505             t = p1;
506             p1 = p2;
507             p2 = t;
508             t = chisq1;
509             chisq1 = chisq2;
510             chisq2 = t;
511         } // end if
512         i = 1; nnn = 0;
513         do {   // INCREMENT param(K) UNTIL CHI-SQUARED STARTS TO INCREASE
514             nnn++;
515             p3 = p2 + delta;
516             mmm = nnn - (nnn/5)*5;  // multiplo de 5
517             if( mmm == 0 ){
518                 d1 = delta;
519                 // INCREASE STEP SIZE IF STEPPING TOWARDS MINIMUM IS TOO SLOW 
520                 delta *= 5;
521             } // end if
522             param[k] = p3;
523             // Constrain paramiters
524             Int_t kpos = (k-1) % knParam;
525             switch( kpos ){
526             case 0 :
527                 if( param[k] <= 20 ) param[k] = fMinPeak;
528                 break;
529             case 1 :
530                 if( TMath::Abs( param[k] - prm0[k] ) > 1.5 ) param[k] = prm0[k];
531                 break;
532             case 2 :
533                 if( TMath::Abs( param[k] - prm0[k] ) > 1. ) param[k] = prm0[k];
534                 break;
535             case 3 :
536                 if( param[k] < .5 ) param[k] = .5;        
537                 break;
538             case 4 :
539                 if( param[k] < .288 ) param[k] = .288;// 1/sqrt(12) = 0.288
540                 if( param[k] > zdim*.5 ) param[k] = zdim*.5;
541                 break;
542             }; // end switch
543             PeakFunc( xdim, zdim, param, speFit );
544             chisq3 = ChiSqr( xdim, zdim, spe, speFit );
545             if( chisq3 < chisq2 && nnn < 50 ){
546                 p1 = p2;
547                 p2 = p3;
548                 chisq1 = chisq2;
549                 chisq2 = chisq3;
550             }else i=0;
551         } while( i );
552         // FIND MINIMUM OF PARABOLA DEFINED BY LAST THREE POINTS
553         a = chisq1*(p2-p3)+chisq2*(p3-p1)+chisq3*(p1-p2);
554         b = chisq1*(p2*p2-p3*p3)+chisq2*(p3*p3-p1*p1)+chisq3*(p1*p1-p2*p2);
555         if( a!=0 ) p0 = (Double_t)(0.5*b/a);
556         else p0 = 10000;
557         //--IN CASE OF NEARLY EQUAL CHI-SQUARED AND TOO SMALL STEP SIZE PREVENT
558         //   ERRONEOUS EVALUATION OF PARABOLA MINIMUM
559         //---NEXT TWO LINES CAN BE OMITTED FOR HIGHER PRECISION MACHINES
560         //dp = (Double_t) max (TMath::Abs(p3-p2), TMath::Abs(p2-p1));
561         //if( TMath::Abs( p2-p0 ) > dp ) p0 = p2;
562         param[k] = p0;
563         // Constrain paramiters
564         Int_t kpos = (k-1) % knParam;
565         switch( kpos ){
566         case 0 :
567             if( param[k] <= 20 ) param[k] = fMinPeak;   
568             break;
569         case 1 :
570             if( TMath::Abs( param[k] - prm0[k] ) > 1.5 ) param[k] = prm0[k];
571             break;
572         case 2 :
573             if( TMath::Abs( param[k] - prm0[k] ) > 1. ) param[k] = prm0[k];
574             break;
575         case 3 :
576             if( param[k] < .5 ) param[k] = .5;        
577             break;
578         case 4 :
579             if( param[k] < .288 ) param[k] = .288;  // 1/sqrt(12) = 0.288
580             if( param[k] > zdim*.5 ) param[k] = zdim*.5;
581             break;
582         }; // end switch
583         PeakFunc( xdim, zdim, param, speFit );
584         chisqt = ChiSqr( xdim, zdim, spe, speFit );
585         // DO NOT ALLOW ERRONEOUS INTERPOLATION
586         if( chisqt <= *chisqr ) *chisqr = chisqt;
587         else param[k] = prm0[k];
588         // OPTIMIZE SEARCH STEP FOR EVENTUAL NEXT CALL OF MINIM
589         steprm[k] = (param[k]-prm0[k])/5;
590         if( steprm[k] >= d1 ) steprm[k] = d1/5;
591     } // end for k
592     // EVALUATE FIT AND CHI-SQUARED FOR OPTIMIZED PARAMETERS
593     PeakFunc( xdim, zdim, param, speFit );
594     *chisqr = ChiSqr( xdim, zdim, spe, speFit );
595     return;
596 }
597 //_________________________________________________________________________
598 Int_t AliITSClusterFinderSDD::NoLinearFit( Int_t xdim, Int_t zdim, 
599                                            Double_t *param, Double_t *spe, 
600                                            Int_t *niter, Double_t *chir ){
601     // fit method from Comput. Phys. Commun 46(1987) 149
602     const Double_t kchilmt = 0.01;  //        relative accuracy           
603     const Int_t   knel = 3;        //        for parabolic minimization  
604     const Int_t   knstop = 50;     //        Max. iteration number          
605     const Int_t   knParam = 5;
606     Int_t npeak = (Int_t)param[0];
607     // RETURN IF NUMBER OF DEGREES OF FREEDOM IS NOT POSITIVE 
608     if( (xdim*zdim - npeak*knParam) <= 0 ) return( -1 );
609     Double_t degFree = (xdim*zdim - npeak*knParam)-1;
610     Int_t   n, k, iterNum = 0;
611     Double_t *prm0 = new Double_t[npeak*knParam+1];
612     Double_t *step = new Double_t[npeak*knParam+1];
613     Double_t *schi = new Double_t[npeak*knParam+1]; 
614     Double_t *sprm[3];
615     sprm[0] = new Double_t[npeak*knParam+1];
616     sprm[1] = new Double_t[npeak*knParam+1];
617     sprm[2] = new Double_t[npeak*knParam+1];
618     Double_t  chi0, chi1, reldif, a, b, prmin, dp;
619     Double_t *speFit = new Double_t[ xdim*zdim ];
620     PeakFunc( xdim, zdim, param, speFit );
621     chi0 = ChiSqr( xdim, zdim, spe, speFit );
622     chi1 = chi0;
623     for( k=1; k<(npeak*knParam+1); k++) prm0[k] = param[k];
624         for( k=1 ; k<(npeak*knParam+1); k+=knParam ){
625             step[k] = param[k] / 20.0 ;
626             step[k+1] = param[k+1] / 50.0;
627             step[k+2] = param[k+2] / 50.0;                 
628             step[k+3] = param[k+3] / 20.0;                 
629             step[k+4] = param[k+4] / 20.0;                 
630         } // end for k
631     Int_t out = 0;
632     do{
633         iterNum++;
634             chi0 = chi1;
635             Minim( xdim, zdim, param, prm0, step, &chi1, spe, speFit );
636             reldif = ( chi1 > 0 ) ? ((Double_t) TMath::Abs( chi1-chi0)/chi1 ) : 0;
637         // EXIT conditions
638         if( reldif < (float) kchilmt ){
639             *chir  = (chi1>0) ? (float) TMath::Sqrt (chi1/degFree) :0;
640             *niter = iterNum;
641             out = 0;
642             break;
643         } // end if
644         if( (reldif < (float)(5*kchilmt)) && (iterNum > knstop) ){
645             *chir = (chi1>0) ?(float) TMath::Sqrt (chi1/degFree):0;
646             *niter = iterNum;
647             out = 0;
648             break;
649         } // end if
650         if( iterNum > 5*knstop ){
651             *chir  = (chi1>0) ?(float) TMath::Sqrt (chi1/degFree):0;
652             *niter = iterNum;
653             out = 1;
654             break;
655         } // end if
656         if( iterNum <= knel ) continue;
657         n = iterNum - (iterNum/knel)*knel; // EXTRAPOLATION LIMIT COUNTER N
658         if( n > 3 || n == 0 ) continue;
659         schi[n-1] = chi1;
660         for( k=1; k<(npeak*knParam+1); k++ ) sprm[n-1][k] = param[k];
661         if( n != 3 ) continue;
662         // -EVALUATE EXTRAPOLATED VALUE OF EACH PARAMETER BY FINDING MINIMUM OF
663         //    PARABOLA DEFINED BY LAST THREE CALLS OF MINIM
664         for( k=1; k<(npeak*knParam+1); k++ ){
665             Double_t tmp0 = sprm[0][k];
666             Double_t tmp1 = sprm[1][k];
667             Double_t tmp2 = sprm[2][k];
668             a  = schi[0]*(tmp1-tmp2) + schi[1]*(tmp2-tmp0);
669             a += (schi[2]*(tmp0-tmp1));
670             b  = schi[0]*(tmp1*tmp1-tmp2*tmp2);
671             b += (schi[1]*(tmp2*tmp2-tmp0*tmp0)+(schi[2]*
672                                              (tmp0*tmp0-tmp1*tmp1)));
673             if ((double)a < 1.0E-6) prmin = 0;
674             else prmin = (float) (0.5*b/a);
675             dp = 5*(tmp2-tmp0);
676             if( TMath::Abs(prmin-tmp2) > TMath::Abs(dp) ) prmin = tmp2+dp;
677             param[k] = prmin;
678             step[k]  = dp/10; // OPTIMIZE SEARCH STEP
679         } // end for k
680     } while( kTRUE );
681     delete [] prm0;
682     delete [] step;
683     delete [] schi; 
684     delete [] sprm[0];
685     delete [] sprm[1];
686     delete [] sprm[2];
687     delete [] speFit;
688     return( out );
689 }
690
691 //______________________________________________________________________
692 void AliITSClusterFinderSDD::ResolveClusters(){
693     // The function to resolve clusters if the clusters overlapping exists
694     Int_t i;
695     // get number of clusters for this module
696     Int_t nofClusters = NClusters();
697     nofClusters -= fNclusters;
698     Int_t fNofMaps = GetSeg()->Npz();
699     Int_t fNofAnodes = fNofMaps/2;
700     //Int_t fMaxNofSamples = GetSeg()->Npx();
701     Int_t dummy=0;
702     Double_t fTimeStep = GetSeg()->Dpx( dummy );
703     Double_t fSddLength = GetSeg()->Dx();
704     Double_t anodePitch = GetSeg()->Dpz( dummy );
705     Int_t electronics =1;//GetResp(fModule)->GetElectronics(); // 1 = PASCAL, 2 = OLA
706     AliITSCalibrationSDD* cal = (AliITSCalibrationSDD*)GetResp(fModule);
707     Bool_t isZeroSupp=cal->GetZeroSupp();
708
709     
710
711     for( Int_t j=0; j<nofClusters; j++ ){ 
712         // get cluster information
713         AliITSRawClusterSDD *clusterJ=(AliITSRawClusterSDD*) Cluster(j);
714         Int_t astart = clusterJ->Astart();
715         Int_t astop = clusterJ->Astop();
716         Int_t tstart = clusterJ->Tstartf();
717         Int_t tstop = clusterJ->Tstopf();
718         Int_t wing = (Int_t)clusterJ->W();
719         if( wing == 2 ){
720             astart += fNofAnodes; 
721             astop  += fNofAnodes;
722         } // end if 
723         Int_t xdim = tstop-tstart+3;
724         Int_t zdim = astop-astart+3;
725         if( xdim > 50 || zdim > 30 ) { 
726             Warning("ResolveClusters","xdim: %d , zdim: %d ",xdim,zdim);
727             continue;
728         }
729         Double_t *sp = new Double_t[ xdim*zdim+1 ];
730         memset( sp, 0, sizeof(Double_t)*(xdim*zdim+1) );
731         
732         // make a local map from cluster region
733         for( Int_t ianode=astart; ianode<=astop; ianode++ ){
734             for( Int_t itime=tstart; itime<=tstop; itime++ ){
735                 Double_t fadc = Map()->GetSignal( ianode, itime );             
736                 if(!isZeroSupp){
737                   Double_t baseline=GetResp(fModule)->GetBaseline(ianode);
738                   if( fadc > baseline ) fadc -= (Double_t)baseline;
739                   else fadc = 0.;
740                 }
741                 Int_t index = (itime-tstart+1)*zdim+(ianode-astart+1);
742                 sp[index] = fadc;
743             } // time loop
744         } // anode loop
745         
746         // search peaks on cluster
747         const Int_t kNp = 150;
748         Int_t peakX1[kNp];
749         Int_t peakZ1[kNp];
750         Double_t peakAmp1[kNp];
751         Int_t npeak = SearchPeak(sp,xdim,zdim,peakX1,peakZ1,peakAmp1,fMinPeak);
752
753         // if multiple peaks, split cluster
754         if( npeak >= 1 ){
755             //        cout << "npeak " << npeak << endl;
756             //        clusterJ->PrintInfo();
757             Double_t *par = new Double_t[npeak*5+1];
758             par[0] = (Double_t)npeak;                
759             // Initial parameters in cell dimentions
760             Int_t k1 = 1;
761             for( i=0; i<npeak; i++ ){
762                 par[k1] = peakAmp1[i];
763                 par[k1+1] = peakX1[i]; // local time pos. [timebin]
764                 par[k1+2] = peakZ1[i]; // local anode pos. [anodepitch]
765                 if( electronics == 1 ) par[k1+3] = 2.; // PASCAL
766                 else if(electronics==2) par[k1+3] = 0.7;//tau [timebin] OLA 
767                 par[k1+4] = .4;    // sigma        [anodepich]
768                 k1 += 5;
769             } // end for i                        
770             Int_t niter;
771             Double_t chir;                        
772             NoLinearFit( xdim, zdim, par, sp, &niter, &chir );
773             Double_t peakX[kNp];
774             Double_t peakZ[kNp];
775             Double_t sigma[kNp];
776             Double_t tau[kNp];
777             Double_t peakAmp[kNp];
778             Double_t integral[kNp];
779             //get integrals => charge for each peak
780             PeakFunc( xdim, zdim, par, sp, integral );
781             k1 = 1;
782             for( i=0; i<npeak; i++ ){
783                 peakAmp[i] = par[k1];
784                 peakX[i]   = par[k1+1];
785                 peakZ[i]   = par[k1+2];
786                 tau[i]     = par[k1+3];
787                 sigma[i]   = par[k1+4];
788                 k1+=5;
789             } // end for i
790             // calculate parameter for new clusters
791             for( i=0; i<npeak; i++ ){
792                 AliITSRawClusterSDD clusterI( *clusterJ );
793             
794                 Int_t newAnode = peakZ1[i]-1 + astart;
795
796             //    Int_t newiTime = peakX1[i]-1 + tstart;
797             //    Int_t shift = (Int_t)(fTimeCorr/fTimeStep + 0.5);
798             //    if( newiTime > shift && newiTime < (fMaxNofSamples-shift) ) 
799             //        shift = 0;
800             //    Int_t peakpos = Map()->GetHitIndex(newAnode,newiTime+shift );
801             //    clusterI.SetPeakPos( peakpos );
802             
803                 clusterI.SetPeakAmpl( peakAmp1[i] );
804                 Double_t newAnodef = peakZ[i] - 0.5 + astart;
805                 Double_t newiTimef = peakX[i] - 1 + tstart;
806                 if( wing == 2 ) newAnodef -= fNofAnodes; 
807                 Double_t anodePath = (newAnodef - fNofAnodes/2)*anodePitch;
808                 newiTimef *= fTimeStep;
809                 if( newiTimef > fTimeCorr ) newiTimef -= fTimeCorr;
810                 if( electronics == 1 ){
811                 //    newiTimef *= 0.999438;    // PASCAL
812                 //    newiTimef += (6./fDriftSpeed - newiTimef/3000.);
813                 }else if( electronics == 2 )
814                     newiTimef *= 0.99714;    // OLA
815                     
816                 Int_t timeBin = (Int_t)(newiTimef/fTimeStep+0.5);    
817                 Int_t peakpos = Map()->GetHitIndex( newAnode, timeBin );
818                 if( peakpos < 0 ) { 
819                     for( Int_t ii=0; ii<3; ii++ ) {
820                         peakpos = Map()->GetHitIndex( newAnode, timeBin+ii );
821                         if( peakpos > 0 ) break;
822                         peakpos = Map()->GetHitIndex( newAnode, timeBin-ii );
823                         if( peakpos > 0 ) break;
824                     }
825                 }
826                 
827                 if( peakpos < 0 ) { 
828                     //Warning("ResolveClusters",
829                     //        "Digit not found for cluster");
830                     //if(AliDebugLevel()>=3) clusterI.PrintInfo(); 
831                    continue;
832                 }
833                 clusterI.SetPeakPos( peakpos ); 
834                 Float_t dp = cal->GetDriftPath(newiTimef,newAnodef);
835                 Float_t driftPath = fSddLength - (Double_t)dp;
836                 Float_t sign = ( wing == 1 ) ? -1. : 1.;
837                 Float_t xcoord = driftPath*sign * 0.0001;
838                 Float_t zcoord = anodePath * 0.0001;
839                 Float_t corrx=0, corrz=0;
840                 cal->GetCorrections(zcoord,xcoord,corrz,corrx,GetSeg());
841                 xcoord+=corrx;
842                 zcoord+=corrz;
843                 clusterI.SetX( xcoord );        
844                 clusterI.SetZ( zcoord );
845                 clusterI.SetAnode( newAnodef );
846                 clusterI.SetTime( newiTimef );
847                 clusterI.SetAsigma( sigma[i]*anodePitch );
848                 clusterI.SetTsigma( tau[i]*fTimeStep );
849                 clusterI.SetQ( integral[i] );
850                 
851                 fDetTypeRec->AddCluster( 1, &clusterI );
852             } // end for i
853             Clusters()->RemoveAt( j );
854             delete [] par;
855         } else {  // something odd
856             Warning( "ResolveClusters",
857                      "--- Peak not found!!!!  minpeak=%d ,cluster peak= %f"
858                      " , module= %d",
859                      fMinPeak, clusterJ->PeakAmpl(),GetModule()); 
860             clusterJ->PrintInfo();
861             Warning( "ResolveClusters"," xdim= %d zdim= %d", xdim-2, zdim-2 );
862         }
863         delete [] sp;
864     } // cluster loop
865     Clusters()->Compress();
866 //    Map()->ClearMap(); 
867 }
868 //________________________________________________________________________
869 void  AliITSClusterFinderSDD::GroupClusters(){
870     // group clusters
871     Int_t dummy=0;
872     Double_t fTimeStep = GetSeg()->Dpx(dummy);
873     // get number of clusters for this module
874     Int_t nofClusters = NClusters();
875     nofClusters -= fNclusters;
876     AliITSRawClusterSDD *clusterI;
877     AliITSRawClusterSDD *clusterJ;
878     Int_t *label = new Int_t [nofClusters];
879     Int_t i,j;
880     for(i=0; i<nofClusters; i++) label[i] = 0;
881     for(i=0; i<nofClusters; i++) { 
882         if(label[i] != 0) continue;
883         for(j=i+1; j<nofClusters; j++) { 
884             if(label[j] != 0) continue;
885             clusterI = (AliITSRawClusterSDD*) Cluster(i);
886             clusterJ = (AliITSRawClusterSDD*) Cluster(j);
887             // 1.3 good
888             if(clusterI->T() < fTimeStep*60) fDAnode = 4.2;  // TB 3.2  
889             if(clusterI->T() < fTimeStep*10) fDAnode = 1.5;  // TB 1.
890             Bool_t pair = clusterI->Brother(clusterJ,fDAnode,fDTime);
891             if(!pair) continue;
892             if(AliDebugLevel()>=4){
893                 clusterI->PrintInfo();
894                 clusterJ->PrintInfo();
895             } // end if AliDebugLevel
896             clusterI->Add(clusterJ);
897             label[j] = 1;
898             Clusters()->RemoveAt(j);
899             j=i; // <- Ernesto
900         } // J clusters  
901         label[i] = 1;
902     } // I clusters
903     Clusters()->Compress();
904
905     delete [] label;
906     return;
907 }
908 //________________________________________________________________________
909 void AliITSClusterFinderSDD::SelectClusters(){
910     // get number of clusters for this module
911     Int_t nofClusters = NClusters();
912
913     nofClusters -= fNclusters;
914     Int_t i;
915     for(i=0; i<nofClusters; i++) { 
916         AliITSRawClusterSDD *clusterI =(AliITSRawClusterSDD*) Cluster(i);
917         Int_t rmflg = 0;
918         Double_t wy = 0.;
919         if(clusterI->Anodes() != 0.) {
920             wy = ((Double_t) clusterI->Samples())/clusterI->Anodes();
921         } // end if
922         Int_t amp = (Int_t) clusterI->PeakAmpl();
923         Int_t cha = (Int_t) clusterI->Q();
924         if(amp < fMinPeak) rmflg = 1;  
925         if(cha < fMinCharge) rmflg = 1;
926         if(wy < fMinNCells) rmflg = 1;
927         //if(wy > fMaxNCells) rmflg = 1;
928         if(rmflg) Clusters()->RemoveAt(i);
929     } // I clusters
930     Clusters()->Compress();
931     return;
932 }
933
934 //______________________________________________________________________
935 void AliITSClusterFinderSDD::GetRecPoints(AliITSCalibrationSDD* cal){
936     // get rec points
937   
938     // get number of clusters for this module
939     Int_t nofClusters = NClusters();
940     nofClusters -= fNclusters;
941     const Double_t kconvGeV = 1.e-6; // GeV -> KeV
942     const Double_t kconv = 1.0e-4; 
943     const Double_t kcmToMicrons = 10000.;
944     const Double_t kRMSx = 38.0*kconv; // microns->cm ITS TDR Table 1.3
945     const Double_t kRMSz = 28.0*kconv; // microns->cm ITS TDR Table 1.3
946     Int_t nAnodes=GetSeg()->NpzHalf();
947     Int_t i;
948     Int_t ix, iz, idx=-1;
949     AliITSdigitSDD *dig=0;
950     Int_t ndigits=NDigits();
951
952     Int_t lay,lad,det;
953     fDetTypeRec->GetITSgeom()->GetModuleId(fModule,lay,lad,det);
954     Int_t ind=(lad-1)*fDetTypeRec->GetITSgeom()->GetNdetectors(lay)+(det-1);
955     Int_t lyr=(lay-1);
956
957
958     for(i=0; i<nofClusters; i++) { 
959         AliITSRawClusterSDD *clusterI = (AliITSRawClusterSDD*)Cluster(i);
960         if(!clusterI) Error("SDD: GetRecPoints","i clusterI ",i,clusterI);
961         if(clusterI) idx=clusterI->PeakPos();
962         if(idx>ndigits) Error("SDD: GetRecPoints","idx ndigits",idx,ndigits);
963         // try peak neighbours - to be done 
964         if(idx&&idx<= ndigits) dig =(AliITSdigitSDD*)GetDigit(idx);
965         if(!dig) {
966             // try cog
967             Float_t xMicrons=clusterI->X()*kcmToMicrons;
968             Float_t zMicrons=clusterI->Z()*kcmToMicrons;
969             Float_t zAnode=zMicrons/GetSeg()->Dpz(0)+nAnodes/2;
970             Float_t driftSpeed=cal->GetDriftSpeedAtAnode(zAnode);           
971             Float_t driftPath=GetSeg()->Dx()-TMath::Abs(xMicrons);
972             ix=1+(Int_t)(driftPath/driftSpeed/GetSeg()->Dpx(0));
973             iz=1+(Int_t)zAnode;
974             if(xMicrons>0) iz+=nAnodes;
975             dig = (AliITSdigitSDD*)Map()->GetHit(iz-1,ix-1);
976             // if null try neighbours
977             if (!dig) dig = (AliITSdigitSDD*)Map()->GetHit(iz-1,ix); 
978             if (!dig) dig = (AliITSdigitSDD*)Map()->GetHit(iz-1,ix+1); 
979             if (!dig) printf("SDD: cannot assign the track number!\n");
980         } //  end if !dig
981
982         Int_t lab[4] = {-3141593,-3141593,-3141593,ind};
983         if (dig) {
984           lab[0] = dig->GetTrack(0);
985           lab[1] = dig->GetTrack(1);
986           lab[2] = dig->GetTrack(2);
987         }
988         Float_t hit[5] = {clusterI->X(),clusterI->Z(),kRMSx*kRMSx,kRMSz*kRMSz,clusterI->Q()};
989         Int_t info[3] = {0,0,lyr};
990
991         AliITSRecPoint rnew(lab,hit,info,kTRUE);
992         rnew.SetdEdX(kconvGeV*clusterI->Q());
993
994         fDetTypeRec->AddRecPoint(rnew);        
995     } // I clusters
996 //    Map()->ClearMap();
997 }
998 //______________________________________________________________________
999 void AliITSClusterFinderSDD::FindRawClusters(Int_t mod){
1000     // find raw clusters
1001     
1002     SetModule(mod);
1003     SetCutAmplitude(mod);
1004     AliITSCalibrationSDD* cal = (AliITSCalibrationSDD*)GetResp(mod);
1005     Int_t nanodes=GetSeg()->Npz();
1006     Int_t noise=0;
1007     for(Int_t i=0;i<nanodes;i++){
1008       noise+=(Int_t)cal->GetNoiseAfterElectronics(i);
1009     }    
1010     SetMinPeak((noise/nanodes)*5);
1011     Find1DClustersE();
1012     GroupClusters();
1013     SelectClusters();
1014     ResolveClusters();
1015     GetRecPoints(cal);
1016 }
1017 //_______________________________________________________________________
1018 void AliITSClusterFinderSDD::PrintStatus() const{
1019     // Print SDD cluster finder Parameters
1020
1021     cout << "**************************************************" << endl;
1022     cout << " Silicon Drift Detector Cluster Finder Parameters " << endl;
1023     cout << "**************************************************" << endl;
1024     cout << "Number of Clusters: " << fNclusters << endl;
1025     cout << "Anode Tolerance: " << fDAnode << endl;
1026     cout << "Time  Tolerance: " << fDTime << endl;
1027     cout << "Time  correction (electronics): " << fTimeCorr << endl;
1028     cout << "Cut Amplitude (threshold): " << fCutAmplitude[0] << endl;
1029     cout << "Minimum Amplitude: " << fMinPeak << endl;
1030     cout << "Minimum Charge: " << fMinCharge << endl;
1031     cout << "Minimum number of cells/clusters: " << fMinNCells << endl;
1032     cout << "Maximum number of cells/clusters: " << fMaxNCells << endl;
1033     cout << "**************************************************" << endl;
1034 }
1035
1036