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