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()
138 //Already deleted in AliEMCALReconstructor.
140 // if(fGeom) delete fGeom;
141 // if(fCalibData) delete fCalibData;
142 // if(fCaloPed) delete fCaloPed;
145 // fDigitsArr->Clear("C");
146 // delete fDigitsArr;
149 // fRecPoints->Delete();
150 // delete fRecPoints;
154 //____________________________________________________________________________
155 Float_t AliEMCALClusterizer::Calibrate(const Float_t amp, const Float_t time, const Int_t absId)
158 // Convert digitized amplitude into energy.
159 // Calibration parameters are taken from calibration data base for raw data,
160 // or from digitizer parameters for simulated data.
164 AliFatal("Did not get geometry from EMCALLoader") ;
173 Bool_t bCell = fGeom->GetCellIndex(absId, iSupMod, nModule, nIphi, nIeta) ;
175 fGeom->PrintGeometry();
176 Error("Calibrate()"," Wrong cell id number : %i", absId);
180 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,nModule,nIphi, nIeta,iphi,ieta);
182 // Check if channel is bad (dead or hot), in this case return 0.
183 // Gustavo: 15-12-09 In case of RAW data this selection is already done, but not in simulation.
184 // for the moment keep it here but remember to do the selection at the sdigitizer level
185 // and remove it from here
186 Int_t channelStatus = (Int_t)(fCaloPed->GetDeadMap(iSupMod))->GetBinContent(ieta,iphi);
187 if(channelStatus == AliCaloCalibPedestal::kHot || channelStatus == AliCaloCalibPedestal::kDead) {
188 AliDebug(2,Form("Tower from SM %d, ieta %d, iphi %d is BAD : status %d !!!",iSupMod,ieta,iphi, channelStatus));
191 //Check if time is too large or too small, indication of a noisy channel, remove in this case
192 if(time > fTimeMax || time < fTimeMin) return 0;
194 fADCchannelECA = fCalibData->GetADCchannel (iSupMod,ieta,iphi);
195 fADCpedestalECA = fCalibData->GetADCpedestal(iSupMod,ieta,iphi);
197 return -fADCpedestalECA + amp * fADCchannelECA ;
200 else //Return energy with default parameters if calibration is not available
201 return -fADCpedestalECA + amp * fADCchannelECA ;
205 //____________________________________________________________________________
206 void AliEMCALClusterizer::GetCalibrationParameters()
208 // Set calibration parameters:
209 // if calibration database exists, they are read from database,
210 // otherwise, they are taken from digitizer.
212 // It is a user responsilibity to open CDB before reconstruction,
214 // AliCDBStorage* storage = AliCDBManager::Instance()->GetStorage("local://CalibDB");
216 //Check if calibration is stored in data base
220 AliCDBEntry *entry = (AliCDBEntry*)
221 AliCDBManager::Instance()->Get("EMCAL/Calib/Data");
222 if (entry) fCalibData = (AliEMCALCalibData*) entry->GetObject();
226 AliFatal("Calibration parameters not found in CDB!");
230 //____________________________________________________________________________
231 void AliEMCALClusterizer::GetCaloCalibPedestal()
233 // Set calibration parameters:
234 // if calibration database exists, they are read from database,
235 // otherwise, they are taken from digitizer.
237 // It is a user responsilibity to open CDB before reconstruction,
239 // AliCDBStorage* storage = AliCDBManager::Instance()->GetStorage("local://CalibDB");
241 //Check if calibration is stored in data base
245 AliCDBEntry *entry = (AliCDBEntry*)
246 AliCDBManager::Instance()->Get("EMCAL/Calib/Pedestals");
247 if (entry) fCaloPed = (AliCaloCalibPedestal*) entry->GetObject();
251 AliFatal("Pedestal info not found in CDB!");
255 //____________________________________________________________________________
256 void AliEMCALClusterizer::Init()
258 // Make all memory allocations which can not be done in default constructor.
259 // Attach the Clusterizer task to the list of EMCAL tasks
261 AliRunLoader *rl = AliRunLoader::Instance();
262 if (rl->GetAliRun() && dynamic_cast<AliEMCAL*>(rl->GetAliRun()->GetDetector("EMCAL")))
263 fGeom = dynamic_cast<AliEMCAL*>(rl->GetAliRun()->GetDetector("EMCAL"))->GetGeometry();
265 fGeom = AliEMCALGeometry::GetInstance(AliEMCALGeometry::GetDefaultGeometryName());
267 AliDebug(1,Form("geom %p",fGeom));
270 gMinuit = new TMinuit(100) ;
274 //____________________________________________________________________________
275 void AliEMCALClusterizer::InitParameters()
277 // Initializes the parameters for the Clusterizer
278 fNumberOfECAClusters = 0 ;
282 const AliEMCALRecParam* recParam = AliEMCALReconstructor::GetRecParam();
284 AliFatal("Reconstruction parameters for EMCAL not set!");
286 fECAClusteringThreshold = recParam->GetClusteringThreshold();
287 fECAW0 = recParam->GetW0();
288 fMinECut = recParam->GetMinECut();
289 fToUnfold = recParam->GetUnfold();
290 if(fToUnfold) AliWarning("Cluster Unfolding ON. Implementing only for eta=0 case!!!");
291 fECALocMaxCut = recParam->GetLocMaxCut();
292 fTimeCut = recParam->GetTimeCut();
293 fTimeMin = recParam->GetTimeMin();
294 fTimeMax = recParam->GetTimeMax();
296 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",
297 fECAClusteringThreshold,fECAW0,fMinECut,fToUnfold,fECALocMaxCut,fTimeCut, fTimeMin, fTimeMax));
303 //____________________________________________________________________________
304 void AliEMCALClusterizer::Print(Option_t * /*option*/)const
306 // Print clusterizer parameters
308 TString message("\n") ;
310 if( strcmp(GetName(), "") !=0 ){
314 TString taskName(Version()) ;
316 printf("--------------- ");
317 printf("%s",taskName.Data()) ;
319 printf("Clusterizing digits: ");
320 printf("\n ECA Local Maximum cut = %f", fECALocMaxCut);
321 printf("\n ECA Logarithmic weight = %f", fECAW0);
323 printf("\nUnfolding on\n");
325 printf("\nUnfolding off\n");
327 printf("------------------------------------------------------------------");
330 printf("AliEMCALClusterizer not initialized ") ;
333 //____________________________________________________________________________
334 void AliEMCALClusterizer::PrintRecPoints(Option_t * option)
336 // Prints list of RecPoints produced at the current pass of AliEMCALClusterizer
337 if(strstr(option,"deb")) {
338 printf("PrintRecPoints: Clusterization result:") ;
340 printf(" Found %d ECA Rec Points\n ",
341 fRecPoints->GetEntriesFast()) ;
344 if(strstr(option,"all")) {
345 if(strstr(option,"deb")) {
346 printf("\n-----------------------------------------------------------------------\n") ;
347 printf("Clusters in ECAL section\n") ;
348 printf("Index Ene(GeV) Multi Module GX GY GZ lX lY lZ Dispersion Lambda 1 Lambda 2 # of prim Primaries list\n") ;
351 for (index = 0 ; index < fRecPoints->GetEntries() ; index++) {
352 AliEMCALRecPoint * rp = dynamic_cast<AliEMCALRecPoint * >(fRecPoints->At(index)) ;
355 //rp->GetGlobalPosition(globalpos);
357 rp->GetLocalPosition(localpos);
359 rp->GetElipsAxis(lambda);
362 Int_t * primaries = rp->GetPrimaries(nprimaries);
364 if(strstr(option,"deb"))
365 printf("\n%6d %8.4f %3d %4.1f %4.1f %4.1f %4.1f %4.1f %4.1f %4.1f %4f %4f %2d : ",
366 rp->GetIndexInList(), rp->GetEnergy(), rp->GetMultiplicity(),
367 globalpos.X(), globalpos.Y(), globalpos.Z(), localpos.X(), localpos.Y(), localpos.Z(),
368 rp->GetDispersion(), lambda[0], lambda[1], nprimaries) ;
369 if(strstr(option,"deb")){
370 for (Int_t iprimary=0; iprimary<nprimaries; iprimary++) {
371 printf("%d ", primaries[iprimary] ) ;
377 if(strstr(option,"deb"))
378 printf("\n-----------------------------------------------------------------------\n");
382 //___________________________________________________________________
383 void AliEMCALClusterizer::PrintRecoInfo()
386 printf(" AliEMCALClusterizer::PrintRecoInfo() : version %s \n", Version() );
390 //____________________________________________________________________________
391 void AliEMCALClusterizer::SetInput(TTree *digitsTree)
393 // Read the digits from the input tree
394 TBranch *branch = digitsTree->GetBranch("EMCAL");
396 AliError("can't get the branch with the EMCAL digits !");
400 fDigitsArr = new TClonesArray("AliEMCALDigit",100);
401 branch->SetAddress(&fDigitsArr);
405 //____________________________________________________________________________
406 void AliEMCALClusterizer::SetOutput(TTree *clustersTree)
408 // Read the digits from the input tree
409 fTreeR = clustersTree;
411 AliDebug(9, "Making array for EMCAL clusters");
412 fRecPoints = new TObjArray(100) ;
414 Int_t bufsize = 32000;
415 fTreeR->Branch("EMCALECARP", "TObjArray", &fRecPoints, bufsize, split);