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"
59 #include "AliEMCALUnfolding.h"
61 ClassImp(AliEMCALClusterizer)
63 Bool_t AliEMCALClusterizer::fgkIsInputCalibrated = kFALSE;
66 //____________________________________________________________________________
67 AliEMCALClusterizer::AliEMCALClusterizer():
74 fADCchannelECA(0.),fADCpedestalECA(0.),
75 fTimeMin(-1.),fTimeMax(1.),fTimeCut(1.),
76 fDefaultInit(kFALSE),fToUnfold(kFALSE),
77 fNumberOfECAClusters(0), fECAClusteringThreshold(0.),
78 fECALocMaxCut(0.),fECAW0(0.),fMinECut(0.),
79 fClusterUnfolding(NULL)
87 //____________________________________________________________________________
88 AliEMCALClusterizer::AliEMCALClusterizer(AliEMCALGeometry* geometry):
95 fADCchannelECA(0.),fADCpedestalECA(0.),
96 fTimeMin(-1.),fTimeMax(1.),fTimeCut(1.),
97 fDefaultInit(kFALSE),fToUnfold(kFALSE),
98 fNumberOfECAClusters(0), fECAClusteringThreshold(0.),
99 fECALocMaxCut(0.),fECAW0(0.),fMinECut(0.),
100 fClusterUnfolding(NULL)
102 // ctor with the indication of the file where header Tree and digits Tree are stored
103 // use this contructor to avoid usage of Init() which uses runloader
104 // change needed by HLT - MP
106 // Note for the future: the use on runloader should be avoided or optional at least
107 // another way is to make Init virtual and protected at least such that the deriving classes can overload
113 AliFatal("Geometry not initialized.");
116 for (i = 0; i < 8; i++)
118 for (i = 0; i < 3; i++) {
124 //____________________________________________________________________________
125 AliEMCALClusterizer::AliEMCALClusterizer(AliEMCALGeometry* geometry, AliEMCALCalibData * calib, AliCaloCalibPedestal * caloped):
132 fADCchannelECA(0.),fADCpedestalECA(0.),
133 fTimeMin(-1.),fTimeMax(1.),fTimeCut(1.),
134 fDefaultInit(kFALSE),fToUnfold(kFALSE),
135 fNumberOfECAClusters(0), fECAClusteringThreshold(0.),
136 fECALocMaxCut(0.),fECAW0(0.),fMinECut(0.),
137 fClusterUnfolding(NULL)
139 // ctor, geometry and calibration are initialized elsewhere.
142 AliFatal("Geometry not initialized.");
145 for (i = 0; i < 8; i++)
147 for (i = 0; i < 3; i++) {
155 //____________________________________________________________________________
156 AliEMCALClusterizer::~AliEMCALClusterizer()
159 //Already deleted in AliEMCALReconstructor.
161 // if(fGeom) delete fGeom;
162 // if(fCalibData) delete fCalibData;
163 // if(fCaloPed) delete fCaloPed;
166 // fDigitsArr->Clear("C");
167 // delete fDigitsArr;
170 // fRecPoints->Delete();
171 // delete fRecPoints;
174 if(fClusterUnfolding) delete fClusterUnfolding;
177 //____________________________________________________________________________
178 Float_t AliEMCALClusterizer::Calibrate(const Float_t amp, const Float_t time, const Int_t absId)
181 // Convert digitized amplitude into energy.
182 // Calibration parameters are taken from calibration data base for raw data,
183 // or from digitizer parameters for simulated data.
187 AliFatal("Did not get geometry from EMCALLoader") ;
196 Bool_t bCell = fGeom->GetCellIndex(absId, iSupMod, nModule, nIphi, nIeta) ;
198 fGeom->PrintGeometry();
199 Error("Calibrate()"," Wrong cell id number : %i", absId);
203 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,nModule,nIphi, nIeta,iphi,ieta);
205 // Check if channel is bad (dead or hot), in this case return 0.
206 // Gustavo: 15-12-09 In case of RAW data this selection is already done, but not in simulation.
207 // for the moment keep it here but remember to do the selection at the sdigitizer level
208 // and remove it from here
209 Int_t channelStatus = (Int_t)(fCaloPed->GetDeadMap(iSupMod))->GetBinContent(ieta,iphi);
210 if(channelStatus == AliCaloCalibPedestal::kHot || channelStatus == AliCaloCalibPedestal::kDead) {
211 AliDebug(2,Form("Tower from SM %d, ieta %d, iphi %d is BAD : status %d !!!",iSupMod,ieta,iphi, channelStatus));
214 //Check if time is too large or too small, indication of a noisy channel, remove in this case
215 if(time > fTimeMax || time < fTimeMin) return 0;
217 if (AliEMCALClusterizer::fgkIsInputCalibrated == kTRUE)
219 AliDebug(10, Form("Input already calibrated!"));
223 fADCchannelECA = fCalibData->GetADCchannel (iSupMod,ieta,iphi);
224 fADCpedestalECA = fCalibData->GetADCpedestal(iSupMod,ieta,iphi);
227 return -fADCpedestalECA + amp * fADCchannelECA ;
230 else{ //Return energy with default parameters if calibration is not available
232 if (AliEMCALClusterizer::fgkIsInputCalibrated == kTRUE)
234 AliDebug(10, Form("Input already calibrated!"));
238 return -fADCpedestalECA + amp * fADCchannelECA ;
243 //____________________________________________________________________________
244 void AliEMCALClusterizer::GetCalibrationParameters()
246 // Set calibration parameters:
247 // if calibration database exists, they are read from database,
248 // otherwise, they are taken from digitizer.
250 // It is a user responsilibity to open CDB before reconstruction,
252 // AliCDBStorage* storage = AliCDBManager::Instance()->GetStorage("local://CalibDB");
254 //Check if calibration is stored in data base
258 AliCDBEntry *entry = (AliCDBEntry*)
259 AliCDBManager::Instance()->Get("EMCAL/Calib/Data");
260 if (entry) fCalibData = (AliEMCALCalibData*) entry->GetObject();
264 AliFatal("Calibration parameters not found in CDB!");
268 //____________________________________________________________________________
269 void AliEMCALClusterizer::GetCaloCalibPedestal()
271 // Set calibration parameters:
272 // if calibration database exists, they are read from database,
273 // otherwise, they are taken from digitizer.
275 // It is a user responsilibity to open CDB before reconstruction,
277 // AliCDBStorage* storage = AliCDBManager::Instance()->GetStorage("local://CalibDB");
279 //Check if calibration is stored in data base
283 AliCDBEntry *entry = (AliCDBEntry*)
284 AliCDBManager::Instance()->Get("EMCAL/Calib/Pedestals");
285 if (entry) fCaloPed = (AliCaloCalibPedestal*) entry->GetObject();
289 AliFatal("Pedestal info not found in CDB!");
293 //____________________________________________________________________________
294 void AliEMCALClusterizer::Init()
296 // Make all memory allocations which can not be done in default constructor.
297 // Attach the Clusterizer task to the list of EMCAL tasks
299 AliRunLoader *rl = AliRunLoader::Instance();
300 if (rl->GetAliRun()){
301 AliEMCAL* emcal = dynamic_cast<AliEMCAL*>(rl->GetAliRun()->GetDetector("EMCAL"));
302 if(emcal)fGeom = emcal->GetGeometry();
306 fGeom = AliEMCALGeometry::GetInstance(AliEMCALGeometry::GetDefaultGeometryName());
309 AliDebug(1,Form("geom %p",fGeom));
312 gMinuit = new TMinuit(100) ;
315 for (i = 0; i < 8; i++)
317 for (i = 0; i < 3; i++) {
324 //____________________________________________________________________________
325 void AliEMCALClusterizer::InitParameters()
327 // Initializes the parameters for the Clusterizer
328 fNumberOfECAClusters = 0 ;
332 const AliEMCALRecParam* recParam = AliEMCALReconstructor::GetRecParam();
334 AliFatal("Reconstruction parameters for EMCAL not set!");
336 fECAClusteringThreshold = recParam->GetClusteringThreshold();
337 fECAW0 = recParam->GetW0();
338 fMinECut = recParam->GetMinECut();
339 fToUnfold = recParam->GetUnfold();
340 fECALocMaxCut = recParam->GetLocMaxCut();
341 fTimeCut = recParam->GetTimeCut();
342 fTimeMin = recParam->GetTimeMin();
343 fTimeMax = recParam->GetTimeMax();
345 AliDebug(1,Form("Reconstruction parameters: fECAClusteringThreshold=%.3f GeV, fECAW=%.3f, fMinECut=%.3f GeV, fToUnfold=%d, fECALocMaxCut=%.3f GeV, fTimeCut=%e s,fTimeMin=%e s,fTimeMax=%e s",
346 fECAClusteringThreshold,fECAW0,fMinECut,fToUnfold,fECALocMaxCut,fTimeCut, fTimeMin, fTimeMax));
351 for (i = 0; i < 8; i++) {
352 fSSPars[i] = recParam->GetSSPars(i);
353 }//end of loop over parameters
354 for (i = 0; i < 3; i++) {
355 fPar5[i] = recParam->GetPar5(i);
356 fPar6[i] = recParam->GetPar6(i);
357 }//end of loop over parameters
359 fClusterUnfolding=new AliEMCALUnfolding(fGeom,fECALocMaxCut,fSSPars,fPar5,fPar6);
361 for (i = 0; i < 8; i++) {
362 AliDebug(1,Form("unfolding shower shape parameters: fSSPars=%f \n",fSSPars[i]));
364 for (i = 0; i < 3; i++) {
365 AliDebug(1,Form("unfolding parameter 5: fPar5=%f \n",fPar5[i]));
366 AliDebug(1,Form("unfolding parameter 6: fPar6=%f \n",fPar6[i]));
370 }// recparam not null
375 //____________________________________________________________________________
376 void AliEMCALClusterizer::Print(Option_t * /*option*/)const
378 // Print clusterizer parameters
380 TString message("\n") ;
382 if( strcmp(GetName(), "") !=0 ){
386 TString taskName(Version()) ;
388 printf("--------------- ");
389 printf("%s",taskName.Data()) ;
391 printf("Clusterizing digits: ");
392 printf("\n ECA Local Maximum cut = %f", fECALocMaxCut);
393 printf("\n ECA Logarithmic weight = %f", fECAW0);
395 printf("\nUnfolding on\n");
396 printf("Unfolding parameters: fSSpars: \n");
398 for (i = 0; i < 8; i++) {
399 printf("fSSPars[%d] = %f \n", i, fSSPars[i]);
401 printf("Unfolding parameter 5 and 6: fPar5 and fPar6: \n");
402 for (i = 0; i < 3; i++) {
403 printf("fPar5[%d] = %f \n", i, fPar5[i]);
404 printf("fPar6[%d] = %f \n", i, fPar6[i]);
408 printf("\nUnfolding off\n");
410 printf("------------------------------------------------------------------");
413 printf("AliEMCALClusterizer not initialized ") ;
416 //____________________________________________________________________________
417 void AliEMCALClusterizer::PrintRecPoints(Option_t * option)
419 // Prints list of RecPoints produced at the current pass of AliEMCALClusterizer
420 if(strstr(option,"deb")) {
421 printf("PrintRecPoints: Clusterization result:") ;
423 printf(" Found %d ECA Rec Points\n ",
424 fRecPoints->GetEntriesFast()) ;
427 if(strstr(option,"all")) {
428 if(strstr(option,"deb")) {
429 printf("\n-----------------------------------------------------------------------\n") ;
430 printf("Clusters in ECAL section\n") ;
431 printf("Index Ene(GeV) Multi Module GX GY GZ lX lY lZ Dispersion Lambda 1 Lambda 2 # of prim Primaries list\n") ;
434 for (index = 0 ; index < fRecPoints->GetEntries() ; index++) {
435 AliEMCALRecPoint * rp = dynamic_cast<AliEMCALRecPoint * >(fRecPoints->At(index)) ;
438 //rp->GetGlobalPosition(globalpos);
440 rp->GetLocalPosition(localpos);
442 rp->GetElipsAxis(lambda);
445 Int_t * primaries = rp->GetPrimaries(nprimaries);
447 if(strstr(option,"deb"))
448 printf("\n%6d %8.4f %3d %4.1f %4.1f %4.1f %4.1f %4.1f %4.1f %4.1f %4f %4f %2d : ",
449 rp->GetIndexInList(), rp->GetEnergy(), rp->GetMultiplicity(),
450 globalpos.X(), globalpos.Y(), globalpos.Z(), localpos.X(), localpos.Y(), localpos.Z(),
451 rp->GetDispersion(), lambda[0], lambda[1], nprimaries) ;
452 if(strstr(option,"deb")){
453 for (Int_t iprimary=0; iprimary<nprimaries; iprimary++) {
454 printf("%d ", primaries[iprimary] ) ;
460 if(strstr(option,"deb"))
461 printf("\n-----------------------------------------------------------------------\n");
465 //___________________________________________________________________
466 void AliEMCALClusterizer::PrintRecoInfo()
469 printf(" AliEMCALClusterizer::PrintRecoInfo() : version %s \n", Version() );
473 //____________________________________________________________________________
474 void AliEMCALClusterizer::SetInput(TTree *digitsTree)
476 // Read the digits from the input tree
477 TBranch *branch = digitsTree->GetBranch("EMCAL");
479 AliError("can't get the branch with the EMCAL digits !");
483 fDigitsArr = new TClonesArray("AliEMCALDigit",100);
484 branch->SetAddress(&fDigitsArr);
488 //____________________________________________________________________________
489 void AliEMCALClusterizer::SetOutput(TTree *clustersTree)
491 // Read the digits from the input tree
492 fTreeR = clustersTree;
494 AliDebug(9, "Making array for EMCAL clusters");
495 fRecPoints = new TObjArray(100) ;
497 Int_t bufsize = 32000;
498 fTreeR->Branch("EMCALECARP", "TObjArray", &fRecPoints, bufsize, split);
501 //___________________________________________________________________
502 void AliEMCALClusterizer::SetInputCalibrated(Bool_t val)
505 // input is calibrated - the case when we run already on ESD
507 AliEMCALClusterizer::fgkIsInputCalibrated = val;