]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDsegmentArray.cxx
Last minute changes; ExB correction in AliTRDclusterizerV1; taking into account of...
[u/mrichter/AliRoot.git] / TRD / AliTRDsegmentArray.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 $Log$
18 Revision 1.6  2000/11/01 14:53:21  cblume
19 Merge with TRD-develop
20
21 Revision 1.1.4.3  2000/10/06 16:49:46  cblume
22 Made Getters const
23
24 Revision 1.1.4.2  2000/10/04 16:34:58  cblume
25 Replace include files by forward declarations
26
27 Revision 1.5  2000/10/02 21:28:19  fca
28 Removal of useless dependecies via forward declarations
29
30 Revision 1.4  2000/06/27 13:08:50  cblume
31 Changed to Copy(TObject &A) to appease the HP-compiler
32
33 Revision 1.3  2000/06/08 18:32:58  cblume
34 Make code compliant to coding conventions
35
36 Revision 1.2  2000/05/08 16:17:27  cblume
37 Merge TRD-develop
38
39 Revision 1.1.4.1  2000/05/08 14:55:03  cblume
40 Bug fixes
41
42 Revision 1.1  2000/02/28 19:02:32  cblume
43 Add new TRD classes
44
45 */
46
47 ///////////////////////////////////////////////////////////////////////////////
48 //                                                                           //
49 //  Alice segment manager class                                              //
50 //                                                                           //
51 ///////////////////////////////////////////////////////////////////////////////
52
53 #include <TTree.h>
54
55 #include "AliRun.h"
56
57 #include "AliTRD.h"
58 #include "AliTRDgeometry.h"
59 #include "AliTRDsegmentArray.h"
60 #include "AliTRDdataArray.h"
61
62 ClassImp(AliTRDsegmentArray)
63
64 //_____________________________________________________________________________
65 AliTRDsegmentArray::AliTRDsegmentArray():AliTRDsegmentArrayBase()
66 {
67   //
68   // Default constructor
69   //
70
71 }
72
73 //_____________________________________________________________________________
74 AliTRDsegmentArray::AliTRDsegmentArray(Text_t *classname, Int_t n)
75                    :AliTRDsegmentArrayBase(classname,n)
76 {
77   //
78   // Constructor creating an array of AliTRDdataArray of size <n>
79   //
80
81   AliTRDdataArray *dataArray;  
82
83   for (Int_t i = 0; i < n; i++) {
84     dataArray = (AliTRDdataArray *) AddSegment(i);
85   }
86
87 }
88
89 //_____________________________________________________________________________
90 AliTRDsegmentArray::AliTRDsegmentArray(AliTRDsegmentArray &a)
91 {
92   //
93   // AliTRDsegmentArray copy constructor
94   //
95
96   a.Copy(*this);
97
98 }
99
100 //_____________________________________________________________________________
101 AliTRDsegmentArray::~AliTRDsegmentArray()
102 {
103   //
104   // AliTRDsegmentArray destructor
105   //
106 }
107
108 //_____________________________________________________________________________
109 void AliTRDsegmentArray::Copy(TObject &a)
110 {
111   //
112   // Copy function
113   //
114
115   AliTRDsegmentArrayBase::Copy(a);
116
117 }
118
119 //_____________________________________________________________________________
120 void AliTRDsegmentArray::Delete()
121 {
122   //
123   // Deletes all detector segments from the array
124   //
125
126   for (Int_t iDet = 0; iDet < fNSegment; iDet++) {
127     ClearSegment(iDet);
128   }
129
130 }
131
132 //_____________________________________________________________________________
133 Bool_t AliTRDsegmentArray::LoadArray(const Char_t *branchname)
134 {
135   //
136   // Loads all segments of the array from the branch <branchname> of
137   // the digits tree
138   //
139
140   // Connect the digits tree
141   fTree = gAlice->TreeD();
142   if (!fTree) return kFALSE;
143
144   // Get the branch
145   fBranch = fTree->GetBranch(branchname);
146   if (!fBranch) return kFALSE;
147
148   // Loop through all segments and read them from the tree
149   Bool_t status = kTRUE;
150   for (Int_t iSegment = 0; iSegment < fNSegment; iSegment++) {
151     AliTRDdataArray *dataArray = (AliTRDdataArray *) fSegment->At(iSegment);
152     if (!dataArray) {
153       status = kFALSE;
154       break;    
155     }
156     fBranch->SetAddress(&dataArray);
157     fBranch->GetEntry(iSegment);
158   }
159
160   return status;
161
162 }
163
164 //_____________________________________________________________________________
165 Bool_t AliTRDsegmentArray::StoreArray(const Char_t *branchname)
166 {
167   //
168   // Stores all segments of the array in the branch <branchname> of 
169   // the digits tree
170   //
171
172   // Connect the digits tree
173   fTree = gAlice->TreeD();
174   if (!fTree) return kFALSE;
175
176   // Get the branch
177   fBranch = fTree->GetBranch(branchname);
178   if (!fBranch) return kFALSE;
179
180   // Loop through all segments and fill them into the tree
181   Bool_t status = kTRUE;
182   for (Int_t iSegment = 0; iSegment < fNSegment; iSegment++) {
183     const AliTRDdataArray *kDataArray = 
184          (AliTRDdataArray *) AliTRDsegmentArrayBase::At(iSegment);
185     if (!kDataArray) {
186       status = kFALSE;
187       break;
188     }
189     fBranch->SetAddress(&kDataArray);
190     fBranch->Fill();
191   }
192
193   return status;
194
195 }
196
197 //_____________________________________________________________________________
198 AliTRDdataArray *AliTRDsegmentArray::GetDataArray(Int_t det) const
199 {
200   //
201   // Returns the data array for a given detector
202   //
203
204   return ((AliTRDdataArray *) AliTRDsegmentArrayBase::At(det));
205
206 }
207
208 //_____________________________________________________________________________
209 AliTRDdataArray *AliTRDsegmentArray::GetDataArray(Int_t pla
210                                                 , Int_t cha, Int_t sec) const
211 {
212   //
213   // Returns the data array for a given detector
214   //
215
216   if (gAlice) {
217
218     AliTRDgeometry *geo = ((AliTRD*) gAlice->GetDetector("TRD"))->GetGeometry();  
219     Int_t det = geo->GetDetector(pla,cha,sec);
220     return GetDataArray(det);
221
222   }
223   else {
224
225     printf("AliTRDsegmentArray::GetDigits -- ");
226     printf("gAlice is not defined\n");
227     return NULL;
228
229   }
230
231 }