StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StSvtHit.cxx
1 /***************************************************************************
2  *
3  * $Id: StSvtHit.cxx,v 2.18 2009/11/23 22:20:51 ullrich Exp $
4  *
5  * Author: Thomas Ullrich, Jan 1999
6  ***************************************************************************
7  *
8  * Description:
9  *
10  ***************************************************************************
11  *
12  * $Log: StSvtHit.cxx,v $
13  * Revision 2.18 2009/11/23 22:20:51 ullrich
14  * Minor cleanup performed, fixed compiler warnings.
15  *
16  * Revision 2.17 2009/11/23 16:34:07 fisyak
17  * Cleanup, remove dependence on dst tables, clean up software monitors
18  *
19  * Revision 2.16 2009/11/10 00:41:03 ullrich
20  * Changed print-out format and added new method shell().
21  *
22  * Revision 2.15 2007/09/20 20:02:32 ullrich
23  * Added new members to hold and access the number of anodes and of pixels.
24  *
25  * Revision 2.14 2006/04/27 21:59:00 ullrich
26  * Added data member and methods to deal with local positions.
27  *
28  * Revision 2.13 2005/07/19 21:37:56 perev
29  * Cleanup
30  *
31  * Revision 2.12 2005/06/15 01:21:01 ullrich
32  * In constructor using dst_point: set mFitFlag
33  *
34  * Revision 2.11 2004/08/06 15:37:09 fisyak
35  * Add clster id
36  *
37  * Revision 2.10 2004/07/15 16:36:25 ullrich
38  * Removed all clone() declerations and definitions. Use StObject::clone() only.
39  *
40  * Revision 2.9 2001/08/07 20:50:57 caines
41  * Implement better packing of hardware and charge values
42  *
43  * Revision 2.8 2001/04/05 04:00:56 ullrich
44  * Replaced all (U)Long_t by (U)Int_t and all redundant ROOT typedefs.
45  *
46  * Revision 2.7 2001/03/24 03:34:59 perev
47  * clone() -> clone() const
48  *
49  * Revision 2.6 2000/06/01 21:39:03 ullrich
50  * Added member mFlag and access member flag() and setFlag().
51  *
52  * Revision 2.5 1999/12/13 20:16:19 ullrich
53  * Changed numbering scheme for hw_position unpack methods (STAR conventions).
54  *
55  * Revision 2.4 1999/11/11 11:03:55 ullrich
56  * Inlined layer(), sector() and ladder().
57  *
58  * Revision 2.3 1999/11/09 19:35:20 ullrich
59  * Memory now allocated using StMemoryPool via overloaded new/delete
60  *
61  * Revision 2.2 1999/11/04 21:40:55 ullrich
62  * Added missing default constructor
63  *
64  * Revision 2.1 1999/10/28 22:26:41 ullrich
65  * Adapted new StArray version. First version to compile on Linux and Sun.
66  *
67  * Revision 2.0 1999/10/12 18:42:43 ullrich
68  * Completely Revised for New Version
69  *
70  **************************************************************************/
71 #include "StSvtHit.h"
72 #include "StTrack.h"
73 
74 static const char rcsid[] = "$Id: StSvtHit.cxx,v 2.18 2009/11/23 22:20:51 ullrich Exp $";
75 
76 ClassImp(StSvtHit)
77 
78 StMemoryPool StSvtHit::mPool(sizeof(StSvtHit));
79 
80 StSvtHit::StSvtHit()
81 {
82  mPeak = 0;
83  mAnode = 0;
84  mTimebucket = 0;
85  mLocalPosition[0] = 0;
86  mLocalPosition[1] = 0;
87  mNumberOfAnodes = 0;
88  mNumberOfPixels = 0;
89 }
90 
91 StSvtHit::StSvtHit(const StThreeVectorF& p,
92  const StThreeVectorF& e,
93  unsigned int hw, float q, unsigned char c)
94  : StHit(p, e, hw, q, c)
95 {
96  mPeak = 0;
97  mAnode = 0;
98  mTimebucket = 0;
99  mLocalPosition[0] = 0;
100  mLocalPosition[1] = 0;
101  mNumberOfAnodes = 0; // need to be set through access functions
102  mNumberOfPixels = 0; // need to be set through access functions
103 }
104 StSvtHit::~StSvtHit() {/* noop */}
105 
106 unsigned int
107 StSvtHit::barrel() const {
108 
109  int Index = index();
110 
111  if( Index < 0) return 0; // Something wrong
112 
113  if( Index < 64) return 1; // Index starts at 0 for hybrid1,wafer1,
114  else if( Index < 208) return 2; // ladder1,barrel1 and moves out
115  else if( Index < 432) return 3; // Index=431 is the largest value
116  return 0; // Something wrong
117 }
118 
119 
120 unsigned int
121 StSvtHit::ladder() const {
122 
123  int Index = index();
124  int mLadder;
125  int mHybrid[3]={8,12,14}; // Hybrids on each ladder
126  int mLadderTot[2]={8,12}; // Ladders on each barrel
127  switch( barrel()){
128  case 1:
129  mLadder = Index/mHybrid[0];
130  return mLadder+1;
131  break;
132  case 2:
133  Index -= mHybrid[0]*mLadderTot[0]; // Subtract off hybrids from previous
134  mLadder = Index/mHybrid[1]; // layers the div. by hybrids per lay
135  return mLadder+1;
136  break;
137  case 3:
138  Index -= mHybrid[0]*mLadderTot[0]; // Subtract off hybrids from previous
139  Index -= mHybrid[1]*mLadderTot[1]; // layers the div. by hybrids per lay
140  mLadder = Index/mHybrid[2];
141  return mLadder+1;
142  break;
143  default:
144  return 0; //Something Wrong
145  }
146 }
147 
148 unsigned int
149 StSvtHit::layer() const {return layer(barrel(), ladder());}
150 
151 unsigned int
152 StSvtHit::layer(unsigned int Barrel, unsigned int Ladder) {
153 
154  if( Ladder%2){
155  switch( Barrel){
156  case 1:
157  return 2; // Outer layers are the odd numbered ladders
158  break;
159  case 2:
160  return 4;
161  break;
162  case 3:
163  return 6;
164  break;
165  default:
166  return 0;
167  }
168  }
169  else{
170  switch( Barrel){
171  case 1:
172  return 1; // Inner layers are the even ladders
173  break;
174  case 2:
175  return 3;
176  break;
177  case 3:
178  return 5;
179  break;
180  default:
181  return 0;
182  }
183  }
184 
185  return 0;
186 }
187 
188 
189 unsigned int
190 StSvtHit::wafer() const
191 {
192 
193  int Index = index();
194  int Barrel = barrel()-1;
195  int Ladder = ladder()-1;
196  int mHybrid[3] ={8,12,14}; // Number of hybrids per ladder
197  int mLadderTot[3] ={8,12,16}; // Number of ladders per barrel
198 
199  for( int B=0; B<Barrel; B++){
200  Index -= mHybrid[B]*mLadderTot[B]; // Sub. the hybrids from prev. barrels
201  }
202 
203  for( int L=0; L<Ladder; L++){
204  Index -= mHybrid[Barrel]; // Sub. hybrids from previous ladders on barrel
205  }
206 
207  return (Index/2)+1; // Two hybrids per wafer start counting from 1
208 
209 }
210 
211 
212 unsigned int
213 StSvtHit::hybrid() const { return ((index()%2)+1); }
214 
215 float
216 StSvtHit::localPosition(unsigned int i) const
217 {
218  if (i<2)
219  return mLocalPosition[i];
220  else
221  return 0;
222 }
223 
224 void
225 StSvtHit::setLocalPosition(float u, float v)
226 {
227  mLocalPosition[0] = u;
228  mLocalPosition[1] = v;
229 }
230 
231 void StSvtHit::setNumberOfAnodes(unsigned short val)
232 {
233  mNumberOfAnodes = val;
234 }
235 
236 void StSvtHit::setNumberOfPixels(unsigned short val)
237 {
238  mNumberOfPixels = val;
239 }
240 
241 int StSvtHit::numberOfAnodes() const
242 {
243  return mNumberOfAnodes;
244 }
245 
246 int StSvtHit::numberOfPixels() const
247 {
248  return mNumberOfPixels;
249 }
250 
251 float StSvtHit::peakADC() const
252 {
253  return mPeak;
254 }
255 
256 float StSvtHit::anode() const
257 {
258  return mAnode;
259 }
260 
261 unsigned int
262 StSvtHit::shell(unsigned int barrel, unsigned int ladder) {
263  return ((barrel == 1 && ladder <= 4) ||
264  (barrel == 2 && ladder <= 6) ||
265  (barrel == 3 && ladder <= 8)) ? 1 : 2;
266 }
267 
268 unsigned int
269 StSvtHit::shell() const {return shell(barrel(), ladder());}
270 
271 
272 int
273 StSvtHit::volumeID() const {return 10000 * shell() + 1000 * layer() + 100 * wafer() + ladder();}
274 
275 ostream& operator<<(ostream& os, const StSvtHit& v)
276 {
277  return os << Form("Svt b:%2i l:%2i w:%2i h:%1i",v.barrel(),v.ladder(), v.wafer(), v.hybrid())
278  << *((StHit *)&v)
279  << Form(" P:%8.3f",v.peakADC())
280  << Form(" Luv: %8.3f %8.3f anode %8.3f timeb %8.3f",v.localPosition(0),v.localPosition(1),v.anode(),v.timebucket());
281 }
282 void StSvtHit::Print(Option_t *option) const {cout << *this << endl;}
Definition: StHit.h:125