Line | |
---|
1 | #include "TRandom2.h"
|
---|
2 | #include "TH1F.h"
|
---|
3 | #include "TCanvas.h"
|
---|
4 |
|
---|
5 | #include <stdio.h>
|
---|
6 | #include <iostream>
|
---|
7 |
|
---|
8 |
|
---|
9 | #define FAD_MAX_SAMPLES 1024
|
---|
10 |
|
---|
11 | vector<float> Vmeas(FAD_MAX_SAMPLES);
|
---|
12 | vector <float> Vfir(FAD_MAX_SAMPLES);
|
---|
13 | vector <float> Vpulse(FAD_MAX_SAMPLES);
|
---|
14 | #include "factfir.C"
|
---|
15 |
|
---|
16 |
|
---|
17 | #define k 16
|
---|
18 | double a[k];
|
---|
19 | double b=k;
|
---|
20 |
|
---|
21 | void testfir(){
|
---|
22 |
|
---|
23 | for (int j=0; j<k; j++){
|
---|
24 | a[j]=1;
|
---|
25 | }
|
---|
26 |
|
---|
27 | TRandom2 myrandom;
|
---|
28 | myrandom.RndmArray(1024,Vmeas);
|
---|
29 |
|
---|
30 | int pulse_start=350;
|
---|
31 | float pulse_height=0.6;
|
---|
32 | int pulse_len = 60;
|
---|
33 | for (int i = pulse_start; i<pulse_start + pulse_len; i++){
|
---|
34 | Vpulse[i] += pulse_height/pulse_len * (pulse_len-(i-pulse_start));
|
---|
35 | // in cas e you want the pulse in the data
|
---|
36 | Vmeas[i] += Vpulse[i];
|
---|
37 | }
|
---|
38 |
|
---|
39 |
|
---|
40 | factfir(b,a,k, Vfir);
|
---|
41 |
|
---|
42 | TH1F *meas = new TH1F("Vmeas","Vmeas test",FAD_MAX_SAMPLES, -0.5 , FAD_MAX_SAMPLES-0.5);
|
---|
43 | TH1F *fir = new TH1F("Vfir","Vfir test",FAD_MAX_SAMPLES, -0.5 , FAD_MAX_SAMPLES-0.5);
|
---|
44 | TH1F *pulse = new TH1F("Vpulse","Vpulse test",FAD_MAX_SAMPLES, -0.5 , FAD_MAX_SAMPLES-0.5);
|
---|
45 |
|
---|
46 | for (int i=0; i<FAD_MAX_SAMPLES; i++){
|
---|
47 | meas->SetBinContent(i,Vmeas[i]);
|
---|
48 | fir->SetBinContent(i,Vfir[i]);
|
---|
49 | pulse->SetBinContent(i,Vpulse[i]);
|
---|
50 | }
|
---|
51 |
|
---|
52 | TCanvas *c = new TCanvas();
|
---|
53 | c->Divide(1,3);
|
---|
54 | c->cd(1);
|
---|
55 | meas->Draw("HIST");
|
---|
56 | c->cd(2);
|
---|
57 | fir->Draw("HIST");
|
---|
58 | c->cd(3);
|
---|
59 | pulse->Draw("HIST");
|
---|
60 |
|
---|
61 |
|
---|
62 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.