forked from gsmith23/Simlab
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTTheory.C
executable file
·257 lines (190 loc) · 6.74 KB
/
TTheory.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
#include "TTheory.h"
//#include "./includes.h"
// Default constructor
TTheory::TTheory(){
}
// Destructor
TTheory::~TTheory(){
}
//----------------------------------------------
// Finite Geometry Asymmetry Calculation
// Snyder 1948
// Angular Correlation of Scattered Annihilation Radiation
// http://link.aps.org/doi/10.1103/PhysRev.73.440
// Member functions below are used to calculate
// rho = N(90)/N(0)
Float_t TTheory::X(Float_t theta){
return ( 2. - Cos(theta) );
}
Float_t TTheory::JLim(Float_t theta){
return ( Log(X(theta)) - 1./( 2.*X(theta)*X(theta) ) );
}
Float_t TTheory::J(Float_t theta, Float_t semiSpan){
return ( JLim(theta+semiSpan) - JLim(theta-semiSpan) ) ;
}
Float_t TTheory::JdashLim(Float_t theta){
return ( -X(theta) + 4.*Log(X(theta)) + 3./( X(theta) ) );
}
Float_t TTheory::Jdash(Float_t theta, Float_t semiSpan){
return ( JdashLim(theta+semiSpan) - JdashLim(theta-semiSpan) ) ;
}
// Asymmetry for finite theta only
// semi-span is half the size of the detector in theta
Float_t TTheory::rho1(Float_t theta, Float_t semiSpan){
return ( 1. + 1./( 1./2.*( J(theta,semiSpan)/Jdash(theta,semiSpan) )*( J(theta,semiSpan)/Jdash(theta,semiSpan) ) - ( J(theta,semiSpan)/Jdash(theta,semiSpan) ) ) );
}
Float_t TTheory::u(Float_t alpha){
return ( 2*alpha*alpha - 1./2.*Sin(2*alpha)*Sin(2*alpha) );
}
Float_t TTheory::w(Float_t alpha){
return ( 2*alpha*alpha + 1./2.*Sin(2*alpha)*Sin(2*alpha) );
}
Float_t TTheory::Z(Float_t alpha){
return (u(alpha)/w(alpha));
}
// Asymmetry for finite theta and finite phi
// alpha is half the size of the detector in phi
Float_t TTheory::rho2(Float_t theta, Float_t semiSpan, Float_t alpha){
return ( (Z(alpha) + rho1(theta,semiSpan) )/( 1 + Z(alpha)*rho1(theta,semiSpan)) );
}
//working stage - no resolution
Float_t TTheory::modFactor(Float_t theta1, Float_t theta2){
Float_t m1 = Power(Sin(theta1),2.)*(2. - Cos(theta1))/(2. + Power((1.- Cos(theta1)),3.));
Float_t m2 = Power(Sin(theta2),2.)*(2. - Cos(theta2))/(2. + Power((1.- Cos(theta2)),3.));
return m1*m2;
}
//--------------------------------------------------
// Compton scattering variable conversions
Float_t TTheory::ThetaToPhotonEnergy(Float_t theta){
return (511./(2 - Cos(TMath::DegToRad()*theta)));
}
Float_t TTheory::ThetaToElectronEnergy(Float_t theta){
return (511. - (511./(2. - Cos(TMath::DegToRad()*theta))));
}
//--------------------------------------------------
// Plotting routine
void TTheory::GraphFiniteAsymmetry(Int_t nBins,
Float_t semiSpan,
Char_t xVariable){
TCanvas *canvas = new TCanvas("canvas","canvas",
10,10,1200,800);
// This is a dummy histogram which is
// used for setting the axis on the TGraph
TH1F * hr = new TH1F();
// Plot as a function of energy or theta
if ( xVariable=='t')
hr = canvas->DrawFrame(0.0,0.5,180.0,3.0);
else if( xVariable=='e'){
hr = canvas->DrawFrame(0.0,0.5, 511.,3.0);
}
TGraphErrors * gr[3];
// this second graph array is used for simultaneously
// plotting as a function of photon energy when plotting
// as a function of electron energy (energy deposited
// in 1st crystal)
TGraphErrors * gr2[3];
Float_t theta[nBins];
Float_t elecNRG[nBins];
Float_t gammaNRG[nBins];
Float_t asymm1[nBins];
Float_t asymm2[nBins];
Float_t asymm3[nBins];
// To Do: determine resolution
// of detector system using simulation
Float_t alpha1 = 20.;
Float_t alpha2 = 30.;
Float_t alpha3 = 40.;
TLegend * leg = new TLegend(0.6,0.7,0.8,0.85);
TString legTit;
legTit.Form("semi span #theta = %.1f ^{o}",
semiSpan);
leg->AddEntry((TObject*)0,legTit, "");
TString legStr[3];
legStr[0].Form("#alpha_{#phi} = %.1f ^{o}",
alpha1);
legStr[1].Form("#alpha_{#phi} = %.1f ^{o}",
alpha2);
legStr[2].Form("#alpha_{#phi} = %.1f ^{o}",
alpha3);
alpha1 = alpha1 * DegToRad();
alpha2 = alpha2 * DegToRad();
alpha3 = alpha3 * DegToRad();
semiSpan = DegToRad()*semiSpan;
Float_t centreTh = 94.;
for(Int_t i = 0 ; i < nBins ; i++){
// symmetric bins around centreTh
theta[i] = centreTh - (nBins-1)*semiSpan*RadToDeg();
theta[i] = theta[i] + i*2*semiSpan*RadToDeg();
elecNRG[i] = ThetaToElectronEnergy(theta[i]);
gammaNRG[i] = ThetaToPhotonEnergy(theta[i]);
theta[i] = theta[i]*DegToRad();
asymm1[i] = rho2(theta[i],semiSpan,alpha1);
asymm2[i] = rho2(theta[i],semiSpan,alpha2);
asymm3[i] = rho2(theta[i],semiSpan,alpha3);
theta[i] = theta[i]*RadToDeg();
}
if ( xVariable=='t'){
hr->GetXaxis()->SetTitle("#theta (deg)");
gr[0] = new TGraphErrors(nBins,theta,asymm1,0,0);
gr[1] = new TGraphErrors(nBins,theta,asymm2,0,0);
gr[2] = new TGraphErrors(nBins,theta,asymm3,0,0);
}
else if( xVariable=='e'){
hr->GetXaxis()->SetTitle("energy (keV): electron (dashed), photon (solid)");
gr[0] = new TGraphErrors(nBins,elecNRG,asymm1,0,0);
gr[1] = new TGraphErrors(nBins,elecNRG,asymm2,0,0);
gr[2] = new TGraphErrors(nBins,elecNRG,asymm3,0,0);
gr2[0] = new TGraphErrors(nBins,gammaNRG,asymm1,0,0);
gr2[1] = new TGraphErrors(nBins,gammaNRG,asymm2,0,0);
gr2[2] = new TGraphErrors(nBins,gammaNRG,asymm3,0,0);
}
gr[0]->SetLineColor(kRed+1);
gr[0]->SetMarkerColor(kRed+1);
gr[0]->SetMarkerStyle(20);
gr[0]->SetLineStyle(2);
if( xVariable=='e'){
gr2[0]->SetLineColor(kRed-2);
gr2[0]->SetMarkerColor(kRed-2);
gr2[0]->SetMarkerStyle(20);
}
gr[1]->SetLineColor(kBlue+1);
gr[1]->SetMarkerColor(kBlue+1);
gr[1]->SetMarkerStyle(20);
gr[1]->SetLineStyle(2);
if( xVariable=='e'){
gr2[1]->SetLineColor(kBlue-2);
gr2[1]->SetMarkerColor(kBlue-2);
gr2[1]->SetMarkerStyle(20);
}
gr[2]->SetLineColor(kGreen+3);
gr[2]->SetMarkerColor(kGreen+3);
gr[2]->SetMarkerStyle(20);
gr[2]->SetLineStyle(2);
if( xVariable=='e'){
gr2[2]->SetLineColor(kGreen+1);
gr2[2]->SetMarkerColor(kGreen+1);
gr2[2]->SetMarkerStyle(20);
}
TString plotStyle = "PL";
gr[0]->Draw(plotStyle);
plotStyle = plotStyle + "same";
gr[1]->Draw(plotStyle);
gr[2]->Draw(plotStyle);
if( xVariable=='e'){
gr2[0]->Draw(plotStyle);
gr2[1]->Draw(plotStyle);
gr2[2]->Draw(plotStyle);
}
hr->GetYaxis()->SetTitle("P(#Delta#phi = 90)/P(#Delta#phi = 0)");
Char_t plotName[128];
if ( xVariable=='t')
sprintf(plotName,"../Plots/A_Theory_%d_bins_theta.pdf", nBins);
else if( xVariable=='e')
sprintf(plotName,"../Plots/A_Theory_%d_bins_energy.pdf", nBins);
leg->AddEntry(gr[0],legStr[0],plotStyle);
leg->AddEntry(gr[1],legStr[1],plotStyle);
leg->AddEntry(gr[2],legStr[2],plotStyle);
leg->Draw();
canvas->SaveAs(plotName);
}
//--------------------------------------------------