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