]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TRD/AliTRDclusterizerHLT.cxx
fix mem leak and compiler warning
[u/mrichter/AliRoot.git] / HLT / TRD / AliTRDclusterizerHLT.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 //                                                                           //
18 // TRD cluster finder                                                        //
19 //                                                                           //
20 ///////////////////////////////////////////////////////////////////////////////
21
22 #include <TF1.h>
23 #include <TTree.h>
24 #include <TH1.h>
25 #include <TFile.h>
26
27 #include "AliRunLoader.h"
28 #include "AliLoader.h"
29 #include "AliRawReader.h"
30 #include "AliLog.h"
31
32 #include "AliTRDclusterizerHLT.h"
33 #include "AliTRDgeometry.h"
34 #include "AliTRDdataArrayF.h"
35 #include "AliTRDdataArrayI.h"
36 #include "AliTRDdigitsManager.h"
37 #include "AliTRDfeeParam.h"
38 #include "AliTRDpadPlane.h"
39 #include "AliTRDrawData.h"
40 #include "AliTRDcalibDB.h"
41 #include "AliTRDSimParam.h"
42 #include "AliTRDcluster.h"
43
44 #include "Cal/AliTRDCalROC.h"
45 #include "Cal/AliTRDCalDet.h"
46
47 ClassImp(AliTRDclusterizerHLT)
48
49 //_____________________________________________________________________________
50 AliTRDclusterizerHLT::AliTRDclusterizerHLT() 
51   : AliTRDclusterizer()
52   , fTreeCreatedHere(kFALSE)
53   , fNclusters(-1)
54   , fRawDataSource(0)
55   , fFeeParams(0)
56 {
57   //
58   // AliTRDclusterizerHLT default constructor
59   //
60 }
61
62 //_____________________________________________________________________________
63 AliTRDclusterizerHLT::AliTRDclusterizerHLT(const Text_t *name, const Text_t *title) 
64   : AliTRDclusterizer(name,title)
65   , fTreeCreatedHere(kFALSE)
66   , fNclusters(-1)
67   , fRawDataSource(0)
68   , fFeeParams(0)
69 {
70   //
71   // AliTRDclusterizerHLT constructor
72   //
73 }
74
75 //_____________________________________________________________________________
76 AliTRDclusterizerHLT::AliTRDclusterizerHLT(const AliTRDclusterizerHLT &c)
77   : AliTRDclusterizer(c)
78   , fTreeCreatedHere(kFALSE)
79   , fNclusters(-1)
80   , fRawDataSource(0)
81   , fFeeParams(0)
82 {
83   //
84   // AliTRDclusterizerHLT copy constructor
85   //
86 }
87
88 //_____________________________________________________________________________
89 AliTRDclusterizerHLT::~AliTRDclusterizerHLT()
90 {
91   //
92   // AliTRDclusterizerHLT destructor
93   //
94   if (fTreeCreatedHere == kTRUE)
95     delete fClusterTree;
96   
97   delete fRawDataSource;
98   
99 }
100
101 //_____________________________________________________________________________
102 AliTRDclusterizerHLT &AliTRDclusterizerHLT::operator=(const AliTRDclusterizerHLT &c)
103 {
104   //
105   // Assignment operator
106   //
107
108   this->fRawDataSource = 0;
109   if (this != &c) ((AliTRDclusterizerHLT &) c).Copy(*this);
110   return *this;
111
112 }
113
114 //_____________________________________________________________________________
115 void AliTRDclusterizerHLT::Copy(TObject &c) const
116 {
117   //
118   // Copy function
119   //
120
121   AliFatal("Not implemented");
122
123   //use the parameter c - no warning...
124   ((AliTRDclusterizerHLT &) c).fDigitsManager = 0;
125 //   ((AliTRDclusterizerHLT &) c).fDigitsManager = 0;
126 //   ((AliTRDclusterizerHLT &) c).fTreeCreatedHere = kFALSE;
127 //   AliTRDclusterizer::Copy(c);
128
129 }
130
131 void AliTRDclusterizerHLT::SetRawVersion(Int_t iver)
132
133   //
134   // set the expected raw data version
135   //
136
137   AliTRDclusterizer::SetRawVersion(iver);  
138
139   if (fFeeParams == 0)
140     {
141       fFeeParams = AliTRDfeeParam::Instance();
142     }
143   
144   fFeeParams->SetRAWversion(iver);
145
146 //_____________________________________________________________________________
147 Bool_t AliTRDclusterizerHLT::ReadDigits(AliRawReaderMemory *rawReader)
148 {
149   //
150   // Reads the digits arrays from the ddl file
151   //
152
153   if (fRawDataSource == 0)
154     fRawDataSource = new AliTRDrawData;
155
156   //PH  fRawDataSource->SetRawVersion(fRawVersion);
157
158   fDigitsManager = fRawDataSource->Raw2Digits((AliRawReader*)rawReader);
159   //AliInfo(Form("Digits manager at 0x%x", fDigitsManager));
160   AliDebug(1, Form("Digits manager at 0x%x", fDigitsManager));
161   if (fDigitsManager)
162     return kTRUE;
163   else
164     return kFALSE;
165
166 }
167
168 //_____________________________________________________________________________
169 Bool_t AliTRDclusterizerHLT::InitClusterTree()
170 {
171   //
172   // This has to be called on HLT - creation of the cluster Tree used by the offline clusterizer (base class)
173   //
174   Bool_t kReturn = kFALSE;
175   if (fClusterTree == 0)
176     {
177       fClusterTree = new TTree("TRDclusterTree", "TRDclusterTree");
178       fTreeCreatedHere = kTRUE;
179     }
180
181   if (fClusterTree != 0)
182     kReturn = kTRUE;    
183
184   return kReturn;
185 }
186
187 //_____________________________________________________________________________
188 Bool_t AliTRDclusterizerHLT::InsertClusters(TObjArray *tobjarr, Int_t idet)
189 {
190   //
191   // Fill the tree with clusters - from a different component for example
192   //
193
194   //clear the current
195   ResetRecPoints();
196   delete fRecPoints;
197   fRecPoints = 0;
198
199   //set the pointer used in WriteClusters
200   fRecPoints = tobjarr;  
201   Bool_t kRet = kFALSE;
202   if (InitClusterTree())
203     kRet = WriteClusters(idet);  
204
205   fRecPoints = 0;
206
207   return kRet;
208 }
209 //_____________________________________________________________________________
210 Int_t AliTRDclusterizerHLT::GetNclusters()
211 {
212   //
213   // Returns the number of clusters AliTRDclusterizerHLT::fNclusters
214   // Count them first if fNclusters < 0
215   //
216
217   if (fNclusters < 0)
218     {
219       CountClusters();
220     }
221   return fNclusters;
222 }
223
224 //_____________________________________________________________________________
225 Bool_t AliTRDclusterizerHLT::ResetTree()
226 {
227   //
228   // Recreate the cluster tree
229   // 
230
231   //   if (fClusterTree != 0)
232   //     fClusterTree->Reset();
233   // well we'd better delete the whole tree and branches
234   delete fClusterTree;
235   fClusterTree = NULL;
236   fClusterTree = new TTree("TRDclusterTree", "TRDclusterTree");
237   if (fClusterTree)
238     {
239       fTreeCreatedHere = kTRUE;
240       fNclusters = -1;
241       //AliInfo("Tree Reset Successful");
242       AliDebug(1,Form("Tree Reset Successful"));
243     }
244   else
245     {
246       fTreeCreatedHere = kFALSE;
247       AliError("Reset Tree Error!\n");
248     }
249   
250   return fTreeCreatedHere;
251 }
252
253 //_____________________________________________________________________________
254 Int_t AliTRDclusterizerHLT::CountClusters()
255 {
256   //
257   // Count the clusters - runs over the cluster tree
258   //
259
260   fNclusters = -1;
261   if (fClusterTree == 0)
262     {
263       AliError("No tree to count clusters!\n");
264       return -1;
265     }
266   TList *lt = (TList*)fClusterTree->GetListOfBranches();
267   TIter it(lt);
268   it.Reset();
269   TBranch *tb = 0;
270   Int_t icount = 0;
271   while ((tb = (TBranch*)it.Next()) != 0)
272     {
273       TObjArray *clusters = 0;
274       tb->SetAddress(&clusters);
275       for (Int_t icb = 0; icb < tb->GetEntries(); icb++)
276         {
277           tb->GetEntry(icb);
278           icount += clusters->GetEntries();
279         }
280     }
281   fNclusters = icount;
282   //AliInfo(Form("Recounted clusters %d", fNclusters));
283   AliDebug(2, Form("Recounted clusters %d", fNclusters));
284
285   return fNclusters;
286 }