GENIEGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions | Variables
gNucleonDecayEvGen.cxx File Reference
#include <cassert>
#include <cstdlib>
#include <string>
#include <vector>
#include <sstream>
#include <TSystem.h>
#include "Framework/Algorithm/AlgFactory.h"
#include "Framework/EventGen/EventRecord.h"
#include "Framework/EventGen/EventGeneratorI.h"
#include "Framework/EventGen/EventRecordVisitorI.h"
#include "Framework/EventGen/GMCJMonitor.h"
#include "Framework/Messenger/Messenger.h"
#include "Framework/Ntuple/NtpWriter.h"
#include "Physics/NucleonDecay/NucleonDecayMode.h"
#include "Physics/NucleonDecay/NucleonDecayUtils.h"
#include "Framework/Numerical/RandomGen.h"
#include "Framework/ParticleData/PDGCodes.h"
#include "Framework/ParticleData/PDGUtils.h"
#include "Framework/ParticleData/PDGLibrary.h"
#include "Framework/Utils/StringUtils.h"
#include "Framework/Utils/UnitUtils.h"
#include "Framework/Utils/PrintUtils.h"
#include "Framework/Utils/AppInit.h"
#include "Framework/Utils/RunOpt.h"
#include "Framework/Utils/CmdLnArgParser.h"
Include dependency graph for gNucleonDecayEvGen.cxx:

Go to the source code of this file.

Functions

void GetCommandLineArgs (int argc, char **argv)
 
void PrintSyntax (void)
 
int SelectInitState (void)
 
const EventRecordVisitorINucleonDecayGenerator (void)
 
int main (int argc, char **argv)
 

Variables

string kDefOptGeomLUnits = "mm"
 
string kDefOptGeomDUnits = "g_cm3"
 
NtpMCFormat_t kDefOptNtpFormat = kNFGHEP
 
string kDefOptEvFilePrefix = "gntp"
 
Long_t gOptRunNu = 1000
 
int gOptNev = 10
 
NucleonDecayMode_t gOptDecayMode = kNDNull
 
int gOptDecayedNucleon = kNDNull
 
string gOptEvFilePrefix = kDefOptEvFilePrefix
 
bool gOptUsingRootGeom = false
 
map< int, double > gOptTgtMix
 
string gOptRootGeom
 
string gOptRootGeomTopVol = ""
 
double gOptGeomLUnits = 0
 
double gOptGeomDUnits = 0
 
long int gOptRanSeed = -1
 

Function Documentation

void GetCommandLineArgs ( int  argc,
char **  argv 
)
int main ( int  argc,
char **  argv 
)

Definition at line 176 of file gNucleonDecayEvGen.cxx.

References genie::NtpWriter::AddEventRecord(), genie::NtpWriter::CustomizeFilenamePrefix(), genie::utils::nucleon_decay::DecayedNucleonPdgCode(), GetCommandLineArgs(), gOptDecayedNucleon, gOptDecayMode, gOptEvFilePrefix, gOptNev, gOptRanSeed, gOptRunNu, genie::NtpWriter::Initialize(), genie::RunOpt::Instance(), kDefOptNtpFormat, LOG, genie::utils::app_init::MesgThresholds(), genie::Interaction::NDecay(), NucleonDecayGenerator(), pINFO, pNOTICE, genie::EventRecordVisitorI::ProcessEventRecord(), genie::utils::app_init::RandGen(), genie::NtpWriter::Save(), SelectInitState(), genie::GHepRecord::SetPrintLevel(), genie::GMCJMonitor::SetRefreshRate(), and genie::GMCJMonitor::Update().

177 {
178  // Parse command line arguments
179  GetCommandLineArgs(argc,argv);
180 
181  // Init messenger and random number seed
182  utils::app_init::MesgThresholds(RunOpt::Instance()->MesgThresholdFiles());
184 
185  // Initialize an Ntuple Writer to save GHEP records into a TTree
187  ntpw.CustomizeFilenamePrefix(gOptEvFilePrefix);
188  ntpw.Initialize();
189 
190  // Create a MC job monitor for a periodically updated status file
191  GMCJMonitor mcjmonitor(gOptRunNu);
192  mcjmonitor.SetRefreshRate(RunOpt::Instance()->MCJobStatusRefreshRate());
193 
194  // Set GHEP print level
195  GHepRecord::SetPrintLevel(RunOpt::Instance()->EventRecordPrintLevel());
196 
197  // Get the nucleon decay generator
198  const EventRecordVisitorI * mcgen = NucleonDecayGenerator();
199 
200  // Event loop
201  int ievent = 0;
202  int dpdg = 0;
203  if (gOptDecayedNucleon > 0) {
204  dpdg = gOptDecayedNucleon;
205  } else {
207  }
208 
209  while (1)
210  {
211  if(ievent == gOptNev) break;
212 
213  LOG("gevgen_ndcy", pNOTICE)
214  << " *** Generating event............ " << ievent;
215 
216  EventRecord * event = new EventRecord;
217  int target = SelectInitState();
218  int decay = (int)gOptDecayMode;
219  Interaction * interaction = Interaction::NDecay(target,decay,dpdg);
220  event->AttachSummary(interaction);
221 
222  // Simulate decay
223  mcgen->ProcessEventRecord(event);
224 
225  LOG("gevgen_ndcy", pINFO)
226  << "Generated event: " << *event;
227 
228  // Add event at the output ntuple, refresh the mc job monitor & clean-up
229  ntpw.AddEventRecord(ievent, event);
230  mcjmonitor.Update(ievent,event);
231  delete event;
232 
233  ievent++;
234  } // event loop
235 
236  // Save the generated event tree & close the output file
237  ntpw.Save();
238 
239  LOG("gevgen_ndcy", pNOTICE) << "Done!";
240 
241  return 0;
242 }
const EventRecordVisitorI * NucleonDecayGenerator(void)
void RandGen(long int seed)
Definition: AppInit.cxx:30
HNLDecayMode_t gOptDecayMode
string gOptEvFilePrefix
Definition: gAtmoEvGen.cxx:310
Defines the EventRecordVisitorI interface. Concrete implementations of this interface use the &#39;Visito...
int gOptDecayedNucleon
Summary information for an interaction.
Definition: Interaction.h:56
Simple class to create &amp; update MC job status files and env. vars. This is used to be able to keep tr...
Definition: GMCJMonitor.h:31
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
virtual void ProcessEventRecord(GHepRecord *event_rec) const =0
int gOptNev
Definition: gAtmoEvGen.cxx:305
#define pINFO
Definition: Messenger.h:62
Long_t gOptRunNu
Definition: gAtmoEvGen.cxx:295
Generated Event Record. It is a GHepRecord object that can accept / be visited by EventRecordVisitorI...
Definition: EventRecord.h:37
A utility class to facilitate creating the GENIE MC Ntuple from the output GENIE GHEP event records...
Definition: NtpWriter.h:39
NtpMCFormat_t kDefOptNtpFormat
Definition: gAtmoEvGen.cxx:319
void MesgThresholds(string inpfile)
Definition: AppInit.cxx:99
int SelectInitState(void)
#define pNOTICE
Definition: Messenger.h:61
void GetCommandLineArgs(int argc, char **argv)
Definition: gAtmoEvGen.cxx:563
int DecayedNucleonPdgCode(NucleonDecayMode_t ndm)
long int gOptRanSeed
Definition: gAtmoEvGen.cxx:312
const EventRecordVisitorI * NucleonDecayGenerator ( void  )

Definition at line 298 of file gNucleonDecayEvGen.cxx.

References genie::gAbortingInErr, genie::AlgFactory::GetAlgorithm(), genie::AlgFactory::Instance(), LOG, and pFATAL.

Referenced by main().

299 {
300  string sname = "genie::EventGenerator";
301  string sconfig = "NucleonDecay";
302  AlgFactory * algf = AlgFactory::Instance();
303  const EventRecordVisitorI * mcgen =
304  dynamic_cast<const EventRecordVisitorI *> (algf->GetAlgorithm(sname,sconfig));
305  if(!mcgen) {
306  LOG("gevgen_ndcy", pFATAL) << "Couldn't instantiate the nucleon decay generator";
307  gAbortingInErr = true;
308  exit(1);
309  }
310  return mcgen;
311 }
Defines the EventRecordVisitorI interface. Concrete implementations of this interface use the &#39;Visito...
#define pFATAL
Definition: Messenger.h:56
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
const Algorithm * GetAlgorithm(const AlgId &algid)
Definition: AlgFactory.cxx:75
The GENIE Algorithm Factory.
Definition: AlgFactory.h:39
bool gAbortingInErr
Definition: Messenger.cxx:34
void PrintSyntax ( void  )
int SelectInitState ( void  )

Variable Documentation

int gOptDecayedNucleon = kNDNull

Definition at line 165 of file gNucleonDecayEvGen.cxx.

Referenced by main().

NucleonDecayMode_t gOptDecayMode = kNDNull

Definition at line 164 of file gNucleonDecayEvGen.cxx.

string gOptEvFilePrefix = kDefOptEvFilePrefix

Definition at line 166 of file gNucleonDecayEvGen.cxx.

double gOptGeomDUnits = 0

Definition at line 172 of file gNucleonDecayEvGen.cxx.

double gOptGeomLUnits = 0

Definition at line 171 of file gNucleonDecayEvGen.cxx.

int gOptNev = 10

Definition at line 163 of file gNucleonDecayEvGen.cxx.

long int gOptRanSeed = -1

Definition at line 173 of file gNucleonDecayEvGen.cxx.

string gOptRootGeom

Definition at line 169 of file gNucleonDecayEvGen.cxx.

string gOptRootGeomTopVol = ""

Definition at line 170 of file gNucleonDecayEvGen.cxx.

Long_t gOptRunNu = 1000

Definition at line 162 of file gNucleonDecayEvGen.cxx.

map<int,double> gOptTgtMix

Definition at line 168 of file gNucleonDecayEvGen.cxx.

bool gOptUsingRootGeom = false

Definition at line 167 of file gNucleonDecayEvGen.cxx.

string kDefOptEvFilePrefix = "gntp"

Definition at line 159 of file gNucleonDecayEvGen.cxx.

string kDefOptGeomDUnits = "g_cm3"

Definition at line 157 of file gNucleonDecayEvGen.cxx.

string kDefOptGeomLUnits = "mm"

Definition at line 156 of file gNucleonDecayEvGen.cxx.

NtpMCFormat_t kDefOptNtpFormat = kNFGHEP

Definition at line 158 of file gNucleonDecayEvGen.cxx.