StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StTrsAnalogSignalGenerator.hh
1 /***************************************************************************
2  *
3  * $Id: StTrsAnalogSignalGenerator.hh,v 1.10 2008/10/13 19:56:10 fisyak Exp $
4  *
5  * Author:
6  ***************************************************************************
7  *
8  * Description: Abstract Class to define the Analog signal generator
9  *
10  ***************************************************************************
11  *
12  * $Log: StTrsAnalogSignalGenerator.hh,v $
13  * Revision 1.10 2008/10/13 19:56:10 fisyak
14  * Account that Z-offset is sector dependent
15  *
16  * Revision 1.9 2005/09/09 22:12:48 perev
17  * Bug fix + IdTruth added
18  *
19  * Revision 1.8 2000/02/10 01:21:47 calderon
20  * Switch to use StTpcDb.
21  * Coordinates checked for consistency.
22  * Fixed problems with StTrsIstream & StTrsOstream.
23  *
24  * Revision 1.7 2000/01/10 23:11:31 lasiuk
25  * Include MACROS for compatibility with SUN CC5.0
26  *
27  * Revision 1.6 1999/11/10 15:45:50 calderon
28  * Made changes to reduce timing, including:
29  * Made coordinate transfrom a data member of StTrsAnalogSignalGenerator
30  * Added upper-lower bound instead of symmetric cut.
31  * Revived checking if signal is above threshold.
32  *
33  * Revision 1.5 1999/04/23 19:20:55 lasiuk
34  * add mTimeShiftOfSignalCentroid
35  *
36  * Revision 1.4 1999/02/28 20:13:40 lasiuk
37  * noise additions
38  *
39  * Revision 1.3 1999/01/18 21:00:52 lasiuk
40  * add fractionSampled(); reorder initialization
41  *
42  * Revision 1.2 1999/01/18 10:20:23 lasiuk
43  * add tau
44  *
45  * Revision 1.1 1998/11/10 17:12:08 fisyak
46  * Put Brian trs versin into StRoot
47  *
48  * Revision 1.5 1998/11/08 17:02:32 lasiuk
49  * vector allocator, TRUE/true
50  *
51  * Revision 1.4 1998/11/04 21:27:04 lasiuk
52  * unresolved symbol--forgot to set virtual function to zero (inducedChargeOnPad)
53  *
54  * Revision 1.3 1998/11/04 18:46:20 lasiuk
55  * remove gas gain functionality (now in WireHistogram)
56  * initialization in base class
57  * incorporate signalSampler
58  *
59  * Revision 1.2 1998/10/22 14:58:12 lasiuk
60  * image charge returns double and uses PRF integral
61  *
62  * Revision 1.1 1998/06/30 22:54:10 lasiuk
63  * Initial Revision
64  *
65  **************************************************************************/
66 #ifndef ST_TRS_ANALOG_SIGNAL_GENERATOR_HH
67 #define ST_TRS_ANALOG_SIGNAL_GENERATOR_HH
68 
69 #include <utility>
70 #include <vector>
71 
72 #if defined (__SUNPRO_CC) && __SUNPRO_CC >= 0x500
73 using std::min;
74 using std::max;
75 #endif
76 
77 #include "Randomize.h"
78 
79 #include "StTrsAnalogSignal.hh"
80 #include "StTpcGeometry.hh"
81 #include "StTpcSlowControl.hh"
82 #include "StTpcElectronics.hh"
83 #define TPC_DATABASE_PARAMETERS
84 #ifndef TPC_DATABASE_PARAMETERS
85 #include "StTpcCoordinateTransform.hh"
86 #else
87 #include "StDbUtilities/StTpcCoordinateTransform.hh"
88 #endif
89 #include "StTrsWireHistogram.hh"
90 #include "StTrsSector.hh"
91 
93 public:
95  virtual ~StTrsAnalogSignalGenerator() {/* nopt */}
96 
97  // Charge Induction
98  virtual void inducedChargeOnPad(StTrsWireHistogram*, Int_t sector) = 0;
99 
100  // Sampling
101  virtual void sampleAnalogSignal() = 0;
102  virtual double signalSampler(double, StTrsAnalogSignal&) = 0;
103 
104  // access and set
105  void setDeltaPad(int);
106  void setDeltaRow(int);
107  void setSignalThreshold(double);
108  void setSuppressEmptyTimeBins(bool);
109  virtual void setNormalFactor(double FudgeFactor) {assert(0);}
110  // noise generation
111  void addNoise(bool);
112  void setNoiseRMS(double);
113  void generateNoiseUnderSignalOnly(bool);
114 
115 protected:
116  void fractionSampled();
117  double generateNoise() const;
118 
119 protected:
120  StTpcGeometry* mGeomDb;
121  StTpcSlowControl* mSCDb;
122  StTpcElectronics* mElectronicsDb;
123  StTpcCoordinateTransform transformer;
124  int mDeltaPad;
125  int mDeltaRow;
126  pair<int, int> mRowLimits;
127  pair<int, int> mPadLimits;
128 
129  StTrsSector* mSector; // MAKE SURE IT IS CONTAINED BY REFERENCE
130 
131  //sampling
132  double mSignalThreshold;
133  bool mSuppressEmptyTimeBins;
134  StTrsAnalogSignal mElectronicSignal;
135 #ifndef ST_NO_TEMPLATE_DEF_ARGS
136  vector<StTrsAnalogSignal> mDiscreteAnalogTimeSequence;
137  vector<StTrsAnalogSignal>::iterator mTimeSequenceIterator;
138 #else
139  vector<StTrsAnalogSignal, allocator<StTrsAnalogSignal> > mDiscreteAnalogTimeSequence;
140  vector<StTrsAnalogSignal, allocator<StTrsAnalogSignal> >::iterator mTimeSequenceIterator;
141 #endif
142  // db parameters
143  double mSigma1;
144  double mSigma2;
145  double mTau;
146  double mSamplingFrequency;
147  double mGain;
148  double mFractionSampled;
149 
150  // Noise Generation
151  bool mAddNoise;
152  bool mAddNoiseUnderSignalOnly;
153  double mNoiseRMS;
154 
155 
156  // Time Shift for electronics
157  double mTimeShiftOfSignalCentroid;
158 
159 
160  static HepJamesRandom mEngine;
161  static RandGauss mGaussDistribution;
162 };
163 void inline StTrsAnalogSignalGenerator::setDeltaRow(int dr) { mDeltaRow = (dr >=0) ? dr : 0;}
164 void inline StTrsAnalogSignalGenerator::setDeltaPad(int dp) { mDeltaPad = (dp >=0) ? dp : 0;}
165 void inline StTrsAnalogSignalGenerator::setSignalThreshold(double th) { mSignalThreshold = th;}
166 void inline StTrsAnalogSignalGenerator::setSuppressEmptyTimeBins(bool su) {mSuppressEmptyTimeBins = su;}
167 void inline StTrsAnalogSignalGenerator::addNoise(bool v) {mAddNoise = v;}
168 void inline StTrsAnalogSignalGenerator::setNoiseRMS(double v) {mNoiseRMS = v*mGain;}
169 void inline StTrsAnalogSignalGenerator::generateNoiseUnderSignalOnly(bool v) {mAddNoiseUnderSignalOnly = v;}
170 double inline StTrsAnalogSignalGenerator::generateNoise() const {return fabs(mGaussDistribution.shoot(0.,mNoiseRMS));}
171 #endif