AliRoot Core  3abf5b4 (3abf5b4)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMpTrigger.cxx
Go to the documentation of this file.
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.4 2006/05/24 13:58:52 ivana Exp $
18 
19 #include "AliMpTrigger.h"
20 #include "AliMpSlatSegmentation.h"
21 #include "AliMpConstants.h"
22 #include "AliLog.h"
23 #include "AliMpSlat.h"
24 
25 #include "Riostream.h"
26 #include "TArrayI.h"
27 #include "TObjArray.h"
28 
29 //-----------------------------------------------------------------------------
40 //-----------------------------------------------------------------------------
41 
42 using std::cout;
43 using std::endl;
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 //_____________________________________________________________________________
70 : TObject(),
71  fId(""),
72  fPlaneType(AliMp::kNonBendingPlane),
73  fSlats(0),
74  fSlatSegmentations(0),
75  fMaxNofPadsY(0),
76  fDX(0),
77  fDY(0)
78 {
80 
81  AliDebugStream(1) << "this = " << this << endl;
82 
83  fSlats.SetOwner(kFALSE);
84  fSlatSegmentations.SetOwner(kTRUE);
85 }
86 
87 //_____________________________________________________________________________
88 AliMpTrigger::AliMpTrigger(const char* slatType, AliMp::PlaneType bendingOrNot)
89  : TObject(),
90  fId(slatType),
91  fPlaneType(bendingOrNot),
92  fSlats(0),
93  fSlatSegmentations(0),
94  fMaxNofPadsY(0),
95  fDX(0),
96  fDY(0)
97 {
99 
100  AliDebugStream(1) << "this = " << this << endl;
101 
102  fSlats.SetOwner(kFALSE);
103  fSlatSegmentations.SetOwner(kTRUE);
104 }
105 
106 //_____________________________________________________________________________
108 {
110  AliDebugStream(1) << "this = " << this << endl;
111 
112  fSlatSegmentations.Delete();
113 }
114 
115 //_____________________________________________________________________________
116 Bool_t
118 {
121 
122  AliDebug(2,Form("%s is adopting %s ",
123  GetID(),slat->GetID()));
124 
125  // Check that we keep our size constant.
126 
127  if ( GetSize() > 0 &&
128  ( !::IsEqual(slat->DX(),fDX,AliMpConstants::LengthTolerance()) ||
129  !::IsEqual(slat->DY(),fDY,AliMpConstants::LengthTolerance()) )
130  )
131  {
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(),
135  fDX,fDY));
136  return kFALSE;
137  }
138  fSlats.Add(slat);
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));
143  fMaxNofPadsY = TMath::Max(slat->GetMaxNofPadsY(),fMaxNofPadsY);
144  fDX = TMath::Max(fDX,slat->DX());
145  fDY = TMath::Max(fDY,slat->DY());
146  return kTRUE;
147 }
148 
149 //_____________________________________________________________________________
150 Double_t
152 {
154  return fDX;
155 }
156 
157 //_____________________________________________________________________________
158 Double_t
160 {
162  return fDY;
163 }
164 
165 //_____________________________________________________________________________
166 void
168 {
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;
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*
195 {
197  return fId.Data();
198 }
199 
200 //_____________________________________________________________________________
201 const char*
203 {
205  TString name(GetID());
207  {
208  name += ".Bending";
209  }
210  else if ( fPlaneType == AliMp::kNonBendingPlane )
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 {
226  if ( IsLayerValid(layer) )
227  {
228  return (AliMpSlat*)fSlats.At(layer);
229  }
230  return 0;
231 }
232 
233 //_____________________________________________________________________________
236 {
238  if ( IsLayerValid(layer) )
239  {
240  return (AliMpSlatSegmentation*)fSlatSegmentations.At(layer);
241  }
242  return 0;
243 }
244 
245 //_____________________________________________________________________________
246 Int_t
248 {
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
261 {
263  return fMaxNofPadsY;
264 }
265 
266 //_____________________________________________________________________________
267 Int_t
269 {
271  return fSlats.GetEntriesFast();
272 }
273 
274 //_____________________________________________________________________________
275 Bool_t
277 {
279  if ( layer >= 0 && layer < GetSize() )
280  {
281  return kTRUE;
282  }
283  return kFALSE;
284 }
285 
286 //_____________________________________________________________________________
289 {
291  return fPlaneType;
292 }
293 
294 //_____________________________________________________________________________
295 void
296 AliMpTrigger::Print(Option_t* opt) const
297 {
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 //_____________________________________________________________________________
Int_t GetNofPadsX() const
Double_t DX() const
void GetAllMotifPositionsIDs(TArrayI &ecn) const
Return the ids of the electronic cards (either manu or local board).
Definition: AliMpSlat.cxx:335
virtual ~AliMpTrigger()
void Print(Option_t *option="") const
void GetAllLocalBoardNumbers(TArrayI &lbn) const
const char * GetID() const
AliMpSlat * GetLayer(int layer) const
Bool_t IsLayerValid(int layer) const
AliMpVSegmentation * GetLayerSegmentation(int layer) const
Double_t fDX
half-size in x (cm)
Definition: AliMpTrigger.h:88
AliMp::PlaneType PlaneType() const
A slat (building block of stations 3, 4 and 5)
Definition: AliMpSlat.h:51
TObjArray fSlats
virtual slat composing this trigger slat
Definition: AliMpTrigger.h:85
Double_t DY() const
Definition: AliMpSlat.cxx:171
ClassImp(TPCGenInfo)
Definition: AliTPCCmpNG.C:254
static Double_t LengthTolerance()
Return the length precision for tests.
A trigger slat.
Definition: AliMpTrigger.h:37
Bool_t AdoptLayer(AliMpSlat *slat)
void Print(Option_t *option="") const
Definition: AliMpSlat.cxx:456
Double_t fDY
half-size in y (cm)
Definition: AliMpTrigger.h:89
const char * GetName() const
Double_t DX() const
Definition: AliMpSlat.cxx:161
Int_t GetSize() const
Returns the number of layers.
Double_t DY() const
Int_t GetNofPadsX() const
Returns the number of pads in the x-direction contained in this slat.
Definition: AliMpSlat.cxx:425
non-bending plane
Int_t GetMaxNofPadsY() const
Definition: AliMpSlat.cxx:366
const char * GetID() const
Definition: AliMpSlat.cxx:356
Implementation of AliMpVSegmentation for St345 slats.
bending plane
The abstract base class for the segmentation.
AliMp::PlaneType fPlaneType
bending or non-bending
Definition: AliMpTrigger.h:84
Int_t fMaxNofPadsY
max number of pads in y direction
Definition: AliMpTrigger.h:87
Int_t GetNofElectronicCards() const
Return the number of electronic cards (either manu or local board).
Definition: AliMpSlat.cxx:415
TString fId
name of that slat
Definition: AliMpTrigger.h:83
TObjArray fSlatSegmentations
segmentations for virtual slats
Definition: AliMpTrigger.h:86
Int_t GetMaxNofPadsY() const