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