51G4SPSRandomGenerator::bweights_t::bweights_t()
53 for (
G4int i=0 ; i<9 ; ++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)
264 if ( local_IPDFXBias.
Get().val ==
false )
272 local_IPDFXBias.
Get().val =
true;
274 if (IPDFXBias ==
false)
278 G4double bins[1024], vals[1024], sum;
282 vals[0] = XBiasH(std::size_t(0));
284 for (ii=1; ii<maxbin; ++ii)
287 vals[ii] = XBiasH(std::size_t(ii)) + vals[ii - 1];
288 sum = sum + XBiasH(std::size_t(ii));
291 for (ii=0; ii<maxbin; ++ii)
293 vals[ii] = vals[ii] / sum;
311 G4int biasn2 = numberOfBin / 2;
312 G4int biasn3 = numberOfBin - 1;
313 while (biasn1 != biasn3 - 1)
315 if (rndm > IPDFXBiasH(biasn2))
319 biasn2 = biasn1 + (biasn3 - biasn1 + 1) / 2;
324 bweights_t& w = bweights.
Get();
325 w[0] = IPDFXBiasH(biasn2) - IPDFXBiasH(biasn2 - 1);
329 w[0] = NatProb / w[0];
330 if (verbosityLevel >= 1)
332 G4cout <<
"X bin weight " << w[0] <<
" " << rndm <<
G4endl;
340 if (verbosityLevel >= 1)
352 if ( local_IPDFYBias.
Get().val ==
false )
354 local_IPDFYBias.
Get().val =
true;
356 if (IPDFYBias ==
false)
360 G4double bins[1024], vals[1024], sum;
364 vals[0] = YBiasH(std::size_t(0));
366 for (ii=1; ii<maxbin; ++ii)
369 vals[ii] = YBiasH(std::size_t(ii)) + vals[ii - 1];
370 sum = sum + YBiasH(std::size_t(ii));
373 for (ii=0; ii<maxbin; ++ii)
375 vals[ii] = vals[ii] / sum;
387 G4int biasn2 = numberOfBin / 2;
388 G4int biasn3 = numberOfBin - 1;
389 while (biasn1 != biasn3 - 1)
391 if (rndm > IPDFYBiasH(biasn2))
395 biasn2 = biasn1 + (biasn3 - biasn1 + 1) / 2;
397 bweights_t& w = bweights.
Get();
398 w[1] = IPDFYBiasH(biasn2) - IPDFYBiasH(biasn2 - 1);
402 w[1] = NatProb / w[1];
403 if (verbosityLevel >= 1)
405 G4cout <<
"Y bin weight " << w[1] <<
" " << rndm <<
G4endl;
413 if (verbosityLevel >= 1)
425 if ( local_IPDFZBias.
Get().val ==
false )
427 local_IPDFZBias.
Get().val =
true;
429 if (IPDFZBias ==
false)
433 G4double bins[1024], vals[1024], sum;
437 vals[0] = ZBiasH(std::size_t(0));
439 for (ii=1; ii<maxbin; ++ii)
442 vals[ii] = ZBiasH(std::size_t(ii)) + vals[ii - 1];
443 sum = sum + ZBiasH(std::size_t(ii));
446 for (ii=0; ii<maxbin; ++ii)
448 vals[ii] = vals[ii] / sum;
460 G4int biasn2 = numberOfBin / 2;
461 G4int biasn3 = numberOfBin - 1;
462 while (biasn1 != biasn3 - 1)
464 if (rndm > IPDFZBiasH(biasn2))
468 biasn2 = biasn1 + (biasn3 - biasn1 + 1) / 2;
470 bweights_t& w = bweights.
Get();
471 w[2] = IPDFZBiasH(biasn2) - IPDFZBiasH(biasn2 - 1);
475 w[2] = NatProb / w[2];
476 if (verbosityLevel >= 1)
478 G4cout <<
"Z bin weight " << w[2] <<
" " << rndm <<
G4endl;
486 if (verbosityLevel >= 1)
492 if (ThetaBias ==
false)
499 if ( local_IPDFThetaBias.
Get().val ==
false )
501 local_IPDFThetaBias.
Get().val =
true;
503 if (IPDFThetaBias ==
false)
507 G4double bins[1024], vals[1024], sum;
511 vals[0] = ThetaBiasH(std::size_t(0));
513 for (ii=1; ii<maxbin; ++ii)
516 vals[ii] = ThetaBiasH(std::size_t(ii)) + vals[ii - 1];
517 sum = sum + ThetaBiasH(std::size_t(ii));
520 for (ii=0; ii<maxbin; ++ii)
522 vals[ii] = vals[ii] / sum;
525 IPDFThetaBias =
true;
534 G4int biasn2 = numberOfBin / 2;
535 G4int biasn3 = numberOfBin - 1;
536 while (biasn1 != biasn3 - 1)
538 if (rndm > IPDFThetaBiasH(biasn2))
542 biasn2 = biasn1 + (biasn3 - biasn1 + 1) / 2;
544 bweights_t& w = bweights.
Get();
545 w[3] = IPDFThetaBiasH(biasn2) - IPDFThetaBiasH(biasn2 - 1);
549 w[3] = NatProb / w[3];
550 if (verbosityLevel >= 1)
552 G4cout <<
"Theta bin weight " << w[3] <<
" " << rndm <<
G4endl;
560 if (verbosityLevel >= 1)
565 if (PhiBias ==
false)
572 if ( local_IPDFPhiBias.
Get().val ==
false )
574 local_IPDFPhiBias.
Get().val =
true;
576 if (IPDFPhiBias ==
false)
580 G4double bins[1024], vals[1024], sum;
584 vals[0] = PhiBiasH(std::size_t(0));
586 for (ii=1; ii<maxbin; ++ii)
589 vals[ii] = PhiBiasH(std::size_t(ii)) + vals[ii - 1];
590 sum = sum + PhiBiasH(std::size_t(ii));
593 for (ii=0; ii<maxbin; ++ii)
595 vals[ii] = vals[ii] / sum;
607 G4int biasn2 = numberOfBin / 2;
608 G4int biasn3 = numberOfBin - 1;
609 while (biasn1 != biasn3 - 1)
611 if (rndm > IPDFPhiBiasH(biasn2))
615 biasn2 = biasn1 + (biasn3 - biasn1 + 1) / 2;
617 bweights_t& w = bweights.
Get();
618 w[4] = IPDFPhiBiasH(biasn2) - IPDFPhiBiasH(biasn2 - 1);
622 w[4] = NatProb / w[4];
623 if (verbosityLevel >= 1)
625 G4cout <<
"Phi bin weight " << w[4] <<
" " << rndm <<
G4endl;
633 if (verbosityLevel >= 1)
638 if (EnergyBias ==
false)
645 if ( local_IPDFEnergyBias.
Get().val ==
false )
647 local_IPDFEnergyBias.
Get().val =
true;
649 if (IPDFEnergyBias ==
false)
653 G4double bins[1024], vals[1024], sum;
657 vals[0] = EnergyBiasH(std::size_t(0));
659 for (ii=1; ii<maxbin; ++ii)
662 vals[ii] = EnergyBiasH(std::size_t(ii)) + vals[ii - 1];
663 sum = sum + EnergyBiasH(std::size_t(ii));
665 IPDFEnergyBiasH = ZeroPhysVector;
666 for (ii=0; ii<maxbin; ++ii)
668 vals[ii] = vals[ii] / sum;
671 IPDFEnergyBias =
true;
680 G4int biasn2 = numberOfBin / 2;
681 G4int biasn3 = numberOfBin - 1;
682 while (biasn1 != biasn3 - 1)
684 if (rndm > IPDFEnergyBiasH(biasn2))
688 biasn2 = biasn1 + (biasn3 - biasn1 + 1) / 2;
690 bweights_t& w = bweights.
Get();
691 w[5] = IPDFEnergyBiasH(biasn2) - IPDFEnergyBiasH(biasn2 - 1);
695 w[5] = NatProb / w[5];
696 if (verbosityLevel >= 1)
698 G4cout <<
"Energy bin weight " << w[5] <<
" " << rndm <<
G4endl;
700 return (IPDFEnergyBiasH.
GetEnergy(rndm));
706 if (verbosityLevel >= 1)
712 if (PosThetaBias ==
false)
719 if ( local_IPDFPosThetaBias.
Get().val ==
false )
721 local_IPDFPosThetaBias.
Get().val =
true;
723 if (IPDFPosThetaBias ==
false)
727 G4double bins[1024], vals[1024], sum;
731 vals[0] = PosThetaBiasH(std::size_t(0));
733 for (ii=1; ii<maxbin; ++ii)
736 vals[ii] = PosThetaBiasH(std::size_t(ii)) + vals[ii - 1];
737 sum = sum + PosThetaBiasH(std::size_t(ii));
740 for (ii=0; ii<maxbin; ++ii)
742 vals[ii] = vals[ii] / sum;
745 IPDFPosThetaBias =
true;
754 G4int biasn2 = numberOfBin / 2;
755 G4int biasn3 = numberOfBin - 1;
756 while (biasn1 != biasn3 - 1)
758 if (rndm > IPDFPosThetaBiasH(biasn2))
762 biasn2 = biasn1 + (biasn3 - biasn1 + 1) / 2;
764 bweights_t& w = bweights.
Get();
765 w[6] = IPDFPosThetaBiasH(biasn2) - IPDFPosThetaBiasH(biasn2 - 1);
769 w[6] = NatProb / w[6];
770 if (verbosityLevel >= 1)
772 G4cout <<
"PosTheta bin weight " << w[6] <<
" " << rndm <<
G4endl;
774 return (IPDFPosThetaBiasH.
GetEnergy(rndm));
780 if (verbosityLevel >= 1)
785 if (PosPhiBias ==
false)
792 if (local_IPDFPosPhiBias.
Get().val ==
false )
794 local_IPDFPosPhiBias.
Get().val =
true;
796 if (IPDFPosPhiBias ==
false)
800 G4double bins[1024], vals[1024], sum;
804 vals[0] = PosPhiBiasH(std::size_t(0));
806 for (ii=1; ii<maxbin; ++ii)
809 vals[ii] = PosPhiBiasH(std::size_t(ii)) + vals[ii - 1];
810 sum = sum + PosPhiBiasH(std::size_t(ii));
813 for (ii=0; ii<maxbin; ++ii)
815 vals[ii] = vals[ii] / sum;
818 IPDFPosPhiBias =
true;
827 G4int biasn2 = numberOfBin / 2;
828 G4int biasn3 = numberOfBin - 1;
829 while (biasn1 != biasn3 - 1)
831 if (rndm > IPDFPosPhiBiasH(biasn2))
835 biasn2 = biasn1 + (biasn3 - biasn1 + 1) / 2;
837 bweights_t& w = bweights.
Get();
838 w[7] = IPDFPosPhiBiasH(biasn2) - IPDFPosPhiBiasH(biasn2 - 1);
842 w[7] = NatProb / w[7];
843 if (verbosityLevel >= 1)
845 G4cout <<
"PosPhi bin weight " << w[7] <<
" " << rndm <<
G4endl;
847 return (IPDFPosPhiBiasH.
GetEnergy(rndm));
#define G4MUTEXDESTROY(mutex)
#define G4MUTEXINIT(mutex)
G4GLOB_DLL std::ostream G4cout
void InsertValues(G4double energy, G4double value)
G4double GetEnergy(G4double aValue)
G4double GetLowEdgeEnergy(std::size_t binNumber) 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 &)