LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
evgen::NeutronOsc Class Reference
Inheritance diagram for evgen::NeutronOsc:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Public Types

using ModuleType = EDProducer
 
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 

Public Member Functions

 NeutronOsc (fhicl::ParameterSet const &p)
 
 NeutronOsc (NeutronOsc const &)=delete
 
 NeutronOsc (NeutronOsc &&)=delete
 
NeutronOscoperator= (NeutronOsc const &)=delete
 
NeutronOscoperator= (NeutronOsc &&)=delete
 
void produce (art::Event &e) override
 
void beginRun (art::Run &run) override
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
void fillProductDescriptions ()
 
void registerProducts (ProductDescriptions &productsToRegister)
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
std::unique_ptr< Worker > makeWorker (WorkerParams const &wp)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Protected Member Functions

ConsumesCollector & consumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Private Member Functions

int SelectAnnihilationMode (int pdg_code)
 

Private Attributes

const genie::EventRecordVisitorI * mcgen
 
genie::NNBarOscMode_t gOptDecayMode = genie::kNONull
 
CLHEP::RandFlat flatDist
 

Detailed Description

Definition at line 72 of file NeutronOsc_module.cc.

Member Typedef Documentation

Definition at line 17 of file EDProducer.h.

template<typename UserConfig , typename KeysToIgnore = void>
using art::detail::Producer::Table = Modifier::Table<UserConfig, KeysToIgnore>
inherited

Definition at line 26 of file Producer.h.

Constructor & Destructor Documentation

evgen::NeutronOsc::NeutronOsc ( fhicl::ParameterSet const &  p)
explicit

Definition at line 100 of file NeutronOsc_module.cc.

References art::detail::EngineCreator::createEngine(), flatDist, gOptDecayMode, mcgen, seed, and evgb::SetEventGeneratorListAndTune().

101  : art::EDProducer{p}
102  // create a default random engine; obtain the random seed from NuRandomService,
103  // unless overridden in configuration with key "Seed"
105  -> registerAndSeedEngine(createEngine(0), p, "Seed")}
106 {
107  string sname = "genie::EventGenerator";
108  // GENIE v2 // string sconfig = "NeutronOsc";
109  string sconfig = "NNBarOsc";
110  // GENIE v3 needs a tune (even if irrelevant)
111  evgb::SetEventGeneratorListAndTune("Default", "Default");
112 
113  genie::PDGLibrary::Instance(); //Ensure Messenger is started first in GENIE.
114 
115  genie::AlgFactory* algf = genie::AlgFactory::Instance();
116  mcgen = dynamic_cast<const genie::EventRecordVisitorI*>(algf->GetAlgorithm(sname, sconfig));
117  if (!mcgen) {
118  throw cet::exception("NeutronOsc")
119  << "Couldn't instantiate the neutron-antineutron oscillation generator";
120  }
121  int fDecayMode = p.get<int>("DecayMode");
122  gOptDecayMode = (genie::NNBarOscMode_t)fDecayMode;
123 
124  produces<std::vector<simb::MCTruth>>();
125  produces<sumdata::RunData, art::InRun>();
126 
127  unsigned int seed = art::ServiceHandle<rndm::NuRandomService>()->getSeed();
128  genie::utils::app_init::RandGen(seed);
129 }
base_engine_t & createEngine(seed_t seed)
long seed
Definition: chem4.cc:67
const genie::EventRecordVisitorI * mcgen
void SetEventGeneratorListAndTune(const std::string &evtlistname="", const std::string &tunename="${GENIE_XSEC_TUNE}")
Definition: GENIE2ART.cxx:128
genie::NNBarOscMode_t gOptDecayMode
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
CLHEP::RandFlat flatDist
evgen::NeutronOsc::NeutronOsc ( NeutronOsc const &  )
delete
evgen::NeutronOsc::NeutronOsc ( NeutronOsc &&  )
delete

Member Function Documentation

void evgen::NeutronOsc::beginRun ( art::Run run)
overridevirtual

Reimplemented from art::EDProducer.

Definition at line 209 of file NeutronOsc_module.cc.

References geo::GeometryCore::DetectorName(), art::fullRun(), and art::Run::put().

210 {
212  run.put(std::make_unique<sumdata::RunData>(geo->DetectorName()), art::fullRun());
213 }
constexpr auto fullRun()
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: Run.h:121
std::string const & DetectorName() const
Returns a string with the name of the detector, as configured.
Definition: GeometryCore.h:203
Namespace collecting geometry-related classes utilities.
template<typename T , BranchType BT>
ProductToken< T > art::ModuleBase::consumes ( InputTag const &  tag)
protectedinherited

Definition at line 61 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumes().

62  {
63  return collector_.consumes<T, BT>(tag);
64  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ProductToken< T > consumes(InputTag const &)
ConsumesCollector & art::ModuleBase::consumesCollector ( )
protectedinherited

Definition at line 57 of file ModuleBase.cc.

References art::ModuleBase::collector_.

58  {
59  return collector_;
60  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename T , BranchType BT>
void art::ModuleBase::consumesMany ( )
protectedinherited

Definition at line 75 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumesMany().

76  {
77  collector_.consumesMany<T, BT>();
78  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::ModuleBase::consumesView ( InputTag const &  )
protectedinherited
template<typename T , BranchType BT>
ViewToken<T> art::ModuleBase::consumesView ( InputTag const &  tag)
inherited

Definition at line 68 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumesView().

69  {
70  return collector_.consumesView<T, BT>(tag);
71  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ViewToken< Element > consumesView(InputTag const &)
void art::detail::Producer::doBeginJob ( SharedResources const &  resources)
inherited

Definition at line 22 of file Producer.cc.

References art::detail::Producer::beginJobWithFrame(), and art::detail::Producer::setupQueues().

23  {
24  setupQueues(resources);
25  ProcessingFrame const frame{ScheduleID{}};
26  beginJobWithFrame(frame);
27  }
virtual void setupQueues(SharedResources const &)=0
virtual void beginJobWithFrame(ProcessingFrame const &)=0
bool art::detail::Producer::doBeginRun ( RunPrincipal rp,
ModuleContext const &  mc 
)
inherited

Definition at line 65 of file Producer.cc.

References art::detail::Producer::beginRunWithFrame(), art::RangeSet::forRun(), art::RunPrincipal::makeRun(), r, art::RunPrincipal::runID(), and art::ModuleContext::scheduleID().

66  {
67  auto r = rp.makeRun(mc, RangeSet::forRun(rp.runID()));
68  ProcessingFrame const frame{mc.scheduleID()};
69  beginRunWithFrame(r, frame);
70  r.commitProducts();
71  return true;
72  }
TRandom r
Definition: spectrum.C:23
virtual void beginRunWithFrame(Run &, ProcessingFrame const &)=0
static RangeSet forRun(RunID)
Definition: RangeSet.cc:51
bool art::detail::Producer::doBeginSubRun ( SubRunPrincipal srp,
ModuleContext const &  mc 
)
inherited

Definition at line 85 of file Producer.cc.

References art::detail::Producer::beginSubRunWithFrame(), art::RangeSet::forSubRun(), art::SubRunPrincipal::makeSubRun(), art::ModuleContext::scheduleID(), and art::SubRunPrincipal::subRunID().

86  {
87  auto sr = srp.makeSubRun(mc, RangeSet::forSubRun(srp.subRunID()));
88  ProcessingFrame const frame{mc.scheduleID()};
89  beginSubRunWithFrame(sr, frame);
90  sr.commitProducts();
91  return true;
92  }
virtual void beginSubRunWithFrame(SubRun &, ProcessingFrame const &)=0
static RangeSet forSubRun(SubRunID)
Definition: RangeSet.cc:57
void art::detail::Producer::doEndJob ( )
inherited

Definition at line 30 of file Producer.cc.

References art::detail::Producer::endJobWithFrame().

31  {
32  ProcessingFrame const frame{ScheduleID{}};
33  endJobWithFrame(frame);
34  }
virtual void endJobWithFrame(ProcessingFrame const &)=0
bool art::detail::Producer::doEndRun ( RunPrincipal rp,
ModuleContext const &  mc 
)
inherited

Definition at line 75 of file Producer.cc.

References art::detail::Producer::endRunWithFrame(), art::RunPrincipal::makeRun(), r, art::ModuleContext::scheduleID(), and art::Principal::seenRanges().

76  {
77  auto r = rp.makeRun(mc, rp.seenRanges());
78  ProcessingFrame const frame{mc.scheduleID()};
79  endRunWithFrame(r, frame);
80  r.commitProducts();
81  return true;
82  }
TRandom r
Definition: spectrum.C:23
virtual void endRunWithFrame(Run &, ProcessingFrame const &)=0
bool art::detail::Producer::doEndSubRun ( SubRunPrincipal srp,
ModuleContext const &  mc 
)
inherited

Definition at line 95 of file Producer.cc.

References art::detail::Producer::endSubRunWithFrame(), art::SubRunPrincipal::makeSubRun(), art::ModuleContext::scheduleID(), and art::Principal::seenRanges().

96  {
97  auto sr = srp.makeSubRun(mc, srp.seenRanges());
98  ProcessingFrame const frame{mc.scheduleID()};
99  endSubRunWithFrame(sr, frame);
100  sr.commitProducts();
101  return true;
102  }
virtual void endSubRunWithFrame(SubRun &, ProcessingFrame const &)=0
bool art::detail::Producer::doEvent ( EventPrincipal ep,
ModuleContext const &  mc,
std::atomic< std::size_t > &  counts_run,
std::atomic< std::size_t > &  counts_passed,
std::atomic< std::size_t > &  counts_failed 
)
inherited

Definition at line 105 of file Producer.cc.

References art::detail::Producer::checkPutProducts_, e, art::EventPrincipal::makeEvent(), art::detail::Producer::produceWithFrame(), and art::ModuleContext::scheduleID().

110  {
111  auto e = ep.makeEvent(mc);
112  ++counts_run;
113  ProcessingFrame const frame{mc.scheduleID()};
114  produceWithFrame(e, frame);
115  e.commitProducts(checkPutProducts_, &expectedProducts<InEvent>());
116  ++counts_passed;
117  return true;
118  }
bool const checkPutProducts_
Definition: Producer.h:70
Float_t e
Definition: plot.C:35
virtual void produceWithFrame(Event &, ProcessingFrame const &)=0
void art::detail::Producer::doRespondToCloseInputFile ( FileBlock const &  fb)
inherited

Definition at line 44 of file Producer.cc.

References art::detail::Producer::respondToCloseInputFileWithFrame().

45  {
46  ProcessingFrame const frame{ScheduleID{}};
48  }
virtual void respondToCloseInputFileWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void art::detail::Producer::doRespondToCloseOutputFiles ( FileBlock const &  fb)
inherited

Definition at line 58 of file Producer.cc.

References art::detail::Producer::respondToCloseOutputFilesWithFrame().

59  {
60  ProcessingFrame const frame{ScheduleID{}};
62  }
virtual void respondToCloseOutputFilesWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void art::detail::Producer::doRespondToOpenInputFile ( FileBlock const &  fb)
inherited

Definition at line 37 of file Producer.cc.

References art::detail::Producer::respondToOpenInputFileWithFrame().

38  {
39  ProcessingFrame const frame{ScheduleID{}};
41  }
virtual void respondToOpenInputFileWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void art::detail::Producer::doRespondToOpenOutputFiles ( FileBlock const &  fb)
inherited

Definition at line 51 of file Producer.cc.

References art::detail::Producer::respondToOpenOutputFilesWithFrame().

52  {
53  ProcessingFrame const frame{ScheduleID{}};
55  }
virtual void respondToOpenOutputFilesWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void art::Modifier::fillProductDescriptions ( )
inherited

Definition at line 10 of file Modifier.cc.

References art::ProductRegistryHelper::fillDescriptions(), and art::ModuleBase::moduleDescription().

11  {
13  }
void fillDescriptions(ModuleDescription const &md)
ModuleDescription const & moduleDescription() const
Definition: ModuleBase.cc:13
std::array< std::vector< ProductInfo >, NumBranchTypes > const & art::ModuleBase::getConsumables ( ) const
inherited

Definition at line 43 of file ModuleBase.cc.

References art::ModuleBase::collector_, and art::ConsumesCollector::getConsumables().

44  {
45  return collector_.getConsumables();
46  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables() const
std::unique_ptr< Worker > art::ModuleBase::makeWorker ( WorkerParams const &  wp)
inherited

Definition at line 37 of file ModuleBase.cc.

References art::ModuleBase::doMakeWorker(), and art::NumBranchTypes.

38  {
39  return doMakeWorker(wp);
40  }
virtual std::unique_ptr< Worker > doMakeWorker(WorkerParams const &wp)=0
template<typename T , BranchType BT>
ProductToken< T > art::ModuleBase::mayConsume ( InputTag const &  tag)
protectedinherited

Definition at line 82 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsume().

83  {
84  return collector_.mayConsume<T, BT>(tag);
85  }
ProductToken< T > mayConsume(InputTag const &)
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename T , BranchType BT>
void art::ModuleBase::mayConsumeMany ( )
protectedinherited

Definition at line 96 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsumeMany().

97  {
98  collector_.mayConsumeMany<T, BT>();
99  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::ModuleBase::mayConsumeView ( InputTag const &  )
protectedinherited
template<typename T , BranchType BT>
ViewToken<T> art::ModuleBase::mayConsumeView ( InputTag const &  tag)
inherited

Definition at line 89 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsumeView().

90  {
91  return collector_.mayConsumeView<T, BT>(tag);
92  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ViewToken< Element > mayConsumeView(InputTag const &)
ModuleDescription const & art::ModuleBase::moduleDescription ( ) const
inherited

Definition at line 13 of file ModuleBase.cc.

References art::errors::LogicError.

Referenced by art::OutputModule::doRespondToOpenInputFile(), art::OutputModule::doWriteEvent(), art::Modifier::fillProductDescriptions(), art::OutputModule::makePlugins_(), art::OutputWorker::OutputWorker(), reco::shower::LArPandoraModularShowerCreation::produce(), art::Modifier::registerProducts(), and art::OutputModule::registerProducts().

14  {
15  if (md_.has_value()) {
16  return *md_;
17  }
18 
20  "There was an error while calling moduleDescription().\n"}
21  << "The moduleDescription() base-class member function cannot be called\n"
22  "during module construction. To determine which module is "
23  "responsible\n"
24  "for calling it, find the '<module type>:<module "
25  "label>@Construction'\n"
26  "tag in the message prefix above. Please contact artists@fnal.gov\n"
27  "for guidance.\n";
28  }
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::optional< ModuleDescription > md_
Definition: ModuleBase.h:55
NeutronOsc& evgen::NeutronOsc::operator= ( NeutronOsc const &  )
delete
NeutronOsc& evgen::NeutronOsc::operator= ( NeutronOsc &&  )
delete
void evgen::NeutronOsc::produce ( art::Event e)
overridevirtual

Implements art::EDProducer.

Definition at line 131 of file NeutronOsc_module.cc.

References simb::MCTruth::Add(), flatDist, lcvn::interaction, geo::GeometryCore::Iterate(), simb::kUnknown, mcgen, MF_LOG_DEBUG, part, art::Event::put(), SelectAnnihilationMode(), simb::MCTruth::SetOrigin(), and target.

132 {
133  // Implementation of required member function here.
134  genie::EventRecord* event = new genie::EventRecord;
135  int target = 1000180400; //Only use argon target
136  int decay = SelectAnnihilationMode(target);
137  genie::Interaction* interaction = genie::Interaction::NOsc(target, decay);
138  event->AttachSummary(interaction);
139 
140  // Simulate decay
141  mcgen->ProcessEventRecord(event);
142 
143  // genie::Interaction *inter = event->Summary();
144  // const genie::InitialState &initState = inter->InitState();
145  // std::cout<<"initState = "<<initState.AsString()<<std::endl;
146  // const genie::ProcessInfo &procInfo = inter->ProcInfo();
147  // std::cout<<"procInfo = "<<procInfo.AsString()<<std::endl;
148  MF_LOG_DEBUG("NeutronOsc") << "Generated event: " << *event;
149 
150  std::unique_ptr<std::vector<simb::MCTruth>> truthcol(new std::vector<simb::MCTruth>);
151  simb::MCTruth truth;
152 
154 
155  // Find boundary of active volume
156  double minx = 1e9;
157  double maxx = -1e9;
158  double miny = 1e9;
159  double maxy = -1e9;
160  double minz = 1e9;
161  double maxz = -1e9;
162  for (auto const& tpc : geo->Iterate<geo::TPCGeo>(geo::CryostatID{0})) {
163  if (minx > tpc.MinX()) minx = tpc.MinX();
164  if (maxx < tpc.MaxX()) maxx = tpc.MaxX();
165  if (miny > tpc.MinY()) miny = tpc.MinY();
166  if (maxy < tpc.MaxY()) maxy = tpc.MaxY();
167  if (minz > tpc.MinZ()) minz = tpc.MinZ();
168  if (maxz < tpc.MaxZ()) maxz = tpc.MaxZ();
169  }
170 
171  // Assign vertice position
172  double X0 = flatDist.fire(minx, maxx);
173  double Y0 = flatDist.fire(miny, maxy);
174  double Z0 = flatDist.fire(minz, maxz);
175 
176  TIter partitr(event);
177  genie::GHepParticle* part = 0;
178  // GHepParticles return units of GeV/c for p. the V_i are all in fermis
179  // and are relative to the center of the struck nucleus.
180  // add the vertex X/Y/Z to the V_i for status codes 0 and 1
181  int trackid = 0;
182  std::string primary("primary");
183 
184  while ((part = dynamic_cast<genie::GHepParticle*>(partitr.Next()))) {
185 
186  simb::MCParticle tpart(
187  trackid, part->Pdg(), primary, part->FirstMother(), part->Mass(), part->Status());
188 
189  TLorentzVector pos(X0, Y0, Z0, 0);
190  TLorentzVector mom(part->Px(), part->Py(), part->Pz(), part->E());
191  tpart.AddTrajectoryPoint(pos, mom);
192  if (part->PolzIsSet()) {
193  TVector3 polz;
194  part->GetPolarization(polz);
195  tpart.SetPolarization(polz);
196  }
197  truth.Add(tpart);
198 
199  ++trackid;
200  } // end loop to convert GHepParticles to MCParticles
201  truth.SetOrigin(simb::kUnknown);
202  truthcol->push_back(truth);
203  //FillHistograms(truth);
204  e.put(std::move(truthcol));
205 
206  delete event;
207 }
details::range_type< T > Iterate() const
Initializes the specified ID with the ID of the first cryostat.
Definition: GeometryCore.h:541
void SetOrigin(simb::Origin_t origin)
Definition: MCTruth.h:82
Geometry information for a single TPC.
Definition: TPCGeo.h:36
int SelectAnnihilationMode(int pdg_code)
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: Event.h:77
TString part[npart]
Definition: Style.C:32
const genie::EventRecordVisitorI * mcgen
void Add(simb::MCParticle const &part)
Definition: MCTruth.h:80
#define MF_LOG_DEBUG(id)
cout<< "-> Edep in the target
Definition: analysis.C:53
Event generator information.
Definition: MCTruth.h:32
Namespace collecting geometry-related classes utilities.
Event finding and building.
The data type to uniquely identify a cryostat.
Definition: geo_types.h:192
CLHEP::RandFlat flatDist
void art::Modifier::registerProducts ( ProductDescriptions productsToRegister)
inherited

Definition at line 16 of file Modifier.cc.

References art::ModuleBase::moduleDescription(), and art::ProductRegistryHelper::registerProducts().

17  {
18  ProductRegistryHelper::registerProducts(productsToRegister,
20  }
void registerProducts(ProductDescriptions &productsToRegister, ModuleDescription const &md)
ModuleDescription const & moduleDescription() const
Definition: ModuleBase.cc:13
int evgen::NeutronOsc::SelectAnnihilationMode ( int  pdg_code)
private

Definition at line 215 of file NeutronOsc_module.cc.

References DEFINE_ART_MODULE, flatDist, gOptDecayMode, and util::to_string().

Referenced by produce().

216 {
217  // if the mode is set to 'random' (the default), pick one at random!
218  if ((int)gOptDecayMode == 0) {
219  int mode;
220 
221  std::string pdg_string = std::to_string(static_cast<long long>(pdg_code));
222  if (pdg_string.size() != 10) {
223  std::cout << "Expecting PDG code to be a 10-digit integer; instead, it's the following: "
224  << pdg_string << std::endl;
225  exit(1);
226  }
227 
228  // count number of protons & neutrons
229  int n_nucleons = std::stoi(pdg_string.substr(6, 3)) - 1;
230  int n_protons = std::stoi(pdg_string.substr(3, 3));
231 
232  // factor proton / neutron ratio into branching ratios
233  double proton_frac = ((double)n_protons) / ((double)n_nucleons);
234  double neutron_frac = 1 - proton_frac;
235 
236  // set branching ratios, taken from bubble chamber data
237  const int n_modes = 16;
238  double br[n_modes] = {0.010,
239  0.080,
240  0.100,
241  0.220,
242  0.360,
243  0.160,
244  0.070,
245  0.020,
246  0.015,
247  0.065,
248  0.110,
249  0.280,
250  0.070,
251  0.240,
252  0.100,
253  0.100};
254 
255  for (int i = 0; i < n_modes; i++) {
256  if (i < 7)
257  br[i] *= proton_frac;
258  else
259  br[i] *= neutron_frac;
260  }
261 
262  // randomly generate a number between 1 and 0
263  double p = flatDist.fire();
264 
265  // loop through all modes, figure out which one our random number corresponds to
266  double threshold = 0;
267  for (int i = 0; i < n_modes; i++) {
268  threshold += br[i];
269  if (p < threshold) {
270  // once we've found our mode, return it!
271  mode = i + 1;
272  return mode;
273  }
274  }
275 
276  // error message, in case the random number selection fails
277  std::cout << "Random selection of final state failed!" << std::endl;
278  exit(1);
279  }
280 
281  // if specific annihilation mode specified, just use that
282  else {
283  int mode = (int)gOptDecayMode;
284  return mode;
285  }
286 }
decltype(auto) constexpr to_string(T &&obj)
ADL-aware version of std::to_string.
genie::NNBarOscMode_t gOptDecayMode
CLHEP::RandFlat flatDist
void art::ModuleBase::setModuleDescription ( ModuleDescription const &  md)
inherited

Definition at line 31 of file ModuleBase.cc.

References art::ModuleBase::md_.

32  {
33  md_ = md;
34  }
std::optional< ModuleDescription > md_
Definition: ModuleBase.h:55
void art::ModuleBase::sortConsumables ( std::string const &  current_process_name)
inherited

Definition at line 49 of file ModuleBase.cc.

References art::ModuleBase::collector_, and art::ConsumesCollector::sortConsumables().

50  {
51  // Now that we know we have seen all the consumes declarations,
52  // sort the results for fast lookup later.
53  collector_.sortConsumables(current_process_name);
54  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
void sortConsumables(std::string const &current_process_name)

Member Data Documentation

CLHEP::RandFlat evgen::NeutronOsc::flatDist
private

Definition at line 97 of file NeutronOsc_module.cc.

Referenced by NeutronOsc(), produce(), and SelectAnnihilationMode().

genie::NNBarOscMode_t evgen::NeutronOsc::gOptDecayMode = genie::kNONull
private

Definition at line 96 of file NeutronOsc_module.cc.

Referenced by NeutronOsc(), and SelectAnnihilationMode().

const genie::EventRecordVisitorI* evgen::NeutronOsc::mcgen
private

Definition at line 95 of file NeutronOsc_module.cc.

Referenced by NeutronOsc(), and produce().


The documentation for this class was generated from the following file: