TPCCondData
ADCChannelMapping.cc
Go to the documentation of this file.
1 /* ADCChannelMapping.cc
2  * $Id$
3  */
4 
5 #include "ADCChannelMapping.h"
6 #include <Exceptions.h>
7 
8 namespace tpcconddata
9 {
10 
12  {
13  return std::string("$Rev: 2568 $");
14  }
15 
17  {
18  return std::string("TPCChannelMapping");
19  }
20 
21  ADCChannelMapping::ADCChannelMapping(int channelID, int padIndex, int type , int moduleID,
22  int readoutGroup)
23  : _createObj(true) // remember that we have to delete the object in the destructor
24  {
25  // create a fixed size generic object with 5 ints
26  _myObj = new IMPL::LCGenericObjectImpl(5,0,0);
27 
28  // set the 4 values
29  _myObj->setIntVal( 0, channelID) ;
30  _myObj->setIntVal( 1, padIndex) ;
31  _myObj->setIntVal( 2, type) ;
32  _myObj->setIntVal( 3, moduleID) ;
33  _myObj->setIntVal( 4, readoutGroup) ;
34  }
35 
37  : _createObj(false) // we did not create the object, so we must not delete it in the d'tor
38  {
39  // initialise the object pointer
40  _myObj = dynamic_cast<IMPL::LCGenericObjectImpl*>(obj);
41 
42  if (_myObj == 0) // the cast did not succeed
43  {
44  throw lcio::Exception("Cannot create ADCChannelMapping from sth."
45  " that is not LCGenericObjectImpl" ) ;
46  }
47 
48  // check the size of the generic object
49  // there have to be 3 or 4 interes, no floats ot doubles
50  if ( ( ( _myObj->getNInt() != 3 ) && ( _myObj->getNInt() != 5 ) ) ||
51  ( _myObj->getNFloat() != 0 ) ||
52  ( _myObj->getNDouble() != 0 )
53  )
54  {
55  throw lcio::Exception("ADCChannelMapping(LCObject* obj): Wrong number of elements in object" ) ;
56  }
57 
58  }
59 
61  {
62  // delete the LCGenericObjectImpl, but only if it was created in the constructor
63  if( _createObj)
64  delete (_myObj);
65  }
66 
68  {
69  return _myObj->getIntVal( 0 ) ;
70  }
71 
73  {
74  return _myObj->getIntVal( 1 ) ;
75  }
76 
78  {
79  return _myObj->getIntVal( 2 ) ;
80  }
81 
83  {
84  // This implementation should be backward compatible to the version
85  // without moduleID, so the generic object might only contain 3 integers.
86  // Return moduleID = 0 in this case.
87 
88  if ( _myObj->getNInt() >=4)
89  {
90  return _myObj->getIntVal( 3 ) ;
91  }
92  else
93  {
94  return 0;
95  }
96  }
97 
99  {
100  // This implementation should be backward compatible to the version
101  // without readoutGroup, so the generic object might only contain 3 integers.
102  // Return moduleGroup = 0 in this case.
103 
104  if ( _myObj->getNInt() >=5)
105  {
106  return _myObj->getIntVal( 4 ) ;
107  }
108  else
109  {
110  return 0;
111  }
112  }
113 
114  void ADCChannelMapping::print ( std::ostream& os ) const
115  {
116  os<<"ADCChannelMapping: Pad "<<getPadID()
117  <<" <-> "
118  <<"Channel "<<getChannelID()
119  <<" Type: "<<getType()<<" ; "
120  <<"ModuleID " <<getModuleID()
121  <<std::endl;
122  }
123 
124  std::ostream &operator<<(std::ostream &os, const ADCChannelMapping &acm)
125  {
126  acm.print(os);
127  return os;
128  }
129 
130  #ifdef USE_LCCD
131  ADCChannelMapping::key_type ADCChannelMapping::softwareToHardwareKey() const
132  {
133 
134  return key_type( getPadID(), getModuleID() );
135  }
136 
137  ADCChannelMapping::key_type ADCChannelMapping::hardwareToSoftwareKey() const
138  {
139 
140  return key_type( getChannelID(), getReadoutGroup() );
141  }
142  #endif
143 
144 } //namespace
ADCChannelMapping(int channelID, int padIndex, int type=-1, int moduleID=0, int readoutGroup=0)
The constructor with all the member functions given.
std::ostream & operator<<(std::ostream &os, const ADCChannelMapping &acm)
void print(std::ostream &os=std::cout) const
IMPL::LCGenericObjectImpl * _myObj
static std::string getRevision()
virtual ~ADCChannelMapping()
The desctructor.
static std::string getDefaultColName()
class to store the mapping pad (position) to the channel ID (electronic) also the type of the used el...
IMPL::LCGenericObjectImpl * obj() const