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