]>
Commit | Line | Data |
---|---|---|
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 | ||
88cb7938 | 16 | /* $Id$ */ |
f7336fa3 | 17 | |
18 | /////////////////////////////////////////////////////////////////////////////// | |
19 | // // | |
8230f242 | 20 | // Alice segment manager class // |
21 | // // | |
f7336fa3 | 22 | /////////////////////////////////////////////////////////////////////////////// |
23 | ||
94de3818 | 24 | #include <TTree.h> |
25 | ||
793ff80c | 26 | #include "AliRun.h" |
27 | ||
f7336fa3 | 28 | #include "AliTRDgeometry.h" |
29 | #include "AliTRDsegmentArray.h" | |
6244debe | 30 | #include "AliTRDdataArray.h" |
f7336fa3 | 31 | |
32 | ClassImp(AliTRDsegmentArray) | |
33 | ||
34 | //_____________________________________________________________________________ | |
35 | AliTRDsegmentArray::AliTRDsegmentArray():AliTRDsegmentArrayBase() | |
36 | { | |
37 | // | |
38 | // Default constructor | |
39 | // | |
40 | ||
41 | } | |
42 | ||
43 | //_____________________________________________________________________________ | |
8e8eae84 | 44 | AliTRDsegmentArray::AliTRDsegmentArray(const char *classname, Int_t n) |
6f1e466d | 45 | :AliTRDsegmentArrayBase(classname,n) |
f7336fa3 | 46 | { |
47 | // | |
48 | // Constructor creating an array of AliTRDdataArray of size <n> | |
49 | // | |
50 | ||
8230f242 | 51 | AliTRDdataArray *dataArray; |
f7336fa3 | 52 | |
53 | for (Int_t i = 0; i < n; i++) { | |
8230f242 | 54 | dataArray = (AliTRDdataArray *) AddSegment(i); |
f7336fa3 | 55 | } |
56 | ||
57 | } | |
58 | ||
8230f242 | 59 | //_____________________________________________________________________________ |
60 | AliTRDsegmentArray::AliTRDsegmentArray(AliTRDsegmentArray &a) | |
73ae7b59 | 61 | :AliTRDsegmentArrayBase(a) |
8230f242 | 62 | { |
63 | // | |
64 | // AliTRDsegmentArray copy constructor | |
65 | // | |
66 | ||
67 | a.Copy(*this); | |
68 | ||
69 | } | |
70 | ||
71 | //_____________________________________________________________________________ | |
72 | AliTRDsegmentArray::~AliTRDsegmentArray() | |
73 | { | |
74 | // | |
75 | // AliTRDsegmentArray destructor | |
76 | // | |
17eee78a | 77 | |
78 | Delete(); | |
79 | ||
8230f242 | 80 | } |
81 | ||
82 | //_____________________________________________________________________________ | |
e0d47c25 | 83 | void AliTRDsegmentArray::Copy(TObject &a) const |
8230f242 | 84 | { |
85 | // | |
86 | // Copy function | |
87 | // | |
88 | ||
89 | AliTRDsegmentArrayBase::Copy(a); | |
90 | ||
91 | } | |
92 | ||
f7336fa3 | 93 | //_____________________________________________________________________________ |
94 | void AliTRDsegmentArray::Delete() | |
95 | { | |
96 | // | |
97 | // Deletes all detector segments from the array | |
98 | // | |
99 | ||
100 | for (Int_t iDet = 0; iDet < fNSegment; iDet++) { | |
101 | ClearSegment(iDet); | |
102 | } | |
103 | ||
104 | } | |
105 | ||
106 | //_____________________________________________________________________________ | |
abaf1f1d | 107 | Bool_t AliTRDsegmentArray::LoadArray(const Char_t *branchname, TTree *tree) |
f7336fa3 | 108 | { |
109 | // | |
110 | // Loads all segments of the array from the branch <branchname> of | |
abaf1f1d | 111 | // the digits tree <tree> |
f7336fa3 | 112 | // |
113 | ||
abaf1f1d | 114 | fTree = tree; |
115 | ||
116 | // Connect the digits tree as default | |
117 | if (!fTree) { | |
118 | printf("AliTRDsegmentArray::LoadArray -- "); | |
119 | printf("Use default TreeD\n"); | |
120 | fTree = gAlice->TreeD(); | |
121 | if (!fTree) return kFALSE; | |
122 | } | |
f7336fa3 | 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 | //_____________________________________________________________________________ | |
abaf1f1d | 145 | Bool_t AliTRDsegmentArray::StoreArray(const Char_t *branchname, TTree *tree) |
f7336fa3 | 146 | { |
147 | // | |
148 | // Stores all segments of the array in the branch <branchname> of | |
abaf1f1d | 149 | // the digits tree <tree> |
f7336fa3 | 150 | // |
151 | ||
abaf1f1d | 152 | fTree = tree; |
153 | ||
154 | // Connect the digits tree as default | |
155 | if (!fTree) { | |
156 | printf("AliTRDsegmentArray::StoreArray -- "); | |
157 | printf("Use default TreeD\n"); | |
158 | fTree = gAlice->TreeD(); | |
159 | if (!fTree) return kFALSE; | |
160 | } | |
f7336fa3 | 161 | |
162 | // Get the branch | |
163 | fBranch = fTree->GetBranch(branchname); | |
164 | if (!fBranch) return kFALSE; | |
165 | ||
166 | // Loop through all segments and fill them into the tree | |
167 | Bool_t status = kTRUE; | |
168 | for (Int_t iSegment = 0; iSegment < fNSegment; iSegment++) { | |
8230f242 | 169 | const AliTRDdataArray *kDataArray = |
f7336fa3 | 170 | (AliTRDdataArray *) AliTRDsegmentArrayBase::At(iSegment); |
8230f242 | 171 | if (!kDataArray) { |
f7336fa3 | 172 | status = kFALSE; |
173 | break; | |
174 | } | |
8230f242 | 175 | fBranch->SetAddress(&kDataArray); |
f7336fa3 | 176 | fBranch->Fill(); |
177 | } | |
178 | ||
179 | return status; | |
180 | ||
181 | } | |
182 | ||
183 | //_____________________________________________________________________________ | |
793ff80c | 184 | AliTRDdataArray *AliTRDsegmentArray::GetDataArray(Int_t det) const |
f7336fa3 | 185 | { |
186 | // | |
187 | // Returns the data array for a given detector | |
188 | // | |
189 | ||
190 | return ((AliTRDdataArray *) AliTRDsegmentArrayBase::At(det)); | |
191 | ||
192 | } | |
193 | ||
194 | //_____________________________________________________________________________ | |
793ff80c | 195 | AliTRDdataArray *AliTRDsegmentArray::GetDataArray(Int_t pla |
196 | , Int_t cha, Int_t sec) const | |
f7336fa3 | 197 | { |
198 | // | |
199 | // Returns the data array for a given detector | |
200 | // | |
201 | ||
202 | if (gAlice) { | |
203 | ||
bdbb05bb | 204 | AliTRDgeometry *geo = AliTRDgeometry::GetGeometry(gAlice->GetRunLoader()); |
8230f242 | 205 | Int_t det = geo->GetDetector(pla,cha,sec); |
f7336fa3 | 206 | return GetDataArray(det); |
207 | ||
208 | } | |
209 | else { | |
210 | ||
211 | printf("AliTRDsegmentArray::GetDigits -- "); | |
212 | printf("gAlice is not defined\n"); | |
213 | return NULL; | |
214 | ||
215 | } | |
216 | ||
217 | } |