#include "StandardLabels.C" void baseline_noise_test(void) { TRandom rnd(time(NULL)); double noise_rate = 1.0; // GHz double noise_amplitude_sigma = 1.0; // mV double max_ramp_rate = 1.0/0.5; // mV/ns double t_width = 130.0; // ns // Start off at t=0 and randomly choose a time difference // to the next point assuming an exponential time structure // until we get past the end of the time window. double t = 0.0; vector times; vector amps; times.push_back(0); // add first point as 0 amplitude amps.push_back(0.0); do{ double s = rnd.Rndm(); double delta_t = -1.0/noise_rate * log(1.0-s); t += delta_t; if(tSetGrid(); c1->SetTicks(); TH2D *axes = new TH2D("axes", "Simulated electronic noise", 100, 0.0, t_width, 100, -10.0, 10.0); axes->SetStats(0); axes->SetXTitle("Time (ns)"); axes->SetYTitle("Amplitude (mV)"); axes->Draw(); spline->SetLineColor(kRed); spline->Draw("same"); TGraph *graph = new TGraph(times.size(), ×[0], &s[0]); graph->SetMarkerStyle(7); graph->SetMarkerSize(0.75); graph->SetMarkerColor(kBlack); graph->Draw("Psame"); char lab[256]; sprintf(lab, "1/#tau:%3.1fGHz #sigma:%3.1fmV max ramp rate:%3.1fmV/ns", noise_rate, noise_amplitude_sigma, max_ramp_rate); StandardLabels(axes, lab); c1->SaveAs("baseline_noise_test.png"); c1->SaveAs("baseline_noise_test.pdf"); }