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