Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

MJGeneratorPrimaryMessenger.cc

Go to the documentation of this file.
00001 //---------------------------------------------------------------------------//
00002 //bb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nu//
00003 //                                                                           //
00004 //                         MAJORANA Simulation                               //
00005 //                                                                           //
00006 //      This code implementation is the intellectual property of the         //
00007 //      MAJORANA Collaboration. It is based on Geant4, an intellectual       //
00008 //      property of the RD44 GEANT4 collaboration.                           //
00009 //                                                                           //
00010 //                        *********************                              //
00011 //                                                                           //
00012 //    Neither the authors of this software system, nor their employing       //
00013 //    institutes, nor the agencies providing financial support for this      //
00014 //    work  make  any representation or  warranty, express or implied,       //
00015 //    regarding this software system or assume any liability for its use.    //
00016 //    By copying, distributing or modifying the Program (or any work based   //
00017 //    on on the Program) you indicate your acceptance of this statement,     //
00018 //    and all its terms.                                                     //
00019 //                                                                           //
00020 //bb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nu//
00021 //---------------------------------------------------------------------------//
00022 //                                                          
00023 // $Id: MJGeneratorPrimaryMessenger.cc,v 1.4 2004/11/15 09:53:56 xliu Exp $ 
00024 //      
00025 // CLASS IMPLEMENTATION:  MJGeneratorPrimaryMessenger.cc
00026 //
00027 //---------------------------------------------------------------------------//
00031 // 
00032 //---------------------------------------------------------------------------//
00044 //---------------------------------------------------------------------------//
00045 //
00046 
00047 #include "globals.hh"
00048 #include "G4UIcmdWithoutParameter.hh"
00049 #include "G4UIcmdWithAString.hh"
00050 #include "G4UIdirectory.hh"
00051 #include "G4PhysicalVolumeStore.hh"
00052 
00053 #include "generators/MJGeneratorPNNL.hh"
00054 #include "generators/MJGeneratorPrimary.hh"
00055 #include "generators/MJGeneratorRDM.hh"
00056 #include "generators/MJGeneratorG4Gun.hh"
00057 #include "generators/MJGeneratorTUNLFEL.hh"
00058 #include "generators/MaGeGeneratorDecay0.hh"
00059 
00060 #include "io/MJLogger.hh"
00061 //---------------------------------------------------------------------------//
00062 
00063 #include "generators/MJGeneratorPrimaryMessenger.hh" 
00064 
00065 //---------------------------------------------------------------------------//
00066 
00067 MJGeneratorPrimaryMessenger::MJGeneratorPrimaryMessenger
00068 (MJGeneratorPrimary *generator):
00069   fGeneratorPrimary(generator)
00070 {
00071   // /MJ/generator/ directory definition
00072   fGeneratorDirectory = new G4UIdirectory("/MJ/generator/");
00073   fGeneratorDirectory->SetGuidance("Control commands for generators:");
00074   fGeneratorDirectory->SetGuidance("/MJ/generator/select: Select generator.");
00075   
00076   // /MJ/generator/select command
00077   fSelectCmd = new G4UIcmdWithAString("/MJ/generator/select", this);
00078   fSelectCmd->SetGuidance("Selects generator for events.");
00079   fSelectCmd->SetGuidance("Options are:");
00080   fSelectCmd->SetGuidance("PNNLiso : PNNL model for radioactive isotopes.");
00081   fSelectCmd->SetGuidance("RDMiso: G4 model for radioactive isotopes.");
00082   fSelectCmd->SetGuidance("TUNLFEL: TUNL FEL beam.");
00083   fSelectCmd->SetGuidance("G4gun: Standard G4 gun.");
00084   fSelectCmd->SetGuidance("decay0: decay0 generator.");
00085   fSelectCmd->SetCandidates("PNNLiso RDMiso TUNLFEL G4gun decay0");
00086 
00087   // /MJ/generator/name
00088   fNameCmd = new G4UIcmdWithoutParameter("/MJ/generator/name", this);
00089   fNameCmd->SetGuidance("Returns name of current generator.");
00090 
00091   // /MJ/generator/confine
00092   fConfineCmd = new G4UIcmdWithAString("/MJ/generator/confine", this);
00093   fConfineCmd->SetGuidance("Selects confinement for the source.");
00094   fConfineCmd->SetGuidance("Options are:");
00095   fConfineCmd->SetGuidance("noconfined : source not confined");
00096   fConfineCmd->SetGuidance("volume : source confined in a volume.");
00097   fConfineCmd->SetGuidance("surface : source confined in a surface.");
00098   fConfineCmd->SetCandidates("noconfined volume surface");
00099 
00100   // /MJ/generator/volume
00101   fVolumeCmd = new G4UIcmdWithAString("/MJ/generator/volume", this);
00102   fVolumeCmd->SetGuidance("Selects the volume where the source is confined");
00103   fVolumeCmd->AvailableForStates(G4State_Init,G4State_Idle);
00104 }
00105 
00106 //---------------------------------------------------------------------------//
00107 
00108 MJGeneratorPrimaryMessenger::MJGeneratorPrimaryMessenger(const MJGeneratorPrimaryMessenger & other)
00109 {;}
00110 
00111 //---------------------------------------------------------------------------//
00112 
00113 MJGeneratorPrimaryMessenger::~MJGeneratorPrimaryMessenger()
00114 {
00115   delete fGeneratorDirectory;
00116   delete fNameCmd;
00117   delete fSelectCmd;
00118   delete fConfineCmd;
00119   delete fVolumeCmd;
00120 }
00121 
00122 //---------------------------------------------------------------------------//
00123 
00124 G4String MJGeneratorPrimaryMessenger::GetCurrentValue(G4UIcommand *command)
00125 {
00126   G4String cv;
00127 
00128   // /MJ/generator/name
00129   if(command == fNameCmd) {
00130     cv = "Current generator is : " + 
00131       fGeneratorPrimary->GetMJGenerator()->GetGeneratorName();
00132   }
00133 
00134   return cv;
00135 }
00136 
00137 //---------------------------------------------------------------------------//
00138 
00139 void MJGeneratorPrimaryMessenger::SetNewValue(G4UIcommand *command,
00140                                               G4String newValues)
00141 {
00142   // /MJ/generator/select
00143   if(command == fSelectCmd) {
00144     if(newValues == "PNNLiso") 
00145       fGeneratorPrimary->SetMJGenerator(new MJGeneratorPNNL);
00146     else if(newValues == "RDMiso")
00147       fGeneratorPrimary->SetMJGenerator(new MJGeneratorRDM);
00148     else if(newValues == "G4gun")
00149       fGeneratorPrimary->SetMJGenerator(new MJGeneratorG4Gun);
00150     else if(newValues == "TUNLFEL")
00151       fGeneratorPrimary->SetMJGenerator(new MJGeneratorTUNLFEL);
00152     else if(newValues == "decay0")
00153       fGeneratorPrimary->SetMJGenerator(new MaGeGeneratorDecay0);
00154     else 
00155       MJLog(warning) << "Unknown generator. Please try again." << endlog;
00156   }
00157 
00158   if(command == fConfineCmd) {
00159     if(newValues == "noconfined")
00160       {
00161         fGeneratorPrimary->SetConfinementCode(noconfined);
00162         MJLog(trace) << "Source not confined" << endlog;
00163       }
00164     else if(newValues == "volume")
00165       {
00166         fGeneratorPrimary->SetConfinementCode(volume);
00167         MJLog(trace) << "Source confined in volume" << endlog;
00168       }
00169     else if(newValues == "surface")
00170       {
00171         fGeneratorPrimary->SetConfinementCode(surface);
00172         MJLog(trace) << "Source confined in skin surface" << endlog;
00173       }
00174   }
00175 
00176   if (command == fVolumeCmd)
00177     {
00178       MJLog(trace) << " choose volume command "<<endlog;
00179       fGeneratorPrimary->SetVolumeName(newValues);
00180 
00181       G4bool ifound = false;
00182       G4PhysicalVolumeStore* volumeStore = G4PhysicalVolumeStore::GetInstance();
00183       G4int nVolumes = (G4int) volumeStore->size();
00184       G4String candidateList;
00185       for(G4int i=0;i<nVolumes;i++)
00186         {
00187           candidateList += (*volumeStore)[i]->GetName();
00188           candidateList += ", ";
00189           if ((*volumeStore)[i]->GetName() == newValues) ifound = true;
00190         }
00191 
00192       if (ifound) {
00193         if (fGeneratorPrimary->GetConfinementCode() != noconfined) 
00194           {
00195             fGeneratorPrimary->SetVolumeName(newValues);
00196             MJLog(trace) << "Source confined in " << newValues << endlog;
00197           }
00198         else 
00199           MJLog(warning) << "Source not confined: nothing happens " << endlog;
00200       }
00201       else
00202         {
00203           MJLog(warning) << "Volume not found " << endlog;
00204           MJLog(warning) << "The list of volumes is: "
00205                          << candidateList << endlog;
00206         }
00207 
00208     }
00209 
00210 }
00211 
00212 //---------------------------------------------------------------------------//
00213 //---------------------------------------------------------------------------//

Generated on Mon Nov 29 16:58:51 2004 for Majorana Simulation by  doxygen 1.3.9.1