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