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