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.4 2006/05/24 13:58:52 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
41 ClassImp(AliMpTrigger)
46 Bool_t IsEqual(Double_t a, Double_t b, Double_t precision)
50 Double_t diff = TMath::Abs(b-a)/TMath::Abs(b);
51 if ( diff < precision )
58 if ( !a ) return kTRUE;
64 //_____________________________________________________________________________
65 AliMpTrigger::AliMpTrigger()
66 : TObject(), fId(""), fPlaneType(kNonBendingPlane),
67 fMaxNofPadsY(0), fDX(0), fDY(0)
72 //_____________________________________________________________________________
73 AliMpTrigger::AliMpTrigger(const char* slatType, AliMpPlaneType bendingOrNot)
74 : TObject(), fId(slatType), fPlaneType(bendingOrNot),
75 fMaxNofPadsY(0), fDX(0), fDY(0)
80 //_____________________________________________________________________________
81 AliMpTrigger::~AliMpTrigger()
84 AliDebug(1,Form("this=%p before fSlats.Delete()",this));
86 AliDebug(1,Form("this=%p after fSlats.Delete()",this));
89 //_____________________________________________________________________________
91 AliMpTrigger::AdoptLayer(AliMpSlat* slat)
93 // Adopt (i.e. we become owner of that pointer) a slat, as
94 // a layer of this trigger slat.
96 AliDebug(1,Form("%s is adopting %s :\n",
97 GetID(),slat->GetID()));
99 // Check that we keep our size constant.
101 const Double_t kPrecision = 1E-3;
103 if ( GetSize() > 0 &&
104 ( !::IsEqual(slat->DX(),fDX,kPrecision) ||
105 !::IsEqual(slat->DY(),fDY,kPrecision) )
108 AliError(Form("In %s trying to add a layer (%e,%e) of a different size than "
109 "mine (%e,%e)\n",GetID(),slat->DX(),slat->DY(),
114 fMaxNofPadsY = std::max(slat->GetMaxNofPadsY(),fMaxNofPadsY);
115 fDX = std::max(fDX,slat->DX());
116 fDY = std::max(fDY,slat->DY());
120 //_____________________________________________________________________________
122 AliMpTrigger::Dimensions() const
124 // Returns the dimensions (half-sizes) of that slat (cm)
125 return TVector2(DX(),DY());
128 //_____________________________________________________________________________
130 AliMpTrigger::DX() const
132 // Returns the half-size in X (cm)
136 //_____________________________________________________________________________
138 AliMpTrigger::DY() const
140 // Returns the half-size in Y (cm)
144 //_____________________________________________________________________________
146 AliMpTrigger::GetAllLocalBoardNumbers(TArrayI& lbn) const
148 // Fills lbn with the local board numbers we're dealing with
150 for ( Int_t i = 0; i < GetSize(); ++i )
152 n += GetLayer(i)->GetNofElectronicCards();
159 for ( Int_t i = 0; i < GetSize(); ++i )
162 GetLayer(i)->GetAllMotifPositionsIDs(slbn);
163 for ( Int_t j = 0; j < slbn.GetSize(); ++j )
165 lbn[index] = slbn[j];
171 //_____________________________________________________________________________
173 AliMpTrigger::GetID() const
175 // returns the id of this slat
179 //_____________________________________________________________________________
181 AliMpTrigger::GetName() const
183 // returns the name (=id+bending/non-bending) of this slat
184 TString name(GetID());
185 if ( fPlaneType == kBendingPlane )
189 else if ( fPlaneType == kNonBendingPlane )
191 name += ".NonBending";
200 //_____________________________________________________________________________
202 AliMpTrigger::GetLayer(int layer) const
204 // Returns a given layer
205 if ( IsLayerValid(layer) )
207 return (AliMpSlat*)fSlats.At(layer);
212 //_____________________________________________________________________________
214 AliMpTrigger::GetNofPadsX() const
216 // Returns the number of pad in x direction
217 if ( !GetSize() ) return -1;
220 return GetLayer(0)->GetNofPadsX();
225 //_____________________________________________________________________________
227 AliMpTrigger::GetMaxNofPadsY() const
229 // Maximum number of pads in y direction
233 //_____________________________________________________________________________
235 AliMpTrigger::GetSize() const
238 return fSlats.GetEntriesFast();
241 //_____________________________________________________________________________
243 AliMpTrigger::IsLayerValid(int layer) const
245 // Whether a given layer index is valid or not
246 if ( layer >= 0 && layer < GetSize() )
253 //_____________________________________________________________________________
255 AliMpTrigger::PlaneType() const
261 //_____________________________________________________________________________
263 AliMpTrigger::Position() const
265 // Slat position (cm)
266 return TVector2(DX(),DY());
269 //_____________________________________________________________________________
271 AliMpTrigger::Print(Option_t* opt) const
274 cout << "AliMpTrigger::" << GetID();
275 if ( GetSize() == 0 )
279 else if ( GetSize() > 1 )
281 cout << " Number of layers : " << GetSize();
285 cout << " One layer";
288 for ( Int_t i = 0; i < GetSize(); ++i )
291 GetLayer(i)->Print(opt);
295 //_____________________________________________________________________________
296 //_____________________________________________________________________________
297 //_____________________________________________________________________________
298 //_____________________________________________________________________________