All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
evgen::NeutronOsc Class Reference
Inheritance diagram for evgen::NeutronOsc:

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
 

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.

Constructor & Destructor Documentation

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

Definition at line 103 of file NeutronOsc_module.cc.

104  : art::EDProducer{p}
105  // create a default random engine; obtain the random seed from NuRandomService,
106  // unless overridden in configuration with key "Seed"
107  , flatDist{art::ServiceHandle<rndm::NuRandomService>{}->createEngine(*this, p, "Seed")}
pdgs p
Definition: selectors.fcl:22
CLHEP::RandFlat flatDist
evgen::NeutronOsc::NeutronOsc ( NeutronOsc const &  )
delete
evgen::NeutronOsc::NeutronOsc ( NeutronOsc &&  )
delete

Member Function Documentation

void evgen::NeutronOsc::beginRun ( art::Run &  run)
override

Definition at line 217 of file NeutronOsc_module.cc.

218 {
219  art::ServiceHandle<geo::Geometry const> geo;
220  run.put(std::make_unique<sumdata::RunData>(geo->DetectorName()));
221 }
NeutronOsc& evgen::NeutronOsc::operator= ( NeutronOsc const &  )
delete
NeutronOsc& evgen::NeutronOsc::operator= ( NeutronOsc &&  )
delete
void evgen::NeutronOsc::produce ( art::Event &  e)
override

Definition at line 133 of file NeutronOsc_module.cc.

134 {
135  // Implementation of required member function here.
136  genie::EventRecord * event = new genie::EventRecord;
137  int target = 1000180400; //Only use argon target
138  int decay = SelectAnnihilationMode(target);
139  genie::Interaction * interaction = genie::Interaction::NOsc(target,decay);
140  event->AttachSummary(interaction);
141 
142  // Simulate decay
143  mcgen->ProcessEventRecord(event);
144 
145 // genie::Interaction *inter = event->Summary();
146 // const genie::InitialState &initState = inter->InitState();
147 // std::cout<<"initState = "<<initState.AsString()<<std::endl;
148 // const genie::ProcessInfo &procInfo = inter->ProcInfo();
149 // std::cout<<"procInfo = "<<procInfo.AsString()<<std::endl;
150  MF_LOG_DEBUG("NeutronOsc")
151  << "Generated event: " << *event;
152 
153  std::unique_ptr< std::vector<simb::MCTruth> > truthcol(new std::vector<simb::MCTruth>);
154  simb::MCTruth truth;
155 
156  art::ServiceHandle<geo::Geometry const> geo;
157 
158  // Find boundary of active volume
159  double minx = 1e9;
160  double maxx = -1e9;
161  double miny = 1e9;
162  double maxy = -1e9;
163  double minz = 1e9;
164  double maxz = -1e9;
165  for (size_t i = 0; i<geo->NTPC(); ++i){
166  const geo::TPCGeo &tpc = geo->TPC(i);
167  if (minx>tpc.MinX()) minx = tpc.MinX();
168  if (maxx<tpc.MaxX()) maxx = tpc.MaxX();
169  if (miny>tpc.MinY()) miny = tpc.MinY();
170  if (maxy<tpc.MaxY()) maxy = tpc.MaxY();
171  if (minz>tpc.MinZ()) minz = tpc.MinZ();
172  if (maxz<tpc.MaxZ()) maxz = tpc.MaxZ();
173  }
174 
175  // Assign vertice position
176  double X0 = flatDist.fire( minx, maxx );
177  double Y0 = flatDist.fire( miny, maxy );
178  double Z0 = flatDist.fire( minz, maxz );
179 
180  TIter partitr(event);
181  genie::GHepParticle *part = 0;
182  // GHepParticles return units of GeV/c for p. the V_i are all in fermis
183  // and are relative to the center of the struck nucleus.
184  // add the vertex X/Y/Z to the V_i for status codes 0 and 1
185  int trackid = 0;
186  std::string primary("primary");
187 
188  while( (part = dynamic_cast<genie::GHepParticle *>(partitr.Next())) ){
189 
190  simb::MCParticle tpart(trackid,
191  part->Pdg(),
192  primary,
193  part->FirstMother(),
194  part->Mass(),
195  part->Status());
196 
197  TLorentzVector pos(X0, Y0, Z0, 0);
198  TLorentzVector mom(part->Px(), part->Py(), part->Pz(), part->E());
199  tpart.AddTrajectoryPoint(pos,mom);
200  if(part->PolzIsSet()) {
201  TVector3 polz;
202  part->GetPolarization(polz);
203  tpart.SetPolarization(polz);
204  }
205  truth.Add(tpart);
206 
207  ++trackid;
208  }// end loop to convert GHepParticles to MCParticles
209  truth.SetOrigin(simb::kUnknown);
210  truthcol->push_back(truth);
211  //FillHistograms(truth);
212  e.put(std::move(truthcol));
213 
214  delete event;
215 }
process_name opdaq physics producers generator physics producers generator physics producers generator Z0
Definition: gen_protons.fcl:45
double MinX() const
Returns the world x coordinate of the start of the box.
Definition: BoxBoundedGeo.h:88
Geometry information for a single TPC.
Definition: TPCGeo.h:38
double MaxX() const
Returns the world x coordinate of the end of the box.
Definition: BoxBoundedGeo.h:91
process_name opdaq physics producers generator physics producers generator Y0
Definition: gen_protons.fcl:45
int SelectAnnihilationMode(int pdg_code)
standard_singlep gaussian distribution X0
Definition: multigen.fcl:8
double MinZ() const
Returns the world z coordinate of the start of the box.
double MaxY() const
Returns the world y coordinate of the end of the box.
const genie::EventRecordVisitorI * mcgen
double MaxZ() const
Returns the world z coordinate of the end of the box.
do i e
double MinY() const
Returns the world y coordinate of the start of the box.
CLHEP::RandFlat flatDist
int evgen::NeutronOsc::SelectAnnihilationMode ( int  pdg_code)
private

Definition at line 224 of file NeutronOsc_module.cc.

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

Member Data Documentation

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

Definition at line 98 of file NeutronOsc_module.cc.

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

Definition at line 97 of file NeutronOsc_module.cc.

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

Definition at line 96 of file NeutronOsc_module.cc.


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