source: trunk/WuerzburgSoft/Thomas/mphys/analp.C@ 1369

Last change on this file since 1369 was 1364, checked in by tbretz, 22 years ago
*** empty log message ***
File size: 4.1 KB
Line 
1//Double_t kRad2Deg = 180./TMath::Pi();
2
3void analp()
4{
5 TChain chain("Photons");
6 chain.Add("cascade_500kpc_0*.root");
7 chain.Add("cascade_500kpc_2*.root");
8// chain.Add("cascade_100kpc_0*.root");
9// chain.Add("cascade_100kpc_1*.root");
10
11 MPhoton *p = new MPhoton;
12 chain.SetBranchAddress("MPhoton.", &p);
13
14 Int_t n = chain.GetEntries();
15
16 cout << "Found " << n << " entries." << endl;
17
18 if (n==0)
19 return;
20
21 MBinning binsx;
22 binsx.SetEdgesLog(14, 1e4, 1e11);
23
24 MBinning binspolx;
25 MBinning binspoly1;
26 MBinning binspoly2;
27 binspolx.SetEdges(16, -180, 180);
28
29 const Double_t ls = 299792458; // [m/s]
30 const Double_t ly = 3600.*24.*365.*ls; // [m/ly]
31 const Double_t pc = 1./3.258; // [pc/ly]
32
33 binspoly1.SetEdges(20, 0, 2e-6*3600);
34 binspoly2.SetEdges(20, 0, 1e-5*1e3/pc*365);
35
36 TH1D h;
37 h.SetName("Photons");
38 h.SetTitle(" E^{2} Spectra ");
39 h.SetXTitle("E\\gamma [GeV]");
40 h.SetYTitle("E^{2} * Counts");
41 MH::SetBinning(&h, &binsx);
42
43 TH1D prim;
44 MH::SetBinning(&prim, &binsx);
45
46 TH2D r;
47 TH2D a;
48 MH::SetBinning(&a, &binspolx, &binspoly1);
49 MH::SetBinning(&r, &binspolx, &binspoly2);
50
51 Double_t weight = 0;
52 Double_t alpha = -2;
53 for (int i=0; i<n; i++)
54 {
55 chain.GetEntry(i);
56
57 Double_t Ep = p->GetEnergy();
58
59 if (i==0)
60 weight = pow(Ep, alpha);
61
62 if (p->IsPrimary())
63 {
64 weight = pow(Ep, alpha);
65 prim.Fill(Ep, Ep*Ep * weight);
66 continue;
67 }
68
69 h.Fill(Ep, Ep*Ep * weight);
70 r.Fill(p->GetPhi()*kRad2Deg, p->GetR()*1e3/pc*365, weight);
71 a.Fill(p->GetPsi()*kRad2Deg, p->GetTheta()*kRad2Deg*3600, weight);
72 }
73
74 delete p;
75
76 gStyle->SetOptStat(10);
77
78// delete gROOT->FindObject("Analysis Arrival");
79 c = MH::MakeDefCanvas("Analysis Arrival", "");
80 c->Divide(2,2);
81
82 c->cd(1);
83 gPad->SetLogy();
84 gPad->SetLogz();
85 gPad->SetTheta(70);
86 gPad->SetPhi(90);
87 r.SetTitle(" Distance from Observer ");
88 r.GetXaxis()->SetLabelOffset(-0.015);
89 r.GetXaxis()->SetTitleOffset(1.1);
90 r.GetXaxis()->SetRangeUser(1e4, 1e9);
91 r.SetXTitle("\\Phi [\\circ]");
92 r.SetYTitle("R [light days]");
93 r.DrawCopy("surf1pol");
94
95 c->cd(2);
96 gPad->SetLogy();
97 gPad->SetLogz();
98 gPad->SetTheta(70);
99 gPad->SetPhi(90);
100 a.SetTitle(" Hit Angle for Observer ");
101 a.GetXaxis()->SetLabelOffset(-0.015);
102 a.GetXaxis()->SetTitleOffset(1.1);
103 a.GetXaxis()->SetRangeUser(1e4, 1e9);
104 a.SetXTitle("\\Psi [\\circ]");
105 a.SetYTitle("\\Theta [\"]");
106 a.DrawCopy("surf1pol");
107
108 c->cd(3);
109 gPad->SetLogy();
110 TH1 *g=r.ProjectionY("p1");
111 g->SetBit(kCanDelete);
112 g->SetTitle(" Hit Observers Plain ");
113 g->GetXaxis()->SetLabelOffset(0);
114 g->GetXaxis()->SetTitleOffset(1.1);
115 g->GetYaxis()->SetTitleOffset(1.3);
116 g->SetXTitle("R [light days]");
117 g->SetYTitle("Counts");
118 g->Draw();
119
120 c->cd(4);
121 gPad->SetLogy();
122 g=a.ProjectionY("p2");
123 g->SetBit(kCanDelete);
124 g->SetTitle("Hit Angle");
125 g->GetXaxis()->SetLabelOffset(0);
126 g->GetXaxis()->SetTitleOffset(1.1);
127 g->GetYaxis()->SetTitleOffset(1.3);
128 g->SetXTitle("\\Phi [\"]");
129 g->SetYTitle("Counts");
130 g->Draw();
131
132 // delete gROOT->FindObject("Analysis Photons");
133 TCanvas *c = MH::MakeDefCanvas("Analysis Photons", "", 580, 870);
134 c->Divide(1,2);
135
136 c->cd(1);
137 gPad->SetLogx();
138 gPad->SetLogy();
139 prim.SetFillStyle(0);
140 h.SetFillStyle(0);
141 h.GetXaxis()->SetLabelOffset(-0.015);
142 h.GetXaxis()->SetTitleOffset(1.1);
143// h.GetXaxis()->SetRangeUser(1e4, 1e9);
144 prim.SetMarkerStyle(kPlus);
145 h.SetMarkerStyle(kMultiply);
146 prim.SetMarkerColor(kRed);
147 prim.SetLineColor(kRed);
148
149 h.DrawCopy("P");
150 prim.DrawCopy("Psame");
151 prim.DrawCopy("Csame");
152 h.DrawCopy("Csame");
153
154 c->cd(2);
155 gPad->SetLogx();
156 TH1D div;
157 MH::SetBinning(&div, &binsx);
158 div.Divide(&h, &prim);
159 div.SetTitle("Spectrum / Primara Spectrum");
160 div.GetXaxis()->SetLabelOffset(-0.015);
161 div.GetXaxis()->SetTitleOffset(1.1);
162 div.SetXTitle("E\\gamma [GeV]");
163 div.SetYTitle("Ratio");
164 div.DrawCopy();
165}
Note: See TracBrowser for help on using the repository browser.