15 #include "TDatabasePDG.h" 35 #include "nugen/EventGeneratorBase/evgenbase.h" 64 double getMomentum(
const double& pkf,
const double&
m)
const;
76 std::vector<double>
fP0;
81 std::vector<double>
fX0;
82 std::vector<double>
fY0;
83 std::vector<double>
fZ0;
84 std::vector<double>
fT0;
236 produces< std::vector<simb::MCTruth> >();
237 produces< sumdata::SubRunData, art::InSubRun >();
238 produces< sumdata::RunData, art::InRun >();
247 fPDG = pset.
get< std::vector<int> >(
"PDG");
252 std::cout<<
"SingleGen: Using Kinetic energy for the meaning of P0, SigmaP and PDist\n";
254 else if(fPMeaning == 2) {
255 std::cout<<
"SingleGen: Using Total energy for the meaning of P0, SigmaP and PDist\n";
258 fP0 = pset.
get< std::vector<double> >(
"P0");
259 fSigmaP = pset.
get< std::vector<double> >(
"SigmaP");
260 fSigmaP2 = pset.
get< std::vector<double> >(
"SigmaP2");
261 fPDist = pset.
get< std::vector<int> >(
"PDist");
262 fX0 = pset.
get< std::vector<double> >(
"X0");
263 fY0 = pset.
get< std::vector<double> >(
"Y0");
264 fZ0 = pset.
get< std::vector<double> >(
"Z0");
265 fT0 = pset.
get< std::vector<double> >(
"T0");
266 fSigmaX = pset.
get< std::vector<double> >(
"SigmaX");
267 fSigmaY = pset.
get< std::vector<double> >(
"SigmaY");
268 fSigmaZ = pset.
get< std::vector<double> >(
"SigmaZ");
269 fSigmaT = pset.
get< std::vector<double> >(
"SigmaT");
270 fSigmaX2 = pset.
get< std::vector<double> >(
"SigmaX2");
271 fSigmaY2 = pset.
get< std::vector<double> >(
"SigmaY2");
272 fSigmaZ2 = pset.
get< std::vector<double> >(
"SigmaZ2");
273 fSigmaT2 = pset.
get< std::vector<double> >(
"SigmaT2");
274 fPosDist = pset.
get< std::vector<int> >(
"PosDist");
275 fCosZ0 = pset.
get< std::vector<double> >(
"CosZ0");
279 fPhiXY0 = pset.
get< std::vector<double> >(
"PhiXY0");
282 fPhiDist = pset.
get< std::vector<int> >(
"PhiDist");
308 run.
put(std::move(runcol));
310 bool UseROOT =
false;
311 for (
unsigned int i=0;
i<
fPDG.size(); ++
i)
321 phi_mu = (TH1F*)
f.Get(
"phi_mu");
324 phi_pi = (TH1F*)
f.Get(
"phi_pi");
327 phi_pr = (TH1F*)
f.Get(
"phi_pr");
330 phi_ph = (TH1F*)
f.Get(
"phi_ph");
333 phi_el = (TH1F*)
f.Get(
"phi_el");
418 sum = pmag_mu->GetBinContent(
i) +
sum;
582 sr.
put(std::move(sd));
591 std::unique_ptr< std::vector<simb::MCTruth> > truthcol(
new std::vector<simb::MCTruth>);
598 truthcol->push_back(truth);
601 evt.
put(std::move(truthcol));
629 for (
unsigned int i=0;
i<
fPDG.size(); ++
i) {
675 const TDatabasePDG* pdgt = TDatabasePDG::Instance();
676 const TParticlePDG* pdgp = pdgt->GetParticle(
fPDG[
i]);
679 if (pdgp) m = pdgp->Mass();
787 const TLorentzVector
pos(x[0], x[1], x[2], x[3]);
793 for (itry=0; itry<1000000; ++itry) {
841 if (cosz>=-1.0 && cosz<=1.0)
break;
844 if (cosz<-1.0 || cosz>1.0) {
845 mf::LogError(
"SingleGen") << __FILE__ <<
":" << __LINE__
846 <<
" Failed to find an acceptable cos(theta_z)" 847 <<
" after many tries.\n" 848 <<
" Please adjust CosZ0 and SigmaCosZ0 in your" 849 <<
" SingleGen.fcl file and rerun";
901 const double sinz =
sqrt(1.0-cosz*cosz);
902 const double sinphi =
sin(phi*
M_PI/180.0);
903 const double cosphi =
cos(phi*
M_PI/180.0);
908 const int trackid = -1*(i+1);
917 TVector3 flat_unit_p = TVector3(gauss.
fire(), gauss.
fire(), gauss.
fire()).
Unit();
918 pvec.SetPxPyPzE(p*flat_unit_p.Px(),
931 pvec.SetPxPyPzE(cosphi*sinz*p,
948 double total_energy = 0.0;
950 total_energy = pkf +
m;
956 total_energy =
sqrt(pkf*pkf + m*m);
959 return sqrt(total_energy*total_energy - m*m);
std::vector< double > fSigmaT2
Variation in t position (ns)
std::vector< double > fSigmaP2
Variation in momenta (GeV/c)
std::vector< int > fCosZDist
How to distribute cosz (0=uniform, 1=gaussian)
std::vector< float > sums_phi_el
A module to check the results from the Monte Carlo generator.
std::vector< float > sums_posy_pi
std::vector< float > sums_theta_pi
std::vector< float > sums_posz_el
std::vector< float > sums_posz_pr
std::vector< double > fSigmaPhiXY2
Size of variation in phixy (degrees)
std::vector< float > sums
void AddTrajectoryPoint(TLorentzVector const &position, TLorentzVector const &momentum)
std::vector< float > sums_posx_mu
void SetOrigin(simb::Origin_t origin)
std::vector< float > sums_phi_pi
std::vector< double > fSigmaT
Variation in t position (ns)
std::vector< float > sums_posy_ph
double getMomentum(const double &pkf, const double &m) const
std::vector< double > fSigmaZ2
Variation in z position (cm)
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
unsigned int GetRandomNumberSeed()
std::vector< bool > fCoverage4pi
Boolean to override other angle args and achieve 4pi coverage.
base_engine_t & createEngine(seed_t seed)
std::vector< float > sums_posy_mu
std::vector< int > fPosDist
How to distribute xyz (0=uniform, 1=gaussian)
std::vector< double > fSigmaCosZ2
Size of variation of cosz.
std::vector< float > sums_theta_mu
std::vector< float > sums_posz_pi
std::vector< float > sums_phi_ph
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
art::ProductID put(std::unique_ptr< PROD > &&)
DEFINE_ART_MODULE(TestTMapFile)
void reconfigure(const fhicl::ParameterSet &pset)
void Add(simb::MCParticle &part)
std::vector< float > sums_posx_el
std::vector< float > sums_phi_pr
std::vector< float > sums_theta_el
std::vector< float > sums_posz_ph
std::vector< float > sums_posy_pr
std::vector< float > sums_posx_pr
std::vector< double > fSigmaZ
Variation in z position (cm)
std::vector< float > sums_pmag_pi
ProductID put(std::unique_ptr< PROD > &&product)
double sd(Eigen::VectorXd x)
std::vector< float > sums_pmag_ph
std::vector< double > fT0
Central t position (ns)
std::vector< double > fSigmaCosZ
Size of variation of cosz.
base_engine_t & getEngine() const
std::vector< int > fPDist
How to distribute momenta (0=uniform, 1=gaussian)
std::vector< double > fSigmaPhiXY
Size of variation in phixy (degrees)
std::vector< double > fP0
Central momentum (GeV/c) to generate.
std::vector< float > sums_theta_ph
single particles thrown at the detector
std::vector< float > sums_posx_ph
std::vector< float > sums_pmag_mu
T get(std::string const &key) const
novadaq::cnv::DetId DetId() const
Prefer ds::DetectorService::DetId() instead.
std::vector< float > sums_pmag_el
std::vector< int > fPhiDist
How to distribute phixy (0=uniform, 1=gaussian)
static constexpr Double_t gauss
std::vector< double > fCosZ0
Cosine of central angle wrt z-axis.
std::vector< float > sums_posx_pi
std::vector< double > fY0
Central y position (cm)
std::vector< int > fPDG
PDG code of particles to generate.
std::vector< double > fSigmaY2
Variation in y position (cm)
std::vector< float > sums_posz_mu
std::vector< double > fSigmaX2
Variation in x position (cm)
std::vector< double > fSigmaP
Variation in momenta (GeV/c)
void produce(art::Event &evt)
std::vector< double > fZ0
Central z position (cm)
std::vector< double > fSigmaX
Variation in x position (cm)
int fCycle
cycle number of MC production
ProductID put(std::unique_ptr< PROD > &&)
void endSubRun(art::SubRun &sr)
void beginRun(art::Run &run)
std::vector< double > fX0
Central x position (cm)
std::vector< float > sums_pmag_pr
assert(nhit_max >=nhit_nbins)
std::vector< double > fPhiXY0
Central angle in the x-y plane (degrees)
std::string ExtractGDML() const
Extract contents from fGDMLFile and return as a string.
void Sample(simb::MCTruth &truth)
Event generator information.
Module to generate only pions from cosmic rays.
SingleGen(fhicl::ParameterSet const &pset)
Encapsulate the geometry of one entire detector (near, far, ndos)
std::vector< float > sums_phi_mu
std::string FileBaseName() const
std::vector< float > sums_theta_pr
std::vector< double > fSigmaY
Variation in y position (cm)
std::vector< float > sums_posy_el