55 #include "nugen/EventGeneratorBase/GENIE/GENIE2ART.h" 59 #include "nurandom/RandomUtils/NuRandomService.h" 65 #include "CLHEP/Random/RandFlat.h" 110 string sname =
"genie::EventGenerator";
112 string sconfig =
"NNBarOsc";
114 evgb::SetEventGeneratorListAndTune(
"Default",
"Default");
120 throw cet::exception(
"NeutronOsc") <<
"Couldn't instantiate the neutron-antineutron oscillation generator";
122 int fDecayMode =
p.get<
int>(
"DecayMode");
125 produces< std::vector<simb::MCTruth> >();
126 produces< sumdata::RunData, art::InRun >();
139 event->AttachSummary(interaction);
150 <<
"Generated event: " << *
event;
152 std::unique_ptr< std::vector<simb::MCTruth> > truthcol(
new std::vector<simb::MCTruth>);
164 for (
size_t i = 0; i<geo->
NTPC(); ++i){
166 if (minx>tpc.
MinX()) minx = tpc.
MinX();
167 if (maxx<tpc.
MaxX()) maxx = tpc.
MaxX();
168 if (miny>tpc.
MinY()) miny = tpc.
MinY();
169 if (maxy<tpc.
MaxY()) maxy = tpc.
MaxY();
170 if (minz>tpc.
MinZ()) minz = tpc.
MinZ();
171 if (maxz<tpc.
MaxZ()) maxz = tpc.
MaxZ();
175 double X0 =
flatDist.fire( minx, maxx );
176 double Y0 =
flatDist.fire( miny, maxy );
177 double Z0 =
flatDist.fire( minz, maxz );
179 TIter partitr(
event);
187 while( (part = dynamic_cast<genie::GHepParticle *>(partitr.Next())) ){
196 TLorentzVector
pos(X0, Y0, Z0, 0);
197 TLorentzVector mom(part->
Px(), part->
Py(), part->
Pz(), part->
E());
198 tpart.AddTrajectoryPoint(pos,mom);
202 tpart.SetPolarization(polz);
209 truthcol->push_back(truth);
230 if (pdg_string.size() != 10) {
231 std::cout <<
"Expecting PDG code to be a 10-digit integer; instead, it's the following: " << pdg_string <<
std::endl;
236 int n_nucleons = std::stoi(pdg_string.substr(6,3)) - 1;
237 int n_protons = std::stoi(pdg_string.substr(3,3));
240 double proton_frac = ((double)n_protons) / ((double)n_nucleons);
241 double neutron_frac = 1 - proton_frac;
244 const int n_modes = 16;
245 double br [n_modes] = { 0.010, 0.080, 0.100, 0.220,
246 0.360, 0.160, 0.070, 0.020,
247 0.015, 0.065, 0.110, 0.280,
248 0.070, 0.240, 0.100, 0.100 };
250 for (
int i = 0; i < n_modes; i++) {
252 br[i] *= proton_frac;
254 br[i] *= neutron_frac;
261 double threshold = 0;
262 for (
int i = 0; i < n_modes; i++) {
272 std::cout <<
"Random selection of final state failed!" <<
std::endl;
void RandGen(long int seed)
NeutronOsc(fhicl::ParameterSet const &p)
void beginRun(art::Run &run) override
virtual void ProcessEventRecord(GHepRecord *event_rec) const =0
double E(void) const
Get energy.
void SetOrigin(simb::Origin_t origin)
Defines the EventRecordVisitorI interface. Concrete implementations of this interface use the 'Visito...
EDProducer(fhicl::ParameterSet const &pset)
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.
double Mass(void) const
Mass that corresponds to the PDG code.
int SelectAnnihilationMode(int pdg_code)
double Pz(void) const
Get Pz.
GHepStatus_t Status(void) const
art framework interface to geometry description
double Px(void) const
Get Px.
int FirstMother(void) const
Summary information for an interaction.
#define DEFINE_ART_MODULE(klass)
std::string DetectorName() const
Returns a string with the name of the detector, as configured.
enum genie::ENNBarOscMode NNBarOscMode_t
const Algorithm * GetAlgorithm(const AlgId &algid)
double MinZ() const
Returns the world z coordinate of the start of the box.
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
bool PolzIsSet(void) const
void produce(art::Event &e) override
double MaxY() const
Returns the world y coordinate of the end of the box.
const genie::EventRecordVisitorI * mcgen
unsigned int NTPC(unsigned int cstat=0) const
Returns the total number of TPCs in the specified cryostat.
void GetPolarization(TVector3 &polz)
Generated Event Record. It is a GHepRecord object that can accept / be visited by EventRecordVisitorI...
void Add(simb::MCParticle const &part)
static PDGLibrary * Instance(void)
static AlgFactory * Instance()
genie::NNBarOscMode_t gOptDecayMode
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.
The GENIE Algorithm Factory.
Event generator information.
LArSoft geometry interface.
double MinY() const
Returns the world y coordinate of the start of the box.
Event Generation using GENIE, cosmics or single particles.
STDHEP-like event record entry that can fit a particle or a nucleus.
std::string to_string(ModuleType const mt)
cet::coded_exception< error, detail::translate > exception
QTextStream & endl(QTextStream &s)
Event finding and building.
static Interaction * NOsc(int tgt, int annihilation_mode=-1)
NeutronOsc & operator=(NeutronOsc const &)=delete
double Py(void) const
Get Py.