diff --git a/LHCbG4Tests/G4GammaToDiLeptonConversionTest/G4GammaToDiLeptonConversionTest.cc b/LHCbG4Tests/G4GammaToDiLeptonConversionTest/G4GammaToDiLeptonConversionTest.cc index e7dde52b04aa9b1f5c9bb0fdde95fad2b2a78f00..6c998cace94191abe9d948514b4c5a6420815f01 100644 --- a/LHCbG4Tests/G4GammaToDiLeptonConversionTest/G4GammaToDiLeptonConversionTest.cc +++ b/LHCbG4Tests/G4GammaToDiLeptonConversionTest/G4GammaToDiLeptonConversionTest.cc @@ -64,6 +64,8 @@ G4double thickness = 0.3; //in mm G4String dimu_xsec_fac = "1000"; +G4String output_dir = "."; + //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -97,8 +99,14 @@ int main(int argc,char** argv) { ++i; } + if(G4String(argv[i]) == "--outputdir") + { + ++i; + output_dir = G4String(argv[i]); + ++i; + } + } - //choose the Random engine CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine); @@ -120,7 +128,7 @@ int main(int argc,char** argv) { //set user action classes RunAction* RunAct; - runManager->SetUserAction(RunAct = new RunAction(det, energy, thickness, nEvts)); + runManager->SetUserAction(RunAct = new RunAction(det, energy, thickness, nEvts, output_dir)); runManager->SetUserAction(new SteppingAction(RunAct)); runManager->SetUserAction(new StackingAction); diff --git a/LHCbG4Tests/G4GammaToDiLeptonConversionTest/include/RunAction.hh b/LHCbG4Tests/G4GammaToDiLeptonConversionTest/include/RunAction.hh index 6d942a4ebded18dca99ed68b28dfcf8aa4c7ff6d..4ef4d39a9792f93d6b4431abb1f0705065e8314c 100644 --- a/LHCbG4Tests/G4GammaToDiLeptonConversionTest/include/RunAction.hh +++ b/LHCbG4Tests/G4GammaToDiLeptonConversionTest/include/RunAction.hh @@ -51,14 +51,14 @@ class G4Run; class RunAction : public G4UserRunAction { public: - RunAction(DetectorConstruction*, G4double, G4double, G4int); + RunAction(DetectorConstruction*, G4double, G4double, G4int, G4String); ~RunAction(); public: - void BeginOfRunAction(const G4Run*) override; - void EndOfRunAction(const G4Run*) override; - void CountProcesses(G4String); - + virtual void BeginOfRunAction(const G4Run*); + virtual void EndOfRunAction(const G4Run*); + void CountProcesses(G4String); + private: DetectorConstruction* fDetector; ProcessesCount* fProcCounter; diff --git a/LHCbG4Tests/G4GammaToDiLeptonConversionTest/scripts/G4GammaToDiLeptonConversionTest.py b/LHCbG4Tests/G4GammaToDiLeptonConversionTest/scripts/G4GammaToDiLeptonConversionTest.py index 15e4f52fb71e2eb1d38fe79ea89219a37e29c53b..a3af22003ec69fed34c9f9f2ed603d6522b18f91 100644 --- a/LHCbG4Tests/G4GammaToDiLeptonConversionTest/scripts/G4GammaToDiLeptonConversionTest.py +++ b/LHCbG4Tests/G4GammaToDiLeptonConversionTest/scripts/G4GammaToDiLeptonConversionTest.py @@ -16,6 +16,7 @@ parser.add_argument("--energies", default="[1000]", help="Energies List") parser.add_argument("--thickness", default="[0.3]", help="List of thicknesses") parser.add_argument("--scale", default="100000", help="Scale DiMuon Conversion Cross Section by factor") parser.add_argument("--debug", default=False, action="store_true", help="Debug Mode") +parser.add_argument("--outputdir", default="G4GammaCVTestROOTFiles", help="Output Location") args = parser.parse_args() @@ -39,6 +40,9 @@ except TypeError: _logger.error("Invalid Input for Number of Events") exit(0) +_logger.debug("Creating Test Output Directory...") + +subprocess.check_call("mkdir -p {}".format(args.outputdir), shell=True) for energy in energies: for t in thickness: @@ -46,17 +50,18 @@ for energy in energies: "\n\tNumber of Events :\t%s "+ "\n\tBeam Energy :\t%s GeV"+ "\n\tTarget Thickness :\t%s mm"+ - "\n\tDiMuon XSec Scale Factor :\t%s\n", - '='*40, args.nevts, energy, t, args.scale) + "\n\tDiMuon XSec Scale Factor :\t%s"+ + "\n\tOutput Directory :\t%s\n", + '='*40, args.nevts, energy, t, args.scale, args.outputdir) _logger.info('='*40) - subprocess.check_call("G4GammaToDiLeptonConversionTest.exe --nevts {} --energy {} --thickness {} --scale {}".format(args.nevts, energy, t, args.scale), shell=True) - + subprocess.check_call("G4GammaToDiLeptonConversionTest.exe --nevts {} --energy {}".format(args.nevts, energy) + + " --thickness {} --scale {} --outputdir {}".format(t, args.scale, args.outputdir), shell=True) _logger.info("Creating Single Combined Plots ROOT File...") import ROOT -_output = ROOT.TFile.Open("G4GammaToDiLeptonConversionTest.root", "NEW") +_output = ROOT.TFile.Open("G4GammaCVTestROOTFiles/G4GammaToDiLeptonConversionTest.root", "NEW") _histo_dim_dict = {'DiElectron' : {'Hist' : {'InvMass' : (100, 0, 100), 'ThetaSep' : (50, 0, 6E-4), @@ -73,8 +78,8 @@ _histo_dim_dict = {'DiElectron' : {'Hist' : {'InvMass' : (100, 0, 100), for energy in energies: for t in thickness: - _logger.debug("Opening file '%s'", "TestEM6_Al_{}mm_{}GeV_{}.root".format(t, energy, args.nevts)) - _tmp = ROOT.TFile.Open("TestEM6_Al_{}mm_{}GeV_{}.root".format(t, energy, args.nevts)) + _logger.debug("Opening file '%s'", "{}/TestEM6_Al_{}mm_{}GeV_{}.root".format(args.outputdir, t, energy, args.nevts)) + _tmp = ROOT.TFile.Open("{}/TestEM6_Al_{}mm_{}GeV_{}.root".format(args.outputdir, t, energy, args.nevts)) for particle in _histo_dim_dict.keys(): _logger.debug("Attempting to retrieve TTree '%s'", particle) diff --git a/LHCbG4Tests/G4GammaToDiLeptonConversionTest/src/RunAction.cc b/LHCbG4Tests/G4GammaToDiLeptonConversionTest/src/RunAction.cc index dfc52a0c86a6bdaf00cf36bb17e66d00ca53a037..8ba8a0f73b41b12eba8074df76b4c3d8a75c45a9 100644 --- a/LHCbG4Tests/G4GammaToDiLeptonConversionTest/src/RunAction.cc +++ b/LHCbG4Tests/G4GammaToDiLeptonConversionTest/src/RunAction.cc @@ -51,11 +51,12 @@ //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -RunAction::RunAction(DetectorConstruction* det, G4double e, G4double t, G4int n) +RunAction::RunAction(DetectorConstruction* det, G4double e, G4double t, G4int n, G4String dir) : G4UserRunAction(),fDetector(det),fProcCounter(0),fAnalysis(0),fMat(0) { std::stringstream file_name; - file_name << "TestEM6_Al_"; + file_name << dir; + file_name << "/TestEM6_Al_"; file_name << t; file_name << "mm_"; file_name << e;