Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions Pinpoint/Pinpoint.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions Pinpoint/include/PrimaryGeneratorAction.hh
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ class PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction

void GeneratePrimaries(G4Event* anEvent) override;
void SetGenerator(G4String name);
static void SetFirstEvent(G4int firstEvent) { fFirstEvent = firstEvent; }

private:

PrimaryGeneratorMessenger* fGenMessenger;
GeneratorBase* fGenerator;
G4bool fInitialized;

static G4long fFirstEvent;
};

#endif
2 changes: 1 addition & 1 deletion Pinpoint/include/generators/GFaserGeneratorMessenger.hh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class GFaserGeneratorMessenger: public G4UImessenger

G4UIdirectory* fGFaserGeneratorDir;
G4UIcmdWithAString* fInputFileCmd;
G4UIcmdWithAnInteger* fFirstEventCmd;
// G4UIcmdWithAnInteger* fFirstEventCmd;
G4UIcmdWithABool* fUseFixedZPositionCmd;
};

Expand Down
2 changes: 1 addition & 1 deletion Pinpoint/macros/test.mac
Original file line number Diff line number Diff line change
Expand Up @@ -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

# ======================================================
Expand Down
2 changes: 1 addition & 1 deletion Pinpoint/src/DetectorConstruction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(100.0*cm / fLayerThickness); // maximum layers allowed
auto maxLayers = static_cast<int>(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;
Expand Down
10 changes: 8 additions & 2 deletions Pinpoint/src/PrimaryGeneratorAction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "G4Event.hh"
#include "G4Exception.hh"

G4long PrimaryGeneratorAction::fFirstEvent = -1;

PrimaryGeneratorAction::PrimaryGeneratorAction()
{
Expand All @@ -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" )
Expand Down
14 changes: 7 additions & 7 deletions Pinpoint/src/generators/GFaserGeneratorMessenger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -33,16 +33,16 @@ GFaserGeneratorMessenger::GFaserGeneratorMessenger(GFaserGenerator* action)
GFaserGeneratorMessenger::~GFaserGeneratorMessenger()
{
delete fInputFileCmd;
delete fFirstEventCmd;
// delete fFirstEventCmd;
delete fGFaserGeneratorDir;
}


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));
}