]>
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 | ||
16 | /* | |
17 | $Log$ | |
6f1e466d | 18 | Revision 1.1.4.1 2000/05/08 14:55:03 cblume |
19 | Bug fixes | |
20 | ||
21 | Revision 1.1 2000/02/28 19:02:32 cblume | |
22 | Add new TRD classes | |
23 | ||
f7336fa3 | 24 | */ |
25 | ||
26 | /////////////////////////////////////////////////////////////////////////////// | |
27 | // // | |
28 | /////////////////////////////////////////////////////////////////////////////// | |
29 | ||
30 | #include "AliTRD.h" | |
31 | #include "AliTRDgeometry.h" | |
32 | #include "AliTRDsegmentArray.h" | |
33 | ||
34 | ClassImp(AliTRDsegmentArray) | |
35 | ||
36 | //_____________________________________________________________________________ | |
37 | AliTRDsegmentArray::AliTRDsegmentArray():AliTRDsegmentArrayBase() | |
38 | { | |
39 | // | |
40 | // Default constructor | |
41 | // | |
42 | ||
43 | } | |
44 | ||
45 | //_____________________________________________________________________________ | |
6f1e466d | 46 | AliTRDsegmentArray::AliTRDsegmentArray(Text_t *classname, Int_t n) |
47 | :AliTRDsegmentArrayBase(classname,n) | |
f7336fa3 | 48 | { |
49 | // | |
50 | // Constructor creating an array of AliTRDdataArray of size <n> | |
51 | // | |
52 | ||
53 | AliTRDdataArray *DataArray; | |
54 | ||
55 | for (Int_t i = 0; i < n; i++) { | |
56 | DataArray = (AliTRDdataArray *) AddSegment(i); | |
57 | } | |
58 | ||
59 | } | |
60 | ||
61 | //_____________________________________________________________________________ | |
62 | void AliTRDsegmentArray::Delete() | |
63 | { | |
64 | // | |
65 | // Deletes all detector segments from the array | |
66 | // | |
67 | ||
68 | for (Int_t iDet = 0; iDet < fNSegment; iDet++) { | |
69 | ClearSegment(iDet); | |
70 | } | |
71 | ||
72 | } | |
73 | ||
74 | //_____________________________________________________________________________ | |
75 | Bool_t AliTRDsegmentArray::LoadArray(const Char_t *branchname) | |
76 | { | |
77 | // | |
78 | // Loads all segments of the array from the branch <branchname> of | |
79 | // the digits tree | |
80 | // | |
81 | ||
82 | // Connect the digits tree | |
83 | fTree = gAlice->TreeD(); | |
84 | if (!fTree) return kFALSE; | |
85 | ||
86 | // Get the branch | |
87 | fBranch = fTree->GetBranch(branchname); | |
88 | if (!fBranch) return kFALSE; | |
89 | ||
90 | // Loop through all segments and read them from the tree | |
91 | Bool_t status = kTRUE; | |
92 | for (Int_t iSegment = 0; iSegment < fNSegment; iSegment++) { | |
93 | AliTRDdataArray *DataArray = (AliTRDdataArray *) fSegment->At(iSegment); | |
94 | if (!DataArray) { | |
95 | status = kFALSE; | |
96 | break; | |
97 | } | |
98 | fBranch->SetAddress(&DataArray); | |
99 | fBranch->GetEntry(iSegment); | |
100 | } | |
101 | ||
102 | return status; | |
103 | ||
104 | } | |
105 | ||
106 | //_____________________________________________________________________________ | |
107 | Bool_t AliTRDsegmentArray::StoreArray(const Char_t *branchname) | |
108 | { | |
109 | // | |
110 | // Stores all segments of the array in the branch <branchname> of | |
111 | // the digits tree | |
112 | // | |
113 | ||
114 | // Connect the digits tree | |
115 | fTree = gAlice->TreeD(); | |
116 | if (!fTree) return kFALSE; | |
117 | ||
118 | // Get the branch | |
119 | fBranch = fTree->GetBranch(branchname); | |
120 | if (!fBranch) return kFALSE; | |
121 | ||
122 | // Loop through all segments and fill them into the tree | |
123 | Bool_t status = kTRUE; | |
124 | for (Int_t iSegment = 0; iSegment < fNSegment; iSegment++) { | |
125 | const AliTRDdataArray *DataArray = | |
126 | (AliTRDdataArray *) AliTRDsegmentArrayBase::At(iSegment); | |
127 | if (!DataArray) { | |
128 | status = kFALSE; | |
129 | break; | |
130 | } | |
131 | fBranch->SetAddress(&DataArray); | |
132 | fBranch->Fill(); | |
133 | } | |
134 | ||
135 | return status; | |
136 | ||
137 | } | |
138 | ||
139 | //_____________________________________________________________________________ | |
140 | AliTRDdataArray *AliTRDsegmentArray::GetDataArray(Int_t det) | |
141 | { | |
142 | // | |
143 | // Returns the data array for a given detector | |
144 | // | |
145 | ||
146 | return ((AliTRDdataArray *) AliTRDsegmentArrayBase::At(det)); | |
147 | ||
148 | } | |
149 | ||
150 | //_____________________________________________________________________________ | |
151 | AliTRDdataArray *AliTRDsegmentArray::GetDataArray(Int_t pla, Int_t cha, Int_t sec) | |
152 | { | |
153 | // | |
154 | // Returns the data array for a given detector | |
155 | // | |
156 | ||
157 | if (gAlice) { | |
158 | ||
159 | AliTRDgeometry *Geo = ((AliTRD*) gAlice->GetDetector("TRD"))->GetGeometry(); | |
160 | Int_t det = Geo->GetDetector(pla,cha,sec); | |
161 | return GetDataArray(det); | |
162 | ||
163 | } | |
164 | else { | |
165 | ||
166 | printf("AliTRDsegmentArray::GetDigits -- "); | |
167 | printf("gAlice is not defined\n"); | |
168 | return NULL; | |
169 | ||
170 | } | |
171 | ||
172 | } |