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