source: trunk/WuerzburgSoft/Thomas/mphys/MPairProduction.cc@ 3038

Last change on this file since 3038 was 1449, checked in by tbretz, 22 years ago
*** empty log message ***
File size: 5.7 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): Thomas Bretz 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2002
21!
22!
23\* ======================================================================== */
24
25//////////////////////////////////////////////////////////////////////////////
26// //
27// //
28//////////////////////////////////////////////////////////////////////////////
29#include "MPairProduction.h"
30
31#include <TF1.h>
32#include <TMath.h>
33#include <TRandom.h>
34
35#include "TList.h"
36#include "MElectron.h"
37
38ClassImp(MPairProduction);
39
40Double_t AngleDistrib(Double_t *x, Double_t *k)
41{
42
43 const Double_t c = x[0]; // cos(alpha)
44 const Double_t b = k[0]; // sqrt(1-1/s)
45
46 const Double_t b2 = b*b;
47 const Double_t b4 = b2*b2;
48
49 const Double_t c2 = c*c;
50 const Double_t c4 = c2*c2;
51
52 const Double_t u = 1 - b4*c4 +2*b2*(1-b2)*(1-c2);
53 const Double_t d = 1-b2*c2;
54
55 return u/(d*d);
56}
57
58// --------------------------------------------------------------------------
59MPairProduction::MPairProduction()
60{
61 fAngle = new TF1("AngleDistrib", AngleDistrib, -1, 1, 1);
62}
63
64MPairProduction::~MPairProduction()
65{
66 delete fAngle;
67}
68
69#include <iostream.h>
70
71// --------------------------------------------------------------------------
72Bool_t MPairProduction::Process(MParticle *gamma, const Double_t Ep, const Double_t theta, TList *list)
73{
74 //
75 // gamma: primary particle from source
76 // phot: infrared photon from background. (angle = interaction angle)
77 // Ep: Energy photon [GeV]
78 // theta: interaction angle [rad]
79 //
80 const Double_t E0 = 511e-6; // [GeV]
81 const Double_t Eg = gamma->GetEnergy(); // [GeV]
82
83 const Double_t ctheta = cos(theta);
84
85 const Double_t s = Ep*Eg*2*(1-ctheta); //[1]
86 const Double_t S = s/(E0*E0*4); //[1]
87 if (S<1)
88 return kFALSE;
89
90 const Double_t stheta = sin(theta);
91
92 const Double_t sqrbetah = s/((Eg+Ep)*(Eg+Ep)) + 1;
93 const Double_t sqrbetae = 1.-1./S;
94
95 const Double_t GammaH = (Eg+Ep)/sqrt(s);
96
97 const Double_t psi = stheta/(GammaH*(ctheta-sqrt(sqrbetah)));
98
99 fAngle->SetParameter(0, sqrt(sqrbetae));
100
101 const Double_t alpha = psi-acos(fAngle->GetRandom());
102
103 const Double_t salpha = sin(alpha);
104 const Double_t calpha = cos(alpha);
105
106 const Double_t tphi = stheta/(Eg/Ep+ctheta); // tan(phi)
107
108 const Double_t bb = sqrt(sqrbetah/sqrbetae);
109
110 const Double_t s1 = calpha/GammaH;
111 const Double_t s2 = tphi*s1 - salpha - bb;
112
113 const Double_t tan1 = ((salpha+bb)*tphi+s1)/s2;
114 const Double_t tan2 = ((salpha-bb)*tphi+s1)/s2;
115
116 const Double_t E = (Eg+Ep)/2;;
117 const Double_t f = sqrt(sqrbetah*sqrbetae)*salpha;
118
119 // cout << " {" << f << "," << E << "," << atan(tan1) << "," << atan(-tan2) << "} " << flush;
120
121 MElectron &p0 = *new MElectron(*gamma, E*(1.-f), kTRUE);
122 MElectron &p1 = *new MElectron(*gamma, E*(1.+f), kFALSE);
123
124 Double_t rnd = gRandom->Uniform(TMath::Pi() * 2);
125 p0.SetNewDirection(atan(+tan1), rnd);
126 p1.SetNewDirection(atan(-tan2), rnd+TMath::Pi());
127
128 list->Add(&p0);
129 list->Add(&p1);
130
131 /*
132 const Double_t Epg = Ep/Eg; // 1+Epg ~ 1
133 const Double_t Egp = Eg/Ep; // 1+Egp ~ Egp
134
135 const Double_t phi = atan(sin(theta)/(Egp+ctheta));
136
137 const Double_t sphi = sin(phi);
138 const Double_t cphi = cos(phi);
139
140 const Double_t alpha = theta-phi;
141 const Double_t calpha = cos(alpha);
142 const Double_t salpha = sin(alpha);
143
144 const Double_t beta = (Eg*cphi+Ep*calpha)/(Ep+Eg);
145
146 //
147 // gamma1 = 1/gamma = sqrt(1-beta*beta)
148 //
149 const Double_t gamma1 = sqrt((sphi*phi+Epg*salpha*Epg*salpha+2*Epg*(1-cphi*calpha)));
150
151 const Double_t Beta = sqrt(1-1/s); //[1]
152
153 fAngle->SetParameter(0, Beta);
154
155 const Double_t psi = atan(gamma1*sphi/(cphi-beta));
156 const Double_t delta = acos(fAngle->GetRandom()) - psi;
157
158 const Double_t Bcosd = Beta*cos(delta);
159 const Double_t Bsind = Beta*sin(delta);
160
161 const Double_t E = sqrt(s)*E0/gamma1;
162 const Double_t dE = E*Bcosd;
163
164 const Double_t E1 = E0/(E+dE);
165 const Double_t E2 = E0/(E-dE);
166
167 const Double_t beta1 = sqrt(1.-E1*E1);
168 const Double_t beta2 = sqrt(1.-E2*E2);
169
170 const Double_t Bscp = Bsind*cphi;
171 const Double_t spg = sphi/gamma1;
172 const Double_t cpg = cphi/gamma1;
173
174 const Double_t tan1 = (spg*(Bcosd+1) + Bscp)/((cpg*(Bcosd+1) - Bscp));
175 const Double_t tan2 = (spg*(Bcosd-1) + Bscp)/((cpg*(Bcosd-1) - Bscp));
176
177 MElectron &p0 = *new MElectron(E+dE, gamma->GetZ());
178 MElectron &p1 = *new MElectron(E-dE, gamma->GetZ());
179 p0 = *gamma; // Set Position and direction
180 p1 = *gamma; // Set Position and direction
181
182 p0.SetBeta(beta1);
183 p1.SetBeta(beta2);
184
185 static TRandom rand(0);
186 Double_t rnd = rand.Uniform(TMath::Pi() * 2);
187 p0.SetNewDirection(atan(tan1), rnd);
188 p1.SetNewDirection(atan(tan2), rnd+TMath::Pi());
189
190 list->Add(&p0);
191 list->Add(&p1);
192 */
193 return kTRUE;
194}
195
Note: See TracBrowser for help on using the repository browser.