GENIEGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Typedefs | Enumerations | Functions | Variables
gBeamHNLValidationApp.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/HNLFluxContainer.h"
#include "Physics/BeamHNL/HNLDecayer.h"
#include "Physics/BeamHNL/HNLProductionMode.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 gBeamHNLValidationApp.cxx:

Go to the source code of this file.

Typedefs

typedef enum t_HNLValidation HNLValidation_t
 

Enumerations

enum  t_HNLValidation {
  kValNone = 0, kValFluxFromDk2nu = 1, kValDecay = 2, kValGeom = 3,
  kValFullSim = 4
}
 

Functions

void GetCommandLineArgs (int argc, char **argv)
 
void ReadInConfig (void)
 
void PrintSyntax (void)
 
const EventRecordVisitorIHNLGenerator (void)
 
int TestDecay (void)
 
int main (int argc, char **argv)
 

Variables

string kDefOptGeomLUnits = "mm"
 
string kDefOptGeomAUnits = "rad"
 
string kDefOptGeomTUnits = "ns"
 
string kDefOptGeomDUnits = "g_cm3"
 
NtpMCFormat_t kDefOptNtpFormat = kNFGHEP
 
string kDefOptEvFilePrefix = "gntp"
 
string kDefOptFluxFilePath = "./input-flux.root"
 
string kDefOptSName = "genie::EventGenerator"
 
string kDefOptSConfig = "BeamHNL"
 
string kDefOptSTune = "GHNL20_00a_00_000"
 
Long_t gOptRunNu = 1000
 
int gOptNev = 10
 
HNLValidation_t gOptValidationMode = kValNone
 
double gCfgMassHNL = -1
 
double gCfgECoupling = -1
 
double gCfgMCoupling = -1
 
double gCfgTCoupling = -1
 
bool gCfgIsMajorana = false
 
int gCfgHNLKind = 2
 
double CoMLifetime = -1
 
HNLProd_t gCfgProdMode = kHNLProdNull
 
HNLDecayMode_t gCfgDecayMode = kHNLDcyNull
 
std::vector< HNLDecayMode_tgCfgIntChannels
 
double gCfgUserOx = -1
 
double gCfgUserOy = -1
 
double gCfgUserOz = -1
 
double gCfgUserAx1 = -1
 
double gCfgUserAz = -1
 
double gCfgUserAx2 = -1
 
double gCfgBoxLx = -1
 
double gCfgBoxLy = -1
 
double gCfgBoxLz = -1
 
double gCfgParentEnergy = -1
 
double gCfgParentTheta = -1
 
double gCfgParentPhi = -1
 
double gCfgParentOx = -1
 
double gCfgParentOy = -1
 
double gCfgParentOz = -1
 
double gCfgHNLCx = -1
 
double gCfgHNLCy = -1
 
double gCfgHNLCz = -1
 
double gOptEnergyHNL = -1
 
bool gOptIsMonoEnFlux = true
 
string gOptEvFilePrefix = kDefOptEvFilePrefix
 
bool gOptUsingRootGeom = false
 
string gOptRootGeom
 
string geom
 
string lunits
 
string aunits
 
string tunits
 
double gOptGeomLUnits = 0
 
double gOptGeomAUnits = 0
 
double gOptGeomTUnits = 0
 
string gOptRootGeomTopVol = ""
 
double fdx = 0
 
double fdy = 0
 
double fdz = 0
 
double fox = 0
 
double foy = 0
 
double foz = 0
 
long int gOptRanSeed = -1
 

Typedef Documentation

Enumeration Type Documentation

Enumerator
kValNone 
kValFluxFromDk2nu 
kValDecay 
kValGeom 
kValFullSim 

Definition at line 134 of file gBeamHNLValidationApp.cxx.

134  {
135 
136  kValNone = 0,
137  kValFluxFromDk2nu = 1,
138  kValDecay = 2,
139  kValGeom = 3,
140  kValFullSim = 4
141 
enum t_HNLValidation HNLValidation_t

Function Documentation

void GetCommandLineArgs ( int  argc,
char **  argv 
)
const EventRecordVisitorI* HNLGenerator ( void  )
int main ( int  argc,
char **  argv 
)

Definition at line 255 of file gBeamHNLValidationApp.cxx.

References GetCommandLineArgs(), gOptRanSeed, gOptValidationMode, genie::RunOpt::Instance(), kValDecay, kValFluxFromDk2nu, kValGeom, LOG, genie::utils::app_init::MesgThresholds(), pFATAL, genie::utils::app_init::RandGen(), ReadInConfig(), and TestDecay().

256 {
257  // suppress ROOT Info messages
258  gErrorIgnoreLevel = kWarning;
259 
260  // Parse command line arguments
261  GetCommandLineArgs(argc,argv);
262 
263  // Get the validation configuration
264  ReadInConfig();
265 
266  // Init messenger and random number seed
267  utils::app_init::MesgThresholds(RunOpt::Instance()->MesgThresholdFiles());
269 
270  switch( gOptValidationMode ){
271 
272  case kValFluxFromDk2nu: return TestFluxFromDk2nu(); break;
273  case kValDecay: return TestDecay(); break;
274  case kValGeom: return TestGeom(); break;
275  default: LOG( "gevald_hnl", pFATAL ) << "I didn't recognise this mode. Goodbye world!"; break;
276  }
277 
278  return 0;
279 }
void RandGen(long int seed)
Definition: AppInit.cxx:30
#define pFATAL
Definition: Messenger.h:56
int TestDecay(void)
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
void ReadInConfig(void)
HNLValidation_t gOptValidationMode
void MesgThresholds(string inpfile)
Definition: AppInit.cxx:99
void GetCommandLineArgs(int argc, char **argv)
Definition: gAtmoEvGen.cxx:563
long int gOptRanSeed
Definition: gAtmoEvGen.cxx:312
void PrintSyntax ( void  )
void ReadInConfig ( void  )

Definition at line 1421 of file gBeamHNLValidationApp.cxx.

References genie::hnl::selector::__attribute__(), genie::utils::hnl::AsString(), aunits, CoMLifetime, gCfgECoupling, gCfgHNLCx, gCfgHNLCy, gCfgHNLCz, gCfgIntChannels, gCfgIsMajorana, gCfgMassHNL, gCfgMCoupling, gCfgTCoupling, gCfgUserAx1, gCfgUserAx2, gCfgUserAz, gCfgUserOx, gCfgUserOy, gCfgUserOz, genie::AlgFactory::GetAlgorithm(), genie::hnl::FluxCreator::GetB2URotation(), genie::hnl::FluxCreator::GetB2UTranslation(), genie::hnl::Decayer::GetHNLCouplings(), genie::hnl::Decayer::GetHNLInterestingChannels(), genie::hnl::Decayer::GetHNLLifetime(), genie::hnl::Decayer::GetHNLMass(), genie::hnl::Decayer::GetPGunDirection(), genie::hnl::Decayer::GetPGunEnergy(), gOptEnergyHNL, gOptGeomAUnits, gOptGeomLUnits, genie::AlgFactory::Instance(), genie::hnl::Decayer::IsHNLMajorana(), LOG, lunits, genie::units::m, pDEBUG, pFATAL, and genie::units::rad.

Referenced by main().

1422 {
1423  LOG("gevald_hnl", pFATAL)
1424  << "Reading in validation configuration. . .";
1425 
1426  const Algorithm * algHNLGen = AlgFactory::Instance()->GetAlgorithm("genie::hnl::Decayer", "Default");
1427  __attribute__((unused)) const Decayer * hnlgen = dynamic_cast< const Decayer * >( algHNLGen );
1428 
1429  CoMLifetime = hnlgen->GetHNLLifetime();
1430 
1431  gCfgMassHNL = hnlgen->GetHNLMass();
1432  std::vector<double> U4l2s = hnlgen->GetHNLCouplings();
1433  gCfgECoupling = U4l2s.at(0);
1434  gCfgMCoupling = U4l2s.at(1);
1435  gCfgTCoupling = U4l2s.at(2);
1436  gCfgIsMajorana = hnlgen->IsHNLMajorana();
1437 
1438  //gOptEnergyHNL = utils::hnl::GetCfgDouble( "HNL", "ParticleGun", "PG-Energy" );
1439  gOptEnergyHNL = hnlgen->GetPGunEnergy();
1440 
1441  std::vector< double > PGDirection = hnlgen->GetPGunDirection();
1442  gCfgHNLCx = PGDirection.at(0), gCfgHNLCy = PGDirection.at(1), gCfgHNLCz = PGDirection.at(2);
1443  /*
1444  gCfgHNLCx = utils::hnl::GetCfgDouble( "HNL", "ParticleGun", "PG-cx" );
1445  gCfgHNLCy = utils::hnl::GetCfgDouble( "HNL", "ParticleGun", "PG-cy" );
1446  gCfgHNLCz = utils::hnl::GetCfgDouble( "HNL", "ParticleGun", "PG-cz" );
1447  */
1448 
1449  double dircosMag2 = std::pow( gCfgHNLCx, 2.0 ) +
1450  std::pow( gCfgHNLCy, 2.0 ) +
1451  std::pow( gCfgHNLCz, 2.0 );
1452  double invdircosmag = 1.0 / std::sqrt( dircosMag2 );
1453  gCfgHNLCx *= invdircosmag;
1454  gCfgHNLCy *= invdircosmag;
1455  gCfgHNLCz *= invdircosmag;
1456 
1457  std::string stIntChannels = hnlgen->GetHNLInterestingChannels(); int iChan = -1;
1458  if( gCfgIntChannels.size() > 0 ) gCfgIntChannels.clear();
1459  while( stIntChannels.size() > 0 ){ // read channels from right (lowest mass) to left (highest mass)
1460  iChan++;
1461  HNLDecayMode_t md = static_cast< HNLDecayMode_t >( iChan );
1462  std::string tmpSt = stIntChannels.substr( stIntChannels.size()-1, stIntChannels.size() );
1463  if( std::strcmp( tmpSt.c_str(), "1" ) == 0 )
1464  gCfgIntChannels.emplace_back( md );
1465 
1466  stIntChannels.erase( stIntChannels.end()-1, stIntChannels.end() );
1467  }
1468 
1469  const Algorithm * algFluxCreator = AlgFactory::Instance()->GetAlgorithm("genie::hnl::FluxCreator", "Default");
1470  __attribute__((unused)) const FluxCreator * fluxCreator = dynamic_cast< const FluxCreator * >( algFluxCreator );
1471 
1472  std::vector< double > b2uTranslation = fluxCreator->GetB2UTranslation();
1473  gCfgUserOx = b2uTranslation.at(0); gCfgUserOy = b2uTranslation.at(1); gCfgUserOz = b2uTranslation.at(2);
1474  std::vector< double > b2uRotation = fluxCreator->GetB2URotation();
1475  gCfgUserAx1 = b2uRotation.at(0); gCfgUserAz = b2uRotation.at(1); gCfgUserAx2 = b2uRotation.at(2);
1476 
1477  // now transform the lengths and angles to the correct units
1478  gCfgUserOx *= units::m / gOptGeomLUnits;
1479  gCfgUserOy *= units::m / gOptGeomLUnits;
1480  gCfgUserOz *= units::m / gOptGeomLUnits;
1481 
1482  gCfgUserAx1 *= units::rad / gOptGeomAUnits;
1483  gCfgUserAz *= units::rad / gOptGeomAUnits;
1484  gCfgUserAx2 *= units::rad / gOptGeomAUnits;
1485 
1486  ostringstream csts;
1487  csts << "Read out the following config:"
1488  << "\n"
1489  << "\nHNL mass = " << gCfgMassHNL << " [GeV]"
1490  << "\n|U_e4|^2 = " << gCfgECoupling
1491  << "\n|U_m4|^2 = " << gCfgMCoupling
1492  << "\n|U_t4|^2 = " << gCfgTCoupling
1493  << "\n"
1494  << "\nInteresting decay channels:";
1495  for( std::vector< HNLDecayMode_t >::iterator chit = gCfgIntChannels.begin();
1496  chit != gCfgIntChannels.end(); ++chit ){ csts << "\n\t" << utils::hnl::AsString(*chit); }
1497  csts << "\n"
1498  << "\nUser origin in beam coordinates = ( " << gCfgUserOx
1499  << ", " << gCfgUserOy << ", " << gCfgUserOz << " ) [" << lunits.c_str() << "]"
1500  << "\nEuler extrinsic x-z-x rotation = ( " << gCfgUserAx1
1501  << ", " << gCfgUserAz << ", " << gCfgUserAx2 << " ) [" << aunits.c_str() << "]"
1502  << "\nHNL particle-gun directional cosines: ( " << gCfgHNLCx << ", " << gCfgHNLCy
1503  << ", " << gCfgHNLCz << ") [ GeV / GeV ]";
1504 
1505  LOG("gevald_hnl", pDEBUG) << csts.str();
1506 
1507 }
double gCfgHNLCx
double gOptGeomAUnits
double CoMLifetime
string aunits
static constexpr double rad
Definition: Units.h:164
Heavy Neutral Lepton final-state product generator.
Definition: HNLDecayer.h:41
double gCfgUserOy
double gCfgUserAx2
double gCfgUserOx
#define pFATAL
Definition: Messenger.h:56
std::vector< HNLDecayMode_t > gCfgIntChannels
Algorithm abstract base class.
Definition: Algorithm.h:54
double gCfgECoupling
double gCfgMCoupling
double gCfgUserAz
string lunits
double gCfgUserAx1
Calculates HNL production kinematics &amp; production vertex. Is a concrete implementation of the FluxRec...
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
static constexpr double GeV
Definition: Units.h:28
double gOptEnergyHNL
bool gCfgIsMajorana
enum genie::hnl::EHNLDecayMode HNLDecayMode_t
double gCfgUserOz
double gCfgHNLCz
double gCfgHNLCy
static __attribute__((unused)) double fDecayGammas[]
double gCfgMassHNL
const char * AsString(Resonance_t res)
resonance id -&gt; string
vector< vector< double > > clear
double gOptGeomLUnits
Definition: gAtmoEvGen.cxx:302
static constexpr double m
Definition: Units.h:71
double gCfgTCoupling
#define pDEBUG
Definition: Messenger.h:63
int TestDecay ( void  )

Definition at line 545 of file gBeamHNLValidationApp.cxx.

References genie::hnl::selector::__attribute__(), genie::utils::hnl::AsString(), CoMLifetime, genie::XclsTag::DecayMode(), genie::Interaction::ExclTag(), gCfgECoupling, gCfgHNLCx, gCfgHNLCy, gCfgHNLCz, gCfgMassHNL, gCfgMCoupling, gCfgTCoupling, genie::AlgFactory::GetAlgorithm(), genie::hnl::Decayer::GetPGunEnergy(), genie::hnl::Decayer::GetPGunOrigin(), genie::hnl::SimpleHNL::GetValidChannels(), gOptEnergyHNL, gOptNev, gOptRootGeom, genie::Interaction::HNL(), HNLGenerator(), genie::Interaction::InitStatePtr(), genie::RunOpt::Instance(), genie::AlgFactory::Instance(), genie::hnl::kHNLDcyNuEE, genie::hnl::kHNLDcyNull, genie::hnl::kHNLDcyNuMuE, genie::hnl::kHNLDcyNuMuMu, genie::hnl::kHNLDcyNuNuNu, genie::hnl::kHNLDcyPi0Nu, genie::hnl::kHNLDcyPi0Pi0Nu, genie::hnl::kHNLDcyPiE, genie::hnl::kHNLDcyPiMu, genie::hnl::kHNLDcyPiPi0E, genie::hnl::kHNLDcyPiPi0Mu, genie::kIStInitialState, genie::kPdgHNL, genie::kPdgKP, LOG, genie::units::m, genie::units::mm, genie::utils::print::P4AsString(), pDEBUG, pFATAL, pINFO, genie::hnl::Decayer::ProcessEventRecord(), genie::hnl::VertexGenerator::ProcessEventRecord(), genie::hnl::SimpleHNL::SetEnergy(), genie::hnl::VertexGenerator::SetGeomFile(), genie::hnl::SimpleHNL::SetMomentumDirection(), genie::GHepRecord::SetPrintLevel(), and genie::InitialState::SetProbeP4().

Referenced by main().

546 {
547  string foutName("test_decay.root");
548 
549  TFile * fout = TFile::Open( foutName.c_str(), "RECREATE" );
550 
551  __attribute__((unused)) const EventRecordVisitorI * mcgen = HNLGenerator();
552  const Algorithm * algHNLGen = AlgFactory::Instance()->GetAlgorithm("genie::hnl::Decayer", "Default");
553  const Decayer * hnlgen = dynamic_cast< const Decayer * >( algHNLGen );
554 
555  bool geom_is_accessible = ! (gSystem->AccessPathName(gOptRootGeom.c_str()));
556  if (!geom_is_accessible) {
557  LOG("gevald_hnl", pFATAL)
558  << "The specified ROOT geometry doesn't exist! Initialization failed!";
559  exit(1);
560  }
561 
562  if( !gOptRootGeoManager ) gOptRootGeoManager = TGeoManager::Import(gOptRootGeom.c_str());
563 
564  TGeoVolume * top_volume = gOptRootGeoManager->GetTopVolume();
565  assert( top_volume );
566  TGeoShape * ts = top_volume->GetShape();
567  __attribute__((unused)) TGeoBBox * box = (TGeoBBox *)ts;
568 
569  LOG( "gevald_hnl", pDEBUG ) << "Imported box.";
570 
571  const Algorithm * algVtxGen = AlgFactory::Instance()->GetAlgorithm("genie::hnl::VertexGenerator", "Default");
572 
573  const VertexGenerator * vtxGen = dynamic_cast< const VertexGenerator * >( algVtxGen );
574  vtxGen->SetGeomFile( gOptRootGeom );
575 
576  SimpleHNL sh = SimpleHNL( "HNLInstance", 0, kPdgHNL, kPdgKP,
578  std::map< HNLDecayMode_t, double > valMap = sh.GetValidChannels();
579  //const double CoMLifetime = sh.GetCoMLifetime();
580 
581  assert( valMap.size() > 0 ); // must be able to decay to something!
582  assert( (*valMap.begin()).first == kHNLDcyNuNuNu );
583 
584  LOG( "gevald_hnl", pINFO )
585  << "\n\nTesting decay modes for the HNL."
586  << "\nWill process gOptNev = " << gOptNev << " x ( N_channels = " << valMap.size()
587  << " ) = " << valMap.size() * gOptNev << " events, 1 for each valid channel."
588  << "\nWill produce 1 ROOT file ( " << foutName << " ) with:"
589  << "\n--> Energy spectrum for the decay products for each channel"
590  << "\n--> Rates of each decay channel";
591 
592  // Set GHEP print level
593  GHepRecord::SetPrintLevel(RunOpt::Instance()->EventRecordPrintLevel());
594 
595  // first set the 4-momentum of the HNL
596  //gOptEnergyHNL = utils::hnl::GetCfgDouble( "HNL", "ParticleGun", "PG-Energy" );
597  gOptEnergyHNL = hnlgen->GetPGunEnergy();
598  double p3HNL = std::sqrt( gOptEnergyHNL * gOptEnergyHNL - gCfgMassHNL * gCfgMassHNL );
599  assert( p3HNL >= 0.0 );
600  TLorentzVector * p4HNL = new TLorentzVector( p3HNL * gCfgHNLCx,
601  p3HNL * gCfgHNLCy,
602  p3HNL * gCfgHNLCz, gOptEnergyHNL );
603 
604  LOG( "gevald_hnl", pDEBUG )
605  << "\nUsing HNL with 4-momentum " << utils::print::P4AsString( p4HNL );
606  sh.SetEnergy( gOptEnergyHNL );
607  sh.SetMomentumDirection( gCfgHNLCx, gCfgHNLCy, gCfgHNLCz );
608 
609  TLorentzVector * x4HNL = new TLorentzVector( 1.0, 2.0, 3.0, 0.0 ); // dummy
610 
611  // now build array with indices of valid decay modes for speedy access
612  HNLDecayMode_t validModes[10] = { kHNLDcyNull, kHNLDcyNull, kHNLDcyNull, kHNLDcyNull, kHNLDcyNull, kHNLDcyNull, kHNLDcyNull, kHNLDcyNull, kHNLDcyNull, kHNLDcyNull };
613  //double validRates[10] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 };
614  std::map< HNLDecayMode_t, double >::iterator vmit = valMap.begin(); int modeIdx = 0;
615  std::ostringstream msts;
616  for( ; vmit != valMap.end(); ++vmit ){
617  validModes[ modeIdx ] = (*vmit).first;
618  //validRates[ modeIdx ] = (*vmit).second;
619  msts << "\n" << utils::hnl::AsString( (*vmit).first );
620  modeIdx++;
621  }
622 
623  LOG( "gevald_hnl", pDEBUG ) << "Here are the modes in order : " << msts.str();
624 
625  // declare histos
626  // hSpectrum[i][j]: i iterates over HNLDecayMode_t, j over FS particle in same order as event record
627  TH1D hSpectrum[10][3], hCMSpectrum[10][3], hRates;
628  TH1D hParamSpace = TH1D( "hParamSpace", "Parameter space", 5, 0., 5. );
629 
630  hParamSpace.SetBinContent( 1, 1000.0 * gCfgMassHNL ); // MeV
631  hParamSpace.SetBinContent( 2, gCfgECoupling );
632  hParamSpace.SetBinContent( 3, gCfgMCoupling );
633  hParamSpace.SetBinContent( 4, gCfgTCoupling );
634 
635  hRates = TH1D( "hRates", "Rates of HNL decay channels", 10, 0, 10 );
636 
637  std::string shortModes[10] = { "vvv", "vee", "vmue", "pi0v", "pie", "vmumu", "pimu", "pi0pi0v",
638  "pipi0e", "pipi0mu" };
639  std::string part0names[10] = { "v1", "v", "v", "pi0", "pi", "v", "pi", "pi01", "pi", "pi" };
640  std::string part1names[10] = { "v2", "e1", "mu", "v", "e", "mu1", "mu", "pi02", "pi0", "pi0" };
641  std::string part2names[10] = { "v3", "e2", "e", "None", "None", "mu2", "None", "v", "e", "mu" };
642  std::string partNames[3][10] = { part0names, part1names, part2names };
643  for( unsigned int iChan = 0; iChan < valMap.size(); iChan++ ){
644 
645  std::string shortMode = shortModes[iChan];
646 
647  for( Int_t iPart = 0; iPart < 3; iPart++ ){
648  std::string ParticleName = partNames[iPart][iChan];
649  if( strcmp( ParticleName.c_str(), "None" ) != 0 ){
650  hSpectrum[iChan][iPart] = TH1D( Form( "hSpectrum_%s_%s", shortMode.c_str(), ParticleName.c_str() ),
651  Form( "Fractional energy of particle: %s in decay: %s",
652  ParticleName.c_str(),
653  (utils::hnl::AsString( validModes[iChan] )).c_str() ),
654  100, 0., 1.0 );
655  hCMSpectrum[iChan][iPart] = TH1D( Form( "hCMSpectrum_%s_%s", shortMode.c_str(), ParticleName.c_str() ),
656  Form( "Rest frame energy of particle: %s in decay: %s",
657  ParticleName.c_str(),
658  (utils::hnl::AsString( validModes[iChan] )).c_str() ),
659  100, 0., gCfgMassHNL );
660  } // only declare histos of particles that exist in decay
661  // and are of allowed decays
662  }
663  }
664 
665  // fill hRates now
666  double rnununu = ( (*valMap.find( kHNLDcyNuNuNu )) ).second;
667  double rnuee = ( valMap.find( kHNLDcyNuEE ) != valMap.end() ) ? (*(valMap.find( kHNLDcyNuEE ))).second : 0.0;
668  double rnumue = ( valMap.find( kHNLDcyNuMuE ) != valMap.end() ) ? (*(valMap.find( kHNLDcyNuMuE ))).second : 0.0;
669  double rpi0nu = ( valMap.find( kHNLDcyPi0Nu ) != valMap.end() ) ? (*(valMap.find( kHNLDcyPi0Nu ))).second : 0.0;
670  double rpie = ( valMap.find( kHNLDcyPiE ) != valMap.end() ) ? (*(valMap.find( kHNLDcyPiE ))).second : 0.0;
671  double rnumumu = ( valMap.find( kHNLDcyNuMuMu ) != valMap.end() ) ? (*(valMap.find( kHNLDcyNuMuMu ))).second : 0.0;
672  double rpimu = ( valMap.find( kHNLDcyPiMu ) != valMap.end() ) ? (*(valMap.find( kHNLDcyPiMu ))).second : 0.0;
673  double rpi0pi0nu = ( valMap.find( kHNLDcyPi0Pi0Nu ) != valMap.end() ) ? (*(valMap.find( kHNLDcyPi0Pi0Nu ))).second : 0.0;
674  double rpipi0e = ( valMap.find( kHNLDcyPiPi0E ) != valMap.end() ) ? (*(valMap.find( kHNLDcyPiPi0E ))).second : 0.0;
675  double rpipi0mu = ( valMap.find( kHNLDcyPiPi0Mu ) != valMap.end() ) ? (*(valMap.find( kHNLDcyPiPi0Mu ))).second : 0.0;
676 
677  hRates.SetBinContent( 1, rpimu );
678  hRates.SetBinContent( 2, rpie );
679  hRates.SetBinContent( 3, rpi0nu );
680  hRates.SetBinContent( 4, rnununu );
681  hRates.SetBinContent( 5, rnumumu );
682  hRates.SetBinContent( 6, rnuee );
683  hRates.SetBinContent( 7, rnumue );
684  hRates.SetBinContent( 8, rpipi0e );
685  hRates.SetBinContent( 9, rpipi0mu );
686  hRates.SetBinContent( 10, rpi0pi0nu );
687 
688  int ievent = 0;
689  while( true ){
690 
691  if( gOptNev >= 10000 ){
692  if( ievent % (gOptNev / 1000) == 0 ){
693  int irat = ievent / (gOptNev / 1000);
694  std::cerr << Form("%2.2f", 0.1 * irat) << " % ( " << ievent << " / "
695  << gOptNev << " ) \r" << std::flush;
696  }
697  } else if( gOptNev >= 100 ) {
698  if( ievent % (gOptNev / 10) == 0 ){
699  int irat = ievent / ( gOptNev / 10 );
700  std::cerr << 10.0 * irat << " % " << " ( " << ievent
701  << " / " << gOptNev << " ) \r" << std::flush;
702  }
703  }
704 
705  if( ievent == gOptNev ){ std::cerr << " \n"; break; }
706 
707  ostringstream asts;
708  for( unsigned int iMode = 0; iMode < valMap.size(); iMode++ ){
709  if( ievent == 0 ){
710  asts
711  << "\nDecay mode " << iMode << " is " << utils::hnl::AsString( validModes[ iMode ] );
712  }
713 
714  // build an event
715  EventRecord * event = new EventRecord;
716  Interaction * interaction = Interaction::HNL( genie::kPdgHNL, gOptEnergyHNL, validModes[ iMode ] );
717  // set Particle(0) and a dummy vertex
718  GHepParticle ptHNL( kPdgHNL, kIStInitialState, -1, -1, -1, -1, *p4HNL, *x4HNL );
719  event->AddParticle( ptHNL );
720  interaction->InitStatePtr()->SetProbeP4( *p4HNL );
721  event->SetVertex( *x4HNL );
722 
723  event->SetProbability( CoMLifetime );
724 
725  event->AttachSummary( interaction );
726  LOG( "gevald_hnl", pDEBUG )
727  << "Simulating decay with mode "
728  << utils::hnl::AsString( (HNLDecayMode_t) interaction->ExclTag().DecayMode() );
729 
730  // simulate the decay
731  hnlgen->ProcessEventRecord( event );
732 
733  // now get a weight.
734  // = exp( - T_{box} / \tau_{HNL} ) = exp( - L_{box} / ( \beta_{HNL} \gamma_{HNL} c ) * h / \Gamma_{tot} )
735  // placing the HNL at a point configured by the user
736  std::vector< double > PGOrigin = hnlgen->GetPGunOrigin();
737  double ox = PGOrigin.at(0), oy = PGOrigin.at(1), oz = PGOrigin.at(2);
738  /*
739  double ox = utils::hnl::GetCfgDouble( "HNL", "ParticleGun", "PG-OriginX" );
740  double oy = utils::hnl::GetCfgDouble( "HNL", "ParticleGun", "PG-OriginY" );
741  double oz = utils::hnl::GetCfgDouble( "HNL", "ParticleGun", "PG-OriginZ" );
742  */
743  ox *= units::m / units::mm; oy *= units::m / units::mm; oz *= units::m / units::mm;
744  TVector3 startPoint( ox, oy, oz ); TVector3 entryPoint, exitPoint;
745  TLorentzVector tmpVtx( ox, oy, oz, 0.0 );
746  event->SetVertex( tmpVtx );
747 
748  vtxGen->ProcessEventRecord(event);
749 
750  LOG( "gevald_hnl", pDEBUG ) << *event;
751 
752  // now fill the histos!
753  double wgt = event->Weight();
754  hSpectrum[iMode][0].Fill( (event->Particle(1))->E() / gOptEnergyHNL, wgt );
755  hSpectrum[iMode][1].Fill( (event->Particle(2))->E() / gOptEnergyHNL, wgt );
756  if( event->Particle(3) ) hSpectrum[iMode][2].Fill( (event->Particle(3))->E() / gOptEnergyHNL, wgt );
757 
758  // let's also fill the CM spectra
759  // get particle 4-momenta and boost back to rest frame!
760  TLorentzVector * p4p1 = (event->Particle(1))->GetP4();
761  TLorentzVector * p4p2 = (event->Particle(2))->GetP4();
762  TLorentzVector * p4p3 = 0;
763  if( event->Particle(3) ) p4p3 = (event->Particle(3))->GetP4();
764 
765  TVector3 boostVec = p4HNL->BoostVector();
766 
767  p4p1->Boost( -boostVec );
768  p4p2->Boost( -boostVec );
769  if( p4p3 ) p4p3->Boost( -boostVec );
770 
771  hCMSpectrum[iMode][0].Fill( p4p1->E(), wgt );
772  hCMSpectrum[iMode][1].Fill( p4p2->E(), wgt );
773  if( p4p3 ) hCMSpectrum[iMode][2].Fill( p4p3->E(), wgt );
774 
775  // clean-up
776  delete event;
777 
778  } // loop over valid decay channels
779 
780  if( ievent == 0 ) LOG( "gevald_hnl", pDEBUG ) << asts.str();
781  LOG( "gevald_hnl", pDEBUG ) << "Finished event: " << ievent;
782 
783  ievent++;
784 
785  } // event loop
786 
787  fout->cd();
788  hParamSpace.Write();
789  hRates.Write();
790  for( unsigned int i = 0; i < valMap.size(); i++ ){
791  for( Int_t j = 0; j < 3; j++ ){
792  std::string ParticleName = partNames[j][i];
793  if( strcmp( ParticleName.c_str(), "None" ) != 0 ){
794  hSpectrum[i][j].Write();
795  hCMSpectrum[i][j].Write();
796  }
797  }
798  }
799  fout->Write();
800  fout->Close();
801 
802  delete p4HNL;
803  delete x4HNL;
804  return 0;
805 }
double gCfgHNLCx
double CoMLifetime
Heavy Neutral Lepton final-state product generator.
Definition: HNLDecayer.h:41
Heavy Neutral Lepton decay vertex generator given production vertex and momentum ***.
void SetProbeP4(const TLorentzVector &P4)
Defines the EventRecordVisitorI interface. Concrete implementations of this interface use the &#39;Visito...
#define pFATAL
Definition: Messenger.h:56
HNL object.
Definition: SimpleHNL.h:36
string P4AsString(const TLorentzVector *p)
Definition: PrintUtils.cxx:27
Algorithm abstract base class.
Definition: Algorithm.h:54
double gCfgECoupling
double gCfgMCoupling
Some common run-time GENIE options.
Definition: RunOpt.h:35
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
int gOptNev
Definition: gAtmoEvGen.cxx:305
const int kPdgKP
Definition: PDGCodes.h:172
const int kPdgHNL
Definition: PDGCodes.h:224
int DecayMode(void) const
Definition: XclsTag.h:70
enum genie::hnl::EHNLDecayMode HNLDecayMode_t
#define pINFO
Definition: Messenger.h:62
double gCfgHNLCz
string gOptRootGeom
Definition: gAtmoEvGen.cxx:300
double gCfgHNLCy
Generated Event Record. It is a GHepRecord object that can accept / be visited by EventRecordVisitorI...
Definition: EventRecord.h:37
static __attribute__((unused)) double fDecayGammas[]
double gCfgMassHNL
const XclsTag & ExclTag(void) const
Definition: Interaction.h:72
static constexpr double mm
Definition: Units.h:65
InitialState * InitStatePtr(void) const
Definition: Interaction.h:74
const char * AsString(Resonance_t res)
resonance id -&gt; string
const EventRecordVisitorI * HNLGenerator(void)
The GENIE Algorithm Factory.
Definition: AlgFactory.h:39
GENIE&#39;s GHEP MC event record.
Definition: GHepRecord.h:45
static constexpr double m
Definition: Units.h:71
STDHEP-like event record entry that can fit a particle or a nucleus.
Definition: GHepParticle.h:39
double gCfgTCoupling
#define pDEBUG
Definition: Messenger.h:63

Variable Documentation

string aunits

Definition at line 234 of file gBeamHNLValidationApp.cxx.

Referenced by ReadInConfig().

double CoMLifetime = -1

Definition at line 190 of file gBeamHNLValidationApp.cxx.

double fdx = 0

Definition at line 245 of file gBeamHNLValidationApp.cxx.

double fdy = 0

Definition at line 246 of file gBeamHNLValidationApp.cxx.

double fdz = 0

Definition at line 247 of file gBeamHNLValidationApp.cxx.

double fox = 0

Definition at line 248 of file gBeamHNLValidationApp.cxx.

double foy = 0

Definition at line 249 of file gBeamHNLValidationApp.cxx.

double foz = 0

Definition at line 250 of file gBeamHNLValidationApp.cxx.

double gCfgBoxLx = -1

Definition at line 204 of file gBeamHNLValidationApp.cxx.

double gCfgBoxLy = -1

Definition at line 205 of file gBeamHNLValidationApp.cxx.

double gCfgBoxLz = -1

Definition at line 206 of file gBeamHNLValidationApp.cxx.

HNLDecayMode_t gCfgDecayMode = kHNLDcyNull

Definition at line 194 of file gBeamHNLValidationApp.cxx.

double gCfgECoupling = -1

Definition at line 184 of file gBeamHNLValidationApp.cxx.

Referenced by ReadInConfig(), and TestDecay().

double gCfgHNLCx = -1

Definition at line 215 of file gBeamHNLValidationApp.cxx.

Referenced by ReadInConfig(), and TestDecay().

double gCfgHNLCy = -1

Definition at line 216 of file gBeamHNLValidationApp.cxx.

Referenced by ReadInConfig(), and TestDecay().

double gCfgHNLCz = -1

Definition at line 217 of file gBeamHNLValidationApp.cxx.

Referenced by ReadInConfig(), and TestDecay().

int gCfgHNLKind = 2

Definition at line 188 of file gBeamHNLValidationApp.cxx.

std::vector< HNLDecayMode_t > gCfgIntChannels

Definition at line 195 of file gBeamHNLValidationApp.cxx.

Referenced by ReadInConfig().

bool gCfgIsMajorana = false

Definition at line 187 of file gBeamHNLValidationApp.cxx.

Referenced by ReadInConfig().

double gCfgMassHNL = -1

Definition at line 183 of file gBeamHNLValidationApp.cxx.

Referenced by ReadInConfig(), and TestDecay().

double gCfgMCoupling = -1

Definition at line 185 of file gBeamHNLValidationApp.cxx.

Referenced by ReadInConfig(), and TestDecay().

double gCfgParentEnergy = -1

Definition at line 208 of file gBeamHNLValidationApp.cxx.

double gCfgParentOx = -1

Definition at line 211 of file gBeamHNLValidationApp.cxx.

double gCfgParentOy = -1

Definition at line 212 of file gBeamHNLValidationApp.cxx.

double gCfgParentOz = -1

Definition at line 213 of file gBeamHNLValidationApp.cxx.

double gCfgParentPhi = -1

Definition at line 210 of file gBeamHNLValidationApp.cxx.

double gCfgParentTheta = -1

Definition at line 209 of file gBeamHNLValidationApp.cxx.

HNLProd_t gCfgProdMode = kHNLProdNull

Definition at line 193 of file gBeamHNLValidationApp.cxx.

double gCfgTCoupling = -1

Definition at line 186 of file gBeamHNLValidationApp.cxx.

Referenced by ReadInConfig(), and TestDecay().

double gCfgUserAx1 = -1

Definition at line 200 of file gBeamHNLValidationApp.cxx.

Referenced by ReadInConfig().

double gCfgUserAx2 = -1

Definition at line 202 of file gBeamHNLValidationApp.cxx.

Referenced by ReadInConfig().

double gCfgUserAz = -1

Definition at line 201 of file gBeamHNLValidationApp.cxx.

Referenced by ReadInConfig().

double gCfgUserOx = -1

Definition at line 197 of file gBeamHNLValidationApp.cxx.

Referenced by ReadInConfig().

double gCfgUserOy = -1

Definition at line 198 of file gBeamHNLValidationApp.cxx.

Referenced by ReadInConfig().

double gCfgUserOz = -1

Definition at line 199 of file gBeamHNLValidationApp.cxx.

Referenced by ReadInConfig().

string geom

Definition at line 233 of file gBeamHNLValidationApp.cxx.

Referenced by GetCommandLineArgs(), GetTargetCodes(), and main().

double gOptEnergyHNL = -1

Definition at line 221 of file gBeamHNLValidationApp.cxx.

string gOptEvFilePrefix = kDefOptEvFilePrefix

Definition at line 229 of file gBeamHNLValidationApp.cxx.

double gOptGeomAUnits = 0

Definition at line 236 of file gBeamHNLValidationApp.cxx.

Referenced by ReadInConfig().

double gOptGeomLUnits = 0

Definition at line 235 of file gBeamHNLValidationApp.cxx.

double gOptGeomTUnits = 0

Definition at line 237 of file gBeamHNLValidationApp.cxx.

bool gOptIsMonoEnFlux = true

Definition at line 227 of file gBeamHNLValidationApp.cxx.

int gOptNev = 10

Definition at line 177 of file gBeamHNLValidationApp.cxx.

long int gOptRanSeed = -1

Definition at line 252 of file gBeamHNLValidationApp.cxx.

string gOptRootGeom

Definition at line 231 of file gBeamHNLValidationApp.cxx.

string gOptRootGeomTopVol = ""

Definition at line 242 of file gBeamHNLValidationApp.cxx.

Long_t gOptRunNu = 1000

Definition at line 176 of file gBeamHNLValidationApp.cxx.

bool gOptUsingRootGeom = false

Definition at line 230 of file gBeamHNLValidationApp.cxx.

HNLValidation_t gOptValidationMode = kValNone

Definition at line 179 of file gBeamHNLValidationApp.cxx.

Referenced by main().

string kDefOptEvFilePrefix = "gntp"

Definition at line 168 of file gBeamHNLValidationApp.cxx.

string kDefOptFluxFilePath = "./input-flux.root"

Definition at line 169 of file gBeamHNLValidationApp.cxx.

string kDefOptGeomAUnits = "rad"

Definition at line 163 of file gBeamHNLValidationApp.cxx.

string kDefOptGeomDUnits = "g_cm3"

Definition at line 165 of file gBeamHNLValidationApp.cxx.

string kDefOptGeomLUnits = "mm"

Definition at line 162 of file gBeamHNLValidationApp.cxx.

string kDefOptGeomTUnits = "ns"

Definition at line 164 of file gBeamHNLValidationApp.cxx.

NtpMCFormat_t kDefOptNtpFormat = kNFGHEP

Definition at line 167 of file gBeamHNLValidationApp.cxx.

string kDefOptSConfig = "BeamHNL"

Definition at line 172 of file gBeamHNLValidationApp.cxx.

string kDefOptSName = "genie::EventGenerator"

Definition at line 171 of file gBeamHNLValidationApp.cxx.

string kDefOptSTune = "GHNL20_00a_00_000"

Definition at line 173 of file gBeamHNLValidationApp.cxx.

string lunits

Definition at line 234 of file gBeamHNLValidationApp.cxx.

Referenced by GetCommandLineArgs(), and ReadInConfig().

string tunits

Definition at line 234 of file gBeamHNLValidationApp.cxx.