Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:19:20

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 // $Id: G4TBFieldMessenger.cc,v 1.5 2012/07/10 16:48:20 pinkenbu Exp $
0028 // GEANT4 tag $Name:  $
0029 //
0030 //
0031 
0032 #include "G4TBFieldMessenger.hh"
0033 
0034 #include "G4TBMagneticFieldSetup.hh"
0035 
0036 #include <Geant4/G4ApplicationState.hh>
0037 #include <Geant4/G4String.hh>
0038 #include <Geant4/G4UIcmdWithADoubleAndUnit.hh>
0039 #include <Geant4/G4UIcmdWithAString.hh>
0040 #include <Geant4/G4UIcmdWithAnInteger.hh>
0041 #include <Geant4/G4UIcmdWithoutParameter.hh>
0042 #include <Geant4/G4UIdirectory.hh>
0043 
0044 class G4UIcommand;
0045 
0046 //////////////////////////////////////////////////////////////////////////////
0047 
0048 G4TBFieldMessenger::G4TBFieldMessenger(G4TBMagneticFieldSetup* pEMfield)
0049   : fEFieldSetup(pEMfield)
0050 {
0051   G4TBdetDir = new G4UIdirectory("/field/");
0052   G4TBdetDir->SetGuidance("G4TB field tracking control.");
0053 
0054   StepperCmd = new G4UIcmdWithAnInteger("/field/setStepperType", this);
0055   StepperCmd->SetGuidance("Select stepper type for electric field");
0056   StepperCmd->SetParameterName("choice", true);
0057   StepperCmd->SetDefaultValue(4);
0058   StepperCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0059 
0060   UpdateCmd = new G4UIcmdWithoutParameter("/field/update", this);
0061   UpdateCmd->SetGuidance("Update calorimeter geometry.");
0062   UpdateCmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
0063   UpdateCmd->SetGuidance("if you changed geometrical value(s).");
0064   UpdateCmd->AvailableForStates(G4State_Idle);
0065 
0066   ElFieldCmd = new G4UIcmdWithADoubleAndUnit("/field/setFieldZ", this);
0067   ElFieldCmd->SetGuidance("Define uniform Electric field.");
0068   ElFieldCmd->SetGuidance("Electric field will be in Z direction.");
0069   ElFieldCmd->SetGuidance("Value of Electric field has to be given in volt/m");
0070   ElFieldCmd->SetParameterName("Ez", false, false);
0071   ElFieldCmd->SetDefaultUnit("volt/m");
0072   ElFieldCmd->AvailableForStates(G4State_Idle);
0073 
0074   MinStepCmd = new G4UIcmdWithADoubleAndUnit("/field/setMinStep", this);
0075   MinStepCmd->SetGuidance("Define minimal step");
0076   MinStepCmd->SetParameterName("min step", false, false);
0077   MinStepCmd->SetDefaultUnit("mm");
0078   MinStepCmd->AvailableForStates(G4State_Idle);
0079 
0080   AbsMaterCmd = new G4UIcmdWithAString("/field/setAbsMat", this);
0081   AbsMaterCmd->SetGuidance("Select Material of the Absorber.");
0082   AbsMaterCmd->SetParameterName("choice", true);
0083   AbsMaterCmd->SetDefaultValue("Xe");
0084   AbsMaterCmd->AvailableForStates(G4State_Idle);
0085 }
0086 
0087 ///////////////////////////////////////////////////////////////////////////////
0088 
0089 G4TBFieldMessenger::~G4TBFieldMessenger()
0090 {
0091   delete StepperCmd;
0092   delete ElFieldCmd;
0093   delete MinStepCmd;
0094   delete G4TBdetDir;
0095   delete UpdateCmd;
0096 
0097   delete AbsMaterCmd;
0098 }
0099 
0100 ////////////////////////////////////////////////////////////////////////////
0101 //
0102 //
0103 
0104 void G4TBFieldMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
0105 {
0106   if (command == StepperCmd)
0107   {
0108     fEFieldSetup->SetStepperType(StepperCmd->GetNewIntValue(newValue));
0109   }
0110   if (command == UpdateCmd)
0111   {
0112     fEFieldSetup->UpdateField();
0113   }
0114   if (command == ElFieldCmd)
0115   {
0116     fEFieldSetup->SetFieldValue(ElFieldCmd->GetNewDoubleValue(newValue));
0117   }
0118   if (command == MinStepCmd)
0119   {
0120     fEFieldSetup->SetMinStep(MinStepCmd->GetNewDoubleValue(newValue));
0121   }
0122 }
0123 
0124 //
0125 //
0126 /////////////////////////////////////////////////////////////////////////