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);
00029 ~QPulseGenerator();
00030
00032 int GetChannelId() const { return fChannelId; }
00034 double GetSamplingFrequency() const { return fSamplFreq; }
00036 bool NeedNoisePS() const { return fNeedNoisePS; }
00038 void SetNoisePS(const QVector& noisePS);
00040 bool NeedAmplitudeHisto() const { return fNeedAmplitudeHisto; }
00042 void SetAmplitudeHisto(const TH1D& histo);
00044 void GenerateFromEnergy(bool fromEnergy) { fGenerateFromEnergy = fromEnergy; }
00046 void SetCalibrationFunction(const TF1& calibFunc) { fCalibrationFunction = calibFunc; }
00047
00049 void Generate();
00051 double GetTime() const { return fMainEventInfo.fTime; }
00052
00054 void FillWindow(QVector& window) const;
00056 int GetMasterSampleIndex() const { return fMasterSampleIndex; }
00058 vector<int> GetSamplesIndex() const { return fSamplesIndex; }
00059
00061 bool operator<(const QPulseGenerator& other) const { return GetTime() < other.GetTime(); }
00062
00063 class EventInfo {
00064 public:
00065 bool operator<(const EventInfo& other) const { return fTime < other.fTime; }
00067 double fTime;
00069 double fDeltaT;
00071 double fEnergy;
00073 double fAmplitude;
00075 double fMax;
00077 double fMaxPos;
00078 };
00079
00081 vector<EventInfo> GetEventInfo() const {return fWindowEventInfo;}
00083 EventInfo GetMainEventInfo() const { return fMainEventInfo;}
00084
00085 private:
00086
00088 const QVector& GenerateNoise(bool continued, size_t nsamples);
00090 double GenerateAmplitude();
00092 double GenerateDeltaT();
00097 EventInfo GenerateDeltaTAndAmplitude();
00099 const QVector& GeneratePulse(double delay, double amplitude, double& max, double& maxpos);
00101 void FillInfo();
00103 void Init(const QVector& config);
00104
00105 bool fFirstCall;
00106
00107 bool fGenerateFromEnergy;
00108 TF1 fCalibrationFunction;
00109 int fChannelId;
00110 int fNumSamples;
00111 double fSamplFreq;
00112 double fBesselCutOff;
00113 double fWideDuration;
00114 double fPreTrigger;
00115 double fBaseline;
00116 QMathFunction* fPhysicsPulse;
00117 double fThermalMax;
00118 double fBesselGain;
00119 double* fParams;
00120
00121 QNoiseGenerator* fNoiseGenerator;
00122 QAmplitudeGenerator* fAmplitudeGenerator;
00123
00124 const gsl_rng* fRandomGen;
00125
00126 double fTime;
00127
00128 size_t fWideWindowSize;
00129 size_t fWideWindowRatio;
00130 QVector fWideWindow;
00131 QVector fPulseWindow;
00132 QVector fNoiseRemainder;
00133 QVector fNoiseWindow;
00134
00135 list<EventInfo> fEventInfos;
00136 list<EventInfo>::iterator fMainEventIter;
00137 vector<EventInfo> fWindowEventInfo;
00138 EventInfo fMainEventInfo;
00139
00140 int fMasterSampleIndex;
00141 vector<int> fSamplesIndex;
00142
00143 QAmplitudeGenerator::Type fAmplDistrType;
00144 bool fNeedAmplitudeHisto;
00145 double fAmplDistrP1;
00146 double fAmplDistrP2;
00147 int fTimeDistrType;
00148 double fTimeDistrP1;
00149 double fTimeDistrP2;
00150 QNoiseGenerator::Type fNoiseDistrType ;
00151 bool fNeedNoisePS;
00152 double fNoiseDistrP1;
00153 double fNoiseDistrP2;
00154
00155 };
00156 #endif