66 G4SPSRandomGenerator::bweights_t::bweights_t() {
67 for (
int i = 0 ; i < 9 ; ++i ) w[i] = 1;
71 G4SPSRandomGenerator::bweights_t::operator [](
const int i) {
return w[i]; }
85 IPDFThetaBias =
false;
89 IPDFEnergyBias =
false;
91 IPDFPosThetaBias =
false;
93 IPDFPosPhiBias =
false;
183 bweights.
Get()[8] = weight;
187 bweights_t& w = bweights.
Get();
188 return w[0] * w[1] * w[2] * w[3]
189 * w[4] * w[5] * w[6] * w[7]
205 if (atype ==
"biasx") {
208 local_IPDFXBias.
Get().val =
false;
209 XBiasH = IPDFXBiasH = ZeroPhysVector;
210 }
else if (atype ==
"biasy") {
213 local_IPDFYBias.
Get().val =
false;
214 YBiasH = IPDFYBiasH = ZeroPhysVector;
215 }
else if (atype ==
"biasz") {
218 local_IPDFZBias.
Get().val =
false;
219 ZBiasH = IPDFZBiasH = ZeroPhysVector;
220 }
else if (atype ==
"biast") {
222 IPDFThetaBias =
false;
223 local_IPDFThetaBias.
Get().val =
false;
224 ThetaBiasH = IPDFThetaBiasH = ZeroPhysVector;
225 }
else if (atype ==
"biasp") {
228 local_IPDFPhiBias.
Get().val =
false;
229 PhiBiasH = IPDFPhiBiasH = ZeroPhysVector;
230 }
else if (atype ==
"biase") {
232 IPDFEnergyBias =
false;
233 local_IPDFEnergyBias.
Get().val =
false;
234 EnergyBiasH = IPDFEnergyBiasH = ZeroPhysVector;
235 }
else if (atype ==
"biaspt") {
236 PosThetaBias =
false;
237 IPDFPosThetaBias =
false;
238 local_IPDFPosThetaBias.
Get().val =
false;
239 PosThetaBiasH = IPDFPosThetaBiasH = ZeroPhysVector;
240 }
else if (atype ==
"biaspp") {
242 IPDFPosPhiBias =
false;
243 local_IPDFPosPhiBias.
Get().val =
false;
244 PosPhiBiasH = IPDFPosPhiBiasH = ZeroPhysVector;
251 if (verbosityLevel >= 1)
253 if (XBias ==
false) {
264 if ( local_IPDFXBias.
Get().val == false ) {
270 local_IPDFXBias.
Get().val =
true;
272 if (IPDFXBias ==
false) {
274 G4double bins[1024], vals[1024], sum;
278 vals[0] = XBiasH(
size_t(0));
280 for (ii = 1; ii < maxbin; ii++) {
282 vals[ii] = XBiasH(
size_t(ii)) + vals[ii - 1];
283 sum = sum + XBiasH(
size_t(ii));
286 for (ii = 0; ii < maxbin; ii++) {
287 vals[ii] = vals[ii] / sum;
303 G4int biasn2 = numberOfBin / 2;
304 G4int biasn3 = numberOfBin - 1;
305 while (biasn1 != biasn3 - 1) {
306 if (rndm > IPDFXBiasH(biasn2))
310 biasn2 = biasn1 + (biasn3 - biasn1 + 1) / 2;
313 bweights_t& w = bweights.
Get();
314 w[0] = IPDFXBiasH(biasn2) - IPDFXBiasH(biasn2 - 1);
320 w[0] = NatProb / w[0];
321 if (verbosityLevel >= 1)
322 G4cout <<
"X bin weight " << w[0] <<
" " << rndm <<
G4endl;
328 if (verbosityLevel >= 1)
330 if (YBias ==
false) {
336 if ( local_IPDFYBias.
Get().val == false ) {
337 local_IPDFYBias.
Get().val =
true;
339 if (IPDFYBias ==
false) {
341 G4double bins[1024], vals[1024], sum;
345 vals[0] = YBiasH(
size_t(0));
347 for (ii = 1; ii < maxbin; ii++) {
349 vals[ii] = YBiasH(
size_t(ii)) + vals[ii - 1];
350 sum = sum + YBiasH(
size_t(ii));
353 for (ii = 0; ii < maxbin; ii++) {
354 vals[ii] = vals[ii] / sum;
364 G4int biasn2 = numberOfBin / 2;
365 G4int biasn3 = numberOfBin - 1;
366 while (biasn1 != biasn3 - 1) {
367 if (rndm > IPDFYBiasH(biasn2))
371 biasn2 = biasn1 + (biasn3 - biasn1 + 1) / 2;
373 bweights_t& w = bweights.
Get();
374 w[1] = IPDFYBiasH(biasn2) - IPDFYBiasH(biasn2 - 1);
378 w[1] = NatProb / w[1];
379 if (verbosityLevel >= 1)
380 G4cout <<
"Y bin weight " << w[1] <<
" " << rndm <<
G4endl;
386 if (verbosityLevel >= 1)
388 if (ZBias ==
false) {
394 if (local_IPDFZBias.
Get().val == false ) {
395 local_IPDFZBias.
Get().val =
true;
397 if (IPDFZBias ==
false) {
399 G4double bins[1024], vals[1024], sum;
403 vals[0] = ZBiasH(
size_t(0));
405 for (ii = 1; ii < maxbin; ii++) {
407 vals[ii] = ZBiasH(
size_t(ii)) + vals[ii - 1];
408 sum = sum + ZBiasH(
size_t(ii));
411 for (ii = 0; ii < maxbin; ii++) {
412 vals[ii] = vals[ii] / sum;
424 G4int biasn2 = numberOfBin / 2;
425 G4int biasn3 = numberOfBin - 1;
426 while (biasn1 != biasn3 - 1) {
427 if (rndm > IPDFZBiasH(biasn2))
431 biasn2 = biasn1 + (biasn3 - biasn1 + 1) / 2;
433 bweights_t& w = bweights.
Get();
434 w[2] = IPDFZBiasH(biasn2) - IPDFZBiasH(biasn2 - 1);
438 w[2] = NatProb / w[2];
439 if (verbosityLevel >= 1)
440 G4cout <<
"Z bin weight " << w[2] <<
" " << rndm <<
G4endl;
446 if (verbosityLevel >= 1) {
450 if (ThetaBias ==
false) {
456 if ( local_IPDFThetaBias.
Get().val == false ) {
457 local_IPDFThetaBias.
Get().val =
true;
459 if (IPDFThetaBias ==
false) {
461 G4double bins[1024], vals[1024], sum;
465 vals[0] = ThetaBiasH(
size_t(0));
467 for (ii = 1; ii < maxbin; ii++) {
469 vals[ii] = ThetaBiasH(
size_t(ii)) + vals[ii - 1];
470 sum = sum + ThetaBiasH(
size_t(ii));
473 for (ii = 0; ii < maxbin; ii++) {
474 vals[ii] = vals[ii] / sum;
478 IPDFThetaBias =
true;
486 G4int biasn2 = numberOfBin / 2;
487 G4int biasn3 = numberOfBin - 1;
488 while (biasn1 != biasn3 - 1) {
489 if (rndm > IPDFThetaBiasH(biasn2))
493 biasn2 = biasn1 + (biasn3 - biasn1 + 1) / 2;
495 bweights_t& w = bweights.
Get();
496 w[3] = IPDFThetaBiasH(biasn2) - IPDFThetaBiasH(biasn2 - 1);
500 w[3] = NatProb / w[3];
501 if (verbosityLevel >= 1)
502 G4cout <<
"Theta bin weight " << w[3] <<
" " << rndm
509 if (verbosityLevel >= 1)
511 if (PhiBias ==
false) {
517 if ( local_IPDFPhiBias.
Get().val == false ) {
518 local_IPDFPhiBias.
Get().val =
true;
520 if (IPDFPhiBias ==
false) {
522 G4double bins[1024], vals[1024], sum;
526 vals[0] = PhiBiasH(
size_t(0));
528 for (ii = 1; ii < maxbin; ii++) {
530 vals[ii] = PhiBiasH(
size_t(ii)) + vals[ii - 1];
531 sum = sum + PhiBiasH(
size_t(ii));
534 for (ii = 0; ii < maxbin; ii++) {
535 vals[ii] = vals[ii] / sum;
547 G4int biasn2 = numberOfBin / 2;
548 G4int biasn3 = numberOfBin - 1;
549 while (biasn1 != biasn3 - 1) {
550 if (rndm > IPDFPhiBiasH(biasn2))
554 biasn2 = biasn1 + (biasn3 - biasn1 + 1) / 2;
556 bweights_t& w = bweights.
Get();
557 w[4] = IPDFPhiBiasH(biasn2) - IPDFPhiBiasH(biasn2 - 1);
561 w[4] = NatProb / w[4];
562 if (verbosityLevel >= 1)
563 G4cout <<
"Phi bin weight " << w[4] <<
" " << rndm <<
G4endl;
569 if (verbosityLevel >= 1)
571 if (EnergyBias ==
false) {
576 if ( local_IPDFEnergyBias.
Get().val == false ) {
577 local_IPDFEnergyBias.
Get().val =
true;
580 if (IPDFEnergyBias ==
false) {
582 G4double bins[1024], vals[1024], sum;
586 vals[0] = EnergyBiasH(
size_t(0));
588 for (ii = 1; ii < maxbin; ii++) {
590 vals[ii] = EnergyBiasH(
size_t(ii)) + vals[ii - 1];
591 sum = sum + EnergyBiasH(
size_t(ii));
593 IPDFEnergyBiasH = ZeroPhysVector;
594 for (ii = 0; ii < maxbin; ii++) {
595 vals[ii] = vals[ii] / sum;
599 IPDFEnergyBias =
true;
607 G4int biasn2 = numberOfBin / 2;
608 G4int biasn3 = numberOfBin - 1;
609 while (biasn1 != biasn3 - 1) {
610 if (rndm > IPDFEnergyBiasH(biasn2))
614 biasn2 = biasn1 + (biasn3 - biasn1 + 1) / 2;
616 bweights_t& w = bweights.
Get();
617 w[5] = IPDFEnergyBiasH(biasn2) - IPDFEnergyBiasH(biasn2 - 1);
621 w[5] = NatProb / w[5];
622 if (verbosityLevel >= 1)
623 G4cout <<
"Energy bin weight " << w[5] <<
" " << rndm
625 return (IPDFEnergyBiasH.
GetEnergy(rndm));
630 if (verbosityLevel >= 1) {
634 if (PosThetaBias ==
false) {
640 if ( local_IPDFPosThetaBias.
Get().val == false ) {
641 local_IPDFPosThetaBias.
Get().val =
true;
643 if (IPDFPosThetaBias ==
false) {
645 G4double bins[1024], vals[1024], sum;
649 vals[0] = PosThetaBiasH(
size_t(0));
651 for (ii = 1; ii < maxbin; ii++) {
653 vals[ii] = PosThetaBiasH(
size_t(ii)) + vals[ii - 1];
654 sum = sum + PosThetaBiasH(
size_t(ii));
657 for (ii = 0; ii < maxbin; ii++) {
658 vals[ii] = vals[ii] / sum;
662 IPDFPosThetaBias =
true;
670 G4int biasn2 = numberOfBin / 2;
671 G4int biasn3 = numberOfBin - 1;
672 while (biasn1 != biasn3 - 1) {
673 if (rndm > IPDFPosThetaBiasH(biasn2))
677 biasn2 = biasn1 + (biasn3 - biasn1 + 1) / 2;
679 bweights_t& w = bweights.
Get();
680 w[6] = IPDFPosThetaBiasH(biasn2) - IPDFPosThetaBiasH(biasn2 - 1);
685 w[6] = NatProb / w[6];
686 if (verbosityLevel >= 1)
687 G4cout <<
"PosTheta bin weight " << w[6] <<
" " << rndm
689 return (IPDFPosThetaBiasH.
GetEnergy(rndm));
694 if (verbosityLevel >= 1)
696 if (PosPhiBias ==
false) {
702 if (local_IPDFPosPhiBias.
Get().val == false ) {
703 local_IPDFPosPhiBias.
Get().val =
true;
705 if (IPDFPosPhiBias ==
false) {
707 G4double bins[1024], vals[1024], sum;
711 vals[0] = PosPhiBiasH(
size_t(0));
713 for (ii = 1; ii < maxbin; ii++) {
715 vals[ii] = PosPhiBiasH(
size_t(ii)) + vals[ii - 1];
716 sum = sum + PosPhiBiasH(
size_t(ii));
719 for (ii = 0; ii < maxbin; ii++) {
720 vals[ii] = vals[ii] / sum;
724 IPDFPosPhiBias =
true;
732 G4int biasn2 = numberOfBin / 2;
733 G4int biasn3 = numberOfBin - 1;
734 while (biasn1 != biasn3 - 1) {
735 if (rndm > IPDFPosPhiBiasH(biasn2))
739 biasn2 = biasn1 + (biasn3 - biasn1 + 1) / 2;
741 bweights_t& w = bweights.
Get();
742 w[7] = IPDFPosPhiBiasH(biasn2) - IPDFPosPhiBiasH(biasn2 - 1);
746 w[7] = NatProb / w[7];
747 if (verbosityLevel >= 1)
748 G4cout <<
"PosPhi bin weight " << w[7] <<
" " << rndm
750 return (IPDFPosPhiBiasH.
GetEnergy(rndm));
std::vector< ExP01TrackerHit * > a
#define G4MUTEXINIT(mutex)
void InsertValues(G4double energy, G4double value)
void SetEnergyBias(G4ThreeVector)
void SetYBias(G4ThreeVector)
size_t GetVectorLength() const
G4double GetLowEdgeEnergy(size_t binNumber) const
void SetPosThetaBias(G4ThreeVector)
void SetThetaBias(G4ThreeVector)
void SetZBias(G4ThreeVector)
void SetXBias(G4ThreeVector)
G4GLOB_DLL std::ostream G4cout
void SetVerbosity(G4int a)
G4double GetEnergy(G4double aValue)
void SetPhiBias(G4ThreeVector)
void SetIntensityWeight(G4double weight)
G4double GenRandPosTheta()
#define G4MUTEXDESTROY(mutex)
void SetPosPhiBias(G4ThreeVector)