Memory leak of AliPHOSEmcRecPoint is fixed
[u/mrichter/AliRoot.git] / PHOS / AliPHOSClusterizer.cxx
CommitLineData
d15a28e7 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//_________________________________________________________________________
b2a60966 17// Base class for the clusterization algorithm (pure abstract)
baef0810 18//*--
b2a60966 19//*-- Author: Yves Schutz SUBATECH
d15a28e7 20//////////////////////////////////////////////////////////////////////////////
21
9a2cdbdf 22#include <TClonesArray.h>
23#include <TTree.h>
d15a28e7 24
d15a28e7 25#include "AliPHOSClusterizer.h"
9a2cdbdf 26#include "AliPHOSDigit.h"
d76c31f4 27#include "AliLog.h"
75e8b893 28
d15a28e7 29ClassImp(AliPHOSClusterizer)
30
e68222ce 31AliPHOSCalibData * AliPHOSClusterizer::fgCalibData = 0 ;
32
d15a28e7 33//____________________________________________________________________________
0378398c 34AliPHOSClusterizer::AliPHOSClusterizer():
9a2cdbdf 35 fGeom(NULL),
9a2cdbdf 36 fDigitsArr(0),
37 fTreeR(0),
38 fEMCRecPoints(0),
39 fCPVRecPoints(0)
9a1398dd 40{
9a2cdbdf 41 // ctor
9a1398dd 42}
8d0f3f77 43
9a1398dd 44//____________________________________________________________________________
9a2cdbdf 45AliPHOSClusterizer::AliPHOSClusterizer(AliPHOSGeometry *geom):
46 fGeom(geom),
9a2cdbdf 47 fDigitsArr(0),
48 fTreeR(0),
49 fEMCRecPoints(0),
50 fCPVRecPoints(0)
d15a28e7 51{
52 // ctor
d76c31f4 53
d15a28e7 54}
55
56//____________________________________________________________________________
57AliPHOSClusterizer::~AliPHOSClusterizer()
58{
59 // dtor
9a2cdbdf 60 if (fDigitsArr) {
61 fDigitsArr->Delete();
62 delete fDigitsArr;
63 }
64 if (fEMCRecPoints) {
65 fEMCRecPoints->Delete();
66 delete fEMCRecPoints;
67 }
68 if (fCPVRecPoints) {
69 fCPVRecPoints->Delete();
70 delete fCPVRecPoints;
71 }
8d0f3f77 72}
73
9a2cdbdf 74//____________________________________________________________________________
75void AliPHOSClusterizer::SetInput(TTree * digitsTree)
76{
77 // Get the tree with digits and sets
78 // the input array with digits for PHOS
79 TBranch *branch = digitsTree->GetBranch("PHOS");
80 if (!branch) {
81 AliError("can't get the branch with the PHOS digits !");
82 return;
83 }
84 fDigitsArr = new TClonesArray("AliPHOSDigit",100);
85 branch->SetAddress(&fDigitsArr);
86 branch->GetEntry(0);
87}
88
89//____________________________________________________________________________
90void AliPHOSClusterizer::SetOutput(TTree * clustersTree)
91{
92 // Set the output clusters tree,
93 // creates the arrays for EMC and CPV,
94 // and set the corresponding branch addresses
95 fTreeR = clustersTree;
8d0f3f77 96
9a2cdbdf 97 AliDebug(9, "Making array for EMC clusters");
98 fEMCRecPoints = new TObjArray(100) ;
99 fEMCRecPoints->SetName("EMCRECPOINTS") ;
100 Int_t split = 0;
101 Int_t bufsize = 32000;
102 fTreeR->Branch("PHOSEmcRP", "TObjArray", &fEMCRecPoints, bufsize, split);
103
104 AliDebug(9, "Making array for CPV clusters");
105 fCPVRecPoints = new TObjArray(100) ;
106 fCPVRecPoints->SetName("CPVRECPOINTS") ;
107 fTreeR->Branch("PHOSCpvRP", "TObjArray", &fCPVRecPoints, bufsize, split);
108}