9 #include "cetlib_except/exception.h" 11 #include "TLorentzVector.h" 13 #include "TDatabasePDG.h" 70 produces< std::vector<simb::MCTruth> >();
71 produces< sumdata::RunData, art::InRun >();
76 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");
77 fRand =
new TRandom3(0);
106 std::unique_ptr< std::vector<simb::MCTruth> > truthcol(
new std::vector<simb::MCTruth>);
112 assert(parts.size()==2);
116 TVector3 vec0(parts[0].Px(),parts[0].Py(),parts[0].Pz());
117 TVector3 vec1(parts[1].Px(),parts[1].Py(),parts[1].Pz());
119 truthcol->push_back(truth);
151 static TDatabasePDG
pdg;
152 TParticlePDG* pdgp = pdg.GetParticle(ePDG);
154 if (pdgp) eMass = pdgp->Mass();
163 int nuPDG = gRandom->Uniform(0,1) < fracE ? 12 : 14;
166 double ga = nuPDG==12 ? 0.5 : -0.5;
167 double gv = nuPDG==12 ? 2*fWMA+0.5 : 2*fWMA-0.5;
171 fdsigdT->SetParameter(3,eMass);
174 double tmax = 2*eMass / (TMath::Power(1+eMass/Enu,2) - 1);
175 double eKE =
fdsigdT->GetRandom(0,tmax);
176 double eMom = sqrt(eKE*eKE+2*eMass*eKE);
177 std::cout <<
"Throwing a neutrino of energy " << Enu <<
" with a maximum electron energy " << tmax <<
" from cross section " <<
fdsigdT->GetExpFormula() <<
", and got " << eKE <<
std::endl;
180 double nuCos =
fRand->Uniform(-1,1);
181 double nuPhi = gRandom->Uniform(0,2*TMath::Pi());
182 TVector3 nu(sqrt(1-nuCos*nuCos)*sin(nuPhi),
183 sqrt(1-nuCos*nuCos)*cos(nuPhi),
189 TVector3 zprime = nu.Unit();
190 TVector3 xprime(0,0,0);
191 xprime.SetX(1-nu[0]*nu[0]);
192 xprime.SetY( -nu[0]*nu[1]);
193 xprime.SetZ( -nu[0]*nu[2]);
194 xprime = xprime.Unit();
195 TVector3 yprime(0,0,0);
196 yprime.SetX( -nu[1]*nu[0]-xprime[1]*xprime[0]);
197 yprime.SetY(1-nu[1]*nu[1]-xprime[1]*xprime[1]);
198 yprime.SetZ( -nu[1]*nu[2]-xprime[1]*xprime[2]);
199 yprime = yprime.Unit();
202 TMath::Sqrt( (eKE*TMath::Power(1+(eMass/Enu),2) ) / ( 2*eMass + eKE));
203 double ePhi =
fRand->Uniform(0,2*TMath::Pi());
205 double eSin = sqrt(1-eCos*eCos);
207 e.SetX(eCos*zprime[0]+eSin*sin(ePhi)*xprime[0]+eSin*cos(ePhi)*yprime[0]);
208 e.SetY(eCos*zprime[1]+eSin*sin(ePhi)*xprime[1]+eSin*cos(ePhi)*yprime[1]);
209 e.SetZ(eCos*zprime[2]+eSin*sin(ePhi)*xprime[2]+eSin*cos(ePhi)*yprime[2]);
214 TLorentzVector e4d(e,eMass+eKE);
215 TLorentzVector nu4d(nu,Enu);
221 TLorentzVector vtx(vtxx,vtxy,vtxz,vtxt);
230 std::vector<simb::MCParticle> ret;
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.
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)