diff --git a/FullSimLight/src/FSLDetectorMessenger.cc b/FullSimLight/src/FSLDetectorMessenger.cc index 7fb7236d997c2340388f8c7aab48b5a73c412037..7c31236b0f980db65b4db443d742c93ffe9b9a6d 100644 --- a/FullSimLight/src/FSLDetectorMessenger.cc +++ b/FullSimLight/src/FSLDetectorMessenger.cc @@ -1,57 +1,138 @@ - #include "FSLDetectorMessenger.hh" - #include "FSLDetectorConstruction.hh" #include "G4UIdirectory.hh" #include "G4UIcmdWithADoubleAndUnit.hh" #include "G4UIcmdWithAString.hh" #include "G4UIcmdWithoutParameter.hh" #include "globals.hh" +#include "G4ChordFinder.hh" +#include "G4FieldManager.hh" +#include "G4TransportationManager.hh" +#include "G4MagneticField.hh" +#include "G4IntegrationDriver.hh" +#include "G4VIntegrationDriver.hh" +#include "G4Field.hh" +#include "G4UImanager.hh" +#include "G4UIcommand.hh" +#include "G4UIcontrolMessenger.hh" +#include "G4UIbatch.hh" -FSLDetectorMessenger:: -FSLDetectorMessenger( FSLDetectorConstruction* FSLDet ) - : theDetector( FSLDet ) { +#include "G4RunManager.hh" - theDetectorDir = new G4UIdirectory( "/FSLdet/" ); - theDetectorDir->SetGuidance( "Detector control." ); +FSLDetectorMessenger::FSLDetectorMessenger(FSLDetectorConstruction* FSLDet) + : theDetector(FSLDet) +{ + theDetectorDir = new G4UIdirectory("/FSLdet/"); + theDetectorDir->SetGuidance("Detector control."); - theFieldCommand = new G4UIcmdWithADoubleAndUnit( "/FSLdet/setField", this ); - theFieldCommand->SetGuidance( "Define uniform magnetic field along Z." ); - theFieldCommand->SetGuidance( " -> in unit of [Tesla]" ); - theFieldCommand->SetParameterName( "By", false ); - theFieldCommand->SetDefaultValue( 0.0 ); - theFieldCommand->SetUnitCategory( "Magnetic flux density" ); - theFieldCommand->AvailableForStates( G4State_PreInit, G4State_Idle ); + theFieldCommand = new G4UIcmdWithADoubleAndUnit("/FSLdet/setField", this); + theFieldCommand->SetGuidance("Define uniform magnetic field along Z."); + theFieldCommand->SetGuidance(" -> in unit of [Tesla]"); + theFieldCommand->SetParameterName("By", false); + theFieldCommand->SetDefaultValue(0.0); + theFieldCommand->SetUnitCategory("Magnetic flux density"); + theFieldCommand->AvailableForStates(G4State_PreInit, G4State_Idle); - theGDMLCommand = new G4UIcmdWithAString( "/FSLdet/setGdmlFile", this ); - theGDMLCommand->SetGuidance( "Set the GDML file." ); - theGDMLCommand->SetDefaultValue( "atlas2018.gdml" ); - theGDMLCommand->AvailableForStates( G4State_PreInit, G4State_Idle ); + theGDMLCommand = new G4UIcmdWithAString("/FSLdet/setGdmlFile", this); + theGDMLCommand->SetGuidance("Set the GDML file."); + // theGDMLCommand->SetDefaultValue("atlas2018.gdml"); + theGDMLCommand->AvailableForStates(G4State_PreInit, G4State_Idle); - theRegionCommand = new G4UIcmdWithoutParameter( "/FSLdet/addRegions", this ); - theRegionCommand->SetGuidance( "Try to add detector regions." ); - theRegionCommand->AvailableForStates( G4State_PreInit, G4State_Idle ); + theRegionCommand = new G4UIcmdWithoutParameter("/FSLdet/addRegions", this); + theRegionCommand->SetGuidance("Try to add detector regions."); + theRegionCommand->AvailableForStates(G4State_PreInit, G4State_Idle); -} + // Add commands for deltaIntersection and deltaOneStep + theDeltaIntersectionCommand = new G4UIcmdWithADoubleAndUnit("/FSLdet/setDeltaIntersection", this); + theDeltaIntersectionCommand->SetGuidance("Set deltaIntersection value for tracking."); + theDeltaIntersectionCommand->SetParameterName("deltaIntersection", false); + theDeltaIntersectionCommand->SetUnitCategory("Length"); + theDeltaIntersectionCommand->AvailableForStates(G4State_PreInit, G4State_Idle); + + theDeltaOneStepCommand = new G4UIcmdWithADoubleAndUnit("/FSLdet/setDeltaOneStep", this); + theDeltaOneStepCommand->SetGuidance("Set deltaOneStep value for tracking."); + theDeltaOneStepCommand->SetParameterName("deltaOneStep", false); + theDeltaOneStepCommand->SetUnitCategory("Length"); + theDeltaOneStepCommand->AvailableForStates(G4State_PreInit, G4State_Idle); + + theEpsilonMinCommand = new G4UIcmdWithADoubleAndUnit("/FSLdet/setEpsilonMin", this); + theEpsilonMinCommand->SetGuidance("Set EpsilonMin value for tracking."); + theEpsilonMinCommand->SetParameterName("EpsilonMin", false); + theEpsilonMinCommand->SetUnitCategory("Length"); + theEpsilonMinCommand->AvailableForStates(G4State_PreInit, G4State_Idle); + theEpsilonMaxCommand = new G4UIcmdWithADoubleAndUnit("/FSLdet/setEpsilonMax", this); + theEpsilonMaxCommand->SetGuidance("Set EpsilonMax value for tracking."); + theEpsilonMaxCommand->SetParameterName("EpsilonMax", false); + theEpsilonMaxCommand->SetUnitCategory("Length"); + theEpsilonMaxCommand->AvailableForStates(G4State_PreInit, G4State_Idle); -FSLDetectorMessenger::~FSLDetectorMessenger() { - delete theFieldCommand; - delete theDetectorDir; - delete theRegionCommand; + // Add command for chord length + theDeltaChordCommand = new G4UIcmdWithADoubleAndUnit("/FSLdet/setDeltaChord", this); + theDeltaChordCommand->SetGuidance("Set the DeltaChord length for tracking."); + theDeltaChordCommand->SetParameterName("DeltaChord", false); + theDeltaChordCommand->SetGuidance(" -> in unit of [millimeter]"); + theDeltaChordCommand->SetUnitCategory("Length"); + theDeltaChordCommand->AvailableForStates(G4State_PreInit, G4State_Idle); } +FSLDetectorMessenger::~FSLDetectorMessenger() +{ + delete theFieldCommand; + delete theDetectorDir; + delete theRegionCommand; + delete theDeltaIntersectionCommand; + delete theDeltaOneStepCommand; + delete theEpsilonMinCommand; + delete theEpsilonMaxCommand; + delete theDeltaChordCommand; +} +//////////////////////////////////////////////////////////////// +// +void FSLDetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue) +{ + if (command == theFieldCommand) { + theDetector->SetMagFieldValue(theFieldCommand->GetNewDoubleValue(newValue)); + } + if (command == theGDMLCommand) { + theDetector->SetGDMLFileName(newValue); + } + if (command == theRegionCommand) { + theDetector->SetAddRegions(true); + } -void FSLDetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue) { - if ( command == theFieldCommand ) { - theDetector->SetMagFieldValue( theFieldCommand->GetNewDoubleValue(newValue) ); - } - if ( command == theGDMLCommand ) { - theDetector->SetGDMLFileName( newValue ); - } - if ( command == theRegionCommand ) { - theDetector->SetAddRegions( true ); - } +//////////Adding cmd////// -} + G4FieldManager* fieldMgr = G4TransportationManager::GetTransportationManager()->GetFieldManager(); + if (fieldMgr != nullptr) { + if (command == theDeltaIntersectionCommand) { + fieldMgr->SetDeltaIntersection(theDeltaIntersectionCommand->GetNewDoubleValue(newValue)); + } + if (command == theDeltaOneStepCommand) { + fieldMgr->SetDeltaOneStep(theDeltaOneStepCommand->GetNewDoubleValue(newValue)); + } + if (command == theEpsilonMinCommand) { + fieldMgr->SetMinimumEpsilonStep(theEpsilonMinCommand->GetNewDoubleValue(newValue)); + } + if (command == theEpsilonMaxCommand) { + fieldMgr->SetMaximumEpsilonStep(theEpsilonMaxCommand->GetNewDoubleValue(newValue)); + } + + G4ChordFinder* fChordFinder = fieldMgr->GetChordFinder(); + if (fChordFinder != nullptr) { + if (command == theDeltaChordCommand) +fieldMgr->GetChordFinder()->SetDeltaChord(theDeltaChordCommand->GetNewDoubleValue(newValue)); + +//fieldMgr->GetChordFinder()->SetDeltaChord( fDeltaChord); +//fieldMgr->fDeltaChord = theDeltaChordCommand->GetNewDoubleValue(newValue); +//fChordFinder->SetDeltaChord(fDeltaChord); + + //G4ChordFinder* fChordFinder = fieldMgr->GetChordFinder(); + // if (fChordFinder != nullptr) { + // if (command == theDeltaChordCommand) + // fChordFinder->SetDeltaChord(theDeltaChordCommand->GetNewDoubleValue(newValue)); + // fChordFinder->SetDeltaChord(theDeltaChordCommand->GetNewDoubleValue(newValue)); + } + } + }