Back to home page

EIC code displayed by LXR

 
 

    


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

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 optical/OpNovice2/src/DetectorMessenger.cc
0027 /// \brief Implementation of the DetectorMessenger class
0028 //
0029 //
0030 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0031 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0032 
0033 #include "DetectorMessenger.hh"
0034 
0035 #include "DetectorConstruction.hh"
0036 
0037 #include "G4OpticalSurface.hh"
0038 #include "G4UIcmdWithADouble.hh"
0039 #include "G4UIcmdWithADoubleAndUnit.hh"
0040 #include "G4UIcmdWithAString.hh"
0041 #include "G4UIcmdWithAnInteger.hh"
0042 #include "G4UIcmdWithoutParameter.hh"
0043 #include "G4UIcommand.hh"
0044 #include "G4UIdirectory.hh"
0045 #include "G4UIparameter.hh"
0046 
0047 #include <iostream>
0048 #include <sstream>
0049 
0050 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0051 
0052 DetectorMessenger::DetectorMessenger(DetectorConstruction* Det) : G4UImessenger(), fDetector(Det)
0053 {
0054   fOpticalDir = new G4UIdirectory("/opnovice2/");
0055   fOpticalDir->SetGuidance("Parameters for optical simulation.");
0056 
0057   fSurfaceTypeCmd = new G4UIcmdWithAString("/opnovice2/surfaceType", this);
0058   fSurfaceTypeCmd->SetGuidance("Surface type.");
0059   fSurfaceTypeCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0060   fSurfaceTypeCmd->SetToBeBroadcasted(false);
0061 
0062   fSurfaceFinishCmd = new G4UIcmdWithAString("/opnovice2/surfaceFinish", this);
0063   fSurfaceFinishCmd->SetGuidance("Surface finish.");
0064   fSurfaceFinishCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0065   fSurfaceFinishCmd->SetToBeBroadcasted(false);
0066 
0067   fSurfaceModelCmd = new G4UIcmdWithAString("/opnovice2/surfaceModel", this);
0068   fSurfaceModelCmd->SetGuidance("surface model.");
0069   fSurfaceModelCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0070   fSurfaceModelCmd->SetToBeBroadcasted(false);
0071 
0072   fSurfaceSigmaAlphaCmd = new G4UIcmdWithADouble("/opnovice2/surfaceSigmaAlpha", this);
0073   fSurfaceSigmaAlphaCmd->SetGuidance("surface sigma alpha");
0074   fSurfaceSigmaAlphaCmd->SetGuidance(" parameter.");
0075   fSurfaceSigmaAlphaCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0076   fSurfaceSigmaAlphaCmd->SetToBeBroadcasted(false);
0077 
0078   fSurfacePolishCmd = new G4UIcmdWithADouble("/opnovice2/surfacePolish", this);
0079   fSurfacePolishCmd->SetGuidance("surface polish");
0080   fSurfacePolishCmd->SetGuidance(" parameter (for Glisur model).");
0081   fSurfacePolishCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0082   fSurfacePolishCmd->SetToBeBroadcasted(false);
0083 
0084   fSurfaceMatPropVectorCmd = new G4UIcmdWithAString("/opnovice2/surfaceProperty", this);
0085   fSurfaceMatPropVectorCmd->SetGuidance("Set material property vector");
0086   fSurfaceMatPropVectorCmd->SetGuidance(" for the surface.");
0087   fSurfaceMatPropVectorCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0088   fSurfaceMatPropVectorCmd->SetToBeBroadcasted(false);
0089 
0090   fSurfaceMatPropConstCmd = new G4UIcmdWithAString("/opnovice2/surfaceConstProperty", this);
0091   fSurfaceMatPropConstCmd->SetGuidance("Set material constant property");
0092   fSurfaceMatPropConstCmd->SetGuidance(" for the surface.");
0093   fSurfaceMatPropConstCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0094   fSurfaceMatPropConstCmd->SetToBeBroadcasted(false);
0095 
0096   fTankMatPropVectorCmd = new G4UIcmdWithAString("/opnovice2/boxProperty", this);
0097   fTankMatPropVectorCmd->SetGuidance("Set material property vector for ");
0098   fTankMatPropVectorCmd->SetGuidance("the box.");
0099   fTankMatPropVectorCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0100   fTankMatPropVectorCmd->SetToBeBroadcasted(false);
0101 
0102   fTankMatPropConstCmd = new G4UIcmdWithAString("/opnovice2/boxConstProperty", this);
0103   fTankMatPropConstCmd->SetGuidance("Set material constant property ");
0104   fTankMatPropConstCmd->SetGuidance("for the box.");
0105   fTankMatPropConstCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0106   fTankMatPropConstCmd->SetToBeBroadcasted(false);
0107 
0108   fTankMaterialCmd = new G4UIcmdWithAString("/opnovice2/boxMaterial", this);
0109   fTankMaterialCmd->SetGuidance("Set material of box.");
0110   fTankMaterialCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0111   fTankMaterialCmd->SetToBeBroadcasted(false);
0112 
0113   fWorldMatPropVectorCmd = new G4UIcmdWithAString("/opnovice2/worldProperty", this);
0114   fWorldMatPropVectorCmd->SetGuidance("Set material property vector ");
0115   fWorldMatPropVectorCmd->SetGuidance("for the world.");
0116   fWorldMatPropVectorCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0117   fWorldMatPropVectorCmd->SetToBeBroadcasted(false);
0118 
0119   fWorldMatPropConstCmd = new G4UIcmdWithAString("/opnovice2/worldConstProperty", this);
0120   fWorldMatPropConstCmd->SetGuidance("Set material constant property");
0121   fWorldMatPropConstCmd->SetGuidance(" for the world.");
0122   fWorldMatPropConstCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0123   fWorldMatPropConstCmd->SetToBeBroadcasted(false);
0124 
0125   fWorldMaterialCmd = new G4UIcmdWithAString("/opnovice2/worldMaterial", this);
0126   fWorldMaterialCmd->SetGuidance("Set material of world.");
0127   fWorldMaterialCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0128   fWorldMaterialCmd->SetToBeBroadcasted(false);
0129 }
0130 
0131 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0132 
0133 DetectorMessenger::~DetectorMessenger()
0134 {
0135   delete fOpticalDir;
0136   delete fSurfaceFinishCmd;
0137   delete fSurfaceTypeCmd;
0138   delete fSurfaceModelCmd;
0139   delete fSurfaceSigmaAlphaCmd;
0140   delete fSurfacePolishCmd;
0141   delete fSurfaceMatPropVectorCmd;
0142   delete fSurfaceMatPropConstCmd;
0143   delete fTankMatPropVectorCmd;
0144   delete fTankMatPropConstCmd;
0145   delete fTankMaterialCmd;
0146   delete fWorldMatPropVectorCmd;
0147   delete fWorldMatPropConstCmd;
0148   delete fWorldMaterialCmd;
0149 }
0150 
0151 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0152 
0153 void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
0154 {
0155   //    FINISH
0156   if (command == fSurfaceFinishCmd) {
0157     if (newValue == "polished") {
0158       fDetector->SetSurfaceFinish(polished);
0159     }
0160     else if (newValue == "polishedfrontpainted") {
0161       fDetector->SetSurfaceFinish(polishedfrontpainted);
0162     }
0163     else if (newValue == "polishedbackpainted") {
0164       fDetector->SetSurfaceFinish(polishedbackpainted);
0165     }
0166     else if (newValue == "ground") {
0167       fDetector->SetSurfaceFinish(ground);
0168     }
0169     else if (newValue == "groundfrontpainted") {
0170       fDetector->SetSurfaceFinish(groundfrontpainted);
0171     }
0172     else if (newValue == "groundbackpainted") {
0173       fDetector->SetSurfaceFinish(groundbackpainted);
0174     }
0175     else if (newValue == "polishedlumirrorair") {
0176       fDetector->SetSurfaceFinish(polishedlumirrorair);
0177     }
0178     else if (newValue == "polishedlumirrorglue") {
0179       fDetector->SetSurfaceFinish(polishedlumirrorglue);
0180     }
0181     else if (newValue == "polishedair") {
0182       fDetector->SetSurfaceFinish(polishedair);
0183     }
0184     else if (newValue == "polishedteflonair") {
0185       fDetector->SetSurfaceFinish(polishedteflonair);
0186     }
0187     else if (newValue == "polishedtioair") {
0188       fDetector->SetSurfaceFinish(polishedtioair);
0189     }
0190     else if (newValue == "polishedtyvekair") {
0191       fDetector->SetSurfaceFinish(polishedtyvekair);
0192     }
0193     else if (newValue == "polishedvm2000air") {
0194       fDetector->SetSurfaceFinish(polishedvm2000air);
0195     }
0196     else if (newValue == "polishedvm2000glue") {
0197       fDetector->SetSurfaceFinish(polishedvm2000glue);
0198     }
0199     else if (newValue == "etchedlumirrorair") {
0200       fDetector->SetSurfaceFinish(etchedlumirrorair);
0201     }
0202     else if (newValue == "etchedlumirrorglue") {
0203       fDetector->SetSurfaceFinish(etchedlumirrorglue);
0204     }
0205     else if (newValue == "etchedair") {
0206       fDetector->SetSurfaceFinish(etchedair);
0207     }
0208     else if (newValue == "etchedteflonair") {
0209       fDetector->SetSurfaceFinish(etchedteflonair);
0210     }
0211     else if (newValue == "etchedtioair") {
0212       fDetector->SetSurfaceFinish(etchedtioair);
0213     }
0214     else if (newValue == "etchedtyvekair") {
0215       fDetector->SetSurfaceFinish(etchedtyvekair);
0216     }
0217     else if (newValue == "etchedvm2000air") {
0218       fDetector->SetSurfaceFinish(etchedvm2000air);
0219     }
0220     else if (newValue == "etchedvm2000glue") {
0221       fDetector->SetSurfaceFinish(etchedvm2000glue);
0222     }
0223     else if (newValue == "groundlumirrorair") {
0224       fDetector->SetSurfaceFinish(groundlumirrorair);
0225     }
0226     else if (newValue == "groundlumirrorglue") {
0227       fDetector->SetSurfaceFinish(groundlumirrorglue);
0228     }
0229     else if (newValue == "groundair") {
0230       fDetector->SetSurfaceFinish(groundair);
0231     }
0232     else if (newValue == "groundteflonair") {
0233       fDetector->SetSurfaceFinish(groundteflonair);
0234     }
0235     else if (newValue == "groundtioair") {
0236       fDetector->SetSurfaceFinish(groundtioair);
0237     }
0238     else if (newValue == "groundtyvekair") {
0239       fDetector->SetSurfaceFinish(groundtyvekair);
0240     }
0241     else if (newValue == "groundvm2000air") {
0242       fDetector->SetSurfaceFinish(groundvm2000air);
0243     }
0244     else if (newValue == "groundvm2000glue") {
0245       fDetector->SetSurfaceFinish(groundvm2000glue);
0246     }
0247     //         for Davis model
0248     else if (newValue == "Rough_LUT") {
0249       fDetector->SetSurfaceFinish(Rough_LUT);
0250     }
0251     else if (newValue == "RoughTeflon_LUT") {
0252       fDetector->SetSurfaceFinish(RoughTeflon_LUT);
0253     }
0254     else if (newValue == "RoughESR_LUT") {
0255       fDetector->SetSurfaceFinish(RoughESR_LUT);
0256     }
0257     else if (newValue == "RoughESRGrease_LUT") {
0258       fDetector->SetSurfaceFinish(RoughESRGrease_LUT);
0259     }
0260     else if (newValue == "Polished_LUT") {
0261       fDetector->SetSurfaceFinish(Polished_LUT);
0262     }
0263     else if (newValue == "PolishedTeflon_LUT") {
0264       fDetector->SetSurfaceFinish(PolishedTeflon_LUT);
0265     }
0266     else if (newValue == "PolishedESR_LUT") {
0267       fDetector->SetSurfaceFinish(PolishedESR_LUT);
0268     }
0269     else if (newValue == "PolishedESRGrease_LUT") {
0270       fDetector->SetSurfaceFinish(PolishedESRGrease_LUT);
0271     }
0272     else if (newValue == "Detector_LUT") {
0273       fDetector->SetSurfaceFinish(Detector_LUT);
0274     }
0275     else {
0276       G4ExceptionDescription ed;
0277       ed << "Invalid surface finish: " << newValue;
0278       G4Exception("DetectorMessenger", "OpNovice2_003", FatalException, ed);
0279     }
0280   }
0281 
0282   //  MODEL
0283   else if (command == fSurfaceModelCmd) {
0284     if (newValue == "glisur") {
0285       fDetector->SetSurfaceModel(glisur);
0286     }
0287     else if (newValue == "unified") {
0288       fDetector->SetSurfaceModel(unified);
0289     }
0290     else if (newValue == "LUT") {
0291       fDetector->SetSurfaceModel(LUT);
0292     }
0293     else if (newValue == "DAVIS") {
0294       fDetector->SetSurfaceModel(DAVIS);
0295     }
0296     else if (newValue == "dichroic") {
0297       fDetector->SetSurfaceModel(dichroic);
0298     }
0299     else {
0300       G4ExceptionDescription ed;
0301       ed << "Invalid surface model: " << newValue;
0302       G4Exception("DetectorMessenger", "ONovice2_001", FatalException, ed);
0303     }
0304   }
0305 
0306   // TYPE
0307   else if (command == fSurfaceTypeCmd) {
0308     if (newValue == "dielectric_metal") {
0309       fDetector->SetSurfaceType(dielectric_metal);
0310     }
0311     else if (newValue == "dielectric_dielectric") {
0312       fDetector->SetSurfaceType(dielectric_dielectric);
0313     }
0314     else if (newValue == "dielectric_LUT") {
0315       fDetector->SetSurfaceType(dielectric_LUT);
0316     }
0317     else if (newValue == "dielectric_LUTDAVIS") {
0318       fDetector->SetSurfaceType(dielectric_LUTDAVIS);
0319     }
0320     else if (newValue == "coated") {
0321       fDetector->SetSurfaceType(coated);
0322     }
0323     else {
0324       G4ExceptionDescription ed;
0325       ed << "Invalid surface type: " << newValue;
0326       G4Exception("DetectorMessenger", "OpNovice2_002", FatalException, ed);
0327     }
0328   }
0329   else if (command == fSurfaceSigmaAlphaCmd) {
0330     fDetector->SetSurfaceSigmaAlpha(G4UIcmdWithADouble::GetNewDoubleValue(newValue));
0331   }
0332   else if (command == fSurfacePolishCmd) {
0333     fDetector->SetSurfacePolish(G4UIcmdWithADouble::GetNewDoubleValue(newValue));
0334   }
0335   else if (command == fTankMatPropVectorCmd) {
0336     // got a string. need to convert it to physics vector.
0337     // string format is property name, then pairs of energy, value
0338     // specify units for each value, eg 3.0*eV
0339     // space delimited
0340     auto mpv = new G4MaterialPropertyVector();
0341     std::istringstream instring(newValue);
0342     G4String prop;
0343     instring >> prop;
0344     while (instring) {
0345       G4String tmp;
0346       instring >> tmp;
0347       if (tmp == "") {
0348         break;
0349       }
0350       G4double en = G4UIcommand::ConvertToDouble(tmp);
0351       instring >> tmp;
0352       G4double val = G4UIcommand::ConvertToDouble(tmp);
0353       mpv->InsertValues(en, val);
0354     }
0355 
0356     fDetector->AddTankMPV(prop, mpv);
0357   }
0358   else if (command == fWorldMatPropVectorCmd) {
0359     // Convert string to physics vector
0360     // string format is property name, then pairs of energy, value
0361     auto mpv = new G4MaterialPropertyVector();
0362     std::istringstream instring(newValue);
0363     G4String prop;
0364     instring >> prop;
0365     while (instring) {
0366       G4String tmp;
0367       instring >> tmp;
0368       if (tmp == "") {
0369         break;
0370       }
0371       G4double en = G4UIcommand::ConvertToDouble(tmp);
0372       instring >> tmp;
0373       G4double val = G4UIcommand::ConvertToDouble(tmp);
0374       mpv->InsertValues(en, val);
0375     }
0376     fDetector->AddWorldMPV(prop, mpv);
0377   }
0378   else if (command == fSurfaceMatPropVectorCmd) {
0379     // Convert string to physics vector
0380     // string format is property name, then pairs of energy, value
0381     // space delimited
0382     auto mpv = new G4MaterialPropertyVector();
0383     G4cout << newValue << G4endl;
0384     std::istringstream instring(newValue);
0385     G4String prop;
0386     instring >> prop;
0387     while (instring) {
0388       G4String tmp;
0389       instring >> tmp;
0390       if (tmp == "") {
0391         break;
0392       }
0393       G4double en = G4UIcommand::ConvertToDouble(tmp);
0394       instring >> tmp;
0395       G4double val = G4UIcommand::ConvertToDouble(tmp);
0396       mpv->InsertValues(en, val);
0397     }
0398     fDetector->AddSurfaceMPV(prop, mpv);
0399   }
0400 
0401   else if (command == fTankMatPropConstCmd) {
0402     // Convert string to physics vector
0403     // string format is property name, then value
0404     // space delimited
0405     std::istringstream instring(newValue);
0406     G4String prop;
0407     G4String tmp;
0408     instring >> prop;
0409     instring >> tmp;
0410     G4double val = G4UIcommand::ConvertToDouble(tmp);
0411     fDetector->AddTankMPC(prop, val);
0412   }
0413   else if (command == fWorldMatPropConstCmd) {
0414     // Convert string to physics vector
0415     // string format is property name, then value
0416     // space delimited
0417     std::istringstream instring(newValue);
0418     G4String prop;
0419     G4String tmp;
0420     instring >> prop;
0421     instring >> tmp;
0422     G4double val = G4UIcommand::ConvertToDouble(tmp);
0423     fDetector->AddWorldMPC(prop, val);
0424   }
0425   else if (command == fSurfaceMatPropConstCmd) {
0426     // Convert string to physics vector
0427     // string format is property name, then value
0428     // space delimited
0429     std::istringstream instring(newValue);
0430     G4String prop;
0431     G4String tmp;
0432     instring >> prop;
0433     instring >> tmp;
0434     G4double val = G4UIcommand::ConvertToDouble(tmp);
0435     fDetector->AddSurfaceMPC(prop, val);
0436   }
0437   else if (command == fWorldMaterialCmd) {
0438     fDetector->SetWorldMaterial(newValue);
0439   }
0440   else if (command == fTankMaterialCmd) {
0441     fDetector->SetTankMaterial(newValue);
0442   }
0443 }
0444 
0445 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......