]>
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$ | |
c9da0af9 | 17 | // $MpId: AliMpTrigger.cxx,v 1.2 2006/03/02 16:35:31 ivana Exp $ |
c667f499 | 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 | ||
c9da0af9 | 100 | //_____________________________________________________________________________ |
101 | TVector2 | |
102 | AliMpTrigger::Dimensions() const | |
103 | { | |
104 | return TVector2(DX(),DY()); | |
105 | } | |
106 | ||
c667f499 | 107 | //_____________________________________________________________________________ |
108 | Double_t | |
109 | AliMpTrigger::DX() const | |
110 | { | |
111 | return fDX; | |
112 | } | |
113 | ||
114 | //_____________________________________________________________________________ | |
115 | Double_t | |
116 | AliMpTrigger::DY() const | |
117 | { | |
118 | return fDY; | |
119 | } | |
120 | ||
121 | //_____________________________________________________________________________ | |
122 | void | |
123 | AliMpTrigger::GetAllLocalBoardNumbers(TArrayI& lbn) const | |
124 | { | |
125 | Int_t n(0); | |
126 | for ( Int_t i = 0; i < GetSize(); ++i ) | |
127 | { | |
128 | n += GetLayer(i)->GetNofElectronicCards(); | |
129 | } | |
130 | ||
131 | lbn.Set(n); | |
132 | ||
133 | Int_t index(0); | |
134 | ||
135 | for ( Int_t i = 0; i < GetSize(); ++i ) | |
136 | { | |
137 | TArrayI slbn; | |
c9da0af9 | 138 | GetLayer(i)->GetAllMotifPositionsIDs(slbn); |
c667f499 | 139 | for ( Int_t j = 0; j < slbn.GetSize(); ++j ) |
140 | { | |
141 | lbn[index] = slbn[j]; | |
142 | ++index; | |
143 | } | |
144 | } | |
145 | } | |
146 | ||
147 | //_____________________________________________________________________________ | |
148 | const char* | |
149 | AliMpTrigger::GetID() const | |
150 | { | |
151 | return fId.Data(); | |
152 | } | |
153 | ||
154 | //_____________________________________________________________________________ | |
155 | const char* | |
156 | AliMpTrigger::GetName() const | |
157 | { | |
158 | TString name(GetID()); | |
159 | if ( fPlaneType == kBendingPlane ) | |
160 | { | |
161 | name += ".Bending"; | |
162 | } | |
163 | else if ( fPlaneType == kNonBendingPlane ) | |
164 | { | |
165 | name += ".NonBending"; | |
166 | } | |
167 | else | |
168 | { | |
169 | name += ".Invalid"; | |
170 | } | |
171 | return name.Data(); | |
172 | } | |
173 | ||
174 | //_____________________________________________________________________________ | |
175 | AliMpSlat* | |
176 | AliMpTrigger::GetLayer(int layer) const | |
177 | { | |
178 | if ( IsLayerValid(layer) ) | |
179 | { | |
180 | return (AliMpSlat*)fSlats.At(layer); | |
181 | } | |
182 | return 0; | |
183 | } | |
184 | ||
185 | //_____________________________________________________________________________ | |
186 | Int_t | |
187 | AliMpTrigger::GetNofPadsX() const | |
188 | { | |
189 | if ( !GetSize() ) return -1; | |
190 | if ( GetLayer(0) ) | |
191 | { | |
192 | return GetLayer(0)->GetNofPadsX(); | |
193 | } | |
194 | return -1; | |
195 | } | |
196 | ||
197 | //_____________________________________________________________________________ | |
198 | Int_t | |
199 | AliMpTrigger::GetMaxNofPadsY() const | |
200 | { | |
201 | return fMaxNofPadsY; | |
202 | } | |
203 | ||
204 | //_____________________________________________________________________________ | |
205 | Int_t | |
206 | AliMpTrigger::GetSize() const | |
207 | { | |
208 | return fSlats.GetEntriesFast(); | |
209 | } | |
210 | ||
211 | //_____________________________________________________________________________ | |
212 | Bool_t | |
213 | AliMpTrigger::IsLayerValid(int layer) const | |
214 | { | |
215 | if ( layer >= 0 && layer < GetSize() ) | |
216 | { | |
217 | return kTRUE; | |
218 | } | |
219 | return kFALSE; | |
220 | } | |
221 | ||
c9da0af9 | 222 | //_____________________________________________________________________________ |
223 | AliMpPlaneType | |
224 | AliMpTrigger::PlaneType() const | |
225 | { | |
226 | return fPlaneType; | |
227 | } | |
228 | ||
c667f499 | 229 | //_____________________________________________________________________________ |
230 | TVector2 | |
231 | AliMpTrigger::Position() const | |
232 | { | |
233 | return TVector2(DX(),DY()); | |
234 | } | |
235 | ||
236 | //_____________________________________________________________________________ | |
237 | void | |
238 | AliMpTrigger::Print(Option_t* opt) const | |
239 | { | |
240 | cout << "AliMpTrigger::" << GetID(); | |
241 | if ( GetSize() == 0 ) | |
242 | { | |
243 | cout << " Empty"; | |
244 | } | |
245 | else if ( GetSize() > 1 ) | |
246 | { | |
247 | cout << " Number of layers : " << GetSize(); | |
248 | } | |
249 | else | |
250 | { | |
251 | cout << " One layer"; | |
252 | } | |
253 | cout << endl; | |
254 | for ( Int_t i = 0; i < GetSize(); ++i ) | |
255 | { | |
256 | cout << " "; | |
257 | GetLayer(i)->Print(opt); | |
258 | } | |
259 | } | |
260 | ||
261 | //_____________________________________________________________________________ | |
262 | //_____________________________________________________________________________ | |
263 | //_____________________________________________________________________________ | |
264 | //_____________________________________________________________________________ |