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

Last change on this file since 1375 was 1367, checked in by tbretz, 22 years ago
*** empty log message ***
File size: 5.2 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::Sigma_gg(Double_t *x, Double_t *k=NULL)
42{
43 const Double_t m2 = x[0]; // m2: (E0/sqrt(s))^2
44
45 const Double_t r0 = 2.81794092e-15; // [m] = e^2/4/pi/m/eps0/c^2
46
47 const Double_t beta2 = 1.-m2;
48 const Double_t beta = sqrt(beta2);
49
50 const Double_t p1 = r0*r0*TMath::Pi()/2;
51
52 // ----- Extreme Relativistic -------
53 // return p1*2 * m*m*m* (log(2./m)-1);
54 // ----------------------------------
55
56 const Double_t p2 = 3.-beta2*beta2;
57 const Double_t p3 = log((1.+beta)/(1.-beta));
58 const Double_t p4 = beta*2*(1.+m2);
59
60 const Double_t sigma = p1*m2*(p2*p3-p4); // [m^2]
61
62 return sigma;
63}
64
65Double_t MPhoton::Int1(Double_t *x, Double_t *k=NULL)
66{
67 const Double_t costheta = x[0];
68
69 const Double_t Eg = k[0];
70 const Double_t Ep = k[1];
71
72 const Double_t E0 = 511e-6; // [GeV]
73
74 Double_t s = E0/Eg*E0/Ep/(1.-costheta)/2;
75 if (s>1) // Why is this necessary???
76 return 0;
77
78 const Double_t sigma = Sigma_gg(&s); // [m^2]
79
80 return sigma/2 * (1.-costheta); // [m^2]
81}
82
83Double_t MPhoton::Int2(Double_t *x, Double_t *k)
84{
85 const Double_t E0 = 511e-6; // [GeV]
86
87 Double_t Ep = x[0];
88 Double_t z = k[1];
89
90 const Double_t Eg = k[0];
91
92 Double_t val[2] = { Eg, Ep };
93
94 static TF1 f("int1", Int1, 0, 0, 2);
95
96 const Double_t from = -1.0;
97 const Double_t to = 1.-E0*E0/(2.*Eg*Ep); // Originally Was: 1.
98 const Double_t int1 = f.Integral(from, to, val, 1e-2); // [m^2]
99 const Double_t planck = MParticle::Planck(&Ep, &z); // [GeV^2]
100
101 const Double_t res = planck * int1;
102
103 return res; // [GeV^2 m^2]
104}
105
106// --------------------------------------------------------------------------
107//
108// Returns 0 in case IL becomes (numerically) infinite.
109//
110Double_t MPhoton::InteractionLength(Double_t *x, Double_t *k=NULL)
111{
112 Double_t E0 = 511e-6; // [GeV]
113 Double_t c = 299792458; // [m/s]
114 Double_t e = 1.602176462e-19; // [C]
115 Double_t h = 1e-9/e*6.62606876e-34; // [GeVs]
116 Double_t hc = h*c; // [GeVm]
117 Double_t pc = 1./3.258; // [pc/ly]
118 Double_t ly = 3600.*24.*365.*c; // [m/ly]
119
120 Double_t Eg = x[0];
121 Double_t z = k ? k[0] : 0;
122
123 Double_t val[2] = { Eg, z };
124
125 static TF1 f("int2", Int2, 0, 0, 2);
126
127 Double_t lolim = E0*E0/Eg;
128 Double_t inf = Eg<1e6 ? 3e-11*(z+1) : 3e-12*(z+1);
129 Double_t int2 = f.Integral(lolim, inf, val, 1e-2); //[GeV^3 m^2]
130
131 if (int2==0)
132 {
133 //cout << "---> Int2==0 <---" << endl;
134 return 0;
135 }
136
137 /* Planck constants: konst */
138 const Double_t konst = 4.*TMath::Pi() * 2. / (hc*hc*hc);
139 int2 *= konst; // [1 / m]
140
141 Double_t res = 1./ int2; // [m]
142 res *= pc/ly * 1e-3; // [kpc]
143
144 if (res > 1e50) return 1e50;
145 if (res < 0) return 1e35;
146
147 return res; //[kpc]
148}
149
150Double_t MPhoton::GetInteractionLength(Double_t energy, Double_t z)
151{
152 return InteractionLength(&energy, &z);
153}
154
155Double_t MPhoton::GetInteractionLength() const
156{
157 return InteractionLength((Double_t*)&fEnergy, (Double_t*)&fZ);
158}
159
160void MPhoton::DrawInteractionLength(Double_t z, Double_t from, Double_t to)
161{
162 if (!gPad)
163 new TCanvas("ILPhoton", "Mean Interaction Length Photon");
164 else
165 gPad->GetVirtCanvas()->cd(4);
166
167 TF1 f1("length", InteractionLength, from, to, 1);
168 f1.SetParameter(0, z);
169
170 gPad->SetLogx();
171 gPad->SetLogy();
172 gPad->SetGrid();
173 f1.SetMaximum(1e5);
174 f1.SetLineWidth(1);
175
176 TH1 &h=*f1.DrawCopy()->GetHistogram();
177
178 h.SetTitle("Mean Interaction Length (Photon)");
179 h.SetXTitle("E [GeV]");
180 h.SetYTitle("x [kpc]");
181
182 gPad->Modified();
183 gPad->Update();
184}
185
186void MPhoton::DrawInteractionLength() const
187{
188 DrawInteractionLength(fZ);
189}
Note: See TracBrowser for help on using the repository browser.