]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/AliEMCALClusterizer.cxx
Fixed typo
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALClusterizer.cxx
CommitLineData
483b0559 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16/* $Id$ */
17
18//_________________________________________________________________________
19// Base class for the clusterization algorithm (pure abstract)
20//*--
21//*-- Author: Yves Schutz SUBATECH
ee08edde 22//
23// Clusterization mother class. Contains common methods/data members of different
24// clusterizers. GCB 2010
483b0559 25//////////////////////////////////////////////////////////////////////////////
26
27// --- ROOT system ---
c47157cd 28#include "TClonesArray.h"
29#include "TTree.h"
ee08edde 30#include <TFile.h>
31class TFolder;
32#include <TMath.h>
33#include <TMinuit.h>
34#include <TTree.h>
35class TSystem;
36#include <TBenchmark.h>
37#include <TBrowser.h>
38#include <TROOT.h>
483b0559 39
40// --- Standard library ---
ee08edde 41#include <cassert>
483b0559 42
43// --- AliRoot header files ---
483b0559 44#include "AliEMCALClusterizer.h"
ee08edde 45#include "AliEMCALReconstructor.h"
46#include "AliRunLoader.h"
47#include "AliRun.h"
c47157cd 48#include "AliLog.h"
ee08edde 49#include "AliEMCAL.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"
57class AliCDBStorage;
58#include "AliCDBEntry.h"
483b0559 59
60ClassImp(AliEMCALClusterizer)
61
62//____________________________________________________________________________
c47157cd 63AliEMCALClusterizer::AliEMCALClusterizer():
64 fDigitsArr(NULL),
65 fTreeR(NULL),
ee08edde 66 fRecPoints(NULL),
67 fGeom(NULL),
68 fCalibData(NULL),
69 fCaloPed(NULL),
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.)
483b0559 75{
76 // ctor
ee08edde 77
78 Init();
79
80}
81
82//____________________________________________________________________________
83AliEMCALClusterizer::AliEMCALClusterizer(AliEMCALGeometry* geometry):
84 fDigitsArr(NULL),
85 fTreeR(NULL),
86 fRecPoints(NULL),
87 fGeom(geometry),
88 fCalibData(NULL),
89 fCaloPed(NULL),
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.)
95{
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
99
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
102 // Init() ;
103 //
104
105 if (!fGeom)
106 {
107 AliFatal("Geometry not initialized.");
108 }
109
483b0559 110}
839828a6 111
ee08edde 112//____________________________________________________________________________
113AliEMCALClusterizer::AliEMCALClusterizer(AliEMCALGeometry* geometry, AliEMCALCalibData * calib, AliCaloCalibPedestal * caloped):
114 fDigitsArr(NULL),
115 fTreeR(NULL),
116 fRecPoints(NULL),
117 fGeom(geometry),
118 fCalibData(calib),
119 fCaloPed(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.)
125{
126 // ctor, geometry and calibration are initialized elsewhere.
127
128 if (!fGeom)
129 AliFatal("Geometry not initialized.");
130
131}
132
133
483b0559 134//____________________________________________________________________________
c47157cd 135AliEMCALClusterizer::~AliEMCALClusterizer()
483b0559 136{
c47157cd 137 // dtor
138 if (fDigitsArr) {
139 fDigitsArr->Delete();
140 delete fDigitsArr;
141 }
142 if (fRecPoints) {
143 fRecPoints->Delete();
144 delete fRecPoints;
145 }
18a21c7c 146}
147
ee08edde 148//____________________________________________________________________________
149Float_t AliEMCALClusterizer::Calibrate(const Float_t amp, const Float_t time, const Int_t absId)
150{
151
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.
155 if(fCalibData){
156
157 if (fGeom==0)
158 AliFatal("Did not get geometry from EMCALLoader") ;
159
160 Int_t iSupMod = -1;
161 Int_t nModule = -1;
162 Int_t nIphi = -1;
163 Int_t nIeta = -1;
164 Int_t iphi = -1;
165 Int_t ieta = -1;
166
167 Bool_t bCell = fGeom->GetCellIndex(absId, iSupMod, nModule, nIphi, nIeta) ;
168 if(!bCell) {
169 fGeom->PrintGeometry();
170 Error("Calibrate()"," Wrong cell id number : %i", absId);
171 assert(0);
172 }
173
174 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,nModule,nIphi, nIeta,iphi,ieta);
175
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));
183 return 0;
184 }
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;
187
188 fADCchannelECA = fCalibData->GetADCchannel (iSupMod,ieta,iphi);
189 fADCpedestalECA = fCalibData->GetADCpedestal(iSupMod,ieta,iphi);
190
191 return -fADCpedestalECA + amp * fADCchannelECA ;
192
193 }
194 else //Return energy with default parameters if calibration is not available
195 return -fADCpedestalECA + amp * fADCchannelECA ;
196
197}
198
199//____________________________________________________________________________
200void AliEMCALClusterizer::GetCalibrationParameters()
201{
202 // Set calibration parameters:
203 // if calibration database exists, they are read from database,
204 // otherwise, they are taken from digitizer.
205 //
206 // It is a user responsilibity to open CDB before reconstruction,
207 // for example:
208 // AliCDBStorage* storage = AliCDBManager::Instance()->GetStorage("local://CalibDB");
209
210 //Check if calibration is stored in data base
211
212 if(!fCalibData)
213 {
214 AliCDBEntry *entry = (AliCDBEntry*)
215 AliCDBManager::Instance()->Get("EMCAL/Calib/Data");
216 if (entry) fCalibData = (AliEMCALCalibData*) entry->GetObject();
217 }
218
219 if(!fCalibData)
220 AliFatal("Calibration parameters not found in CDB!");
221
222}
223
224//____________________________________________________________________________
225void AliEMCALClusterizer::GetCaloCalibPedestal()
226{
227 // Set calibration parameters:
228 // if calibration database exists, they are read from database,
229 // otherwise, they are taken from digitizer.
230 //
231 // It is a user responsilibity to open CDB before reconstruction,
232 // for example:
233 // AliCDBStorage* storage = AliCDBManager::Instance()->GetStorage("local://CalibDB");
234
235 //Check if calibration is stored in data base
236
237 if(!fCaloPed)
238 {
239 AliCDBEntry *entry = (AliCDBEntry*)
240 AliCDBManager::Instance()->Get("EMCAL/Calib/Pedestals");
241 if (entry) fCaloPed = (AliCaloCalibPedestal*) entry->GetObject();
242 }
243
244 if(!fCaloPed)
245 AliFatal("Pedestal info not found in CDB!");
246
247}
248
249//____________________________________________________________________________
250void AliEMCALClusterizer::Init()
251{
252 // Make all memory allocations which can not be done in default constructor.
253 // Attach the Clusterizer task to the list of EMCAL tasks
254
255 AliRunLoader *rl = AliRunLoader::Instance();
256 if (rl->GetAliRun() && rl->GetAliRun()->GetDetector("EMCAL"))
257 fGeom = dynamic_cast<AliEMCAL*>(rl->GetAliRun()->GetDetector("EMCAL"))->GetGeometry();
258 else
259 fGeom = AliEMCALGeometry::GetInstance(AliEMCALGeometry::GetDefaultGeometryName());
260
261 AliDebug(1,Form("geom %p",fGeom));
262
263 if(!gMinuit)
264 gMinuit = new TMinuit(100) ;
265
266}
267
268//____________________________________________________________________________
269void AliEMCALClusterizer::InitParameters()
270{
271 // Initializes the parameters for the Clusterizer
272 fNumberOfECAClusters = 0 ;
273 fCalibData = 0 ;
274 fCaloPed = 0 ;
275
276 const AliEMCALRecParam* recParam = AliEMCALReconstructor::GetRecParam();
277 if(!recParam) {
278 AliFatal("Reconstruction parameters for EMCAL not set!");
279 } else {
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();
289
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));
292 }
293
294}
295
296
297//____________________________________________________________________________
298void AliEMCALClusterizer::Print(Option_t * /*option*/)const
299{
300 // Print clusterizer parameters
301
302 TString message("\n") ;
303
304 if( strcmp(GetName(), "") !=0 ){
305
306 // Print parameters
307
308 TString taskName(Version()) ;
309
310 printf("--------------- ");
311 printf("%s",taskName.Data()) ;
312 printf(" ");
313 printf("Clusterizing digits: ");
314 printf("\n ECA Local Maximum cut = %f", fECALocMaxCut);
315 printf("\n ECA Logarithmic weight = %f", fECAW0);
316 if(fToUnfold)
317 printf("\nUnfolding on\n");
318 else
319 printf("\nUnfolding off\n");
320
321 printf("------------------------------------------------------------------");
322 }
323 else
324 printf("AliEMCALClusterizer not initialized ") ;
325}
326
327//____________________________________________________________________________
328void AliEMCALClusterizer::PrintRecPoints(Option_t * option)
329{
330 // Prints list of RecPoints produced at the current pass of AliEMCALClusterizer
331 if(strstr(option,"deb")) {
332 printf("PrintRecPoints: Clusterization result:") ;
333
334 printf(" Found %d ECA Rec Points\n ",
335 fRecPoints->GetEntriesFast()) ;
336 }
337
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") ;
343 }
344 Int_t index;
345 for (index = 0 ; index < fRecPoints->GetEntries() ; index++) {
346 AliEMCALRecPoint * rp = dynamic_cast<AliEMCALRecPoint * >(fRecPoints->At(index)) ;
347 TVector3 globalpos;
348 //rp->GetGlobalPosition(globalpos);
349 TVector3 localpos;
350 rp->GetLocalPosition(localpos);
351 Float_t lambda[2];
352 rp->GetElipsAxis(lambda);
353
354 Int_t nprimaries=0;
355 Int_t * primaries = rp->GetPrimaries(nprimaries);
356
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] ) ;
365 }
366 }
367 }
368
369 if(strstr(option,"deb"))
370 printf("\n-----------------------------------------------------------------------\n");
371 }
372}
373
374//___________________________________________________________________
375void AliEMCALClusterizer::PrintRecoInfo()
376{
377 //print reco version
378 printf(" AliEMCALClusterizer::PrintRecoInfo() : version %s \n", Version() );
379
380}
381
18a21c7c 382//____________________________________________________________________________
c47157cd 383void AliEMCALClusterizer::SetInput(TTree *digitsTree)
18a21c7c 384{
c47157cd 385 // Read the digits from the input tree
386 TBranch *branch = digitsTree->GetBranch("EMCAL");
387 if (!branch) {
388 AliError("can't get the branch with the EMCAL digits !");
389 return;
390 }
3f9ad99f 391 if (!fDigitsArr)
392 fDigitsArr = new TClonesArray("AliEMCALDigit",100);
c47157cd 393 branch->SetAddress(&fDigitsArr);
394 branch->GetEntry(0);
483b0559 395}
396
397//____________________________________________________________________________
c47157cd 398void AliEMCALClusterizer::SetOutput(TTree *clustersTree)
483b0559 399{
c47157cd 400 // Read the digits from the input tree
401 fTreeR = clustersTree;
402
403 AliDebug(9, "Making array for EMCAL clusters");
404 fRecPoints = new TObjArray(100) ;
405 Int_t split = 0;
406 Int_t bufsize = 32000;
407 fTreeR->Branch("EMCALECARP", "TObjArray", &fRecPoints, bufsize, split);
88cb7938 408}
ee08edde 409
410
411