From df3d9a801cb4d706501b3b6d3a06ef42697b444f Mon Sep 17 00:00:00 2001
From: nnitika <nnitika@cern.ch>
Date: Mon, 23 Oct 2023 11:51:22 +0200
Subject: [PATCH] modified for DeltaChord and StepMax

---
 FullSimLight/src/FSLDetectorMessenger.cc | 32 ++++++++++++++----------
 1 file changed, 19 insertions(+), 13 deletions(-)

diff --git a/FullSimLight/src/FSLDetectorMessenger.cc b/FullSimLight/src/FSLDetectorMessenger.cc
index 7c31236b0..994590f57 100644
--- a/FullSimLight/src/FSLDetectorMessenger.cc
+++ b/FullSimLight/src/FSLDetectorMessenger.cc
@@ -17,7 +17,8 @@
 #include "G4UIcommand.hh"
 #include "G4UIcontrolMessenger.hh"
 #include "G4UIbatch.hh"
-
+#include "G4StepLimiter.hh"
+#include "G4UserLimits.hh"
 #include "G4RunManager.hh"
 
 FSLDetectorMessenger::FSLDetectorMessenger(FSLDetectorConstruction* FSLDet)
@@ -75,6 +76,15 @@ FSLDetectorMessenger::FSLDetectorMessenger(FSLDetectorConstruction* FSLDet)
     theDeltaChordCommand->SetGuidance(" -> in unit of [millimeter]");
     theDeltaChordCommand->SetUnitCategory("Length");
     theDeltaChordCommand->AvailableForStates(G4State_PreInit, G4State_Idle);
+    
+  
+theStepMaxCommand = new G4UIcmdWithADoubleAndUnit("/FSLdet/StepMax", this);
+theStepMaxCommand->SetGuidance("Define a step max");
+theStepMaxCommand->SetParameterName("StepMax", false); // Changed "theStepMax" to "StepMax"
+theStepMaxCommand->SetUnitCategory("Length");
+theStepMaxCommand->AvailableForStates(G4State_PreInit, G4State_Idle);
+
+  
 }
 
 FSLDetectorMessenger::~FSLDetectorMessenger()
@@ -87,6 +97,7 @@ FSLDetectorMessenger::~FSLDetectorMessenger()
     delete theEpsilonMinCommand;
     delete theEpsilonMaxCommand;
     delete theDeltaChordCommand;
+    delete theStepMaxCommand;
 }
 ////////////////////////////////////////////////////////////////
 //
@@ -101,7 +112,12 @@ void FSLDetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
     if (command == theRegionCommand) {
         theDetector->SetAddRegions(true);
     }
-
+    if (command == theStepMaxCommand) {
+           // G4double newStepMax = theStepMaxCommand->GetNewDoubleValue(newValue);
+            //theDetector->SetStepMax(newStepMax);
+            theDetector->SetStepMax(theStepMaxCommand->GetNewDoubleValue(newValue));
+	}
+	
 //////////Adding cmd//////
 
     G4FieldManager* fieldMgr = G4TransportationManager::GetTransportationManager()->GetFieldManager();
@@ -118,21 +134,11 @@ void FSLDetectorMessenger::SetNewValue(G4UIcommand* command, G4String 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));
          }
        }
      }
-- 
GitLab