diff --git a/FSL/src/fsl_mainwindow.cpp b/FSL/src/fsl_mainwindow.cpp index 506601d1003af416f639c373402efdcf004bafe6..fd9fe9f042796662d4116959fa7c895c022e8f8c 100644 --- a/FSL/src/fsl_mainwindow.cpp +++ b/FSL/src/fsl_mainwindow.cpp @@ -73,6 +73,8 @@ FSLMainWindow::FSLMainWindow(QWidget *parent) connect(ui->pB_main_clear, &QPushButton::released, this, &FSLMainWindow::clear_main_status); connect(ui->pB_pythia_browse, &QPushButton::released, this, &FSLMainWindow::assign_pythia_file); connect(ui->pB_magnetic_field_plugin, &QPushButton::released, this, &FSLMainWindow::assign_magnetic_field_plugin_file); + connect(ui->pB_magnetic_field_map, &QPushButton::released, this, &FSLMainWindow::assign_magnetic_field_map); + connect(ui->pB_add_sens_det, &QPushButton::released, this, &FSLMainWindow::add_sens_det); connect(ui->pB_del_sens_det, &QPushButton::released, this, &FSLMainWindow::del_sens_det); @@ -105,7 +107,7 @@ FSLMainWindow::FSLMainWindow(QWidget *parent) ui->cB_particle->setCurrentIndex(0); ui->pB_pythia_browse->setEnabled(false); ui->cB_pythia_type_of_eve->setEnabled(false); - ui->lE_magnetic_field_map->setEnabled(false); + ui->pB_magnetic_field_map->setEnabled(false); ui->pB_magnetic_field_plugin->setEnabled(false); ui->cB_particle->setCurrentIndex(0); ui->lE_px->setText("0"); @@ -652,6 +654,11 @@ void FSLMainWindow::assign_magnetic_field_plugin_file() magnetic_field_plugin_file = this->get_file_name(); } +void FSLMainWindow::assign_magnetic_field_map() +{ + magnetic_field_map = this->get_file_name(); +} + //Function to configure particle energy and direction void FSLMainWindow::configure_energy_direction() { @@ -738,7 +745,7 @@ void FSLMainWindow::configure_magnetic_field() magnetic_field = (ui->lE_fixed_MF->text()).toStdString(); magnetic_field_plugin_file = ""; magnetic_field_map = ""; - ui->lE_magnetic_field_map->setEnabled(false); + ui->pB_magnetic_field_map->setEnabled(false); ui->pB_magnetic_field_plugin->setEnabled(false); ui->lE_fixed_MF->setEnabled(true); @@ -749,11 +756,11 @@ void FSLMainWindow::configure_magnetic_field() else { - magnetic_field_map = (ui->lE_magnetic_field_map->text()).toStdString(); + // magnetic_field_map = (ui->lE_magnetic_field_map->text()).toStdString(); magnetic_field = ""; ui->lE_fixed_MF->setEnabled(false); - ui->lE_magnetic_field_map->setEnabled(true); + ui->pB_magnetic_field_map->setEnabled(true); ui->pB_magnetic_field_plugin->setEnabled(true); } } @@ -1118,19 +1125,19 @@ void FSLMainWindow::load_configuration() magnetic_field_plugin_file = ""; - ui->lE_magnetic_field_map->clear(); - ui->lE_magnetic_field_map->setEnabled(false); + magnetic_field_map = ""; + ui->pB_magnetic_field_map->setEnabled(false); ui->pB_magnetic_field_plugin->setEnabled(false); } else{ - ui->lE_magnetic_field_map->setEnabled(true); + ui->pB_magnetic_field_map->setEnabled(true); ui->pB_magnetic_field_plugin->setEnabled(true); ui->cB_magnetic_field->setCurrentIndex(1); magnetic_field_plugin_file = j_load["Magnetic Field Plugin"]; magnetic_field_map = j_load["Magnetic Field Map"]; - ui->lE_magnetic_field_map->setText(QString::fromUtf8(magnetic_field_map.c_str())); + // ui->lE_magnetic_field_map->setText(QString::fromUtf8(magnetic_field_map.c_str())); magnetic_field = ""; ui->lE_fixed_MF->clear(); diff --git a/FSL/src/fsl_mainwindow.h b/FSL/src/fsl_mainwindow.h index aca7f1cd7979f7000f9883779a13fd426075ba2b..83a6b7e9bfb3e7d94aa2789b446e44ec17be4c36 100644 --- a/FSL/src/fsl_mainwindow.h +++ b/FSL/src/fsl_mainwindow.h @@ -156,6 +156,7 @@ public: void assign_geom_file(); void assign_pythia_file(); void assign_magnetic_field_plugin_file(); + void assign_magnetic_field_map(); void assign_shape_ext_file(); void assign_run_actions_file(); diff --git a/FSL/src/fsl_mainwindow.ui b/FSL/src/fsl_mainwindow.ui index 0907291f77b72515390284ee42ab17c9f0d80f76..5cc4044258c3be3788a2e1e9d9911a75da4cc719 100644 --- a/FSL/src/fsl_mainwindow.ui +++ b/FSL/src/fsl_mainwindow.ui @@ -995,44 +995,44 @@ <property name="title"> <string>Map</string> </property> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <item> - <layout class="QGridLayout" name="gridLayout_3"> - <item row="0" column="1" colspan="2"> - <widget class="QLineEdit" name="lE_magnetic_field_map"/> - </item> - <item row="1" column="0" colspan="2"> - <widget class="QLabel" name="label_21"> - <property name="font"> - <font> - <pointsize>15</pointsize> - </font> - </property> - <property name="text"> - <string>Magnetic Field Plugin</string> - </property> - </widget> - </item> - <item row="1" column="2"> - <widget class="QPushButton" name="pB_magnetic_field_plugin"> - <property name="text"> - <string>Browse Files</string> - </property> - </widget> - </item> - <item row="0" column="0"> - <widget class="QLabel" name="label_7"> - <property name="font"> - <font> - <pointsize>15</pointsize> - </font> - </property> - <property name="text"> - <string>Magnetic Field Map</string> - </property> - </widget> - </item> - </layout> + <layout class="QGridLayout" name="gridLayout_3"> + <item row="0" column="1"> + <widget class="QPushButton" name="pB_magnetic_field_map"> + <property name="text"> + <string>Browse Files</string> + </property> + </widget> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="label_7"> + <property name="font"> + <font> + <pointsize>15</pointsize> + </font> + </property> + <property name="text"> + <string>Magnetic Field Map</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QPushButton" name="pB_magnetic_field_plugin"> + <property name="text"> + <string>Browse Files</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_21"> + <property name="font"> + <font> + <pointsize>15</pointsize> + </font> + </property> + <property name="text"> + <string>Magnetic Field Plugin</string> + </property> + </widget> </item> </layout> </widget> @@ -1558,7 +1558,7 @@ <x>0</x> <y>0</y> <width>1261</width> - <height>22</height> + <height>24</height> </rect> </property> <widget class="QMenu" name="menuFile"> diff --git a/FullSimLight/fullSimLight.cc b/FullSimLight/fullSimLight.cc index b83348fed43ed3870230e4fabb4a5a9df3dca949..820f9ad95fff69bb45dc76551ce6753d81c91dbf 100644 --- a/FullSimLight/fullSimLight.cc +++ b/FullSimLight/fullSimLight.cc @@ -244,7 +244,11 @@ int main(int argc, char** argv) { detector->SetGeometryFileName (simConfig::fsl.geometry); runManager->SetUserInitialization(detector); - if(simConfig::fsl.magFieldType=="Map") detector->SetMagFieldPluginPath(simConfig::fsl.magFieldPlugin); + if(simConfig::fsl.magFieldType=="Map") + { + detector->SetMagFieldPluginPath(simConfig::fsl.magFieldPlugin); + detector->SetMagFieldMapPath(simConfig::fsl.magFieldMap); + } //parse RegionsData for (const auto& element : simConfig::jf["Regions data"]){ diff --git a/FullSimLight/include/FSLDetectorConstruction.hh b/FullSimLight/include/FSLDetectorConstruction.hh index 64e4e4176bfb5546e0448068884f53107d03c408..aa3836edf34e14165619946a9ce09197edb3846f 100644 --- a/FullSimLight/include/FSLDetectorConstruction.hh +++ b/FullSimLight/include/FSLDetectorConstruction.hh @@ -66,6 +66,7 @@ public: void AddSensitiveDetectorPlugin(const std::string & SDPluginName) { sensitiveDetectorPluginName.push_back(SDPluginName);} void SetMagFieldPluginPath(const std::string MFPluginName) {mag_field_plugin_path = MFPluginName;} + void SetMagFieldMapPath(const std::string MFPathName){mag_field_map_path = MFPathName;} static G4double GetFieldValue() { return gFieldValue; } G4double GetTolerance (){return fTolerance;} @@ -106,7 +107,7 @@ private: std::vector<std::string> sensitiveDetectorPluginName; std::string mag_field_plugin_path; - + std::string mag_field_map_path; }; #endif diff --git a/FullSimLight/include/MagFieldPlugin.h b/FullSimLight/include/MagFieldPlugin.h index 37f0e1ae3001b1ce0ebd6bfcb11f234df411eeb8..eb2f0af05f8385af563408685673fca94266f2c0 100644 --- a/FullSimLight/include/MagFieldPlugin.h +++ b/FullSimLight/include/MagFieldPlugin.h @@ -11,7 +11,7 @@ class MagFieldPlugin { // Destructor virtual ~MagFieldPlugin()=default; - virtual G4MagneticField *getField() const=0; + virtual G4MagneticField *getField(std::string map_path) =0; private: diff --git a/FullSimLight/src/FSLDetectorConstruction.cc b/FullSimLight/src/FSLDetectorConstruction.cc index 94f68f04819e574088ba2a8c082c9f6979ab0981..562b499a56880f7e856c09a97beb41a3386ccd0b 100644 --- a/FullSimLight/src/FSLDetectorConstruction.cc +++ b/FullSimLight/src/FSLDetectorConstruction.cc @@ -420,7 +420,7 @@ void FSLDetectorConstruction::ConstructSDandField() { GeoPluginLoader<MagFieldPlugin> loader; MagFieldPlugin *plugin=loader.load(mag_field_plugin_path); - G4MagneticField *g4Field=plugin->getField(); + G4MagneticField *g4Field=plugin->getField(mag_field_map_path); delete plugin; if(g4Field==nullptr) std::cout<<"Error, g4Field is null!"<<std::endl; fField.Put(g4Field);