Skip to content
Snippets Groups Projects
Commit 5e3b3692 authored by Chad Lantz's avatar Chad Lantz
Browse files

Implemented addRandNoise with Gaussian noise. Added draw argument to generateWaveform

parent 388a6be2
No related branches found
No related tags found
No related merge requests found
......@@ -11,9 +11,10 @@ using namespace std;
TGraph* getPMTdata( string fileName );
double evaluateSum( vector< TF1* >& funcVec, double x );
void generateWaveform(string fileName);
void generateWaveform(string fileName, bool DRAW = false);
void addDarkCurrent(vector< TF1* >& vec, float timeInterval);
void addRandNoise(vector< float >* vec, float timeInterval);
void addTimingJitter(vector< float >* vec, float timeInterval);
Double_t PMTpulseFunction(Double_t *t, Double_t *par){
Float_t tt = t[0];
......@@ -299,13 +300,13 @@ void PMTcuts(string fileName, int PMTmodel = 6091){
* Generate a waveform as the sum of single photon responses
* Pulse integral to amplitude conversion factor is a result of the following
* integral_21^∞ A*((t - t0)/10)^3.4 exp(-1/10 (t - t0)) dt = A*101.3581
* DRAW saves event display to .png
*/
void generateWaveform(string fileName){
void generateWaveform(string fileName, bool DRAW){
// Choose a path
bool theHardWay = true; // (superposition) Create a TF1 for every photon using each photon's time and energy/wavelength
bool theMiddleWay = false; // (per time bin) Create a TF1 for every time bin using the sum of that bin's photons energy/wavelength
bool theEasyWay = false; // (impulse) Create a single TF1 using the average photon energy (known value = 4.625eV) multiplied by nPhotons in that tile
bool DRAW = true; // Save each event to .png
float inputImpedance = 50.0; // ohms
float gain = 1e6; // unitless
......@@ -383,11 +384,12 @@ void generateWaveform(string fileName){
addRandNoise(waveforms[tile], 204.8);
if(DRAW){
if(DRAW && tile==10){
for(int bin = 0; bin < 1024; bin ++){
h[tile]->SetBinContent(bin, waveforms[tile]->at(bin));
}//end waveform loop
c->cd(tile+1);
// c->cd(tile+1);
c->cd(0);
h[tile]->Draw();
h[tile]->SetAxisRange(-10,750,"Y");
}
......@@ -427,8 +429,15 @@ void generateWaveform(string fileName){
void addRandNoise(vector< float >* vec, float timeInterval){
float sigma = 5.0; //mV
float mean = 0.0; //mV
int size = vec->size();
TRandom2 rnd;
rnd.SetSeed(gSystem->Now());
for(int i = 0; i < size; i++){
vec->at(i) += rnd.Gaus(mean,sigma);
}
}
/*
......@@ -453,7 +462,7 @@ void addDarkCurrent(vector< TF1* >& pulses, float timeInterval){
float aveNpulses = timeInterval*aveNpulsePerNanoSec; // unitless. Probably want to randomize this a bit
float avePulseAmp = 1e3*aveChargePerPulse*gain*inputImpedance/101.3581; // mV
TRandom rnd;
TRandom2 rnd;
rnd.SetSeed(gSystem->Now());
int nPulses = rnd.Poisson( aveNpulses );
for(int i = 0; i < nPulses; i++){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment