1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 //_________________________________________________________________________
19 // Base class for the clusterization algorithm (pure abstract)
21 //*-- Author: Yves Schutz SUBATECH
23 // Clusterization mother class. Contains common methods/data members of different
24 // clusterizers. GCB 2010
25 //////////////////////////////////////////////////////////////////////////////
27 // --- ROOT system ---
28 #include "TClonesArray.h"
36 #include <TBenchmark.h>
40 // --- Standard library ---
43 // --- AliRoot header files ---
44 #include "AliEMCALClusterizer.h"
45 #include "AliEMCALReconstructor.h"
46 #include "AliRunLoader.h"
50 #include "AliEMCALRecPoint.h"
51 #include "AliEMCALRecParam.h"
52 #include "AliEMCALGeometry.h"
53 #include "AliEMCALRecParam.h"
54 #include "AliCDBManager.h"
55 #include "AliCaloCalibPedestal.h"
56 #include "AliEMCALCalibData.h"
58 #include "AliCDBEntry.h"
60 ClassImp(AliEMCALClusterizer)
62 //____________________________________________________________________________
63 AliEMCALClusterizer::AliEMCALClusterizer():
64 fIsInputCalibrated(kFALSE),
71 fADCchannelECA(0.),fADCpedestalECA(0.),
72 fTimeMin(-1.),fTimeMax(1.),fTimeCut(1.),
73 fDefaultInit(kFALSE),fToUnfold(kFALSE),
74 fNumberOfECAClusters(0), fECAClusteringThreshold(0.),
75 fECALocMaxCut(0.),fECAW0(0.),fMinECut(0.),
76 fClusterUnfolding(NULL)
83 //____________________________________________________________________________
84 AliEMCALClusterizer::AliEMCALClusterizer(AliEMCALGeometry* geometry):
85 fIsInputCalibrated(kFALSE),
92 fADCchannelECA(0.),fADCpedestalECA(0.),
93 fTimeMin(-1.),fTimeMax(1.),fTimeCut(1.),
94 fDefaultInit(kFALSE),fToUnfold(kFALSE),
95 fNumberOfECAClusters(0), fECAClusteringThreshold(0.),
96 fECALocMaxCut(0.),fECAW0(0.),fMinECut(0.),
97 fClusterUnfolding(NULL)
99 // Ctor with the indication of the file where header Tree and digits Tree are stored.
100 // Use this contructor to avoid usage of Init() which uses runloader.
101 // Change needed by HLT - MP.
102 // Note for the future: the use on runloader should be avoided or optional at least.
103 // Another way is to make Init virtual and protected at least
104 // such that the deriving classes can overload Init();
108 AliFatal("Geometry not initialized.");
111 for (i = 0; i < 8; i++)
113 for (i = 0; i < 3; i++) {
119 //____________________________________________________________________________
120 AliEMCALClusterizer::AliEMCALClusterizer(AliEMCALGeometry *geometry,
121 AliEMCALCalibData *calib,
122 AliCaloCalibPedestal *caloped):
123 fIsInputCalibrated(kFALSE),
130 fADCchannelECA(0.),fADCpedestalECA(0.),
131 fTimeMin(-1.),fTimeMax(1.),fTimeCut(1.),
132 fDefaultInit(kFALSE),fToUnfold(kFALSE),
133 fNumberOfECAClusters(0), fECAClusteringThreshold(0.),
134 fECALocMaxCut(0.),fECAW0(0.),fMinECut(0.),
135 fClusterUnfolding(NULL)
137 // ctor, geometry and calibration are initialized elsewhere.
140 AliFatal("Geometry not initialized.");
143 for (i = 0; i < 8; i++)
145 for (i = 0; i < 3; i++) {
151 //____________________________________________________________________________
152 AliEMCALClusterizer::~AliEMCALClusterizer()
155 //Already deleted in AliEMCALReconstructor.
157 if(fClusterUnfolding) delete fClusterUnfolding;
160 //____________________________________________________________________________
161 Float_t AliEMCALClusterizer::Calibrate(const Float_t amp, const Float_t time, const Int_t absId)
163 // Convert digitized amplitude into energy.
164 // Calibration parameters are taken from calibration data base for raw data,
165 // or from digitizer parameters for simulated data.
167 //Return energy with default parameters if calibration is not available
169 if (fIsInputCalibrated == kTRUE)
171 AliDebug(10, Form("Input already calibrated!"));
175 return -fADCpedestalECA + amp * fADCchannelECA ;
179 AliFatal("Did not get geometry from EMCALLoader") ;
188 Bool_t bCell = fGeom->GetCellIndex(absId, iSupMod, nModule, nIphi, nIeta) ;
190 fGeom->PrintGeometry();
191 AliError(Form("Wrong cell id number : %i", absId));
192 //assert(0); // GCB: This aborts reconstruction of raw simulations
193 //where simulation had more SM than default geometry,
194 //change to return 0, to avoid aborting good generations.
198 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,nModule,nIphi, nIeta,iphi,ieta);
200 // Check if channel is bad (dead or hot), in this case return 0.
201 // Gustavo: 15-12-09 In case of RAW data this selection is already done, but not in simulation.
202 // for the moment keep it here but remember to do the selection at the sdigitizer level
203 // and remove it from here
204 Int_t channelStatus = (Int_t)(fCaloPed->GetDeadMap(iSupMod))->GetBinContent(ieta,iphi);
205 if(channelStatus == AliCaloCalibPedestal::kHot || channelStatus == AliCaloCalibPedestal::kDead) {
206 AliDebug(2,Form("Tower from SM %d, ieta %d, iphi %d is BAD : status %d !!!",iSupMod,ieta,iphi, channelStatus));
209 //Check if time is too large or too small, indication of a noisy channel, remove in this case
210 if(time > fTimeMax || time < fTimeMin) return 0;
212 if (fIsInputCalibrated)
214 AliDebug(10, Form("Input already calibrated!"));
218 fADCchannelECA = fCalibData->GetADCchannel (iSupMod,ieta,iphi);
219 fADCpedestalECA = fCalibData->GetADCpedestal(iSupMod,ieta,iphi);
221 return -fADCpedestalECA + amp * fADCchannelECA ;
224 //____________________________________________________________________________
225 void AliEMCALClusterizer::GetCalibrationParameters()
227 // Set calibration parameters:
228 // If calibration database exists, they are read from database,
229 // otherwise, they are taken from digitizer.
230 // It is a user responsilibity to open CDB before reconstruction,
232 // AliCDBStorage* storage = AliCDBManager::Instance()->GetStorage("local://CalibDB");
234 if (fIsInputCalibrated)
237 //Check if calibration is stored in data base
240 AliCDBEntry *entry = (AliCDBEntry*)
241 AliCDBManager::Instance()->Get("EMCAL/Calib/Data");
242 if (entry) fCalibData = (AliEMCALCalibData*) entry->GetObject();
246 AliFatal("Calibration parameters not found in CDB!");
249 //____________________________________________________________________________
250 void AliEMCALClusterizer::GetCaloCalibPedestal()
252 // Set calibration parameters:
253 // if calibration database exists, they are read from database,
254 // otherwise, they are taken from digitizer.
256 // It is a user responsilibity to open CDB before reconstruction,
258 // AliCDBStorage* storage = AliCDBManager::Instance()->GetStorage("local://CalibDB");
260 if (fIsInputCalibrated)
263 // Check if calibration is stored in data base
266 AliCDBEntry *entry = (AliCDBEntry*)
267 AliCDBManager::Instance()->Get("EMCAL/Calib/Pedestals");
268 if (entry) fCaloPed = (AliCaloCalibPedestal*) entry->GetObject();
272 AliFatal("Pedestal info not found in CDB!");
275 //____________________________________________________________________________
276 void AliEMCALClusterizer::Init()
278 // Make all memory allocations which can not be done in default constructor.
279 // Attach the Clusterizer task to the list of EMCAL tasks
281 AliRunLoader *rl = AliRunLoader::Instance();
282 if (rl->GetAliRun()){
283 AliEMCAL* emcal = dynamic_cast<AliEMCAL*>(rl->GetAliRun()->GetDetector("EMCAL"));
284 if(emcal)fGeom = emcal->GetGeometry();
288 fGeom = AliEMCALGeometry::GetInstance(AliEMCALGeometry::GetDefaultGeometryName());
291 AliDebug(1,Form("geom %p",fGeom));
294 gMinuit = new TMinuit(100) ;
297 for (i = 0; i < 8; i++)
299 for (i = 0; i < 3; i++) {
305 //____________________________________________________________________________
306 void AliEMCALClusterizer::InitParameters()
308 // Initializes the parameters for the Clusterizer from AliEMCALReconstructor::GetRecParam().
310 return InitParameters(AliEMCALReconstructor::GetRecParam());
313 //____________________________________________________________________________
314 void AliEMCALClusterizer::InitParameters(const AliEMCALRecParam* recParam)
316 // Initializes the parameters for the Clusterizer
318 fNumberOfECAClusters = 0 ;
323 AliFatal("Reconstruction parameters for EMCAL not set!");
326 fECAClusteringThreshold = recParam->GetClusteringThreshold();
327 fECAW0 = recParam->GetW0();
328 fMinECut = recParam->GetMinECut();
329 fToUnfold = recParam->GetUnfold();
330 fECALocMaxCut = recParam->GetLocMaxCut();
331 fTimeCut = recParam->GetTimeCut();
332 fTimeMin = recParam->GetTimeMin();
333 fTimeMax = recParam->GetTimeMax();
335 AliDebug(1,Form("Reconstruction parameters: fECAClusteringThreshold=%.3f GeV, fECAW=%.3f, fMinECut=%.3f GeV, "
336 "fToUnfold=%d, fECALocMaxCut=%.3f GeV, fTimeCut=%e s,fTimeMin=%e s,fTimeMax=%e s",
337 fECAClusteringThreshold,fECAW0,fMinECut,fToUnfold,fECALocMaxCut,fTimeCut, fTimeMin, fTimeMax));
341 for (i = 0; i < 8; i++) {
342 fSSPars[i] = recParam->GetSSPars(i);
343 } //end of loop over parameters
344 for (i = 0; i < 3; i++) {
345 fPar5[i] = recParam->GetPar5(i);
346 fPar6[i] = recParam->GetPar6(i);
347 } //end of loop over parameters
349 InitClusterUnfolding();
351 for (i = 0; i < 8; i++) {
352 AliDebug(1,Form("unfolding shower shape parameters: fSSPars=%f \n",fSSPars[i]));
354 for (i = 0; i < 3; i++) {
355 AliDebug(1,Form("unfolding parameter 5: fPar5=%f \n",fPar5[i]));
356 AliDebug(1,Form("unfolding parameter 6: fPar6=%f \n",fPar6[i]));
361 //____________________________________________________________________________
362 void AliEMCALClusterizer::Print(Option_t * /*option*/)const
364 // Print clusterizer parameters
366 TString message("\n") ;
368 if (strcmp(GetName(),"") == 0) {
369 printf("AliEMCALClusterizer not initialized\n");
374 TString taskName(Version()) ;
376 printf("--------------- ");
377 printf("%s",taskName.Data()) ;
379 printf("Clusterizing digits: ");
380 printf("\n ECA Local Maximum cut = %f", fECALocMaxCut);
381 printf("\n ECA Logarithmic weight = %f", fECAW0);
383 printf("\nUnfolding on\n");
384 printf("Unfolding parameters: fSSpars: \n");
386 for (i = 0; i < 8; i++) {
387 printf("fSSPars[%d] = %f \n", i, fSSPars[i]);
389 printf("Unfolding parameter 5 and 6: fPar5 and fPar6: \n");
390 for (i = 0; i < 3; i++) {
391 printf("fPar5[%d] = %f \n", i, fPar5[i]);
392 printf("fPar6[%d] = %f \n", i, fPar6[i]);
396 printf("\nUnfolding off\n");
398 printf("------------------------------------------------------------------");
401 //____________________________________________________________________________
402 void AliEMCALClusterizer::PrintRecPoints(Option_t * option)
404 // Prints list of RecPoints produced at the current pass of AliEMCALClusterizer
406 if (strstr(option,"deb")) {
407 printf("PrintRecPoints: Clusterization result:") ;
408 printf(" Found %d ECA Rec Points\n ",
409 fRecPoints->GetEntriesFast()) ;
412 if (strstr(option,"all")) {
413 if (strstr(option,"deb")) {
414 printf("\n-----------------------------------------------------------------------\n") ;
415 printf("Clusters in ECAL section\n") ;
416 printf("Index Ene(GeV) Multi Module GX GY GZ lX lY lZ Dispersion Lambda 1 Lambda 2 # of prim Primaries list\n") ;
419 for (index = 0 ; index < fRecPoints->GetEntries() ; index++) {
420 AliEMCALRecPoint * rp = dynamic_cast<AliEMCALRecPoint * >(fRecPoints->At(index)) ;
425 //rp->GetGlobalPosition(globalpos);
427 rp->GetLocalPosition(localpos);
429 rp->GetElipsAxis(lambda);
432 Int_t * primaries = rp->GetPrimaries(nprimaries);
433 if(strstr(option,"deb"))
434 printf("\n%6d %8.4f %3d %4.1f %4.1f %4.1f %4.1f %4.1f %4.1f %4.1f %4f %4f %2d : ",
435 rp->GetIndexInList(), rp->GetEnergy(), rp->GetMultiplicity(),
436 globalpos.X(), globalpos.Y(), globalpos.Z(), localpos.X(), localpos.Y(), localpos.Z(),
437 rp->GetDispersion(), lambda[0], lambda[1], nprimaries) ;
438 if(strstr(option,"deb")){
439 for (Int_t iprimary=0; iprimary<nprimaries; iprimary++) {
440 printf("%d ", primaries[iprimary] ) ;
445 if(strstr(option,"deb"))
446 printf("\n-----------------------------------------------------------------------\n");
450 //___________________________________________________________________
451 void AliEMCALClusterizer::PrintRecoInfo()
453 // Print reco version
455 printf(" AliEMCALClusterizer::PrintRecoInfo() : version %s \n", Version() );
458 //____________________________________________________________________________
459 void AliEMCALClusterizer::SetInput(TTree *digitsTree)
461 // Read the digits from the input tree
463 TBranch *branch = digitsTree->GetBranch("EMCAL");
465 AliError("can't get the branch with the EMCAL digits !");
469 fDigitsArr = new TClonesArray("AliEMCALDigit",100);
470 branch->SetAddress(&fDigitsArr);
474 //____________________________________________________________________________
475 void AliEMCALClusterizer::SetOutput(TTree *clustersTree)
477 // Read the digits from the input tree
479 AliDebug(9, "Making array for EMCAL clusters");
480 fRecPoints = new TObjArray(1000);
482 fTreeR = clustersTree;
484 Int_t bufsize = 32000;
485 fTreeR->Branch("EMCALECARP", "TObjArray", &fRecPoints, bufsize, split);
489 //___________________________________________________________________
490 void AliEMCALClusterizer::SetInputCalibrated(Bool_t val)
492 // Flag to indicate that input is calibrated - the case when we run already on ESD
494 fIsInputCalibrated = val;