]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/mapping/AliMpPadRow.cxx
Added comments for inline functions
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpPadRow.cxx
CommitLineData
dee1d5f1 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 purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
5f91c9e8 16// $Id$
2c605e66 17// $MpId: AliMpPadRow.cxx,v 1.7 2006/03/17 11:38:43 ivana Exp $
5f91c9e8 18// Category: sector
19//
20// Class AliMpPadRow
f0e4d56c 21// ------------------
5f91c9e8 22// Class describing a pad row composed of the pad row segments.
dbe945cc 23// Included in AliRoot: 2003/05/02
5f91c9e8 24// Authors: David Guez, Ivana Hrivnacova; IPN Orsay
25
5f91c9e8 26#include "AliMpPadRow.h"
f0e4d56c 27#include "AliMpPadRowLSegment.h"
28#include "AliMpPadRowRSegment.h"
5f91c9e8 29
2c605e66 30#include "AliLog.h"
31
32#include <Riostream.h>
33
5f91c9e8 34ClassImp(AliMpPadRow)
35
f0e4d56c 36//_____________________________________________________________________________
37AliMpPadRow::AliMpPadRow(AliMpXDirection direction)
38 : TObject(),
39 fDirection(direction),
dee1d5f1 40 fID(0)
f0e4d56c 41{
dee1d5f1 42/// Standard constructor
f0e4d56c 43}
44
5f91c9e8 45//_____________________________________________________________________________
46AliMpPadRow::AliMpPadRow()
47 : TObject(),
f0e4d56c 48 fDirection(kLeft),
49 fID(0)
5f91c9e8 50{
dee1d5f1 51/// Default constructor
5f91c9e8 52}
53
54//_____________________________________________________________________________
dee1d5f1 55AliMpPadRow::~AliMpPadRow()
56{
57/// Destructor
5f91c9e8 58
59 for (Int_t i=0; i<GetNofPadRowSegments() ; i++)
60 delete fSegments[i];
61}
62
63//
f0e4d56c 64// private methods
5f91c9e8 65//
66
67//_____________________________________________________________________________
f0e4d56c 68Double_t AliMpPadRow::CurrentBorderX() const
5f91c9e8 69{
dee1d5f1 70/// Return the left/right x border
71/// (depending on the direction which the row segments are filled in).
5f91c9e8 72
5f91c9e8 73 if (GetNofPadRowSegments() == 0)
f0e4d56c 74 return fOffsetX;
5f91c9e8 75 else
f0e4d56c 76 if (fDirection == kLeft)
77 return GetPadRowSegment(GetNofPadRowSegments()-1)->LeftBorderX();
78 else
79 return GetPadRowSegment(GetNofPadRowSegments()-1)->RightBorderX();
80}
81
82//
83// public methods
84//
85
86//_____________________________________________________________________________
87AliMpVPadRowSegment*
88AliMpPadRow::AddPadRowSegment(AliMpMotif* motif, Int_t motifPositionId,
89 Int_t nofPads)
90{
dee1d5f1 91/// Add a pad row segment.
f0e4d56c 92
93 AliMpVPadRowSegment* padRowSegment = 0;
94
95 if (fDirection == kLeft) {
96 padRowSegment
97 = new AliMpPadRowLSegment(this, motif, motifPositionId, nofPads);
98 }
99 else {
100 padRowSegment
101 = new AliMpPadRowRSegment(this, motif, motifPositionId, nofPads);
102 }
103
104 // Set pad row segment offset
105 padRowSegment->SetOffsetX(CurrentBorderX());
5f91c9e8 106
107 // Adds the pad row segment
f79c58a5 108#ifdef WITH_STL
5f91c9e8 109 fSegments.push_back(padRowSegment);
f79c58a5 110#endif
111
112#ifdef WITH_ROOT
113 fSegments.Add(padRowSegment);
114#endif
f0e4d56c 115
116 return padRowSegment;
5f91c9e8 117}
118
119//_____________________________________________________________________________
f0e4d56c 120AliMpVPadRowSegment* AliMpPadRow::FindPadRowSegment(Double_t x) const
5f91c9e8 121{
dee1d5f1 122/// Find the row segment for the specified x position;
123/// return 0 if no row segment is found.
5f91c9e8 124
125 for (Int_t i=0; i<GetNofPadRowSegments(); i++) {
f0e4d56c 126 AliMpVPadRowSegment* rs = GetPadRowSegment(i);
5f91c9e8 127 if (x >= rs->LeftBorderX() && x <= rs->RightBorderX())
128 return rs;
129 }
130
131 return 0;
132}
133
134//_____________________________________________________________________________
135Double_t AliMpPadRow::HalfSizeY() const
136{
dee1d5f1 137/// Return the half size in y
138
5f91c9e8 139 return GetPadRowSegment(0)->HalfSizeY();
140}
141
142//_____________________________________________________________________________
143void AliMpPadRow::SetID(Int_t id)
144{
dee1d5f1 145/// Set the ID.
5f91c9e8 146
147 fID = id;
148}
149
150//_____________________________________________________________________________
151void AliMpPadRow::SetOffsetX(Double_t offsetX)
152{
dee1d5f1 153/// Set the x offset.
5f91c9e8 154
155 fOffsetX = offsetX;
156}
157
158//_____________________________________________________________________________
159Int_t AliMpPadRow::GetID() const
160{
dee1d5f1 161/// Return the pad row ID.
5f91c9e8 162
163 return fID;
164}
165
166//_____________________________________________________________________________
167Int_t AliMpPadRow::GetNofPadRowSegments() const
168{
dee1d5f1 169/// Return the number of pad row segments.
5f91c9e8 170
f79c58a5 171#ifdef WITH_STL
5f91c9e8 172 return fSegments.size();
f79c58a5 173#endif
174
175#ifdef WITH_ROOT
176 return fSegments.GetEntriesFast();
177#endif
5f91c9e8 178}
179
180//_____________________________________________________________________________
f0e4d56c 181AliMpVPadRowSegment* AliMpPadRow::GetPadRowSegment(Int_t i) const
5f91c9e8 182{
dee1d5f1 183/// Return the pad row segment with the specified number.
31e62cbe 184
5f91c9e8 185 if (i<0 || i>=GetNofPadRowSegments()) {
2c605e66 186 AliWarningStream() << "Index outside range" << endl;
5f91c9e8 187 return 0;
188 }
189
f79c58a5 190#ifdef WITH_STL
5f91c9e8 191 return fSegments[i];
f79c58a5 192#endif
193
194#ifdef WITH_ROOT
195 return (AliMpVPadRowSegment*)fSegments[i];
196#endif
5f91c9e8 197}
198
199//_____________________________________________________________________________
200Int_t AliMpPadRow::GetNofPads() const
201{
dee1d5f1 202/// Return the number of pads in this pad row.
5f91c9e8 203
204 Int_t nofPads=0;
205 for (Int_t i=0; i<GetNofPadRowSegments(); i++)
206 nofPads += GetPadRowSegment(i)->GetNofPads();
207
208 return nofPads;
209}
210