source: trunk/WuerzburgSoft/Thomas/mphys/MPhoton.cc@ 1357

Last change on this file since 1357 was 1356, checked in by tbretz, 24 years ago
*** empty log message ***
File size: 5.9 KB
Line 
1/* ======================================================================== *\
2!
3! *
4! * This file is part of MARS, the MAGIC Analysis and Reconstruction
5! * Software. It is distributed to you in the hope that it can be a useful
6! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
7! * It is distributed WITHOUT ANY WARRANTY.
8! *
9! * Permission to use, copy, modify and distribute this software and its
10! * documentation for any purpose is hereby granted without fee,
11! * provided that the above copyright notice appear in all copies and
12! * that both that copyright notice and this permission notice appear
13! * in supporting documentation. It is provided "as is" without express
14! * or implied warranty.
15! *
16!
17!
18! Author(s): Harald Kornmayer 1/2001 (harald@mppmu.mpg.de)
19! Author(s): Thomas Bretz 12/2000 (tbretz@uni-sw.gwdg.de)
20!
21! Copyright: MAGIC Software Development, 2000-2001
22!
23!
24\* ======================================================================== */
25
26//////////////////////////////////////////////////////////////////////////////
27// //
28// //
29//////////////////////////////////////////////////////////////////////////////
30#include "MPhoton.h"
31
32#include <iostream.h>
33
34#include <TF1.h>
35#include <TH1.h>
36#include <TPad.h>
37#include <TCanvas.h>
38
39ClassImp(MPhoton);
40
41Double_t MPhoton::Planck(Double_t *x, Double_t *k=NULL)
42{
43 //
44 // Planck, per unit volume, per unit energy
45 //
46 // constants moved out of function, see below
47 //
48 const Double_t E = x[0]; // [GeV]
49 const Double_t z = k ? k[0] : 0;
50
51 const Double_t T = 2.96*(z+1); // [K]
52 const Double_t e = 1.602176462e-19; // [C]
53 const Double_t kB = 1e-9/e*1.3806503e-23; // [GeV/K]
54
55 const Double_t EkT = E/kB/T;
56
57 /*
58 //Double_t c = 299792458; // [m/s]
59 //Double_t h = 1e-9/e*6.62606876e-34; // [GeVs]
60 //Double_t hc = h*c; // [GeVm]
61
62 Double_t konst = 4.*TMath::Pi() * 2. / (hc*hc*hc);
63 return konst * E*E / (exp(EkT)-1.); // [1 / GeV / m^3 ]
64 */
65
66 return E*E / (exp(EkT)-1.); // [GeV^2]
67}
68
69Double_t MPhoton::Sigma_gg(Double_t *x, Double_t *k=NULL)
70{
71 const Double_t m2 = x[0]; // m2: (E0/sqrt(s))^2
72
73 const Double_t r0 = 2.81794092e-15; // [m] = e^2/4/pi/m/eps0/c^2
74
75 const Double_t beta2 = 1.-m2;
76 const Double_t beta = sqrt(beta2);
77
78 const Double_t p1 = r0*r0*TMath::Pi()/2;
79
80 // ----- Extreme Relativistic -------
81 // return p1*2 * m*m*m* (log(2./m)-1);
82 // ----------------------------------
83
84 const Double_t p2 = 3.-beta2*beta2;
85 const Double_t p3 = log((1.+beta)/(1.-beta));
86 const Double_t p4 = beta*2*(1.+m2);
87
88 const Double_t sigma = p1*m2*(p2*p3-p4); // [m^2]
89
90 return sigma;
91}
92
93Double_t MPhoton::Int1(Double_t *x, Double_t *k=NULL)
94{
95 const Double_t costheta = x[0];
96
97 const Double_t Eg = k[0];
98 const Double_t Ep = k[1];
99
100 const Double_t E0 = 511e-6; // [GeV]
101
102 Double_t s = E0/Eg*E0/Ep/(1.-costheta)/2;
103 if (s>1) // Why is this necessary???
104 return 0;
105
106 const Double_t sigma = Sigma_gg(&s); // [m^2]
107
108 return sigma/2 * (1.-costheta); // [m^2]
109}
110
111Double_t MPhoton::Int2(Double_t *x, Double_t *k)
112{
113 const Double_t E0 = 511e-6; // [GeV]
114
115 Double_t Ep = x[0];
116 Double_t z = k[1];
117
118 const Double_t Eg = k[0];
119
120 Double_t val[2] = { Eg, Ep };
121
122 const Double_t from = -1.0;
123 const Double_t to = 1.-E0*E0/(2.*Eg*Ep); // Originally Was: 1.
124
125 TF1 f("int1", Int1, from, to, 2);
126
127 const Double_t int1 = f.Integral(from, to, val); // [m^2]
128 const Double_t planck = Planck(&Ep, &z); // [GeV^2]
129
130 const Double_t res = planck * int1;
131
132 return res; // [GeV^2 m^2]
133}
134
135// --------------------------------------------------------------------------
136//
137// Returns 0 in case IL becomes (numerically) infinite.
138//
139Double_t MPhoton::InteractionLength(Double_t *x, Double_t *k=NULL)
140{
141 Double_t E0 = 511e-6; // [GeV]
142 Double_t c = 299792458; // [m/s]
143 Double_t e = 1.602176462e-19; // [C]
144 Double_t h = 1e-9/e*6.62606876e-34; // [GeVs]
145 Double_t hc = h*c; // [GeVm]
146 Double_t pc = 1./3.258; // [pc/ly]
147 Double_t ly = 3600.*24.*365.*c; // [m/ly]
148
149 Double_t Eg = x[0];
150 Double_t z = k ? k[0] : 0;
151
152 Double_t val[2] = { Eg, z };
153
154 Double_t lolim = E0*E0 > 1e-8 ? E0*E0/Eg : 1e-8/Eg;
155 Double_t inf = 3e-11;
156
157 TF1 f("int2", Int2, lolim, inf, 2);
158
159 Double_t int2 = f.Integral(lolim, inf, val); //[GeV^3 m^2]
160
161 if (int2==0)
162 {
163 //cout << "---> Int2==0 <---" << endl;
164 return 0;
165 }
166
167 /* Planck constants: konst */
168 Double_t konst = 4.*TMath::Pi() * 2. / (hc*hc*hc);
169 int2 *= konst; // [1 / m]
170
171 Double_t res = 1./ int2; // [m]
172 res *= pc/ly * 1e-3; // [kpc]
173
174 if (res > 1e50) return 1e50;
175 if (res < 0) return 1e35;
176
177 return res; //[kpc]
178}
179
180Double_t MPhoton::GetInteractionLength(Double_t energy, Double_t z)
181{
182 return InteractionLength(&energy, &z);
183}
184
185Double_t MPhoton::GetInteractionLength() const
186{
187 return InteractionLength((Double_t*)&fEnergy, (Double_t*)&fZ);
188}
189
190void MPhoton::DrawInteractionLength(Double_t z)
191{
192 if (!gPad)
193 new TCanvas("ILPhoton", "Mean Interaction Length Photon");
194 else
195 gPad->GetVirtCanvas()->cd(4);
196
197 TF1 f1("length", InteractionLength, 1e4, 1e11, 1);
198 f1.SetParameter(0, z);
199
200 gPad->SetLogx();
201 gPad->SetLogy();
202 gPad->SetGrid();
203 f1.SetMaximum(1e5);
204 f1.SetLineWidth(1);
205
206 TH1 &h=*f1.DrawCopy()->GetHistogram();
207
208 h.SetTitle("Mean Interaction Length (Photon)");
209 h.SetXTitle("E [GeV]");
210 h.SetYTitle("x [kpc]");
211
212 gPad->Modified();
213 gPad->Update();
214}
215
216void MPhoton::DrawInteractionLength() const
217{
218 DrawInteractionLength(fZ);
219}
Note: See TracBrowser for help on using the repository browser.