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