24 #include "Algorithm/AlgFactory.h" 25 #include "EVGCore/EventRecordVisitorI.h" 26 #include "EVGCore/EventRecord.h" 27 #include "NucleonDecay/NucleonDecayMode.h" 28 #include "NucleonDecay/NucleonDecayUtils.h" 29 #include "PDG/PDGLibrary.h" 30 #include "GHEP/GHepParticle.h" 31 #include "Utils/AppInit.h" 46 #include "CLHEP/Random/RandFlat.h" 74 const genie::EventRecordVisitorI *
mcgen;
82 genie::PDGLibrary::Instance();
84 string sname =
"genie::EventGenerator";
85 string sconfig =
"NucleonDecay";
86 genie::AlgFactory * algf = genie::AlgFactory::Instance();
88 dynamic_cast<const genie::EventRecordVisitorI *
> (algf->GetAlgorithm(sname,sconfig));
90 throw cet::exception(
"NucleonDecay") <<
"Couldn't instantiate the nucleon decay generator";
92 int fDecayMode = p.
get<
int>(
"DecayMode");
95 if (p.
get<
int>(
"DecayedNucleon") > 0 ){
96 dpdg = p.
get<
int>(
"DecayedNucleon");
99 dpdg = genie::utils::nucleon_decay::DecayedNucleonPdgCode(gOptDecayMode);
102 produces< std::vector<simb::MCTruth> >();
103 produces< sumdata::RunData, art::InRun >();
110 unsigned int seed = art::ServiceHandle<rndm::NuRandomService>()->getSeed();
111 genie::utils::app_init::RandGen(seed);
117 genie::EventRecord *
event =
new genie::EventRecord;
120 genie::Interaction * interaction = genie::Interaction::NDecay(target,decay,
dpdg);
121 event->AttachSummary(interaction);
132 <<
"Generated event: " << *
event;
134 std::unique_ptr< std::vector<simb::MCTruth> > truthcol(
new std::vector<simb::MCTruth>);
139 CLHEP::HepRandomEngine &engine = rng->
getEngine();
140 CLHEP::RandFlat flat(engine);
149 for (
size_t i = 0; i<geo->
NTPC(); ++i){
151 if (minx>tpc.
MinX()) minx = tpc.
MinX();
152 if (maxx<tpc.
MaxX()) maxx = tpc.
MaxX();
153 if (miny>tpc.
MinY()) miny = tpc.
MinY();
154 if (maxy<tpc.
MaxY()) maxy = tpc.
MaxY();
155 if (minz>tpc.
MinZ()) minz = tpc.
MinZ();
156 if (maxz<tpc.
MaxZ()) maxz = tpc.
MaxZ();
160 double X0 = flat.fire( minx, maxx );
161 double Y0 = flat.fire( miny, maxy );
162 double Z0 = flat.fire( minz, maxz );
164 TIter partitr(
event);
165 genie::GHepParticle *
part = 0;
170 std::string primary(
"primary");
172 while( (part = dynamic_cast<genie::GHepParticle *>(partitr.Next())) ){
181 TLorentzVector pos(X0, Y0, Z0, 0);
182 TLorentzVector mom(part->Px(), part->Py(), part->Pz(), part->E());
183 tpart.AddTrajectoryPoint(pos,mom);
184 if(part->PolzIsSet()) {
186 part->GetPolarization(polz);
187 tpart.SetPolarization(polz);
189 tpart.SetRescatter(part->RescatterCode());
195 truthcol->push_back(truth);
197 e.
put(std::move(truthcol));
211 run.
put(std::move(runcol));
genie::NucleonDecayMode_t gOptDecayMode
NucleonDecay(fhicl::ParameterSet const &p)
void SetOrigin(simb::Origin_t origin)
cout<< "-> Edep in the target
const genie::EventRecordVisitorI * mcgen
double MinX() const
Returns the world x coordinate of the start of the box.
Geometry information for a single TPC.
double MaxX() const
Returns the world x coordinate of the end of the box.
art::ProductID put(std::unique_ptr< PROD > &&)
void Add(simb::MCParticle &part)
void beginRun(art::Run &run) override
ProductID put(std::unique_ptr< PROD > &&product)
base_engine_t & getEngine() const
base_engine_t & createEngine(seed_t seed)
#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
double MinZ() const
Returns the world z coordinate of the start of the box.
void produce(art::Event &e) override
An art service to assist in the distribution of guaranteed unique seeds to all engines within an art ...
double MaxY() const
Returns the world y coordinate of the end of the box.
unsigned int NTPC(unsigned int cstat=0) const
Returns the total number of TPCs in the specified cryostat.
NucleonDecay & operator=(NucleonDecay const &)=delete
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
double MaxZ() const
Returns the world z coordinate of the end of the box.
TPCGeo const & TPC(unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified TPC.
Event generator information.
Namespace collecting geometry-related classes utilities.
double MinY() const
Returns the world y coordinate of the start of the box.
Event Generation using GENIE, cosmics or single particles.
art framework interface to geometry description
cet::coded_exception< error, detail::translate > exception
Event finding and building.