14 #include "art/Framework/Core/EDProducer.h"
15 #include "art/Framework/Core/ModuleMacros.h"
16 #include "art/Framework/Principal/Event.h"
17 #include "art/Framework/Principal/Run.h"
18 #include "art/Framework/Services/Registry/ServiceHandle.h"
19 #include "fhiclcpp/ParameterSet.h"
20 #include "messagefacility/MessageLogger/MessageLogger.h"
23 #include "Framework/Algorithm/AlgFactory.h"
24 #include "Framework/EventGen/EventRecordVisitorI.h"
25 #include "Framework/EventGen/EventRecord.h"
26 #include "Physics/NucleonDecay/NucleonDecayMode.h"
27 #include "Physics/NucleonDecay/NucleonDecayUtils.h"
28 #include "Framework/ParticleData/PDGLibrary.h"
29 #include "Framework/GHEP/GHepParticle.h"
30 #include "Framework/Utils/AppInit.h"
33 #include "nusimdata/SimulationBase/MCTruth.h"
34 #include "nusimdata/SimulationBase/MCParticle.h"
36 #include "nugen/EventGeneratorBase/GENIE/GENIE2ART.h"
40 #include "nurandom/RandomUtils/NuRandomService.h"
46 #include "CLHEP/Random/RandFlat.h"
65 void produce(art::Event &
e)
override;
68 void beginRun(art::Run& run)
override;
73 const genie::EventRecordVisitorI *
mcgen;
84 , flatDist{art::ServiceHandle<rndm::NuRandomService>{}->createEngine(*
this,
p,
"Seed")}
86 genie::PDGLibrary::Instance();
88 string sname =
"genie::EventGenerator";
91 evgb::SetEventGeneratorListAndTune(
"Default",
"Default");
93 genie::AlgFactory *
algf = genie::AlgFactory::Instance();
95 dynamic_cast<const genie::EventRecordVisitorI *
> (algf->GetAlgorithm(sname,sconfig));
97 throw cet::exception(
"NucleonDecay") <<
"Couldn't instantiate the nucleon decay generator";
102 if (
p.get<
int>(
"DecayedNucleon") > 0 ){
103 dpdg =
p.get<
int>(
"DecayedNucleon");
106 dpdg = genie::utils::nucleon_decay::DecayedNucleonPdgCode(
gOptDecayMode);
109 produces< std::vector<simb::MCTruth> >();
112 unsigned int seed = art::ServiceHandle<rndm::NuRandomService>()->getSeed();
113 genie::utils::app_init::RandGen(seed);
119 genie::EventRecord *
event =
new genie::EventRecord;
120 int target = 1000180400;
122 genie::Interaction * interaction = genie::Interaction::NDecay(target,decay,dpdg);
123 event->AttachSummary(interaction);
126 mcgen->ProcessEventRecord(event);
133 MF_LOG_DEBUG(
"NucleonDecay")
134 <<
"Generated event: " << *event;
136 std::unique_ptr< std::vector<simb::MCTruth> > truthcol(
new std::vector<simb::MCTruth>);
139 art::ServiceHandle<geo::Geometry const> geo;
148 for (
size_t i = 0; i<geo->NTPC(); ++i){
150 if (minx>tpc.
MinX()) minx = tpc.
MinX();
151 if (maxx<tpc.
MaxX()) maxx = tpc.
MaxX();
152 if (miny>tpc.
MinY()) miny = tpc.
MinY();
153 if (maxy<tpc.
MaxY()) maxy = tpc.
MaxY();
154 if (minz>tpc.
MinZ()) minz = tpc.
MinZ();
155 if (maxz<tpc.
MaxZ()) maxz = tpc.
MaxZ();
159 double X0 = flatDist.fire( minx, maxx );
160 double Y0 = flatDist.fire( miny, maxy );
161 double Z0 = flatDist.fire( minz, maxz );
163 TIter partitr(event);
164 genie::GHepParticle *part = 0;
169 std::string primary(
"primary");
171 while( (part = dynamic_cast<genie::GHepParticle *>(partitr.Next())) ){
173 simb::MCParticle tpart(trackid,
180 TLorentzVector pos(X0, Y0, Z0, 0);
181 TLorentzVector mom(part->Px(), part->Py(), part->Pz(), part->E());
182 tpart.AddTrajectoryPoint(pos,mom);
183 if(part->PolzIsSet()) {
185 part->GetPolarization(polz);
186 tpart.SetPolarization(polz);
188 tpart.SetRescatter(part->RescatterCode());
193 truth.SetOrigin(simb::kUnknown);
194 truthcol->push_back(truth);
196 e.put(std::move(truthcol));
203 art::ServiceHandle<geo::Geometry const> geo;
204 run.put(std::make_unique<sumdata::RunData>(geo->DetectorName()));
genie::NucleonDecayMode_t gOptDecayMode
NucleonDecay(fhicl::ParameterSet const &p)
process_name opdaq physics producers generator physics producers generator physics producers generator Z0
const genie::EventRecordVisitorI * mcgen
double MinX() const
Returns the world x coordinate of the start of the box.
Geometry information for a single TPC.
produces< sumdata::RunData, art::InRun >()
double MaxX() const
Returns the world x coordinate of the end of the box.
process_name opdaq physics producers generator physics producers generator Y0
void beginRun(art::Run &run) override
standard_singlep gaussian distribution X0
double MinZ() const
Returns the world z coordinate of the start of the box.
void produce(art::Event &e) override
double MaxY() const
Returns the world y coordinate of the end of the box.
NucleonDecay & operator=(NucleonDecay const &)=delete
double MaxZ() const
Returns the world z coordinate of the end of the box.
double MinY() const
Returns the world y coordinate of the start of the box.
art framework interface to geometry description