]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/mapping/AliMpTrigger.cxx
Added comments for inline functions
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpTrigger.cxx
CommitLineData
c667f499 1/**************************************************************************
2* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3* *
4* Author: The ALICE Off-line Project. *
5* Contributors are mentioned in the code where appropriate. *
6* *
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**************************************************************************/
15
16// $Id$
c9da0af9 17// $MpId: AliMpTrigger.cxx,v 1.2 2006/03/02 16:35:31 ivana Exp $
c667f499 18
19#include "AliMpTrigger.h"
20
21#include "AliLog.h"
22#include "AliMpSlat.h"
23
24#include "Riostream.h"
25#include "TArrayI.h"
26#include "TObjArray.h"
27
85fec35d 28///
29/// \class AliMpTrigger
30///
31/// A trigger 'slat' object.
32/// It is to be viewed as a superposition of
33/// virtual layers of AliMpSlat objects. The need for more than one layer
34/// arise from the fact that a given local board deals with strips
35/// located in different detelem. So a given strip (pad) can have several
36/// "locations".
37///
38/// \author Laurent Aphecetche
39
c667f499 40ClassImp(AliMpTrigger)
41
42namespace
43{
44 Bool_t IsEqual(Double_t a, Double_t b, Double_t precision)
45{
46 if (b)
47 {
48 Double_t diff = TMath::Abs(b-a)/TMath::Abs(b);
49 if ( diff < precision )
50 {
51 return kTRUE;
52 }
53 }
54 else
55 {
56 if ( !a ) return kTRUE;
57 }
58 return kFALSE;
59}
60}
61
62//_____________________________________________________________________________
63AliMpTrigger::AliMpTrigger()
64: TObject(), fId(""), fPlaneType(kNonBendingPlane),
65fMaxNofPadsY(0), fDX(0), fDY(0)
66{
85fec35d 67 // default ctor
c667f499 68}
69
70//_____________________________________________________________________________
71AliMpTrigger::AliMpTrigger(const char* slatType, AliMpPlaneType bendingOrNot)
72: TObject(), fId(slatType), fPlaneType(bendingOrNot),
73fMaxNofPadsY(0), fDX(0), fDY(0)
74{
85fec35d 75 // normal ctor
c667f499 76}
77
78//_____________________________________________________________________________
79AliMpTrigger::~AliMpTrigger()
80{
85fec35d 81 // dtor
c667f499 82 AliDebug(1,Form("this=%p before fSlats.Delete()",this));
83 fSlats.Delete();
84 AliDebug(1,Form("this=%p after fSlats.Delete()",this));
85}
86
87//_____________________________________________________________________________
88Bool_t
89AliMpTrigger::AdoptLayer(AliMpSlat* slat)
90{
85fec35d 91 // Adopt (i.e. we become owner of that pointer) a slat, as
92 // a layer of this trigger slat.
93
c667f499 94 AliDebug(1,Form("%s is adopting %s :\n",
95 GetID(),slat->GetID()));
96
97 // Check that we keep our size constant.
98
84aac932 99 const Double_t kPrecision = 1E-3;
c667f499 100
101 if ( GetSize() > 0 &&
84aac932 102 ( !::IsEqual(slat->DX(),fDX,kPrecision) ||
103 !::IsEqual(slat->DY(),fDY,kPrecision) )
c667f499 104 )
105 {
106 AliError(Form("In %s trying to add a layer (%e,%e) of a different size than "
107 "mine (%e,%e)\n",GetID(),slat->DX(),slat->DY(),
108 fDX,fDY));
109 return kFALSE;
110 }
111 fSlats.Add(slat);
112 fMaxNofPadsY = std::max(slat->GetMaxNofPadsY(),fMaxNofPadsY);
113 fDX = std::max(fDX,slat->DX());
114 fDY = std::max(fDY,slat->DY());
115 return kTRUE;
116}
117
c9da0af9 118//_____________________________________________________________________________
119TVector2
120AliMpTrigger::Dimensions() const
121{
85fec35d 122 // Returns the dimensions (half-sizes) of that slat (cm)
c9da0af9 123 return TVector2(DX(),DY());
124}
125
c667f499 126//_____________________________________________________________________________
127Double_t
128AliMpTrigger::DX() const
129{
85fec35d 130 // Returns the half-size in X (cm)
c667f499 131 return fDX;
132}
133
134//_____________________________________________________________________________
135Double_t
136AliMpTrigger::DY() const
137{
85fec35d 138 // Returns the half-size in Y (cm)
c667f499 139 return fDY;
140}
141
142//_____________________________________________________________________________
143void
144AliMpTrigger::GetAllLocalBoardNumbers(TArrayI& lbn) const
145{
85fec35d 146 // Fills lbn with the local board numbers we're dealing with
c667f499 147 Int_t n(0);
148 for ( Int_t i = 0; i < GetSize(); ++i )
149 {
150 n += GetLayer(i)->GetNofElectronicCards();
151 }
152
153 lbn.Set(n);
154
155 Int_t index(0);
156
157 for ( Int_t i = 0; i < GetSize(); ++i )
158 {
159 TArrayI slbn;
c9da0af9 160 GetLayer(i)->GetAllMotifPositionsIDs(slbn);
c667f499 161 for ( Int_t j = 0; j < slbn.GetSize(); ++j )
162 {
163 lbn[index] = slbn[j];
164 ++index;
165 }
166 }
167}
168
169//_____________________________________________________________________________
170const char*
171AliMpTrigger::GetID() const
172{
85fec35d 173 // returns the id of this slat
c667f499 174 return fId.Data();
175}
176
177//_____________________________________________________________________________
178const char*
179AliMpTrigger::GetName() const
180{
85fec35d 181 // returns the name (=id+bending/non-bending) of this slat
c667f499 182 TString name(GetID());
183 if ( fPlaneType == kBendingPlane )
184 {
185 name += ".Bending";
186 }
187 else if ( fPlaneType == kNonBendingPlane )
188 {
189 name += ".NonBending";
190 }
191 else
192 {
193 name += ".Invalid";
194 }
195 return name.Data();
196}
197
198//_____________________________________________________________________________
199AliMpSlat*
200AliMpTrigger::GetLayer(int layer) const
201{
85fec35d 202 // Returns a given layer
c667f499 203 if ( IsLayerValid(layer) )
204 {
205 return (AliMpSlat*)fSlats.At(layer);
206 }
207 return 0;
208}
209
210//_____________________________________________________________________________
211Int_t
212AliMpTrigger::GetNofPadsX() const
213{
85fec35d 214 // Returns the number of pad in x direction
c667f499 215 if ( !GetSize() ) return -1;
216 if ( GetLayer(0) )
217 {
218 return GetLayer(0)->GetNofPadsX();
219 }
220 return -1;
221}
222
223//_____________________________________________________________________________
224Int_t
225AliMpTrigger::GetMaxNofPadsY() const
226{
85fec35d 227 // Maximum number of pads in y direction
c667f499 228 return fMaxNofPadsY;
229}
230
231//_____________________________________________________________________________
232Int_t
233AliMpTrigger::GetSize() const
234{
85fec35d 235 // Number of layers
c667f499 236 return fSlats.GetEntriesFast();
237}
238
239//_____________________________________________________________________________
240Bool_t
241AliMpTrigger::IsLayerValid(int layer) const
242{
85fec35d 243 // Whether a given layer index is valid or not
c667f499 244 if ( layer >= 0 && layer < GetSize() )
245 {
246 return kTRUE;
247 }
248 return kFALSE;
249}
250
c9da0af9 251//_____________________________________________________________________________
252AliMpPlaneType
253AliMpTrigger::PlaneType() const
254{
85fec35d 255 // Bending or not
c9da0af9 256 return fPlaneType;
257}
258
c667f499 259//_____________________________________________________________________________
260TVector2
261AliMpTrigger::Position() const
262{
85fec35d 263 // Slat position (cm)
c667f499 264 return TVector2(DX(),DY());
265}
266
267//_____________________________________________________________________________
268void
269AliMpTrigger::Print(Option_t* opt) const
270{
85fec35d 271 // Dump on screen
c667f499 272 cout << "AliMpTrigger::" << GetID();
273 if ( GetSize() == 0 )
274 {
275 cout << " Empty";
276 }
277 else if ( GetSize() > 1 )
278 {
279 cout << " Number of layers : " << GetSize();
280 }
281 else
282 {
283 cout << " One layer";
284 }
285 cout << endl;
286 for ( Int_t i = 0; i < GetSize(); ++i )
287 {
288 cout << " ";
289 GetLayer(i)->Print(opt);
290 }
291}
292
293//_____________________________________________________________________________
294//_____________________________________________________________________________
295//_____________________________________________________________________________
296//_____________________________________________________________________________