51G4SPSRandomGenerator::bweights_t::bweights_t()
53 for (
double & i : w) { i = 1; }
56G4double& G4SPSRandomGenerator::bweights_t::operator [](
const G4int i)
74 IPDFThetaBias =
false;
78 IPDFEnergyBias =
false;
80 IPDFPosThetaBias =
false;
82 IPDFPosPhiBias =
false;
177 bweights.
Get()[8] = weight;
182 bweights_t& w = bweights.
Get();
183 return w[0] * w[1] * w[2] * w[3] * w[4] * w[5] * w[6] * w[7] * w[8];
200 if (atype ==
"biasx") {
203 local_IPDFXBias.
Get().val =
false;
204 XBiasH = IPDFXBiasH = ZeroPhysVector;
205 }
else if (atype ==
"biasy") {
208 local_IPDFYBias.
Get().val =
false;
209 YBiasH = IPDFYBiasH = ZeroPhysVector;
210 }
else if (atype ==
"biasz") {
213 local_IPDFZBias.
Get().val =
false;
214 ZBiasH = IPDFZBiasH = ZeroPhysVector;
215 }
else if (atype ==
"biast") {
217 IPDFThetaBias =
false;
218 local_IPDFThetaBias.
Get().val =
false;
219 ThetaBiasH = IPDFThetaBiasH = ZeroPhysVector;
220 }
else if (atype ==
"biasp") {
223 local_IPDFPhiBias.
Get().val =
false;
224 PhiBiasH = IPDFPhiBiasH = ZeroPhysVector;
225 }
else if (atype ==
"biase") {
227 IPDFEnergyBias =
false;
228 local_IPDFEnergyBias.
Get().val =
false;
229 EnergyBiasH = IPDFEnergyBiasH = ZeroPhysVector;
230 }
else if (atype ==
"biaspt") {
231 PosThetaBias =
false;
232 IPDFPosThetaBias =
false;
233 local_IPDFPosThetaBias.
Get().val =
false;
234 PosThetaBiasH = IPDFPosThetaBiasH = ZeroPhysVector;
235 }
else if (atype ==
"biaspp") {
237 IPDFPosPhiBias =
false;
238 local_IPDFPosPhiBias.
Get().val =
false;
239 PosPhiBiasH = IPDFPosPhiBiasH = ZeroPhysVector;
247 if (verbosityLevel >= 1)
263 if ( !local_IPDFXBias.
Get().val )
271 local_IPDFXBias.
Get().val =
true;
277 G4double bins[1024], vals[1024], sum;
283 for (ii=1; ii<maxbin; ++ii)
286 vals[ii] = XBiasH(ii) + vals[ii - 1];
287 sum = sum + XBiasH(ii);
290 for (ii=0; ii<maxbin; ++ii)
292 vals[ii] = vals[ii] / sum;
309 std::size_t biasn1 = 0;
310 std::size_t biasn2 = numberOfBin / 2;
311 std::size_t biasn3 = numberOfBin - 1;
312 while (biasn1 != biasn3 - 1)
314 if (rndm > IPDFXBiasH(biasn2))
318 biasn2 = biasn1 + (biasn3 - biasn1 + 1) / 2;
323 bweights_t& w = bweights.
Get();
324 w[0] = IPDFXBiasH(biasn2) - IPDFXBiasH(biasn2 - 1);
328 w[0] = NatProb / w[0];
329 if (verbosityLevel >= 1)
331 G4cout <<
"X bin weight " << w[0] <<
" " << rndm <<
G4endl;
339 if (verbosityLevel >= 1)
350 if ( !local_IPDFYBias.
Get().val )
352 local_IPDFYBias.
Get().val =
true;
358 G4double bins[1024], vals[1024], sum;
364 for (ii=1; ii<maxbin; ++ii)
367 vals[ii] = YBiasH(ii) + vals[ii - 1];
368 sum = sum + YBiasH(ii);
371 for (ii=0; ii<maxbin; ++ii)
373 vals[ii] = vals[ii] / sum;
384 std::size_t biasn1 = 0;
385 std::size_t biasn2 = numberOfBin / 2;
386 std::size_t biasn3 = numberOfBin - 1;
387 while (biasn1 != biasn3 - 1)
389 if (rndm > IPDFYBiasH(biasn2))
393 biasn2 = biasn1 + (biasn3 - biasn1 + 1) / 2;
395 bweights_t& w = bweights.
Get();
396 w[1] = IPDFYBiasH(biasn2) - IPDFYBiasH(biasn2 - 1);
400 w[1] = NatProb / w[1];
401 if (verbosityLevel >= 1)
403 G4cout <<
"Y bin weight " << w[1] <<
" " << rndm <<
G4endl;
411 if (verbosityLevel >= 1)
422 if ( !local_IPDFZBias.
Get().val )
424 local_IPDFZBias.
Get().val =
true;
430 G4double bins[1024], vals[1024], sum;
436 for (ii=1; ii<maxbin; ++ii)
439 vals[ii] = ZBiasH(ii) + vals[ii - 1];
440 sum = sum + ZBiasH(ii);
443 for (ii=0; ii<maxbin; ++ii)
445 vals[ii] = vals[ii] / sum;
456 std::size_t biasn1 = 0;
457 std::size_t biasn2 = numberOfBin / 2;
458 std::size_t biasn3 = numberOfBin - 1;
459 while (biasn1 != biasn3 - 1)
461 if (rndm > IPDFZBiasH(biasn2))
465 biasn2 = biasn1 + (biasn3 - biasn1 + 1) / 2;
467 bweights_t& w = bweights.
Get();
468 w[2] = IPDFZBiasH(biasn2) - IPDFZBiasH(biasn2 - 1);
472 w[2] = NatProb / w[2];
473 if (verbosityLevel >= 1)
475 G4cout <<
"Z bin weight " << w[2] <<
" " << rndm <<
G4endl;
483 if (verbosityLevel >= 1)
495 if ( !local_IPDFThetaBias.
Get().val )
497 local_IPDFThetaBias.
Get().val =
true;
503 G4double bins[1024], vals[1024], sum;
507 vals[0] = ThetaBiasH(0);
509 for (ii=1; ii<maxbin; ++ii)
512 vals[ii] = ThetaBiasH(ii) + vals[ii - 1];
513 sum = sum + ThetaBiasH(ii);
516 for (ii=0; ii<maxbin; ++ii)
518 vals[ii] = vals[ii] / sum;
521 IPDFThetaBias =
true;
529 std::size_t biasn1 = 0;
530 std::size_t biasn2 = numberOfBin / 2;
531 std::size_t biasn3 = numberOfBin - 1;
532 while (biasn1 != biasn3 - 1)
534 if (rndm > IPDFThetaBiasH(biasn2))
538 biasn2 = biasn1 + (biasn3 - biasn1 + 1) / 2;
540 bweights_t& w = bweights.
Get();
541 w[3] = IPDFThetaBiasH(biasn2) - IPDFThetaBiasH(biasn2 - 1);
545 w[3] = NatProb / w[3];
546 if (verbosityLevel >= 1)
548 G4cout <<
"Theta bin weight " << w[3] <<
" " << rndm <<
G4endl;
556 if (verbosityLevel >= 1)
567 if ( !local_IPDFPhiBias.
Get().val )
569 local_IPDFPhiBias.
Get().val =
true;
575 G4double bins[1024], vals[1024], sum;
579 vals[0] = PhiBiasH(0);
581 for (ii=1; ii<maxbin; ++ii)
584 vals[ii] = PhiBiasH(ii) + vals[ii - 1];
585 sum = sum + PhiBiasH(ii);
588 for (ii=0; ii<maxbin; ++ii)
590 vals[ii] = vals[ii] / sum;
601 std::size_t biasn1 = 0;
602 std::size_t biasn2 = numberOfBin / 2;
603 std::size_t biasn3 = numberOfBin - 1;
604 while (biasn1 != biasn3 - 1)
606 if (rndm > IPDFPhiBiasH(biasn2))
610 biasn2 = biasn1 + (biasn3 - biasn1 + 1) / 2;
612 bweights_t& w = bweights.
Get();
613 w[4] = IPDFPhiBiasH(biasn2) - IPDFPhiBiasH(biasn2 - 1);
617 w[4] = NatProb / w[4];
618 if (verbosityLevel >= 1)
620 G4cout <<
"Phi bin weight " << w[4] <<
" " << rndm <<
G4endl;
628 if (verbosityLevel >= 1)
639 if ( !local_IPDFEnergyBias.
Get().val )
641 local_IPDFEnergyBias.
Get().val =
true;
647 G4double bins[1024], vals[1024], sum;
651 vals[0] = EnergyBiasH(0);
653 for (ii=1; ii<maxbin; ++ii)
656 vals[ii] = EnergyBiasH(ii) + vals[ii - 1];
657 sum = sum + EnergyBiasH(ii);
659 IPDFEnergyBiasH = ZeroPhysVector;
660 for (ii=0; ii<maxbin; ++ii)
662 vals[ii] = vals[ii] / sum;
665 IPDFEnergyBias =
true;
673 std::size_t biasn1 = 0;
674 std::size_t biasn2 = numberOfBin / 2;
675 std::size_t biasn3 = numberOfBin - 1;
676 while (biasn1 != biasn3 - 1)
678 if (rndm > IPDFEnergyBiasH(biasn2))
682 biasn2 = biasn1 + (biasn3 - biasn1 + 1) / 2;
684 bweights_t& w = bweights.
Get();
685 w[5] = IPDFEnergyBiasH(biasn2) - IPDFEnergyBiasH(biasn2 - 1);
689 w[5] = NatProb / w[5];
690 if (verbosityLevel >= 1)
692 G4cout <<
"Energy bin weight " << w[5] <<
" " << rndm <<
G4endl;
694 return (IPDFEnergyBiasH.
GetEnergy(rndm));
700 if (verbosityLevel >= 1)
712 if ( !local_IPDFPosThetaBias.
Get().val )
714 local_IPDFPosThetaBias.
Get().val =
true;
716 if (!IPDFPosThetaBias)
720 G4double bins[1024], vals[1024], sum;
724 vals[0] = PosThetaBiasH(0);
726 for (ii=1; ii<maxbin; ++ii)
729 vals[ii] = PosThetaBiasH(ii) + vals[ii - 1];
730 sum = sum + PosThetaBiasH(ii);
733 for (ii=0; ii<maxbin; ++ii)
735 vals[ii] = vals[ii] / sum;
738 IPDFPosThetaBias =
true;
746 std::size_t biasn1 = 0;
747 std::size_t biasn2 = numberOfBin / 2;
748 std::size_t biasn3 = numberOfBin - 1;
749 while (biasn1 != biasn3 - 1)
751 if (rndm > IPDFPosThetaBiasH(biasn2))
755 biasn2 = biasn1 + (biasn3 - biasn1 + 1) / 2;
757 bweights_t& w = bweights.
Get();
758 w[6] = IPDFPosThetaBiasH(biasn2) - IPDFPosThetaBiasH(biasn2 - 1);
762 w[6] = NatProb / w[6];
763 if (verbosityLevel >= 1)
765 G4cout <<
"PosTheta bin weight " << w[6] <<
" " << rndm <<
G4endl;
767 return (IPDFPosThetaBiasH.
GetEnergy(rndm));
773 if (verbosityLevel >= 1)
784 if (!local_IPDFPosPhiBias.
Get().val )
786 local_IPDFPosPhiBias.
Get().val =
true;
792 G4double bins[1024], vals[1024], sum;
796 vals[0] = PosPhiBiasH(0);
798 for (ii=1; ii<maxbin; ++ii)
801 vals[ii] = PosPhiBiasH(ii) + vals[ii - 1];
802 sum = sum + PosPhiBiasH(ii);
805 for (ii=0; ii<maxbin; ++ii)
807 vals[ii] = vals[ii] / sum;
810 IPDFPosPhiBias =
true;
818 std::size_t biasn1 = 0;
819 std::size_t biasn2 = numberOfBin / 2;
820 std::size_t biasn3 = numberOfBin - 1;
821 while (biasn1 != biasn3 - 1)
823 if (rndm > IPDFPosPhiBiasH(biasn2))
827 biasn2 = biasn1 + (biasn3 - biasn1 + 1) / 2;
829 bweights_t& w = bweights.
Get();
830 w[7] = IPDFPosPhiBiasH(biasn2) - IPDFPosPhiBiasH(biasn2 - 1);
834 w[7] = NatProb / w[7];
835 if (verbosityLevel >= 1)
837 G4cout <<
"PosPhi bin weight " << w[7] <<
" " << rndm <<
G4endl;
839 return (IPDFPosPhiBiasH.
GetEnergy(rndm));
#define G4MUTEXDESTROY(mutex)
#define G4MUTEXINIT(mutex)
G4GLOB_DLL std::ostream G4cout
void InsertValues(const G4double energy, const G4double value)
G4double GetEnergy(const G4double value) const
G4double GetLowEdgeEnergy(const std::size_t index) const
std::size_t GetVectorLength() const
void SetIntensityWeight(G4double weight)
void SetXBias(const G4ThreeVector &)
void SetEnergyBias(const G4ThreeVector &)
void SetPosPhiBias(const G4ThreeVector &)
void SetThetaBias(const G4ThreeVector &)
G4double GetBiasWeight() const
void SetYBias(const G4ThreeVector &)
void SetVerbosity(G4int a)
void SetPosThetaBias(const G4ThreeVector &)
G4double GenRandPosTheta()
void SetPhiBias(const G4ThreeVector &)
void SetZBias(const G4ThreeVector &)
void ReSetHist(const G4String &)