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"
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;
80 fSlats.SetOwner(kFALSE);
81 fSlatSegmentations.SetOwner(kTRUE);
84 //_____________________________________________________________________________
85 AliMpTrigger::AliMpTrigger(const char* slatType, AliMpPlaneType bendingOrNot)
88 fPlaneType(bendingOrNot),
90 fSlatSegmentations(0),
97 AliDebugStream(1) << "this = " << this << endl;
99 fSlats.SetOwner(kFALSE);
100 fSlatSegmentations.SetOwner(kTRUE);
103 //_____________________________________________________________________________
104 AliMpTrigger::~AliMpTrigger()
107 AliDebugStream(1) << "this = " << this << endl;
109 fSlatSegmentations.Delete();
112 //_____________________________________________________________________________
114 AliMpTrigger::AdoptLayer(AliMpSlat* slat)
116 // Adopt (i.e. we become owner of that pointer) a slat, as
117 // a layer of this trigger slat.
119 AliDebug(2,Form("%s is adopting %s ",
120 GetID(),slat->GetID()));
122 // Check that we keep our size constant.
124 if ( GetSize() > 0 &&
125 ( !::IsEqual(slat->DX(),fDX,AliMpConstants::LengthTolerance()) ||
126 !::IsEqual(slat->DY(),fDY,AliMpConstants::LengthTolerance()) )
129 AliError(Form("In %s trying to add a layer (%e,%e) (layer #%d) "
130 "of a different size than mine (%e,%e)",
131 GetID(),slat->DX(),slat->DY(),fSlats.GetEntries(),
137 // the slat segmentation will be the owner of the slat, and will delete
138 // it when it'll be deleted itself
139 fSlatSegmentations.Add(new AliMpSlatSegmentation(slat,owner));
140 fMaxNofPadsY = std::max(slat->GetMaxNofPadsY(),fMaxNofPadsY);
141 fDX = std::max(fDX,slat->DX());
142 fDY = std::max(fDY,slat->DY());
146 //_____________________________________________________________________________
148 AliMpTrigger::Dimensions() const
150 // Returns the dimensions (half-sizes) of that slat (cm)
151 return TVector2(DX(),DY());
154 //_____________________________________________________________________________
156 AliMpTrigger::DX() const
158 // Returns the half-size in X (cm)
162 //_____________________________________________________________________________
164 AliMpTrigger::DY() const
166 // Returns the half-size in Y (cm)
170 //_____________________________________________________________________________
172 AliMpTrigger::GetAllLocalBoardNumbers(TArrayI& lbn) const
174 // Fills lbn with the local board numbers we're dealing with
176 for ( Int_t i = 0; i < GetSize(); ++i )
178 n += GetLayer(i)->GetNofElectronicCards();
185 for ( Int_t i = 0; i < GetSize(); ++i )
188 GetLayer(i)->GetAllMotifPositionsIDs(slbn);
189 for ( Int_t j = 0; j < slbn.GetSize(); ++j )
191 lbn[index] = slbn[j];
197 //_____________________________________________________________________________
199 AliMpTrigger::GetID() const
201 // returns the id of this slat
205 //_____________________________________________________________________________
207 AliMpTrigger::GetName() const
209 // returns the name (=id+bending/non-bending) of this slat
210 TString name(GetID());
211 if ( fPlaneType == kBendingPlane )
215 else if ( fPlaneType == kNonBendingPlane )
217 name += ".NonBending";
226 //_____________________________________________________________________________
228 AliMpTrigger::GetLayer(int layer) const
230 // Returns a given layer
231 if ( IsLayerValid(layer) )
233 return (AliMpSlat*)fSlats.At(layer);
238 //_____________________________________________________________________________
240 AliMpTrigger::GetLayerSegmentation(int layer) const
242 // Returns a given layer
243 if ( IsLayerValid(layer) )
245 return (AliMpSlatSegmentation*)fSlatSegmentations.At(layer);
250 //_____________________________________________________________________________
252 AliMpTrigger::GetNofPadsX() const
254 // Returns the number of pad in x direction
255 if ( !GetSize() ) return -1;
258 return GetLayer(0)->GetNofPadsX();
263 //_____________________________________________________________________________
265 AliMpTrigger::GetMaxNofPadsY() const
267 // Maximum number of pads in y direction
271 //_____________________________________________________________________________
273 AliMpTrigger::GetSize() const
276 return fSlats.GetEntriesFast();
279 //_____________________________________________________________________________
281 AliMpTrigger::IsLayerValid(int layer) const
283 // Whether a given layer index is valid or not
284 if ( layer >= 0 && layer < GetSize() )
291 //_____________________________________________________________________________
293 AliMpTrigger::PlaneType() const
299 //_____________________________________________________________________________
301 AliMpTrigger::Position() const
303 // Slat position (cm)
304 return TVector2(DX(),DY());
307 //_____________________________________________________________________________
309 AliMpTrigger::Print(Option_t* opt) const
312 cout << "AliMpTrigger::" << GetID();
313 if ( GetSize() == 0 )
317 else if ( GetSize() > 1 )
319 cout << " Number of layers : " << GetSize();
323 cout << " One layer";
326 for ( Int_t i = 0; i < GetSize(); ++i )
329 GetLayer(i)->Print(opt);
333 //_____________________________________________________________________________
334 //_____________________________________________________________________________
335 //_____________________________________________________________________________
336 //_____________________________________________________________________________