From e572b120194b4593e98b500507cfb3acc6c69768 Mon Sep 17 00:00:00 2001 From: Tobias Boeckh Date: Tue, 9 Dec 2025 15:55:15 +0100 Subject: [PATCH 1/2] Change maximum thickness to 150 cm --- Pinpoint/src/DetectorConstruction.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Pinpoint/src/DetectorConstruction.cc b/Pinpoint/src/DetectorConstruction.cc index bf9d2dd..163b5bf 100644 --- a/Pinpoint/src/DetectorConstruction.cc +++ b/Pinpoint/src/DetectorConstruction.cc @@ -178,7 +178,7 @@ G4VPhysicalVolume* DetectorConstruction::Construct() if(sim_flag == 0) { fLayerThickness = 2.0*fTungstenThickness + fBoxThickness + fSiliconThickness + fScintThickness;} //pixel + single scintillator, TPTSTPTS... if(sim_flag == 1) { fLayerThickness = 2.0*fTungstenThickness + fBoxThickness + fSiliconThickness + 2.0*fScintThickness;} //pixel + double scintillator, TPTSSTPTSS... //auto fLayerThickness = fTungstenThickness + fBoxThickness + fSiliconThickness; - auto maxLayers = static_cast(100.0*cm / fLayerThickness); // maximum layers allowed + auto maxLayers = static_cast(150.0*cm / fLayerThickness); // maximum layers allowed if(fNLayers > maxLayers) { G4cout << "Warning: Reducing number of layers from " << fNLayers << " to " << maxLayers << " to keep detector thickness <= 100 cm." << G4endl; From 95d25782c2c9de0b1d6c8e22325d7dee21ae9e51 Mon Sep 17 00:00:00 2001 From: Tobias Boeckh Date: Tue, 9 Dec 2025 17:47:21 +0100 Subject: [PATCH 2/2] Add command line argument to set first event --- Pinpoint/Pinpoint.cc | 12 ++++++++++-- Pinpoint/include/PrimaryGeneratorAction.hh | 2 ++ .../include/generators/GFaserGeneratorMessenger.hh | 2 +- Pinpoint/macros/test.mac | 2 +- Pinpoint/src/PrimaryGeneratorAction.cc | 10 ++++++++-- .../src/generators/GFaserGeneratorMessenger.cc | 14 +++++++------- 6 files changed, 29 insertions(+), 13 deletions(-) diff --git a/Pinpoint/Pinpoint.cc b/Pinpoint/Pinpoint.cc index 25b52ad..7d83a58 100644 --- a/Pinpoint/Pinpoint.cc +++ b/Pinpoint/Pinpoint.cc @@ -17,6 +17,7 @@ // allow ourselves to give the user extra info about available physics ctors #include "G4PhysicsConstructorFactory.hh" +#include "PrimaryGeneratorAction.hh" // forward declaration void PrintAvailable(G4int verb = 1); @@ -32,10 +33,13 @@ int main(int argc, char** argv) { // pick physics list std::string physListName = "FTFP_BERT+PY8DK"; - - for (G4int i = 1; i < argc; i = i + 2) { + G4long firstEvent = -1; // -1 indicates not set via command line + for (G4int i = 0; i < argc; i = i + 2) { G4String g4argv(argv[i]); // convert only once if (g4argv == "-p") physListName = argv[i + 1]; + else if (g4argv == "-f" || g4argv == "--firstEvent") { + firstEvent = std::atol(argv[i + 1]); + } } // Choose the Random engine @@ -87,6 +91,10 @@ int main(int argc, char** argv) { G4UImanager* UImanager = G4UImanager::GetUIpointer(); + if (firstEvent >= 0) { + PrimaryGeneratorAction::SetFirstEvent(firstEvent); + } + // Parse command line arguments if (argc==1) { G4UIExecutive* ui = new G4UIExecutive(argc, argv); diff --git a/Pinpoint/include/PrimaryGeneratorAction.hh b/Pinpoint/include/PrimaryGeneratorAction.hh index 82f786e..93f2b97 100644 --- a/Pinpoint/include/PrimaryGeneratorAction.hh +++ b/Pinpoint/include/PrimaryGeneratorAction.hh @@ -15,6 +15,7 @@ class PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction void GeneratePrimaries(G4Event* anEvent) override; void SetGenerator(G4String name); + static void SetFirstEvent(G4int firstEvent) { fFirstEvent = firstEvent; } private: @@ -22,6 +23,7 @@ class PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction GeneratorBase* fGenerator; G4bool fInitialized; + static G4long fFirstEvent; }; #endif diff --git a/Pinpoint/include/generators/GFaserGeneratorMessenger.hh b/Pinpoint/include/generators/GFaserGeneratorMessenger.hh index 1d2431d..e63a8f2 100644 --- a/Pinpoint/include/generators/GFaserGeneratorMessenger.hh +++ b/Pinpoint/include/generators/GFaserGeneratorMessenger.hh @@ -23,7 +23,7 @@ class GFaserGeneratorMessenger: public G4UImessenger G4UIdirectory* fGFaserGeneratorDir; G4UIcmdWithAString* fInputFileCmd; - G4UIcmdWithAnInteger* fFirstEventCmd; + // G4UIcmdWithAnInteger* fFirstEventCmd; G4UIcmdWithABool* fUseFixedZPositionCmd; }; diff --git a/Pinpoint/macros/test.mac b/Pinpoint/macros/test.mac index dc19070..645968c 100644 --- a/Pinpoint/macros/test.mac +++ b/Pinpoint/macros/test.mac @@ -49,7 +49,7 @@ # Primary generator: gfaser /gen/select gfaser /gen/gfaser/inputFile /eos/project/f/fasersim-bonn/public/dhruv/pinpoint_local/geant4Input/tungsten_5mm_pixel_5mm_scint_5mm_single_bar/nutau_775_795.root # <-- set actual path -/gen/gfaser/firstEvent 0 +# /gen/gfaser/firstEvent 0 /gen/gfaser/useFixedZPosition true # ====================================================== diff --git a/Pinpoint/src/PrimaryGeneratorAction.cc b/Pinpoint/src/PrimaryGeneratorAction.cc index 38b7d65..aa4d611 100644 --- a/Pinpoint/src/PrimaryGeneratorAction.cc +++ b/Pinpoint/src/PrimaryGeneratorAction.cc @@ -12,6 +12,7 @@ #include "G4Event.hh" #include "G4Exception.hh" +G4long PrimaryGeneratorAction::fFirstEvent = -1; PrimaryGeneratorAction::PrimaryGeneratorAction() { @@ -36,8 +37,13 @@ void PrimaryGeneratorAction::SetGenerator(G4String name) if( name == "genie" ) fGenerator = new GENIEGenerator(); - else if ( name == "gfaser" ) - fGenerator = new GFaserGenerator(); + else if ( name == "gfaser" ) { + GFaserGenerator* gfaserGen = new GFaserGenerator(); + if (fFirstEvent >= 0) { + gfaserGen->SetFirstEvent(fFirstEvent); + } + fGenerator = gfaserGen; + } else if( name == "hepmc" ) fGenerator = new HepMCGenerator(); else if ( name == "gun" ) diff --git a/Pinpoint/src/generators/GFaserGeneratorMessenger.cc b/Pinpoint/src/generators/GFaserGeneratorMessenger.cc index 85a6a6c..3f1b96c 100644 --- a/Pinpoint/src/generators/GFaserGeneratorMessenger.cc +++ b/Pinpoint/src/generators/GFaserGeneratorMessenger.cc @@ -18,10 +18,10 @@ GFaserGeneratorMessenger::GFaserGeneratorMessenger(GFaserGenerator* action) fInputFileCmd->SetGuidance("set input filename of the gfaser generator"); fInputFileCmd->AvailableForStates(G4State_PreInit, G4State_Init, G4State_Idle); - fFirstEventCmd = new G4UIcmdWithAnInteger("/gen/gfaser/firstEvent", this); - fFirstEventCmd->SetGuidance("set the index of the first event in the *.gfaser.root file"); - fFirstEventCmd->SetDefaultValue((G4int)0); - fFirstEventCmd->AvailableForStates(G4State_PreInit, G4State_Idle); + // fFirstEventCmd = new G4UIcmdWithAnInteger("/gen/gfaser/firstEvent", this); + // fFirstEventCmd->SetGuidance("set the index of the first event in the *.gfaser.root file"); + // fFirstEventCmd->SetDefaultValue((G4int)0); + // fFirstEventCmd->AvailableForStates(G4State_PreInit, G4State_Idle); fUseFixedZPositionCmd = new G4UIcmdWithABool("/gen/gfaser/useFixedZPosition", this); fUseFixedZPositionCmd->SetGuidance("set whether to use a fixed Z position for the neutrino vertex"); @@ -33,7 +33,7 @@ GFaserGeneratorMessenger::GFaserGeneratorMessenger(GFaserGenerator* action) GFaserGeneratorMessenger::~GFaserGeneratorMessenger() { delete fInputFileCmd; - delete fFirstEventCmd; + // delete fFirstEventCmd; delete fGFaserGeneratorDir; } @@ -41,8 +41,8 @@ GFaserGeneratorMessenger::~GFaserGeneratorMessenger() void GFaserGeneratorMessenger::SetNewValue(G4UIcommand* command, G4String newValues) { if (command == fInputFileCmd) fGFaserAction->SetInputFileName(newValues); - else if (command == fFirstEventCmd) - fGFaserAction->SetFirstEvent(fFirstEventCmd->GetNewIntValue(newValues)); + // else if (command == fFirstEventCmd) + // fGFaserAction->SetFirstEvent(fFirstEventCmd->GetNewIntValue(newValues)); else if (command == fUseFixedZPositionCmd) fGFaserAction->SetUseFixedZPosition(fUseFixedZPositionCmd->GetNewBoolValue(newValues)); }