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