- Reset TProcessID count after each event
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALClusterizerv1.cxx
CommitLineData
483b0559 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 **************************************************************************/
173558f2 15
483b0559 16/* $Id$ */
803d1ab0 17
3a8be91c 18//-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (SUBATECH & Kurchatov Institute)
05a92d59 19// August 2002 Yves Schutz: clone PHOS as closely as possible and intoduction
20// of new IO (à la PHOS)
f1487f22 21// Mar 2007, Aleksei Pavlinov - new algoritmh of pseudo clusters
483b0559 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
29// standalone mode.
30// Use Case:
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
47
48// --- ROOT system ---
7dd95fbf 49#include <cassert>
483b0559 50
1d59832c 51class TROOT;
e52475ed 52#include <TH1.h>
53#include <TFile.h>
1d59832c 54class TFolder;
e52475ed 55#include <TMath.h>
56#include <TMinuit.h>
57#include <TTree.h>
1d59832c 58class TSystem;
e52475ed 59#include <TBenchmark.h>
60#include <TBrowser.h>
a1e17193 61#include <TROOT.h>
1d59832c 62
483b0559 63// --- Standard library ---
64
173558f2 65
483b0559 66// --- AliRoot header files ---
5dee926e 67#include "AliRunLoader.h"
68#include "AliRun.h"
1d59832c 69#include "AliESD.h"
483b0559 70#include "AliEMCALClusterizerv1.h"
70a93198 71#include "AliEMCALRecPoint.h"
483b0559 72#include "AliEMCALDigit.h"
73#include "AliEMCALDigitizer.h"
483b0559 74#include "AliEMCAL.h"
05a92d59 75#include "AliEMCALGeometry.h"
e52475ed 76#include "AliEMCALHistoUtilities.h"
c47157cd 77#include "AliEMCALRecParam.h"
78#include "AliEMCALReconstructor.h"
1bd98442 79#include "AliCDBManager.h"
1d59832c 80
81class AliCDBStorage;
1bd98442 82#include "AliCDBEntry.h"
483b0559 83
84ClassImp(AliEMCALClusterizerv1)
1963b290 85
483b0559 86//____________________________________________________________________________
c47157cd 87AliEMCALClusterizerv1::AliEMCALClusterizerv1()
18a21c7c 88 : AliEMCALClusterizer(),
89 fHists(0),fPointE(0),fPointL1(0),fPointL2(0),
90 fPointDis(0),fPointMult(0),fDigitAmp(0),fMaxE(0),
91 fMaxL1(0),fMaxL2(0),fMaxDis(0),fGeom(0),
18a21c7c 92 fDefaultInit(kFALSE),
93 fToUnfold(kFALSE),
0e7c6655 94 fNumberOfECAClusters(0),fCalibData(0),
18a21c7c 95 fADCchannelECA(0.),fADCpedestalECA(0.),fECAClusteringThreshold(0.),fECALocMaxCut(0.),
c47157cd 96 fECAW0(0.),fTimeCut(0.),fMinECut(0.)
483b0559 97{
98 // ctor with the indication of the file where header Tree and digits Tree are stored
99
839828a6 100 InitParameters() ;
483b0559 101 Init() ;
483b0559 102}
05a92d59 103
483b0559 104//____________________________________________________________________________
105 AliEMCALClusterizerv1::~AliEMCALClusterizerv1()
106{
ef305168 107 // dtor
ef305168 108}
109
110//____________________________________________________________________________
1bd98442 111Float_t AliEMCALClusterizerv1::Calibrate(Int_t amp, Int_t AbsId)
9859bfc0 112{
1bd98442 113
114 // Convert digitized amplitude into energy.
115 // Calibration parameters are taken from calibration data base for raw data,
116 // or from digitizer parameters for simulated data.
117
118 if(fCalibData){
1bd98442 119
a5c60732 120 if (fGeom==0)
1bd98442 121 AliFatal("Did not get geometry from EMCALLoader") ;
122
123 Int_t iSupMod = -1;
2bb3725c 124 Int_t nModule = -1;
1bd98442 125 Int_t nIphi = -1;
126 Int_t nIeta = -1;
127 Int_t iphi = -1;
128 Int_t ieta = -1;
129
2bb3725c 130 Bool_t bCell = fGeom->GetCellIndex(AbsId, iSupMod, nModule, nIphi, nIeta) ;
1d46d1f6 131 if(!bCell) {
132 fGeom->PrintGeometry();
133 Error("Calibrate()"," Wrong cell id number : %i", AbsId);
134 assert(0);
135 }
54b24bce 136
2bb3725c 137 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,nModule,nIphi, nIeta,iphi,ieta);
1bd98442 138
139 fADCchannelECA = fCalibData->GetADCchannel (iSupMod,ieta,iphi);
140 fADCpedestalECA = fCalibData->GetADCpedestal(iSupMod,ieta,iphi);
54b24bce 141
142 return -fADCpedestalECA + amp * fADCchannelECA ;
1bd98442 143
144 }
145 else //Return energy with default parameters if calibration is not available
146 return -fADCpedestalECA + amp * fADCchannelECA ;
147
483b0559 148}
05a92d59 149
483b0559 150//____________________________________________________________________________
c47157cd 151void AliEMCALClusterizerv1::Digits2Clusters(Option_t * option)
483b0559 152{
98e9578e 153 // Steering method to perform clusterization for the current event
154 // in AliEMCALLoader
483b0559 155
483b0559 156 if(strstr(option,"tim"))
157 gBenchmark->Start("EMCALClusterizer");
158
159 if(strstr(option,"print"))
160 Print("") ;
98e9578e 161
1bd98442 162 //Get calibration parameters from file or digitizer default values.
163 GetCalibrationParameters() ;
164
483b0559 165
98e9578e 166 fNumberOfECAClusters = 0;
483b0559 167
0e7c6655 168 MakeClusters() ; //only the real clusters
a5c60732 169
98e9578e 170 if(fToUnfold)
171 MakeUnfolding() ;
ed611565 172
bbac7e6f 173 Int_t index ;
174
175 //Evaluate position, dispersion and other RecPoint properties for EC section
176 for(index = 0; index < fRecPoints->GetEntries(); index++) {
bbac7e6f 177 dynamic_cast<AliEMCALRecPoint *>(fRecPoints->At(index))->EvalAll(fECAW0,fDigitsArr) ;
178 }
179
180 fRecPoints->Sort() ;
181
182 for(index = 0; index < fRecPoints->GetEntries(); index++) {
183 (dynamic_cast<AliEMCALRecPoint *>(fRecPoints->At(index)))->SetIndexInList(index) ;
184 (dynamic_cast<AliEMCALRecPoint *>(fRecPoints->At(index)))->Print();
185 }
186
c47157cd 187 fTreeR->Fill();
188
98e9578e 189 if(strstr(option,"deb") || strstr(option,"all"))
190 PrintRecPoints(option) ;
483b0559 191
c47157cd 192 AliDebug(1,Form("EMCAL Clusterizer found %d Rec Points",fRecPoints->GetEntriesFast()));
88cb7938 193
483b0559 194 if(strstr(option,"tim")){
195 gBenchmark->Stop("EMCALClusterizer");
98e9578e 196 printf("Exec took %f seconds for Clusterizing",
197 gBenchmark->GetCpuTime("EMCALClusterizer"));
198 }
483b0559 199}
200
201//____________________________________________________________________________
70a93198 202Bool_t AliEMCALClusterizerv1::FindFit(AliEMCALRecPoint * emcRP, AliEMCALDigit ** maxAt, Float_t * maxAtEnergy,
483b0559 203 Int_t nPar, Float_t * fitparameters) const
204{
205 // Calls TMinuit to fit the energy distribution of a cluster with several maxima
206 // The initial values for fitting procedure are set equal to the positions of local maxima.
207 // Cluster will be fitted as a superposition of nPar/3 electromagnetic showers
208
483b0559 209 gMinuit->mncler(); // Reset Minuit's list of paramters
210 gMinuit->SetPrintLevel(-1) ; // No Printout
211 gMinuit->SetFCN(AliEMCALClusterizerv1::UnfoldingChiSquare) ;
212 // To set the address of the minimization function
483b0559 213 TList * toMinuit = new TList();
214 toMinuit->AddAt(emcRP,0) ;
c47157cd 215 toMinuit->AddAt(fDigitsArr,1) ;
483b0559 216
217 gMinuit->SetObjectFit(toMinuit) ; // To tranfer pointer to UnfoldingChiSquare
218
219 // filling initial values for fit parameters
220 AliEMCALDigit * digit ;
221
222 Int_t ierflg = 0;
223 Int_t index = 0 ;
224 Int_t nDigits = (Int_t) nPar / 3 ;
225
226 Int_t iDigit ;
227
483b0559 228 for(iDigit = 0; iDigit < nDigits; iDigit++){
a0636361 229 digit = maxAt[iDigit];
483b0559 230
483b0559 231 Float_t x = 0.;
232 Float_t z = 0.;
dc7da436 233 // have to be tune for TRD1; May 31,06
234 // Int_t relid[2] ;
235 // fGeom->AbsToRelNumbering(digit->GetId(), relid) ; // obsolete method
236 // fGeom->PosInAlice(relid, x, z) ; // obsolete method
483b0559 237
238 Float_t energy = maxAtEnergy[iDigit] ;
239
240 gMinuit->mnparm(index, "x", x, 0.1, 0, 0, ierflg) ;
241 index++ ;
242 if(ierflg != 0){
9859bfc0 243 Error("FindFit", "EMCAL Unfolding Unable to set initial value for fit procedure : x = %f", x ) ;
483b0559 244 return kFALSE;
245 }
246 gMinuit->mnparm(index, "z", z, 0.1, 0, 0, ierflg) ;
247 index++ ;
248 if(ierflg != 0){
9859bfc0 249 Error("FindFit", "EMCAL Unfolding Unable to set initial value for fit procedure : z = %f", z) ;
483b0559 250 return kFALSE;
251 }
252 gMinuit->mnparm(index, "Energy", energy , 0.05*energy, 0., 4.*energy, ierflg) ;
253 index++ ;
254 if(ierflg != 0){
9859bfc0 255 Error("FindFit", "EMCAL Unfolding Unable to set initial value for fit procedure : energy = %f", energy) ;
483b0559 256 return kFALSE;
257 }
258 }
259
260 Double_t p0 = 0.1 ; // "Tolerance" Evaluation stops when EDM = 0.0001*p0 ; The number of function call slightly
261 // depends on it.
262 Double_t p1 = 1.0 ;
263 Double_t p2 = 0.0 ;
264
265 gMinuit->mnexcm("SET STR", &p2, 0, ierflg) ; // force TMinuit to reduce function calls
266 gMinuit->mnexcm("SET GRA", &p1, 1, ierflg) ; // force TMinuit to use my gradient
267 gMinuit->SetMaxIterations(5);
268 gMinuit->mnexcm("SET NOW", &p2 , 0, ierflg) ; // No Warnings
269
270 gMinuit->mnexcm("MIGRAD", &p0, 0, ierflg) ; // minimize
271
272 if(ierflg == 4){ // Minimum not found
9859bfc0 273 Error("FindFit", "EMCAL Unfolding Fit not converged, cluster abandoned " ) ;
483b0559 274 return kFALSE ;
275 }
276 for(index = 0; index < nPar; index++){
277 Double_t err ;
278 Double_t val ;
279 gMinuit->GetParameter(index, val, err) ; // Returns value and error of parameter index
280 fitparameters[index] = val ;
281 }
282
283 delete toMinuit ;
284 return kTRUE;
285
286}
287
288//____________________________________________________________________________
289void AliEMCALClusterizerv1::GetCalibrationParameters()
290{
1bd98442 291 // Set calibration parameters:
292 // if calibration database exists, they are read from database,
293 // otherwise, they are taken from digitizer.
294 //
295 // It is a user responsilibity to open CDB before reconstruction,
296 // for example:
297 // AliCDBStorage* storage = AliCDBManager::Instance()->GetStorage("local://CalibDB");
298
299 //Check if calibration is stored in data base
54b24bce 300
c47157cd 301 if(!fCalibData && (AliCDBManager::Instance()->IsDefaultStorageSet()))
302 {
303 AliCDBEntry *entry = (AliCDBEntry*)
304 AliCDBManager::Instance()->Get("EMCAL/Calib/Data");
305 if (entry) fCalibData = (AliEMCALCalibData*) entry->GetObject();
306 }
307
308 if(!fCalibData)
309 AliFatal("Calibration parameters not found in CDB!");
310
311 // Please fix it!! Or better just remove it...
312// if(!fCalibData)
313// {
314// //If calibration is not available use default parameters
315// //Loader
316// if ( !emcalLoader->Digitizer() )
317// emcalLoader->LoadDigitizer();
318// AliEMCALDigitizer * dig = dynamic_cast<AliEMCALDigitizer*>(emcalLoader->Digitizer());
1bd98442 319
c47157cd 320// fADCchannelECA = dig->GetECAchannel() ;
321// fADCpedestalECA = dig->GetECApedestal();
322// }
483b0559 323}
05a92d59 324
483b0559 325//____________________________________________________________________________
326void AliEMCALClusterizerv1::Init()
327{
328 // Make all memory allocations which can not be done in default constructor.
329 // Attach the Clusterizer task to the list of EMCAL tasks
330
5dee926e 331 AliRunLoader *rl = AliRunLoader::GetRunLoader();
98e9578e 332 if (rl->GetAliRun() && rl->GetAliRun()->GetDetector("EMCAL"))
333 fGeom = dynamic_cast<AliEMCAL*>(rl->GetAliRun()->GetDetector("EMCAL"))->GetGeometry();
334 else
335 fGeom = AliEMCALGeometry::GetInstance(AliEMCALGeometry::GetDefaulGeometryName());
336
6d0b6861 337 AliDebug(1,Form("geom 0x%x",fGeom));
05a92d59 338
483b0559 339 if(!gMinuit)
340 gMinuit = new TMinuit(100) ;
a5c60732 341
342 fHists = BookHists();
483b0559 343}
344
345//____________________________________________________________________________
839828a6 346void AliEMCALClusterizerv1::InitParameters()
fdebddeb 347{
348 // Initializes the parameters for the Clusterizer
349 fNumberOfECAClusters = 0;
1963b290 350
e52475ed 351 fECALocMaxCut = 0.03; // ??
1963b290 352
98e9578e 353 fTimeCut = 300e-9 ; // 300 ns time cut (to be tuned)
839828a6 354 fToUnfold = kFALSE ;
1bd98442 355
356 fCalibData = 0 ;
3a8be91c 357
c47157cd 358 const AliEMCALRecParam* recParam = AliEMCALReconstructor::GetRecParam();
359 if(!recParam) {
360 AliFatal("Reconstruction parameters for EMCAL not set!");
361 }
362 else {
363 fECAClusteringThreshold = recParam->GetClusteringThreshold();
364 fECAW0 = recParam->GetW0();
365 fMinECut = recParam->GetMinECut();
366 AliDebug(1,Form("Reconstruction parameters: fECAClusteringThreshold=%.3f, fECAW=%.3f, fMinECut=%.3f",
3a8be91c 367 fECAClusteringThreshold,fECAW0,fMinECut));
368 }
369
839828a6 370}
371
372//____________________________________________________________________________
e52475ed 373Int_t AliEMCALClusterizerv1::AreNeighbours(AliEMCALDigit * d1, AliEMCALDigit * d2) const
483b0559 374{
1d46d1f6 375 // Gives the neighbourness of two digits = 0 are not neighbour ; continue searching
483b0559 376 // = 1 are neighbour
1d46d1f6 377 // = 2 is in different SM; continue searching
483b0559 378 // neighbours are defined as digits having at least a common vertex
379 // The order of d1 and d2 is important: first (d1) should be a digit already in a cluster
380 // which is compared to a digit (d2) not yet in a cluster
381
e52475ed 382 static Int_t rv;
2bb3725c 383 static Int_t nSupMod1=0, nModule1=0, nIphi1=0, nIeta1=0, iphi1=0, ieta1=0;
384 static Int_t nSupMod2=0, nModule2=0, nIphi2=0, nIeta2=0, iphi2=0, ieta2=0;
e52475ed 385 static Int_t rowdiff, coldiff;
386 rv = 0 ;
483b0559 387
2bb3725c 388 fGeom->GetCellIndex(d1->GetId(), nSupMod1,nModule1,nIphi1,nIeta1);
389 fGeom->GetCellIndex(d2->GetId(), nSupMod2,nModule2,nIphi2,nIeta2);
e52475ed 390 if(nSupMod1 != nSupMod2) return 2; // different SM
391
2bb3725c 392 fGeom->GetCellPhiEtaIndexInSModule(nSupMod1,nModule1,nIphi1,nIeta1, iphi1,ieta1);
393 fGeom->GetCellPhiEtaIndexInSModule(nSupMod2,nModule2,nIphi2,nIeta2, iphi2,ieta2);
e52475ed 394
395 rowdiff = TMath::Abs(iphi1 - iphi2);
396 coldiff = TMath::Abs(ieta1 - ieta2) ;
70a93198 397
3d99d6d5 398 // neighbours with at least commom side; May 11, 2007
399 if ((coldiff==0 && abs(rowdiff)==1) || (rowdiff==0 && abs(coldiff)==1)) rv = 1;
70a93198 400
e52475ed 401 if (gDebug == 2 && rv==1)
402 printf("AreNeighbours: neighbours=%d, id1=%d, relid1=%d,%d \n id2=%d, relid2=%d,%d \n",
403 rv, d1->GetId(), iphi1,ieta1, d2->GetId(), iphi2,ieta2);
ed611565 404
483b0559 405 return rv ;
406}
407
88cb7938 408//____________________________________________________________________________
0e7c6655 409void AliEMCALClusterizerv1::MakeClusters()
483b0559 410{
411 // Steering method to construct the clusters stored in a list of Reconstructed Points
412 // A cluster is defined as a list of neighbour digits
f1487f22 413 // Mar 03, 2007 by PAI
ed611565 414
f1487f22 415 if (fGeom==0) AliFatal("Did not get geometry from EMCALLoader");
ed611565 416
c47157cd 417 fRecPoints->Clear();
98e9578e 418
419 // Set up TObjArray with pointers to digits to work on
420 TObjArray *digitsC = new TObjArray();
c47157cd 421 TIter nextdigit(fDigitsArr);
98e9578e 422 AliEMCALDigit *digit;
423 while ( (digit = dynamic_cast<AliEMCALDigit*>(nextdigit())) ) {
424 digitsC->AddLast(digit);
425 }
a5c60732 426
1d46d1f6 427 double e = 0.0, ehs = 0.0;
98e9578e 428 TIter nextdigitC(digitsC);
429
1d46d1f6 430 while ( (digit = dynamic_cast<AliEMCALDigit *>(nextdigitC())) ) { // clean up digits
1bd98442 431 e = Calibrate(digit->GetAmp(), digit->GetId());
e52475ed 432 AliEMCALHistoUtilities::FillH1(fHists, 10, digit->GetAmp());
433 AliEMCALHistoUtilities::FillH1(fHists, 11, e);
98e9578e 434 if ( e < fMinECut || digit->GetTimeR() > fTimeCut )
435 digitsC->Remove(digit);
436 else
437 ehs += e;
1d59832c 438 }
439 AliDebug(1,Form("MakeClusters: Number of digits %d -> (e %f), ehs %d\n",
c47157cd 440 fDigitsArr->GetEntries(),fMinECut,ehs));
98e9578e 441
1d46d1f6 442 nextdigitC.Reset();
98e9578e 443
1d46d1f6 444 while ( (digit = dynamic_cast<AliEMCALDigit *>(nextdigitC())) ) { // scan over the list of digitsC
c47157cd 445 TArrayI clusterECAdigitslist(fDigitsArr->GetEntries());
e52475ed 446
a5c60732 447 if(fGeom->CheckAbsCellId(digit->GetId()) && (Calibrate(digit->GetAmp(), digit->GetId()) > fECAClusteringThreshold ) ){
98e9578e 448 // start a new Tower RecPoint
c47157cd 449 if(fNumberOfECAClusters >= fRecPoints->GetSize()) fRecPoints->Expand(2*fNumberOfECAClusters+1) ;
98e9578e 450 AliEMCALRecPoint *recPoint = new AliEMCALRecPoint("") ;
c47157cd 451 fRecPoints->AddAt(recPoint, fNumberOfECAClusters) ;
452 recPoint = dynamic_cast<AliEMCALRecPoint *>(fRecPoints->At(fNumberOfECAClusters)) ;
4aa81449 453 fNumberOfECAClusters++ ;
a5c60732 454
8ada0ffe 455 recPoint->SetClusterType(AliESDCaloCluster::kEMCALClusterv1);
a5c60732 456
1bd98442 457 recPoint->AddDigit(*digit, Calibrate(digit->GetAmp(), digit->GetId())) ;
98e9578e 458 TObjArray clusterDigits;
459 clusterDigits.AddLast(digit);
4aa81449 460 digitsC->Remove(digit) ;
f1487f22 461
462 AliDebug(1,Form("MakeClusters: OK id = %d, ene = %f , cell.th. = %f \n", digit->GetId(),
463 Calibrate(digit->GetAmp(),digit->GetId()), fECAClusteringThreshold));
483b0559 464
98e9578e 465 // Grow cluster by finding neighbours
466 TIter nextClusterDigit(&clusterDigits);
467 while ( (digit = dynamic_cast<AliEMCALDigit*>(nextClusterDigit())) ) { // scan over digits in cluster
468 TIter nextdigitN(digitsC);
469 AliEMCALDigit *digitN = 0; // digi neighbor
470 while ( (digitN = (AliEMCALDigit *)nextdigitN()) ) { // scan over all digits to look for neighbours
471 if (AreNeighbours(digit, digitN)==1) { // call (digit,digitN) in THAT oder !!!!!
1d46d1f6 472 recPoint->AddDigit(*digitN, Calibrate(digitN->GetAmp(),digitN->GetId()) ) ;
98e9578e 473 clusterDigits.AddLast(digitN) ;
1d46d1f6 474 digitsC->Remove(digitN) ;
1d46d1f6 475 } // if(ineb==1)
98e9578e 476 } // scan over digits
e52475ed 477 } // scan over digits already in cluster
98e9578e 478 if(recPoint)
479 AliDebug(2,Form("MakeClusters: %d digitd, energy %f \n", clusterDigits.GetEntries(), recPoint->GetEnergy()));
480 } // If seed found
1d59832c 481 } // while digit
98e9578e 482
483b0559 483 delete digitsC ;
a5c60732 484
c47157cd 485 AliDebug(1,Form("total no of clusters %d from %d digits",fNumberOfECAClusters,fDigitsArr->GetEntriesFast()));
483b0559 486}
487
fdebddeb 488void AliEMCALClusterizerv1::MakeUnfolding() const
483b0559 489{
490 Fatal("AliEMCALClusterizerv1::MakeUnfolding", "--> Unfolding not implemented") ;
483b0559 491}
492
493//____________________________________________________________________________
494Double_t AliEMCALClusterizerv1::ShowerShape(Double_t r)
495{
496 // Shape of the shower (see EMCAL TDR)
497 // If you change this function, change also the gradient evaluation in ChiSquare()
498
499 Double_t r4 = r*r*r*r ;
500 Double_t r295 = TMath::Power(r, 2.95) ;
501 Double_t shape = TMath::Exp( -r4 * (1. / (2.32 + 0.26 * r4) + 0.0316 / (1 + 0.0652 * r295) ) ) ;
502 return shape ;
503}
504
505//____________________________________________________________________________
70a93198 506void AliEMCALClusterizerv1::UnfoldCluster(AliEMCALRecPoint * /*iniTower*/,
9e5d2067 507 Int_t /*nMax*/,
508 AliEMCALDigit ** /*maxAt*/,
fdebddeb 509 Float_t * /*maxAtEnergy*/) const
483b0559 510{
511 // Performs the unfolding of a cluster with nMax overlapping showers
483b0559 512
9859bfc0 513 Fatal("UnfoldCluster", "--> Unfolding not implemented") ;
173558f2 514
483b0559 515}
516
517//_____________________________________________________________________________
9e5d2067 518void AliEMCALClusterizerv1::UnfoldingChiSquare(Int_t & /*nPar*/, Double_t * /*Grad*/,
519 Double_t & /*fret*/,
520 Double_t * /*x*/, Int_t /*iflag*/)
483b0559 521{
522 // Calculates the Chi square for the cluster unfolding minimization
523 // Number of parameters, Gradient, Chi squared, parameters, what to do
483b0559 524
9859bfc0 525 ::Fatal("UnfoldingChiSquare","Unfolding not implemented") ;
483b0559 526}
483b0559 527//____________________________________________________________________________
9e5d2067 528void AliEMCALClusterizerv1::Print(Option_t * /*option*/)const
483b0559 529{
530 // Print clusterizer parameters
531
9859bfc0 532 TString message("\n") ;
533
483b0559 534 if( strcmp(GetName(), "") !=0 ){
535
536 // Print parameters
537
c47157cd 538 TString taskName(Version()) ;
9859bfc0 539
fdebddeb 540 printf("--------------- ");
541 printf(taskName.Data()) ;
542 printf(" ");
c47157cd 543 printf("Clusterizing digits: ");
fdebddeb 544 printf("\n ECA Local Maximum cut = %f", fECALocMaxCut);
b481a360 545 printf("\n ECA Logarithmic weight = %f", fECAW0);
483b0559 546 if(fToUnfold)
fdebddeb 547 printf("\nUnfolding on\n");
483b0559 548 else
fdebddeb 549 printf("\nUnfolding off\n");
483b0559 550
fdebddeb 551 printf("------------------------------------------------------------------");
483b0559 552 }
553 else
fdebddeb 554 printf("AliEMCALClusterizerv1 not initialized ") ;
483b0559 555}
173558f2 556
483b0559 557//____________________________________________________________________________
558void AliEMCALClusterizerv1::PrintRecPoints(Option_t * option)
559{
b481a360 560 // Prints list of RecPoints produced at the current pass of AliEMCALClusterizer
1d46d1f6 561 if(strstr(option,"deb")) {
562 printf("PrintRecPoints: Clusterization result:") ;
ed611565 563
1d46d1f6 564 printf(" Found %d ECA Rec Points\n ",
c47157cd 565 fRecPoints->GetEntriesFast()) ;
1d46d1f6 566 }
483b0559 567
568 if(strstr(option,"all")) {
1d46d1f6 569 if(strstr(option,"deb")) {
570 printf("\n-----------------------------------------------------------------------\n") ;
571 printf("Clusters in ECAL section\n") ;
572 printf("Index Ene(GeV) Multi Module GX GY GZ lX lY lZ Dispersion Lambda 1 Lambda 2 # of prim Primaries list\n") ;
573 }
574 Int_t index =0;
1963b290 575 Float_t maxE=0;
576 Float_t maxL1=0;
577 Float_t maxL2=0;
578 Float_t maxDis=0;
579
c47157cd 580 AliEMCALHistoUtilities::FillH1(fHists, 12, double(fRecPoints->GetEntries()));
1d46d1f6 581
c47157cd 582 for (index = 0 ; index < fRecPoints->GetEntries() ; index++) {
583 AliEMCALRecPoint * rp = dynamic_cast<AliEMCALRecPoint * >(fRecPoints->At(index)) ;
483b0559 584 TVector3 globalpos;
1963b290 585 //rp->GetGlobalPosition(globalpos);
ed611565 586 TVector3 localpos;
587 rp->GetLocalPosition(localpos);
483b0559 588 Float_t lambda[2];
589 rp->GetElipsAxis(lambda);
590 Int_t * primaries;
591 Int_t nprimaries;
592 primaries = rp->GetPrimaries(nprimaries);
1d46d1f6 593 if(strstr(option,"deb"))
70a93198 594 printf("\n%6d %8.4f %3d %4.1f %4.1f %4.1f %4.1f %4.1f %4.1f %4.1f %4f %4f %2d : ",
595 rp->GetIndexInList(), rp->GetEnergy(), rp->GetMultiplicity(),
ed611565 596 globalpos.X(), globalpos.Y(), globalpos.Z(), localpos.X(), localpos.Y(), localpos.Z(),
597 rp->GetDispersion(), lambda[0], lambda[1], nprimaries) ;
1963b290 598 /////////////
599 if(rp->GetEnergy()>maxE){
600 maxE=rp->GetEnergy();
601 maxL1=lambda[0];
602 maxL2=lambda[1];
603 maxDis=rp->GetDispersion();
604 }
a5c60732 605 fPointE->Fill(rp->GetEnergy());
606 fPointL1->Fill(lambda[0]);
607 fPointL2->Fill(lambda[1]);
608 fPointDis->Fill(rp->GetDispersion());
609 fPointMult->Fill(rp->GetMultiplicity());
1963b290 610 /////////////
1d46d1f6 611 if(strstr(option,"deb")){
612 for (Int_t iprimary=0; iprimary<nprimaries; iprimary++) {
613 printf("%d ", primaries[iprimary] ) ;
614 }
615 }
483b0559 616 }
1963b290 617
a5c60732 618 fMaxE->Fill(maxE);
619 fMaxL1->Fill(maxL1);
620 fMaxL2->Fill(maxL2);
621 fMaxDis->Fill(maxDis);
1963b290 622
1d46d1f6 623 if(strstr(option,"deb"))
ed611565 624 printf("\n-----------------------------------------------------------------------\n");
483b0559 625 }
626}
e52475ed 627TList* AliEMCALClusterizerv1::BookHists()
1963b290 628{
14ce0a6e 629 //set up histograms for monitoring clusterizer performance
630
e52475ed 631 gROOT->cd();
632
1d46d1f6 633 fPointE = new TH1F("00_pointE","point energy", 2000, 0.0, 150.);
634 fPointL1 = new TH1F("01_pointL1","point L1", 1000, 0.0, 3.);
635 fPointL2 = new TH1F("02_pointL2","point L2", 1000, 0.0, 3.);
636 fPointDis = new TH1F("03_pointDisp","point dispersion", 1000, 0.0, 10.);
637 fPointMult = new TH1F("04_pointMult","#cell in point(cluster)", 101, -0.5, 100.5);
638 fDigitAmp = new TH1F("05_digitAmp","Digit Amplitude", 2000, 0.0, 5000.);
639 fMaxE = new TH1F("06_maxE","Max point energy", 2000, 0.0, 150.);
640 fMaxL1 = new TH1F("07_maxL1","Largest (first) of eigenvalue of covariance matrix", 1000, 0.0, 3.);
641 fMaxL2 = new TH1F("08_maxL2","Smalest (second) of eigenvalue of covariace matrix", 1000, 0.0, 3.);
642 fMaxDis = new TH1F("09_maxDis","Point dispersion", 1000, 0.0, 10.); // 9
e52475ed 643 //
1d46d1f6 644 new TH1F("10_adcOfDigits","adc of digits(threshold control)", 1001, -0.5, 1000.5); // 10
645 new TH1F("11_energyOfDigits","energy of digits(threshold control)", 1000, 0.0, 1.); // 11
646 new TH1F("12_numberOfPoints","number of points(clusters)", 101, -0.5, 100.5); // 12
e52475ed 647
648 return AliEMCALHistoUtilities::MoveHistsToList("EmcalClusterizerv1ControlHists", kFALSE);
1963b290 649}
e52475ed 650
651void AliEMCALClusterizerv1::SaveHists(const char *fn)
1963b290 652{
e52475ed 653 AliEMCALHistoUtilities::SaveListOfHists(fHists, fn, kTRUE);
1963b290 654}
655
1d46d1f6 656void AliEMCALClusterizerv1::PrintRecoInfo()
657{
658 printf(" AliEMCALClusterizerv1::PrintRecoInfo() : version %s \n", Version() );
659 TH1F *h = (TH1F*)fHists->At(12);
660 if(h) {
661 printf(" ## Multiplicity of RecPoints ## \n");
662 for(int i=1; i<=h->GetNbinsX(); i++) {
663 int nbin = int((*h)[i]);
664 int mult = int(h->GetBinCenter(i));
665 if(nbin > 0) printf(" %i : %5.5i %6.3f %% \n", mult, nbin, 100.*nbin/h->GetEntries());
666 }
667 }
668}
669
670void AliEMCALClusterizerv1::DrawLambdasHists()
671{
672 if(fMaxL1) {
673 fMaxL1->Draw();
674 if(fMaxL2) fMaxL2->Draw("same");
675 if(fMaxDis) {
676 fMaxDis->Draw("same");
677 }
678 }
679}