Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-17 07:52:14

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 // gpaterno, October 2025
0027 //
0028 /// \file DetectorConstructionMessenger.cc
0029 /// \brief Implementation of the DetectorConstruction messenger class
0030 //
0031 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0032 
0033 #include "DetectorConstructionMessenger.hh"
0034 #include "DetectorConstruction.hh"
0035 
0036 #include "G4UIdirectory.hh"
0037 #include "G4UIcmdWithADoubleAndUnit.hh"
0038 #include "G4UIcmdWithADouble.hh"
0039 #include "G4UIcmdWithAnInteger.hh"
0040 #include "G4UIcmdWith3VectorAndUnit.hh"
0041 #include "G4UIcmdWithABool.hh"
0042 #include "G4UIcmdWithAString.hh"
0043 
0044 #include "G4RunManager.hh"
0045 #include "G4ios.hh"
0046 
0047 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0048 
0049 DetectorConstructionMessenger::DetectorConstructionMessenger(DetectorConstruction* det):
0050 fDetector(det)
0051 {
0052     fCmdDir = new G4UIdirectory("/crystal/");
0053     fCmdDir->SetGuidance("crystal Control");  
0054     
0055 
0056     fHybridSourceCmd = new G4UIcmdWithABool("/det/isHybridSource", this);
0057     fHybridSourceCmd->SetGuidance("set if it is a HybridSource");      
0058     fHybridSourceCmd->SetParameterName("SetHybridSource",true);
0059     fHybridSourceCmd->SetDefaultValue(false); 
0060     
0061     
0062     fCrystalMaterialCmd = new G4UIcmdWithAString("/crystal/setCrystalMaterial",this);  
0063     fCrystalMaterialCmd->SetGuidance("Set Crystal Material");
0064     fCrystalMaterialCmd->SetParameterName("matname",true);
0065     fCrystalMaterialCmd->SetDefaultValue("Si");
0066                
0067     fCrystalSizeCmd = new G4UIcmdWith3VectorAndUnit("/crystal/setCrystalSize",this);
0068     fCrystalSizeCmd->SetGuidance("Set Crystal size");
0069     fCrystalSizeCmd->SetParameterName("cryX","cryY","cryZ",false);
0070     fCrystalSizeCmd->SetUnitCategory("Length");
0071     fCrystalSizeCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
0072     
0073     fCrystalLatticeCmd = new G4UIcmdWithAString("/crystal/setCrystalLattice",this);  
0074     fCrystalLatticeCmd->SetGuidance("Set Crystal Lattice");
0075     fCrystalLatticeCmd->SetParameterName("lattice",false);
0076     fCrystalLatticeCmd->SetDefaultValue("(111)");    
0077       
0078     fCrystalAngleXCmd = new G4UIcmdWithADouble("/crystal/setCrystalAngleX",this);
0079     fCrystalAngleXCmd->SetGuidance("Set crystal orientation with respet to the beam");
0080     fCrystalAngleXCmd->SetParameterName("angX",false);
0081     fCrystalAngleXCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 
0082     
0083     fCrystalAngleYCmd = new G4UIcmdWithADouble("/crystal/setCrystalAngleY",this);
0084     fCrystalAngleYCmd->SetGuidance("Set crystal orientation with respet to the beam");
0085     fCrystalAngleYCmd->SetParameterName("angY",false);
0086     fCrystalAngleYCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 
0087     
0088     fCrystalBendingAngleCmd = 
0089         new G4UIcmdWithADouble("/crystal/setCrystalBendingAngle",this);
0090     fCrystalBendingAngleCmd->SetGuidance("Set crystal bending angle");
0091     fCrystalBendingAngleCmd->SetParameterName("bendingAngle",false);
0092     fCrystalBendingAngleCmd->SetRange("bendingAngle >= 0");
0093     fCrystalBendingAngleCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 
0094     
0095     fRadModelCmd = new G4UIcmdWithABool("/crystal/setRadiationModel", this);
0096     fRadModelCmd->SetGuidance("set Radiation Model");      
0097     fRadModelCmd->SetParameterName("ActivateRadiationModel",true);
0098     fRadModelCmd->SetDefaultValue(false);  
0099     
0100     fOCeffectsCmd = new G4UIcmdWithABool("/crystal/setOCeffects", this);
0101     fOCeffectsCmd->SetGuidance("set Oriented Crystal effects");      
0102     fOCeffectsCmd->SetParameterName("OCeffects",true);
0103     fOCeffectsCmd->SetDefaultValue(false);
0104     
0105     fPotentialPathCmd = new G4UIcmdWithAString("/crystal/setChannelingDataPath",this);
0106     fPotentialPathCmd->
0107             SetGuidance("Set the path where to find the available data "
0108                         "for the G4ChannelingFastSimModel "
0109                         "if different from G4CHANNELINGDATA");
0110     fPotentialPathCmd->SetParameterName("channelingDataPath",false);
0111     fPotentialPathCmd->SetDefaultValue("");
0112       
0113       
0114     fRadiatorConverterSepDistanceCmd = 
0115         new G4UIcmdWithADoubleAndUnit("/det/setRadiatorConverterSepDistance",this);
0116     fRadiatorConverterSepDistanceCmd->
0117         SetGuidance("Set Radiator-Converter Separation Distance");
0118     fRadiatorConverterSepDistanceCmd->SetParameterName("RCsepDist",false);
0119     fRadiatorConverterSepDistanceCmd->SetUnitCategory("Length");
0120     fRadiatorConverterSepDistanceCmd->SetRange("RCsepDist>=0.");
0121     fRadiatorConverterSepDistanceCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 
0122     
0123     fConverterSizeCmd = new G4UIcmdWith3VectorAndUnit("/det/setConverterSize",this);
0124     fConverterSizeCmd->SetGuidance("Set Converter size");
0125     fConverterSizeCmd->SetParameterName("pos3cnvX","pos3cnvY","pos3cnvZ",false);
0126     fConverterSizeCmd->SetUnitCategory("Length");
0127     fConverterSizeCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
0128     
0129     fGranularConverterCmd = new G4UIcmdWithABool("/det/setGranularConverter",this);
0130     fGranularConverterCmd->SetGuidance("set Collimator");      
0131     fGranularConverterCmd->SetParameterName("IWantCollimator",true);
0132     fGranularConverterCmd->SetDefaultValue(false);
0133       
0134     fSphereRadiusCmd = new G4UIcmdWithADoubleAndUnit("/det/setSphereRadius",this);
0135     fSphereRadiusCmd->
0136         SetGuidance("Set the radius of the spheres composing the Granular Converter");
0137     fSphereRadiusCmd->SetParameterName("sphr",false);
0138     fSphereRadiusCmd->SetUnitCategory("Length");
0139     fSphereRadiusCmd->SetRange("sphr>=0.");
0140     fSphereRadiusCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 
0141     
0142     fConverterMaterialCmd = new G4UIcmdWithAString("/det/setConverterMaterial",this);  
0143     fConverterMaterialCmd->SetGuidance("Set Converter Material");
0144     fConverterMaterialCmd->SetParameterName("convmatname",true);
0145     fConverterMaterialCmd->SetDefaultValue("W"); 
0146           
0147 
0148     fMagneticFieldCmd = new G4UIcmdWithABool("/det/setMagneticField",this);
0149     fMagneticFieldCmd->SetGuidance("set Magnetic Field");      
0150     fMagneticFieldCmd->SetParameterName("IWantMagneticField",true);
0151     fMagneticFieldCmd->SetDefaultValue(false);  
0152       
0153     fFieldValueCmd = new G4UIcmdWithADoubleAndUnit("/det/setMagneticFieldValue",this);
0154     fFieldValueCmd->SetGuidance("Set Magnetic Field By Value");
0155     fFieldValueCmd->SetParameterName("By",false);
0156     fFieldValueCmd->SetUnitCategory("Magnetic flux density");
0157     fFieldValueCmd->SetRange("By>=0.");
0158     fFieldValueCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
0159     
0160     fFieldRegionLengthCmd = 
0161         new G4UIcmdWithADoubleAndUnit("/det/setMagneticFieldRegionLength",this);
0162     fFieldRegionLengthCmd->SetGuidance("Set Magnetic Field region length");
0163     fFieldRegionLengthCmd->SetParameterName("brl",false);
0164     fFieldRegionLengthCmd->SetUnitCategory("Length");
0165     fFieldRegionLengthCmd->SetRange("brl>0.");
0166     fFieldRegionLengthCmd->AvailableForStates(G4State_PreInit,G4State_Idle);      
0167       
0168       
0169     fCollimatorCmd = new G4UIcmdWithABool("/det/setCollimator",this);
0170     fCollimatorCmd->SetGuidance("set Collimator");      
0171     fCollimatorCmd->SetParameterName("IWantCollimator",true);
0172     fCollimatorCmd->SetDefaultValue(false);
0173             
0174     fCollimatorApertureCmd = 
0175         new G4UIcmdWithADoubleAndUnit("/det/setCollimatorAperture",this);
0176     fCollimatorApertureCmd->SetGuidance("Set Collimator Aperture");
0177     fCollimatorApertureCmd->SetParameterName("CollAp",false);
0178     fCollimatorApertureCmd->SetUnitCategory("Length");
0179     fCollimatorApertureCmd->SetRange("CollAp>0.");
0180     fCollimatorApertureCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
0181     
0182     fCollimatorHoleCmd = new G4UIcmdWithAString("/det/setCollimatorHole",this);  
0183     fCollimatorHoleCmd->SetGuidance("Set Collimator hole shape");
0184     fCollimatorHoleCmd->SetParameterName("holeshape",true);
0185     fCollimatorHoleCmd->SetDefaultValue("squared");
0186     
0187     fCollimatorThicknessCmd = 
0188         new G4UIcmdWithADoubleAndUnit("/det/setCollimatorThickness",this);
0189     fCollimatorThicknessCmd->SetGuidance("Set Collimator thickenss");
0190     fCollimatorThicknessCmd->SetParameterName("collth",false);
0191     fCollimatorThicknessCmd->SetUnitCategory("Length");
0192     fCollimatorThicknessCmd->SetRange("collth>=0.");
0193     fCollimatorThicknessCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
0194     
0195     fCollimatorSideCmd = new G4UIcmdWithADoubleAndUnit("/det/setCollimatorSide",this);
0196     fCollimatorSideCmd->SetGuidance("Set Collimator Side size");
0197     fCollimatorSideCmd->SetParameterName("collside",false);
0198     fCollimatorSideCmd->SetUnitCategory("Length");
0199     fCollimatorSideCmd->SetRange("collside>=0.");
0200     fCollimatorSideCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 
0201     
0202     fRadiatorCollimatorSepDistanceCmd = 
0203         new G4UIcmdWithADoubleAndUnit("/det/setRadiatorCollimatorSepDistance",this);
0204     fRadiatorCollimatorSepDistanceCmd->
0205         SetGuidance("Set Radiator-Collimator Separation Distance");
0206     fRadiatorCollimatorSepDistanceCmd->SetParameterName("RCsepDist",false);
0207     fRadiatorCollimatorSepDistanceCmd->SetUnitCategory("Length");
0208     fRadiatorCollimatorSepDistanceCmd->SetRange("RCsepDist>=0.");
0209     fRadiatorCollimatorSepDistanceCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 
0210     
0211     
0212     fVirtualDetectorSizeCmd = 
0213         new G4UIcmdWith3VectorAndUnit("/crystal/setVirtualDetectorSize",this);
0214     fVirtualDetectorSizeCmd->SetGuidance("Set VirtualDetector size");
0215     fVirtualDetectorSizeCmd->SetParameterName("vdX","vdY","vdZ",false);
0216     fVirtualDetectorSizeCmd->SetUnitCategory("Length");
0217     fVirtualDetectorSizeCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
0218     
0219     
0220     fScoringCrystalExitCmd = new G4UIcmdWithABool("/det/setScoringCrystalExit",this);
0221     fScoringCrystalExitCmd->SetGuidance("set IWantScoringCrystalExit");      
0222     fScoringCrystalExitCmd->SetParameterName("IWantScoringCrystalExit",true);
0223     fScoringCrystalExitCmd->SetDefaultValue(false);
0224     fScoringCrystalExitCmd->AvailableForStates(G4State_PreInit,G4State_Idle);      
0225 }
0226 
0227 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0228 
0229 DetectorConstructionMessenger::~DetectorConstructionMessenger()
0230 {
0231     delete fCmdDir;
0232     
0233     delete fHybridSourceCmd;
0234     
0235     delete fCrystalMaterialCmd;
0236     delete fCrystalSizeCmd;
0237     delete fCrystalLatticeCmd;
0238     delete fCrystalAngleXCmd;
0239     delete fCrystalAngleYCmd;
0240     delete fCrystalBendingAngleCmd;
0241     delete fRadModelCmd;    
0242     delete fOCeffectsCmd;
0243     delete fPotentialPathCmd;
0244     
0245     delete fRadiatorConverterSepDistanceCmd;
0246     delete fConverterSizeCmd;
0247     delete fGranularConverterCmd;
0248     delete fSphereRadiusCmd;
0249     delete fConverterMaterialCmd;
0250     
0251     delete fMagneticFieldCmd;
0252     delete fFieldValueCmd;
0253     delete fFieldRegionLengthCmd;
0254     
0255     delete fCollimatorCmd;
0256     delete fCollimatorApertureCmd;
0257     delete fCollimatorHoleCmd;
0258     delete fCollimatorThicknessCmd;
0259     delete fCollimatorSideCmd;
0260     delete fRadiatorCollimatorSepDistanceCmd;
0261     
0262     delete fVirtualDetectorSizeCmd;
0263     
0264     delete fScoringCrystalExitCmd;
0265 }
0266 
0267 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0268 
0269 void DetectorConstructionMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
0270 {
0271     if (command == fHybridSourceCmd) 
0272         {fDetector->SetHybridSource(fHybridSourceCmd->GetNewBoolValue(newValue));}    
0273     
0274     if (command == fCrystalMaterialCmd) 
0275         {fDetector->SetCrystalMaterial(newValue);}
0276     if (command == fCrystalSizeCmd) 
0277         {fDetector->SetCrystalSize(fCrystalSizeCmd->GetNew3VectorValue(newValue));}    
0278     if (command == fCrystalLatticeCmd) 
0279         {fDetector->SetCrystalLattice(newValue);}
0280     if (command == fCrystalAngleXCmd) 
0281         {fDetector->SetCrystalAngleX(fCrystalAngleXCmd->GetNewDoubleValue(newValue));}    
0282     if (command == fCrystalAngleYCmd) 
0283         {fDetector->SetCrystalAngleY(fCrystalAngleYCmd->GetNewDoubleValue(newValue));}    
0284     if (command == fCrystalBendingAngleCmd) 
0285         {fDetector->
0286             SetCrystalBendingAngle(fCrystalBendingAngleCmd->GetNewDoubleValue(newValue));}        
0287     if (command == fRadModelCmd) 
0288         {fDetector->SetRadiationModel(fRadModelCmd->GetNewBoolValue(newValue));}    
0289     if (command == fOCeffectsCmd) 
0290         {fDetector->SetOCeffects(fOCeffectsCmd->GetNewBoolValue(newValue));}
0291     if (command == fPotentialPathCmd) 
0292         {fDetector->SetPotentialPath(newValue);}  
0293 
0294     if (command == fRadiatorConverterSepDistanceCmd) 
0295         {fDetector->SetRadiatorConverterSepDistance(
0296             fRadiatorConverterSepDistanceCmd->GetNewDoubleValue(newValue));}
0297     if (command == fConverterSizeCmd) 
0298         {fDetector->SetConverterSize(fConverterSizeCmd->GetNew3VectorValue(newValue));}
0299     if (command == fGranularConverterCmd) 
0300         {fDetector->
0301             SetGranularConverter(fGranularConverterCmd->GetNewBoolValue(newValue));}
0302     if (command == fSphereRadiusCmd) 
0303         {fDetector->SetSphereRadius(fSphereRadiusCmd->GetNewDoubleValue(newValue));}    
0304     if (command == fConverterMaterialCmd) 
0305         {fDetector->SetConverterMaterial(newValue);}
0306         
0307     if (command == fMagneticFieldCmd) 
0308         {fDetector->SetMagneticField(fMagneticFieldCmd->GetNewBoolValue(newValue));}    
0309     if (command == fFieldValueCmd) 
0310         {fDetector->SetFieldValue(fFieldValueCmd->GetNewDoubleValue(newValue));}
0311     if (command == fFieldRegionLengthCmd) 
0312         {fDetector->
0313             SetFieldRegionLength(fFieldRegionLengthCmd->GetNewDoubleValue(newValue));}        
0314         
0315     if (command == fCollimatorCmd) 
0316         {fDetector->SetCollimator(fCollimatorCmd->GetNewBoolValue(newValue));}        
0317     if (command == fCollimatorApertureCmd) 
0318         {fDetector->
0319             SetCollimatorAperture(fCollimatorApertureCmd->GetNewDoubleValue(newValue));}
0320     if (command == fCollimatorHoleCmd) 
0321         {fDetector->SetCollimatorHole(newValue);}    
0322     if (command == fCollimatorThicknessCmd) 
0323         {fDetector->
0324             SetCollimatorThickness(fCollimatorThicknessCmd->GetNewDoubleValue(newValue));}
0325     if (command == fCollimatorSideCmd) 
0326         {fDetector->SetCollimatorSide(fCollimatorSideCmd->GetNewDoubleValue(newValue));}
0327     if (command == fRadiatorCollimatorSepDistanceCmd) 
0328         {fDetector->SetRadiatorCollimatorSepDistance(
0329             fRadiatorCollimatorSepDistanceCmd->GetNewDoubleValue(newValue));}
0330 
0331     if (command == fVirtualDetectorSizeCmd) 
0332         {fDetector->
0333             SetVirtualDetectorSize(fVirtualDetectorSizeCmd->GetNew3VectorValue(newValue));}
0334     if (command == fScoringCrystalExitCmd) 
0335         {fDetector->
0336             SetScoringCrystalExit(fScoringCrystalExitCmd->GetNewBoolValue(newValue));}             
0337 }
0338 
0339 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0340