]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/mapping/AliMpTrigger.cxx
- Reordering includes and/or
[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
28ClassImp(AliMpTrigger)
29
30namespace
31{
32 Bool_t IsEqual(Double_t a, Double_t b, Double_t precision)
33{
34 if (b)
35 {
36 Double_t diff = TMath::Abs(b-a)/TMath::Abs(b);
37 if ( diff < precision )
38 {
39 return kTRUE;
40 }
41 }
42 else
43 {
44 if ( !a ) return kTRUE;
45 }
46 return kFALSE;
47}
48}
49
50//_____________________________________________________________________________
51AliMpTrigger::AliMpTrigger()
52: TObject(), fId(""), fPlaneType(kNonBendingPlane),
53fMaxNofPadsY(0), fDX(0), fDY(0)
54{
55}
56
57//_____________________________________________________________________________
58AliMpTrigger::AliMpTrigger(const char* slatType, AliMpPlaneType bendingOrNot)
59: TObject(), fId(slatType), fPlaneType(bendingOrNot),
60fMaxNofPadsY(0), fDX(0), fDY(0)
61{
62}
63
64//_____________________________________________________________________________
65AliMpTrigger::~AliMpTrigger()
66{
67 AliDebug(1,Form("this=%p before fSlats.Delete()",this));
68 fSlats.Delete();
69 AliDebug(1,Form("this=%p after fSlats.Delete()",this));
70}
71
72//_____________________________________________________________________________
73Bool_t
74AliMpTrigger::AdoptLayer(AliMpSlat* slat)
75{
76 AliDebug(1,Form("%s is adopting %s :\n",
77 GetID(),slat->GetID()));
78
79 // Check that we keep our size constant.
80
81 const Double_t precision = 1E-3;
82
83 if ( GetSize() > 0 &&
84 ( !::IsEqual(slat->DX(),fDX,precision) ||
85 !::IsEqual(slat->DY(),fDY,precision) )
86 )
87 {
88 AliError(Form("In %s trying to add a layer (%e,%e) of a different size than "
89 "mine (%e,%e)\n",GetID(),slat->DX(),slat->DY(),
90 fDX,fDY));
91 return kFALSE;
92 }
93 fSlats.Add(slat);
94 fMaxNofPadsY = std::max(slat->GetMaxNofPadsY(),fMaxNofPadsY);
95 fDX = std::max(fDX,slat->DX());
96 fDY = std::max(fDY,slat->DY());
97 return kTRUE;
98}
99
c9da0af9 100//_____________________________________________________________________________
101TVector2
102AliMpTrigger::Dimensions() const
103{
104 return TVector2(DX(),DY());
105}
106
c667f499 107//_____________________________________________________________________________
108Double_t
109AliMpTrigger::DX() const
110{
111 return fDX;
112}
113
114//_____________________________________________________________________________
115Double_t
116AliMpTrigger::DY() const
117{
118 return fDY;
119}
120
121//_____________________________________________________________________________
122void
123AliMpTrigger::GetAllLocalBoardNumbers(TArrayI& lbn) const
124{
125 Int_t n(0);
126 for ( Int_t i = 0; i < GetSize(); ++i )
127 {
128 n += GetLayer(i)->GetNofElectronicCards();
129 }
130
131 lbn.Set(n);
132
133 Int_t index(0);
134
135 for ( Int_t i = 0; i < GetSize(); ++i )
136 {
137 TArrayI slbn;
c9da0af9 138 GetLayer(i)->GetAllMotifPositionsIDs(slbn);
c667f499 139 for ( Int_t j = 0; j < slbn.GetSize(); ++j )
140 {
141 lbn[index] = slbn[j];
142 ++index;
143 }
144 }
145}
146
147//_____________________________________________________________________________
148const char*
149AliMpTrigger::GetID() const
150{
151 return fId.Data();
152}
153
154//_____________________________________________________________________________
155const char*
156AliMpTrigger::GetName() const
157{
158 TString name(GetID());
159 if ( fPlaneType == kBendingPlane )
160 {
161 name += ".Bending";
162 }
163 else if ( fPlaneType == kNonBendingPlane )
164 {
165 name += ".NonBending";
166 }
167 else
168 {
169 name += ".Invalid";
170 }
171 return name.Data();
172}
173
174//_____________________________________________________________________________
175AliMpSlat*
176AliMpTrigger::GetLayer(int layer) const
177{
178 if ( IsLayerValid(layer) )
179 {
180 return (AliMpSlat*)fSlats.At(layer);
181 }
182 return 0;
183}
184
185//_____________________________________________________________________________
186Int_t
187AliMpTrigger::GetNofPadsX() const
188{
189 if ( !GetSize() ) return -1;
190 if ( GetLayer(0) )
191 {
192 return GetLayer(0)->GetNofPadsX();
193 }
194 return -1;
195}
196
197//_____________________________________________________________________________
198Int_t
199AliMpTrigger::GetMaxNofPadsY() const
200{
201 return fMaxNofPadsY;
202}
203
204//_____________________________________________________________________________
205Int_t
206AliMpTrigger::GetSize() const
207{
208 return fSlats.GetEntriesFast();
209}
210
211//_____________________________________________________________________________
212Bool_t
213AliMpTrigger::IsLayerValid(int layer) const
214{
215 if ( layer >= 0 && layer < GetSize() )
216 {
217 return kTRUE;
218 }
219 return kFALSE;
220}
221
c9da0af9 222//_____________________________________________________________________________
223AliMpPlaneType
224AliMpTrigger::PlaneType() const
225{
226 return fPlaneType;
227}
228
c667f499 229//_____________________________________________________________________________
230TVector2
231AliMpTrigger::Position() const
232{
233 return TVector2(DX(),DY());
234}
235
236//_____________________________________________________________________________
237void
238AliMpTrigger::Print(Option_t* opt) const
239{
240 cout << "AliMpTrigger::" << GetID();
241 if ( GetSize() == 0 )
242 {
243 cout << " Empty";
244 }
245 else if ( GetSize() > 1 )
246 {
247 cout << " Number of layers : " << GetSize();
248 }
249 else
250 {
251 cout << " One layer";
252 }
253 cout << endl;
254 for ( Int_t i = 0; i < GetSize(); ++i )
255 {
256 cout << " ";
257 GetLayer(i)->Print(opt);
258 }
259}
260
261//_____________________________________________________________________________
262//_____________________________________________________________________________
263//_____________________________________________________________________________
264//_____________________________________________________________________________