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 AliError(Form("Wrong cell id number : %i", absId));
199 //assert(0); // GCB: This aborts reconstruction of raw simulations where simulation had more SM than default geometry,
200 //change to return 0, to avoid aborting good generations.
204 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,nModule,nIphi, nIeta,iphi,ieta);
206 // Check if channel is bad (dead or hot), in this case return 0.
207 // Gustavo: 15-12-09 In case of RAW data this selection is already done, but not in simulation.
208 // for the moment keep it here but remember to do the selection at the sdigitizer level
209 // and remove it from here
210 Int_t channelStatus = (Int_t)(fCaloPed->GetDeadMap(iSupMod))->GetBinContent(ieta,iphi);
211 if(channelStatus == AliCaloCalibPedestal::kHot || channelStatus == AliCaloCalibPedestal::kDead) {
212 AliDebug(2,Form("Tower from SM %d, ieta %d, iphi %d is BAD : status %d !!!",iSupMod,ieta,iphi, channelStatus));
215 //Check if time is too large or too small, indication of a noisy channel, remove in this case
216 if(time > fTimeMax || time < fTimeMin) return 0;
218 if (AliEMCALClusterizer::fgkIsInputCalibrated == kTRUE)
220 AliDebug(10, Form("Input already calibrated!"));
224 fADCchannelECA = fCalibData->GetADCchannel (iSupMod,ieta,iphi);
225 fADCpedestalECA = fCalibData->GetADCpedestal(iSupMod,ieta,iphi);
228 return -fADCpedestalECA + amp * fADCchannelECA ;
231 else{ //Return energy with default parameters if calibration is not available
233 if (AliEMCALClusterizer::fgkIsInputCalibrated == kTRUE)
235 AliDebug(10, Form("Input already calibrated!"));
239 return -fADCpedestalECA + amp * fADCchannelECA ;
244 //____________________________________________________________________________
245 void AliEMCALClusterizer::GetCalibrationParameters()
247 // Set calibration parameters:
248 // if calibration database exists, they are read from database,
249 // otherwise, they are taken from digitizer.
251 // It is a user responsilibity to open CDB before reconstruction,
253 // AliCDBStorage* storage = AliCDBManager::Instance()->GetStorage("local://CalibDB");
255 //Check if calibration is stored in data base
259 AliCDBEntry *entry = (AliCDBEntry*)
260 AliCDBManager::Instance()->Get("EMCAL/Calib/Data");
261 if (entry) fCalibData = (AliEMCALCalibData*) entry->GetObject();
265 AliFatal("Calibration parameters not found in CDB!");
269 //____________________________________________________________________________
270 void AliEMCALClusterizer::GetCaloCalibPedestal()
272 // Set calibration parameters:
273 // if calibration database exists, they are read from database,
274 // otherwise, they are taken from digitizer.
276 // It is a user responsilibity to open CDB before reconstruction,
278 // AliCDBStorage* storage = AliCDBManager::Instance()->GetStorage("local://CalibDB");
280 //Check if calibration is stored in data base
284 AliCDBEntry *entry = (AliCDBEntry*)
285 AliCDBManager::Instance()->Get("EMCAL/Calib/Pedestals");
286 if (entry) fCaloPed = (AliCaloCalibPedestal*) entry->GetObject();
290 AliFatal("Pedestal info not found in CDB!");
294 //____________________________________________________________________________
295 void AliEMCALClusterizer::Init()
297 // Make all memory allocations which can not be done in default constructor.
298 // Attach the Clusterizer task to the list of EMCAL tasks
300 AliRunLoader *rl = AliRunLoader::Instance();
301 if (rl->GetAliRun()){
302 AliEMCAL* emcal = dynamic_cast<AliEMCAL*>(rl->GetAliRun()->GetDetector("EMCAL"));
303 if(emcal)fGeom = emcal->GetGeometry();
307 fGeom = AliEMCALGeometry::GetInstance(AliEMCALGeometry::GetDefaultGeometryName());
310 AliDebug(1,Form("geom %p",fGeom));
313 gMinuit = new TMinuit(100) ;
316 for (i = 0; i < 8; i++)
318 for (i = 0; i < 3; i++) {
325 //____________________________________________________________________________
326 void AliEMCALClusterizer::InitParameters()
328 // Initializes the parameters for the Clusterizer
329 fNumberOfECAClusters = 0 ;
333 const AliEMCALRecParam* recParam = AliEMCALReconstructor::GetRecParam();
335 AliFatal("Reconstruction parameters for EMCAL not set!");
337 fECAClusteringThreshold = recParam->GetClusteringThreshold();
338 fECAW0 = recParam->GetW0();
339 fMinECut = recParam->GetMinECut();
340 fToUnfold = recParam->GetUnfold();
341 fECALocMaxCut = recParam->GetLocMaxCut();
342 fTimeCut = recParam->GetTimeCut();
343 fTimeMin = recParam->GetTimeMin();
344 fTimeMax = recParam->GetTimeMax();
346 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",
347 fECAClusteringThreshold,fECAW0,fMinECut,fToUnfold,fECALocMaxCut,fTimeCut, fTimeMin, fTimeMax));
352 for (i = 0; i < 8; i++) {
353 fSSPars[i] = recParam->GetSSPars(i);
354 }//end of loop over parameters
355 for (i = 0; i < 3; i++) {
356 fPar5[i] = recParam->GetPar5(i);
357 fPar6[i] = recParam->GetPar6(i);
358 }//end of loop over parameters
360 InitClusterUnfolding();
362 for (i = 0; i < 8; i++) {
363 AliDebug(1,Form("unfolding shower shape parameters: fSSPars=%f \n",fSSPars[i]));
365 for (i = 0; i < 3; i++) {
366 AliDebug(1,Form("unfolding parameter 5: fPar5=%f \n",fPar5[i]));
367 AliDebug(1,Form("unfolding parameter 6: fPar6=%f \n",fPar6[i]));
371 }// recparam not null
376 //____________________________________________________________________________
377 void AliEMCALClusterizer::Print(Option_t * /*option*/)const
379 // Print clusterizer parameters
381 TString message("\n") ;
383 if( strcmp(GetName(), "") !=0 ){
387 TString taskName(Version()) ;
389 printf("--------------- ");
390 printf("%s",taskName.Data()) ;
392 printf("Clusterizing digits: ");
393 printf("\n ECA Local Maximum cut = %f", fECALocMaxCut);
394 printf("\n ECA Logarithmic weight = %f", fECAW0);
396 printf("\nUnfolding on\n");
397 printf("Unfolding parameters: fSSpars: \n");
399 for (i = 0; i < 8; i++) {
400 printf("fSSPars[%d] = %f \n", i, fSSPars[i]);
402 printf("Unfolding parameter 5 and 6: fPar5 and fPar6: \n");
403 for (i = 0; i < 3; i++) {
404 printf("fPar5[%d] = %f \n", i, fPar5[i]);
405 printf("fPar6[%d] = %f \n", i, fPar6[i]);
409 printf("\nUnfolding off\n");
411 printf("------------------------------------------------------------------");
414 printf("AliEMCALClusterizer not initialized ") ;
417 //____________________________________________________________________________
418 void AliEMCALClusterizer::PrintRecPoints(Option_t * option)
420 // Prints list of RecPoints produced at the current pass of AliEMCALClusterizer
421 if(strstr(option,"deb")) {
422 printf("PrintRecPoints: Clusterization result:") ;
424 printf(" Found %d ECA Rec Points\n ",
425 fRecPoints->GetEntriesFast()) ;
428 if(strstr(option,"all")) {
429 if(strstr(option,"deb")) {
430 printf("\n-----------------------------------------------------------------------\n") ;
431 printf("Clusters in ECAL section\n") ;
432 printf("Index Ene(GeV) Multi Module GX GY GZ lX lY lZ Dispersion Lambda 1 Lambda 2 # of prim Primaries list\n") ;
435 for (index = 0 ; index < fRecPoints->GetEntries() ; index++) {
436 AliEMCALRecPoint * rp = dynamic_cast<AliEMCALRecPoint * >(fRecPoints->At(index)) ;
439 //rp->GetGlobalPosition(globalpos);
441 rp->GetLocalPosition(localpos);
443 rp->GetElipsAxis(lambda);
446 Int_t * primaries = rp->GetPrimaries(nprimaries);
448 if(strstr(option,"deb"))
449 printf("\n%6d %8.4f %3d %4.1f %4.1f %4.1f %4.1f %4.1f %4.1f %4.1f %4f %4f %2d : ",
450 rp->GetIndexInList(), rp->GetEnergy(), rp->GetMultiplicity(),
451 globalpos.X(), globalpos.Y(), globalpos.Z(), localpos.X(), localpos.Y(), localpos.Z(),
452 rp->GetDispersion(), lambda[0], lambda[1], nprimaries) ;
453 if(strstr(option,"deb")){
454 for (Int_t iprimary=0; iprimary<nprimaries; iprimary++) {
455 printf("%d ", primaries[iprimary] ) ;
461 if(strstr(option,"deb"))
462 printf("\n-----------------------------------------------------------------------\n");
466 //___________________________________________________________________
467 void AliEMCALClusterizer::PrintRecoInfo()
470 printf(" AliEMCALClusterizer::PrintRecoInfo() : version %s \n", Version() );
474 //____________________________________________________________________________
475 void AliEMCALClusterizer::SetInput(TTree *digitsTree)
477 // Read the digits from the input tree
478 TBranch *branch = digitsTree->GetBranch("EMCAL");
480 AliError("can't get the branch with the EMCAL digits !");
484 fDigitsArr = new TClonesArray("AliEMCALDigit",100);
485 branch->SetAddress(&fDigitsArr);
489 //____________________________________________________________________________
490 void AliEMCALClusterizer::SetOutput(TTree *clustersTree)
492 // Read the digits from the input tree
493 fTreeR = clustersTree;
495 AliDebug(9, "Making array for EMCAL clusters");
496 fRecPoints = new TObjArray(100) ;
498 Int_t bufsize = 32000;
499 fTreeR->Branch("EMCALECARP", "TObjArray", &fRecPoints, bufsize, split);
502 //___________________________________________________________________
503 void AliEMCALClusterizer::SetInputCalibrated(Bool_t val)
506 // input is calibrated - the case when we run already on ESD
508 AliEMCALClusterizer::fgkIsInputCalibrated = val;