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