source: trunk/WuerzburgSoft/Thomas/mphys/anale.C@ 1362

Last change on this file since 1362 was 1362, checked in by tbretz, 22 years ago
*** empty log message ***
File size: 3.1 KB
Line 
1//Double_t kRad2Deg = 180./TMath::Pi();
2
3void anale()
4{
5 TChain chain("Electrons");
6 chain.Add("cascade01.root");
7 chain.Add("cascade02.root");
8
9 MElectron *e = new MElectron;
10 chain.SetBranchAddress("MElectron.", &e);
11
12 Int_t n = chain.GetEntries();
13
14 cout << "Found " << n << " entries." << endl;
15
16 MBinning binsx;
17 MBinning binsy;
18 MBinning binsr;
19 binsx.SetEdgesLog(80, 1e1, 1e9);
20 binsy.SetEdgesLog(80, 1e1, 1e9);
21 binsr.SetEdgesLog(84, 1e-5, 1.8);
22
23 TH2D h;
24 h.SetName("Photons");
25 h.SetTitle(" Photons from inv.Compton ");
26 h.SetXTitle("E_{e} [GeV]");
27 h.SetYTitle("E\\gamma [GeV]");
28 h.SetZTitle("Counts");
29 MH::SetBinning(&h, &binsx, &binsy);
30
31 TH2D r;
32 r.SetName("ratio");
33 r.SetTitle("Ratio E\\gamma / E_{e}");
34 r.SetXTitle("E_{e} [GeV]");
35 r.SetYTitle("Ratio");
36 r.SetZTitle("Counts");
37 MH::SetBinning(&r, &binsx, &binsr);
38
39 Double_t E = -1;
40 for (int i=0; i<n; i++)
41 {
42 chain.GetEntry(i);
43
44 if (e->IsPrimary())
45 {
46 E = e->GetEnergy();
47 continue;
48 }
49
50 Double_t dE = E - e->GetEnergy();
51
52 h.Fill(E, dE);
53 r.Fill(E, dE/E);
54
55 E = e->GetEnergy();
56 }
57
58 delete e;
59
60 gStyle->SetOptStat(10);
61
62 TLine line;
63 line.SetLineColor(kBlack);
64 line.SetLineWidth(1);
65
66 TCanvas *c = new TCanvas("c1", "name");
67 c->Divide(2,2);
68
69 c->cd(1);
70 gPad->SetLogx();
71 gPad->SetLogy();
72 h.GetXaxis()->SetRangeUser(1e4, 1e9);
73 h.GetXaxis()->SetLabelOffset(-0.015);
74 h.GetXaxis()->SetTitleOffset(1.1);
75 h.GetXaxis()->SetRangeUser(1e4, 1e9);
76 h.GetYaxis()->SetTitleOffset(1.1);
77 h.DrawCopy();
78 TH1 *p=h.ProfileX();
79 p->SetBit(kCanDelete);
80 p->SetTitle("Profile e^{-} / \\gamma ");
81 p->SetLineColor(kRed);
82 p->GetXaxis()->SetLabelOffset(-0.015);
83 p->GetXaxis()->SetTitleOffset(1.1);
84 p->SetXTitle("E_{e} [GeV]");
85 p->SetYTitle("E\\gamma [GeV]");
86 p->SetMinimum(1e3);
87 p->SetMaximum(1e9);
88 p->GetXaxis()->SetRangeUser(1e3, 1e9);
89 p->Draw("same");
90 line.DrawLine(4.2, 4.2, 8.8, 8.8);
91
92 c->cd(2);
93 gPad->SetLogx();
94 gPad->SetLogy();
95 r.GetXaxis()->SetLabelOffset(-0.015);
96 r.GetXaxis()->SetTitleOffset(1.1);
97 r.GetXaxis()->SetRangeUser(1e4, 1e9);
98 r.DrawCopy();
99 p=r.ProfileX();
100 p->SetBit(kCanDelete);
101 p->SetLineColor(kRed);
102 p->Draw("same");
103
104 c->cd(3);
105 gPad->SetLogx();
106 p=h.ProjectionX();
107 p->SetBit(kCanDelete);
108 p->SetTitle("e^{-} / \\gamma Distribution");
109 p->GetXaxis()->SetLabelOffset(-0.015);
110 p->GetXaxis()->SetTitleOffset(1.1);
111 p->GetYaxis()->SetTitleOffset(1.3);
112 p->SetXTitle("E [GeV]");
113 p->SetYTitle("Counts");
114 p->Draw();
115 p=h.ProjectionY();
116 p->SetBit(kCanDelete);
117 p->SetTitle("Projection Y");
118 p->SetLineColor(kBlue);
119 p->Draw("same");
120
121 c->cd(4);
122 gPad->SetLogx();
123 p=r.ProjectionY();
124 p->SetBit(kCanDelete);
125 p->SetTitle("Ratio E\\gamma / E_{e}");
126 p->GetXaxis()->SetLabelOffset(-0.015);
127 p->GetXaxis()->SetTitleOffset(1.1);
128 p->GetYaxis()->SetTitleOffset(1.3);
129 p->SetXTitle("Ratio");
130 p->SetYTitle("Counts");
131 p->SetLineColor(kBlue);
132 p->Draw();
133}
Note: See TracBrowser for help on using the repository browser.