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"
28 ClassImp(AliMpTrigger)
32 Bool_t IsEqual(Double_t a, Double_t b, Double_t precision)
36 Double_t diff = TMath::Abs(b-a)/TMath::Abs(b);
37 if ( diff < precision )
44 if ( !a ) return kTRUE;
50 //_____________________________________________________________________________
51 AliMpTrigger::AliMpTrigger()
52 : TObject(), fId(""), fPlaneType(kNonBendingPlane),
53 fMaxNofPadsY(0), fDX(0), fDY(0)
57 //_____________________________________________________________________________
58 AliMpTrigger::AliMpTrigger(const char* slatType, AliMpPlaneType bendingOrNot)
59 : TObject(), fId(slatType), fPlaneType(bendingOrNot),
60 fMaxNofPadsY(0), fDX(0), fDY(0)
64 //_____________________________________________________________________________
65 AliMpTrigger::~AliMpTrigger()
67 AliDebug(1,Form("this=%p before fSlats.Delete()",this));
69 AliDebug(1,Form("this=%p after fSlats.Delete()",this));
72 //_____________________________________________________________________________
74 AliMpTrigger::AdoptLayer(AliMpSlat* slat)
76 AliDebug(1,Form("%s is adopting %s :\n",
77 GetID(),slat->GetID()));
79 // Check that we keep our size constant.
81 const Double_t kPrecision = 1E-3;
84 ( !::IsEqual(slat->DX(),fDX,kPrecision) ||
85 !::IsEqual(slat->DY(),fDY,kPrecision) )
88 AliError(Form("In %s trying to add a layer (%e,%e) of a different size than "
89 "mine (%e,%e)\n",GetID(),slat->DX(),slat->DY(),
94 fMaxNofPadsY = std::max(slat->GetMaxNofPadsY(),fMaxNofPadsY);
95 fDX = std::max(fDX,slat->DX());
96 fDY = std::max(fDY,slat->DY());
100 //_____________________________________________________________________________
102 AliMpTrigger::Dimensions() const
104 return TVector2(DX(),DY());
107 //_____________________________________________________________________________
109 AliMpTrigger::DX() const
114 //_____________________________________________________________________________
116 AliMpTrigger::DY() const
121 //_____________________________________________________________________________
123 AliMpTrigger::GetAllLocalBoardNumbers(TArrayI& lbn) const
126 for ( Int_t i = 0; i < GetSize(); ++i )
128 n += GetLayer(i)->GetNofElectronicCards();
135 for ( Int_t i = 0; i < GetSize(); ++i )
138 GetLayer(i)->GetAllMotifPositionsIDs(slbn);
139 for ( Int_t j = 0; j < slbn.GetSize(); ++j )
141 lbn[index] = slbn[j];
147 //_____________________________________________________________________________
149 AliMpTrigger::GetID() const
154 //_____________________________________________________________________________
156 AliMpTrigger::GetName() const
158 TString name(GetID());
159 if ( fPlaneType == kBendingPlane )
163 else if ( fPlaneType == kNonBendingPlane )
165 name += ".NonBending";
174 //_____________________________________________________________________________
176 AliMpTrigger::GetLayer(int layer) const
178 if ( IsLayerValid(layer) )
180 return (AliMpSlat*)fSlats.At(layer);
185 //_____________________________________________________________________________
187 AliMpTrigger::GetNofPadsX() const
189 if ( !GetSize() ) return -1;
192 return GetLayer(0)->GetNofPadsX();
197 //_____________________________________________________________________________
199 AliMpTrigger::GetMaxNofPadsY() const
204 //_____________________________________________________________________________
206 AliMpTrigger::GetSize() const
208 return fSlats.GetEntriesFast();
211 //_____________________________________________________________________________
213 AliMpTrigger::IsLayerValid(int layer) const
215 if ( layer >= 0 && layer < GetSize() )
222 //_____________________________________________________________________________
224 AliMpTrigger::PlaneType() const
229 //_____________________________________________________________________________
231 AliMpTrigger::Position() const
233 return TVector2(DX(),DY());
236 //_____________________________________________________________________________
238 AliMpTrigger::Print(Option_t* opt) const
240 cout << "AliMpTrigger::" << GetID();
241 if ( GetSize() == 0 )
245 else if ( GetSize() > 1 )
247 cout << " Number of layers : " << GetSize();
251 cout << " One layer";
254 for ( Int_t i = 0; i < GetSize(); ++i )
257 GetLayer(i)->Print(opt);
261 //_____________________________________________________________________________
262 //_____________________________________________________________________________
263 //_____________________________________________________________________________
264 //_____________________________________________________________________________