]>
Commit | Line | Data |
---|---|---|
c667f499 | 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 purpeateose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | // $Id$ | |
17 | // $MpId$ | |
18 | ||
19 | #include "AliMpTrigger.h" | |
20 | ||
21 | #include "AliLog.h" | |
22 | #include "AliMpSlat.h" | |
23 | ||
24 | #include "Riostream.h" | |
25 | #include "TArrayI.h" | |
26 | #include "TObjArray.h" | |
27 | ||
28 | ClassImp(AliMpTrigger) | |
29 | ||
30 | namespace | |
31 | { | |
32 | Bool_t IsEqual(Double_t a, Double_t b, Double_t precision) | |
33 | { | |
34 | if (b) | |
35 | { | |
36 | Double_t diff = TMath::Abs(b-a)/TMath::Abs(b); | |
37 | if ( diff < precision ) | |
38 | { | |
39 | return kTRUE; | |
40 | } | |
41 | } | |
42 | else | |
43 | { | |
44 | if ( !a ) return kTRUE; | |
45 | } | |
46 | return kFALSE; | |
47 | } | |
48 | } | |
49 | ||
50 | //_____________________________________________________________________________ | |
51 | AliMpTrigger::AliMpTrigger() | |
52 | : TObject(), fId(""), fPlaneType(kNonBendingPlane), | |
53 | fMaxNofPadsY(0), fDX(0), fDY(0) | |
54 | { | |
55 | } | |
56 | ||
57 | //_____________________________________________________________________________ | |
58 | AliMpTrigger::AliMpTrigger(const char* slatType, AliMpPlaneType bendingOrNot) | |
59 | : TObject(), fId(slatType), fPlaneType(bendingOrNot), | |
60 | fMaxNofPadsY(0), fDX(0), fDY(0) | |
61 | { | |
62 | } | |
63 | ||
64 | //_____________________________________________________________________________ | |
65 | AliMpTrigger::~AliMpTrigger() | |
66 | { | |
67 | AliDebug(1,Form("this=%p before fSlats.Delete()",this)); | |
68 | fSlats.Delete(); | |
69 | AliDebug(1,Form("this=%p after fSlats.Delete()",this)); | |
70 | } | |
71 | ||
72 | //_____________________________________________________________________________ | |
73 | Bool_t | |
74 | AliMpTrigger::AdoptLayer(AliMpSlat* slat) | |
75 | { | |
76 | AliDebug(1,Form("%s is adopting %s :\n", | |
77 | GetID(),slat->GetID())); | |
78 | ||
79 | // Check that we keep our size constant. | |
80 | ||
81 | const Double_t precision = 1E-3; | |
82 | ||
83 | if ( GetSize() > 0 && | |
84 | ( !::IsEqual(slat->DX(),fDX,precision) || | |
85 | !::IsEqual(slat->DY(),fDY,precision) ) | |
86 | ) | |
87 | { | |
88 | AliError(Form("In %s trying to add a layer (%e,%e) of a different size than " | |
89 | "mine (%e,%e)\n",GetID(),slat->DX(),slat->DY(), | |
90 | fDX,fDY)); | |
91 | return kFALSE; | |
92 | } | |
93 | fSlats.Add(slat); | |
94 | fMaxNofPadsY = std::max(slat->GetMaxNofPadsY(),fMaxNofPadsY); | |
95 | fDX = std::max(fDX,slat->DX()); | |
96 | fDY = std::max(fDY,slat->DY()); | |
97 | return kTRUE; | |
98 | } | |
99 | ||
100 | //_____________________________________________________________________________ | |
101 | Double_t | |
102 | AliMpTrigger::DX() const | |
103 | { | |
104 | return fDX; | |
105 | } | |
106 | ||
107 | //_____________________________________________________________________________ | |
108 | Double_t | |
109 | AliMpTrigger::DY() const | |
110 | { | |
111 | return fDY; | |
112 | } | |
113 | ||
114 | //_____________________________________________________________________________ | |
115 | void | |
116 | AliMpTrigger::GetAllLocalBoardNumbers(TArrayI& lbn) const | |
117 | { | |
118 | Int_t n(0); | |
119 | for ( Int_t i = 0; i < GetSize(); ++i ) | |
120 | { | |
121 | n += GetLayer(i)->GetNofElectronicCards(); | |
122 | } | |
123 | ||
124 | lbn.Set(n); | |
125 | ||
126 | Int_t index(0); | |
127 | ||
128 | for ( Int_t i = 0; i < GetSize(); ++i ) | |
129 | { | |
130 | TArrayI slbn; | |
131 | GetLayer(i)->GetAllElectronicCardNumbers(slbn); | |
132 | for ( Int_t j = 0; j < slbn.GetSize(); ++j ) | |
133 | { | |
134 | lbn[index] = slbn[j]; | |
135 | ++index; | |
136 | } | |
137 | } | |
138 | } | |
139 | ||
140 | //_____________________________________________________________________________ | |
141 | const char* | |
142 | AliMpTrigger::GetID() const | |
143 | { | |
144 | return fId.Data(); | |
145 | } | |
146 | ||
147 | //_____________________________________________________________________________ | |
148 | const char* | |
149 | AliMpTrigger::GetName() const | |
150 | { | |
151 | TString name(GetID()); | |
152 | if ( fPlaneType == kBendingPlane ) | |
153 | { | |
154 | name += ".Bending"; | |
155 | } | |
156 | else if ( fPlaneType == kNonBendingPlane ) | |
157 | { | |
158 | name += ".NonBending"; | |
159 | } | |
160 | else | |
161 | { | |
162 | name += ".Invalid"; | |
163 | } | |
164 | return name.Data(); | |
165 | } | |
166 | ||
167 | //_____________________________________________________________________________ | |
168 | AliMpSlat* | |
169 | AliMpTrigger::GetLayer(int layer) const | |
170 | { | |
171 | if ( IsLayerValid(layer) ) | |
172 | { | |
173 | return (AliMpSlat*)fSlats.At(layer); | |
174 | } | |
175 | return 0; | |
176 | } | |
177 | ||
178 | //_____________________________________________________________________________ | |
179 | Int_t | |
180 | AliMpTrigger::GetNofPadsX() const | |
181 | { | |
182 | if ( !GetSize() ) return -1; | |
183 | if ( GetLayer(0) ) | |
184 | { | |
185 | return GetLayer(0)->GetNofPadsX(); | |
186 | } | |
187 | return -1; | |
188 | } | |
189 | ||
190 | //_____________________________________________________________________________ | |
191 | Int_t | |
192 | AliMpTrigger::GetMaxNofPadsY() const | |
193 | { | |
194 | return fMaxNofPadsY; | |
195 | } | |
196 | ||
197 | //_____________________________________________________________________________ | |
198 | Int_t | |
199 | AliMpTrigger::GetSize() const | |
200 | { | |
201 | return fSlats.GetEntriesFast(); | |
202 | } | |
203 | ||
204 | //_____________________________________________________________________________ | |
205 | Bool_t | |
206 | AliMpTrigger::IsLayerValid(int layer) const | |
207 | { | |
208 | if ( layer >= 0 && layer < GetSize() ) | |
209 | { | |
210 | return kTRUE; | |
211 | } | |
212 | return kFALSE; | |
213 | } | |
214 | ||
215 | //_____________________________________________________________________________ | |
216 | TVector2 | |
217 | AliMpTrigger::Position() const | |
218 | { | |
219 | return TVector2(DX(),DY()); | |
220 | } | |
221 | ||
222 | //_____________________________________________________________________________ | |
223 | void | |
224 | AliMpTrigger::Print(Option_t* opt) const | |
225 | { | |
226 | cout << "AliMpTrigger::" << GetID(); | |
227 | if ( GetSize() == 0 ) | |
228 | { | |
229 | cout << " Empty"; | |
230 | } | |
231 | else if ( GetSize() > 1 ) | |
232 | { | |
233 | cout << " Number of layers : " << GetSize(); | |
234 | } | |
235 | else | |
236 | { | |
237 | cout << " One layer"; | |
238 | } | |
239 | cout << endl; | |
240 | for ( Int_t i = 0; i < GetSize(); ++i ) | |
241 | { | |
242 | cout << " "; | |
243 | GetLayer(i)->Print(opt); | |
244 | } | |
245 | } | |
246 | ||
247 | //_____________________________________________________________________________ | |
248 | //_____________________________________________________________________________ | |
249 | //_____________________________________________________________________________ | |
250 | //_____________________________________________________________________________ |