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 //-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (SUBATECH & Kurchatov Institute)
19 // August 2002 Yves Schutz: clone PHOS as closely as possible and intoduction
20 // of new IO (à la PHOS)
21 // Mar 2007, Aleksei Pavlinov - new algoritmh of pseudo clusters
22 //////////////////////////////////////////////////////////////////////////////
23 // Clusterization class. Performs clusterization (collects neighbouring active cells) and
24 // unfolds the clusters having several local maxima.
25 // Results are stored in TreeR#, branches EMCALTowerRP (EMC recPoints),
26 // EMCALPreShoRP (CPV RecPoints) and AliEMCALClusterizer (Clusterizer with all
27 // parameters including input digits branch title, thresholds etc.)
28 // This TTask is normally called from Reconstructioner, but can as well be used in
31 // root [0] AliEMCALClusterizerv1 * cl = new AliEMCALClusterizerv1("galice.root")
32 // Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated
33 // //reads gAlice from header file "..."
34 // root [1] cl->ExecuteTask()
35 // //finds RecPoints in all events stored in galice.root
36 // root [2] cl->SetDigitsBranch("digits2")
37 // //sets another title for Digitis (input) branch
38 // root [3] cl->SetRecPointsBranch("recp2")
39 // //sets another title four output branches
40 // root [4] cl->SetTowerLocalMaxCut(0.03)
41 // //set clusterization parameters
42 // root [5] cl->ExecuteTask("deb all time")
43 // //once more finds RecPoints options are
44 // // deb - print number of found rec points
45 // // deb all - print number of found RecPoints and some their characteristics
46 // // time - print benchmarking results
48 // --- ROOT system ---
59 #include <TBenchmark.h>
63 // --- Standard library ---
66 // --- AliRoot header files ---
67 #include "AliRunLoader.h"
70 #include "AliEMCALClusterizerv1.h"
71 #include "AliEMCALRecPoint.h"
72 #include "AliEMCALDigit.h"
73 #include "AliEMCALDigitizer.h"
75 #include "AliEMCALGeometry.h"
77 //#include "AliEMCALHistoUtilities.h"
78 #include "AliEMCALRecParam.h"
79 #include "AliEMCALReconstructor.h"
80 #include "AliCDBManager.h"
83 #include "AliCDBEntry.h"
85 ClassImp(AliEMCALClusterizerv1)
87 //____________________________________________________________________________
88 AliEMCALClusterizerv1::AliEMCALClusterizerv1()
89 : AliEMCALClusterizer(),
91 //fHists(0),fPointE(0),fPointL1(0),fPointL2(0),
92 //fPointDis(0),fPointMult(0),fDigitAmp(0),fMaxE(0),
93 //fMaxL1(0),fMaxL2(0),fMaxDis(0),
97 fNumberOfECAClusters(0),fCalibData(0),
98 fADCchannelECA(0.),fADCpedestalECA(0.),fECAClusteringThreshold(0.),fECALocMaxCut(0.),
99 fECAW0(0.),fTimeCut(0.),fMinECut(0.)
101 // ctor with the indication of the file where header Tree and digits Tree are stored
107 //____________________________________________________________________________
108 AliEMCALClusterizerv1::~AliEMCALClusterizerv1()
113 //____________________________________________________________________________
114 Float_t AliEMCALClusterizerv1::Calibrate(Int_t amp, Int_t AbsId)
117 // Convert digitized amplitude into energy.
118 // Calibration parameters are taken from calibration data base for raw data,
119 // or from digitizer parameters for simulated data.
124 AliFatal("Did not get geometry from EMCALLoader") ;
133 Bool_t bCell = fGeom->GetCellIndex(AbsId, iSupMod, nModule, nIphi, nIeta) ;
135 fGeom->PrintGeometry();
136 Error("Calibrate()"," Wrong cell id number : %i", AbsId);
140 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,nModule,nIphi, nIeta,iphi,ieta);
142 fADCchannelECA = fCalibData->GetADCchannel (iSupMod,ieta,iphi);
143 fADCpedestalECA = fCalibData->GetADCpedestal(iSupMod,ieta,iphi);
145 return -fADCpedestalECA + amp * fADCchannelECA ;
148 else //Return energy with default parameters if calibration is not available
149 return -fADCpedestalECA + amp * fADCchannelECA ;
153 //____________________________________________________________________________
154 void AliEMCALClusterizerv1::Digits2Clusters(Option_t * option)
156 // Steering method to perform clusterization for the current event
159 if(strstr(option,"tim"))
160 gBenchmark->Start("EMCALClusterizer");
162 if(strstr(option,"print"))
165 //Get calibration parameters from file or digitizer default values.
166 GetCalibrationParameters() ;
169 fNumberOfECAClusters = 0;
171 MakeClusters() ; //only the real clusters
178 //Evaluate position, dispersion and other RecPoint properties for EC section
179 for(index = 0; index < fRecPoints->GetEntries(); index++) {
180 dynamic_cast<AliEMCALRecPoint *>(fRecPoints->At(index))->EvalAll(fECAW0,fDigitsArr) ;
185 for(index = 0; index < fRecPoints->GetEntries(); index++) {
186 (dynamic_cast<AliEMCALRecPoint *>(fRecPoints->At(index)))->SetIndexInList(index) ;
187 (dynamic_cast<AliEMCALRecPoint *>(fRecPoints->At(index)))->Print();
192 if(strstr(option,"deb") || strstr(option,"all"))
193 PrintRecPoints(option) ;
195 AliDebug(1,Form("EMCAL Clusterizer found %d Rec Points",fRecPoints->GetEntriesFast()));
197 if(strstr(option,"tim")){
198 gBenchmark->Stop("EMCALClusterizer");
199 printf("Exec took %f seconds for Clusterizing",
200 gBenchmark->GetCpuTime("EMCALClusterizer"));
204 //____________________________________________________________________________
205 Bool_t AliEMCALClusterizerv1::FindFit(AliEMCALRecPoint * RecPoint, AliEMCALDigit ** maxAt,
206 Float_t* maxAtEnergy,
207 Int_t nPar, Float_t * fitparameters) const
209 // Calls TMinuit to fit the energy distribution of a cluster with several maxima
210 // The initial values for fitting procedure are set equal to the
211 // positions of local maxima.
212 // Cluster will be fitted as a superposition of nPar/3
213 // electromagnetic showers
215 if (fGeom==0) AliFatal("Did not get geometry from EMCALLoader");
217 gMinuit->mncler(); // Reset Minuit's list of paramters
218 gMinuit->SetPrintLevel(-1) ; // No Printout
219 gMinuit->SetFCN(AliEMCALClusterizerv1::UnfoldingChiSquare) ;
220 // To set the address of the minimization function
221 TList * toMinuit = new TList();
222 toMinuit->AddAt(RecPoint,0) ;
223 toMinuit->AddAt(fDigitsArr,1) ;
224 toMinuit->AddAt(fGeom,2) ;
226 gMinuit->SetObjectFit(toMinuit) ; // To tranfer pointer to UnfoldingChiSquare
228 // filling initial values for fit parameters
229 AliEMCALDigit * digit ;
233 Int_t nDigits = (Int_t) nPar / 3 ;
237 for(iDigit = 0; iDigit < nDigits; iDigit++){
238 digit = maxAt[iDigit];
243 fGeom->RelPosCellInSModule(digit->GetId(), y, x, z);
245 Float_t energy = maxAtEnergy[iDigit] ;
247 gMinuit->mnparm(index, "x", x, 0.1, 0, 0, ierflg) ;
250 Error("FindFit", "EMCAL Unfolding Unable to set initial value for fit procedure : x = %f", x ) ;
253 gMinuit->mnparm(index, "z", z, 0.1, 0, 0, ierflg) ;
256 Error("FindFit", "EMCAL Unfolding Unable to set initial value for fit procedure : z = %f", z) ;
259 gMinuit->mnparm(index, "Energy", energy , 0.05*energy, 0., 4.*energy, ierflg) ;
262 Error("FindFit", "EMCAL Unfolding Unable to set initial value for fit procedure : energy = %f", energy) ;
267 Double_t p0 = 0.1 ; // "Tolerance" Evaluation stops when EDM = 0.0001*p0 ;
268 // The number of function call slightly depends on it.
272 gMinuit->mnexcm("SET STR", &p2, 0, ierflg) ; // force TMinuit to reduce function calls
273 gMinuit->mnexcm("SET GRA", &p1, 1, ierflg) ; // force TMinuit to use my gradient
274 gMinuit->SetMaxIterations(5);
275 gMinuit->mnexcm("SET NOW", &p2 , 0, ierflg) ; // No Warnings
276 gMinuit->mnexcm("MIGRAD", &p0, 0, ierflg) ; // minimize
278 if(ierflg == 4){ // Minimum not found
279 Error("FindFit", "EMCAL Unfolding Fit not converged, cluster abandoned " ) ;
282 for(index = 0; index < nPar; index++){
285 gMinuit->GetParameter(index, val, err) ; // Returns value and error of parameter index
286 fitparameters[index] = val ;
294 //____________________________________________________________________________
295 void AliEMCALClusterizerv1::GetCalibrationParameters()
297 // Set calibration parameters:
298 // if calibration database exists, they are read from database,
299 // otherwise, they are taken from digitizer.
301 // It is a user responsilibity to open CDB before reconstruction,
303 // AliCDBStorage* storage = AliCDBManager::Instance()->GetStorage("local://CalibDB");
305 //Check if calibration is stored in data base
307 if(!fCalibData && (AliCDBManager::Instance()->IsDefaultStorageSet()))
309 AliCDBEntry *entry = (AliCDBEntry*)
310 AliCDBManager::Instance()->Get("EMCAL/Calib/Data");
311 if (entry) fCalibData = (AliEMCALCalibData*) entry->GetObject();
315 AliFatal("Calibration parameters not found in CDB!");
319 //____________________________________________________________________________
320 void AliEMCALClusterizerv1::Init()
322 // Make all memory allocations which can not be done in default constructor.
323 // Attach the Clusterizer task to the list of EMCAL tasks
325 AliRunLoader *rl = AliRunLoader::GetRunLoader();
326 if (rl->GetAliRun() && rl->GetAliRun()->GetDetector("EMCAL"))
327 fGeom = dynamic_cast<AliEMCAL*>(rl->GetAliRun()->GetDetector("EMCAL"))->GetGeometry();
329 fGeom = AliEMCALGeometry::GetInstance(AliEMCALGeometry::GetDefaultGeometryName());
331 AliDebug(1,Form("geom 0x%x",fGeom));
334 gMinuit = new TMinuit(100) ;
337 //fHists = BookHists();
340 //____________________________________________________________________________
341 void AliEMCALClusterizerv1::InitParameters()
343 // Initializes the parameters for the Clusterizer
344 fNumberOfECAClusters = 0;
345 fTimeCut = 300e-9 ; // 300 ns time cut (to be tuned)
349 const AliEMCALRecParam* recParam = AliEMCALReconstructor::GetRecParam();
351 AliFatal("Reconstruction parameters for EMCAL not set!");
354 fECAClusteringThreshold = recParam->GetClusteringThreshold();
355 fECAW0 = recParam->GetW0();
356 fMinECut = recParam->GetMinECut();
357 fToUnfold = recParam->GetUnfold();
358 fECALocMaxCut = recParam->GetLocMaxCut();
360 AliDebug(1,Form("Reconstruction parameters: fECAClusteringThreshold=%.3f, fECAW=%.3f, fMinECut=%.3f, fToUnfold=%d, fECALocMaxCut=%.3f",
361 fECAClusteringThreshold,fECAW0,fMinECut,fToUnfold,fECALocMaxCut));
366 //____________________________________________________________________________
367 Int_t AliEMCALClusterizerv1::AreNeighbours(AliEMCALDigit * d1, AliEMCALDigit * d2) const
369 // Gives the neighbourness of two digits = 0 are not neighbour ; continue searching
371 // = 2 is in different SM; continue searching
372 // neighbours are defined as digits having at least a common vertex
373 // The order of d1 and d2 is important: first (d1) should be a digit already in a cluster
374 // which is compared to a digit (d2) not yet in a cluster
377 static Int_t nSupMod1=0, nModule1=0, nIphi1=0, nIeta1=0, iphi1=0, ieta1=0;
378 static Int_t nSupMod2=0, nModule2=0, nIphi2=0, nIeta2=0, iphi2=0, ieta2=0;
379 static Int_t rowdiff, coldiff;
382 fGeom->GetCellIndex(d1->GetId(), nSupMod1,nModule1,nIphi1,nIeta1);
383 fGeom->GetCellIndex(d2->GetId(), nSupMod2,nModule2,nIphi2,nIeta2);
384 if(nSupMod1 != nSupMod2) return 2; // different SM
386 fGeom->GetCellPhiEtaIndexInSModule(nSupMod1,nModule1,nIphi1,nIeta1, iphi1,ieta1);
387 fGeom->GetCellPhiEtaIndexInSModule(nSupMod2,nModule2,nIphi2,nIeta2, iphi2,ieta2);
389 rowdiff = TMath::Abs(iphi1 - iphi2);
390 coldiff = TMath::Abs(ieta1 - ieta2) ;
392 // neighbours with at least commom side; May 11, 2007
393 if ((coldiff==0 && abs(rowdiff)==1) || (rowdiff==0 && abs(coldiff)==1)) rv = 1;
395 if (gDebug == 2 && rv==1)
396 printf("AreNeighbours: neighbours=%d, id1=%d, relid1=%d,%d \n id2=%d, relid2=%d,%d \n",
397 rv, d1->GetId(), iphi1,ieta1, d2->GetId(), iphi2,ieta2);
402 //____________________________________________________________________________
403 void AliEMCALClusterizerv1::MakeClusters()
405 // Steering method to construct the clusters stored in a list of Reconstructed Points
406 // A cluster is defined as a list of neighbour digits
407 // Mar 03, 2007 by PAI
409 if (fGeom==0) AliFatal("Did not get geometry from EMCALLoader");
413 // Set up TObjArray with pointers to digits to work on
414 TObjArray *digitsC = new TObjArray();
415 TIter nextdigit(fDigitsArr);
416 AliEMCALDigit *digit;
417 while ( (digit = dynamic_cast<AliEMCALDigit*>(nextdigit())) ) {
418 digitsC->AddLast(digit);
421 double e = 0.0, ehs = 0.0;
422 TIter nextdigitC(digitsC);
424 while ( (digit = dynamic_cast<AliEMCALDigit *>(nextdigitC())) ) { // clean up digits
425 e = Calibrate(digit->GetAmp(), digit->GetId());
427 //AliEMCALHistoUtilities::FillH1(fHists, 10, digit->GetAmp());
428 //AliEMCALHistoUtilities::FillH1(fHists, 11, e);
429 if ( e < fMinECut || digit->GetTimeR() > fTimeCut )
430 digitsC->Remove(digit);
434 AliDebug(1,Form("MakeClusters: Number of digits %d -> (e %f), ehs %d\n",
435 fDigitsArr->GetEntries(),fMinECut,ehs));
439 while ( (digit = dynamic_cast<AliEMCALDigit *>(nextdigitC())) ) { // scan over the list of digitsC
440 TArrayI clusterECAdigitslist(fDigitsArr->GetEntries());
442 if(fGeom->CheckAbsCellId(digit->GetId()) && (Calibrate(digit->GetAmp(), digit->GetId()) > fECAClusteringThreshold ) ){
443 // start a new Tower RecPoint
444 if(fNumberOfECAClusters >= fRecPoints->GetSize()) fRecPoints->Expand(2*fNumberOfECAClusters+1) ;
445 AliEMCALRecPoint *recPoint = new AliEMCALRecPoint("") ;
446 fRecPoints->AddAt(recPoint, fNumberOfECAClusters) ;
447 recPoint = dynamic_cast<AliEMCALRecPoint *>(fRecPoints->At(fNumberOfECAClusters)) ;
448 fNumberOfECAClusters++ ;
450 recPoint->SetClusterType(AliESDCaloCluster::kEMCALClusterv1);
452 recPoint->AddDigit(*digit, Calibrate(digit->GetAmp(), digit->GetId())) ;
453 TObjArray clusterDigits;
454 clusterDigits.AddLast(digit);
455 digitsC->Remove(digit) ;
457 AliDebug(1,Form("MakeClusters: OK id = %d, ene = %f , cell.th. = %f \n", digit->GetId(),
458 Calibrate(digit->GetAmp(),digit->GetId()), fECAClusteringThreshold));
460 // Grow cluster by finding neighbours
461 TIter nextClusterDigit(&clusterDigits);
462 while ( (digit = dynamic_cast<AliEMCALDigit*>(nextClusterDigit())) ) { // scan over digits in cluster
463 TIter nextdigitN(digitsC);
464 AliEMCALDigit *digitN = 0; // digi neighbor
465 while ( (digitN = (AliEMCALDigit *)nextdigitN()) ) { // scan over all digits to look for neighbours
466 if (AreNeighbours(digit, digitN)==1) { // call (digit,digitN) in THAT oder !!!!!
467 recPoint->AddDigit(*digitN, Calibrate(digitN->GetAmp(),digitN->GetId()) ) ;
468 clusterDigits.AddLast(digitN) ;
469 digitsC->Remove(digitN) ;
471 } // scan over digits
472 } // scan over digits already in cluster
474 AliDebug(2,Form("MakeClusters: %d digitd, energy %f \n", clusterDigits.GetEntries(), recPoint->GetEnergy()));
480 AliDebug(1,Form("total no of clusters %d from %d digits",fNumberOfECAClusters,fDigitsArr->GetEntriesFast()));
483 //____________________________________________________________________________
484 void AliEMCALClusterizerv1::MakeUnfolding()
486 // Unfolds clusters using the shape of an ElectroMagnetic shower
487 // Performs unfolding of all clusters
489 if(fNumberOfECAClusters > 0){
491 AliFatal("Did not get geometry from EMCALLoader") ;
492 Int_t nModulesToUnfold = fGeom->GetNCells();
494 Int_t numberofNotUnfolded = fNumberOfECAClusters ;
496 for(index = 0 ; index < numberofNotUnfolded ; index++){
498 AliEMCALRecPoint * RecPoint = dynamic_cast<AliEMCALRecPoint *>( fRecPoints->At(index) ) ;
502 RecPoint->GetGlobalPosition(gpos);
503 fGeom->GetAbsCellIdFromEtaPhi(gpos.Eta(),gpos.Phi(),absId);
504 if(absId > nModulesToUnfold)
507 Int_t nMultipl = RecPoint->GetMultiplicity() ;
508 AliEMCALDigit ** maxAt = new AliEMCALDigit*[nMultipl] ;
509 Float_t * maxAtEnergy = new Float_t[nMultipl] ;
510 Int_t nMax = RecPoint->GetNumberOfLocalMax(maxAt, maxAtEnergy,fECALocMaxCut,fDigitsArr) ;
512 if( nMax > 1 ) { // if cluster is very flat (no pronounced maximum) then nMax = 0
513 UnfoldCluster(RecPoint, nMax, maxAt, maxAtEnergy) ;
514 fRecPoints->Remove(RecPoint);
515 fRecPoints->Compress() ;
517 fNumberOfECAClusters-- ;
518 numberofNotUnfolded-- ;
521 RecPoint->SetNExMax(1) ; //Only one local maximum
525 delete[] maxAtEnergy ;
528 // End of Unfolding of clusters
531 //____________________________________________________________________________
532 Double_t AliEMCALClusterizerv1::ShowerShape(Double_t x, Double_t y)
534 // Shape of the shower
535 // If you change this function, change also the gradient evaluation in ChiSquare()
537 Double_t r = sqrt(x*x+y*y);
538 Double_t r133 = TMath::Power(r, 1.33) ;
539 Double_t r669 = TMath::Power(r, 6.69) ;
540 Double_t shape = TMath::Exp( -r133 * (1. / (1.57 + 0.0860 * r133) - 0.55 / (1 + 0.000563 * r669) ) ) ;
544 //____________________________________________________________________________
545 void AliEMCALClusterizerv1::UnfoldCluster(AliEMCALRecPoint * iniTower,
547 AliEMCALDigit ** maxAt,
548 Float_t * maxAtEnergy)
550 // Performs the unfolding of a cluster with nMax overlapping showers
551 Int_t nPar = 3 * nMax ;
552 Float_t * fitparameters = new Float_t[nPar] ;
555 AliFatal("Did not get geometry from EMCALLoader") ;
557 Bool_t rv = FindFit(iniTower, maxAt, maxAtEnergy, nPar, fitparameters) ;
559 // Fit failed, return and remove cluster
560 iniTower->SetNExMax(-1) ;
561 delete[] fitparameters ;
565 // create unfolded rec points and fill them with new energy lists
566 // First calculate energy deposited in each sell in accordance with
567 // fit (without fluctuations): efit[]
568 // and later correct this number in acordance with actual energy
571 Int_t nDigits = iniTower->GetMultiplicity() ;
572 Float_t * efit = new Float_t[nDigits] ;
573 Double_t xDigit=0.,yDigit=0.,zDigit=0. ;
574 Float_t xpar=0.,zpar=0.,epar=0. ;
576 AliEMCALDigit * digit = 0 ;
577 Int_t * Digits = iniTower->GetDigitsList() ;
581 for(iDigit = 0 ; iDigit < nDigits ; iDigit ++){
582 digit = dynamic_cast<AliEMCALDigit*>( fDigitsArr->At(Digits[iDigit] ) ) ;
583 fGeom->RelPosCellInSModule(digit->GetId(), yDigit, xDigit, zDigit);
587 while(iparam < nPar ){
588 xpar = fitparameters[iparam] ;
589 zpar = fitparameters[iparam+1] ;
590 epar = fitparameters[iparam+2] ;
592 efit[iDigit] += epar * ShowerShape(xDigit - xpar,zDigit - zpar) ;
597 // Now create new RecPoints and fill energy lists with efit corrected to fluctuations
598 // so that energy deposited in each cell is distributed between new clusters proportionally
599 // to its contribution to efit
601 Float_t * Energies = iniTower->GetEnergiesList() ;
605 while(iparam < nPar ){
606 xpar = fitparameters[iparam] ;
607 zpar = fitparameters[iparam+1] ;
608 epar = fitparameters[iparam+2] ;
611 AliEMCALRecPoint * RecPoint = 0 ;
613 if(fNumberOfECAClusters >= fRecPoints->GetSize())
614 fRecPoints->Expand(2*fNumberOfECAClusters) ;
616 (*fRecPoints)[fNumberOfECAClusters] = new AliEMCALRecPoint("") ;
617 RecPoint = dynamic_cast<AliEMCALRecPoint *>( fRecPoints->At(fNumberOfECAClusters) ) ;
618 fNumberOfECAClusters++ ;
619 RecPoint->SetNExMax((Int_t)nPar/3) ;
622 for(iDigit = 0 ; iDigit < nDigits ; iDigit ++){
623 digit = dynamic_cast<AliEMCALDigit*>( fDigitsArr->At( Digits[iDigit] ) ) ;
624 fGeom->RelPosCellInSModule(digit->GetId(), yDigit, xDigit, zDigit);
626 ratio = epar * ShowerShape(xDigit - xpar,zDigit - zpar) / efit[iDigit] ;
627 eDigit = Energies[iDigit] * ratio ;
628 RecPoint->AddDigit( *digit, eDigit ) ;
632 delete[] fitparameters ;
637 //_____________________________________________________________________________
638 void AliEMCALClusterizerv1::UnfoldingChiSquare(Int_t & nPar, Double_t * Grad,
640 Double_t * x, Int_t iflag)
642 // Calculates the Chi square for the cluster unfolding minimization
643 // Number of parameters, Gradient, Chi squared, parameters, what to do
645 TList * toMinuit = dynamic_cast<TList*>( gMinuit->GetObjectFit() ) ;
647 AliEMCALRecPoint * RecPoint = dynamic_cast<AliEMCALRecPoint*>( toMinuit->At(0) ) ;
648 TClonesArray * digits = dynamic_cast<TClonesArray*>( toMinuit->At(1) ) ;
649 // A bit buggy way to get an access to the geometry
651 AliEMCALGeometry *geom = dynamic_cast<AliEMCALGeometry *>(toMinuit->At(2));
653 Int_t * Digits = RecPoint->GetDigitsList() ;
655 Int_t nOdigits = RecPoint->GetDigitsMultiplicity() ;
657 Float_t * Energies = RecPoint->GetEnergiesList() ;
663 for(iparam = 0 ; iparam < nPar ; iparam++)
664 Grad[iparam] = 0 ; // Will evaluate gradient
668 AliEMCALDigit * digit ;
671 for( iDigit = 0 ; iDigit < nOdigits ; iDigit++) {
673 digit = dynamic_cast<AliEMCALDigit*>( digits->At( Digits[iDigit] ) );
677 Double_t yDigit=0 ;//not used yet, assumed to be 0
679 geom->RelPosCellInSModule(digit->GetId(), yDigit, xDigit, zDigit);
681 if(iflag == 2){ // calculate gradient
684 while(iParam < nPar ){
685 Double_t dx = (xDigit - x[iParam]) ;
687 Double_t dz = (zDigit - x[iParam]) ;
689 efit += x[iParam] * ShowerShape(dx,dz) ;
692 Double_t sum = 2. * (efit - Energies[iDigit]) / Energies[iDigit] ; // Here we assume, that sigma = sqrt(E)
694 while(iParam < nPar ){
695 Double_t xpar = x[iParam] ;
696 Double_t zpar = x[iParam+1] ;
697 Double_t epar = x[iParam+2] ;
698 Double_t dr = TMath::Sqrt( (xDigit - xpar) * (xDigit - xpar) + (zDigit - zpar) * (zDigit - zpar) );
699 Double_t shape = sum * ShowerShape(xDigit - xpar,zDigit - zpar) ;
700 Double_t r133 = TMath::Power(dr, 1.33);
701 Double_t r669 = TMath::Power(dr,6.69);
702 Double_t deriv =-1.33 * TMath::Power(dr,0.33)*dr * ( 1.57 / ( (1.57 + 0.0860 * r133) * (1.57 + 0.0860 * r133) )
703 - 0.55 / (1 + 0.000563 * r669) / ( (1 + 0.000563 * r669) * (1 + 0.000563 * r669) ) ) ;
705 Grad[iParam] += epar * shape * deriv * (xpar - xDigit) ; // Derivative over x
707 Grad[iParam] += epar * shape * deriv * (zpar - zDigit) ; // Derivative over z
709 Grad[iParam] += shape ; // Derivative over energy
717 while(iparam < nPar ){
718 Double_t xpar = x[iparam] ;
719 Double_t zpar = x[iparam+1] ;
720 Double_t epar = x[iparam+2] ;
722 efit += epar * ShowerShape(xDigit - xpar,zDigit - zpar) ;
725 fret += (efit-Energies[iDigit])*(efit-Energies[iDigit])/Energies[iDigit] ;
726 // Here we assume, that sigma = sqrt(E)
729 //____________________________________________________________________________
730 void AliEMCALClusterizerv1::Print(Option_t * /*option*/)const
732 // Print clusterizer parameters
734 TString message("\n") ;
736 if( strcmp(GetName(), "") !=0 ){
740 TString taskName(Version()) ;
742 printf("--------------- ");
743 printf(taskName.Data()) ;
745 printf("Clusterizing digits: ");
746 printf("\n ECA Local Maximum cut = %f", fECALocMaxCut);
747 printf("\n ECA Logarithmic weight = %f", fECAW0);
749 printf("\nUnfolding on\n");
751 printf("\nUnfolding off\n");
753 printf("------------------------------------------------------------------");
756 printf("AliEMCALClusterizerv1 not initialized ") ;
759 //____________________________________________________________________________
760 void AliEMCALClusterizerv1::PrintRecPoints(Option_t * option)
762 // Prints list of RecPoints produced at the current pass of AliEMCALClusterizer
763 if(strstr(option,"deb")) {
764 printf("PrintRecPoints: Clusterization result:") ;
766 printf(" Found %d ECA Rec Points\n ",
767 fRecPoints->GetEntriesFast()) ;
770 if(strstr(option,"all")) {
771 if(strstr(option,"deb")) {
772 printf("\n-----------------------------------------------------------------------\n") ;
773 printf("Clusters in ECAL section\n") ;
774 printf("Index Ene(GeV) Multi Module GX GY GZ lX lY lZ Dispersion Lambda 1 Lambda 2 # of prim Primaries list\n") ;
783 //AliEMCALHistoUtilities::FillH1(fHists, 12, double(fRecPoints->GetEntries()));
785 for (index = 0 ; index < fRecPoints->GetEntries() ; index++) {
786 AliEMCALRecPoint * rp = dynamic_cast<AliEMCALRecPoint * >(fRecPoints->At(index)) ;
788 //rp->GetGlobalPosition(globalpos);
790 rp->GetLocalPosition(localpos);
792 rp->GetElipsAxis(lambda);
795 primaries = rp->GetPrimaries(nprimaries);
796 if(strstr(option,"deb"))
797 printf("\n%6d %8.4f %3d %4.1f %4.1f %4.1f %4.1f %4.1f %4.1f %4.1f %4f %4f %2d : ",
798 rp->GetIndexInList(), rp->GetEnergy(), rp->GetMultiplicity(),
799 globalpos.X(), globalpos.Y(), globalpos.Z(), localpos.X(), localpos.Y(), localpos.Z(),
800 rp->GetDispersion(), lambda[0], lambda[1], nprimaries) ;
802 if(rp->GetEnergy()>maxE){
803 maxE=rp->GetEnergy();
806 maxDis=rp->GetDispersion();
809 //fPointE->Fill(rp->GetEnergy());
810 //fPointL1->Fill(lambda[0]);
811 //fPointL2->Fill(lambda[1]);
812 //fPointDis->Fill(rp->GetDispersion());
813 //fPointMult->Fill(rp->GetMultiplicity());
815 if(strstr(option,"deb")){
816 for (Int_t iprimary=0; iprimary<nprimaries; iprimary++) {
817 printf("%d ", primaries[iprimary] ) ;
823 // fMaxE->Fill(maxE);
824 // fMaxL1->Fill(maxL1);
825 // fMaxL2->Fill(maxL2);
826 // fMaxDis->Fill(maxDis);
828 if(strstr(option,"deb"))
829 printf("\n-----------------------------------------------------------------------\n");
834 TList* AliEMCALClusterizerv1::BookHists()
836 //set up histograms for monitoring clusterizer performance
840 fPointE = new TH1F("00_pointE","point energy", 2000, 0.0, 150.);
841 fPointL1 = new TH1F("01_pointL1","point L1", 1000, 0.0, 3.);
842 fPointL2 = new TH1F("02_pointL2","point L2", 1000, 0.0, 3.);
843 fPointDis = new TH1F("03_pointDisp","point dispersion", 1000, 0.0, 10.);
844 fPointMult = new TH1F("04_pointMult","#cell in point(cluster)", 101, -0.5, 100.5);
845 fDigitAmp = new TH1F("05_digitAmp","Digit Amplitude", 2000, 0.0, 5000.);
846 fMaxE = new TH1F("06_maxE","Max point energy", 2000, 0.0, 150.);
847 fMaxL1 = new TH1F("07_maxL1","Largest (first) of eigenvalue of covariance matrix", 1000, 0.0, 3.);
848 fMaxL2 = new TH1F("08_maxL2","Smalest (second) of eigenvalue of covariace matrix", 1000, 0.0, 3.);
849 fMaxDis = new TH1F("09_maxDis","Point dispersion", 1000, 0.0, 10.); // 9
851 new TH1F("10_adcOfDigits","adc of digits(threshold control)", 1001, -0.5, 1000.5); // 10
852 new TH1F("11_energyOfDigits","energy of digits(threshold control)", 1000, 0.0, 1.); // 11
853 new TH1F("12_numberOfPoints","number of points(clusters)", 101, -0.5, 100.5); // 12
855 return AliEMCALHistoUtilities::MoveHistsToList("EmcalClusterizerv1ControlHists", kFALSE);
858 void AliEMCALClusterizerv1::SaveHists(const char *fn)
860 AliEMCALHistoUtilities::SaveListOfHists(fHists, fn, kTRUE);
864 //___________________________________________________________________
865 void AliEMCALClusterizerv1::PrintRecoInfo()
867 printf(" AliEMCALClusterizerv1::PrintRecoInfo() : version %s \n", Version() );
869 //TH1F *h = (TH1F*)fHists->At(12);
871 // printf(" ## Multiplicity of RecPoints ## \n");
872 // for(int i=1; i<=h->GetNbinsX(); i++) {
873 // int nbin = int((*h)[i]);
874 // int mult = int(h->GetBinCenter(i));
875 // if(nbin > 0) printf(" %i : %5.5i %6.3f %% \n", mult, nbin, 100.*nbin/h->GetEntries());
882 //___________________________________________________________________
883 void AliEMCALClusterizerv1::DrawLambdasHists()
887 if(fMaxL2) fMaxL2->Draw("same");
889 fMaxDis->Draw("same");