Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:22:22

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 
0027 #include "OpNoviceDetectorMessenger.hh"
0028 
0029 #include "OpNoviceDetectorConstruction.hh"
0030 #include "OpNoviceGDMLDetectorConstruction.hh"
0031 
0032 #include "G4UIcmdWithABool.hh"
0033 #include "G4UIcmdWithAString.hh"
0034 #include "G4UIdirectory.hh"
0035 
0036 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0037 
0038 OpNoviceDetectorMessenger::OpNoviceDetectorMessenger(G4VUserDetectorConstruction* detcon)
0039   : G4UImessenger(), fOpNoviceDetCon(detcon)
0040 {
0041   fDetConDir = new G4UIdirectory("/OpNovice/DetectorConstruction/");
0042   fDetConDir->SetGuidance("Configuring Detector Construction");
0043 
0044   fVerboseCmd = new G4UIcmdWithABool("/OpNovice/DetectorConstruction/enableVerbose", this);
0045   fVerboseCmd->SetGuidance("Set flag for enabling verbose diagnostic printout");
0046   fVerboseCmd->SetDefaultValue(false);
0047   fVerboseCmd->AvailableForStates(G4State_PreInit);
0048 
0049   fDumpGdmlCmd = new G4UIcmdWithABool("/OpNovice/DetectorConstruction/dumpGdml", this);
0050   fDumpGdmlCmd->SetGuidance("Set flag for enabling dumping the detector to a gdml file");
0051   fDumpGdmlCmd->SetDefaultValue(false);
0052   fDumpGdmlCmd->AvailableForStates(G4State_PreInit);
0053 
0054   fDumpGdmlFileNameCmd =
0055     new G4UIcmdWithAString("/OpNovice/DetectorConstruction/dumpGdmlFileName", this);
0056   fDumpGdmlFileNameCmd->SetGuidance("Enter file name to dump gdml file ");
0057   fDumpGdmlFileNameCmd->SetDefaultValue("OpNovice_dump.gdml");
0058   fDumpGdmlFileNameCmd->AvailableForStates(G4State_PreInit);
0059 }
0060 
0061 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0062 
0063 OpNoviceDetectorMessenger::~OpNoviceDetectorMessenger()
0064 {
0065   delete fDetConDir;
0066   delete fVerboseCmd;
0067   delete fDumpGdmlCmd;
0068   delete fDumpGdmlFileNameCmd;
0069 }
0070 
0071 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0072 
0073 void OpNoviceDetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
0074 {
0075   auto dc1 = dynamic_cast<OpNoviceDetectorConstruction*>(fOpNoviceDetCon);
0076   if (dc1 != nullptr) {
0077     if (command == fVerboseCmd) dc1->SetVerbose(fVerboseCmd->GetNewBoolValue(newValue));
0078     if (command == fDumpGdmlCmd) dc1->SetDumpGdml(fDumpGdmlCmd->GetNewBoolValue(newValue));
0079     if (command == fDumpGdmlFileNameCmd) dc1->SetDumpGdmlFile(newValue);
0080   }
0081   else {
0082     auto dc2 = dynamic_cast<OpNoviceGDMLDetectorConstruction*>(fOpNoviceDetCon);
0083     if (command == fVerboseCmd) dc2->SetVerbose(fVerboseCmd->GetNewBoolValue(newValue));
0084     if (command == fDumpGdmlCmd) dc2->SetDumpGdml(fDumpGdmlCmd->GetNewBoolValue(newValue));
0085     if (command == fDumpGdmlFileNameCmd) dc2->SetDumpGdmlFile(newValue);
0086   }
0087 }
0088 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......