LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
GENIEHelper.h
Go to the documentation of this file.
1 #ifndef EVGB_GENIEHELPER_H
9 #define EVGB_GENIEHELPER_H
10 
11 #include <vector>
12 #include <set>
13 
14 
15 // GENIE
16 namespace genie {
17  class GFluxI;
18  class GeomAnalyzerI;
19  class GMCJDriver;
20 }
21 
22 // ROOT
23 class TH1D;
24 class TH2D;
25 class TF1;
26 class TRandom3;
27 class TRotation;
28 class TGeoManager;
29 #include "TVector3.h"
30 
32 namespace fhicl {
33  class ParameterSet;
34 }
35 
37 namespace ifdh_ns {
38  class ifdh;
39 }
40 
41 namespace simb {
42  class MCTruth;
43  class MCFlux;
44  class GTruth;
45 }
46 
48 namespace genie { class EventRecord; }
49 
50 namespace evgb {
51 
52  class EvtTimeShiftI; // for shifting time within a spill
53 
54  class GENIEHelper {
55 
56  public:
57 
58  explicit GENIEHelper(fhicl::ParameterSet const& pset,
59  TGeoManager* rootGeom,
60  std::string const& rootFile,
61  double const& detectorMass);
62  ~GENIEHelper();
63 
64  void Initialize();
65  bool Stop();
66  bool Sample(simb::MCTruth &truth,
67  simb::MCFlux &flux,
68  simb::GTruth &gtruth);
69 
70  double TotalHistFlux();
71  double TotalExposure() const { return fTotalExposure; }
72 
73  // Call the following method before calling Stop, otherwise fSpillExposure
74  // will be reset to 0
75  double SpillExposure() const { return fSpillExposure; }
76  std::string FluxType() const { return fFluxType; }
77  std::string DetectorLocation() const { return fDetLocation; }
78 
79  // methods for checking the various algorithms in GENIEHelper - please
80  // do not use these in your code!!!!!
81  std::vector<TH1D*> FluxHistograms() const { return fFluxHistograms; }
82  double TotalMass() const { return fDetectorMass+fSurroundingMass; }
83 
84  genie::EventRecord * GetGenieEventRecord() { return fGenieEventRecord; }
85 
86  // access the random number generator that is supplying additional values for helper
87  TRandom3* GetHelperRandom() { return fHelperRandom; }
88 
89  // direct access to flux driver ... no ownership handover
90  // base is the "real" flux driver, might be wrapped by a flavor mixer
91  genie::GFluxI* GetFluxDriver(bool base = true )
92  { return ( (base) ? fFluxD : fFluxD2GMCJD ); }
93 
94  // these might be updated after parsing the parameter set in init()
95  std::string GetTuneName() const { return fTuneName; }
96  std::string GetEventGeneratorList() const { return fEventGeneratorList; }
97 
98  private:
99 
100  void RegularizeFluxType();
101  void SqueezeFilePatterns();
102  void AtmoFluxCheck();
103  void HistogramFluxCheck();
104 
105  void InitializeGeometry();
106  void InitializeFiducialSelection();
107  void InitializeRockBoxSelection();
108  void InitializeFluxDriver();
109  void ConfigGeomScan();
110  void SetMaxPathOutInfo();
111 
112  void BuildFluxRotation();
113  void ExpandFluxPaths();
114  void ExpandFluxFilePatternsDirect();
115  void ExpandFluxFilePatternsIFDH();
116  bool StringToBool(std::string v);
117 
118  void SetGXMLPATH();
119  void SetGMSGLAYOUT();
120  void StartGENIEMessenger(std::string prodmode);
121  void ReadXSecTable();
122 
123  TGeoManager* fGeoManager;
124  std::string fGeoFile;
125 
126  genie::EventRecord* fGenieEventRecord;
127  genie::GeomAnalyzerI* fGeomD;
128  genie::GFluxI* fFluxD;
129  genie::GFluxI* fFluxD2GMCJD;
130  genie::GMCJDriver* fDriver;
131 
132  // for now leave this here ... but not necessary when using IFDH_service
133  ifdh_ns::ifdh* fIFDH;
134 
135  TRandom3* fHelperRandom;
138 
139  std::string fFluxType;
140 
142  std::string fFluxSearchPaths;
143  std::vector<std::string> fFluxFilePatterns;
144  std::vector<std::string> fSelectedFluxFiles;
147  std::string fFluxCopyMethod;
148  std::string fFluxCleanup;
149  std::string fBeamName;
150  std::string fFluxRotCfg;
151  std::vector<double> fFluxRotValues;
152  TRotation* fFluxRotation;
153 
154  std::string fTopVolume;
155  std::string fWorldVolume;
156  std::string fDetLocation;
157  std::vector<TH1D *> fFluxHistograms;
158 
159  double fFluxUpstreamZ;
161  double fPOTPerSpill;
165  double fSpillExposure;
166  double fTotalExposure;
167  double fMonoEnergy;
168  std::string fFunctionalFlux;
170  double fEmin;
171  double fEmax;
172  double fXSecMassPOT;
173  double fTotalHistFlux;
174  TVector3 fBeamDirection;
175  TVector3 fBeamCenter;
176  double fBeamRadius;
177  double fDetectorMass;
179  double fGlobalTimeOffset;
182  std::string fSpillTimeConfig;
185 
186  std::vector<int> fGenFlavors;
187  double fAtmoEmin;
188  double fAtmoEmax;
189  double fAtmoRl;
190  double fAtmoRt;
191  double fAtmoSpectralIndex;
193 
194  std::vector<std::string> fEnvironment;
195  std::string fXSecTable;
196  std::string fTuneName;
197  std::string fEventGeneratorList;
198  std::string fGXMLPATH;
199  std::string fGMSGLAYOUT;
200  std::string fGENIEMsgThresholds;
202  std::string fMixerConfig;
203  double fMixerBaseline;
205  std::string fFiducialCut;
206  std::string fGeomScan;
207  std::string fMaxPathOutInfo;
208  unsigned int fDebugFlags;
209  };
210 }
211 #endif //EVGB_GENIEHELPER_H
genie::GFluxI * GetFluxDriver(bool base=true)
Definition: GENIEHelper.h:91
std::vector< std::string > fFluxFilePatterns
wildcard patterns files containing histograms or ntuples, or txt
Definition: GENIEHelper.h:143
std::string FluxType() const
Definition: GENIEHelper.h:76
bool fUseHelperRndGen4GENIE
use fHelperRandom for gRandom during Sample()
Definition: GENIEHelper.h:136
double fEventsPerSpill
Definition: GENIEHelper.h:160
std::string fDetLocation
name of flux window location
Definition: GENIEHelper.h:156
double fAtmoEmax
atmo: Maximum energy of neutrinos in GeV
Definition: GENIEHelper.h:188
int fMaxFluxFileNumber
maximum # of flux files
Definition: GENIEHelper.h:146
double fMixerBaseline
baseline distance if genie flux can&#39;t calculate it
Definition: GENIEHelper.h:203
std::string fTuneName
GENIE R-3 Tune name (defines model configuration)
Definition: GENIEHelper.h:196
IFDH interface (data handling) ... if using bare interface.
Definition: GENIEHelper.h:37
GENIE neutrino interaction simulation objects.
Definition: GENIE2ART.h:19
double fTotalHistFlux
total flux of neutrinos from flux histograms for used flavors
Definition: GENIEHelper.h:173
ifdh_ns::ifdh * fIFDH
(optional) flux file handling
Definition: GENIEHelper.h:133
std::string fGXMLPATH
locations for GENIE XML files
Definition: GENIEHelper.h:198
std::string fFiducialCut
configuration for geometry selector
Definition: GENIEHelper.h:205
std::string DetectorLocation() const
Definition: GENIEHelper.h:77
genie::EventRecord * GetGenieEventRecord()
Definition: GENIEHelper.h:84
void Initialize()
Definition: errprop.cc:100
double fRandomTimeOffset
additional random time shift (ns) added to every particle time
Definition: GENIEHelper.h:181
TVector3 fBeamCenter
center of beam for histogram fluxes - must be in meters
Definition: GENIEHelper.h:175
std::string fSpillTimeConfig
alternative to flat spill distribution
Definition: GENIEHelper.h:182
std::string fEventGeneratorList
control over event topologies, was $GEVGL [Default]
Definition: GENIEHelper.h:197
TGeoManager * fGeoManager
pointer to ROOT TGeoManager
Definition: GENIEHelper.h:123
std::string fGENIEMsgThresholds
additional XML file setting Messager level thresholds (":" separated)
Definition: GENIEHelper.h:200
std::vector< int > fGenFlavors
pdg codes for flavors to generate
Definition: GENIEHelper.h:186
evgb::EvtTimeShiftI * fTimeShifter
generator for time offset within a spill
Definition: GENIEHelper.h:137
genie::GMCJDriver * fDriver
Definition: GENIEHelper.h:130
double fXSecMassPOT
product of cross section, mass and POT/spill for histogram fluxes
Definition: GENIEHelper.h:172
std::vector< std::string > fSelectedFluxFiles
flux files selected after wildcard expansion and subset selection
Definition: GENIEHelper.h:144
genie::EventRecord * fGenieEventRecord
last generated event
Definition: GENIEHelper.h:126
double TotalMass() const
Definition: GENIEHelper.h:82
std::string fXSecTable
cross section file (was $GSPLOAD)
Definition: GENIEHelper.h:195
double fFluxUpstreamZ
z where flux starts from (if non-default, simple/ntuple only)
Definition: GENIEHelper.h:159
std::vector< TH1D * > fFluxHistograms
histograms for each nu species
Definition: GENIEHelper.h:157
interface for event time distribution
Definition: EvtTimeShiftI.h:29
double fSurroundingMass
Definition: GENIEHelper.h:178
double SpillExposure() const
Definition: GENIEHelper.h:75
int fGHepPrintLevel
GHepRecord::SetPrintLevel(), -1=no-print.
Definition: GENIEHelper.h:201
std::string fFluxRotCfg
how to interpret fFluxRotValues
Definition: GENIEHelper.h:150
TVector3 fBeamDirection
direction of the beam for histogram fluxes
Definition: GENIEHelper.h:174
std::string fBeamName
name of the beam we are simulating
Definition: GENIEHelper.h:149
std::string fWorldVolume
name of the world volume in the ROOT geometry
Definition: GENIEHelper.h:155
bool fForceApplyFlxWgt
apply GFluxI::Weight() before returning event
Definition: GENIEHelper.h:184
double fTotalExposure
pot used from flux ntuple
Definition: GENIEHelper.h:166
TRandom3 * fHelperRandom
random # generator for GENIEHelper
Definition: GENIEHelper.h:135
parameter set interface
std::string fTopVolume
top volume in the ROOT geometry in which to generate events
Definition: GENIEHelper.h:154
std::string GetEventGeneratorList() const
Definition: GENIEHelper.h:96
bool fUseBlenderDist
get neutrino&#39;s travel distance from blender (default: true)
Definition: GENIEHelper.h:204
std::vector< TH1D * > FluxHistograms() const
Definition: GENIEHelper.h:81
genie::GeomAnalyzerI * fGeomD
Definition: GENIEHelper.h:127
std::string fFluxSearchPaths
colon separated set of path stems
Definition: GENIEHelper.h:142
std::string fGMSGLAYOUT
format for GENIE log message [BASIC]|SIMPLE (SIMPLE=no timestamps)
Definition: GENIEHelper.h:199
ART objects.
double fBeamRadius
radius of cylindar for histogram fluxes - must be in meters
Definition: GENIEHelper.h:176
std::string fMixerConfig
configuration string for genie GFlavorMixerI
Definition: GENIEHelper.h:202
genie::GFluxI * fFluxD
real flux driver
Definition: GENIEHelper.h:128
bool fAddGenieVtxTime
incorporate time from flux window to interaction point and (possibily) proton-on-target to flux windo...
Definition: GENIEHelper.h:183
double fMonoEnergy
energy of monoenergetic neutrinos
Definition: GENIEHelper.h:167
double fDetectorMass
mass of the detector in kg
Definition: GENIEHelper.h:177
std::vector< double > fFluxRotValues
parameters for rotation
Definition: GENIEHelper.h:151
TRandom3 * GetHelperRandom()
Definition: GENIEHelper.h:87
std::vector< std::string > fEnvironment
environmental variables and settings used by genie
Definition: GENIEHelper.h:194
double TotalExposure() const
Definition: GENIEHelper.h:71
std::string fMaxPathOutInfo
output info if writing PathLengthList from GeomScan
Definition: GENIEHelper.h:207
double fSpillExposure
total exposure (i.e. pot) for this spill
Definition: GENIEHelper.h:165
double fAtmoEmin
atmo: Minimum energy of neutrinos in GeV
Definition: GENIEHelper.h:187
std::string fGeoFile
name of file containing the Geometry description
Definition: GENIEHelper.h:124
double fAtmoRl
atmo: radius of the sphere on where the neutrinos are generated
Definition: GENIEHelper.h:189
std::string GetTuneName() const
Definition: GENIEHelper.h:95
unsigned int fDebugFlags
set bits to enable debug info
Definition: GENIEHelper.h:208
Physics generators for neutrinos, cosmic rays, and others.
Definition: CRYHelper.cxx:33
std::string fFluxCopyMethod
"DIRECT" = old direct access method, otherwise = ifdh approach schema ("" okay)
Definition: GENIEHelper.h:147
std::string fFluxCleanup
"ALWAYS", "/var/tmp", "NEVER"
Definition: GENIEHelper.h:148
Event generator information.
Definition: MCTruth.h:32
double fHistEventsPerSpill
number of events per spill for histogram fluxes - changes each spill
Definition: GENIEHelper.h:163
TRotation * fFluxRotation
rotation for atmos / astro flux coord systems
Definition: GENIEHelper.h:152
std::string fGeomScan
configuration for geometry scan to determine max pathlengths
Definition: GENIEHelper.h:206
int fSpillEvents
total events for this spill
Definition: GENIEHelper.h:164
genie::GFluxI * fFluxD2GMCJD
flux driver passed to genie GMCJDriver, might be GFluxBlender
Definition: GENIEHelper.h:129
std::string fFunctionalFlux
Definition: GENIEHelper.h:168
int fMaxFluxFileMB
maximum size of flux files (MB)
Definition: GENIEHelper.h:145
std::string fFluxType
Definition: GENIEHelper.h:139