Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DCCALGeometry.cc
Go to the documentation of this file.
1 // $Id$
2 //
3 // File: DCCALGeometry.cc
4 // Created: Tue Nov 30 15:42:41 EST 2010
5 // Creator: davidl (on Linux ifarml6 2.6.18-128.el5 x86_64)
6 //
7 
8 #include <cassert>
9 #include <math.h>
10 using namespace std;
11 
12 #include "DCCALGeometry.h"
13 #include "DVector2.h"
14 
15 //---------------------------------
16 // DCCALGeometry (Constructor)
17 //---------------------------------
19  m_numActiveBlocks( 0 ){
20 
21  for( int row = 0; row < kCCALBlocksTall; row++ ){
22  for( int col = 0; col < kCCALBlocksWide; col++ ){
23 
24  // transform to beam axis
25  m_positionOnFace[row][col] =
26  DVector2( ( (double)col - kCCALMidBlock + 0.5 ) * blockSize(),
27  ( (double)row - kCCALMidBlock + 0.5 ) * blockSize() );
28 
29  m_activeBlock[row][col] = true;
30 
31  // build the "channel map"
35 
37  }
38  }
39 }
40 
41 bool
42 DCCALGeometry::isBlockActive( int row, int column ) const
43 {
44  // I'm inserting these lines to effectively disable the
45  // two assert calls below. They are causing all programs
46  // (hd_dump, hdview) to exit, even when I'm not interested
47  // in the FCAL. This does not fix the underlying problem
48  // of why we're getting invalid row/column values.
49  // 12/13/05 DL
50  if( row < 0 || row >= kCCALBlocksTall )return false;
51  if( column < 0 || column >= kCCALBlocksWide )return false;
52 
53  assert( row >= 0 && row < kCCALBlocksTall );
54  assert( column >= 0 && column < kCCALBlocksWide );
55 
56  return m_activeBlock[row][column];
57 }
58 
59 int
60 DCCALGeometry::row( float y ) const
61 {
62  return static_cast<int>( y / blockSize() + kCCALMidBlock );
63 }
64 
65 int
66 DCCALGeometry::column( float x ) const
67 {
68  return static_cast<int>( x / blockSize() + kCCALMidBlock );
69 }
70 
73 {
74  assert( row >= 0 && row < kCCALBlocksTall );
75  assert( column >= 0 && column < kCCALBlocksWide );
76 
77  return m_positionOnFace[row][column];
78 }
79 
81 DCCALGeometry::positionOnFace( int channel ) const
82 {
83  assert( channel >= 0 && channel < m_numActiveBlocks );
84 
85  return positionOnFace( m_row[channel], m_column[channel] );
86 }
87 
88 int
89 DCCALGeometry::channel( int row, int column ) const
90 {
91  if( isBlockActive( row, column ) ){
92 
93  return m_channelNumber[row][column];
94  }
95  else{
96 
97  cerr << "ERROR: request for channel number of inactive block!" << endl;
98  return -1;
99  }
100 }
DVector2 positionOnFace(int row, int column) const
int channel(int row, int column) const
TVector2 DVector2
Definition: DVector2.h:9
Double_t x[NCHANNELS]
Definition: st_tw_resols.C:39
#define y
static const int kCCALBlocksWide
Definition: DCCALGeometry.h:25
bool m_activeBlock[kCCALBlocksTall][kCCALBlocksWide]
Definition: DCCALGeometry.h:62
int m_column[kCCALMaxChannels]
Definition: DCCALGeometry.h:67
static double blockSize()
Definition: DCCALGeometry.h:31
static const int kCCALMidBlock
Definition: DCCALGeometry.h:28
int column(int channel) const
Definition: DCCALGeometry.h:47
DVector2 m_positionOnFace[kCCALBlocksTall][kCCALBlocksWide]
Definition: DCCALGeometry.h:63
static const int kCCALBlocksTall
Definition: DCCALGeometry.h:26
int row(int channel) const
Definition: DCCALGeometry.h:46
int m_channelNumber[kCCALBlocksTall][kCCALBlocksWide]
Definition: DCCALGeometry.h:65
bool isBlockActive(int row, int column) const
int m_row[kCCALMaxChannels]
Definition: DCCALGeometry.h:66