-
Notifications
You must be signed in to change notification settings - Fork 0
/
Pi0PGen.h
434 lines (312 loc) · 12.3 KB
/
Pi0PGen.h
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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
// Compton Scattering and Pi0P/PiPN Photoproduction Event Generator
// Designed for use with the MAMI A2 Geant4 Simulation
//
// Pi0P photoproduction event generator class
//
// Author - P. Martel
class Pi0PGen : public BaseGen {
protected:
BasePart pPhoton, pTarget, pPi0, pRecoil, pDecay1, pDecay2;
Float_t fPhotEk, fPhotEkCM;
TLorentzVector lvMiss, lvPi0, lvPi0CM, lvReco, lvRecoCM;
TH2F *hPvP1, *hPvP1Lo, *hPvP1Hi, *hPvP2, *hPvP2Lo, *hPvP2Hi, *hMiM;
TH2F *hTpvtp, *hTpvtpi, *htpvtpi;
public:
Pi0PGen(TString, TString, TString, TString, Float_t, Float_t, Int_t, Int_t, Int_t);
~Pi0PGen();
void Init();
void InitCoher();
Bool_t NewEvent(Float_t);
void Reset();
void SaveHists(TString);
};
Pi0PGen::Pi0PGen(TString sName, TString sTarget, TString sRecoil, TString sBase, Float_t fTargMass, Float_t fRecoMass, Int_t iRecoG3id, Int_t beamlo, Int_t beamhi) : BaseGen(sName, sTarget, sRecoil, sBase, beamlo, beamhi), pPhoton("Photon",0), pTarget("Target",fTargMass), pPi0("Pi0",kMPI0_MEV), pRecoil("Recoil",fRecoMass), pDecay1("Decay1",0), pDecay2("Decay2",0) {
cout << "Constructing generator" << endl;
// Setup Geant4 Ntuple
Int_t ptag[4] = {iRecoG3id,7,1,1};
InitNtuple(4,ptag);
// Create some histograms for testing
hPvP1 = new TH2F("hPvP1","Recoil vs Decay Photon1 Theta",180,0,180,180,0,180);
hPvP1->GetXaxis()->SetTitle("Photon Theta (deg)");
hPvP1->GetYaxis()->SetTitle("Recoil Theta (deg)");
hPvP1Lo = new TH2F("hPvP1Lo","Recoil (E<50 MeV) vs Decay Photon1 Theta",180,0,180,180,0,180);
hPvP1Lo->GetXaxis()->SetTitle("Photon Theta (deg)");
hPvP1Lo->GetYaxis()->SetTitle("Recoil Theta (deg)");
hPvP1Lo->SetMarkerColor(2);
hPvP1Hi = new TH2F("hPvP1Hi","Recoil (E>=50 MeV) vs Decay Photon1 Theta",180,0,180,180,0,180);
hPvP1Hi->GetXaxis()->SetTitle("Photon Theta (deg)");
hPvP1Hi->GetYaxis()->SetTitle("Recoil Theta (deg)");
hPvP2 = new TH2F("hPvP2","Recoil vs Decay Photon2 Theta",180,0,180,180,0,180);
hPvP2->GetXaxis()->SetTitle("Photon Theta (deg)");
hPvP2->GetYaxis()->SetTitle("Recoil Theta (deg)");
hPvP2Lo = new TH2F("hPvP2Lo","Recoil (E<50 MeV) vs Decay Photon2 Theta",180,0,180,180,0,180);
hPvP2Lo->GetXaxis()->SetTitle("Photon Theta (deg)");
hPvP2Lo->GetYaxis()->SetTitle("Recoil Theta (deg)");
hPvP2Lo->SetMarkerColor(2);
hPvP2Hi = new TH2F("hPvP2Hi","Recoil (E>=50 MeV) vs Decay Photon2 Theta",180,0,180,180,0,180);
hPvP2Hi->GetXaxis()->SetTitle("Photon Theta (deg)");
hPvP2Hi->GetYaxis()->SetTitle("Recoil Theta (deg)");
Int_t iMassCent = ((TMath::Nint(fRecoMass/50.))*50);
hMiM = new TH2F("hMissM","Missing Mass vs Recoil K",100,0,500,60,iMassCent-150,iMassCent+150);
hMiM->GetXaxis()->SetTitle("Recoil Kinetic Energy (MeV)");
hMiM->GetYaxis()->SetTitle("Missing Mass (MeV)");
hTpvtp = new TH2F("hTpvtp","#gamma p #rightarrow #pi^{0}p;#theta^{p} (deg);T^{p} (MeV)",180,0,180,180,0,180);
hTpvtpi = new TH2F("hTpvtpi","#gamma p #rightarrow #pi^{0}p;#theta^{#pi^{0}}_{cm} (deg);T^{p} (MeV)",180,0,180,180,0,180);
htpvtpi = new TH2F("htpvtpi","#gamma p #rightarrow #pi^{0}p;#theta^{#pi^{0}}_{cm} (deg);#theta^{p} (deg)",180,0,180,180,0,180);
};
Pi0PGen::~Pi0PGen(){
cout << "Deleting generator" << endl;
delete hPvP1;
delete hPvP1Lo;
delete hPvP1Hi;
delete hPvP2;
delete hPvP2Lo;
delete hPvP2Hi;
delete hMiM;
delete hTpvtp;
delete hTpvtpi;
delete htpvtpi;
};
void Pi0PGen::Init(){
// Initialization for Pi0P Photoproduction process
if(bCoher && !bIsotW) InitCoher();
else if(bIsotW){
cout << endl;
cout << "--------------------------------------------------" << endl << endl;
cout << "Using isotropic Pi0P distributions" << endl;
}
else{
cout << endl;
cout << "--------------------------------------------------" << endl << endl;
cout << "Loading Pi0P Photoproduction data files" << endl;
InitBase(sBaseName);
cout << "E (MeV)\t\tMax CS (ub)\tTot CS (ub)" << endl;
CrossGen();
}
cout << endl;
cout << "--------------------------------------------------" << endl << endl;
cout << "Running" << endl << endl;
t1->Branch("Phot",&fPhotEk);
t1->Branch("PhotCM",&fPhotEkCM);
t1->Branch("Pi0",&lvPi0);
t1->Branch("Pi0CM",&lvPi0CM);
t1->Branch("Reco",&lvReco);
t1->Branch("RecoCM",&lvRecoCM);
};
void Pi0PGen::InitCoher(){
// Initialization for Coherent Pi0P Photoproduction process
cout << endl;
cout << "--------------------------------------------------" << endl << endl;
cout << "Constructing Coherent cross sections table" << endl;
Int_t iParN = 0, iEnrN = 0, iAngN = 0, iNPar = 9;
Float_t fCPeak, fKpi, fFFSlope, fQ2, fFq2, fCMax = 0, fScale, fRatio = 1;
if(((iBeamHi-iBeamLo)%5) == 0) iNEnr = (1+((iBeamHi-iBeamLo)/5));
else if(((iBeamHi-iBeamLo)%4) == 0) iNEnr = (1+((iBeamHi-iBeamLo)/4));
else if(((iBeamHi-iBeamLo)%3) == 0) iNEnr = (1+((iBeamHi-iBeamLo)/3));
else if(((iBeamHi-iBeamLo)%2) == 0) iNEnr = (1+((iBeamHi-iBeamLo)/2));
else iNEnr = (1+(iBeamHi-iBeamLo));
iNAng = 37;
iNPhi = 73;
const Int_t iNEnrC = iNEnr;
const Int_t iNAngC = iNAng;
const Int_t iNParC = iNPar;
// Determine step sizes for energy and angle
iBeamSt = ((iBeamHi-iBeamLo)/(iNEnr-1));
iAngSt = (180/(iNAng-1));
// Create arrays to hold input
fPar = new Float_t**[iNParC];
for(iParN=0; iParN<iNPar; iParN++){
fPar[iParN] = new Float_t*[iNEnrC];
for(iEnrN=0; iEnrN<iNEnr; iEnrN++){
fPar[iParN][iEnrN] = new Float_t[iNAngC];
for(iAngN=0; iAngN<iNAng; iAngN++){
fPar[iParN][iEnrN][iAngN] = 0;
}
}
}
fEnr = new Float_t[iNEnrC];
for(iEnrN=0; iEnrN<iNEnr; iEnrN++){
fEnr[iEnrN] = (iBeamLo+(iEnrN*iBeamSt));
fPar[0][iEnrN] = new Float_t[iNAngC];
fPar[1][iEnrN] = new Float_t[iNAngC];
fCPeak = (70.*(290.-fEnr[iEnrN])*(350.-fEnr[iEnrN])/(290.-200.)/(350.-200.)+180.*(fEnr[iEnrN]-200.)*(350.-fEnr[iEnrN])/(290.-200.)/(350.-290.)+200.*(fEnr[iEnrN]-200.)*(fEnr[iEnrN]-290.)/(350.-200.)/(350.-290.));
fKpi = TMath::Sqrt(Sqr(fEnr[iEnrN])-Sqr(kMPI0_MEV));
fFFSlope = (1.05*(268.-fEnr[iEnrN])/(268.-223.)+1.2*(fEnr[iEnrN]-223.)/(268.-223.));
fCMax = 0;
for(iAngN=0; iAngN<iNAng; iAngN++){
fPar[0][iEnrN][iAngN] = (iAngN*iAngSt);
fQ2 = ((Sqr(fEnr[iEnrN])+Sqr(fKpi)-(2*fEnr[iEnrN]*fKpi*cos(fPar[0][iEnrN][iAngN]*kD2R)))/Sqr(197.));
fFq2 = TMath::Exp(-fQ2*fFFSlope);
fPar[1][iEnrN][iAngN] = Sqr(fFq2*sin(fPar[0][iEnrN][iAngN]*kD2R));
if(fPar[1][iEnrN][iAngN] > fCMax) fCMax = fPar[1][iEnrN][iAngN];
}
fScale = (fCPeak/fCMax);
if(sTargName.Contains("3He")) fRatio = (3./12.);
else if(sTargName.Contains("4He")) fRatio = (4./12.);
else if(sTargName.Contains("16O")) fRatio = (16./12.);
fFFSlope = ((1.05*(268.-fEnr[iEnrN])/(268.-223.)+1.2*(fEnr[iEnrN]-223.)/(268.-223.))*TMath::Power(fRatio,(1./3.)));
for(iAngN=0; iAngN<iNAng; iAngN++){
fQ2 = ((Sqr(fEnr[iEnrN])+Sqr(fKpi)-(2*fEnr[iEnrN]*fKpi*cos(fPar[0][iEnrN][iAngN]*kD2R)))/Sqr(197.));
fFq2 = TMath::Exp(-fQ2*fFFSlope);
fPar[1][iEnrN][iAngN] = (Sqr(fFq2*sin(fPar[0][iEnrN][iAngN]*kD2R)*fRatio)*fScale);
}
}
cout << endl << "Produced " << iNEnr << " energies with " << iNAng << " angle entries" << endl << "Giving " << iBeamSt << " MeV and " << iAngSt << " deg steps" << endl << endl;
// Reset bin settings for the cross section histograms
hCrossSec->SetBins(iNEnr,iBeamLo-0.5*iBeamSt,iBeamHi+0.5*iBeamSt,iNAng,-0.5*iAngSt,180+0.5*iAngSt,iNPhi,-180-0.5*iAngSt,180+0.5*iAngSt);
hCrossMax->SetBins(iNEnr,iBeamLo-0.5*iBeamSt,iBeamHi+0.5*iBeamSt);
hCrossTot->SetBins(iNEnr,iBeamLo-0.5*iBeamSt,iBeamHi+0.5*iBeamSt);
cout << "E (MeV)\t\tMax CS (ub)\tTot CS (ub)" << endl;
CrossGen();
};
Bool_t Pi0PGen::NewEvent(Float_t fBeamE){
// Make sure the beam energy is above threshold
if(fBeamE < (((TMath::Power((pPi0.Mass+pRecoil.Mass),2.0))-(TMath::Power((pPhoton.Mass+pTarget.Mass),2.0)))/(2*pTarget.Mass))){
return kFALSE;
}
Bool_t bCheck = kTRUE;
Double_t dCTot = hCrossTot->Interpolate(fBeamE);
if(!bIsotW && ((dCTot*dConv) <= (gRandom->Rndm()))) return kFALSE;
while(bCheck){
// Construct new event
Reset();
NewVertex();
// Set initial state particles
pPhoton.SetP4Lab(fBeamE,fBeamE,0,0);
pTarget.SetP4Lab(pTarget.Mass,0,0,0);
// Introduce a collision to determine energy, momentum, and direction
// of final states particles
Collision2B(pPhoton, pTarget, pPi0, pRecoil);
// Check whether to reject the event based on the selected weighting
bCheck = Reject(fBeamE,pPi0.ThetaCM,pPi0.PhiCM);
}
// For an incoherent process, use the previously determined directions of the
// final state particles but determine the proper energies and momenta
// through a spectral model
if(bIncoh){
SpecModel(pTarget);
Collision2B(pPhoton, pTarget, pPi0, pRecoil);
}
// Make sure the event is above threshold
if(pPi0.Ener<pPi0.Mass){
return kFALSE;
}
// Decay the pi0 into two photons
Decay2B(pPi0, pDecay1, pDecay2);
// Fill the particle histograms and construct the Geant4 Ntuple
pPhoton.HistLab();
pTarget.HistLab();
pPi0.HistLab();
pRecoil.HistLab();
pDecay1.HistLab();
pDecay2.HistLab();
pPhoton.FillNtuple(var,3);
pRecoil.FillNtuple(var,8);
pPi0.FillNtuple(var,13);
pDecay1.FillNtuple(var,18);
pDecay2.FillNtuple(var,23);
// Fill ntuple
h1->Fill(var);
// Fill tree
fPhotEk = pPhoton.KEner;
fPhotEkCM = pPhoton.KEnerCM;
lvPi0 = pPi0.P4;
lvPi0CM = pPi0.P4CM;
lvReco = pRecoil.P4;
lvRecoCM = pRecoil.P4CM;
t1->Fill();
// Fill other test histograms
hPvP1->Fill(pDecay1.Theta,pRecoil.Theta);
hPvP2->Fill(pDecay2.Theta,pRecoil.Theta);
if(pRecoil.KEner<50){
hPvP1Lo->Fill(pDecay1.Theta,pRecoil.Theta);
hPvP2Lo->Fill(pDecay2.Theta,pRecoil.Theta);
}
else{
hPvP1Hi->Fill(pDecay1.Theta,pRecoil.Theta);
hPvP2Hi->Fill(pDecay2.Theta,pRecoil.Theta);
}
lvMiss = (pPhoton.P4+pTarget.P4-pDecay1.P4-pDecay2.P4);
hMiM->Fill(pRecoil.KEner,lvMiss.M());
hTpvtp->Fill(pRecoil.Theta,pRecoil.KEner);
hTpvtpi->Fill(pPi0.ThetaCM,pRecoil.KEner);
htpvtpi->Fill(pPi0.ThetaCM,pRecoil.Theta);
return kTRUE;
};
void Pi0PGen::Reset(){
// Reset particle information
pPhoton.Reset();
pTarget.Reset();
pPi0.Reset();
pRecoil.Reset();
pDecay1.Reset();
pDecay2.Reset();
};
void Pi0PGen::SaveHists(TString sFile){
// Write out test histograms
cout << "Saving histograms" << endl;
Int_t i;
TFile f1(sFile, "RECREATE", "MC_Hists_File");
pPhoton.WriteHists();
pTarget.WriteHists();
pPi0.WriteHists();
pRecoil.WriteHists();
pDecay1.WriteHists();
pDecay2.WriteHists();
TCanvas *cPvP1 = new TCanvas("cPvP1", "Proton vs Photon Angle", 800, 1000);
TLine *xlo = new TLine(20,0,20,180);
TLine *xhi = new TLine(160,0,160,180);
TLine *ylo = new TLine(0,20,180,20);
TLine *yhi = new TLine(0,160,180,160);
Int_t iArCoo[9][4] = {{30,30,10,10},{90,30,90,10},{150,30,170,10},{30,90,10,90},{90,90,90,90},{150,90,170,90},{30,150,10,170},{90,150,90,170},{150,150,170,170}};
Int_t iPtCoo[9][4] = {{30,30,50,40},{80,30,100,40},{130,30,150,40},{30,85,50,95},{80,85,100,95},{130,85,150,95},{30,140,50,150},{80,140,100,150},{130,140,150,150}};
TString sPtTxt[9] = {"TAPS,TAPS","CB,TAPS","Out,TAPS","TAPS,CB","CB,CB","Out,CB","TAPS,Out","CB,Out","Out,Out"};
TArrow *ar[9];
TPaveText *pt[9];
for(i=0; i<9; i++){
ar[i] = new TArrow(iArCoo[i][0],iArCoo[i][1],iArCoo[i][2],iArCoo[i][3],0.01,"|>");
ar[i]->SetLineWidth(2);
ar[i]->SetLineColor(4);
ar[i]->SetFillColor(4);
pt[i] = new TPaveText(iPtCoo[i][0],iPtCoo[i][1],iPtCoo[i][2],iPtCoo[i][3]);
pt[i]->AddText(sPtTxt[i]);
}
hPvP1Lo->SetStats(kFALSE);
hPvP1Lo->Draw();
hPvP1Hi->Draw("same");
xlo->Draw("same");
xhi->Draw("same");
ylo->Draw("same");
yhi->Draw("same");
for(i=0; i<9; i++){
if(i!=4) ar[i]->Draw();
pt[i]->Draw();
}
TCanvas *cPvP2 = new TCanvas("cPvP2", "Proton vs Photon Angle", 800, 1000);
hPvP2Lo->SetStats(kFALSE);
hPvP2Lo->Draw();
hPvP2Hi->Draw("same");
xlo->Draw("same");
xhi->Draw("same");
ylo->Draw("same");
yhi->Draw("same");
for(i=0; i<9; i++){
if(i!=4) ar[i]->Draw();
pt[i]->Draw();
}
hPvP1Lo->Write();
hPvP1Hi->Write();
hPvP2Lo->Write();
hPvP2Hi->Write();
cPvP1->Write();
cPvP2->Write();
hPvP1->Write();
hPvP2->Write();
hMiM->Write();
hTpvtp->Write();
hTpvtpi->Write();
htpvtpi->Write();
hCrossMax->Write();
hCrossTot->Write();
f1.Close();
};