1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 // $MpId: AliMpTrigger.cxx,v 1.2 2006/03/02 16:35:31 ivana Exp $
19 #include "AliMpTrigger.h"
22 #include "AliMpSlat.h"
24 #include "Riostream.h"
26 #include "TObjArray.h"
29 /// \class AliMpTrigger
31 /// A trigger 'slat' object.
32 /// It is to be viewed as a superposition of
33 /// virtual layers of AliMpSlat objects. The need for more than one layer
34 /// arise from the fact that a given local board deals with strips
35 /// located in different detelem. So a given strip (pad) can have several
38 /// \author Laurent Aphecetche
40 ClassImp(AliMpTrigger)
44 Bool_t IsEqual(Double_t a, Double_t b, Double_t precision)
48 Double_t diff = TMath::Abs(b-a)/TMath::Abs(b);
49 if ( diff < precision )
56 if ( !a ) return kTRUE;
62 //_____________________________________________________________________________
63 AliMpTrigger::AliMpTrigger()
64 : TObject(), fId(""), fPlaneType(kNonBendingPlane),
65 fMaxNofPadsY(0), fDX(0), fDY(0)
70 //_____________________________________________________________________________
71 AliMpTrigger::AliMpTrigger(const char* slatType, AliMpPlaneType bendingOrNot)
72 : TObject(), fId(slatType), fPlaneType(bendingOrNot),
73 fMaxNofPadsY(0), fDX(0), fDY(0)
78 //_____________________________________________________________________________
79 AliMpTrigger::~AliMpTrigger()
82 AliDebug(1,Form("this=%p before fSlats.Delete()",this));
84 AliDebug(1,Form("this=%p after fSlats.Delete()",this));
87 //_____________________________________________________________________________
89 AliMpTrigger::AdoptLayer(AliMpSlat* slat)
91 // Adopt (i.e. we become owner of that pointer) a slat, as
92 // a layer of this trigger slat.
94 AliDebug(1,Form("%s is adopting %s :\n",
95 GetID(),slat->GetID()));
97 // Check that we keep our size constant.
99 const Double_t kPrecision = 1E-3;
101 if ( GetSize() > 0 &&
102 ( !::IsEqual(slat->DX(),fDX,kPrecision) ||
103 !::IsEqual(slat->DY(),fDY,kPrecision) )
106 AliError(Form("In %s trying to add a layer (%e,%e) of a different size than "
107 "mine (%e,%e)\n",GetID(),slat->DX(),slat->DY(),
112 fMaxNofPadsY = std::max(slat->GetMaxNofPadsY(),fMaxNofPadsY);
113 fDX = std::max(fDX,slat->DX());
114 fDY = std::max(fDY,slat->DY());
118 //_____________________________________________________________________________
120 AliMpTrigger::Dimensions() const
122 // Returns the dimensions (half-sizes) of that slat (cm)
123 return TVector2(DX(),DY());
126 //_____________________________________________________________________________
128 AliMpTrigger::DX() const
130 // Returns the half-size in X (cm)
134 //_____________________________________________________________________________
136 AliMpTrigger::DY() const
138 // Returns the half-size in Y (cm)
142 //_____________________________________________________________________________
144 AliMpTrigger::GetAllLocalBoardNumbers(TArrayI& lbn) const
146 // Fills lbn with the local board numbers we're dealing with
148 for ( Int_t i = 0; i < GetSize(); ++i )
150 n += GetLayer(i)->GetNofElectronicCards();
157 for ( Int_t i = 0; i < GetSize(); ++i )
160 GetLayer(i)->GetAllMotifPositionsIDs(slbn);
161 for ( Int_t j = 0; j < slbn.GetSize(); ++j )
163 lbn[index] = slbn[j];
169 //_____________________________________________________________________________
171 AliMpTrigger::GetID() const
173 // returns the id of this slat
177 //_____________________________________________________________________________
179 AliMpTrigger::GetName() const
181 // returns the name (=id+bending/non-bending) of this slat
182 TString name(GetID());
183 if ( fPlaneType == kBendingPlane )
187 else if ( fPlaneType == kNonBendingPlane )
189 name += ".NonBending";
198 //_____________________________________________________________________________
200 AliMpTrigger::GetLayer(int layer) const
202 // Returns a given layer
203 if ( IsLayerValid(layer) )
205 return (AliMpSlat*)fSlats.At(layer);
210 //_____________________________________________________________________________
212 AliMpTrigger::GetNofPadsX() const
214 // Returns the number of pad in x direction
215 if ( !GetSize() ) return -1;
218 return GetLayer(0)->GetNofPadsX();
223 //_____________________________________________________________________________
225 AliMpTrigger::GetMaxNofPadsY() const
227 // Maximum number of pads in y direction
231 //_____________________________________________________________________________
233 AliMpTrigger::GetSize() const
236 return fSlats.GetEntriesFast();
239 //_____________________________________________________________________________
241 AliMpTrigger::IsLayerValid(int layer) const
243 // Whether a given layer index is valid or not
244 if ( layer >= 0 && layer < GetSize() )
251 //_____________________________________________________________________________
253 AliMpTrigger::PlaneType() const
259 //_____________________________________________________________________________
261 AliMpTrigger::Position() const
263 // Slat position (cm)
264 return TVector2(DX(),DY());
267 //_____________________________________________________________________________
269 AliMpTrigger::Print(Option_t* opt) const
272 cout << "AliMpTrigger::" << GetID();
273 if ( GetSize() == 0 )
277 else if ( GetSize() > 1 )
279 cout << " Number of layers : " << GetSize();
283 cout << " One layer";
286 for ( Int_t i = 0; i < GetSize(); ++i )
289 GetLayer(i)->Print(opt);
293 //_____________________________________________________________________________
294 //_____________________________________________________________________________
295 //_____________________________________________________________________________
296 //_____________________________________________________________________________