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"
20 #include "AliMpSlatSegmentation.h"
23 #include "AliMpSlat.h"
25 #include "Riostream.h"
27 #include "TObjArray.h"
30 /// \class AliMpTrigger
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
39 /// \author Laurent Aphecetche
42 ClassImp(AliMpTrigger)
47 Bool_t IsEqual(Double_t a, Double_t b, Double_t precision)
51 Double_t diff = TMath::Abs(b-a)/TMath::Abs(b);
52 if ( diff < precision )
59 if ( !a ) return kTRUE;
65 //_____________________________________________________________________________
66 AliMpTrigger::AliMpTrigger()
69 fPlaneType(kNonBendingPlane),
71 fSlatSegmentations(0),
78 AliDebugStream(1) << "this = " << this << endl;
81 //_____________________________________________________________________________
82 AliMpTrigger::AliMpTrigger(const char* slatType, AliMpPlaneType bendingOrNot)
85 fPlaneType(bendingOrNot),
87 fSlatSegmentations(0),
94 AliDebugStream(1) << "this = " << this << endl;
97 //_____________________________________________________________________________
98 AliMpTrigger::~AliMpTrigger()
101 AliDebugStream(1) << "this = " << this << endl;
104 fSlatSegmentations.Delete();
107 //_____________________________________________________________________________
109 AliMpTrigger::AdoptLayer(AliMpSlat* slat)
111 // Adopt (i.e. we become owner of that pointer) a slat, as
112 // a layer of this trigger slat.
114 AliDebug(2,Form("%s is adopting %s ",
115 GetID(),slat->GetID()));
117 // Check that we keep our size constant.
119 const Double_t kPrecision = 1E-3;
121 if ( GetSize() > 0 &&
122 ( !::IsEqual(slat->DX(),fDX,kPrecision) ||
123 !::IsEqual(slat->DY(),fDY,kPrecision) )
126 AliError(Form("In %s trying to add a layer (%e,%e) of a different size than "
127 "mine (%e,%e)\n",GetID(),slat->DX(),slat->DY(),
132 fSlatSegmentations.Add(new AliMpSlatSegmentation(slat));
133 fMaxNofPadsY = std::max(slat->GetMaxNofPadsY(),fMaxNofPadsY);
134 fDX = std::max(fDX,slat->DX());
135 fDY = std::max(fDY,slat->DY());
139 //_____________________________________________________________________________
141 AliMpTrigger::Dimensions() const
143 // Returns the dimensions (half-sizes) of that slat (cm)
144 return TVector2(DX(),DY());
147 //_____________________________________________________________________________
149 AliMpTrigger::DX() const
151 // Returns the half-size in X (cm)
155 //_____________________________________________________________________________
157 AliMpTrigger::DY() const
159 // Returns the half-size in Y (cm)
163 //_____________________________________________________________________________
165 AliMpTrigger::GetAllLocalBoardNumbers(TArrayI& lbn) const
167 // Fills lbn with the local board numbers we're dealing with
169 for ( Int_t i = 0; i < GetSize(); ++i )
171 n += GetLayer(i)->GetNofElectronicCards();
178 for ( Int_t i = 0; i < GetSize(); ++i )
181 GetLayer(i)->GetAllMotifPositionsIDs(slbn);
182 for ( Int_t j = 0; j < slbn.GetSize(); ++j )
184 lbn[index] = slbn[j];
190 //_____________________________________________________________________________
192 AliMpTrigger::GetID() const
194 // returns the id of this slat
198 //_____________________________________________________________________________
200 AliMpTrigger::GetName() const
202 // returns the name (=id+bending/non-bending) of this slat
203 TString name(GetID());
204 if ( fPlaneType == kBendingPlane )
208 else if ( fPlaneType == kNonBendingPlane )
210 name += ".NonBending";
219 //_____________________________________________________________________________
221 AliMpTrigger::GetLayer(int layer) const
223 // Returns a given layer
224 if ( IsLayerValid(layer) )
226 return (AliMpSlat*)fSlats.At(layer);
231 //_____________________________________________________________________________
233 AliMpTrigger::GetLayerSegmentation(int layer) const
235 // Returns a given layer
236 if ( IsLayerValid(layer) )
238 return (AliMpSlatSegmentation*)fSlatSegmentations.At(layer);
243 //_____________________________________________________________________________
245 AliMpTrigger::GetNofPadsX() const
247 // Returns the number of pad in x direction
248 if ( !GetSize() ) return -1;
251 return GetLayer(0)->GetNofPadsX();
256 //_____________________________________________________________________________
258 AliMpTrigger::GetMaxNofPadsY() const
260 // Maximum number of pads in y direction
264 //_____________________________________________________________________________
266 AliMpTrigger::GetSize() const
269 return fSlats.GetEntriesFast();
272 //_____________________________________________________________________________
274 AliMpTrigger::IsLayerValid(int layer) const
276 // Whether a given layer index is valid or not
277 if ( layer >= 0 && layer < GetSize() )
284 //_____________________________________________________________________________
286 AliMpTrigger::PlaneType() const
292 //_____________________________________________________________________________
294 AliMpTrigger::Position() const
296 // Slat position (cm)
297 return TVector2(DX(),DY());
300 //_____________________________________________________________________________
302 AliMpTrigger::Print(Option_t* opt) const
305 cout << "AliMpTrigger::" << GetID();
306 if ( GetSize() == 0 )
310 else if ( GetSize() > 1 )
312 cout << " Number of layers : " << GetSize();
316 cout << " One layer";
319 for ( Int_t i = 0; i < GetSize(); ++i )
322 GetLayer(i)->Print(opt);
326 //_____________________________________________________________________________
327 //_____________________________________________________________________________
328 //_____________________________________________________________________________
329 //_____________________________________________________________________________