TPCCondData
TimePixParameters.cc
Go to the documentation of this file.
1 #include "TimePixParameters.h"
2 
3 // the data format is as follow:
4 // there are 4 leading integers:
5 // 0 : chipID
6 // 1 : type
7 // 2 : polarity
8 // 3 : nChips
9 // then the block of nChips*16 DAC values follows
10 // if the data format is extended only add trailing integers to
11 // preserve backward compatibility
12 #define N_LEADING_INTEGERS 4
13 #define N_TRAILING_INTEGERS 0
14 
15 
16 namespace tpcconddata
17 {
18 
20  {
21  createObj = true;
22  myObj = new IMPL::LCGenericObjectImpl(N_LEADING_INTEGERS + nChips*16 + N_TRAILING_INTEGERS,
23  0, // no floats
24  2);// two doubles
25 
26  myObj->setIntVal(3, nChips);
27  setType(3); // set the default type to TimePix
28  }
29 
31  {
32  createObj=false;
33  myObj = dynamic_cast<IMPL::LCGenericObjectImpl*>( obj );
34 
35  if (myObj ==0){
36  //could be a TimePixParameters object
37  TimePixParameters* dummyObj = dynamic_cast<TimePixParameters*>( obj );
38  if (dummyObj != 0){
39  myObj=dummyObj->myObj;
40  }
41  }
42  }
43 
45  {
46  if (createObj) delete myObj;
47  }
48 
49  void TimePixParameters::setChipID (int chipID){ myObj->setIntVal(0, chipID); }
50  int TimePixParameters::getChipID() const{ return myObj->getIntVal(0); }
51 
52  void TimePixParameters::setDACs(int chipIndex, int * DACs)
53  {
54  for (int i=0; i<16; i++)
55  {
56  myObj->setIntVal( N_LEADING_INTEGERS + chipIndex*16 + i , DACs[i] );
57  }
58  }
59  // const int * TimePixParameters::getDACs(int chipIndex) const
60  //{
61  // OK, this does not work since the getIntVal gives a copy, not a reference :-(
62  // return &myObj->getIntVal( getChipID() + chipIndex*16 );
63  //}
64 
65 
67  int TimePixParameters::getDAC(int chipIndex, int dacIndex) const
68  {
69  return myObj->getIntVal(N_LEADING_INTEGERS + chipIndex*16 + dacIndex);
70  }
71 
72  void TimePixParameters::setType(int type) { myObj->setIntVal(1, type); }
74  int TimePixParameters::getType() const { return myObj->getIntVal(1); }
75 
77  void TimePixParameters::setPolarity(int polarity){ myObj->setIntVal(2, polarity); }
79  int TimePixParameters::getPolarity() const { return myObj->getIntVal(2); }
80 
81  // get the DACs for the Timepix by name (convenience functions for not to use the index)
82  int TimePixParameters::getIKrumm(int chipIndex) const {return getDAC( chipIndex, 0);}
83  int TimePixParameters::getDisc(int chipIndex) const {return getDAC( chipIndex, 1);}
84  int TimePixParameters::getPreamp(int chipIndex) const {return getDAC( chipIndex, 2);}
85  int TimePixParameters::getBuffA(int chipIndex) const {return getDAC( chipIndex, 3);}
86  int TimePixParameters::getBuffB(int chipIndex) const {return getDAC( chipIndex, 4);}
87  int TimePixParameters::getDelayN(int chipIndex) const {return getDAC( chipIndex, 5);}
88  int TimePixParameters::getTHLFine(int chipIndex) const {return getDAC( chipIndex, 6);}
89  int TimePixParameters::getTHLCoarse(int chipIndex) const{return getDAC( chipIndex, 7);}
90  int TimePixParameters::getTHHFine(int chipIndex) const {return getDAC( chipIndex, 8);}
91  int TimePixParameters::getTHHCoarse(int chipIndex) const{return getDAC( chipIndex, 9);}
92  int TimePixParameters::getFBK(int chipIndex) const {return getDAC( chipIndex, 10);}
93  int TimePixParameters::getGnd(int chipIndex) const {return getDAC( chipIndex, 11);}
94  int TimePixParameters::getTHS(int chipIndex) const {return getDAC( chipIndex, 12);}
95  int TimePixParameters::getBiasVLDS(int chipIndex) const {return getDAC( chipIndex, 13);}
96  int TimePixParameters::getRefLVDS(int chipIndex) const {return getDAC( chipIndex, 14);}
97 
99  void TimePixParameters::setClock(double clock) { myObj->setDoubleVal(0, clock); }
101  double TimePixParameters::getClock() const { return myObj->getDoubleVal(0); }
102 
104  void TimePixParameters::setShutterEndTime(double shutterEndTime){ myObj->setDoubleVal(1, shutterEndTime); }
106  double TimePixParameters::getShutterEndTime() const{ return myObj->getDoubleVal(1); }
107 
109  int TimePixParameters::getNChips() const { return myObj->getIntVal(3); }
110 
111  std::string TimePixParameters::getRevision() {return std::string("$Rev: $");}
113  {
114  return std::string("TimePixParameters");
115  }
116 
117  // void TimePixParameters::print( std::ostream& os ) const;
118 
119  // -------- need to implement abstract methods from LCGenericObject
121  + getNChips()*16
123  int TimePixParameters::getNFloat() const {return 0; }
124  int TimePixParameters::getNDouble() const { return 2; }
125 
126  int TimePixParameters::getIntVal(int index) const {return myObj->getIntVal( index);}
127  float TimePixParameters::getFloatVal(int index) const{return myObj->getFloatVal( index);}
128  double TimePixParameters::getDoubleVal(int index) const{return myObj->getDoubleVal( index);}
129 
130  void TimePixParameters::print ( std::ostream& os ) const {
131  os << "BoardID " << getChipID() << " , Type "<< getType() << " , " << getNChips() << " Chips"
132  <<std::endl;
133  for ( int chip=0; chip<getNChips() ; chip++)
134  {
135  os << "Chip " << chip << "DACs ";
136  for ( int dacIndex=0; dacIndex<16 ; dacIndex++)
137  {
138  os << "\t" << getDAC(chip, dacIndex) ;
139  }
140  os << std::endl;
141  }
142  }
143 
144  std::ostream &operator<<(std::ostream &os, const TimePixParameters &p) {
145  p.print(os);
146  return os;
147  }
148 } //end namespace tpcconddata
149 
int getTHLFine(int chipIndex) const
virtual ~TimePixParameters()
Important for memory handling.
int getTHHCoarse(int chipIndex) const
int getType() const
get the chip type (3=timepix)
TimePixParameters(EVENT::LCObject *obj)
Constructor needed to interpret LCCollection read from file/database.
int getTHS(int chipIndex) const
double getDoubleVal(int index) const
int getNChips() const
Get the number of chips.
int getGnd(int chipIndex) const
int getBiasVLDS(int chipIndex) const
#define N_TRAILING_INTEGERS
int getFBK(int chipIndex) const
void print(std::ostream &os=std::cout) const
int getTHHFine(int chipIndex) const
int getTHLCoarse(int chipIndex) const
The TimePix parameters.
#define N_LEADING_INTEGERS
int getBuffA(int chipIndex) const
void setPolarity(int polarity)
set the polarity
void setClock(double clock)
Set the clock (in MHz)
std::ostream & operator<<(std::ostream &os, const ADCChannelMapping &acm)
int getIKrumm(int chipIndex) const
void setType(int type)
set the chip type (3=timepix)
int getChipID() const
get the chip iID aka module number
int getDisc(int chipIndex) const
void setShutterEndTime(double shutterEndTime)
Set the shutter end time (wrt. tigger)
int getDAC(int chipIndex, int dacIndex) const
Get a specific DAC by index.
double getShutterEndTime() const
Get the shutter end time (wrt. tigger)
float getFloatVal(int index) const
double getClock() const
Get the clock (in MHz)
int getDelayN(int chipIndex) const
IMPL::LCGenericObjectImpl * myObj
static std::string getDefaultColName()
int getRefLVDS(int chipIndex) const
void setDACs(int chipIndex, int *DACs)
Set the DACs for one chip, a 16 words long integer array.
int getBuffB(int chipIndex) const
int getPolarity() const
get the polarity
void setChipID(int chipID)
set the chip iID aka module number
int getPreamp(int chipIndex) const