10 #include "cetlib_except/exception.h" 13 #include "TLorentzVector.h" 15 #include "TDatabasePDG.h" 87 produces< std::vector<simb::MCTruth> >();
88 produces< sumdata::RunData, art::InRun >();
93 fdsigdT =
new TF1(
"xsecform",
"TMath::Power([0] + [1],2) + TMath::Power([0] - [1],2) * TMath::Power(1-x/[2],2) - ([1]*[1] - [0]*[0] * TMath::Power([3]/[2],2))*x");
107 fNueE = (TF1*)eventrates->Get(
"NueE");
108 fNumuE = (TF1*)eventrates->Get(
"NumuE");
109 fNutauE = (TF1*)eventrates->Get(
"NutauE");
110 fNuebarE = (TF1*)eventrates->Get(
"NuebarE");
111 fNumubarE = (TF1*)eventrates->Get(
"NumubarE");
112 fNutaubarE = (TF1*)eventrates->Get(
"NutaubarE");
114 fRand =
new TRandom3(0);
133 std::unique_ptr< std::vector<simb::MCTruth> > truthcol(
new std::vector<simb::MCTruth>);
140 assert(parts.size()==2);
144 truthcol->push_back(truth);
188 double tot = totNueE + totNumuE + totNutauE +
189 totNuebarE + totNumubarE + totNutaubarE;
191 double randflav =
fRand->Uniform(0,1);
192 if (randflav < totNueE/tot){
196 else if (randflav < (totNueE+totNumuE)/tot){
200 else if (randflav < (totNueE+totNumuE+totNutauE)/tot){
204 else if (randflav < (totNueE+totNumuE+totNutauE+totNuebarE)/tot){
208 else if (randflav < (totNueE+totNumuE+totNutauE+totNuebarE+totNumubarE)/tot){
220 double nuCos =
fRand->Uniform(-1,1);
221 double nuPhi =
fRand->Uniform(0,2*TMath::Pi());
222 fNuDir.SetX(sqrt(1-nuCos*nuCos)*sin(nuPhi));
223 fNuDir.SetY(sqrt(1-nuCos*nuCos)*cos(nuPhi));
229 static TDatabasePDG
pdg;
230 TParticlePDG* pdgp = pdg.GetParticle(ePDG);
232 if (pdgp) eMass = pdgp->Mass();
235 double ga =
abs(flav)==12 ? 0.5 : -0.5;
236 double gv =
abs(flav)==12 ? 2*
fWMA+0.5 : 2*
fWMA-0.5;
240 fdsigdT->SetParameter(3,eMass);
243 double tmax = 2*eMass / (TMath::Power(1+eMass/Enu,2) - 1);
244 double eKE =
fdsigdT->GetRandom(0,tmax);
245 double eMom = sqrt(eKE*eKE+2*eMass*eKE);
246 std::cout <<
"Throwing a neutrino of energy " << Enu <<
" with a maximum electron energy " << tmax <<
" from cross section " <<
fdsigdT->GetExpFormula() <<
", and got " << eKE <<
std::endl;
251 TMath::Sqrt( (eKE*TMath::Power(1+(eMass/Enu),2) ) / ( 2*eMass + eKE));
252 double EPhi =
fRand->Uniform(0,2*TMath::Pi());
253 eDir.SetX(sqrt(1-ECos*ECos)*sin(EPhi));
254 eDir.SetY(sqrt(1-ECos*ECos)*cos(EPhi));
257 TVector3 zaxis(0,0,1);
258 TVector3 rotationAxis = zaxis.Cross(
fNuDir);
259 double rotationAngle = zaxis.Angle(
fNuDir);
260 eDir.Rotate(rotationAngle,rotationAxis);
262 TVector3
e = eMom * eDir;;
263 TVector3 nu = Enu *
fNuDir;;
265 TLorentzVector e4d(e,eMass+eKE);
266 TLorentzVector nu4d(nu,Enu);
272 TLorentzVector vtx(vtxx,vtxy,vtxz,vtxt);
281 std::vector<simb::MCParticle> ret;
EventNumber_t event() const
void AddTrajectoryPoint(TLorentzVector const &position, TLorentzVector const &momentum)
EDProducer(fhicl::ParameterSet const &pset)
NuEScatterGen(fhicl::ParameterSet const &p)
std::vector< simb::MCParticle > GenerateEventKinematics()
art framework interface to geometry description
void reconfigure(fhicl::ParameterSet const &p)
void produce(art::Event &e) override
#define DEFINE_ART_MODULE(klass)
std::string DetectorName() const
Returns a string with the name of the detector, as configured.
std::string fEventRateFileName
T get(std::string const &key) const
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
void Add(simb::MCParticle const &part)
void beginRun(art::Run &run) override
Event generator information.
LArSoft geometry interface.
Event Generation using GENIE, cosmics or single particles.
QTextStream & endl(QTextStream &s)