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 Bool_t AliEMCALClusterizer::fgkIsInputCalibrated = kFALSE;
65 //____________________________________________________________________________
66 AliEMCALClusterizer::AliEMCALClusterizer():
73 fADCchannelECA(0.),fADCpedestalECA(0.),
74 fTimeMin(-1.),fTimeMax(1.),fTimeCut(1.),
75 fDefaultInit(kFALSE),fToUnfold(kFALSE),
76 fNumberOfECAClusters(0), fECAClusteringThreshold(0.),
77 fECALocMaxCut(0.),fECAW0(0.),fMinECut(0.),
78 fClusterUnfolding(NULL)
86 //____________________________________________________________________________
87 AliEMCALClusterizer::AliEMCALClusterizer(AliEMCALGeometry* geometry):
94 fADCchannelECA(0.),fADCpedestalECA(0.),
95 fTimeMin(-1.),fTimeMax(1.),fTimeCut(1.),
96 fDefaultInit(kFALSE),fToUnfold(kFALSE),
97 fNumberOfECAClusters(0), fECAClusteringThreshold(0.),
98 fECALocMaxCut(0.),fECAW0(0.),fMinECut(0.),
99 fClusterUnfolding(NULL)
101 // ctor with the indication of the file where header Tree and digits Tree are stored
102 // use this contructor to avoid usage of Init() which uses runloader
103 // change needed by HLT - MP
105 // Note for the future: the use on runloader should be avoided or optional at least
106 // another way is to make Init virtual and protected at least such that the deriving classes can overload
112 AliFatal("Geometry not initialized.");
115 for (i = 0; i < 8; i++)
117 for (i = 0; i < 3; i++) {
123 //____________________________________________________________________________
124 AliEMCALClusterizer::AliEMCALClusterizer(AliEMCALGeometry* geometry, AliEMCALCalibData * calib, AliCaloCalibPedestal * caloped):
131 fADCchannelECA(0.),fADCpedestalECA(0.),
132 fTimeMin(-1.),fTimeMax(1.),fTimeCut(1.),
133 fDefaultInit(kFALSE),fToUnfold(kFALSE),
134 fNumberOfECAClusters(0), fECAClusteringThreshold(0.),
135 fECALocMaxCut(0.),fECAW0(0.),fMinECut(0.),
136 fClusterUnfolding(NULL)
138 // ctor, geometry and calibration are initialized elsewhere.
141 AliFatal("Geometry not initialized.");
144 for (i = 0; i < 8; i++)
146 for (i = 0; i < 3; i++) {
154 //____________________________________________________________________________
155 AliEMCALClusterizer::~AliEMCALClusterizer()
158 //Already deleted in AliEMCALReconstructor.
160 // if(fGeom) delete fGeom;
161 // if(fCalibData) delete fCalibData;
162 // if(fCaloPed) delete fCaloPed;
165 // fDigitsArr->Clear("C");
166 // delete fDigitsArr;
169 // fRecPoints->Delete();
170 // delete fRecPoints;
173 if(fClusterUnfolding) delete fClusterUnfolding;
176 //____________________________________________________________________________
177 Float_t AliEMCALClusterizer::Calibrate(const Float_t amp, const Float_t time, const Int_t absId)
180 // Convert digitized amplitude into energy.
181 // Calibration parameters are taken from calibration data base for raw data,
182 // or from digitizer parameters for simulated data.
186 AliFatal("Did not get geometry from EMCALLoader") ;
195 Bool_t bCell = fGeom->GetCellIndex(absId, iSupMod, nModule, nIphi, nIeta) ;
197 fGeom->PrintGeometry();
198 Error("Calibrate()"," Wrong cell id number : %i", absId);
202 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,nModule,nIphi, nIeta,iphi,ieta);
204 // Check if channel is bad (dead or hot), in this case return 0.
205 // Gustavo: 15-12-09 In case of RAW data this selection is already done, but not in simulation.
206 // for the moment keep it here but remember to do the selection at the sdigitizer level
207 // and remove it from here
208 Int_t channelStatus = (Int_t)(fCaloPed->GetDeadMap(iSupMod))->GetBinContent(ieta,iphi);
209 if(channelStatus == AliCaloCalibPedestal::kHot || channelStatus == AliCaloCalibPedestal::kDead) {
210 AliDebug(2,Form("Tower from SM %d, ieta %d, iphi %d is BAD : status %d !!!",iSupMod,ieta,iphi, channelStatus));
213 //Check if time is too large or too small, indication of a noisy channel, remove in this case
214 if(time > fTimeMax || time < fTimeMin) return 0;
216 if (AliEMCALClusterizer::fgkIsInputCalibrated == kTRUE)
218 AliDebug(10, Form("Input already calibrated!"));
222 fADCchannelECA = fCalibData->GetADCchannel (iSupMod,ieta,iphi);
223 fADCpedestalECA = fCalibData->GetADCpedestal(iSupMod,ieta,iphi);
226 return -fADCpedestalECA + amp * fADCchannelECA ;
229 else{ //Return energy with default parameters if calibration is not available
231 if (AliEMCALClusterizer::fgkIsInputCalibrated == kTRUE)
233 AliDebug(10, Form("Input already calibrated!"));
237 return -fADCpedestalECA + amp * fADCchannelECA ;
242 //____________________________________________________________________________
243 void AliEMCALClusterizer::GetCalibrationParameters()
245 // Set calibration parameters:
246 // if calibration database exists, they are read from database,
247 // otherwise, they are taken from digitizer.
249 // It is a user responsilibity to open CDB before reconstruction,
251 // AliCDBStorage* storage = AliCDBManager::Instance()->GetStorage("local://CalibDB");
253 //Check if calibration is stored in data base
257 AliCDBEntry *entry = (AliCDBEntry*)
258 AliCDBManager::Instance()->Get("EMCAL/Calib/Data");
259 if (entry) fCalibData = (AliEMCALCalibData*) entry->GetObject();
263 AliFatal("Calibration parameters not found in CDB!");
267 //____________________________________________________________________________
268 void AliEMCALClusterizer::GetCaloCalibPedestal()
270 // Set calibration parameters:
271 // if calibration database exists, they are read from database,
272 // otherwise, they are taken from digitizer.
274 // It is a user responsilibity to open CDB before reconstruction,
276 // AliCDBStorage* storage = AliCDBManager::Instance()->GetStorage("local://CalibDB");
278 //Check if calibration is stored in data base
282 AliCDBEntry *entry = (AliCDBEntry*)
283 AliCDBManager::Instance()->Get("EMCAL/Calib/Pedestals");
284 if (entry) fCaloPed = (AliCaloCalibPedestal*) entry->GetObject();
288 AliFatal("Pedestal info not found in CDB!");
292 //____________________________________________________________________________
293 void AliEMCALClusterizer::Init()
295 // Make all memory allocations which can not be done in default constructor.
296 // Attach the Clusterizer task to the list of EMCAL tasks
298 AliRunLoader *rl = AliRunLoader::Instance();
299 if (rl->GetAliRun()){
300 AliEMCAL* emcal = dynamic_cast<AliEMCAL*>(rl->GetAliRun()->GetDetector("EMCAL"));
301 if(emcal)fGeom = emcal->GetGeometry();
305 fGeom = AliEMCALGeometry::GetInstance(AliEMCALGeometry::GetDefaultGeometryName());
308 AliDebug(1,Form("geom %p",fGeom));
311 gMinuit = new TMinuit(100) ;
314 for (i = 0; i < 8; i++)
316 for (i = 0; i < 3; i++) {
323 //____________________________________________________________________________
324 void AliEMCALClusterizer::InitParameters()
326 // Initializes the parameters for the Clusterizer
327 fNumberOfECAClusters = 0 ;
331 const AliEMCALRecParam* recParam = AliEMCALReconstructor::GetRecParam();
333 AliFatal("Reconstruction parameters for EMCAL not set!");
335 fECAClusteringThreshold = recParam->GetClusteringThreshold();
336 fECAW0 = recParam->GetW0();
337 fMinECut = recParam->GetMinECut();
338 fToUnfold = recParam->GetUnfold();
339 fECALocMaxCut = recParam->GetLocMaxCut();
340 fTimeCut = recParam->GetTimeCut();
341 fTimeMin = recParam->GetTimeMin();
342 fTimeMax = recParam->GetTimeMax();
344 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",
345 fECAClusteringThreshold,fECAW0,fMinECut,fToUnfold,fECALocMaxCut,fTimeCut, fTimeMin, fTimeMax));
350 for (i = 0; i < 8; i++) {
351 fSSPars[i] = recParam->GetSSPars(i);
352 }//end of loop over parameters
353 for (i = 0; i < 3; i++) {
354 fPar5[i] = recParam->GetPar5(i);
355 fPar6[i] = recParam->GetPar6(i);
356 }//end of loop over parameters
358 InitClusterUnfolding();
360 for (i = 0; i < 8; i++) {
361 AliDebug(1,Form("unfolding shower shape parameters: fSSPars=%f \n",fSSPars[i]));
363 for (i = 0; i < 3; i++) {
364 AliDebug(1,Form("unfolding parameter 5: fPar5=%f \n",fPar5[i]));
365 AliDebug(1,Form("unfolding parameter 6: fPar6=%f \n",fPar6[i]));
369 }// recparam not null
374 //____________________________________________________________________________
375 void AliEMCALClusterizer::Print(Option_t * /*option*/)const
377 // Print clusterizer parameters
379 TString message("\n") ;
381 if( strcmp(GetName(), "") !=0 ){
385 TString taskName(Version()) ;
387 printf("--------------- ");
388 printf("%s",taskName.Data()) ;
390 printf("Clusterizing digits: ");
391 printf("\n ECA Local Maximum cut = %f", fECALocMaxCut);
392 printf("\n ECA Logarithmic weight = %f", fECAW0);
394 printf("\nUnfolding on\n");
395 printf("Unfolding parameters: fSSpars: \n");
397 for (i = 0; i < 8; i++) {
398 printf("fSSPars[%d] = %f \n", i, fSSPars[i]);
400 printf("Unfolding parameter 5 and 6: fPar5 and fPar6: \n");
401 for (i = 0; i < 3; i++) {
402 printf("fPar5[%d] = %f \n", i, fPar5[i]);
403 printf("fPar6[%d] = %f \n", i, fPar6[i]);
407 printf("\nUnfolding off\n");
409 printf("------------------------------------------------------------------");
412 printf("AliEMCALClusterizer not initialized ") ;
415 //____________________________________________________________________________
416 void AliEMCALClusterizer::PrintRecPoints(Option_t * option)
418 // Prints list of RecPoints produced at the current pass of AliEMCALClusterizer
419 if(strstr(option,"deb")) {
420 printf("PrintRecPoints: Clusterization result:") ;
422 printf(" Found %d ECA Rec Points\n ",
423 fRecPoints->GetEntriesFast()) ;
426 if(strstr(option,"all")) {
427 if(strstr(option,"deb")) {
428 printf("\n-----------------------------------------------------------------------\n") ;
429 printf("Clusters in ECAL section\n") ;
430 printf("Index Ene(GeV) Multi Module GX GY GZ lX lY lZ Dispersion Lambda 1 Lambda 2 # of prim Primaries list\n") ;
433 for (index = 0 ; index < fRecPoints->GetEntries() ; index++) {
434 AliEMCALRecPoint * rp = dynamic_cast<AliEMCALRecPoint * >(fRecPoints->At(index)) ;
437 //rp->GetGlobalPosition(globalpos);
439 rp->GetLocalPosition(localpos);
441 rp->GetElipsAxis(lambda);
444 Int_t * primaries = rp->GetPrimaries(nprimaries);
446 if(strstr(option,"deb"))
447 printf("\n%6d %8.4f %3d %4.1f %4.1f %4.1f %4.1f %4.1f %4.1f %4.1f %4f %4f %2d : ",
448 rp->GetIndexInList(), rp->GetEnergy(), rp->GetMultiplicity(),
449 globalpos.X(), globalpos.Y(), globalpos.Z(), localpos.X(), localpos.Y(), localpos.Z(),
450 rp->GetDispersion(), lambda[0], lambda[1], nprimaries) ;
451 if(strstr(option,"deb")){
452 for (Int_t iprimary=0; iprimary<nprimaries; iprimary++) {
453 printf("%d ", primaries[iprimary] ) ;
459 if(strstr(option,"deb"))
460 printf("\n-----------------------------------------------------------------------\n");
464 //___________________________________________________________________
465 void AliEMCALClusterizer::PrintRecoInfo()
468 printf(" AliEMCALClusterizer::PrintRecoInfo() : version %s \n", Version() );
472 //____________________________________________________________________________
473 void AliEMCALClusterizer::SetInput(TTree *digitsTree)
475 // Read the digits from the input tree
476 TBranch *branch = digitsTree->GetBranch("EMCAL");
478 AliError("can't get the branch with the EMCAL digits !");
482 fDigitsArr = new TClonesArray("AliEMCALDigit",100);
483 branch->SetAddress(&fDigitsArr);
487 //____________________________________________________________________________
488 void AliEMCALClusterizer::SetOutput(TTree *clustersTree)
490 // Read the digits from the input tree
491 fTreeR = clustersTree;
493 AliDebug(9, "Making array for EMCAL clusters");
494 fRecPoints = new TObjArray(100) ;
496 Int_t bufsize = 32000;
497 fTreeR->Branch("EMCALECARP", "TObjArray", &fRecPoints, bufsize, split);
500 //___________________________________________________________________
501 void AliEMCALClusterizer::SetInputCalibrated(Bool_t val)
504 // input is calibrated - the case when we run already on ESD
506 AliEMCALClusterizer::fgkIsInputCalibrated = val;