15 #include "TDatabasePDG.h" 36 #include "nugen/EventGeneratorBase/evgenbase.h" 38 #include "NovaDAQConventions/DAQConventions.h" 58 void Generate(std::unique_ptr< std::vector<simb::MCTruth>> &truthcol);
62 double GetMomentum(
const double& pkf,
const double&
m)
const;
122 produces<std::vector<simb::MCTruth>>();
123 produces<sumdata::SubRunData, art::InSubRun>();
124 produces<sumdata::RunData, art::InRun >();
137 std::cout <<
"SupernovaGen: Using Kinetic energy for the meaning of P0, SigmaP and PDist" <<
std::endl;
140 std::cout <<
"SupernovaGen: Using Total energy for the meaning of P0, SigmaP and PDist" <<
std::endl;
166 TFile *
root_file =
new TFile(fPositronPDFFile.c_str());
183 r.
put(std::move(runcol));
193 sr.
put(std::move(sd));
199 std::unique_ptr<std::vector<simb::MCTruth>> truthcol(
new std::vector<simb::MCTruth>);
212 e.
put(std::move(truthcol));
229 int generatedPositrons = 0;
231 for (
int energyBin = 0; energyBin <
fNenergyBins; ++energyBin) {
234 double positronPDF = 0.;
244 if (nPositrons > 0) {
245 std::cout <<
"\tEnergy bin[" << energyBin
247 <<
" GeV), positron PDF: " << positronPDF
251 std::cout <<
"\tGenerating " << nPositrons
255 for (
int positronIdx = 0; positronIdx < nPositrons; ++positronIdx) {
256 generatedPositrons++;
264 const TDatabasePDG* pdgt = TDatabasePDG::Instance();
265 const TParticlePDG* pdgp = pdgt->GetParticle(
fPDG);
269 if (pdgp) m = pdgp->Mass();
281 std::cout <<
"\t\tpositron[ " << generatedPositrons-1
283 <<
" GeV, x: " << x[0]
284 <<
" cm, y: " << x[1]
285 <<
" cm, z: " << x[2]
286 <<
" cm, t: " << x[3]
289 const TLorentzVector
pos(x[0], x[1], x[2], x[3]);
294 for (tryIdx = 0; tryIdx < 1000000; ++tryIdx) {
305 if (cosz >= -1.0 && cosz <= 1.0)
break;
307 if (cosz < -1.0 || cosz > 1.0) {
308 mf::LogError(
"SupernovaGen") << __FILE__ <<
":" << __LINE__
309 <<
" Failed to find an acceptable cos(theta_z)" 310 <<
" after many tries.\n" 311 <<
" Please adjust CosZ0 and SigmaCosZ0 in your" 312 <<
" SupernovaGen.fcl file and rerun";
316 const double sinz =
sqrt(1.0 - cosz * cosz);
317 const double sinphi =
sin(phi *
M_PI / 180.0);
318 const double cosphi =
cos(phi *
M_PI / 180.0);
321 const int trackid = -1 * (generatedPositrons + 1);
326 const TLorentzVector pvec(cosphi * sinz * p,
329 sqrt(p * p + m * m));
334 truthcol->push_back(mct);
338 std::cout <<
"Generated a total of " << generatedPositrons
347 double total_energy = 0.0;
349 total_energy = pkf +
m;
355 total_energy =
sqrt(pkf * pkf + m * m);
358 return sqrt(total_energy * total_energy - m * m);
double fYlow
Lower y position (cm)
void AddTrajectoryPoint(TLorentzVector const &position, TLorentzVector const &momentum)
int fAngleDist
How to distribute angles (0=uniform, 1=gaussian)
void SetOrigin(simb::Origin_t origin)
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
unsigned int GetRandomNumberSeed()
base_engine_t & createEngine(seed_t seed)
double fYhigh
Upper y position (cm)
int fPDG
PDG code of particles to generate.
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
art::ProductID put(std::unique_ptr< PROD > &&)
DEFINE_ART_MODULE(TestTMapFile)
void Add(simb::MCParticle &part)
double fMaxPositronEnergy
ProductID put(std::unique_ptr< PROD > &&product)
double fPhiXY0
Central angle in the x-y plane (degrees)
double sd(Eigen::VectorXd x)
void reconfigure(const fhicl::ParameterSet &p)
base_engine_t & getEngine() const
double fSigmaCosZ
Size of variation of cosz.
double fXhigh
Upper x position (cm)
single particles thrown at the detector
SupernovaGen(fhicl::ParameterSet const &p)
T get(std::string const &key) const
void Generate(std::unique_ptr< std::vector< simb::MCTruth >> &truthcol)
novadaq::cnv::DetId DetId() const
Prefer ds::DetectorService::DetId() instead.
double fZhigh
Upper z position (cm)
double fXlow
Lower x position (cm)
std::string fPositronPDFFile
ROOT file name where the positron PDFs are stored.
void endSubRun(art::SubRun &sr)
EventNumber_t event() const
static constexpr Double_t gauss
double GetMomentum(const double &pkf, const double &m) const
double fCosZ0
Cosine of central angle wrt z-axis.
double fDistanceScaling
Scaling factor to PDF values.
bool fOnlyNoise
Generate no signal.
double fTlow
Lower t position (ns)
double fZlow
Lower z position (cm)
ProductID put(std::unique_ptr< PROD > &&)
double fSigmaPhiXY
Size of variation in phixy (degrees)
IDNumber_t< Level::Event > EventNumber_t
std::string ExtractGDML() const
Extract contents from fGDMLFile and return as a string.
int fCycle
MC production cycle.
void produce(art::Event &e)
void beginRun(art::Run &r)
double fThigh
Upper t position (ns)
Event generator information.
Module to generate only pions from cosmic rays.
Encapsulate the geometry of one entire detector (near, far, ndos)
double fMinPositronEnergy
std::string FileBaseName() const
art::EventNumber_t fEventPadding
Number of empty events to place at beginning of file.