QPulseGenerator.hh
Go to the documentation of this file.00001 #ifndef _Q_PULSE_GENERATOR_HH_
00002 #define _Q_PULSE_GENERATOR_HH_
00003
00010 #include "QVector.hh"
00011 #include <list>
00012 #include <vector>
00013 #include <queue>
00014 #include <gsl/gsl_rng.h>
00015 #include "QNoiseGenerator.hh"
00016 #include "QAmplitudeGenerator.hh"
00017 #include <TF1.h>
00018
00019 namespace Cuore {class QMathFunction;}
00020 using namespace Cuore;
00021
00022 class QPulseGenerator {
00023 public:
00025 QPulseGenerator() {}
00027 QPulseGenerator(const QVector& config, const gsl_rng* randGen, bool useRK = false);
00029 ~QPulseGenerator();
00030 void Dump(ostream& o);
00031
00033 int GetChannelId() const { return fChannelId; }
00035 double GetSamplingFrequency() const { return fSamplFreq; }
00037 bool NeedNoisePS() const { return fNeedNoisePS; }
00039 void SetNoisePS(const QVector& noisePS);
00041 bool NeedAmplitudeHisto() const { return fNeedAmplitudeHisto; }
00043 void SetAmplitudeHisto(const TH1D& histo);
00045 void GenerateFromEnergy(bool fromEnergy) { fGenerateFromEnergy = fromEnergy; }
00047 void SetCalibrationFunction(const TF1& calibFunc) { fCalibrationFunction = calibFunc; }
00049 void SetHeaterPosition(const double heaterPos) { fHeaterPos = heaterPos; }
00050
00052 void Generate();
00054 double GetTime() const { return fMainEventInfo.fTime; }
00055
00057 void FillWindow(QVector& window) const;
00059 int GetMasterSampleIndex() const { return fMasterSampleIndex; }
00061 vector<int> GetSamplesIndex() const { return fSamplesIndex; }
00062
00064 bool operator<(const QPulseGenerator& other) const { return GetTime() < other.GetTime(); }
00065 enum EventType {
00066 ET_Signal,
00067 ET_Heater,
00068 ET_Noise,
00069 };
00070
00071 class EventInfo {
00072 public:
00073 bool operator<(const EventInfo& other) const { return fTime < other.fTime; }
00075 double fTime;
00077 double fDeltaT;
00079 double fEnergy;
00081 double fThermalAmplitude;
00083 double fAmplitude;
00085 double fMax;
00087 double fMaxPos;
00089 double fAmplAfterMax;
00091 double fBaseline;
00093 EventType fEventType;
00094 };
00095
00097 vector<EventInfo> GetEventInfo() const {return fWindowEventInfo;}
00099 EventInfo GetMainEventInfo() const { return fMainEventInfo;}
00100
00101 private:
00102
00104 const QVector& GenerateNoise(bool continued, size_t nsamples);
00106 double GenerateAmplitude();
00108 double GenerateDeltaT();
00113 EventInfo GenerateDeltaTAndAmplitude();
00114 void GenerateBaseline();
00116 const QVector& GeneratePulse(double delay, double amplitude, double& max, double& maxpos, double& amplAfterMax);
00118 void FillInfo();
00120 void Init(const QVector& config);
00121
00122 bool fFirstCall;
00123
00124 bool fGenerateFromEnergy;
00125 TF1 fCalibrationFunction;
00126 double fHeaterPos;
00127 int fChannelId;
00128 int fNumSamples;
00129 double fSamplFreq;
00130 double fBesselCutOff;
00131 double fWideDuration;
00132 double fPreTrigger;
00133 double fBaseline;
00134 QMathFunction* fPhysicsPulse;
00135 double fThermalMax;
00136 double fBesselGain;
00137 double* fParams;
00138
00139 QNoiseGenerator* fNoiseGenerator;
00140 QAmplitudeGenerator* fAmplitudeGenerator;
00141
00142 const gsl_rng* fRandomGen;
00143
00144 double fTime;
00145
00146 size_t fWideWindowSize;
00147 size_t fWideWindowRatio;
00148 QVector fWideWindow;
00149 QVector fPulseWindow;
00150 QVector fNoiseRemainder;
00151 QVector fNoiseWindow;
00152
00153 list<EventInfo> fEventInfos;
00154 list<EventInfo>::iterator fMainEventIter;
00155 vector<EventInfo> fWindowEventInfo;
00156 EventInfo fMainEventInfo;
00157
00158 int fMasterSampleIndex;
00159 vector<int> fSamplesIndex;
00160
00161 int fBaselineDistrType;
00162 double fBaselineStart;
00163 double fBaselineDistrP2;
00164 QAmplitudeGenerator::Type fAmplDistrType;
00165 bool fNeedAmplitudeHisto;
00166 double fAmplDistrP1;
00167 double fAmplDistrP2;
00168 int fTimeDistrType;
00169 double fTimeDistrP1;
00170 double fTimeDistrP2;
00171 QNoiseGenerator::Type fNoiseDistrType ;
00172 bool fNeedNoisePS;
00173 double fNoiseDistrP1;
00174 double fNoiseDistrP2;
00175
00176 double fR_S_Start;
00177 bool fUseRK;
00178 bool fIsHeater;
00179
00180 };
00181 #endif