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