StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StTpcSimpleElectronics.cc
1 /*****************************************************************
2  *
3  * $Id: StTpcSimpleElectronics.cc,v 1.9 2012/06/11 15:04:56 fisyak Exp $
4  *
5  * Author: brian Nov 3, 1998
6  *
7  *****************************************************************
8  * Description: Simple ASCII Database for Electronics parameters for
9  * the STAR Main TPC
10  *
11  *****************************************************************
12  *
13  * $Log: StTpcSimpleElectronics.cc,v $
14  * Revision 1.9 2012/06/11 15:04:56 fisyak
15  * std namespace
16  *
17  * Revision 1.8 2000/06/07 02:03:11 lasiuk
18  * exit/abort ultimatum
19  *
20  * Revision 1.7 2000/03/15 17:39:49 calderon
21  * Remove beeps
22  *
23  * Revision 1.6 2000/01/10 23:14:30 lasiuk
24  * Include MACROS for compatiblity with SUN CC5
25  *
26  * Revision 1.5 1999/02/28 20:17:40 lasiuk
27  * add numberOfTimeBins
28  *
29  * Revision 1.4 1999/02/24 19:33:29 lasiuk
30  * add tzero offset parameter
31  *
32  * Revision 1.3 1999/01/18 17:21:29 lasiuk
33  * tau units
34  *
35  * Revision 1.2 1999/01/18 10:22:08 lasiuk
36  * add tau
37  *
38  * Revision 1.1 1998/11/10 17:12:22 fisyak
39  * Put Brian trs versin into StRoot
40  *
41  * Revision 1.3 1998/11/05 19:03:50 lasiuk
42  * fix unit integrity to make sure DB call returns in base unit
43  *
44  * Revision 1.2 1998/11/04 21:26:11 lasiuk
45  * incorporate units
46  *
47  * Revision 1.1 1998/11/04 18:52:33 lasiuk
48  * Initial Revision
49  *
50  ******************************************************************/
51 
52 #include "SystemOfUnits.h"
53 #include "StTpcSimpleElectronics.hh"
54 #include "StGetConfigValue.hh"
55 #ifndef ST_NO_EXCEPTIONS
56 # include <stdexcept>
57 # if !defined(ST_NO_NAMESPACES)
58  using std::invalid_argument;
59 # endif
60 #endif
61 
62 StTpcElectronics* StTpcSimpleElectronics::mInstance = 0; // static data member
63 
64 StTpcSimpleElectronics::StTpcSimpleElectronics() { /* nopt */ }
65 
66 StTpcSimpleElectronics::StTpcSimpleElectronics(const char* file)
67 {
68  StGetConfigValue(file,"nominalGain",mNominalGain);
69  StGetConfigValue(file,"samplingFrequency",mSamplingFrequency);
70  StGetConfigValue(file,"tZero",mTZero);
71  StGetConfigValue(file,"adcConversion",mAdcConversion);
72  StGetConfigValue(file,"adcCharge",mAdcConversionCharge);
73  StGetConfigValue(file,"numberOfTimeBins",mNumberOfTimeBins);
74  StGetConfigValue(file,"averagePedestal",mAveragePedestal);
75  StGetConfigValue(file,"shapingTime",mShapingTime);
76  StGetConfigValue(file,"tau",mTau);
77 
78 #ifndef ST_NO_NAMESPACES
79  using namespace units;
80 #endif
81 
82  //Units Integrity
83  mNominalGain *= ((volt*.001)/(coulomb*1.e-15)); // mV/fC
84  mSamplingFrequency *= MHz;
85  mTZero *= microsecond;
86  mAdcConversion *= (volt*.001);
87  mAdcConversionCharge *= (coulomb*1.e-15);
88  mShapingTime *= nanosecond;
89  mTau *= nanosecond;
90 }
91 
93 StTpcSimpleElectronics::instance()
94 {
95  if (!mInstance) {
96 #ifndef ST_NO_EXCEPTIONS
97  throw invalid_argument("StTpcSimpleElectronics::getInstance(): Argument Missing!");
98 #else
99  std::cerr << "StTpcSimpleElectronics::getInstance(): Argument Missing!" << endl;
100  std::cerr << "No arguments for instantiantion" << endl;
101  std::cerr << "Aborting..." << endl;
102  abort();
103 #endif
104  }
105  return mInstance;
106 }
107 
109 StTpcSimpleElectronics::instance(const char* file)
110 {
111  if (!mInstance) {
112  mInstance = new StTpcSimpleElectronics(file);
113  }
114  else {
115  std::cerr << "StTpcSimpleElectronics::instance()" << endl;
116  std::cerr << "\tWARNING:" << endl;
117  std::cerr << "\tSingleton class is already instantiated" << endl;
118  std::cerr << "\tArgument \"" << file << "\" ignored!!" << endl;
119  std::cerr << "\tContinuing..." << endl;
120  }
121  return mInstance;
122 }
123 
124 double StTpcSimpleElectronics::channelGain(int sector, int row, int pad) const
125 {
126  // This should be where channel by channel gains are looked up
127  return nominalGain();
128 }
129 
130 double StTpcSimpleElectronics::channelGain(StTpcPadCoordinate& coord) const
131 {
132  return channelGain(coord.sector(), coord.row(), coord.pad());
133 }
134 
135 int StTpcSimpleElectronics::pedestal(int sector, int row, int pad, int timeB) const
136 {
137  return averagePedestal();
138 }
139 
140 int StTpcSimpleElectronics::pedestal(StTpcPadCoordinate& coord) const
141 {
142  return pedestal(coord.sector(), coord.row(), coord.pad(), coord.timeBucket());
143 }
144 
145 void StTpcSimpleElectronics::print(ostream& os) const
146 {
147 #ifndef ST_NO_NAMESPACES
148  using namespace units;
149 #endif
150  os << "Simple Electronics Data Base Parameters" << endl;
151  os << "=======================================" << endl;
152  os << "Analog:" << endl;
153  os << "nominalGain: " << mNominalGain/((volt*.001)/(coulomb*1.e-15)) << " mV/fC" << endl;
154  os << "samplingFrequency: " << mSamplingFrequency/MHz << " MHz" << endl;
155  os << "tZero: " << mTZero/microsecond << " us" << endl;
156  os << "shapingTime: " << mShapingTime/nanosecond << " ns" << endl;
157  os << "shapingTime2: " << mTau/nanosecond << " ns" << endl;
158 
159  os << "\nDigital:" << endl;
160  os << "adcConversion: " << mAdcConversion/(volt*.001) << " mV/channel" << endl;
161  os << "adcConversionCharge: " << mAdcConversionCharge/(coulomb*1.e-15) << " mV/fC" << endl;
162  os << "numberOfTimeBins: " << mNumberOfTimeBins << endl;
163  os << "averagePedestal: " << mAveragePedestal << " channels" << endl;
164  os << endl;
165 }