Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-08 07:53:51

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 /// \file OpNoviceDetectorMessenger.cc
0027 /// \brief Implementation of the OpNoviceDetectorMessenger class
0028 
0029 #include "OpNoviceDetectorMessenger.hh"
0030 
0031 #include "OpNoviceDetectorConstruction.hh"
0032 #include "OpNoviceGDMLDetectorConstruction.hh"
0033 
0034 #include "G4UIcmdWithABool.hh"
0035 #include "G4UIcmdWithAString.hh"
0036 #include "G4UIdirectory.hh"
0037 
0038 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0039 
0040 OpNoviceDetectorMessenger::OpNoviceDetectorMessenger(G4VUserDetectorConstruction* detcon)
0041   : G4UImessenger(), fOpNoviceDetCon(detcon)
0042 {
0043   fDetConDir = new G4UIdirectory("/OpNovice/DetectorConstruction/");
0044   fDetConDir->SetGuidance("Configuring Detector Construction");
0045 
0046   fVerboseCmd = new G4UIcmdWithABool("/OpNovice/DetectorConstruction/enableVerbose", this);
0047   fVerboseCmd->SetGuidance("Set flag for enabling verbose diagnostic printout");
0048   fVerboseCmd->SetDefaultValue(false);
0049   fVerboseCmd->AvailableForStates(G4State_PreInit);
0050 
0051   fDumpGdmlCmd = new G4UIcmdWithABool("/OpNovice/DetectorConstruction/dumpGdml", this);
0052   fDumpGdmlCmd->SetGuidance("Set flag for enabling dumping the detector to a gdml file");
0053   fDumpGdmlCmd->SetDefaultValue(false);
0054   fDumpGdmlCmd->AvailableForStates(G4State_PreInit);
0055 
0056   fDumpGdmlFileNameCmd =
0057     new G4UIcmdWithAString("/OpNovice/DetectorConstruction/dumpGdmlFileName", this);
0058   fDumpGdmlFileNameCmd->SetGuidance("Enter file name to dump gdml file ");
0059   fDumpGdmlFileNameCmd->SetDefaultValue("OpNovice_dump.gdml");
0060   fDumpGdmlFileNameCmd->AvailableForStates(G4State_PreInit);
0061 }
0062 
0063 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0064 
0065 OpNoviceDetectorMessenger::~OpNoviceDetectorMessenger()
0066 {
0067   delete fDetConDir;
0068   delete fVerboseCmd;
0069   delete fDumpGdmlCmd;
0070   delete fDumpGdmlFileNameCmd;
0071 }
0072 
0073 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0074 
0075 void OpNoviceDetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
0076 {
0077   auto dc1 = dynamic_cast<OpNoviceDetectorConstruction*>(fOpNoviceDetCon);
0078   if (dc1 != nullptr) {
0079     if (command == fVerboseCmd) dc1->SetVerbose(fVerboseCmd->GetNewBoolValue(newValue));
0080     if (command == fDumpGdmlCmd) dc1->SetDumpGdml(fDumpGdmlCmd->GetNewBoolValue(newValue));
0081     if (command == fDumpGdmlFileNameCmd) dc1->SetDumpGdmlFile(newValue);
0082   }
0083   else {
0084     auto dc2 = dynamic_cast<OpNoviceGDMLDetectorConstruction*>(fOpNoviceDetCon);
0085     if (command == fVerboseCmd) dc2->SetVerbose(fVerboseCmd->GetNewBoolValue(newValue));
0086     if (command == fDumpGdmlCmd) dc2->SetDumpGdml(fDumpGdmlCmd->GetNewBoolValue(newValue));
0087     if (command == fDumpGdmlFileNameCmd) dc2->SetDumpGdmlFile(newValue);
0088   }
0089 }
0090 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......