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),
65 fJustClusters(kFALSE),
72 fADCchannelECA(0.),fADCpedestalECA(0.), fTimeECA(0.),
73 fTimeMin(-1.),fTimeMax(1.),fTimeCut(1.),
74 fDefaultInit(kFALSE),fToUnfold(kFALSE),
75 fNumberOfECAClusters(0), fECAClusteringThreshold(0.),
76 fECALocMaxCut(0.),fECAW0(0.),fMinECut(0.),
77 fClusterUnfolding(NULL)
84 //____________________________________________________________________________
85 AliEMCALClusterizer::AliEMCALClusterizer(AliEMCALGeometry* geometry):
86 fIsInputCalibrated(kFALSE),
87 fJustClusters(kFALSE),
94 fADCchannelECA(0.),fADCpedestalECA(0.), fTimeECA(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.
104 // Note for the future: the use on runloader should be avoided or optional at least.
105 // Another way is to make Init virtual and protected at least
106 // such that the deriving classes can overload Init();
110 AliFatal("Geometry not initialized.");
113 for (i = 0; i < 8; i++)
115 for (i = 0; i < 3; i++) {
121 //____________________________________________________________________________
122 AliEMCALClusterizer::AliEMCALClusterizer(AliEMCALGeometry *geometry,
123 AliEMCALCalibData *calib,
124 AliCaloCalibPedestal *caloped):
125 fIsInputCalibrated(kFALSE),
126 fJustClusters(kFALSE),
133 fADCchannelECA(0.),fADCpedestalECA(0.), fTimeECA(0.),
134 fTimeMin(-1.),fTimeMax(1.),fTimeCut(1.),
135 fDefaultInit(kFALSE),fToUnfold(kFALSE),
136 fNumberOfECAClusters(0), fECAClusteringThreshold(0.),
137 fECALocMaxCut(0.),fECAW0(0.),fMinECut(0.),
138 fClusterUnfolding(NULL)
140 // ctor, geometry and calibration are initialized elsewhere.
143 AliFatal("Geometry not initialized.");
146 for (i = 0; i < 8; i++)
148 for (i = 0; i < 3; i++) {
154 //____________________________________________________________________________
155 AliEMCALClusterizer::~AliEMCALClusterizer()
158 //Already deleted in AliEMCALReconstructor.
160 if(fClusterUnfolding) delete fClusterUnfolding;
162 // make sure we delete the rec points array
165 //Delete digits array
170 //____________________________________________________________________________
171 void AliEMCALClusterizer::DeleteRecPoints()
173 // free the cluster array
176 AliDebug(2, "Deleting fRecPoints.");
177 fRecPoints->Delete();
183 //____________________________________________________________________________
184 void AliEMCALClusterizer::DeleteDigits()
186 // free the digits array
189 AliDebug(2, "Deleting fDigitsArr.");
190 fDigitsArr->Clear("C");
196 //____________________________________________________________________________
197 void AliEMCALClusterizer::Calibrate(Float_t & amp, Float_t & time, const Int_t absId)
199 // Convert digitized amplitude into energy, calibrate time
200 // Calibration parameters are taken from OCDB : OCDB/EMCAL/Calib/Data
202 //Check if time is too large or too small, indication of a noisy channel, remove in this case
203 if(time > fTimeMax || time < fTimeMin) {
209 //Return energy with default parameters if calibration is not available
210 if (!fCalibData && !fCaloPed) {
211 if (fIsInputCalibrated == kTRUE)
213 AliDebug(10, Form("Input already calibrated!"));
217 AliFatal("OCDB calibration and bad map parameters are not available");
223 AliFatal("Did not get geometry from EMCALLoader") ;
232 Bool_t bCell = fGeom->GetCellIndex(absId, iSupMod, nModule, nIphi, nIeta) ;
234 fGeom->PrintGeometry();
235 AliError(Form("Wrong cell id number : %i", absId));
236 //assert(0); // GCB: This aborts reconstruction of raw simulations
237 //where simulation had more SM than default geometry,
238 //change to return 0, to avoid aborting good generations.
244 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,nModule,nIphi, nIeta,iphi,ieta);
246 // Check if channel is bad (dead or hot), in this case return 0.
247 // Gustavo: 15-12-09 In case of RAW data this selection is already done, but not in simulation.
248 // for the moment keep it here but remember to do the selection at the sdigitizer level
249 // and remove it from here
251 Int_t channelStatus = (Int_t)(fCaloPed->GetDeadMap(iSupMod))->GetBinContent(ieta,iphi);
252 if(channelStatus == AliCaloCalibPedestal::kHot || channelStatus == AliCaloCalibPedestal::kDead) {
253 AliDebug(2,Form("Tower from SM %d, ieta %d, iphi %d is BAD : status %d !!!",iSupMod,ieta,iphi, channelStatus));
260 if (fIsInputCalibrated || !fCalibData)
262 AliDebug(10, Form("Input already calibrated!"));
266 fADCchannelECA = fCalibData->GetADCchannel (iSupMod,ieta,iphi);
267 fADCpedestalECA = fCalibData->GetADCpedestal(iSupMod,ieta,iphi);
268 fTimeECA = fCalibData->GetTimeChannel(iSupMod,ieta,iphi);
271 amp = amp * fADCchannelECA - fADCpedestalECA ;
275 //____________________________________________________________________________
276 void AliEMCALClusterizer::GetCalibrationParameters()
278 // Set calibration parameters:
279 // If calibration database exists, they are read from database,
280 // otherwise, they are taken from digitizer.
281 // It is a user responsilibity to open CDB before reconstruction,
283 // AliCDBStorage* storage = AliCDBManager::Instance()->GetStorage("local://CalibDB");
285 if (fIsInputCalibrated)
288 //Check if calibration is stored in data base
291 AliCDBEntry *entry = (AliCDBEntry*)
292 AliCDBManager::Instance()->Get("EMCAL/Calib/Data");
293 if (entry) fCalibData = (AliEMCALCalibData*) entry->GetObject();
297 AliFatal("Calibration parameters not found in CDB!");
300 //____________________________________________________________________________
301 void AliEMCALClusterizer::GetCaloCalibPedestal()
303 // Set calibration parameters:
304 // if calibration database exists, they are read from database,
305 // otherwise, they are taken from digitizer.
307 // It is a user responsilibity to open CDB before reconstruction,
309 // AliCDBStorage* storage = AliCDBManager::Instance()->GetStorage("local://CalibDB");
311 if (fIsInputCalibrated)
314 // Check if calibration is stored in data base
317 AliCDBEntry *entry = (AliCDBEntry*)
318 AliCDBManager::Instance()->Get("EMCAL/Calib/Pedestals");
319 if (entry) fCaloPed = (AliCaloCalibPedestal*) entry->GetObject();
323 AliFatal("Pedestal info not found in CDB!");
326 //____________________________________________________________________________
327 void AliEMCALClusterizer::Init()
329 // Make all memory allocations which can not be done in default constructor.
330 // Attach the Clusterizer task to the list of EMCAL tasks
332 AliRunLoader *rl = AliRunLoader::Instance();
333 if (rl->GetAliRun()){
334 AliEMCAL* emcal = dynamic_cast<AliEMCAL*>(rl->GetAliRun()->GetDetector("EMCAL"));
335 if(emcal)fGeom = emcal->GetGeometry();
339 fGeom = AliEMCALGeometry::GetInstance(AliEMCALGeometry::GetDefaultGeometryName());
342 AliDebug(1,Form("geom %p",fGeom));
345 gMinuit = new TMinuit(100) ;
348 for (i = 0; i < 8; i++)
350 for (i = 0; i < 3; i++) {
356 //____________________________________________________________________________
357 void AliEMCALClusterizer::InitParameters()
359 // Initializes the parameters for the Clusterizer from AliEMCALReconstructor::GetRecParam().
361 return InitParameters(AliEMCALReconstructor::GetRecParam());
364 //____________________________________________________________________________
365 void AliEMCALClusterizer::InitParameters(const AliEMCALRecParam* recParam)
367 // Initializes the parameters for the Clusterizer
369 fNumberOfECAClusters = 0 ;
374 AliFatal("Reconstruction parameters for EMCAL not set!");
377 fECAClusteringThreshold = recParam->GetClusteringThreshold();
378 fECAW0 = recParam->GetW0();
379 fMinECut = recParam->GetMinECut();
380 fToUnfold = recParam->GetUnfold();
381 fECALocMaxCut = recParam->GetLocMaxCut();
382 fTimeCut = recParam->GetTimeCut();
383 fTimeMin = recParam->GetTimeMin();
384 fTimeMax = recParam->GetTimeMax();
387 SetNRowDiff(recParam->GetNRowDiff());
388 SetNColDiff(recParam->GetNColDiff());
390 AliDebug(1,Form("Reconstruction parameters: fECAClusteringThreshold=%.3f GeV, fECAW=%.3f, fMinECut=%.3f GeV, "
391 "fToUnfold=%d, fECALocMaxCut=%.3f GeV, fTimeCut=%e s,fTimeMin=%e s,fTimeMax=%e s",
392 fECAClusteringThreshold,fECAW0,fMinECut,fToUnfold,fECALocMaxCut,fTimeCut, fTimeMin, fTimeMax));
396 for (i = 0; i < 8; i++) {
397 fSSPars[i] = recParam->GetSSPars(i);
398 } //end of loop over parameters
399 for (i = 0; i < 3; i++) {
400 fPar5[i] = recParam->GetPar5(i);
401 fPar6[i] = recParam->GetPar6(i);
402 } //end of loop over parameters
404 InitClusterUnfolding();
406 for (i = 0; i < 8; i++) {
407 AliDebug(1,Form("unfolding shower shape parameters: fSSPars=%f \n",fSSPars[i]));
409 for (i = 0; i < 3; i++) {
410 AliDebug(1,Form("unfolding parameter 5: fPar5=%f \n",fPar5[i]));
411 AliDebug(1,Form("unfolding parameter 6: fPar6=%f \n",fPar6[i]));
416 //____________________________________________________________________________
417 void AliEMCALClusterizer::Print(Option_t * /*option*/)const
419 // Print clusterizer parameters
421 TString message("\n") ;
423 if (strcmp(GetName(),"") == 0) {
424 printf("AliEMCALClusterizer not initialized\n");
429 TString taskName(Version()) ;
431 printf("--------------- ");
432 printf("%s",taskName.Data()) ;
434 printf("Clusterizing digits: ");
435 printf("\n ECA Local Maximum cut = %f", fECALocMaxCut);
436 printf("\n ECA Logarithmic weight = %f", fECAW0);
438 printf("\nUnfolding on\n");
439 printf("Unfolding parameters: fSSpars: \n");
441 for (i = 0; i < 8; i++) {
442 printf("fSSPars[%d] = %f \n", i, fSSPars[i]);
444 printf("Unfolding parameter 5 and 6: fPar5 and fPar6: \n");
445 for (i = 0; i < 3; i++) {
446 printf("fPar5[%d] = %f \n", i, fPar5[i]);
447 printf("fPar6[%d] = %f \n", i, fPar6[i]);
451 printf("\nUnfolding off\n");
453 printf("------------------------------------------------------------------");
456 //____________________________________________________________________________
457 void AliEMCALClusterizer::PrintRecPoints(Option_t * option)
459 // Prints list of RecPoints produced at the current pass of AliEMCALClusterizer
461 if (strstr(option,"deb")) {
462 printf("PrintRecPoints: Clusterization result:") ;
463 printf(" Found %d ECA Rec Points\n ",
464 fRecPoints->GetEntriesFast()) ;
467 if (strstr(option,"all")) {
468 if (strstr(option,"deb")) {
469 printf("\n-----------------------------------------------------------------------\n") ;
470 printf("Clusters in ECAL section\n") ;
471 printf("Index Ene(GeV) Multi Module GX GY GZ lX lY lZ Dispersion Lambda 1 Lambda 2 # of prim Primaries list\n") ;
474 for (index = 0 ; index < fRecPoints->GetEntries() ; index++) {
475 AliEMCALRecPoint * rp = dynamic_cast<AliEMCALRecPoint * >(fRecPoints->At(index)) ;
480 //rp->GetGlobalPosition(globalpos);
482 rp->GetLocalPosition(localpos);
484 rp->GetElipsAxis(lambda);
487 Int_t * primaries = rp->GetPrimaries(nprimaries);
488 if(strstr(option,"deb"))
489 printf("\n%6d %8.4f %3d %4.1f %4.1f %4.1f %4.1f %4.1f %4.1f %4.1f %4f %4f %2d : ",
490 rp->GetIndexInList(), rp->GetEnergy(), rp->GetMultiplicity(),
491 globalpos.X(), globalpos.Y(), globalpos.Z(), localpos.X(), localpos.Y(), localpos.Z(),
492 rp->GetDispersion(), lambda[0], lambda[1], nprimaries) ;
493 if(strstr(option,"deb")){
494 for (Int_t iprimary=0; iprimary<nprimaries; iprimary++) {
495 printf("%d ", primaries[iprimary] ) ;
500 if(strstr(option,"deb"))
501 printf("\n-----------------------------------------------------------------------\n");
505 //___________________________________________________________________
506 void AliEMCALClusterizer::PrintRecoInfo()
508 // Print reco version
510 printf(" AliEMCALClusterizer::PrintRecoInfo() : version %s \n", Version() );
513 //____________________________________________________________________________
514 void AliEMCALClusterizer::SetInput(TTree *digitsTree)
516 // Read the digits from the input tree
518 TBranch *branch = digitsTree->GetBranch("EMCAL");
520 AliError("can't get the branch with the EMCAL digits !");
524 fDigitsArr = new TClonesArray("AliEMCALDigit",100);
525 branch->SetAddress(&fDigitsArr);
529 //____________________________________________________________________________
530 void AliEMCALClusterizer::SetOutput(TTree *clustersTree)
532 // Read the digits from the input tree
534 AliDebug(9, "Making array for EMCAL clusters");
535 fRecPoints = new TObjArray(1000);
537 fTreeR = clustersTree;
539 Int_t bufsize = 32000;
540 fTreeR->Branch("EMCALECARP", "TObjArray", &fRecPoints, bufsize, split);
544 //___________________________________________________________________
545 void AliEMCALClusterizer::SetInputCalibrated(Bool_t val)
547 // Flag to indicate that input is calibrated - the case when we run already on ESD
549 fIsInputCalibrated = val;
552 //___________________________________________________________________
553 void AliEMCALClusterizer::SetJustClusters(Bool_t val)
555 // Flag to indicate that we are running on ESDs, when calling
556 // rp->EvalAll(fECAW0,fDigitsArr,fJustClusters); in derived classes