Functions | Variables
gAtmoEvGen.cxx File Reference
#include <cassert>
#include <cstdlib>
#include <cctype>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <iomanip>
#include <cmath>
#include <TRotation.h>
#include <TMath.h>
#include <TGeoShape.h>
#include <TGeoBBox.h>
#include "Framework/Conventions/Units.h"
#include "Framework/EventGen/EventRecord.h"
#include "Framework/EventGen/GFluxI.h"
#include "Framework/EventGen/GMCJDriver.h"
#include "Framework/EventGen/GMCJMonitor.h"
#include "Framework/Messenger/Messenger.h"
#include "Framework/Ntuple/NtpWriter.h"
#include "Framework/Ntuple/NtpMCFormat.h"
#include "Framework/Numerical/RandomGen.h"
#include "Framework/ParticleData/PDGCodes.h"
#include "Framework/ParticleData/PDGLibrary.h"
#include "Framework/Utils/XSecSplineList.h"
#include "Framework/Utils/StringUtils.h"
#include "Framework/Utils/SystemUtils.h"
#include "Framework/Utils/UnitUtils.h"
#include "Framework/Utils/CmdLnArgParser.h"
#include "Framework/Utils/PrintUtils.h"
#include "Framework/Utils/AppInit.h"
#include "Framework/Utils/RunOpt.h"

Go to the source code of this file.

Functions

void GetCommandLineArgs (int argc, char **argv)
 
void PrintSyntax (void)
 
GAtmoFluxGetFlux (void)
 
GeomAnalyzerIGetGeometry (void)
 
int main (int argc, char **argv)
 

Variables

Long_t gOptRunNu
 
string gOptFluxSim
 
map< int, stringgOptFluxFiles
 
bool gOptUsingRootGeom = false
 
map< int, double > gOptTgtMix
 
string gOptRootGeom
 
string gOptRootGeomTopVol = ""
 
double gOptGeomLUnits = 0
 
double gOptGeomDUnits = 0
 
string gOptExtMaxPlXml
 
int gOptNev = -1
 
double gOptKtonYrExposure = -1
 
double gOptSecExposure = -1
 
double gOptEvMin
 
double gOptEvMax
 
string gOptEvFilePrefix
 
TRotation gOptRot
 
long int gOptRanSeed
 
string gOptInpXSecFile
 
double gOptRL = -1
 
double gOptRT = -1
 
NtpMCFormat_t kDefOptNtpFormat = kNFGHEP
 
string kDefOptEvFilePrefix = "gntp"
 
string kDefOptGeomLUnits = "mm"
 
string kDefOptGeomDUnits = "g_cm3"
 
double kDefOptEvMin = 0.5
 
double kDefOptEvMax = 50.0
 

Function Documentation

void GetCommandLineArgs ( int  argc,
char **  argv 
)

Definition at line 563 of file gAtmoEvGen.cxx.

564 {
565 // Get the command line arguments
566 
567  RunOpt::Instance()->ReadFromCommandLine(argc,argv);
568 
569  LOG("gevgen_atmo", pNOTICE) << "Parsing command line arguments";
570 
571  CmdLnArgParser parser(argc,argv);
572 
573  // help?
574  bool help = parser.OptionExists('h');
575  if(help) {
576  PrintSyntax();
577  exit(0);
578  }
579 
580  //
581  // *** run number
582  //
583  if( parser.OptionExists('r') ) {
584  LOG("gevgen_atmo", pDEBUG) << "Reading MC run number";
585  gOptRunNu = parser.ArgAsLong('r');
586  } else {
587  LOG("gevgen_atmo", pDEBUG) << "Unspecified run number - Using default";
588  gOptRunNu = 100000000;
589  } //-r
590 
591  //
592  // *** exposure
593  //
594 
595  // in number of events
596  bool have_required_statistics = false;
597  if( parser.OptionExists('n') ) {
598  LOG("gevgen_atmo", pDEBUG)
599  << "Reading number of events to generate";
600  gOptNev = parser.ArgAsInt('n');
601  have_required_statistics = true;
602  }//-n?
603  // or, in kton*yrs
604  if( parser.OptionExists('e') ) {
605  if(have_required_statistics) {
606  LOG("gevgen_atmo", pFATAL)
607  << "Can't request exposure both in terms of number of events and kton*yrs"
608  << "\nUse just one of the -n and -e options";
609  PrintSyntax();
610  gAbortingInErr = true;
611  exit(1);
612  }
613  LOG("gevgen_atmo", pDEBUG)
614  << "Reading requested exposure in kton*yrs";
615  gOptKtonYrExposure = parser.ArgAsDouble('e');
616  have_required_statistics = true;
617  }//-e?
618 
619  if (parser.OptionExists('T')) {
620  if (have_required_statistics) {
621  LOG("gevgen_atmo", pFATAL)
622  << "Can't request exposure both in terms of number of events or kton*yrs and time"
623  << "\nUse just one of the -n, -e, or -T options";
624  PrintSyntax();
625  gAbortingInErr = true;
626  exit(1);
627  }
628  LOG("gevgen_atmo", pDEBUG)
629  << "Reading requested exposure in seconds";
630  gOptSecExposure = parser.ArgAsDouble('T');
631  have_required_statistics = true;
632  }
633 
634  if(!have_required_statistics) {
635  LOG("gevgen_atmo", pFATAL)
636  << "You must request exposure either in terms of number of events and kton*yrs"
637  << "\nUse any of the -n, -e options";
638  PrintSyntax();
639  gAbortingInErr = true;
640  exit(1);
641  }
642 
643  //
644  // *** event file prefix
645  //
646  if( parser.OptionExists('o') ) {
647  LOG("gevgen_atmo", pDEBUG) << "Reading the event filename prefix";
648  gOptEvFilePrefix = parser.ArgAsString('o');
649  } else {
650  LOG("gevgen_atmo", pDEBUG)
651  << "Will set the default event filename prefix";
653  } //-o
654 
655  //
656  // *** neutrino energy range
657  //
658  if( parser.OptionExists('E') ) {
659  LOG("gevgen_atmo", pINFO) << "Reading neutrino energy range";
660  string nue = parser.ArgAsString('E');
661 
662  // must be a comma separated set of values
663  if(nue.find(",") != string::npos) {
664  // split the comma separated list
665  vector<string> nurange = utils::str::Split(nue, ",");
666  assert(nurange.size() == 2);
667  double emin = atof(nurange[0].c_str());
668  double emax = atof(nurange[1].c_str());
669  assert(emax>emin && emin>=0.);
670  gOptEvMin = emin;
671  gOptEvMax = emax;
672  } else {
673  LOG("gevgen_atmo", pFATAL)
674  << "Invalid energy range. Use `-E emin,emax', eg `-E 0.5,100.";
675  PrintSyntax();
676  gAbortingInErr = true;
677  exit(1);
678  }
679  } else {
680  LOG("gevgen_atmo", pNOTICE)
681  << "No -e option. Using default energy range";
684  }
685 
686  //
687  // *** flux files
688  //
689  // syntax:
690  // simulation:/path/file.data[neutrino_code],/path/file.data[neutrino_code],...
691  //
692  if( parser.OptionExists('f') ) {
693  LOG("gevgen_atmo", pDEBUG) << "Getting input flux files";
694  string flux = parser.ArgAsString('f');
695 
696  // get flux simulation info (FLUKA,BGLRS) so as to instantiate the
697  // appropriate flux driver
698  string::size_type jsimend = flux.find_first_of(":",0);
699  if(jsimend==string::npos) {
700  LOG("gevgen_atmo", pFATAL)
701  << "You need to specify the flux file source";
702  PrintSyntax();
703  gAbortingInErr = true;
704  exit(1);
705  }
706  gOptFluxSim = flux.substr(0,jsimend);
707  for(string::size_type i=0; i<gOptFluxSim.size(); i++) {
708  gOptFluxSim[i] = toupper(gOptFluxSim[i]);
709  }
710  if((gOptFluxSim != "FLUKA") &&
711  (gOptFluxSim != "BGLRS") &&
712  (gOptFluxSim != "HAKKM")) {
713  LOG("gevgen_atmo", pFATAL)
714  << "The flux file source needs to be one of <FLUKA,BGLRS,HAKKM>";
715  PrintSyntax();
716  gAbortingInErr = true;
717  exit(1);
718  }
719  // now get the list of input files and the corresponding neutrino codes.
720  flux.erase(0,jsimend+1);
721  vector<string> fluxv = utils::str::Split(flux,",");
722  vector<string>::const_iterator fluxiter = fluxv.begin();
723  for( ; fluxiter != fluxv.end(); ++fluxiter) {
724  string filename_and_pdg = *fluxiter;
725  string::size_type open_bracket = filename_and_pdg.find("[");
726  string::size_type close_bracket = filename_and_pdg.find("]");
727  if (open_bracket ==string::npos ||
728  close_bracket==string::npos)
729  {
730  LOG("gevgen_atmo", pFATAL)
731  << "You made an error in specifying the flux info";
732  PrintSyntax();
733  gAbortingInErr = true;
734  exit(1);
735  }
736  string::size_type ibeg = 0;
737  string::size_type iend = open_bracket;
738  string::size_type jbeg = open_bracket+1;
739  string::size_type jend = close_bracket;
740  string flux_filename = filename_and_pdg.substr(ibeg,iend-ibeg);
741  string neutrino_pdg = filename_and_pdg.substr(jbeg,jend-jbeg);
742  gOptFluxFiles.insert(
743  map<int,string>::value_type(atoi(neutrino_pdg.c_str()), flux_filename));
744  }
745  if(gOptFluxFiles.size() == 0) {
746  LOG("gevgen_atmo", pFATAL)
747  << "You must specify at least one flux file!";
748  PrintSyntax();
749  gAbortingInErr = true;
750  exit(1);
751  }
752 
753  } else {
754  LOG("gevgen_atmo", pFATAL) << "No flux info was specified! Use the -f option.";
755  PrintSyntax();
756  gAbortingInErr = true;
757  exit(1);
758  }
759 
760  // *** options to fine tune the flux ray generation surface
761 
762  if( parser.OptionExists("flux-ray-generation-surface-distance") ) {
763  LOG("gevgen_atmo", pINFO)
764  << "Reading distance of flux ray generation surface";
765  gOptRL = parser.ArgAsDouble("flux-ray-generation-surface-distance");
766  } else {
767  LOG("gevgen_atmo", pINFO)
768  << "Unspecified distance of flux ray generation surface - Using default";
769  }
770 
771  if( parser.OptionExists("flux-ray-generation-surface-radius") ) {
772  LOG("gevgen_atmo", pINFO)
773  << "Reading radius of flux ray generation surface";
774  gOptRT = parser.ArgAsDouble("flux-ray-generation-surface-radius");
775  } else {
776  LOG("gevgen_atmo", pINFO)
777  << "Unspecified radius of flux ray generation surface - Using default";
778  }
779 
780  //
781  // *** geometry
782  //
783  string geom = "";
784  string lunits, dunits;
785  if( parser.OptionExists('g') ) {
786  LOG("gevgen_atmo", pDEBUG) << "Getting input geometry";
787  geom = parser.ArgAsString('g');
788 
789  // is it a ROOT file that contains a ROOT geometry?
790  bool accessible_geom_file =
791  utils::system::FileExists(geom.c_str());
792  if (accessible_geom_file) {
793  gOptRootGeom = geom;
794  gOptUsingRootGeom = true;
795  }
796  } else {
797  LOG("gevgen_atmo", pFATAL)
798  << "No geometry option specified - Exiting";
799  PrintSyntax();
800  gAbortingInErr = true;
801  exit(1);
802  } //-g
803 
804  if(gOptUsingRootGeom) {
805  // using a ROOT geometry - get requested geometry units
806 
807  // legth units:
808  if( parser.OptionExists('L') ) {
809  LOG("gevgen_atmo", pDEBUG)
810  << "Checking for input geometry length units";
811  lunits = parser.ArgAsString('L');
812  } else {
813  LOG("gevgen_atmo", pDEBUG) << "Using default geometry length units";
814  lunits = kDefOptGeomLUnits;
815  } // -L
816  // density units:
817  if( parser.OptionExists('D') ) {
818  LOG("gevgen_atmo", pDEBUG)
819  << "Checking for input geometry density units";
820  dunits = parser.ArgAsString('D');
821  } else {
822  LOG("gevgen_atmo", pDEBUG) << "Using default geometry density units";
823  dunits = kDefOptGeomDUnits;
824  } // -D
827 
828  // check whether an event generation volume name has been
829  // specified -- default is the 'top volume'
830  if( parser.OptionExists('t') ) {
831  LOG("gevgen_atmo", pDEBUG) << "Checking for input volume name";
832  gOptRootGeomTopVol = parser.ArgAsString('t');
833  } else {
834  LOG("gevgen_atmo", pDEBUG) << "Using the <master volume>";
835  } // -t
836 
837  // check whether an XML file with the maximum (density weighted)
838  // path lengths for each detector material is specified -
839  // otherwise will compute the max path lengths at job init
840  if( parser.OptionExists('m') ) {
841  LOG("gevgen_atmo", pDEBUG)
842  << "Checking for maximum path lengths XML file";
843  gOptExtMaxPlXml = parser.ArgAsString('m');
844  } else {
845  LOG("gevgen_atmo", pDEBUG)
846  << "Will compute the maximum path lengths at job init";
847  gOptExtMaxPlXml = "";
848  } // -m
849  } // using root geom?
850 
851  else {
852  // User has specified a target mix.
853  // Decode the list of target pdf codes & their corresponding weight fraction
854  // (specified as 'pdg_code_1[fraction_1],pdg_code_2[fraction_2],...')
855  // See documentation on top section of this file.
856  //
857  gOptTgtMix.clear();
858  vector<string> tgtmix = utils::str::Split(geom,",");
859  if(tgtmix.size()==1) {
860  int pdg = atoi(tgtmix[0].c_str());
861  double wgt = 1.0;
862  gOptTgtMix.insert(map<int, double>::value_type(pdg, wgt));
863  } else {
864  vector<string>::const_iterator tgtmix_iter = tgtmix.begin();
865  for( ; tgtmix_iter != tgtmix.end(); ++tgtmix_iter) {
866  string tgt_with_wgt = *tgtmix_iter;
867  string::size_type open_bracket = tgt_with_wgt.find("[");
868  string::size_type close_bracket = tgt_with_wgt.find("]");
869  if (open_bracket ==string::npos ||
870  close_bracket==string::npos)
871  {
872  LOG("gevgen_atmo", pFATAL)
873  << "You made an error in specifying the target mix";
874  PrintSyntax();
875  gAbortingInErr = true;
876  exit(1);
877  }
878  string::size_type ibeg = 0;
879  string::size_type iend = open_bracket;
880  string::size_type jbeg = open_bracket+1;
881  string::size_type jend = close_bracket;
882  int pdg = atoi(tgt_with_wgt.substr(ibeg,iend-ibeg).c_str());
883  double wgt = atof(tgt_with_wgt.substr(jbeg,jend-jbeg).c_str());
884  LOG("gevgen_atmo", pDEBUG)
885  << "Adding to target mix: pdg = " << pdg << ", wgt = " << wgt;
886  gOptTgtMix.insert(map<int, double>::value_type(pdg, wgt));
887 
888  }// tgtmix_iter
889  } // >1 materials in mix
890  } // using tgt mix?
891 
892  //
893  // Coordinate rotation matrix
894  //
895  gOptRot.SetToIdentity();
896  if( parser.OptionExists('R') ) {
897  string rotarg = parser.ArgAsString('R');
898  //get convention
899  string::size_type j = rotarg.find_first_of(":",0);
900  string convention = "";
901  if(j==string::npos) { convention = "X"; }
902  else { convention = rotarg.substr(0,j); }
903  //get angles phi,theta,psi
904  rotarg.erase(0,j+1);
905  vector<string> euler_angles = utils::str::Split(rotarg,",");
906  if(euler_angles.size() != 3) {
907  LOG("gevgen_atmo", pFATAL)
908  << "You didn't specify all 3 Euler angles using the -R option";
909  PrintSyntax();
910  gAbortingInErr = true;
911  exit(1);
912  }
913  double phi = atof(euler_angles[0].c_str());
914  double theta = atof(euler_angles[1].c_str());
915  double psi = atof(euler_angles[2].c_str());
916  //set Euler angles using appropriate convention
917  if(convention.find("X")!=string::npos ||
918  convention.find("x")!=string::npos)
919  {
920  LOG("gevgen_atmo", pNOTICE) << "Using X-convention for input Euler angles";
921  gOptRot.SetXEulerAngles(phi,theta,psi);
922  } else
923  if(convention.find("Y")!=string::npos ||
924  convention.find("y")!=string::npos)
925  {
926  LOG("gevgen_atmo", pNOTICE) << "Using Y-convention for input Euler angles";
927  gOptRot.SetYEulerAngles(phi,theta,psi);
928  } else {
929  LOG("gevgen_atmo", pFATAL)
930  << "Unknown Euler angle convention. Please use the X- or Y-convention";
931  PrintSyntax();
932  gAbortingInErr = true;
933  exit(1);
934  }
935  //invert?
936  if(convention.find("^-1")!=string::npos) {
937  LOG("gevgen_atmo", pNOTICE) << "Inverting rotation matrix";
938  gOptRot.Invert();
939  }
940  }
941 
942  //
943  // *** random number seed
944  //
945  if( parser.OptionExists("seed") ) {
946  LOG("gevgen_atmo", pINFO) << "Reading random number seed";
947  gOptRanSeed = parser.ArgAsLong("seed");
948  } else {
949  LOG("gevgen_atmo", pINFO) << "Unspecified random number seed - Using default";
950  gOptRanSeed = -1;
951  }
952 
953  //
954  // *** input cross-section file
955  //
956  if( parser.OptionExists("cross-sections") ) {
957  LOG("gevgen_atmo", pINFO) << "Reading cross-section file";
958  gOptInpXSecFile = parser.ArgAsString("cross-sections");
959  } else {
960  LOG("gevgen_atmo", pINFO) << "Unspecified cross-section file";
961  gOptInpXSecFile = "";
962  }
963 
964  //
965  // print-out summary
966  //
967 
968  PDGLibrary * pdglib = PDGLibrary::Instance();
969 
970  ostringstream gminfo;
971  if (gOptUsingRootGeom) {
972  gminfo << "Using ROOT geometry - file: " << gOptRootGeom
973  << ", top volume: "
974  << ((gOptRootGeomTopVol.size()==0) ? "<master volume>" : gOptRootGeomTopVol)
975  << ", max{PL} file: "
976  << ((gOptExtMaxPlXml.size()==0) ? "<none>" : gOptExtMaxPlXml)
977  << ", length units: " << lunits
978  << ", density units: " << dunits;
979  } else {
980  gminfo << "Using target mix - ";
982  for(iter = gOptTgtMix.begin(); iter != gOptTgtMix.end(); ++iter) {
983  int pdg_code = iter->first;
984  double wgt = iter->second;
985  TParticlePDG * p = pdglib->Find(pdg_code);
986  if(p) {
987  string name = p->GetName();
988  gminfo << "(" << name << ") -> " << 100*wgt << "% / ";
989  }//p?
990  }
991  }
992 
993  ostringstream fluxinfo;
994  fluxinfo << "Using " << gOptFluxSim << " flux files: ";
996  for( ; file_iter != gOptFluxFiles.end(); ++file_iter) {
997  int neutrino_code = file_iter->first;
998  string filename = file_iter->second;
999  TParticlePDG * p = pdglib->Find(neutrino_code);
1000  if(p) {
1001  string name = p->GetName();
1002  fluxinfo << "(" << name << ") -> " << filename << " / ";
1003  }
1004  }
1005  fluxinfo << "Flux ray generation surface - Distance = "
1006  << gOptRL << " m, Radius = " << gOptRT << " m";
1007 
1008  ostringstream expinfo;
1009  if(gOptNev > 0) { expinfo << gOptNev << " events"; }
1010  if(gOptKtonYrExposure > 0) { expinfo << gOptKtonYrExposure << " kton*yrs"; }
1011 
1012  ostringstream rotation;
1013  rotation << "\t| " << gOptRot.XX() << " " << gOptRot.XY() << " " << gOptRot.XZ() << " |\n";
1014  rotation << "\t| " << gOptRot.YX() << " " << gOptRot.YY() << " " << gOptRot.YZ() << " |\n";
1015  rotation << "\t| " << gOptRot.ZX() << " " << gOptRot.ZY() << " " << gOptRot.ZZ() << " |\n";
1016 
1017  LOG("gevgen_atmo", pNOTICE)
1018  << "\n\n"
1019  << utils::print::PrintFramedMesg("gevgen_atmo job configuration");
1020 
1021  LOG("gevgen_atmo", pNOTICE)
1022  << "\n"
1023  << "\n @@ Run number: " << gOptRunNu
1024  << "\n @@ Random number seed: " << gOptRanSeed
1025  << "\n @@ Using cross-section file: " << gOptInpXSecFile
1026  << "\n @@ Geometry"
1027  << "\n\t" << gminfo.str()
1028  << "\n @@ Flux"
1029  << "\n\t" << fluxinfo.str()
1030  << "\n @@ Exposure"
1031  << "\n\t" << expinfo.str()
1032  << "\n @@ Cuts"
1033  << "\n\t Using energy range = (" << gOptEvMin << " GeV, " << gOptEvMax << " GeV)"
1034  << "\n @@ Coordinate transformation (Rotation THZ -> User-defined coordinate system)"
1035  << "\n" << rotation.str()
1036  << "\n\n";
1037 
1038  //
1039  // final checks
1040  //
1041  if(gOptKtonYrExposure > 0) {
1042  LOG("gevgen_atmo", pFATAL)
1043  << "\n Option to set exposure in terms of kton*yrs not supported just yet!"
1044  << "\n Try the -n option instead";
1045  PrintSyntax();
1046  gAbortingInErr = true;
1047  exit(1);
1048  }
1049 }
static QCString name
Definition: declinfo.cpp:673
map< int, string > gOptFluxFiles
Definition: gAtmoEvGen.cxx:297
string gOptEvFilePrefix
Definition: gAtmoEvGen.cxx:310
bool FileExists(string filename)
Definition: SystemUtils.cxx:80
TRotation gOptRot
Definition: gAtmoEvGen.cxx:311
double gOptRT
Definition: gAtmoEvGen.cxx:315
#define pFATAL
Definition: Messenger.h:56
double gOptGeomDUnits
Definition: gAtmoEvGen.cxx:303
intermediate_table::const_iterator const_iterator
map< int, double > gOptTgtMix
Definition: gAtmoEvGen.cxx:299
double gOptEvMin
Definition: gAtmoEvGen.cxx:308
string filename
Definition: train.py:213
double gOptRL
Definition: gAtmoEvGen.cxx:314
double kDefOptEvMax
Definition: gAtmoEvGen.cxx:324
string kDefOptEvFilePrefix
Definition: gAtmoEvGen.cxx:320
string gOptFluxSim
Definition: gAtmoEvGen.cxx:296
string gOptInpXSecFile
Definition: gAtmoEvGen.cxx:313
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
string gOptRootGeomTopVol
Definition: gAtmoEvGen.cxx:301
double UnitFromString(string u)
Definition: UnitUtils.cxx:18
int gOptNev
Definition: gAtmoEvGen.cxx:305
p
Definition: test.py:223
#define pINFO
Definition: Messenger.h:62
string gOptRootGeom
Definition: gAtmoEvGen.cxx:300
Long_t gOptRunNu
Definition: gAtmoEvGen.cxx:295
string kDefOptGeomLUnits
Definition: gAtmoEvGen.cxx:321
vector< string > Split(string input, string delim)
Definition: StringUtils.cxx:36
Singleton class to load & serve a TDatabasePDG.
Definition: PDGLibrary.h:32
double gOptEvMax
Definition: gAtmoEvGen.cxx:309
string PrintFramedMesg(string mesg, unsigned int nl=1, const char f='*')
Definition: PrintUtils.cxx:164
TParticlePDG * Find(int pdgc, bool must_exist=true)
Definition: PDGLibrary.cxx:75
Command line argument parser.
#define pNOTICE
Definition: Messenger.h:61
double gOptKtonYrExposure
Definition: gAtmoEvGen.cxx:306
string kDefOptGeomDUnits
Definition: gAtmoEvGen.cxx:322
bool gAbortingInErr
Definition: Messenger.cxx:34
double gOptSecExposure
Definition: gAtmoEvGen.cxx:307
double gOptGeomLUnits
Definition: gAtmoEvGen.cxx:302
void PrintSyntax(void)
string gOptExtMaxPlXml
Definition: gAtmoEvGen.cxx:304
bool gOptUsingRootGeom
Definition: gAtmoEvGen.cxx:298
#define pDEBUG
Definition: Messenger.h:63
long int gOptRanSeed
Definition: gAtmoEvGen.cxx:312
GFluxI * GetFlux ( void  )

Definition at line 505 of file gAtmoEvGen.cxx.

506 {
507 #ifdef __GENIE_FLUX_DRIVERS_ENABLED__
508 
509  // Instantiate appropriate concrete flux driver
510  GAtmoFlux * atmo_flux_driver = 0;
511  if(gOptFluxSim == "FLUKA") {
512  GFLUKAAtmoFlux * fluka_flux = new GFLUKAAtmoFlux;
513  atmo_flux_driver = dynamic_cast<GAtmoFlux *>(fluka_flux);
514  } else
515  if(gOptFluxSim == "BGLRS") {
516  GBGLRSAtmoFlux * bartol_flux = new GBGLRSAtmoFlux;
517  atmo_flux_driver = dynamic_cast<GAtmoFlux *>(bartol_flux);
518  } else
519  if(gOptFluxSim == "HAKKM") {
520  GHAKKMAtmoFlux * honda_flux = new GHAKKMAtmoFlux;
521  atmo_flux_driver = dynamic_cast<GAtmoFlux *>(honda_flux);
522  } else {
523  LOG("gevgen_atmo", pFATAL) << "Unknown flux simulation: " << gOptFluxSim;
524  gAbortingInErr = true;
525  exit(1);
526  }
527  // Configure GAtmoFlux options (common to all concrete atmospheric flux drivers)
528  // set min/max energy:
529  atmo_flux_driver->ForceMinEnergy (gOptEvMin * units::GeV);
530  atmo_flux_driver->ForceMaxEnergy (gOptEvMax * units::GeV);
531  // set flux files:
533  for( ; file_iter != gOptFluxFiles.end(); ++file_iter) {
534  int neutrino_code = file_iter->first;
535  string filename = file_iter->second;
536  atmo_flux_driver->AddFluxFile(neutrino_code, filename);
537  }
538 
539  if (!atmo_flux_driver->LoadFluxData()) {
540  LOG("gevgen_atmo", pFATAL) << "Error loading flux data. Quitting...";
541  gAbortingInErr = true;
542  exit(1);
543  }
544 
545  // configure flux generation surface:
546  atmo_flux_driver->SetRadii(gOptRL, gOptRT);
547  // set rotation for coordinate tranformation from the topocentric horizontal
548  // system to a user-defined coordinate system:
549  if(!gOptRot.IsIdentity()) {
550  atmo_flux_driver->SetUserCoordSystem(gOptRot);
551  }
552 
553 #else
554  LOG("gevgen_atmo", pFATAL) << "You need to enable the GENIE flux drivers first!";
555  LOG("gevgen_atmo", pFATAL) << "Use --enable-flux-drivers at the configuration step.";
556  gAbortingInErr = true;
557  exit(1);
558 #endif
559 
560  return atmo_flux_driver;
561 }
map< int, string > gOptFluxFiles
Definition: gAtmoEvGen.cxx:297
TRotation gOptRot
Definition: gAtmoEvGen.cxx:311
double gOptRT
Definition: gAtmoEvGen.cxx:315
#define pFATAL
Definition: Messenger.h:56
intermediate_table::const_iterator const_iterator
void SetRadii(double Rlongitudinal, double Rtransverse)
Definition: GAtmoFlux.cxx:369
double gOptEvMin
Definition: gAtmoEvGen.cxx:308
string filename
Definition: train.py:213
double gOptRL
Definition: gAtmoEvGen.cxx:314
A flux driver for the FLUKA 3-D Atmospheric Neutrino Flux.
string gOptFluxSim
Definition: gAtmoEvGen.cxx:296
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
void ForceMaxEnergy(double emax)
Definition: GAtmoFlux.cxx:233
static constexpr double GeV
Definition: Units.h:28
void SetUserCoordSystem(TRotation &rotation)
Rotation: Topocentric Horizontal -> User-defined Topocentric Coord System.
Definition: GAtmoFlux.cxx:263
double gOptEvMax
Definition: gAtmoEvGen.cxx:309
void AddFluxFile(int neutrino_pdg, string filename)
Definition: GAtmoFlux.cxx:394
A driver for the HAKKM 3-D atmospheric neutrino flux (commonly known as the `Honda flux&#39;) ...
A base class for the FLUKA, BGLRS and ATMNC atmo. nu. flux drivers. The driver depends on data files ...
Definition: GAtmoFlux.h:60
void ForceMinEnergy(double emin)
Definition: GAtmoFlux.cxx:227
bool gAbortingInErr
Definition: Messenger.cxx:34
A flux driver for the Bartol Atmospheric Neutrino Flux.
GeomAnalyzerI * GetGeometry ( void  )

Definition at line 433 of file gAtmoEvGen.cxx.

434 {
435  GeomAnalyzerI * geom_driver = 0;
436 
437 #ifdef __GENIE_GEOM_DRIVERS_ENABLED__
438 
439  if(gOptUsingRootGeom) {
440  //
441  // *** Using a realistic root-based detector geometry description
442  //
443 
444  // creating & configuring a root geometry driver
447  rgeom -> SetLengthUnits (gOptGeomLUnits);
448  rgeom -> SetDensityUnits (gOptGeomDUnits);
449  rgeom -> SetTopVolName (gOptRootGeomTopVol);
450  // getting the bounding box dimensions along z so as to set the
451  // appropriate upstream generation surface for the JPARC flux driver
452  TGeoVolume * topvol = rgeom->GetGeometry()->GetTopVolume();
453  if(!topvol) {
454  LOG("gevgen_atmo", pFATAL) << " ** Null top ROOT geometry volume!";
455  gAbortingInErr = true;
456  exit(1);
457  }
458 
459  /* If flux generation surface isn't defined, get the bounding box for the
460  * geometry and set something appropriate. */
461  TGeoShape *bounding_box = topvol->GetShape();
462  TGeoBBox *box = (TGeoBBox *) bounding_box;
463  double dx = box->GetDX()*rgeom->LengthUnits();
464  double dy = box->GetDY()*rgeom->LengthUnits();
465  double dz = box->GetDZ()*rgeom->LengthUnits();
466 
467  if (gOptRL < 0 && gOptRT < 0) {
468  gOptRL = TMath::Sqrt(dx*dx + dy*dy + dz*dz);
469  gOptRT = gOptRL;
470  LOG("gevgen_atmo", pNOTICE) << "Setting flux longitudinal and transverse radius to " << setprecision(2) << gOptRL << " meters based on bounding box of ROOT geometry.";
471  }
472 
473  // switch on/off volumes as requested
474  if ( (gOptRootGeomTopVol[0] == '+') || (gOptRootGeomTopVol[0] == '-') ) {
475  bool exhaust = (*gOptRootGeomTopVol.c_str() == '+');
477  }
478 
479  // casting to the GENIE geometry driver interface
480  geom_driver = dynamic_cast<GeomAnalyzerI *> (rgeom);
481  }
482  else {
483  //
484  // *** Using a 'point' geometry with the specified target mix
485  // *** ( = a list of targets with their corresponding weight fraction)
486  //
487 
488  // creating & configuring a point geometry driver
491  // casting to the GENIE geometry driver interface
492  geom_driver = dynamic_cast<GeomAnalyzerI *> (pgeom);
493  }
494 
495 #else
496  LOG("gevgen_atmo", pFATAL) << "You need to enable the GENIE geometry drivers first!";
497  LOG("gevgen_atmo", pFATAL) << "Use --enable-geom-drivers at the configuration step.";
498  gAbortingInErr = true;
499  exit(1);
500 #endif
501 
502  return geom_driver;
503 }
double gOptRT
Definition: gAtmoEvGen.cxx:315
#define pFATAL
Definition: Messenger.h:56
double gOptGeomDUnits
Definition: gAtmoEvGen.cxx:303
map< int, double > gOptTgtMix
Definition: gAtmoEvGen.cxx:299
double gOptRL
Definition: gAtmoEvGen.cxx:314
Q_EXPORT QTSManip setprecision(int p)
Definition: qtextstream.h:343
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
string gOptRootGeomTopVol
Definition: gAtmoEvGen.cxx:301
virtual double LengthUnits(void) const
A ROOT/GEANT4 geometry driver.
def bounding_box(wires)
Definition: common.py:15
string gOptRootGeom
Definition: gAtmoEvGen.cxx:300
#define pNOTICE
Definition: Messenger.h:61
Defines the GENIE Geometry Analyzer Interface.
Definition: GeomAnalyzerI.h:29
bool gAbortingInErr
Definition: Messenger.cxx:34
void RecursiveExhaust(TGeoVolume *topvol, string volnames, bool exhaust)
Definition: GeoUtils.cxx:16
double gOptGeomLUnits
Definition: gAtmoEvGen.cxx:302
The PointGeomAnalyzer class is the simplest implementation of the GeomAnalyserI interface and defines...
bool gOptUsingRootGeom
Definition: gAtmoEvGen.cxx:298
virtual TGeoManager * GetGeometry(void) const
int main ( int  argc,
char **  argv 
)

Definition at line 327 of file gAtmoEvGen.cxx.

328 {
329  GAtmoFlux* atmo_flux_driver;
330  double total_flux, expected_neutrinos;
331 
332  // Parse command line arguments
333  GetCommandLineArgs(argc,argv);
334 
335  if ( ! RunOpt::Instance()->Tune() ) {
336  LOG("gmkspl", pFATAL) << " No TuneId in RunOption";
337  exit(-1);
338  }
339  RunOpt::Instance()->BuildTune();
340 
341  // Iinitialization of random number generators, cross-section table, messenger, cache etc...
342  utils::app_init::MesgThresholds(RunOpt::Instance()->MesgThresholdFiles());
343  utils::app_init::CacheFile(RunOpt::Instance()->CacheFile());
346 
347  // get geometry driver
348  GeomAnalyzerI * geom_driver = GetGeometry();
349 
350  if (gOptRT < 0) {
351  gOptRT = 1000; // m
352  LOG("gevgen_atmo", pWARN) << "Warning! Flux surface transverse radius not specified so using default value of " << gOptRT << " meters!";
353  }
354 
355  if (gOptRL < 0) {
356  gOptRL = 1000; // m
357  LOG("gevgen_atmo", pWARN) << "Warning! Flux surface longitudinal radius not specified so using default value of " << gOptRL << " meters!";
358  }
359 
360  // get flux driver
361  atmo_flux_driver = GetFlux();
362 
363  // Cast to GFluxI, the generic flux driver interface
364  GFluxI *flux_driver = dynamic_cast<GFluxI *>(atmo_flux_driver);
365 
366  // create the GENIE monte carlo job driver
367  GMCJDriver* mcj_driver = new GMCJDriver;
368  mcj_driver->SetEventGeneratorList(RunOpt::Instance()->EventGeneratorList());
369  mcj_driver->UseFluxDriver(flux_driver);
370  mcj_driver->UseGeomAnalyzer(geom_driver);
371  mcj_driver->Configure();
372  mcj_driver->UseSplines();
373  /* Note: For the method of calculating the total number of events using a
374  * livetime we *need* to force a single probability scale. So if you change
375  * the next line you need to make sure that the user didn't specify the -T
376  * option. */
377  mcj_driver->ForceSingleProbScale();
378 
379  // initialize an ntuple writer
381  ntpw.CustomizeFilenamePrefix(gOptEvFilePrefix);
382  ntpw.Initialize();
383 
384  // Create a MC job monitor for a periodically updated status file
385  GMCJMonitor mcjmonitor(gOptRunNu);
386  mcjmonitor.SetRefreshRate(RunOpt::Instance()->MCJobStatusRefreshRate());
387 
388  // Set GHEP print level
389  GHepRecord::SetPrintLevel(RunOpt::Instance()->EventRecordPrintLevel());
390 
391  total_flux = atmo_flux_driver->GetTotalFluxInEnergyRange();
392  LOG("gevgen_atmo", pNOTICE) << "Total atmospheric neutrino flux is " << setprecision(2) << total_flux << " neutrinos per m^2 per second.";
393  if (gOptSecExposure > 0) {
394  /* Calculate the expected value of the total number of neutrinos we need to
395  * throw. We do this by multiplying the total flux by the exposure time in
396  * seconds and the area of the flux surface. */
397  expected_neutrinos = total_flux*gOptSecExposure*atmo_flux_driver->GetFluxSurfaceArea();
398  LOG("gevgen_atmo", pNOTICE) << "Simulating an exposure of " << setprecision(0) << gOptSecExposure << " seconds which corresponds to a total of " << setprecision(0) << expected_neutrinos << " neutrinos.";
399  }
400 
401  // event loop
402  for(int iev = 0; gOptNev > 0 ? iev < gOptNev : 1; iev++) {
403 
404  // generate next event
405  EventRecord* event = mcj_driver->GenerateEvent();
406 
407  // print-out
408  LOG("gevgen_atmo", pNOTICE) << "Generated event: " << *event;
409 
410  // save the event, refresh the mc job monitor
411  ntpw.AddEventRecord(iev, event);
412  mcjmonitor.Update(iev,event);
413 
414  // clean-up
415  delete event;
416 
417  if (gOptSecExposure > 0 && mcj_driver->NFluxNeutrinos()/mcj_driver->GlobProbScale() > expected_neutrinos) {
418  break;
419  }
420  }
421 
422  // save the event file
423  ntpw.Save();
424 
425  // clean-up
426  delete geom_driver;
427  delete atmo_flux_driver;
428  delete mcj_driver;
429 
430  return 0;
431 }
void RandGen(long int seed)
Definition: AppInit.cxx:30
void XSecTable(string inpfile, bool require_table)
Definition: AppInit.cxx:38
string gOptEvFilePrefix
Definition: gAtmoEvGen.cxx:310
void SetEventGeneratorList(string listname)
Definition: GMCJDriver.cxx:66
double GetFluxSurfaceArea(void)
Definition: GAtmoFlux.cxx:378
double gOptRT
Definition: gAtmoEvGen.cxx:315
#define pFATAL
Definition: Messenger.h:56
double GetTotalFluxInEnergyRange(void)
Definition: GAtmoFlux.cxx:659
double gOptRL
Definition: gAtmoEvGen.cxx:314
Q_EXPORT QTSManip setprecision(int p)
Definition: qtextstream.h:343
GAtmoFlux * GetFlux(void)
Definition: gAtmoEvGen.cxx:505
void UseFluxDriver(GFluxI *flux)
Definition: GMCJDriver.cxx:83
Simple class to create & update MC job status files and env. vars. This is used to be able to keep tr...
Definition: GMCJMonitor.h:31
A GENIE `MC Job Driver&#39;. Can be used for setting up complicated event generation cases involving deta...
Definition: GMCJDriver.h:46
double GlobProbScale(void) const
Definition: GMCJDriver.h:76
string gOptInpXSecFile
Definition: gAtmoEvGen.cxx:313
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
void ForceSingleProbScale(void)
Definition: GMCJDriver.cxx:172
int gOptNev
Definition: gAtmoEvGen.cxx:305
void Configure(bool calc_prob_scales=true)
Definition: GMCJDriver.cxx:399
#define pWARN
Definition: Messenger.h:60
EventRecord * GenerateEvent(void)
Definition: GMCJDriver.cxx:812
long int NFluxNeutrinos(void) const
Definition: GMCJDriver.h:77
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
A vector of EventGeneratorI objects.
void MesgThresholds(string inpfile)
Definition: AppInit.cxx:99
#define pNOTICE
Definition: Messenger.h:61
void GetCommandLineArgs(int argc, char **argv)
Definition: gAtmoEvGen.cxx:563
Defines the GENIE Geometry Analyzer Interface.
Definition: GeomAnalyzerI.h:29
A base class for the FLUKA, BGLRS and ATMNC atmo. nu. flux drivers. The driver depends on data files ...
Definition: GAtmoFlux.h:60
double gOptSecExposure
Definition: gAtmoEvGen.cxx:307
void UseGeomAnalyzer(GeomAnalyzerI *geom)
Definition: GMCJDriver.cxx:88
void UseSplines(bool useLogE=true)
Definition: GMCJDriver.cxx:93
void CacheFile(string inpfile)
Definition: AppInit.cxx:117
Event finding and building.
GENIE Interface for user-defined flux classes.
Definition: GFluxI.h:29
GeomAnalyzerI * GetGeometry(void)
Definition: gAtmoEvGen.cxx:433
long int gOptRanSeed
Definition: gAtmoEvGen.cxx:312
void PrintSyntax ( void  )

Definition at line 1051 of file gAtmoEvGen.cxx.

1052 {
1053  LOG("gevgen_atmo", pFATAL)
1054  << "\n **Syntax**"
1055  << "\n gevgen_atmo [-h]"
1056  << "\n [-r run#]"
1057  << "\n -f simulation:flux_file[neutrino_code],..."
1058  << "\n -g geometry"
1059  << "\n [-R coordinate_rotation_matrix]"
1060  << "\n [-t geometry_top_volume_name]"
1061  << "\n [-m max_path_lengths_xml_file]"
1062  << "\n [-L geometry_length_units]"
1063  << "\n [-D geometry_density_units]"
1064  << "\n <-n n_of_events,"
1065  << "\n -e exposure_in_kton_x_yrs"
1066  << "\n -T exposure_in_seconds>"
1067  << "\n -E min_energy,max_energy"
1068  << "\n [-o output_event_file_prefix]"
1069  << "\n [--flux-ray-generation-surface-distance]"
1070  << "\n [--flux-ray-generation-surface-radius]"
1071  << "\n [--seed random_number_seed]"
1072  << "\n --cross-sections xml_file"
1073  << "\n [--event-generator-list list_name]"
1074  << "\n [--message-thresholds xml_file]"
1075  << "\n [--unphysical-event-mask mask]"
1076  << "\n [--event-record-print-level level]"
1077  << "\n [--mc-job-status-refresh-rate rate]"
1078  << "\n [--cache-file root_file]"
1079  << "\n"
1080  << " Please also read the detailed documentation at http://www.genie-mc.org"
1081  << "\n";
1082 }
#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

Variable Documentation

string gOptEvFilePrefix

Definition at line 310 of file gAtmoEvGen.cxx.

double gOptEvMax

Definition at line 309 of file gAtmoEvGen.cxx.

double gOptEvMin

Definition at line 308 of file gAtmoEvGen.cxx.

string gOptExtMaxPlXml

Definition at line 304 of file gAtmoEvGen.cxx.

map<int,string> gOptFluxFiles

Definition at line 297 of file gAtmoEvGen.cxx.

string gOptFluxSim

Definition at line 296 of file gAtmoEvGen.cxx.

double gOptGeomDUnits = 0

Definition at line 303 of file gAtmoEvGen.cxx.

double gOptGeomLUnits = 0

Definition at line 302 of file gAtmoEvGen.cxx.

string gOptInpXSecFile

Definition at line 313 of file gAtmoEvGen.cxx.

double gOptKtonYrExposure = -1

Definition at line 306 of file gAtmoEvGen.cxx.

int gOptNev = -1

Definition at line 305 of file gAtmoEvGen.cxx.

long int gOptRanSeed

Definition at line 312 of file gAtmoEvGen.cxx.

double gOptRL = -1

Definition at line 314 of file gAtmoEvGen.cxx.

string gOptRootGeom

Definition at line 300 of file gAtmoEvGen.cxx.

string gOptRootGeomTopVol = ""

Definition at line 301 of file gAtmoEvGen.cxx.

TRotation gOptRot

Definition at line 311 of file gAtmoEvGen.cxx.

double gOptRT = -1

Definition at line 315 of file gAtmoEvGen.cxx.

Long_t gOptRunNu

Definition at line 295 of file gAtmoEvGen.cxx.

double gOptSecExposure = -1

Definition at line 307 of file gAtmoEvGen.cxx.

map<int,double> gOptTgtMix

Definition at line 299 of file gAtmoEvGen.cxx.

bool gOptUsingRootGeom = false

Definition at line 298 of file gAtmoEvGen.cxx.

string kDefOptEvFilePrefix = "gntp"

Definition at line 320 of file gAtmoEvGen.cxx.

double kDefOptEvMax = 50.0

Definition at line 324 of file gAtmoEvGen.cxx.

double kDefOptEvMin = 0.5

Definition at line 323 of file gAtmoEvGen.cxx.

string kDefOptGeomDUnits = "g_cm3"

Definition at line 322 of file gAtmoEvGen.cxx.

string kDefOptGeomLUnits = "mm"

Definition at line 321 of file gAtmoEvGen.cxx.

NtpMCFormat_t kDefOptNtpFormat = kNFGHEP

Definition at line 319 of file gAtmoEvGen.cxx.