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():
70 fADCchannelECA(0.),fADCpedestalECA(0.),
71 fTimeMin(-1.),fTimeMax(1.),fTimeCut(1.),
72 fDefaultInit(kFALSE),fToUnfold(kFALSE),
73 fNumberOfECAClusters(0), fECAClusteringThreshold(0.),
74 fECALocMaxCut(0.),fECAW0(0.),fMinECut(0.)
82 //____________________________________________________________________________
83 AliEMCALClusterizer::AliEMCALClusterizer(AliEMCALGeometry* geometry):
90 fADCchannelECA(0.),fADCpedestalECA(0.),
91 fTimeMin(-1.),fTimeMax(1.),fTimeCut(1.),
92 fDefaultInit(kFALSE),fToUnfold(kFALSE),
93 fNumberOfECAClusters(0), fECAClusteringThreshold(0.),
94 fECALocMaxCut(0.),fECAW0(0.),fMinECut(0.)
96 // ctor with the indication of the file where header Tree and digits Tree are stored
97 // use this contructor to avoid usage of Init() which uses runloader
98 // change needed by HLT - MP
100 // Note for the future: the use on runloader should be avoided or optional at least
101 // another way is to make Init virtual and protected at least such that the deriving classes can overload
107 AliFatal("Geometry not initialized.");
112 //____________________________________________________________________________
113 AliEMCALClusterizer::AliEMCALClusterizer(AliEMCALGeometry* geometry, AliEMCALCalibData * calib, AliCaloCalibPedestal * caloped):
120 fADCchannelECA(0.),fADCpedestalECA(0.),
121 fTimeMin(-1.),fTimeMax(1.),fTimeCut(1.),
122 fDefaultInit(kFALSE),fToUnfold(kFALSE),
123 fNumberOfECAClusters(0), fECAClusteringThreshold(0.),
124 fECALocMaxCut(0.),fECAW0(0.),fMinECut(0.)
126 // ctor, geometry and calibration are initialized elsewhere.
129 AliFatal("Geometry not initialized.");
134 //____________________________________________________________________________
135 AliEMCALClusterizer::~AliEMCALClusterizer()
139 fDigitsArr->Delete();
143 fRecPoints->Delete();
148 //____________________________________________________________________________
149 Float_t AliEMCALClusterizer::Calibrate(const Float_t amp, const Float_t time, const Int_t absId)
152 // Convert digitized amplitude into energy.
153 // Calibration parameters are taken from calibration data base for raw data,
154 // or from digitizer parameters for simulated data.
158 AliFatal("Did not get geometry from EMCALLoader") ;
167 Bool_t bCell = fGeom->GetCellIndex(absId, iSupMod, nModule, nIphi, nIeta) ;
169 fGeom->PrintGeometry();
170 Error("Calibrate()"," Wrong cell id number : %i", absId);
174 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,nModule,nIphi, nIeta,iphi,ieta);
176 // Check if channel is bad (dead or hot), in this case return 0.
177 // Gustavo: 15-12-09 In case of RAW data this selection is already done, but not in simulation.
178 // for the moment keep it here but remember to do the selection at the sdigitizer level
179 // and remove it from here
180 Int_t channelStatus = (Int_t)(fCaloPed->GetDeadMap(iSupMod))->GetBinContent(ieta,iphi);
181 if(channelStatus == AliCaloCalibPedestal::kHot || channelStatus == AliCaloCalibPedestal::kDead) {
182 AliDebug(2,Form("Tower from SM %d, ieta %d, iphi %d is BAD : status %d !!!",iSupMod,ieta,iphi, channelStatus));
185 //Check if time is too large or too small, indication of a noisy channel, remove in this case
186 if(time > fTimeMax || time < fTimeMin) return 0;
188 fADCchannelECA = fCalibData->GetADCchannel (iSupMod,ieta,iphi);
189 fADCpedestalECA = fCalibData->GetADCpedestal(iSupMod,ieta,iphi);
191 return -fADCpedestalECA + amp * fADCchannelECA ;
194 else //Return energy with default parameters if calibration is not available
195 return -fADCpedestalECA + amp * fADCchannelECA ;
199 //____________________________________________________________________________
200 void AliEMCALClusterizer::GetCalibrationParameters()
202 // Set calibration parameters:
203 // if calibration database exists, they are read from database,
204 // otherwise, they are taken from digitizer.
206 // It is a user responsilibity to open CDB before reconstruction,
208 // AliCDBStorage* storage = AliCDBManager::Instance()->GetStorage("local://CalibDB");
210 //Check if calibration is stored in data base
214 AliCDBEntry *entry = (AliCDBEntry*)
215 AliCDBManager::Instance()->Get("EMCAL/Calib/Data");
216 if (entry) fCalibData = (AliEMCALCalibData*) entry->GetObject();
220 AliFatal("Calibration parameters not found in CDB!");
224 //____________________________________________________________________________
225 void AliEMCALClusterizer::GetCaloCalibPedestal()
227 // Set calibration parameters:
228 // if calibration database exists, they are read from database,
229 // otherwise, they are taken from digitizer.
231 // It is a user responsilibity to open CDB before reconstruction,
233 // AliCDBStorage* storage = AliCDBManager::Instance()->GetStorage("local://CalibDB");
235 //Check if calibration is stored in data base
239 AliCDBEntry *entry = (AliCDBEntry*)
240 AliCDBManager::Instance()->Get("EMCAL/Calib/Pedestals");
241 if (entry) fCaloPed = (AliCaloCalibPedestal*) entry->GetObject();
245 AliFatal("Pedestal info not found in CDB!");
249 //____________________________________________________________________________
250 void AliEMCALClusterizer::Init()
252 // Make all memory allocations which can not be done in default constructor.
253 // Attach the Clusterizer task to the list of EMCAL tasks
255 AliRunLoader *rl = AliRunLoader::Instance();
256 if (rl->GetAliRun() && rl->GetAliRun()->GetDetector("EMCAL"))
257 fGeom = dynamic_cast<AliEMCAL*>(rl->GetAliRun()->GetDetector("EMCAL"))->GetGeometry();
259 fGeom = AliEMCALGeometry::GetInstance(AliEMCALGeometry::GetDefaultGeometryName());
261 AliDebug(1,Form("geom %p",fGeom));
264 gMinuit = new TMinuit(100) ;
268 //____________________________________________________________________________
269 void AliEMCALClusterizer::InitParameters()
271 // Initializes the parameters for the Clusterizer
272 fNumberOfECAClusters = 0 ;
276 const AliEMCALRecParam* recParam = AliEMCALReconstructor::GetRecParam();
278 AliFatal("Reconstruction parameters for EMCAL not set!");
280 fECAClusteringThreshold = recParam->GetClusteringThreshold();
281 fECAW0 = recParam->GetW0();
282 fMinECut = recParam->GetMinECut();
283 fToUnfold = recParam->GetUnfold();
284 if(fToUnfold) AliWarning("Cluster Unfolding ON. Implementing only for eta=0 case!!!");
285 fECALocMaxCut = recParam->GetLocMaxCut();
286 fTimeCut = recParam->GetTimeCut();
287 fTimeMin = recParam->GetTimeMin();
288 fTimeMax = recParam->GetTimeMax();
290 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",
291 fECAClusteringThreshold,fECAW0,fMinECut,fToUnfold,fECALocMaxCut,fTimeCut, fTimeMin, fTimeMax));
297 //____________________________________________________________________________
298 void AliEMCALClusterizer::Print(Option_t * /*option*/)const
300 // Print clusterizer parameters
302 TString message("\n") ;
304 if( strcmp(GetName(), "") !=0 ){
308 TString taskName(Version()) ;
310 printf("--------------- ");
311 printf("%s",taskName.Data()) ;
313 printf("Clusterizing digits: ");
314 printf("\n ECA Local Maximum cut = %f", fECALocMaxCut);
315 printf("\n ECA Logarithmic weight = %f", fECAW0);
317 printf("\nUnfolding on\n");
319 printf("\nUnfolding off\n");
321 printf("------------------------------------------------------------------");
324 printf("AliEMCALClusterizer not initialized ") ;
327 //____________________________________________________________________________
328 void AliEMCALClusterizer::PrintRecPoints(Option_t * option)
330 // Prints list of RecPoints produced at the current pass of AliEMCALClusterizer
331 if(strstr(option,"deb")) {
332 printf("PrintRecPoints: Clusterization result:") ;
334 printf(" Found %d ECA Rec Points\n ",
335 fRecPoints->GetEntriesFast()) ;
338 if(strstr(option,"all")) {
339 if(strstr(option,"deb")) {
340 printf("\n-----------------------------------------------------------------------\n") ;
341 printf("Clusters in ECAL section\n") ;
342 printf("Index Ene(GeV) Multi Module GX GY GZ lX lY lZ Dispersion Lambda 1 Lambda 2 # of prim Primaries list\n") ;
345 for (index = 0 ; index < fRecPoints->GetEntries() ; index++) {
346 AliEMCALRecPoint * rp = dynamic_cast<AliEMCALRecPoint * >(fRecPoints->At(index)) ;
348 //rp->GetGlobalPosition(globalpos);
350 rp->GetLocalPosition(localpos);
352 rp->GetElipsAxis(lambda);
355 Int_t * primaries = rp->GetPrimaries(nprimaries);
357 if(strstr(option,"deb"))
358 printf("\n%6d %8.4f %3d %4.1f %4.1f %4.1f %4.1f %4.1f %4.1f %4.1f %4f %4f %2d : ",
359 rp->GetIndexInList(), rp->GetEnergy(), rp->GetMultiplicity(),
360 globalpos.X(), globalpos.Y(), globalpos.Z(), localpos.X(), localpos.Y(), localpos.Z(),
361 rp->GetDispersion(), lambda[0], lambda[1], nprimaries) ;
362 if(strstr(option,"deb")){
363 for (Int_t iprimary=0; iprimary<nprimaries; iprimary++) {
364 printf("%d ", primaries[iprimary] ) ;
369 if(strstr(option,"deb"))
370 printf("\n-----------------------------------------------------------------------\n");
374 //___________________________________________________________________
375 void AliEMCALClusterizer::PrintRecoInfo()
378 printf(" AliEMCALClusterizer::PrintRecoInfo() : version %s \n", Version() );
382 //____________________________________________________________________________
383 void AliEMCALClusterizer::SetInput(TTree *digitsTree)
385 // Read the digits from the input tree
386 TBranch *branch = digitsTree->GetBranch("EMCAL");
388 AliError("can't get the branch with the EMCAL digits !");
392 fDigitsArr = new TClonesArray("AliEMCALDigit",100);
393 branch->SetAddress(&fDigitsArr);
397 //____________________________________________________________________________
398 void AliEMCALClusterizer::SetOutput(TTree *clustersTree)
400 // Read the digits from the input tree
401 fTreeR = clustersTree;
403 AliDebug(9, "Making array for EMCAL clusters");
404 fRecPoints = new TObjArray(100) ;
406 Int_t bufsize = 32000;
407 fTreeR->Branch("EMCALECARP", "TObjArray", &fRecPoints, bufsize, split);