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"
21 #include "AliMpConstants.h"
23 #include "AliMpSlat.h"
25 #include "Riostream.h"
27 #include "TObjArray.h"
29 //-----------------------------------------------------------------------------
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
40 //-----------------------------------------------------------------------------
43 ClassImp(AliMpTrigger)
48 Bool_t IsEqual(Double_t a, Double_t b, Double_t precision)
52 Double_t diff = TMath::Abs(b-a)/TMath::Abs(b);
53 if ( diff < precision )
60 if ( !a ) return kTRUE;
66 //_____________________________________________________________________________
67 AliMpTrigger::AliMpTrigger()
70 fPlaneType(AliMp::kNonBendingPlane),
72 fSlatSegmentations(0),
79 AliDebugStream(1) << "this = " << this << endl;
81 fSlats.SetOwner(kFALSE);
82 fSlatSegmentations.SetOwner(kTRUE);
85 //_____________________________________________________________________________
86 AliMpTrigger::AliMpTrigger(const char* slatType, AliMp::PlaneType bendingOrNot)
89 fPlaneType(bendingOrNot),
91 fSlatSegmentations(0),
98 AliDebugStream(1) << "this = " << this << endl;
100 fSlats.SetOwner(kFALSE);
101 fSlatSegmentations.SetOwner(kTRUE);
104 //_____________________________________________________________________________
105 AliMpTrigger::~AliMpTrigger()
108 AliDebugStream(1) << "this = " << this << endl;
110 fSlatSegmentations.Delete();
113 //_____________________________________________________________________________
115 AliMpTrigger::AdoptLayer(AliMpSlat* slat)
117 /// Adopt (i.e. we become owner of that pointer) a slat, as
118 /// a layer of this trigger slat.
120 AliDebug(2,Form("%s is adopting %s ",
121 GetID(),slat->GetID()));
123 // Check that we keep our size constant.
125 if ( GetSize() > 0 &&
126 ( !::IsEqual(slat->DX(),fDX,AliMpConstants::LengthTolerance()) ||
127 !::IsEqual(slat->DY(),fDY,AliMpConstants::LengthTolerance()) )
130 AliError(Form("In %s trying to add a layer (%e,%e) (layer #%d) "
131 "of a different size than mine (%e,%e)",
132 GetID(),slat->DX(),slat->DY(),fSlats.GetEntries(),
138 // the slat segmentation will be the owner of the slat, and will delete
139 // it when it'll be deleted itself
140 fSlatSegmentations.Add(new AliMpSlatSegmentation(slat,owner));
141 fMaxNofPadsY = TMath::Max(slat->GetMaxNofPadsY(),fMaxNofPadsY);
142 fDX = TMath::Max(fDX,slat->DX());
143 fDY = TMath::Max(fDY,slat->DY());
147 //_____________________________________________________________________________
149 AliMpTrigger::Dimensions() const
151 /// Returns the dimensions (half-sizes) of that slat (cm)
152 return TVector2(DX(),DY());
155 //_____________________________________________________________________________
157 AliMpTrigger::DX() const
159 /// Returns the half-size in X (cm)
163 //_____________________________________________________________________________
165 AliMpTrigger::DY() const
167 /// Returns the half-size in Y (cm)
171 //_____________________________________________________________________________
173 AliMpTrigger::GetAllLocalBoardNumbers(TArrayI& lbn) const
175 /// Fills lbn with the local board numbers we're dealing with
177 for ( Int_t i = 0; i < GetSize(); ++i )
179 n += GetLayer(i)->GetNofElectronicCards();
186 for ( Int_t i = 0; i < GetSize(); ++i )
189 GetLayer(i)->GetAllMotifPositionsIDs(slbn);
190 for ( Int_t j = 0; j < slbn.GetSize(); ++j )
192 lbn[index] = slbn[j];
198 //_____________________________________________________________________________
200 AliMpTrigger::GetID() const
202 /// returns the id of this slat
206 //_____________________________________________________________________________
208 AliMpTrigger::GetName() const
210 /// returns the name (=id+bending/non-bending) of this slat
211 TString name(GetID());
212 if ( fPlaneType == AliMp::kBendingPlane )
216 else if ( fPlaneType == AliMp::kNonBendingPlane )
218 name += ".NonBending";
227 //_____________________________________________________________________________
229 AliMpTrigger::GetLayer(int layer) const
231 /// Returns a given layer
232 if ( IsLayerValid(layer) )
234 return (AliMpSlat*)fSlats.At(layer);
239 //_____________________________________________________________________________
241 AliMpTrigger::GetLayerSegmentation(int layer) const
243 /// Returns a given layer
244 if ( IsLayerValid(layer) )
246 return (AliMpSlatSegmentation*)fSlatSegmentations.At(layer);
251 //_____________________________________________________________________________
253 AliMpTrigger::GetNofPadsX() const
255 /// Returns the number of pad in x direction
256 if ( !GetSize() ) return -1;
259 return GetLayer(0)->GetNofPadsX();
264 //_____________________________________________________________________________
266 AliMpTrigger::GetMaxNofPadsY() const
268 /// Maximum number of pads in y direction
272 //_____________________________________________________________________________
274 AliMpTrigger::GetSize() const
277 return fSlats.GetEntriesFast();
280 //_____________________________________________________________________________
282 AliMpTrigger::IsLayerValid(int layer) const
284 /// Whether a given layer index is valid or not
285 if ( layer >= 0 && layer < GetSize() )
292 //_____________________________________________________________________________
294 AliMpTrigger::PlaneType() const
300 //_____________________________________________________________________________
302 AliMpTrigger::Position() const
304 /// Slat position (cm)
305 return TVector2(DX(),DY());
308 //_____________________________________________________________________________
310 AliMpTrigger::Print(Option_t* opt) const
313 cout << "AliMpTrigger::" << GetID();
314 if ( GetSize() == 0 )
318 else if ( GetSize() > 1 )
320 cout << " Number of layers : " << GetSize();
324 cout << " One layer";
327 for ( Int_t i = 0; i < GetSize(); ++i )
330 GetLayer(i)->Print(opt);
334 //_____________________________________________________________________________
335 //_____________________________________________________________________________
336 //_____________________________________________________________________________
337 //_____________________________________________________________________________