From ec7ce5589f5432e5728e38fc3ed26088a64c1940 Mon Sep 17 00:00:00 2001 From: nnitika <nnitika@cern.ch> Date: Tue, 11 Jul 2023 19:39:24 +0200 Subject: [PATCH] modified for parameter opt. --- FullSimLight/src/FSLDetectorConstruction.cc | 146 +++++++++++++++----- 1 file changed, 111 insertions(+), 35 deletions(-) diff --git a/FullSimLight/src/FSLDetectorConstruction.cc b/FullSimLight/src/FSLDetectorConstruction.cc index a253ab31a..3d6d90f0f 100644 --- a/FullSimLight/src/FSLDetectorConstruction.cc +++ b/FullSimLight/src/FSLDetectorConstruction.cc @@ -31,7 +31,35 @@ #include "G4GDMLParser.hh" //#include "G4LogicalVolumeStore.hh" + #include <algorithm> + +//chord +//#include "G4MagneticField.hh" +//#include "G4IntegrationDriver.hh" +//#include "G4VIntegrationDriver.hh" +//#include "G4MagIntegratorStepper.hh" +#include "G4Field.hh" +#include "G4VIntegrationDriver.hh" +#include "G4VIntegrationDriver.hh" +#include "G4FSALIntegrationDriver.hh" +#include "G4VFSALIntegrationStepper.hh" +#include "G4RK547FEq1.hh" +// #include "G4RK547FEq2.hh" +// #include "G4RK547FEq3.hh" +#include "G4NystromRK4.hh" + +// New FSAL type driver / steppers ----- +#include "G4IntegrationDriver.hh" +#include "G4InterpolationDriver.hh" +// #include "G4FSALBogackiShampine45.hh" +// #include "G4FSALDormandPrince745.hh" +#include "G4HelixHeum.hh" +#include "G4BFieldIntegrationDriver.hh" + +#include <cassert> + + // Geant4 steppers #if G4VERSION_NUMBER>=1040 #include "G4BogackiShampine23.hh" @@ -83,9 +111,48 @@ #include "G4LogicalVolume.hh" #include "G4SDManager.hh" +#include "G4UIcommand.hh" #include <iomanip> +// + +#include <iomanip> + +//#include "G4ChordFinder.hh" +#include "G4SystemOfUnits.hh" +#include "G4MagneticField.hh" +#include "G4Mag_UsualEqRhs.hh" +#include "G4MagIntegratorDriver.hh" +// #include "G4ClassicalRK4.hh" +// #include "G4CashKarpRKF45.hh" +// #include "G4BogackiShampine23.hh" +// #include "G4BogackiShampine45.hh" +#include "G4DormandPrince745.hh" + +// New FSAL type driver / steppers ----- +#include "G4FSALIntegrationDriver.hh" +#include "G4VFSALIntegrationStepper.hh" +#include "G4RK547FEq1.hh" +// #include "G4RK547FEq2.hh" +// #include "G4RK547FEq3.hh" +#include "G4NystromRK4.hh" + +// New FSAL type driver / steppers ----- +#include "G4IntegrationDriver.hh" +#include "G4InterpolationDriver.hh" +// #include "G4FSALBogackiShampine45.hh" +// #include "G4FSALDormandPrince745.hh" +#include "G4HelixHeum.hh" +#include "G4BFieldIntegrationDriver.hh" + +#include "G4PropagatorInField.hh" + +#include <cassert> + +// + + G4AnalysisManager* FSLDetectorConstruction::fAnalysisManager = nullptr; G4double FSLDetectorConstruction::gFieldValue = 0.0; @@ -106,7 +173,6 @@ FSLDetectorConstruction::FSLDetectorConstruction() : fWorld(nullptr), fDetectorM fMinStep = 1.0e-2; fField.Put(0); fOutputGDMLFileName = "geometry.gdml"; - } FSLDetectorConstruction::~FSLDetectorConstruction() @@ -368,43 +434,53 @@ void FSLDetectorConstruction::ConstructSDandField() } - - - - if (fFieldConstant && std::abs(fFieldValue) > 0.0){ +if (fFieldConstant && std::abs(fFieldValue) > 0.0) { // Apply a global uniform magnetic field along the Z axis. // Notice that only if the magnetic field is not zero, the Geant4 // transportation in field gets activated. - auto uniformMagField = new G4UniformMagField(G4ThreeVector(0.0, 0.0, fFieldValue)); + auto uniformMagField = new G4UniformMagField(G4ThreeVector(0.0, 0.0, fFieldValue)); G4FieldManager *fieldMgr = G4TransportationManager::GetTransportationManager()->GetFieldManager(); fieldMgr->SetDetectorField(uniformMagField); fieldMgr->CreateChordFinder(uniformMagField); - G4cout << G4endl << " *** SETTING UNIFORM MAGNETIC FIELD : fieldValue = " << fFieldValue / tesla << " Tesla *** " << G4endl - << G4endl; +//fieldMgr->GetChordFinder()->SetDeltaChord( fDeltaChord); +///////////////////////////////////////////DeltaChord(mm) Parameter Set//////////////////// +//fieldMgr->GetChordFinder()->SetDeltaChord( 0.001); //DeltaChord(mm) Parameter Set 1 +//fieldMgr->GetChordFinder()->SetDeltaChord( 0.1); //DeltaChord(mm) Parameter Set 2 +fieldMgr->GetChordFinder()->SetDeltaChord( 0.002); //DeltaChord(mm) Parameter Set 3 + + + G4cout << G4endl << " *** SETTING UNIFORM MAGNETIC FIELD : fieldValue = " << fFieldValue / tesla << " Tesla *** " << G4endl << G4endl; + // G4cout << " Chord Length: " << fieldMgr->GetChordFinder()->GetDeltaChord() / mm << " mm" << G4endl; +} +else if (fFieldConstant && fFieldValue == 0.0) { + G4cout << G4endl << " *** MAGNETIC FIELD IS OFF *** " << G4endl << G4endl; +} +else { + G4cout << G4endl << " *** MAGNETIC FIELD SET FROM PLUGIN *** " << G4endl << G4endl; + if (fField.Get() == 0) { + GeoPluginLoader<MagFieldPlugin> loader; + MagFieldPlugin *plugin = loader.load(mag_field_plugin_path); + G4MagneticField *g4Field = plugin->getField(); + delete plugin; + if (g4Field == nullptr) { + std::cout << "Error, g4Field is null!" << std::endl; + } + fField.Put(g4Field); } - else if (fFieldConstant && fFieldValue == 0.0 ){ - G4cout << G4endl << " *** MAGNETIC FIELD IS OFF *** " << G4endl << G4endl; - } - else // if (!fFieldConstant) - { - G4cout << G4endl << " *** MAGNETIC FIELD SET FROM PLUGIN *** " << G4endl << G4endl; - if (fField.Get() == 0) - { - { - GeoPluginLoader<MagFieldPlugin> loader; - MagFieldPlugin *plugin=loader.load(mag_field_plugin_path); - G4MagneticField *g4Field=plugin->getField(); - delete plugin; - if(g4Field==nullptr) std::cout<<"Error, g4Field is null!"<<std::endl; - fField.Put(g4Field); - } - - //This is thread-local - G4FieldManager* fieldMgr = - G4TransportationManager::GetTransportationManager()->GetFieldManager(); - G4cout<< "DeltaStep "<<fieldMgr->GetDeltaOneStep()/mm <<"mm" <<G4endl; - //G4ChordFinder *pChordFinder = new G4ChordFinder(FSLmagField); +} + + +// This is thread-local +//To print the values of parameters +G4FieldManager *fieldMgr = G4TransportationManager::GetTransportationManager()->GetFieldManager(); +G4cout << "DeltaIntersection " << fieldMgr->GetDeltaIntersection() / mm << " mm" << G4endl; +G4cout << "DeltaOneStep " << fieldMgr->GetDeltaOneStep() / mm << " mm" << G4endl; +G4cout << "EpsilonMin: " << fieldMgr->GetMinimumEpsilonStep() / mm << " mm" << G4endl; +G4cout << "EpsilonMax: " << fieldMgr->GetMaximumEpsilonStep() / mm << " mm" << G4endl; +G4cout << "Delta Chord Length: " << fieldMgr->GetChordFinder()->GetDeltaChord() / mm << " mm" << G4endl; + + } //#if G4VERSION_NUMBER < 1040 // @@ -417,15 +493,15 @@ void FSLDetectorConstruction::ConstructSDandField() // auto driver = createDriverAndStepper(m_integratorStepper, field); // chordFinder->SetIntegrationDriver(driver); - fieldMgr->SetDetectorField(fField.Get()); - fieldMgr->CreateChordFinder(fField.Get()); + // fieldMgr->SetDetectorField(fField.Get()); + // fieldMgr->CreateChordFinder(fField.Get()); //#endif - } + // } - } -} +// } +//} #if G4VERSION_NUMBER>=1040 //============================================================================= // Create the driver with a stepper -- GitLab