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