GENIEGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions | Variables
gBeamHNLParticleGun.cxx File Reference
#include <cassert>
#include <cstdlib>
#include <string>
#include <vector>
#include <sstream>
#include <TSystem.h>
#include "Framework/Algorithm/AlgFactory.h"
#include "Framework/Conventions/Controls.h"
#include "Framework/EventGen/EventRecord.h"
#include "Framework/EventGen/EventGeneratorI.h"
#include "Framework/EventGen/EventRecordVisitorI.h"
#include "Framework/EventGen/GMCJMonitor.h"
#include "Framework/GHEP/GHepParticle.h"
#include "Framework/Messenger/Messenger.h"
#include "Framework/Ntuple/NtpWriter.h"
#include "Physics/BeamHNL/HNLDecayMode.h"
#include "Physics/BeamHNL/HNLDecayUtils.h"
#include "Physics/BeamHNL/HNLVertexGenerator.h"
#include "Physics/BeamHNL/HNLFluxCreator.h"
#include "Physics/BeamHNL/HNLDecayer.h"
#include "Physics/BeamHNL/SimpleHNL.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 gBeamHNLParticleGun.cxx:

Go to the source code of this file.

Functions

void GetCommandLineArgs (int argc, char **argv)
 
void PrintSyntax (void)
 
int SelectDecayMode (std::vector< HNLDecayMode_t > *intChannels, SimpleHNL sh)
 
const EventRecordVisitorIHNLGenerator (void)
 
TLorentzVector * GenerateOriginPosition (GHepRecord *event)
 
TLorentzVector * GenerateOriginMomentum (GHepRecord *event)
 
TLorentzVector GeneratePosition (GHepRecord *event)
 
int main (int argc, char **argv)
 

Variables

string kDefOptGeomLUnits = "mm"
 
string kDefOptGeomDUnits = "g_cm3"
 
NtpMCFormat_t kDefOptNtpFormat = kNFGHEP
 
string kDefOptEvFilePrefix = "gntp"
 
string kDefOptSName = "genie::EventGenerator"
 
string kDefOptSConfig = "BeamHNL"
 
string kDefOptSTune = "GHNL20_00a_00_000"
 
Long_t gOptRunNu = 1000
 
int gOptNev = 10
 
double gOptEnergyHNL = -1
 
double gOptMassHNL = -1
 
double gOptECoupling = -1
 
double gOptMCoupling = -1
 
double gOptTCoupling = -1
 
bool gOptIsMajorana = false
 
int gOptHNLKind = -1
 
HNLDecayMode_t gOptDecayMode = kHNLDcyNull
 
std::vector< HNLDecayMode_tgOptIntChannels
 
string gOptEvFilePrefix = kDefOptEvFilePrefix
 
bool gOptUsingRootGeom = false
 
string gOptRootGeom
 
string gOptRootGeomTopVol = ""
 
double gOptGeomLUnits = 0
 
long int gOptRanSeed = -1
 
double fdx = 0
 
double fdy = 0
 
double fdz = 0
 
double fox = 0
 
double foy = 0
 
double foz = 0
 
double NTP_IS_E = 0.
 
double NTP_IS_PX = 0.
 
double NTP_IS_PY = 0.
 
double NTP_IS_PZ = 0.
 
double NTP_FS0_E = 0.
 
double NTP_FS0_PX = 0.
 
double NTP_FS0_PY = 0.
 
double NTP_FS0_PZ = 0.
 
double NTP_FS1_E = 0.
 
double NTP_FS1_PX = 0.
 
double NTP_FS1_PY = 0.
 
double NTP_FS1_PZ = 0.
 
double NTP_FS2_E = 0.
 
double NTP_FS2_PX = 0.
 
double NTP_FS2_PY = 0.
 
double NTP_FS2_PZ = 0.
 
int NTP_FS0_PDG = 0
 
int NTP_FS1_PDG = 0
 
int NTP_FS2_PDG = 0
 
double CoMLifetime = -1.0
 
double evProdVtx [3] = {0.0, 0.0, 0.0}
 
double evWeight = 1.0
 

Function Documentation

TLorentzVector * GenerateOriginMomentum ( GHepRecord event)

Definition at line 507 of file gBeamHNLParticleGun.cxx.

References genie::AlgFactory::GetAlgorithm(), genie::hnl::Decayer::GetPGunDeviation(), genie::hnl::Decayer::GetPGunDirection(), gOptEnergyHNL, gOptMassHNL, genie::Interaction::InitStatePtr(), genie::RandomGen::Instance(), genie::AlgFactory::Instance(), genie::constants::kPi, LOG, genie::utils::print::P4AsString(), pDEBUG, genie::RandomGen::RndGen(), and genie::InitialState::SetProbeP4().

Referenced by main().

508 {
509  double E = gOptEnergyHNL;
510  double M = gOptMassHNL;
511  double pMag = std::sqrt( E*E - M*M );
512 
513  const Algorithm * algHNLGen = AlgFactory::Instance()->GetAlgorithm("genie::hnl::Decayer", "Default");
514  const Decayer * hnlgen = dynamic_cast< const Decayer * >( algHNLGen );
515 
516  // first map directional cosines to unit sphere
517  /*
518  double cx = utils::hnl::GetCfgDouble( "HNL", "ParticleGun", "PG-cx" );
519  double cy = utils::hnl::GetCfgDouble( "HNL", "ParticleGun", "PG-cy" );
520  double cz = utils::hnl::GetCfgDouble( "HNL", "ParticleGun", "PG-cz" );
521  */
522  std::vector< double > PGDirection = hnlgen->GetPGunDirection();
523  double cx = PGDirection.at(0), cy = PGDirection.at(1), cz = PGDirection.at(2);
524  double c2 = std::sqrt( cx*cx + cy*cy + cz*cz );
525  assert( c2 > 0.0 );
526 
527  cx *= 1.0 / c2; cy *= 1.0 / c2; cz *= 1.0 / c2;
528 
529  double theta = TMath::ACos( cz / c2 );
530  double phi = ( TMath::Sin( theta ) != 0.0 ) ? TMath::ACos( cx / ( c2 * TMath::Sin( theta ) ) ) : 0.0;
531 
532  // apply uniform random deviation
533  std::vector< double > PGunDeviation = hnlgen->GetPGunDeviation();
534  /*
535  double dthetaDeg = utils::hnl::GetCfgDouble( "HNL", "ParticleGun", "PG-DTheta" );
536  double dphiDeg = utils::hnl::GetCfgDouble( "HNL", "ParticleGun", "PG-DPhi" );
537  */
538  double dthetaDeg = PGunDeviation.at(0), dphiDeg = PGunDeviation.at(1);
539  double dThetaMax = dthetaDeg * constants::kPi / 180.0;
540  double dPhiMax = dphiDeg * constants::kPi / 180.0;
541 
542  RandomGen * rng = RandomGen::Instance();
543  double dTheta = rng->RndGen().Uniform( -dThetaMax, dThetaMax );
544  double dPhi = rng->RndGen().Uniform( -dPhiMax, dPhiMax );
545 
546  std::ostringstream asts;
547  asts
548  << "Output details for the momentum:"
549  << "\nDirectional cosines: ( " << cx << ", " << cy << ", " << cz << " )"
550  << "\nMapped to ( " << theta * 180.0 / constants::kPi
551  << ", " << phi * 180.0 / constants::kPi << " ) [deg] on unit sphere"
552  << "\nApplied deviation: dTheta = " << dTheta * 180.0 / constants::kPi
553  << ", dPhi = " << dPhi * 180.0 / constants::kPi << " [deg]";
554 
555  // make momentum
556  theta += dTheta; phi += dPhi;
557  TLorentzVector * p4HNL = new TLorentzVector();
558  p4HNL->SetPxPyPzE( pMag * TMath::Sin( theta ) * TMath::Cos( phi ),
559  pMag * TMath::Sin( theta ) * TMath::Sin( phi ),
560  pMag * TMath::Cos( theta ), E );
561 
562  asts << "\nMomentum = " << utils::print::P4AsString( p4HNL );
563 
564  Interaction * interaction = event->Summary();
565  interaction->InitStatePtr()->SetProbeP4( *p4HNL );
566 
567  LOG( "gevgen_pghnl", pDEBUG ) << asts.str();
568 
569  //delete rng;
570  return p4HNL;
571 }
Heavy Neutral Lepton final-state product generator.
Definition: HNLDecayer.h:41
void SetProbeP4(const TLorentzVector &P4)
string P4AsString(const TLorentzVector *p)
Definition: PrintUtils.cxx:27
Algorithm abstract base class.
Definition: Algorithm.h:54
A singleton holding random number generator classes. All random number generation in GENIE should tak...
Definition: RandomGen.h:29
Summary information for an interaction.
Definition: Interaction.h:56
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
double gOptEnergyHNL
std::vector< double > GetPGunDirection() const
Definition: HNLDecayer.cxx:755
std::vector< double > GetPGunDeviation() const
Definition: HNLDecayer.cxx:762
TRandom3 & RndGen(void) const
rnd number generator for generic usage
Definition: RandomGen.h:80
InitialState * InitStatePtr(void) const
Definition: Interaction.h:74
double gOptMassHNL
#define pDEBUG
Definition: Messenger.h:63
TLorentzVector * GenerateOriginPosition ( GHepRecord event)

Definition at line 573 of file gBeamHNLParticleGun.cxx.

References genie::AlgFactory::GetAlgorithm(), genie::hnl::Decayer::GetPGunDOrigin(), genie::hnl::Decayer::GetPGunOrigin(), genie::RandomGen::Instance(), genie::AlgFactory::Instance(), and genie::RandomGen::RndGen().

Referenced by main().

574 {
575  const Algorithm * algHNLGen = AlgFactory::Instance()->GetAlgorithm("genie::hnl::Decayer", "Default");
576  const Decayer * hnlgen = dynamic_cast< const Decayer * >( algHNLGen );
577 
578  // get centre of box from config
579  std::vector< double > PGOrigin = hnlgen->GetPGunOrigin();
580  /*
581  double ox = utils::hnl::GetCfgDouble( "HNL", "ParticleGun", "PG-OriginX" );
582  double oy = utils::hnl::GetCfgDouble( "HNL", "ParticleGun", "PG-OriginY" );
583  double oz = utils::hnl::GetCfgDouble( "HNL", "ParticleGun", "PG-OriginZ" );
584  */
585  double ox = PGOrigin.at(0), oy = PGOrigin.at(1), oz = PGOrigin.at(2);
586 
587  // allow uniform deviation
588  std::vector< double > PGDOrigin = hnlgen->GetPGunDOrigin();
589  /*
590  double Dxmax = utils::hnl::GetCfgDouble( "HNL", "ParticleGun", "PG-OriginDX" );
591  double Dymax = utils::hnl::GetCfgDouble( "HNL", "ParticleGun", "PG-OriginDY" );
592  double Dzmax = utils::hnl::GetCfgDouble( "HNL", "ParticleGun", "PG-OriginDZ" );
593  */
594  double Dxmax = PGDOrigin.at(0), Dymax = PGDOrigin.at(1), Dzmax = PGDOrigin.at(2);
595 
596  RandomGen * rng = RandomGen::Instance();
597  double dx = rng->RndGen().Uniform( -Dxmax, Dxmax );
598  double dy = rng->RndGen().Uniform( -Dymax, Dymax );
599  double dz = rng->RndGen().Uniform( -Dzmax, Dzmax );
600 
601  // make position
602  ox += dx; oy += dy; oz += dz;
603  TLorentzVector * x4HNL = new TLorentzVector();
604  x4HNL->SetXYZT( ox, oy, oz, 0.0 );
605 
606  event->SetVertex( *x4HNL );
607  //delete rng;
608  return x4HNL;
609 }
Heavy Neutral Lepton final-state product generator.
Definition: HNLDecayer.h:41
Algorithm abstract base class.
Definition: Algorithm.h:54
A singleton holding random number generator classes. All random number generation in GENIE should tak...
Definition: RandomGen.h:29
std::vector< double > GetPGunOrigin() const
Definition: HNLDecayer.cxx:736
std::vector< double > GetPGunDOrigin() const
Definition: HNLDecayer.cxx:743
TRandom3 & RndGen(void) const
rnd number generator for generic usage
Definition: RandomGen.h:80
TLorentzVector GeneratePosition ( GHepRecord event)
void GetCommandLineArgs ( int  argc,
char **  argv 
)
const EventRecordVisitorI* HNLGenerator ( void  )
int main ( int  argc,
char **  argv 
)

Definition at line 194 of file gBeamHNLParticleGun.cxx.

References genie::hnl::selector::__attribute__(), genie::NtpWriter::AddEventRecord(), genie::utils::hnl::AsString(), CoMLifetime, genie::NtpWriter::CustomizeFilenamePrefix(), genie::NtpWriter::EventTree(), evWeight, GenerateOriginMomentum(), GenerateOriginPosition(), GeneratePosition(), genie::AlgFactory::GetAlgorithm(), genie::hnl::SimpleHNL::GetCoMLifetime(), GetCommandLineArgs(), genie::hnl::Decayer::GetHNLCouplings(), genie::hnl::Decayer::GetHNLInterestingChannels(), genie::hnl::Decayer::GetHNLLifetime(), genie::hnl::Decayer::GetHNLMass(), genie::hnl::Decayer::GetPGunEnergy(), genie::hnl::SimpleHNL::GetValidChannels(), gOptDecayMode, gOptECoupling, gOptEnergyHNL, gOptEvFilePrefix, gOptIntChannels, gOptIsMajorana, gOptMassHNL, gOptMCoupling, gOptNev, gOptRanSeed, gOptRootGeom, gOptRunNu, gOptTCoupling, gOptUsingRootGeom, genie::Interaction::HNL(), HNLGenerator(), genie::NtpWriter::Initialize(), genie::Interaction::InitStatePtr(), genie::RandomGen::Instance(), genie::RunOpt::Instance(), genie::AlgFactory::Instance(), genie::hnl::Decayer::IsHNLMajorana(), kDefOptNtpFormat, kDefOptSConfig, kDefOptSName, genie::hnl::kHNLDcyNull, genie::kIStInitialState, genie::kPdgHNL, genie::kPdgKP, LOG, genie::utils::app_init::MesgThresholds(), NTP_FS0_E, NTP_FS0_PDG, NTP_FS0_PX, NTP_FS0_PY, NTP_FS0_PZ, NTP_FS1_E, NTP_FS1_PDG, NTP_FS1_PX, NTP_FS1_PY, NTP_FS1_PZ, NTP_FS2_E, NTP_FS2_PDG, NTP_FS2_PX, NTP_FS2_PY, NTP_FS2_PZ, NTP_IS_E, NTP_IS_PX, NTP_IS_PY, NTP_IS_PZ, pDEBUG, pFATAL, pINFO, pNOTICE, genie::hnl::Decayer::ProcessEventRecord(), genie::hnl::VertexGenerator::ProcessEventRecord(), genie::utils::app_init::RandGen(), genie::NtpWriter::Save(), SelectDecayMode(), genie::hnl::VertexGenerator::SetGeomFile(), genie::GHepRecord::SetPrintLevel(), genie::GHepRecord::SetProbability(), genie::InitialState::SetProbeP4(), genie::GMCJMonitor::SetRefreshRate(), and genie::GMCJMonitor::Update().

195 {
196  // suppress ROOT Info messages
197  gErrorIgnoreLevel = kWarning;
198 
199  // Parse command line arguments
200  GetCommandLineArgs(argc,argv);
201 
202  // Init messenger and random number seed
203  utils::app_init::MesgThresholds(RunOpt::Instance()->MesgThresholdFiles());
205 
206  __attribute__((unused)) RandomGen * rnd = RandomGen::Instance();
207 
208  // Get the HNL generator first to load config
209  // config loaded upon instantiation of HNLGenerator algorithm
210  // ==> Decayer::LoadConfig()
211  __attribute__((unused)) const EventRecordVisitorI * mcgen = HNLGenerator();
212  const Algorithm * algHNLGen = AlgFactory::Instance()->GetAlgorithm("genie::hnl::Decayer", "Default");
213  const Algorithm * algVtxGen = AlgFactory::Instance()->GetAlgorithm("genie::hnl::VertexGenerator", "Default");
214 
215  const Decayer * hnlgen = dynamic_cast< const Decayer * >( algHNLGen );
216  const VertexGenerator * vtxGen = dynamic_cast< const VertexGenerator * >( algVtxGen );
217 
218  bool geom_is_accessible = ! (gSystem->AccessPathName(gOptRootGeom.c_str()));
219  if (!geom_is_accessible) {
220  LOG("gevgen_pghnl", pFATAL)
221  << "The specified ROOT geometry doesn't exist! Initialization failed!";
222  exit(1);
223  }
224  vtxGen->SetGeomFile( gOptRootGeom );
225 
226  if( !gOptRootGeoManager ) gOptRootGeoManager = TGeoManager::Import(gOptRootGeom.c_str());
227 
228  TGeoVolume * top_volume = gOptRootGeoManager->GetTopVolume();
229  assert( top_volume );
230  __attribute__((unused)) TGeoShape * ts = top_volume->GetShape();
231 
232  //TGeoBBox * box = (TGeoBBox *)ts;
233 
234  string confString = kDefOptSName + kDefOptSConfig;
235 
236  CoMLifetime = hnlgen->GetHNLLifetime();
237 
238  gOptMassHNL = hnlgen->GetHNLMass();
239  std::vector< double > U4l2s = hnlgen->GetHNLCouplings();
240  gOptECoupling = U4l2s.at(0);
241  gOptMCoupling = U4l2s.at(1);
242  gOptTCoupling = U4l2s.at(2);
243  gOptIsMajorana = hnlgen->IsHNLMajorana();
244 
245  std::string stIntChannels = hnlgen->GetHNLInterestingChannels(); int iChan = -1;
246  if( gOptIntChannels.size() > 0 ) gOptIntChannels.clear();
247  while( stIntChannels.size() > 0 ){ // read channels from right (lowest mass) to left (highest mass)
248  iChan++;
249  HNLDecayMode_t md = static_cast< HNLDecayMode_t >( iChan );
250  std::string tmpSt = stIntChannels.substr( stIntChannels.size()-1, stIntChannels.size() );
251  if( std::strcmp( tmpSt.c_str(), "1" ) == 0 )
252  gOptIntChannels.emplace_back( md );
253 
254  stIntChannels.erase( stIntChannels.end()-1, stIntChannels.end() );
255  }
256 
257  assert( gOptECoupling >= 0.0 && gOptMCoupling >= 0.0 && gOptTCoupling >= 0.0 );
258 
259  // Initialize an Ntuple Writer to save GHEP records into a TTree
261  ntpw.CustomizeFilenamePrefix(gOptEvFilePrefix);
262  ntpw.Initialize();
263 
264  LOG("gevgen_pghnl", pNOTICE)
265  << "Initialised Ntuple Writer";
266 
267  // add another few branches to tree.
268  ntpw.EventTree()->Branch("hnl_mass", &gOptMassHNL, "gOptMassHNL/D");
269  ntpw.EventTree()->Branch("hnl_coup_e", &gOptECoupling, "gOptECoupling/D");
270  ntpw.EventTree()->Branch("hnl_coup_m", &gOptMCoupling, "gOptMCoupling/D");
271  ntpw.EventTree()->Branch("hnl_coup_t", &gOptTCoupling, "gOptTCoupling/D");
272  ntpw.EventTree()->Branch("hnl_ismaj", &gOptIsMajorana, "gOptIsMajorana/I");
273 
274  // let's make HNL-specific FS branches until we get gntpc sorted out
275  ntpw.EventTree()->Branch("hnl_IS_E", &NTP_IS_E, "NTP_IS_E/D");
276  ntpw.EventTree()->Branch("hnl_IS_PX", &NTP_IS_PX, "NTP_IS_PX/D");
277  ntpw.EventTree()->Branch("hnl_IS_PY", &NTP_IS_PY, "NTP_IS_PY/D");
278  ntpw.EventTree()->Branch("hnl_IS_PZ", &NTP_IS_PZ, "NTP_IS_PZ/D");
279  ntpw.EventTree()->Branch("hnl_FS0_PDG", &NTP_FS0_PDG, "NTP_FS0_PDG/I");
280  ntpw.EventTree()->Branch("hnl_FS0_E", &NTP_FS0_E, "NTP_FS0_E/D");
281  ntpw.EventTree()->Branch("hnl_FS0_PX", &NTP_FS0_PX, "NTP_FS0_PX/D");
282  ntpw.EventTree()->Branch("hnl_FS0_PY", &NTP_FS0_PY, "NTP_FS0_PY/D");
283  ntpw.EventTree()->Branch("hnl_FS0_PZ", &NTP_FS0_PZ, "NTP_FS0_PZ/D");
284  ntpw.EventTree()->Branch("hnl_FS1_PDG", &NTP_FS1_PDG, "NTP_FS1_PDG/I");
285  ntpw.EventTree()->Branch("hnl_FS1_E", &NTP_FS1_E, "NTP_FS1_E/D");
286  ntpw.EventTree()->Branch("hnl_FS1_PX", &NTP_FS1_PX, "NTP_FS1_PX/D");
287  ntpw.EventTree()->Branch("hnl_FS1_PY", &NTP_FS1_PY, "NTP_FS1_PY/D");
288  ntpw.EventTree()->Branch("hnl_FS1_PZ", &NTP_FS1_PZ, "NTP_FS1_PZ/D");
289  ntpw.EventTree()->Branch("hnl_FS2_PDG", &NTP_FS2_PDG, "NTP_FS2_PDG/I");
290  ntpw.EventTree()->Branch("hnl_FS2_E", &NTP_FS2_E, "NTP_FS2_E/D");
291  ntpw.EventTree()->Branch("hnl_FS2_PX", &NTP_FS2_PX, "NTP_FS2_PX/D");
292  ntpw.EventTree()->Branch("hnl_FS2_PY", &NTP_FS2_PY, "NTP_FS2_PY/D");
293  ntpw.EventTree()->Branch("hnl_FS2_PZ", &NTP_FS2_PZ, "NTP_FS2_PZ/D");
294 
295  // Create a MC job monitor for a periodically updated status file
296  GMCJMonitor mcjmonitor(gOptRunNu);
297  mcjmonitor.SetRefreshRate(RunOpt::Instance()->MCJobStatusRefreshRate());
298 
299  LOG("gevgen_pghnl", pNOTICE)
300  << "Initialised MC job monitor";
301 
302  // Set GHEP print level
303  GHepRecord::SetPrintLevel(RunOpt::Instance()->EventRecordPrintLevel());
304 
305 #ifdef __CAN_USE_ROOT_GEOM__
306  // Read geometry bounding box - for vertex position generation
307  if( gOptUsingRootGeom ){
308  InitBoundingBox();
309  }
310 #endif // #ifdef __CAN_USE_ROOT_GEOM__
311 
312  // read in energy. This is always constant
313  //gOptEnergyHNL = utils::hnl::GetCfgDouble( "HNL", "ParticleGun", "PG-Energy" );
314  gOptEnergyHNL = hnlgen->GetPGunEnergy();
315  if( gOptEnergyHNL <= gOptMassHNL ){
316  LOG( "gevgen_pghnl", pFATAL )
317  << "\nInsufficient energy " << gOptEnergyHNL << " GeV for HNL of mass " << gOptMassHNL << " GeV. Exiting."
318  << "\nPlease check ${GENIE}/config/CommonHNL.xml sections \"ParamSpace\" and \"ParticleGun\"";
319  exit(1);
320  }
321  assert( gOptEnergyHNL > gOptMassHNL );
322 
323  // Event loop
324  int ievent = 0;
325 
326  while (1)
327  {
328  if( gOptNev >= 10000 ){
329  if( ievent % (gOptNev / 1000 ) == 0 ){
330  int irat = ievent / ( gOptNev / 1000 );
331  std::cerr << 0.1 * irat << " % " << " ( " << ievent
332  << " / " << gOptNev << " ) \r" << std::flush;
333  }
334  } else if( gOptNev >= 100 ){
335  if( ievent % (gOptNev / 10 ) == 0 ){
336  int irat = ievent / ( gOptNev / 10 );
337  std::cerr << 10.0 * irat << " % " << " ( " << ievent
338  << " / " << gOptNev << " ) \r" << std::flush;
339  }
340  }
341 
342  if((ievent) == gOptNev) break;
343 
344  LOG("gevgen_pghnl", pNOTICE)
345  << " *** Generating event............ " << ievent;
346 
347  int hpdg = genie::kPdgHNL;
348  EventRecord * event = new EventRecord;
349 
350  event->SetProbability( CoMLifetime );
351 
352  int decay = (int) gOptDecayMode;
353 
354  SimpleHNL sh( "HNL", ievent, hpdg, genie::kPdgKP,
356 
357  const std::map< HNLDecayMode_t, double > gammaMap = sh.GetValidChannels();
358  CoMLifetime = sh.GetCoMLifetime();
359 
360  if( gOptDecayMode == kHNLDcyNull ){ // select from available modes
361  LOG("gevgen_pghnl", pNOTICE)
362  << "No decay mode specified - sampling from all available modes.";
363 
364  std::vector< HNLDecayMode_t > * intChannels = &gOptIntChannels;
365 
366  decay = SelectDecayMode( intChannels, sh );
367  }
368 
369  Interaction * interaction = Interaction::HNL(genie::kPdgHNL, gOptEnergyHNL, decay);
370  event->AttachSummary(interaction);
371 
372  // generate origin position and momentum direction for this HNL
373  TLorentzVector * x4orig = GenerateOriginPosition( event );
374  TLorentzVector * p4HNL = GenerateOriginMomentum( event );
375 
376  // and add as Particle(0)
377  GHepParticle ptHNL( kPdgHNL, kIStInitialState, -1, -1, -1, -1, *p4HNL, *x4orig );
378  event->AddParticle( ptHNL );
379 
380  LOG("gevgen_pghnl", pDEBUG)
381  << "Note decay mode is " << utils::hnl::AsString(gOptDecayMode);
382 
383  // Simulate decay
384  hnlgen->ProcessEventRecord(event);
385  vtxGen->ProcessEventRecord(event);
386 
387  // add the FS 4-momenta to special branches
388  // Quite inelegant. Gets the job done, though
389  NTP_FS0_PDG = (event->Particle(1))->Pdg();
390  NTP_FS0_E = ((event->Particle(1))->P4())->E();
391  NTP_FS0_PX = ((event->Particle(1))->P4())->Px();
392  NTP_FS0_PY = ((event->Particle(1))->P4())->Py();
393  NTP_FS0_PZ = ((event->Particle(1))->P4())->Pz();
394  NTP_FS1_PDG = (event->Particle(2))->Pdg();
395  NTP_FS1_E = ((event->Particle(2))->P4())->E();
396  NTP_FS1_PX = ((event->Particle(2))->P4())->Px();
397  NTP_FS1_PY = ((event->Particle(2))->P4())->Py();
398  NTP_FS1_PZ = ((event->Particle(2))->P4())->Pz();
399  if( event->Particle(3) ){
400  NTP_FS2_PDG = (event->Particle(3))->Pdg();
401  NTP_FS2_E = ((event->Particle(3))->P4())->E();
402  NTP_FS2_PX = ((event->Particle(3))->P4())->Px();
403  NTP_FS2_PY = ((event->Particle(3))->P4())->Py();
404  NTP_FS2_PZ = ((event->Particle(3))->P4())->Pz();
405  }
406  else{
407  NTP_FS2_PDG = 0;
408  NTP_FS2_E = 0.0;
409  NTP_FS2_PX = 0.0;
410  NTP_FS2_PY = 0.0;
411  NTP_FS2_PZ = 0.0;
412  }
413 
414  // Generate (or read) a position for the decay vertex
415  // also currently handles the event weight
416  TLorentzVector x4mm = GeneratePosition( event );
417  event->SetWeight( evWeight );
418 
419  // why does InitState show the wrong p4 here?
420  interaction->InitStatePtr()->SetProbeP4( *(event->Particle(0)->P4()) );
421 
422  LOG("gevgen_pghnl", pINFO)
423  << "Generated event: " << *event;
424 
425  // Add event at the output ntuple, refresh the mc job monitor & clean-up
426  ntpw.AddEventRecord(ievent, event);
427  mcjmonitor.Update(ievent,event);
428  delete event;
429 
430  ievent++;
431  } // event loop
432 
433  // Save the generated event tree & close the output file
434  ntpw.Save();
435 
436  LOG("gevgen_pghnl", pNOTICE) << "Done!";
437 
438  return 0;
439 }
void RandGen(long int seed)
Definition: AppInit.cxx:30
double NTP_IS_PX
HNLDecayMode_t gOptDecayMode
double CoMLifetime
TLorentzVector GeneratePosition(GHepRecord *event)
Heavy Neutral Lepton final-state product generator.
Definition: HNLDecayer.h:41
Heavy Neutral Lepton decay vertex generator given production vertex and momentum ***.
double NTP_FS1_PX
string gOptEvFilePrefix
Definition: gAtmoEvGen.cxx:310
void SetProbeP4(const TLorentzVector &P4)
Defines the EventRecordVisitorI interface. Concrete implementations of this interface use the &#39;Visito...
double gOptECoupling
virtual void SetProbability(double prob)
Definition: GHepRecord.h:131
#define pFATAL
Definition: Messenger.h:56
HNL object.
Definition: SimpleHNL.h:36
Algorithm abstract base class.
Definition: Algorithm.h:54
TLorentzVector * GenerateOriginPosition(GHepRecord *event)
int NTP_FS0_PDG
A singleton holding random number generator classes. All random number generation in GENIE should tak...
Definition: RandomGen.h:29
double NTP_FS0_PX
bool gOptIsMajorana
double NTP_IS_E
double evWeight
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
double NTP_IS_PY
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
double NTP_FS2_PY
double gOptEnergyHNL
double NTP_FS2_PX
string kDefOptSName
int gOptNev
Definition: gAtmoEvGen.cxx:305
const int kPdgKP
Definition: PDGCodes.h:172
const int kPdgHNL
Definition: PDGCodes.h:224
enum genie::hnl::EHNLDecayMode HNLDecayMode_t
#define pINFO
Definition: Messenger.h:62
double NTP_IS_PZ
TLorentzVector * GenerateOriginMomentum(GHepRecord *event)
double NTP_FS0_PY
string gOptRootGeom
Definition: gAtmoEvGen.cxx:300
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
double gOptTCoupling
double NTP_FS2_PZ
A utility class to facilitate creating the GENIE MC Ntuple from the output GENIE GHEP event records...
Definition: NtpWriter.h:39
static __attribute__((unused)) double fDecayGammas[]
double NTP_FS2_E
double gOptMCoupling
double NTP_FS0_E
double NTP_FS1_PY
double NTP_FS1_E
string kDefOptSConfig
NtpMCFormat_t kDefOptNtpFormat
Definition: gAtmoEvGen.cxx:319
InitialState * InitStatePtr(void) const
Definition: Interaction.h:74
int SelectDecayMode(std::vector< HNLDecayMode_t > *intChannels, SimpleHNL sh)
const char * AsString(Resonance_t res)
resonance id -&gt; string
vector< vector< double > > clear
void MesgThresholds(string inpfile)
Definition: AppInit.cxx:99
const EventRecordVisitorI * HNLGenerator(void)
#define pNOTICE
Definition: Messenger.h:61
void GetCommandLineArgs(int argc, char **argv)
Definition: gAtmoEvGen.cxx:563
The GENIE Algorithm Factory.
Definition: AlgFactory.h:39
double NTP_FS1_PZ
int NTP_FS1_PDG
int NTP_FS2_PDG
STDHEP-like event record entry that can fit a particle or a nucleus.
Definition: GHepParticle.h:39
double gOptMassHNL
double NTP_FS0_PZ
std::vector< HNLDecayMode_t > gOptIntChannels
bool gOptUsingRootGeom
Definition: gAtmoEvGen.cxx:298
#define pDEBUG
Definition: Messenger.h:63
long int gOptRanSeed
Definition: gAtmoEvGen.cxx:312
void PrintSyntax ( void  )
int SelectDecayMode ( std::vector< HNLDecayMode_t > *  intChannels,
SimpleHNL  sh 
)

Variable Documentation

double CoMLifetime = -1.0

Definition at line 187 of file gBeamHNLParticleGun.cxx.

double evProdVtx[3] = {0.0, 0.0, 0.0}

Definition at line 189 of file gBeamHNLParticleGun.cxx.

double evWeight = 1.0

Definition at line 191 of file gBeamHNLParticleGun.cxx.

double fdx = 0

Definition at line 172 of file gBeamHNLParticleGun.cxx.

double fdy = 0

Definition at line 173 of file gBeamHNLParticleGun.cxx.

double fdz = 0

Definition at line 174 of file gBeamHNLParticleGun.cxx.

double fox = 0

Definition at line 175 of file gBeamHNLParticleGun.cxx.

double foy = 0

Definition at line 176 of file gBeamHNLParticleGun.cxx.

double foz = 0

Definition at line 177 of file gBeamHNLParticleGun.cxx.

HNLDecayMode_t gOptDecayMode = kHNLDcyNull

Definition at line 155 of file gBeamHNLParticleGun.cxx.

double gOptECoupling = -1

Definition at line 148 of file gBeamHNLParticleGun.cxx.

double gOptEnergyHNL = -1

Definition at line 146 of file gBeamHNLParticleGun.cxx.

string gOptEvFilePrefix = kDefOptEvFilePrefix

Definition at line 158 of file gBeamHNLParticleGun.cxx.

double gOptGeomLUnits = 0

Definition at line 168 of file gBeamHNLParticleGun.cxx.

int gOptHNLKind = -1

Definition at line 153 of file gBeamHNLParticleGun.cxx.

std::vector< HNLDecayMode_t > gOptIntChannels

Definition at line 156 of file gBeamHNLParticleGun.cxx.

bool gOptIsMajorana = false

Definition at line 152 of file gBeamHNLParticleGun.cxx.

double gOptMassHNL = -1

Definition at line 147 of file gBeamHNLParticleGun.cxx.

double gOptMCoupling = -1

Definition at line 149 of file gBeamHNLParticleGun.cxx.

int gOptNev = 10

Definition at line 144 of file gBeamHNLParticleGun.cxx.

long int gOptRanSeed = -1

Definition at line 169 of file gBeamHNLParticleGun.cxx.

string gOptRootGeom

Definition at line 160 of file gBeamHNLParticleGun.cxx.

string gOptRootGeomTopVol = ""

Definition at line 167 of file gBeamHNLParticleGun.cxx.

Long_t gOptRunNu = 1000

Definition at line 143 of file gBeamHNLParticleGun.cxx.

double gOptTCoupling = -1

Definition at line 150 of file gBeamHNLParticleGun.cxx.

bool gOptUsingRootGeom = false

Definition at line 159 of file gBeamHNLParticleGun.cxx.

string kDefOptEvFilePrefix = "gntp"

Definition at line 136 of file gBeamHNLParticleGun.cxx.

string kDefOptGeomDUnits = "g_cm3"

Definition at line 134 of file gBeamHNLParticleGun.cxx.

string kDefOptGeomLUnits = "mm"

Definition at line 133 of file gBeamHNLParticleGun.cxx.

NtpMCFormat_t kDefOptNtpFormat = kNFGHEP

Definition at line 135 of file gBeamHNLParticleGun.cxx.

string kDefOptSConfig = "BeamHNL"

Definition at line 139 of file gBeamHNLParticleGun.cxx.

string kDefOptSName = "genie::EventGenerator"

Definition at line 138 of file gBeamHNLParticleGun.cxx.

string kDefOptSTune = "GHNL20_00a_00_000"

Definition at line 140 of file gBeamHNLParticleGun.cxx.

double NTP_FS0_E = 0.

Definition at line 180 of file gBeamHNLParticleGun.cxx.

int NTP_FS0_PDG = 0

Definition at line 183 of file gBeamHNLParticleGun.cxx.

double NTP_FS0_PX = 0.

Definition at line 180 of file gBeamHNLParticleGun.cxx.

double NTP_FS0_PY = 0.

Definition at line 180 of file gBeamHNLParticleGun.cxx.

double NTP_FS0_PZ = 0.

Definition at line 180 of file gBeamHNLParticleGun.cxx.

double NTP_FS1_E = 0.

Definition at line 181 of file gBeamHNLParticleGun.cxx.

int NTP_FS1_PDG = 0

Definition at line 183 of file gBeamHNLParticleGun.cxx.

double NTP_FS1_PX = 0.

Definition at line 181 of file gBeamHNLParticleGun.cxx.

double NTP_FS1_PY = 0.

Definition at line 181 of file gBeamHNLParticleGun.cxx.

double NTP_FS1_PZ = 0.

Definition at line 181 of file gBeamHNLParticleGun.cxx.

double NTP_FS2_E = 0.

Definition at line 182 of file gBeamHNLParticleGun.cxx.

int NTP_FS2_PDG = 0

Definition at line 183 of file gBeamHNLParticleGun.cxx.

double NTP_FS2_PX = 0.

Definition at line 182 of file gBeamHNLParticleGun.cxx.

double NTP_FS2_PY = 0.

Definition at line 182 of file gBeamHNLParticleGun.cxx.

double NTP_FS2_PZ = 0.

Definition at line 182 of file gBeamHNLParticleGun.cxx.

double NTP_IS_E = 0.

Definition at line 179 of file gBeamHNLParticleGun.cxx.

double NTP_IS_PX = 0.

Definition at line 179 of file gBeamHNLParticleGun.cxx.

double NTP_IS_PY = 0.

Definition at line 179 of file gBeamHNLParticleGun.cxx.

double NTP_IS_PZ = 0.

Definition at line 179 of file gBeamHNLParticleGun.cxx.