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 //-----------------------------------------------------------------------------
45 ClassImp(AliMpTrigger)
50 Bool_t IsEqual(Double_t a, Double_t b, Double_t precision)
54 Double_t diff = TMath::Abs(b-a)/TMath::Abs(b);
55 if ( diff < precision )
62 if ( !a ) return kTRUE;
68 //_____________________________________________________________________________
69 AliMpTrigger::AliMpTrigger()
72 fPlaneType(AliMp::kNonBendingPlane),
74 fSlatSegmentations(0),
81 AliDebugStream(1) << "this = " << this << endl;
83 fSlats.SetOwner(kFALSE);
84 fSlatSegmentations.SetOwner(kTRUE);
87 //_____________________________________________________________________________
88 AliMpTrigger::AliMpTrigger(const char* slatType, AliMp::PlaneType bendingOrNot)
91 fPlaneType(bendingOrNot),
93 fSlatSegmentations(0),
100 AliDebugStream(1) << "this = " << this << endl;
102 fSlats.SetOwner(kFALSE);
103 fSlatSegmentations.SetOwner(kTRUE);
106 //_____________________________________________________________________________
107 AliMpTrigger::~AliMpTrigger()
110 AliDebugStream(1) << "this = " << this << endl;
112 fSlatSegmentations.Delete();
115 //_____________________________________________________________________________
117 AliMpTrigger::AdoptLayer(AliMpSlat* slat)
119 /// Adopt (i.e. we become owner of that pointer) a slat, as
120 /// a layer of this trigger slat.
122 AliDebug(2,Form("%s is adopting %s ",
123 GetID(),slat->GetID()));
125 // Check that we keep our size constant.
127 if ( GetSize() > 0 &&
128 ( !::IsEqual(slat->DX(),fDX,AliMpConstants::LengthTolerance()) ||
129 !::IsEqual(slat->DY(),fDY,AliMpConstants::LengthTolerance()) )
132 AliError(Form("In %s trying to add a layer (%e,%e) (layer #%d) "
133 "of a different size than mine (%e,%e)",
134 GetID(),slat->DX(),slat->DY(),fSlats.GetEntries(),
140 // the slat segmentation will be the owner of the slat, and will delete
141 // it when it'll be deleted itself
142 fSlatSegmentations.Add(new AliMpSlatSegmentation(slat,owner));
143 fMaxNofPadsY = TMath::Max(slat->GetMaxNofPadsY(),fMaxNofPadsY);
144 fDX = TMath::Max(fDX,slat->DX());
145 fDY = TMath::Max(fDY,slat->DY());
149 //_____________________________________________________________________________
151 AliMpTrigger::DX() const
153 /// Returns the half-size in X (cm)
157 //_____________________________________________________________________________
159 AliMpTrigger::DY() const
161 /// Returns the half-size in Y (cm)
165 //_____________________________________________________________________________
167 AliMpTrigger::GetAllLocalBoardNumbers(TArrayI& lbn) const
169 /// Fills lbn with the local board numbers we're dealing with
171 for ( Int_t i = 0; i < GetSize(); ++i )
173 n += GetLayer(i)->GetNofElectronicCards();
180 for ( Int_t i = 0; i < GetSize(); ++i )
183 GetLayer(i)->GetAllMotifPositionsIDs(slbn);
184 for ( Int_t j = 0; j < slbn.GetSize(); ++j )
186 lbn[index] = slbn[j];
192 //_____________________________________________________________________________
194 AliMpTrigger::GetID() const
196 /// returns the id of this slat
200 //_____________________________________________________________________________
202 AliMpTrigger::GetName() const
204 /// returns the name (=id+bending/non-bending) of this slat
205 TString name(GetID());
206 if ( fPlaneType == AliMp::kBendingPlane )
210 else if ( fPlaneType == AliMp::kNonBendingPlane )
212 name += ".NonBending";
221 //_____________________________________________________________________________
223 AliMpTrigger::GetLayer(int layer) const
225 /// Returns a given layer
226 if ( IsLayerValid(layer) )
228 return (AliMpSlat*)fSlats.At(layer);
233 //_____________________________________________________________________________
235 AliMpTrigger::GetLayerSegmentation(int layer) const
237 /// Returns a given layer
238 if ( IsLayerValid(layer) )
240 return (AliMpSlatSegmentation*)fSlatSegmentations.At(layer);
245 //_____________________________________________________________________________
247 AliMpTrigger::GetNofPadsX() const
249 /// Returns the number of pad in x direction
250 if ( !GetSize() ) return -1;
253 return GetLayer(0)->GetNofPadsX();
258 //_____________________________________________________________________________
260 AliMpTrigger::GetMaxNofPadsY() const
262 /// Maximum number of pads in y direction
266 //_____________________________________________________________________________
268 AliMpTrigger::GetSize() const
271 return fSlats.GetEntriesFast();
274 //_____________________________________________________________________________
276 AliMpTrigger::IsLayerValid(int layer) const
278 /// Whether a given layer index is valid or not
279 if ( layer >= 0 && layer < GetSize() )
286 //_____________________________________________________________________________
288 AliMpTrigger::PlaneType() const
294 //_____________________________________________________________________________
296 AliMpTrigger::Print(Option_t* opt) const
299 cout << "AliMpTrigger::" << GetID();
300 if ( GetSize() == 0 )
304 else if ( GetSize() > 1 )
306 cout << " Number of layers : " << GetSize();
310 cout << " One layer";
313 for ( Int_t i = 0; i < GetSize(); ++i )
316 GetLayer(i)->Print(opt);
320 //_____________________________________________________________________________
321 //_____________________________________________________________________________
322 //_____________________________________________________________________________
323 //_____________________________________________________________________________