]>
Commit | Line | Data |
---|---|---|
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: AliMpTrigger.cxx,v 1.2 2006/03/02 16:35:31 ivana Exp $ | |
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 | /// | |
29 | /// \class AliMpTrigger | |
30 | /// | |
31 | /// A trigger 'slat' object. | |
32 | /// It is to be viewed as a superposition of | |
33 | /// virtual layers of AliMpSlat objects. The need for more than one layer | |
34 | /// arise from the fact that a given local board deals with strips | |
35 | /// located in different detelem. So a given strip (pad) can have several | |
36 | /// "locations". | |
37 | /// | |
38 | /// \author Laurent Aphecetche | |
39 | ||
40 | ClassImp(AliMpTrigger) | |
41 | ||
42 | namespace | |
43 | { | |
44 | Bool_t IsEqual(Double_t a, Double_t b, Double_t precision) | |
45 | { | |
46 | if (b) | |
47 | { | |
48 | Double_t diff = TMath::Abs(b-a)/TMath::Abs(b); | |
49 | if ( diff < precision ) | |
50 | { | |
51 | return kTRUE; | |
52 | } | |
53 | } | |
54 | else | |
55 | { | |
56 | if ( !a ) return kTRUE; | |
57 | } | |
58 | return kFALSE; | |
59 | } | |
60 | } | |
61 | ||
62 | //_____________________________________________________________________________ | |
63 | AliMpTrigger::AliMpTrigger() | |
64 | : TObject(), fId(""), fPlaneType(kNonBendingPlane), | |
65 | fMaxNofPadsY(0), fDX(0), fDY(0) | |
66 | { | |
67 | // default ctor | |
68 | } | |
69 | ||
70 | //_____________________________________________________________________________ | |
71 | AliMpTrigger::AliMpTrigger(const char* slatType, AliMpPlaneType bendingOrNot) | |
72 | : TObject(), fId(slatType), fPlaneType(bendingOrNot), | |
73 | fMaxNofPadsY(0), fDX(0), fDY(0) | |
74 | { | |
75 | // normal ctor | |
76 | } | |
77 | ||
78 | //_____________________________________________________________________________ | |
79 | AliMpTrigger::~AliMpTrigger() | |
80 | { | |
81 | // dtor | |
82 | AliDebug(1,Form("this=%p before fSlats.Delete()",this)); | |
83 | fSlats.Delete(); | |
84 | AliDebug(1,Form("this=%p after fSlats.Delete()",this)); | |
85 | } | |
86 | ||
87 | //_____________________________________________________________________________ | |
88 | Bool_t | |
89 | AliMpTrigger::AdoptLayer(AliMpSlat* slat) | |
90 | { | |
91 | // Adopt (i.e. we become owner of that pointer) a slat, as | |
92 | // a layer of this trigger slat. | |
93 | ||
94 | AliDebug(1,Form("%s is adopting %s :\n", | |
95 | GetID(),slat->GetID())); | |
96 | ||
97 | // Check that we keep our size constant. | |
98 | ||
99 | const Double_t kPrecision = 1E-3; | |
100 | ||
101 | if ( GetSize() > 0 && | |
102 | ( !::IsEqual(slat->DX(),fDX,kPrecision) || | |
103 | !::IsEqual(slat->DY(),fDY,kPrecision) ) | |
104 | ) | |
105 | { | |
106 | AliError(Form("In %s trying to add a layer (%e,%e) of a different size than " | |
107 | "mine (%e,%e)\n",GetID(),slat->DX(),slat->DY(), | |
108 | fDX,fDY)); | |
109 | return kFALSE; | |
110 | } | |
111 | fSlats.Add(slat); | |
112 | fMaxNofPadsY = std::max(slat->GetMaxNofPadsY(),fMaxNofPadsY); | |
113 | fDX = std::max(fDX,slat->DX()); | |
114 | fDY = std::max(fDY,slat->DY()); | |
115 | return kTRUE; | |
116 | } | |
117 | ||
118 | //_____________________________________________________________________________ | |
119 | TVector2 | |
120 | AliMpTrigger::Dimensions() const | |
121 | { | |
122 | // Returns the dimensions (half-sizes) of that slat (cm) | |
123 | return TVector2(DX(),DY()); | |
124 | } | |
125 | ||
126 | //_____________________________________________________________________________ | |
127 | Double_t | |
128 | AliMpTrigger::DX() const | |
129 | { | |
130 | // Returns the half-size in X (cm) | |
131 | return fDX; | |
132 | } | |
133 | ||
134 | //_____________________________________________________________________________ | |
135 | Double_t | |
136 | AliMpTrigger::DY() const | |
137 | { | |
138 | // Returns the half-size in Y (cm) | |
139 | return fDY; | |
140 | } | |
141 | ||
142 | //_____________________________________________________________________________ | |
143 | void | |
144 | AliMpTrigger::GetAllLocalBoardNumbers(TArrayI& lbn) const | |
145 | { | |
146 | // Fills lbn with the local board numbers we're dealing with | |
147 | Int_t n(0); | |
148 | for ( Int_t i = 0; i < GetSize(); ++i ) | |
149 | { | |
150 | n += GetLayer(i)->GetNofElectronicCards(); | |
151 | } | |
152 | ||
153 | lbn.Set(n); | |
154 | ||
155 | Int_t index(0); | |
156 | ||
157 | for ( Int_t i = 0; i < GetSize(); ++i ) | |
158 | { | |
159 | TArrayI slbn; | |
160 | GetLayer(i)->GetAllMotifPositionsIDs(slbn); | |
161 | for ( Int_t j = 0; j < slbn.GetSize(); ++j ) | |
162 | { | |
163 | lbn[index] = slbn[j]; | |
164 | ++index; | |
165 | } | |
166 | } | |
167 | } | |
168 | ||
169 | //_____________________________________________________________________________ | |
170 | const char* | |
171 | AliMpTrigger::GetID() const | |
172 | { | |
173 | // returns the id of this slat | |
174 | return fId.Data(); | |
175 | } | |
176 | ||
177 | //_____________________________________________________________________________ | |
178 | const char* | |
179 | AliMpTrigger::GetName() const | |
180 | { | |
181 | // returns the name (=id+bending/non-bending) of this slat | |
182 | TString name(GetID()); | |
183 | if ( fPlaneType == kBendingPlane ) | |
184 | { | |
185 | name += ".Bending"; | |
186 | } | |
187 | else if ( fPlaneType == kNonBendingPlane ) | |
188 | { | |
189 | name += ".NonBending"; | |
190 | } | |
191 | else | |
192 | { | |
193 | name += ".Invalid"; | |
194 | } | |
195 | return name.Data(); | |
196 | } | |
197 | ||
198 | //_____________________________________________________________________________ | |
199 | AliMpSlat* | |
200 | AliMpTrigger::GetLayer(int layer) const | |
201 | { | |
202 | // Returns a given layer | |
203 | if ( IsLayerValid(layer) ) | |
204 | { | |
205 | return (AliMpSlat*)fSlats.At(layer); | |
206 | } | |
207 | return 0; | |
208 | } | |
209 | ||
210 | //_____________________________________________________________________________ | |
211 | Int_t | |
212 | AliMpTrigger::GetNofPadsX() const | |
213 | { | |
214 | // Returns the number of pad in x direction | |
215 | if ( !GetSize() ) return -1; | |
216 | if ( GetLayer(0) ) | |
217 | { | |
218 | return GetLayer(0)->GetNofPadsX(); | |
219 | } | |
220 | return -1; | |
221 | } | |
222 | ||
223 | //_____________________________________________________________________________ | |
224 | Int_t | |
225 | AliMpTrigger::GetMaxNofPadsY() const | |
226 | { | |
227 | // Maximum number of pads in y direction | |
228 | return fMaxNofPadsY; | |
229 | } | |
230 | ||
231 | //_____________________________________________________________________________ | |
232 | Int_t | |
233 | AliMpTrigger::GetSize() const | |
234 | { | |
235 | // Number of layers | |
236 | return fSlats.GetEntriesFast(); | |
237 | } | |
238 | ||
239 | //_____________________________________________________________________________ | |
240 | Bool_t | |
241 | AliMpTrigger::IsLayerValid(int layer) const | |
242 | { | |
243 | // Whether a given layer index is valid or not | |
244 | if ( layer >= 0 && layer < GetSize() ) | |
245 | { | |
246 | return kTRUE; | |
247 | } | |
248 | return kFALSE; | |
249 | } | |
250 | ||
251 | //_____________________________________________________________________________ | |
252 | AliMpPlaneType | |
253 | AliMpTrigger::PlaneType() const | |
254 | { | |
255 | // Bending or not | |
256 | return fPlaneType; | |
257 | } | |
258 | ||
259 | //_____________________________________________________________________________ | |
260 | TVector2 | |
261 | AliMpTrigger::Position() const | |
262 | { | |
263 | // Slat position (cm) | |
264 | return TVector2(DX(),DY()); | |
265 | } | |
266 | ||
267 | //_____________________________________________________________________________ | |
268 | void | |
269 | AliMpTrigger::Print(Option_t* opt) const | |
270 | { | |
271 | // Dump on screen | |
272 | cout << "AliMpTrigger::" << GetID(); | |
273 | if ( GetSize() == 0 ) | |
274 | { | |
275 | cout << " Empty"; | |
276 | } | |
277 | else if ( GetSize() > 1 ) | |
278 | { | |
279 | cout << " Number of layers : " << GetSize(); | |
280 | } | |
281 | else | |
282 | { | |
283 | cout << " One layer"; | |
284 | } | |
285 | cout << endl; | |
286 | for ( Int_t i = 0; i < GetSize(); ++i ) | |
287 | { | |
288 | cout << " "; | |
289 | GetLayer(i)->Print(opt); | |
290 | } | |
291 | } | |
292 | ||
293 | //_____________________________________________________________________________ | |
294 | //_____________________________________________________________________________ | |
295 | //_____________________________________________________________________________ | |
296 | //_____________________________________________________________________________ |