Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DFCALGeometry.cc
Go to the documentation of this file.
1 // $Id$
2 //
3 // File: DFCALGeometry.cc
4 // Created: Wed Aug 24 10:18:56 EST 2005
5 // Creator: shepherd (on Darwin 129-79-159-16.dhcp-bl.indiana.edu 8.2.0 powerpc)
6 //
7 
8 #include <cassert>
9 #include <math.h>
10 using namespace std;
11 
12 #include "DFCALGeometry.h"
13 #include "DVector2.h"
14 
15 //---------------------------------
16 // DFCALGeometry (Constructor)
17 //---------------------------------
19 m_numActiveBlocks( 0 )
20 {
21  double innerRadius = ( kBeamHoleSize - 1 ) / 2. * blockSize() * sqrt(2.);
22 
23  // inflate the innner radius by 1% to for "safe" comparison
24  innerRadius *= 1.01;
25 
26  for( int row = 0; row < kBlocksTall; row++ ){
27  for( int col = 0; col < kBlocksWide; col++ ){
28 
29  // transform to beam axis
30  m_positionOnFace[row][col] =
31  DVector2( ( col - kMidBlock ) * blockSize(),
32  ( row - kMidBlock ) * blockSize() );
33 
34  double thisRadius = m_positionOnFace[row][col].Mod();
35 
36  if( ( thisRadius < radius() ) && ( thisRadius > innerRadius ) ){
37 
38  m_activeBlock[row][col] = true;
39 
40  // build the "channel map"
44 
46  }
47  else{
48 
49  m_activeBlock[row][col] = false;
50  }
51  }
52  }
53 }
54 
55 bool
56 DFCALGeometry::isBlockActive( int row, int column ) const
57 {
58  // I'm inserting these lines to effectively disable the
59  // two assert calls below. They are causing all programs
60  // (hd_dump, hdview) to exit, even when I'm not interested
61  // in the FCAL. This does not fix the underlying problem
62  // of why we're getting invalid row/column values.
63  // 12/13/05 DL
64  if( row < 0 || row >= kBlocksTall )return false;
65  if( column < 0 || column >= kBlocksWide )return false;
66 
67  // assert( row >= 0 && row < kBlocksTall );
68  // assert( column >= 0 && column < kBlocksWide );
69 
70  return m_activeBlock[row][column];
71 }
72 
73 int
74 DFCALGeometry::row( float y ) const
75 {
76  return static_cast<int>( y / blockSize() + kMidBlock + 0.5);
77 }
78 
79 int
80 DFCALGeometry::column( float x ) const
81 {
82  return static_cast<int>( x / blockSize() + kMidBlock + 0.5);
83 }
84 
87 {
88  // assert( row >= 0 && row < kBlocksTall );
89  // assert( column >= 0 && column < kBlocksWide );
90 
91  return m_positionOnFace[row][column];
92 }
93 
95 DFCALGeometry::positionOnFace( int channel ) const
96 {
97  assert( channel >= 0 && channel < m_numActiveBlocks );
98 
99  return positionOnFace( m_row[channel], m_column[channel] );
100 }
101 
102 int
103 DFCALGeometry::channel( int row, int column ) const
104 {
105  if( isBlockActive( row, column ) ){
106 
107  return m_channelNumber[row][column];
108  }
109  else{
110 
111  cerr << "ERROR: request for channel number of inactive block! row "
112  << row << " column " << column << endl;
113  return -1;
114  }
115 }
int m_channelNumber[kBlocksTall][kBlocksWide]
Definition: DFCALGeometry.h:83
TVector2 DVector2
Definition: DVector2.h:9
Double_t x[NCHANNELS]
Definition: st_tw_resols.C:39
#define y
bool m_activeBlock[kBlocksTall][kBlocksWide]
Definition: DFCALGeometry.h:80
DVector2 positionOnFace(int row, int column) const
int m_row[kMaxChannels]
Definition: DFCALGeometry.h:84
int m_column[kMaxChannels]
Definition: DFCALGeometry.h:85
static double blockSize()
Definition: DFCALGeometry.h:48
int column(int channel) const
Definition: DFCALGeometry.h:65
double sqrt(double)
static double radius()
Definition: DFCALGeometry.h:49
int channel(int row, int column) const
DVector2 m_positionOnFace[kBlocksTall][kBlocksWide]
Definition: DFCALGeometry.h:81
int row(int channel) const
Definition: DFCALGeometry.h:64
bool isBlockActive(int row, int column) const