Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
47 | f9daq | 1 | #include "TROOT.h" |
2 | #include "TFile.h" |
||
3 | #include "TBenchmark.h" |
||
4 | #include "TH1F.h" |
||
5 | #include "TH2F.h" |
||
6 | #include "TCanvas.h" |
||
7 | #include "TStyle.h" |
||
8 | #include "TPad.h" |
||
9 | #include "TPaveText.h" |
||
10 | //#include "TLabel.h" |
||
11 | #include "TF1.h" |
||
12 | #include "TGraph.h" |
||
13 | #include "TSpectrum.h" |
||
14 | #include "stdio.h" |
||
15 | |||
16 | #include "include/RTUtil.h" |
||
17 | |||
18 | int focus(char filename[256] = "test", int chX=3, int chY=2, double parameter1=16.90, double parameter2=17.20, bool debug = false) |
||
19 | { |
||
20 | const int c_nChannels = 64; |
||
21 | |||
22 | int map[8][8]={{32,34,53,55,40,42,61,63}, |
||
23 | {48,50,37,39,56,58,45,47}, |
||
24 | {33,35,52,54,41,43,60,62}, |
||
25 | {49,51,36,38,57,59,44,46}, |
||
26 | {17,19,4,6,25,27,12,14}, |
||
27 | {1,3,20,22,9,11,28,30}, |
||
28 | {16,18,5,7,24,26,13,15}, |
||
29 | {0,2,21,23,8,10,29,31} |
||
30 | }; |
||
31 | |||
32 | char fnameroot[256]; |
||
33 | TFile* rootfile; |
||
34 | sprintf(fnameroot, "root/%s.root", filename); |
||
35 | rootfile = (TFile *) gROOT->FindObject(filename); |
||
36 | if(rootfile==NULL) rootfile = new TFile(fnameroot); |
||
37 | if(rootfile==NULL) { |
||
38 | printf("Cannot open root file %s!!!\n",fnameroot); |
||
39 | return(0); |
||
40 | } |
||
41 | |||
42 | // set draw style |
||
43 | RTSetStyle(gStyle); |
||
44 | |||
45 | /** Draws the beam profile and fits it with error function |
||
46 | * on some background function |
||
47 | */ |
||
48 | |||
49 | TCanvas* canvas9 = new TCanvas("canvas9","canvas9", 500,500); |
||
50 | canvas9->cd(); |
||
51 | char hname[128]; |
||
52 | int channel = map[chX][chY]; |
||
53 | sprintf(hname, "hnhitsx%d", channel); |
||
54 | TH1F* h_laser = (TH1F*)rootfile->Get(hname); |
||
55 | h_laser->Draw(); |
||
56 | h_laser->SetStats(1); |
||
57 | |||
58 | TF1* err = new TF1("err","[0]+[1]*TMath::Erf((x-[2])/[3])",parameter1,parameter2); |
||
59 | err->SetParameter(0,2500); |
||
60 | err->SetParameter(1, h_laser->GetMaximum()); |
||
61 | err->SetParameter(2, h_laser->GetBinCenter(h_laser->GetMaximumBin())); |
||
62 | err->SetParameter(3, 0.001); |
||
63 | h_laser->Fit(err,"qr"); |
||
64 | h_laser->Fit(err,"lr"); |
||
65 | double sigma = err->GetParameter(3); |
||
66 | printf("sigma = %2.0f um, FWHM = %2.0f um\n", sigma*1000, 2.35*sigma*1000); |
||
67 | |||
68 | return 0; |
||
69 | |||
70 | } |