#include "SolidGenerateIBD.hh" #include "globals.hh" #include "Randomize.hh" #include "TFile.h" #include "TH1D.h" #include "TH2D.h" #include "TLorentzVector.h" #include "G4ThreeVector.hh" #include "G4DynamicParticle.hh" #include "G4SystemOfUnits.hh" #include "G4PhysicalConstants.hh" SolidGenerateIBD::SolidGenerateIBD(const char* RootFile){ _ratefile = new TFile(RootFile); _anuerate = (TH1D*)_ratefile->Get("anuerate"); _ibdKinematics = new protonibd_Vogel0(); } SolidGenerateIBD::~SolidGenerateIBD(){ } double SolidGenerateIBD::randomWithinInterval(double lowerLimit, double upperLimit){ double randomValue; randomValue=lowerLimit+G4UniformRand()*(upperLimit-lowerLimit); return randomValue; } double SolidGenerateIBD::randomNeutrinoEnergy(){ bool valid = false; int counter = 0.; double enu; double threshold = _ibdKinematics->getThreshold(); while (valid == false){ enu = randomWithinInterval(threshold, 15.00); double prob = _anuerate->GetBinContent(_anuerate->FindBin(enu)); //cout<<" E_a1, prob, "< randomWithinInterval(0.,1.)) valid = true; ++counter; } return enu; } void SolidGenerateIBD::NewInteraction(G4DynamicParticle* positron, G4DynamicParticle* neutron, G4ThreeVector antineutrinoMomentumDirection, G4double energy) { if( energy < 0. ) // default IBD energy = randomNeutrinoEnergy(); _ibdKinematics->genereEvent(energy); G4double ePositron = _ibdKinematics->getEPositron();//MeV G4double eNeutron = _ibdKinematics->getENeutron(); //MeV G4double thetaPositron = _ibdKinematics->getThetaPositron(); //theta in pi G4double thetaNeutron = _ibdKinematics->getThetaNeutron();//theta in pi G4double phiPositron = randomWithinInterval(0, 2.0*pi); //phi in pi G4double phiNeutron = phiPositron - pi; positron->SetKineticEnergy(ePositron); neutron->SetKineticEnergy(eNeutron); G4ThreeVector* positronMomentumDirection= new G4ThreeVector(antineutrinoMomentumDirection); //G4cout << "Positron original momentum direction x=" << positronMomentumDirection->getX() // <<" y= " << positronMomentumDirection->getY() // <<" z= " << positronMomentumDirection->getZ() // <rotate(antineutrinoMomentumDirection.orthogonal(),thetaPositron); positronMomentumDirection->rotate(antineutrinoMomentumDirection,phiPositron); //G4cout << "Positron rotated1 momentum direction x=" << positronMomentumDirection->getX() // <<" y= " << positronMomentumDirection->getY() // <<" z= " << positronMomentumDirection->getZ() // <