27
27
// related to the GENBEAM control.in flag.
28
28
29
29
int GlueXPhotonBeamGenerator::fGenerateNotSimulate = 0 ;
30
+ int GlueXPhotonBeamGenerator::fBeamBackgroundTagOnly = 0 ;
30
31
31
32
double GlueXPhotonBeamGenerator::fBeamBucketPeriod = 4 . * ns;
32
33
double GlueXPhotonBeamGenerator::fBeamStartZ = -24 * m;
@@ -71,15 +72,29 @@ GlueXPhotonBeamGenerator::GlueXPhotonBeamGenerator(CobremsGeneration *gen)
71
72
}
72
73
GlueXUserEventInformation::fWriteNoHitEvents = 1 ;
73
74
}
74
-
75
- prepareImportanceSamplingPDFs ();
75
+ std::map<int , int > bgratepars;
76
+ std::map<int , int > bggatepars;
77
+ std::map<int , int > bgtagonlypars;
78
+ if (user_opts->Find (" BEAM" , beampars) &&
79
+ user_opts->Find (" BGRATE" , bgratepars) &&
80
+ user_opts->Find (" BGGATE" , bggatepars))
81
+ {
82
+ if (user_opts->Find (" BGTAGONLY" , bgtagonlypars)) {
83
+ fBeamBackgroundTagOnly = bgtagonlypars[1 ];
84
+ }
85
+ else {
86
+ fBeamBackgroundTagOnly = 0 ;
87
+ }
88
+ }
76
89
77
90
// These cutoffs should be set empirically, as low as possible
78
91
// for good efficiency, but not too low so as to avoid excessive
79
92
// warnings about Pcut violations.
80
93
81
94
fCoherentPDFx .Pcut = .003 ;
82
95
fIncoherentPDFlogx .Pcut = .003 ;
96
+
97
+ prepareImportanceSamplingPDFs ();
83
98
}
84
99
85
100
GlueXPhotonBeamGenerator::~GlueXPhotonBeamGenerator ()
@@ -103,6 +118,11 @@ void GlueXPhotonBeamGenerator::prepareImportanceSamplingPDFs()
103
118
xarr[i] = xmin + (i + 0.5 ) * dx;
104
119
yarr[i] = fCobrems ->Rate_dNcdxdp (xarr[i], M_PI/4 );
105
120
yarr[i] = (yarr[i] > 0 )? yarr[i] : 0 ;
121
+ for (int j=1 ; j < 10 ; ++j) {
122
+ double mfactor = 1 - j / 10 .;
123
+ if (i > j && yarr[i] < yarr[i-j] * mfactor)
124
+ yarr[i] = yarr[i-j] * mfactor;
125
+ }
106
126
}
107
127
fCobrems ->applyBeamCrystalConvolution (Ndim, xarr, yarr);
108
128
sum = 0 ;
@@ -116,6 +136,7 @@ void GlueXPhotonBeamGenerator::prepareImportanceSamplingPDFs()
116
136
fCoherentPDFx .density [i] /= sum * dx;
117
137
fCoherentPDFx .integral [i] /= sum;
118
138
}
139
+ fCoherentPDFx .Pcut = 4 *M_PI * sum * dx;
119
140
120
141
// Compute approximate PDF for dNi/dlogx
121
142
double logxmin = log (xmin);
@@ -387,7 +408,27 @@ void GlueXPhotonBeamGenerator::GenerateBeamPhoton(G4Event* anEvent, double t0)
387
408
}
388
409
}
389
410
390
- // Put the radiator back the way your found it
411
+ #if VERBOSE_COBREMS_SPLITTING
412
+ if (fIncoherentPDFlogx .Npassed / 100 * 100 == fIncoherentPDFlogx .Npassed ) {
413
+ G4cout << " coherent rate is "
414
+ << fCoherentPDFx .Psum / (fCoherentPDFx .Ntested + 1e-99 )
415
+ << " , efficiency is "
416
+ << fCoherentPDFx .Npassed / (fCoherentPDFx .Ntested + 1e-99 )
417
+ << G4endl
418
+ << " incoherent rate is "
419
+ << fIncoherentPDFlogx .Psum / (fIncoherentPDFlogx .Ntested + 1e-99 )
420
+ << " , efficiency is "
421
+ << fIncoherentPDFlogx .Npassed / (fIncoherentPDFlogx .Ntested + 1e-99 )
422
+ << G4endl
423
+ << " counts are "
424
+ << fCoherentPDFx .Npassed << " / " << fIncoherentPDFlogx .Npassed
425
+ << " = "
426
+ << fCoherentPDFx .Npassed / (fIncoherentPDFlogx .Npassed + 1e-99 )
427
+ << G4endl;
428
+ }
429
+ #endif
430
+
431
+ // Put the radiator back the way you found it
391
432
fCobrems ->setTargetOrientation (targetThetax,
392
433
targetThetay,
393
434
targetThetaz);
@@ -426,20 +467,25 @@ void GlueXPhotonBeamGenerator::GenerateBeamPhoton(G4Event* anEvent, double t0)
426
467
int bg = 1 ;
427
468
double tvtx;
428
469
if (t0 == 0 ) {
429
- event_info = new GlueXUserEventInformation ();
430
- anEvent->SetUserInformation (event_info);
431
470
tvtx = (vtx[2 ] - targetCenterZ) / fBeamVelocity ;
432
471
tvtx -= GenerateTriggerTime (anEvent);
472
+ event_info = new GlueXUserEventInformation ();
473
+ anEvent->SetUserInformation (event_info);
433
474
if (fGenerateNotSimulate == 0 ) {
434
475
event_info->AddBeamParticle (1 , tvtx, vtx, mom, pol);
435
476
}
436
477
bg = 0 ;
437
478
}
438
479
else {
439
- event_info = (GlueXUserEventInformation*)anEvent->GetUserInformation ();
440
- assert (event_info != 0 );
441
480
tvtx = fBeamBucketPeriod * floor (t0 / fBeamBucketPeriod + 0.5 );
442
481
tvtx += (vtx[2 ] - targetCenterZ) / fBeamVelocity ;
482
+ if (fBeamBackgroundTagOnly ) {
483
+ double ttag = tvtx + (targetCenterZ - vtx[2 ]) / fBeamVelocity ;
484
+ fTagger ->addTaggerPhoton (anEvent, pabs, ttag, bg);
485
+ return ;
486
+ }
487
+ event_info = (GlueXUserEventInformation*)anEvent->GetUserInformation ();
488
+ assert (event_info != 0 );
443
489
}
444
490
445
491
// Generate new primary for the beam photon
@@ -478,26 +524,6 @@ void GlueXPhotonBeamGenerator::GenerateBeamPhoton(G4Event* anEvent, double t0)
478
524
double ttag = tvtx + (targetCenterZ - vtx[2 ]) / fBeamVelocity ;
479
525
fTagger ->addTaggerPhoton (anEvent, pabs, ttag, bg);
480
526
}
481
-
482
- #if VERBOSE_COBREMS_SPLITTING
483
- if (fIncoherentPDFlogx .Npassed / 100 * 100 == fIncoherentPDFlogx .Npassed ) {
484
- G4cout << " coherent rate is "
485
- << fCoherentPDFx .Psum / (fCoherentPDFx .Ntested + 1e-99 )
486
- << " , efficiency is "
487
- << fCoherentPDFx .Npassed / (fCoherentPDFx .Ntested + 1e-99 )
488
- << G4endl
489
- << " incoherent rate is "
490
- << fIncoherentPDFlogx .Psum / (fIncoherentPDFlogx .Ntested + 1e-99 )
491
- << " , efficiency is "
492
- << fIncoherentPDFlogx .Npassed / (fIncoherentPDFlogx .Ntested + 1e-99 )
493
- << G4endl
494
- << " counts are "
495
- << fCoherentPDFx .Npassed << " / " << fIncoherentPDFlogx .Npassed
496
- << " = "
497
- << fCoherentPDFx .Npassed / (fIncoherentPDFlogx .Npassed + 1e-99 )
498
- << G4endl;
499
- }
500
- #endif
501
527
}
502
528
503
529
double GlueXPhotonBeamGenerator::GenerateTriggerTime (const G4Event *event)
0 commit comments