ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/HFmon2012/test/Laser.h
Revision: 1.1
Committed: Tue Aug 14 13:03:54 2012 UTC (12 years, 8 months ago) by gaydin
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Error occurred while calculating annotation data.
Log Message:
bug fix

File Contents

# Content
1 #include <string>
2 #include <vector>
3 #include <iostream>
4 #include <map>
5 #include <utility>
6
7 #include "TNtuple.h"
8 #include "TRandom.h"
9
10 #include "TTree.h"
11 #include "TFile.h"
12 #include "TH1I.h"
13 #include "TH1F.h"
14 #include "TH2F.h"
15 #include "TProfile.h"
16 #include "TString.h"
17 #include "TMath.h"
18 #include "TF1.h"
19 #include "TString.h"
20 #include "TCanvas.h"
21 #include "TCut.h"
22
23 using namespace std;
24
25
26 class Laser{
27 public:
28 Laser(double rin = 0.9, double win = 0.1, double inn = 10){
29 r = rin;
30 s1 = 100.;
31 s2 = r*s1;
32
33 w = win;
34 noiseFactor = inn;
35 f1 = new TF1("f1","gaus",-10,20);
36 f2 = new TF1("f2","gaus",-10,20);
37
38 fLaser = new TF1("fLaser","gaus(0)+gaus(3)",-5,10);
39
40 f1->SetParameter(0,s1);
41 f2->SetParameter(0,s2);
42
43 f1->SetParameter(1,0);
44 f2->SetParameter(1,1);
45
46 f1->SetParameter(2,w);
47 f2->SetParameter(2,w);
48
49 fLaser->SetParameter(0,s1);
50 fLaser->SetParameter(3,s2);
51
52 fLaser->SetParameter(1,0);
53 fLaser->SetParameter(4,1);
54
55 fLaser->SetParameter(2,w);
56 fLaser->SetParameter(5,w);
57
58
59 }
60
61 void fillHit(TH1* h, double phase = 0){
62
63 h->Reset();
64 for(int i = 0; i < h->GetNbinsX(); ++i){
65 double low = h->GetBinLowEdge(i);
66 double high = h->GetBinLowEdge(i+1);
67 double mid = (low+high)/2.;
68
69 low = low + phase - 4;
70 high = high + phase - 4;
71
72 double adc = f1->Integral(low,high)+f2->Integral(low,high);
73
74 h->Fill(mid,adc);
75 h->Fill(i+0.5,noiseFactor*(gRandom->Uniform()-0.5));
76
77 }
78
79 h->Draw();
80
81 };
82
83
84 void Draw(){
85 f1->SetLineColor(2);
86 f2->SetLineColor(4);
87 f1->SetLineWidth(1);
88 f2->SetLineWidth(1);
89 f2->SetLineStyle(2);
90 f1->SetLineStyle(2);
91
92 fLaser->SetLineColor(1);
93 fLaser->GetXaxis()->SetTitle("t/25ns + arbitrary constant");
94 fLaser->GetYaxis()->SetTitle("Charge #times arbitrary constant");
95
96 fLaser->GetXaxis()->CenterTitle();
97 fLaser->GetYaxis()->CenterTitle();
98 fLaser->SetLineStyle(1);
99
100 fLaser->Draw();
101 f2->Draw("same");
102 f1->Draw("same");
103 // fLaser->Draw("same");
104
105 }
106
107
108 double s1,s2,r,w, noiseFactor;
109 TF1* f1, *f2, *fLaser;
110
111
112
113 };
114
115
116 void findPeak(TH1D* hit,double& s0,double& s1,double& s2,double& s3, int& ts){
117
118 double max1 = -9999;
119 double imax1 = -1;
120
121 for(int i = 1; i < hit->GetNbinsX()+1; ++i){
122 double y = hit->GetBinContent(i)+hit->GetBinContent(i+1);
123 if(y>max1){
124 max1 = y;
125 imax1 = i;
126 }
127 }
128
129 ts = imax1;
130 s0 = hit->GetBinContent(imax1-1);
131 s1 = hit->GetBinContent(imax1);
132 s2 = hit->GetBinContent(imax1+1);
133 s3 = hit->GetBinContent(imax1+2);
134
135 }
136
137
138
139
140
141
142
143
144