G4MatScanMessenger.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id$
00028 //
00029 //
00030 //
00031 
00032 #include "G4MatScanMessenger.hh"
00033 
00034 #include "G4SystemOfUnits.hh"
00035 #include "G4UIdirectory.hh"
00036 #include "G4UIcommand.hh"
00037 #include "G4UIparameter.hh"
00038 #include "G4UIcmdWithoutParameter.hh"
00039 #include "G4UIcmdWithABool.hh"
00040 #include "G4UIcmdWith3VectorAndUnit.hh"
00041 #include "G4UIcmdWith3Vector.hh"
00042 #include "G4UIcmdWithAString.hh"
00043 #include "G4MaterialScanner.hh"
00044 #include "G4ThreeVector.hh"
00045 #include "G4Tokenizer.hh"
00046 
00047 G4MatScanMessenger::G4MatScanMessenger(G4MaterialScanner* p1)
00048 {
00049   theScanner = p1;
00050   G4UIparameter* par;
00051   msDirectory = new G4UIdirectory("/control/matScan/");
00052   msDirectory->SetGuidance("Material scanner commands.");
00053 
00054   scanCmd = new G4UIcmdWithoutParameter("/control/matScan/scan",this);
00055   scanCmd->SetGuidance("Start material scanning.");
00056   scanCmd->SetGuidance("Scanning range should be defined with");
00057   scanCmd->SetGuidance("/control/matScan/theta and /control/matSca/phi commands.");
00058   scanCmd->AvailableForStates(G4State_Idle);
00059 
00060   thetaCmd = new G4UIcommand("/control/matScan/theta",this);
00061   thetaCmd->SetGuidance("Define theta range.");
00062   thetaCmd->SetGuidance("Usage : /control/matScan/theta [nbin] [thetaMin] [thetaSpan] [unit]");
00063   thetaCmd->SetGuidance("Notation of angles :");
00064   thetaCmd->SetGuidance(" theta --- +Z axis : +90 deg. / X-Y plane : 0 deg. / -Z axis : -90 deg.");
00065   par = new G4UIparameter("nbin",'i',false);
00066   par->SetParameterRange("nbin>0");
00067   thetaCmd->SetParameter(par);
00068   par = new G4UIparameter("thetaMin",'d',false);
00069   thetaCmd->SetParameter(par);
00070   par = new G4UIparameter("thetaSpan",'d',true);
00071   par->SetParameterRange("thetaSpan>=0.");
00072   par->SetDefaultValue(0.);
00073   thetaCmd->SetParameter(par);
00074   par = new G4UIparameter("unit",'c',true);
00075   par->SetDefaultValue("deg");
00076   par->SetParameterCandidates(thetaCmd->UnitsList(thetaCmd->CategoryOf("deg")));
00077   thetaCmd->SetParameter(par);
00078 
00079   phiCmd = new G4UIcommand("/control/matScan/phi",this);
00080   phiCmd->SetGuidance("Define phi range.");
00081   phiCmd->SetGuidance("Usage : /control/matScan/phi [nbin] [phiMin] [phiSpan] [unit]");
00082   phiCmd->SetGuidance("Notation of angles :");
00083   phiCmd->SetGuidance(" phi   --- +X axis : 0 deg. / +Y axis : 90 deg. / -X axis : 180 deg. / -Y axis : 270 deg.");
00084   par = new G4UIparameter("nbin",'i',false);
00085   par->SetParameterRange("nbin>0");
00086   phiCmd->SetParameter(par);
00087   par = new G4UIparameter("phiMin",'d',false);
00088   phiCmd->SetParameter(par);
00089   par = new G4UIparameter("phiSpan",'d',true);
00090   par->SetParameterRange("phiSpan>=0.");
00091   par->SetDefaultValue(0.);
00092   phiCmd->SetParameter(par);
00093   par = new G4UIparameter("unit",'c',true);
00094   par->SetDefaultValue("deg");
00095   par->SetParameterCandidates(phiCmd->UnitsList(phiCmd->CategoryOf("deg")));
00096   phiCmd->SetParameter(par);
00097 
00098   singleCmd = new G4UIcommand("/control/matScan/singleMeasure",this);
00099   singleCmd->SetGuidance("Measure thickness for one particular direction.");
00100   singleCmd->SetGuidance("Notation of angles :");
00101   singleCmd->SetGuidance(" theta --- +Z axis : +90 deg. / X-Y plane : 0 deg. / -Z axis : -90 deg.");
00102   singleCmd->SetGuidance(" phi   --- +X axis : 0 deg. / +Y axis : 90 deg. / -X axis : 180 deg. / -Y axis : 270 deg.");
00103   singleCmd->AvailableForStates(G4State_Idle);
00104   par = new G4UIparameter("theta",'d',false);
00105   singleCmd->SetParameter(par);
00106   par = new G4UIparameter("phi",'d',false);
00107   singleCmd->SetParameter(par);
00108   par = new G4UIparameter("unit",'c',true);
00109   par->SetDefaultValue("deg");
00110   par->SetParameterCandidates(singleCmd->UnitsList(singleCmd->CategoryOf("deg")));
00111   singleCmd->SetParameter(par);
00112 
00113   single2Cmd = new G4UIcmdWith3Vector("/control/matScan/singleTo",this);
00114   single2Cmd->SetGuidance("Measure thicknesss for one direction defined by a unit vector.");
00115   single2Cmd->SetParameterName("X","Y","Z",false);
00116 
00117   eyePosCmd = new G4UIcmdWith3VectorAndUnit("/control/matScan/eyePosition",this);
00118   eyePosCmd->SetGuidance("Define the eye position.");
00119   eyePosCmd->SetParameterName("X","Y","Z",true);
00120   eyePosCmd->SetDefaultValue(G4ThreeVector(0.,0.,0.));
00121   eyePosCmd->SetDefaultUnit("m");
00122 
00123   regSenseCmd = new G4UIcmdWithABool("/control/matScan/regionSensitive",this);
00124   regSenseCmd->SetGuidance("Set region sensitivity.");
00125   regSenseCmd->SetGuidance("This command is automatically set to TRUE");
00126   regSenseCmd->SetGuidance(" if /control/matScan/region command is issued.");
00127   regSenseCmd->SetParameterName("senseFlag",true);
00128   regSenseCmd->SetDefaultValue(false);
00129 
00130   regionCmd = new G4UIcmdWithAString("/control/matScan/region",this);
00131   regionCmd->SetGuidance("Define region name to be scanned.");
00132   regionCmd->SetGuidance("/control/matScan/regionSensitive command is automatically");
00133   regionCmd->SetGuidance("set to TRUE with this command.");
00134   regionCmd->SetParameterName("region",true);
00135   regionCmd->SetDefaultValue("DefaultRegionForTheWorld");
00136 }
00137 
00138 G4MatScanMessenger::~G4MatScanMessenger()
00139 {
00140   delete scanCmd;
00141   delete thetaCmd;
00142   delete phiCmd;
00143   delete singleCmd;
00144   delete single2Cmd;
00145   delete eyePosCmd;
00146   delete regSenseCmd;
00147   delete regionCmd;
00148   delete msDirectory;
00149 }
00150 
00151 G4String G4MatScanMessenger::GetCurrentValue(G4UIcommand * command)
00152 {
00153   G4String currentValue;
00154   if(command==thetaCmd)
00155   {
00156    currentValue = thetaCmd->ConvertToString(theScanner->GetNTheta());
00157    currentValue += " ";
00158    currentValue += thetaCmd->ConvertToString((theScanner->GetThetaMin())/deg);
00159    currentValue += " ";
00160    currentValue += thetaCmd->ConvertToString((theScanner->GetThetaSpan())/deg);
00161   }
00162   else if(command==phiCmd)
00163   {
00164    currentValue = phiCmd->ConvertToString(theScanner->GetNPhi());
00165    currentValue += " ";
00166    currentValue += phiCmd->ConvertToString((theScanner->GetPhiMin())/deg);
00167    currentValue += " ";
00168    currentValue += phiCmd->ConvertToString((theScanner->GetPhiSpan())/deg);
00169   }
00170   else if(command==eyePosCmd)
00171   { currentValue = eyePosCmd->ConvertToString(theScanner->GetEyePosition(),"m"); }
00172   else if(command==regSenseCmd)
00173   { currentValue = regSenseCmd->ConvertToString(theScanner->GetRegionSensitive()); }
00174   else if(command==regionCmd)
00175   { currentValue = theScanner->GetRegionName(); }
00176   return currentValue;
00177 }
00178 
00179 void G4MatScanMessenger::SetNewValue(G4UIcommand * command,G4String newValue)
00180 {
00181   if(command==scanCmd)
00182   { theScanner->Scan(); }
00183   else if(command==thetaCmd)
00184   {
00185     G4Tokenizer next( newValue );
00186     G4int nbin = StoI(next());
00187     G4double thetaMin = StoD(next());
00188     G4double thetaSpan = StoD(next());
00189     G4String unit = next();
00190     thetaMin *= thetaCmd->ValueOf(unit);
00191     thetaSpan *= thetaCmd->ValueOf(unit);
00192     theScanner->SetNTheta(nbin);
00193     theScanner->SetThetaMin(thetaMin);
00194     theScanner->SetThetaSpan(thetaSpan);
00195   }
00196   else if(command==phiCmd)
00197   {
00198     G4Tokenizer next( newValue );
00199     G4int nbin = StoI(next());
00200     G4double phiMin = StoD(next());
00201     G4double phiSpan = StoD(next());
00202     G4String unit = next();
00203     phiMin *= phiCmd->ValueOf(unit);
00204     phiSpan *= phiCmd->ValueOf(unit);
00205     theScanner->SetNPhi(nbin);
00206     theScanner->SetPhiMin(phiMin);
00207     theScanner->SetPhiSpan(phiSpan);
00208   }
00209   else if(command==eyePosCmd)
00210   { theScanner->SetEyePosition(eyePosCmd->GetNew3VectorValue(newValue)); }
00211   else if(command==regSenseCmd)
00212   { theScanner->SetRegionSensitive(regSenseCmd->GetNewBoolValue(newValue)); }
00213   else if(command==regionCmd)
00214   { if(theScanner->SetRegionName(newValue)) theScanner->SetRegionSensitive(true); }
00215   else if(command==singleCmd || command==single2Cmd)
00216   {
00217     G4int ntheta = theScanner->GetNTheta();
00218     G4double thetaMin = theScanner->GetThetaMin();
00219     G4double thetaSpan = theScanner->GetThetaSpan();
00220     G4int nphi = theScanner->GetNPhi();
00221     G4double phiMin = theScanner->GetPhiMin();
00222     G4double phiSpan = theScanner->GetPhiSpan();
00223 
00224     G4double theta = 0.;
00225     G4double phi = 0.;
00226     if(command==singleCmd)
00227     {
00228       G4Tokenizer next( newValue );
00229       theta = StoD(next());
00230       phi = StoD(next());
00231       G4String unit = next();
00232       theta *= singleCmd->ValueOf(unit);
00233       phi *= singleCmd->ValueOf(unit);
00234     }
00235     else if(command==single2Cmd)
00236     {
00237       G4ThreeVector v = single2Cmd->GetNew3VectorValue(newValue);
00238       theta = 90.*deg - v.theta();
00239       phi = v.phi();
00240     }
00241     theScanner->SetNTheta(1);
00242     theScanner->SetThetaMin(theta);
00243     theScanner->SetThetaSpan(0.);
00244     theScanner->SetNPhi(1);
00245     theScanner->SetPhiMin(phi);
00246     theScanner->SetPhiSpan(0.);
00247     theScanner->Scan();
00248 
00249     theScanner->SetNTheta(ntheta);
00250     theScanner->SetThetaMin(thetaMin);
00251     theScanner->SetThetaSpan(thetaSpan);
00252     theScanner->SetNPhi(nphi);
00253     theScanner->SetPhiMin(phiMin);
00254     theScanner->SetPhiSpan(phiSpan);
00255   }
00256 
00257 }
00258 
00259 
00260  
00261 
00262 

Generated on Mon May 27 17:48:51 2013 for Geant4 by  doxygen 1.4.7