21 #include "CLHEP/Random/RandFlat.h" 23 #include "TDatabasePDG.h" 25 #include "TLorentzVector.h" 64 produces< std::vector<simb::MCTruth> >();
65 produces< sumdata::RunData, art::InRun >();
74 fMass = TDatabasePDG().GetParticle(fPDGCode)->Mass();
83 (p.
get<std::string>(
"MomentumShapeFormula")).c_str(),
84 p.
get<
double>(
"MomentumLowerBound"),
85 p.
get<
double>(
"MomentumUpperBound"));
90 <<
"Failed making momentum spectrum shape from provided formula!" << std::endl;
93 std::vector<double> shape_par_values = p.
get<std::vector<double> >(
"MomentumShapeParameters");
99 <<
"Number of parameters provided to MomentumShapeFormula does not match with the formula!" << std::endl;
102 for(
size_t i=0; i<shape_par_values.size(); ++i)
112 (p.
get<std::string>(
"ThetaShapeFormula")).c_str(),
113 p.
get<
double>(
"ThetaLowerBound"),
114 p.
get<
double>(
"ThetaUpperBound"));
119 <<
"Failed making momentum spectrum shape from provided formula!" << std::endl;
122 shape_par_values = p.
get<std::vector<double> >(
"ThetaShapeParameters");
125 if((
int)(shape_par_values.size()) !=
fShapeTheta->GetNpar())
128 <<
"Number of parameters provided to ThetaShapeFormula does not match with the formula!" << std::endl;
131 for(
size_t i=0; i<shape_par_values.size(); ++i)
133 fShapeTheta->SetParameter(i,shape_par_values.at(i));
142 CLHEP::HepRandomEngine &engine = rng->
getEngine();
154 run.
put(std::move(runData));
168 std::vector<double> pos(3,0);
189 std::vector<double> udir(3,0);
191 double phi =
fFlatRandom->fire(0, 2 * 3.141592653589793238);
193 udir[0] = TMath::Sin(TMath::ACos(uz)) * TMath::Cos(phi);
194 udir[1] = TMath::Sin(TMath::ACos(uz)) * TMath::Sin(phi);
202 std::unique_ptr< std::vector<simb::MCTruth> > mctArray(
new std::vector<simb::MCTruth>);
212 TLorentzVector pos_lorentz(pos.at(0), pos.at(1), pos.at(2),
fTime);
213 TLorentzVector mom_lorentz( dir.at(0) * mom,
216 sqrt(pow(mom,2)+pow(
fMass,2)));
220 part.AddTrajectoryPoint(pos_lorentz, mom_lorentz);
224 mctArray->push_back(truth);
226 e.
put(std::move(mctArray));
geo::Length_t DetHalfWidth(geo::TPCID const &tpcid) const
Returns the half width of the active volume of the specified TPC.
ToyOneShowerGen(fhicl::ParameterSet const &p)
art::ProductID put(std::unique_ptr< PROD > &&)
void Add(simb::MCParticle &part)
ProductID put(std::unique_ptr< PROD > &&product)
base_engine_t & getEngine() const
base_engine_t & createEngine(seed_t seed)
geo::Length_t DetHalfHeight(geo::TPCID const &tpcid) const
Returns the half height of the active volume of the specified TPC.
#define DEFINE_ART_MODULE(klass)
virtual ~ToyOneShowerGen()
std::string DetectorName() const
Returns a string with the name of the detector, as configured.
T get(std::string const &key) const
geo::Length_t DetLength(geo::TPCID const &tpcid) const
Returns the length of the active volume of the specified TPC.
An art service to assist in the distribution of guaranteed unique seeds to all engines within an art ...
std::vector< double > GetXYZDirection(double uz=0)
CLHEP::RandFlat * fFlatRandom
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
void produce(art::Event &e) override
std::vector< double > GetXYZPosition()
void beginRun(art::Run &run) override
Event generator information.
Namespace collecting geometry-related classes utilities.
Tools and modules for checking out the basics of the Monte Carlo.
art framework interface to geometry description
cet::coded_exception< error, detail::translate > exception