source: fact/tools/rootmacros/testfir.C@ 13501

Last change on this file since 13501 was 12166, checked in by neise, 13 years ago
initial commit
File size: 1.3 KB
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
11vector<float> Vmeas(FAD_MAX_SAMPLES);
12vector <float> Vfir(FAD_MAX_SAMPLES);
13vector <float> Vpulse(FAD_MAX_SAMPLES);
14#include "factfir.C"
15
16
17#define k 16
18double a[k];
19double b=k;
20
21void 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.