11 modified files
slic/include
diff -N G4MSSteppingAction.hh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ G4MSSteppingAction.hh 8 May 2006 20:08:29 -0000 1.3
@@ -0,0 +1,67 @@
+//
+// ********************************************************************
+// * DISCLAIMER *
+// * *
+// * The following disclaimer summarizes all the specific disclaimers *
+// * of contributors to this software. The specific disclaimers,which *
+// * govern, are listed with their locations in: *
+// * http://cern.ch/geant4/license *
+// * *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work make any representation or warranty, express or implied, *
+// * regarding this software system or assume any liability for its *
+// * use. *
+// * *
+// * This code implementation is the intellectual property of the *
+// * GEANT4 collaboration. *
+// * By copying, distributing or modifying the Program (or any work *
+// * based on the Program) you indicate your acceptance of this *
+// * statement, and all its terms. *
+// ********************************************************************
+//
+//
+// $Id: G4MSSteppingAction.hh,v 1.3 2006/05/08 20:08:29 jeremy Exp $
+// GEANT4 tag $Name: $
+//
+//
+
+// class description:
+//
+
+//////////////////////
+//G4MSSteppingAction
+/////////////////////
+
+
+#ifndef G4MSSteppingAction_h
+#define G4MSSteppingAction_h 1
+
+class G4Region;
+
+#include "G4UserSteppingAction.hh"
+#include "globals.hh"
+
+class G4MSSteppingAction : public G4UserSteppingAction
+{
+ public:
+ G4MSSteppingAction();
+ virtual ~G4MSSteppingAction();
+
+ void Initialize(G4bool rSens,G4Region* reg);
+ virtual void UserSteppingAction(const G4Step*);
+
+ private:
+ G4bool regionSensitive;
+ G4Region* theRegion;
+ G4double length;
+ G4double x0;
+ G4double lambda;
+
+ public:
+ inline G4double GetTotalStepLength() const { return length; }
+ inline G4double GetX0() const { return x0; }
+ inline G4double GetLambda0() const { return lambda; }
+};
+
+#endif
slic/include
diff -N G4MatScanMessenger.hh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ G4MatScanMessenger.hh 8 May 2006 20:08:29 -0000 1.3
@@ -0,0 +1,70 @@
+//
+// ********************************************************************
+// * DISCLAIMER *
+// * *
+// * The following disclaimer summarizes all the specific disclaimers *
+// * of contributors to this software. The specific disclaimers,which *
+// * govern, are listed with their locations in: *
+// * http://cern.ch/geant4/license *
+// * *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work make any representation or warranty, express or implied, *
+// * regarding this software system or assume any liability for its *
+// * use. *
+// * *
+// * This code implementation is the intellectual property of the *
+// * GEANT4 collaboration. *
+// * By copying, distributing or modifying the Program (or any work *
+// * based on the Program) you indicate your acceptance of this *
+// * statement, and all its terms. *
+// ********************************************************************
+//
+//
+// $Id: G4MatScanMessenger.hh,v 1.3 2006/05/08 20:08:29 jeremy Exp $
+// GEANT4 tag $Name: $
+//
+//
+
+// class description:
+//
+
+
+#ifndef G4MatScanMessenger_HH
+#define G4MatScanMessenger_HH 1
+
+#include "G4UImessenger.hh"
+class G4UIdirectory;
+class G4UIcmdWithoutParameter;
+class G4UIcommand;
+class G4UIcmdWith3VectorAndUnit;
+class G4UIcmdWithABool;
+class G4UIcmdWithAString;
+class G4MaterialScanner;
+
+class G4MatScanMessenger : public G4UImessenger
+{
+ public:
+ G4MatScanMessenger(G4MaterialScanner* p1);
+ virtual ~G4MatScanMessenger();
+
+ virtual G4String GetCurrentValue(G4UIcommand * command);
+ virtual void SetNewValue(G4UIcommand * command,G4String newValue);
+
+ private:
+ G4MaterialScanner* theScanner;
+
+ G4UIdirectory* msDirectory;
+ G4UIcmdWithoutParameter* scanCmd;
+ G4UIcommand* thetaCmd;
+ G4UIcommand* phiCmd;
+ G4UIcommand* singleCmd;
+ G4UIcmdWithABool* regSenseCmd;
+ G4UIcmdWithAString* regionCmd;
+ G4UIcmdWith3VectorAndUnit* eyePosCmd;
+};
+
+#endif
+
+
+
slic/include
diff -N G4MaterialScanner.hh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ G4MaterialScanner.hh 8 May 2006 20:08:29 -0000 1.3
@@ -0,0 +1,124 @@
+//
+// ********************************************************************
+// * DISCLAIMER *
+// * *
+// * The following disclaimer summarizes all the specific disclaimers *
+// * of contributors to this software. The specific disclaimers,which *
+// * govern, are listed with their locations in: *
+// * http://cern.ch/geant4/license *
+// * *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work make any representation or warranty, express or implied, *
+// * regarding this software system or assume any liability for its *
+// * use. *
+// * *
+// * This code implementation is the intellectual property of the *
+// * GEANT4 collaboration. *
+// * By copying, distributing or modifying the Program (or any work *
+// * based on the Program) you indicate your acceptance of this *
+// * statement, and all its terms. *
+// ********************************************************************
+//
+//
+// $Id: G4MaterialScanner.hh,v 1.3 2006/05/08 20:08:29 jeremy Exp $
+// GEANT4 tag $Name: $
+//
+//
+
+
+#ifndef G4MaterialScanner_H
+#define G4MaterialScanner_H 1
+
+// class description:
+//
+// G4MaterialScanner
+//
+
+#include "globals.hh"
+#include "G4ThreeVector.hh"
+
+class G4Event;
+class G4EventManager;
+class G4UserEventAction;
+class G4UserStackingAction;
+class G4UserTrackingAction;
+class G4UserSteppingAction;
+class G4MSSteppingAction;
+class G4MatScanMessenger;
+class G4RayShooter;
+class G4Region;
+
+class G4MaterialScanner
+{
+ public: // with description
+ G4MaterialScanner();
+
+ public:
+ ~G4MaterialScanner();
+
+ public: // with description
+ void Scan();
+ // The main entry point which triggers ray tracing.
+ // This method is available only if Geant4 is at Idle state.
+
+ private:
+ void DoScan();
+ // Event loop
+ void StoreUserActions();
+ void RestoreUserActions();
+ // Store and restore user action classes if defined
+
+ private:
+ G4RayShooter * theRayShooter;
+ G4MatScanMessenger * theMessenger;
+
+ G4EventManager * theEventManager;
+
+ G4UserEventAction * theUserEventAction;
+ G4UserStackingAction * theUserStackingAction;
+ G4UserTrackingAction * theUserTrackingAction;
+ G4UserSteppingAction * theUserSteppingAction;
+
+ G4UserEventAction * theMatScannerEventAction;
+ G4UserStackingAction * theMatScannerStackingAction;
+ G4UserTrackingAction * theMatScannerTrackingAction;
+ G4MSSteppingAction * theMatScannerSteppingAction;
+
+ G4ThreeVector eyePosition;
+ G4int nTheta;
+ G4double thetaMin;
+ G4double thetaSpan;
+ G4int nPhi;
+ G4double phiMin;
+ G4double phiSpan;
+
+ G4ThreeVector eyeDirection;
+
+ G4bool regionSensitive;
+ G4String regionName;
+ G4Region* theRegion;
+
+ public:
+ inline void SetEyePosition(const G4ThreeVector& val) { eyePosition = val; }
+ inline G4ThreeVector GetEyePosition() const { return eyePosition; }
+ inline void SetNTheta(G4int val) { nTheta = val; }
+ inline G4int GetNTheta() const { return nTheta; }
+ inline void SetThetaMin(G4double val) { thetaMin = val; }
+ inline G4double GetThetaMin() const { return thetaMin; }
+ inline void SetThetaSpan(G4double val) { thetaSpan = val; }
+ inline G4double GetThetaSpan() const { return thetaSpan; }
+ inline void SetNPhi(G4int val) { nPhi = val; }
+ inline G4int GetNPhi() const { return nPhi; }
+ inline void SetPhiMin(G4double val) { phiMin = val; }
+ inline G4double GetPhiMin() const { return phiMin; }
+ inline void SetPhiSpan(G4double val) { phiSpan = val; }
+ inline G4double GetPhiSpan() const { return phiSpan; }
+ inline void SetRegionSensitive(G4bool val=true) { regionSensitive = val; }
+ inline G4bool GetRegionSensitive() const { return regionSensitive; }
+ G4bool SetRegionName(const G4String& val);
+ inline G4String GetRegionName() const { return regionName; }
+
+};
+
+#endif
slic/include
diff -u -r1.39 -r1.40
--- G4Application.hh 10 Apr 2006 21:05:07 -0000 1.39
+++ G4Application.hh 8 May 2006 20:08:29 -0000 1.40
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/G4Application.hh,v 1.39 2006/04/10 21:05:07 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/G4Application.hh,v 1.40 2006/05/08 20:08:29 jeremy Exp $
#ifndef slic_G4Application_hh
#define slic_G4Application_hh 1
@@ -11,9 +11,10 @@
#ifdef G4VIS_USE
#include "VisManager.hh"
#endif
-
#include "G4UIsession.hh"
+#include "G4MatScanMessenger.hh"
+
// std
#include <iostream>
#include <string>
slic/include
diff -u -r1.9 -r1.10
--- SteppingAction.hh 9 Feb 2006 03:05:20 -0000 1.9
+++ SteppingAction.hh 8 May 2006 20:08:29 -0000 1.10
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/SteppingAction.hh,v 1.9 2006/02/09 03:05:20 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/SteppingAction.hh,v 1.10 2006/05/08 20:08:29 jeremy Exp $
#ifndef slic_SteppingAction_hh
#define slic_SteppingAction_hh 1
@@ -9,7 +9,7 @@
#include "G4StepPoint.hh"
// Makoto's material scanner.
-//#include "G4MSSteppingAction.hh"
+#include "G4MSSteppingAction.hh"
class G4UserRegionInformation;
@@ -25,10 +25,9 @@
public:
SteppingAction();
virtual ~SteppingAction();
-
virtual void UserSteppingAction(const G4Step*);
-// private:
-// G4MSSteppingAction* scanner;
+ private:
+ G4MSSteppingAction* scanner;
};
}
slic/src
diff -N G4MSSteppingAction.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ G4MSSteppingAction.cc 8 May 2006 20:08:30 -0000 1.3
@@ -0,0 +1,69 @@
+//
+// ********************************************************************
+// * DISCLAIMER *
+// * *
+// * The following disclaimer summarizes all the specific disclaimers *
+// * of contributors to this software. The specific disclaimers,which *
+// * govern, are listed with their locations in: *
+// * http://cern.ch/geant4/license *
+// * *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work make any representation or warranty, express or implied, *
+// * regarding this software system or assume any liability for its *
+// * use. *
+// * *
+// * This code implementation is the intellectual property of the *
+// * GEANT4 collaboration. *
+// * By copying, distributing or modifying the Program (or any work *
+// * based on the Program) you indicate your acceptance of this *
+// * statement, and all its terms. *
+// ********************************************************************
+//
+//
+// $Id: G4MSSteppingAction.cc,v 1.3 2006/05/08 20:08:30 jeremy Exp $
+// GEANT4 tag $Name: $
+//
+//
+//
+
+
+#include "G4MSSteppingAction.hh"
+
+#include "G4Step.hh"
+#include "G4VPhysicalVolume.hh"
+#include "G4LogicalVolume.hh"
+#include "G4Region.hh"
+#include "G4Material.hh"
+
+G4MSSteppingAction::G4MSSteppingAction()
+{
+ Initialize(false,0);
+}
+
+G4MSSteppingAction::~G4MSSteppingAction()
+{;}
+
+void G4MSSteppingAction::Initialize(G4bool rSens,G4Region* reg)
+{
+ regionSensitive = rSens;
+ theRegion = reg;
+ length = 0.;
+ x0 = 0.;
+ lambda = 0.;
+}
+
+void G4MSSteppingAction::UserSteppingAction(const G4Step* aStep)
+{
+ G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
+ G4Region* region = preStepPoint->GetPhysicalVolume()->GetLogicalVolume()->GetRegion();
+
+ if(regionSensitive && (region!=theRegion)) return;
+
+ G4double stlen = aStep->GetStepLength();
+ G4Material* material = preStepPoint->GetMaterial();
+ length += stlen;
+ x0 += stlen/(material->GetRadlen());
+ lambda += stlen/(material->GetNuclearInterLength());
+}
+
slic/src
diff -N G4MatScanMessenger.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ G4MatScanMessenger.cc 8 May 2006 20:08:30 -0000 1.3
@@ -0,0 +1,243 @@
+//
+// ********************************************************************
+// * DISCLAIMER *
+// * *
+// * The following disclaimer summarizes all the specific disclaimers *
+// * of contributors to this software. The specific disclaimers,which *
+// * govern, are listed with their locations in: *
+// * http://cern.ch/geant4/license *
+// * *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work make any representation or warranty, express or implied, *
+// * regarding this software system or assume any liability for its *
+// * use. *
+// * *
+// * This code implementation is the intellectual property of the *
+// * GEANT4 collaboration. *
+// * By copying, distributing or modifying the Program (or any work *
+// * based on the Program) you indicate your acceptance of this *
+// * statement, and all its terms. *
+// ********************************************************************
+//
+//
+// $Id: G4MatScanMessenger.cc,v 1.3 2006/05/08 20:08:30 jeremy Exp $
+// GEANT4 tag $Name: $
+//
+//
+//
+
+
+#include "G4MatScanMessenger.hh"
+
+#include "G4UIdirectory.hh"
+#include "G4UIcommand.hh"
+#include "G4UIparameter.hh"
+#include "G4UIcmdWithoutParameter.hh"
+#include "G4UIcmdWithABool.hh"
+#include "G4UIcmdWith3VectorAndUnit.hh"
+#include "G4UIcmdWithAString.hh"
+#include "G4MaterialScanner.hh"
+#include "G4ThreeVector.hh"
+#include "G4Tokenizer.hh"
+
+G4MatScanMessenger::G4MatScanMessenger(G4MaterialScanner* p1)
+{
+ theScanner = p1;
+ G4UIparameter* par;
+ msDirectory = new G4UIdirectory("/control/matScan/");
+ msDirectory->SetGuidance("Material scanner commands.");
+
+ scanCmd = new G4UIcmdWithoutParameter("/control/matScan/scan",this);
+ scanCmd->SetGuidance("Start material scanning.");
+ scanCmd->SetGuidance("Scanning range should be defined with");
+ scanCmd->SetGuidance("/control/matScan/theta and /control/matSca/phi commands.");
+ scanCmd->AvailableForStates(G4State_Idle);
+
+ thetaCmd = new G4UIcommand("/control/matScan/theta",this);
+ thetaCmd->SetGuidance("Define theta range.");
+ thetaCmd->SetGuidance("Usage : /control/matScan/theta [nbin] [thetaMin] [thetaSpan] [unit]");
+ thetaCmd->SetGuidance("Notation of angles :");
+ thetaCmd->SetGuidance(" theta --- +Z axis : +90 deg. / X-Y plane : 0 deg. / -Z axis : -90 deg.");
+ par = new G4UIparameter("nbin",'i',false);
+ par->SetParameterRange("nbin>0");
+ thetaCmd->SetParameter(par);
+ par = new G4UIparameter("thetaMin",'d',false);
+ thetaCmd->SetParameter(par);
+ par = new G4UIparameter("thetaSpan",'d',true);
+ par->SetParameterRange("thetaSpan>=0.");
+ par->SetDefaultValue(0.);
+ thetaCmd->SetParameter(par);
+ par = new G4UIparameter("unit",'c',true);
+ par->SetDefaultValue("deg");
+ par->SetParameterCandidates(thetaCmd->UnitsList(thetaCmd->CategoryOf("deg")));
+ thetaCmd->SetParameter(par);
+
+ phiCmd = new G4UIcommand("/control/matScan/phi",this);
+ phiCmd->SetGuidance("Define phi range.");
+ phiCmd->SetGuidance("Usage : /control/matScan/phi [nbin] [phiMin] [phiSpan] [unit]");
+ phiCmd->SetGuidance("Notation of angles :");
+ phiCmd->SetGuidance(" phi --- +X axis : 0 deg. / +Y axis : 90 deg. / -X axis : 180 deg. / -Y axis : 270 deg.");
+ par = new G4UIparameter("nbin",'i',false);
+ par->SetParameterRange("nbin>0");
+ phiCmd->SetParameter(par);
+ par = new G4UIparameter("phiMin",'d',false);
+ phiCmd->SetParameter(par);
+ par = new G4UIparameter("phiSpan",'d',true);
+ par->SetParameterRange("phiSpan>=0.");
+ par->SetDefaultValue(0.);
+ phiCmd->SetParameter(par);
+ par = new G4UIparameter("unit",'c',true);
+ par->SetDefaultValue("deg");
+ par->SetParameterCandidates(phiCmd->UnitsList(phiCmd->CategoryOf("deg")));
+ phiCmd->SetParameter(par);
+
+ singleCmd = new G4UIcommand("/control/matScan/singleMeasure",this);
+ singleCmd->SetGuidance("Measure thickness for one particular direction.");
+ singleCmd->SetGuidance("Notation of angles :");
+ singleCmd->SetGuidance(" theta --- +Z axis : +90 deg. / X-Y plane : 0 deg. / -Z axis : -90 deg.");
+ singleCmd->SetGuidance(" phi --- +X axis : 0 deg. / +Y axis : 90 deg. / -X axis : 180 deg. / -Y axis : 270 deg.");
+ singleCmd->AvailableForStates(G4State_Idle);
+ par = new G4UIparameter("theta",'d',false);
+ singleCmd->SetParameter(par);
+ par = new G4UIparameter("phi",'d',false);
+ singleCmd->SetParameter(par);
+ par = new G4UIparameter("unit",'c',true);
+ par->SetDefaultValue("deg");
+ par->SetParameterCandidates(singleCmd->UnitsList(singleCmd->CategoryOf("deg")));
+ singleCmd->SetParameter(par);
+
+ eyePosCmd = new G4UIcmdWith3VectorAndUnit("/control/matScan/eyePosition",this);
+ eyePosCmd->SetGuidance("Define the eye position.");
+ eyePosCmd->SetParameterName("X","Y","Z",true);
+ eyePosCmd->SetDefaultValue(G4ThreeVector(0.,0.,0.));
+ eyePosCmd->SetDefaultUnit("m");
+
+ regSenseCmd = new G4UIcmdWithABool("/control/matScan/regionSensitive",this);
+ regSenseCmd->SetGuidance("Set region sensitivity.");
+ regSenseCmd->SetGuidance("This command is automatically set to TRUE");
+ regSenseCmd->SetGuidance(" if /control/matScan/region command is issued.");
+ regSenseCmd->SetParameterName("senseFlag",true);
+ regSenseCmd->SetDefaultValue(false);
+
+ regionCmd = new G4UIcmdWithAString("/control/matScan/region",this);
+ regionCmd->SetGuidance("Define region name to be scanned.");
+ regionCmd->SetGuidance("/control/matScan/regionSensitive command is automatically");
+ regionCmd->SetGuidance("set to TRUE with this command.");
+ regionCmd->SetParameterName("region",true);
+ regionCmd->SetDefaultValue("DefaultRegionForTheWorld");
+}
+
+G4MatScanMessenger::~G4MatScanMessenger()
+{
+ delete scanCmd;
+ delete thetaCmd;
+ delete phiCmd;
+ delete singleCmd;
+ delete eyePosCmd;
+ delete regSenseCmd;
+ delete regionCmd;
+ delete msDirectory;
+}
+
+G4String G4MatScanMessenger::GetCurrentValue(G4UIcommand * command)
+{
+ G4String currentValue;
+ if(command==thetaCmd)
+ {
+ currentValue = thetaCmd->ConvertToString(theScanner->GetNTheta());
+ currentValue += " ";
+ currentValue += thetaCmd->ConvertToString((theScanner->GetThetaMin())/deg);
+ currentValue += " ";
+ currentValue += thetaCmd->ConvertToString((theScanner->GetThetaSpan())/deg);
+ }
+ else if(command==phiCmd)
+ {
+ currentValue = phiCmd->ConvertToString(theScanner->GetNPhi());
+ currentValue += " ";
+ currentValue += phiCmd->ConvertToString((theScanner->GetPhiMin())/deg);
+ currentValue += " ";
+ currentValue += phiCmd->ConvertToString((theScanner->GetPhiSpan())/deg);
+ }
+ else if(command==eyePosCmd)
+ { currentValue = eyePosCmd->ConvertToString(theScanner->GetEyePosition(),"m"); }
+ else if(command==regSenseCmd)
+ { currentValue = regSenseCmd->ConvertToString(theScanner->GetRegionSensitive()); }
+ else if(command==regionCmd)
+ { currentValue = theScanner->GetRegionName(); }
+ return currentValue;
+}
+
+void G4MatScanMessenger::SetNewValue(G4UIcommand * command,G4String newValue)
+{
+ if(command==scanCmd)
+ { theScanner->Scan(); }
+ else if(command==thetaCmd)
+ {
+ G4Tokenizer next( newValue );
+ G4int nbin = StoI(next());
+ G4double thetaMin = StoD(next());
+ G4double thetaSpan = StoD(next());
+ G4String unit = next();
+ thetaMin *= thetaCmd->ValueOf(unit);
+ thetaSpan *= thetaCmd->ValueOf(unit);
+ theScanner->SetNTheta(nbin);
+ theScanner->SetThetaMin(thetaMin);
+ theScanner->SetThetaSpan(thetaSpan);
+ }
+ else if(command==phiCmd)
+ {
+ G4Tokenizer next( newValue );
+ G4int nbin = StoI(next());
+ G4double phiMin = StoD(next());
+ G4double phiSpan = StoD(next());
+ G4String unit = next();
+ phiMin *= phiCmd->ValueOf(unit);
+ phiSpan *= phiCmd->ValueOf(unit);
+ theScanner->SetNPhi(nbin);
+ theScanner->SetPhiMin(phiMin);
+ theScanner->SetPhiSpan(phiSpan);
+ }
+ else if(command==eyePosCmd)
+ { theScanner->SetEyePosition(eyePosCmd->GetNew3VectorValue(newValue)); }
+ else if(command==regSenseCmd)
+ { theScanner->SetRegionSensitive(regSenseCmd->GetNewBoolValue(newValue)); }
+ else if(command==regionCmd)
+ { if(theScanner->SetRegionName(newValue)) theScanner->SetRegionSensitive(true); }
+ else if(command==singleCmd)
+ {
+ G4int ntheta = theScanner->GetNTheta();
+ G4double thetaMin = theScanner->GetThetaMin();
+ G4double thetaSpan = theScanner->GetThetaSpan();
+ G4int nphi = theScanner->GetNPhi();
+ G4double phiMin = theScanner->GetPhiMin();
+ G4double phiSpan = theScanner->GetPhiSpan();
+
+ G4Tokenizer next( newValue );
+ G4double theta = StoD(next());
+ G4double phi = StoD(next());
+ G4String unit = next();
+ theta *= singleCmd->ValueOf(unit);
+ phi *= singleCmd->ValueOf(unit);
+ theScanner->SetNTheta(1);
+ theScanner->SetThetaMin(theta);
+ theScanner->SetThetaSpan(0.);
+ theScanner->SetNPhi(1);
+ theScanner->SetPhiMin(phi);
+ theScanner->SetPhiSpan(0.);
+ theScanner->Scan();
+
+ theScanner->SetNTheta(ntheta);
+ theScanner->SetThetaMin(thetaMin);
+ theScanner->SetThetaSpan(thetaSpan);
+ theScanner->SetNPhi(nphi);
+ theScanner->SetPhiMin(phiMin);
+ theScanner->SetPhiSpan(phiSpan);
+ }
+
+}
+
+
+
+
+
slic/src
diff -N G4MaterialScanner.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ G4MaterialScanner.cc 8 May 2006 20:08:30 -0000 1.3
@@ -0,0 +1,229 @@
+//
+// ********************************************************************
+// * DISCLAIMER *
+// * *
+// * The following disclaimer summarizes all the specific disclaimers *
+// * of contributors to this software. The specific disclaimers,which *
+// * govern, are listed with their locations in: *
+// * http://cern.ch/geant4/license *
+// * *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work make any representation or warranty, express or implied, *
+// * regarding this software system or assume any liability for its *
+// * use. *
+// * *
+// * This code implementation is the intellectual property of the *
+// * GEANT4 collaboration. *
+// * By copying, distributing or modifying the Program (or any work *
+// * based on the Program) you indicate your acceptance of this *
+// * statement, and all its terms. *
+// ********************************************************************
+//
+//
+// $Id: G4MaterialScanner.cc,v 1.3 2006/05/08 20:08:30 jeremy Exp $
+// GEANT4 tag $Name: $
+//
+//
+//
+
+
+#include "G4MaterialScanner.hh"
+#include "G4EventManager.hh"
+#include "G4MatScanMessenger.hh"
+#include "G4RayShooter.hh"
+#include "G4MSSteppingAction.hh"
+#include "G4GeometryManager.hh"
+#include "G4StateManager.hh"
+#include "G4Event.hh"
+#include "G4TransportationManager.hh"
+#include "G4ProductionCutsTable.hh"
+#include "G4Region.hh"
+#include "G4RegionStore.hh"
+#include "G4ProcessManager.hh"
+#include "G4ProcessVector.hh"
+#include "G4Geantino.hh"
+#include "G4SDManager.hh"
+
+
+G4MaterialScanner::G4MaterialScanner()
+{
+ theRayShooter = new G4RayShooter();
+ theMessenger = new G4MatScanMessenger(this);
+ theEventManager = G4EventManager::GetEventManager();
+
+ theUserEventAction = 0;
+ theUserStackingAction = 0;
+ theUserTrackingAction = 0;
+ theUserSteppingAction = 0;
+
+ theMatScannerEventAction = 0;
+ theMatScannerStackingAction = 0;
+ theMatScannerTrackingAction = 0;
+ theMatScannerSteppingAction = new G4MSSteppingAction();
+
+ eyePosition = G4ThreeVector(0.,0.,0.);
+ nTheta = 91;
+ thetaMin = 0.*deg;
+ thetaSpan = 90.*deg;
+ nPhi = 37;
+ phiMin = 0.*deg;
+ phiSpan = 360.*deg;
+
+ regionSensitive = false;
+ regionName = "notDefined";
+ theRegion = 0;
+}
+
+G4MaterialScanner::~G4MaterialScanner()
+{
+ delete theRayShooter;
+ delete theMatScannerSteppingAction;
+ delete theMessenger;
+}
+
+void G4MaterialScanner::Scan()
+{
+ G4StateManager* theStateMan = G4StateManager::GetStateManager();
+ G4ApplicationState currentState = theStateMan->GetCurrentState();
+ if(currentState!=G4State_Idle)
+ {
+ G4cerr << "Illegal application state - Scan() ignored." << G4endl;
+ return;
+ }
+
+ StoreUserActions();
+ DoScan();
+ RestoreUserActions();
+}
+
+void G4MaterialScanner::StoreUserActions()
+{
+ theUserEventAction = theEventManager->GetUserEventAction();
+ theUserStackingAction = theEventManager->GetUserStackingAction();
+ theUserTrackingAction = theEventManager->GetUserTrackingAction();
+ theUserSteppingAction = theEventManager->GetUserSteppingAction();
+
+ theEventManager->SetUserAction(theMatScannerEventAction);
+ theEventManager->SetUserAction(theMatScannerStackingAction);
+ theEventManager->SetUserAction(theMatScannerTrackingAction);
+ theEventManager->SetUserAction(theMatScannerSteppingAction);
+
+ G4SDManager* theSDMan = G4SDManager::GetSDMpointerIfExist();
+ if(theSDMan)
+ { theSDMan->Activate("/",false); }
+
+ G4GeometryManager* theGeomMan = G4GeometryManager::GetInstance();
+ theGeomMan->OpenGeometry();
+ theGeomMan->CloseGeometry(true);
+}
+
+void G4MaterialScanner::RestoreUserActions()
+{
+ theEventManager->SetUserAction(theUserEventAction);
+ theEventManager->SetUserAction(theUserStackingAction);
+ theEventManager->SetUserAction(theUserTrackingAction);
+ theEventManager->SetUserAction(theUserSteppingAction);
+
+ G4SDManager* theSDMan = G4SDManager::GetSDMpointerIfExist();
+ if(theSDMan)
+ { theSDMan->Activate("/",true); }
+}
+
+void G4MaterialScanner::DoScan()
+{
+// Confirm process(es) of Geantino is initialized
+ G4VPhysicalVolume* wv = G4TransportationManager::GetTransportationManager()
+ ->GetNavigatorForTracking()->GetWorldVolume();
+
+ G4RegionStore::GetInstance()->UpdateMaterialList(wv);
+ G4ProductionCutsTable::GetProductionCutsTable()->UpdateCoupleTable(wv);
+ G4ProcessVector* pVector
+ = G4Geantino::GeantinoDefinition()->GetProcessManager()->GetProcessList();
+ for (G4int j=0; j < pVector->size(); ++j) {
+ (*pVector)[j]->BuildPhysicsTable(*(G4Geantino::GeantinoDefinition()));
+ }
+
+// Close geometry and set the application state
+ G4GeometryManager* geomManager = G4GeometryManager::GetInstance();
+ geomManager->OpenGeometry();
+ geomManager->CloseGeometry(1,0);
+
+ G4ThreeVector center(0,0,0);
+ G4Navigator* navigator =
+ G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking();
+ navigator->LocateGlobalPointAndSetup(center,0,false);
+
+ G4StateManager* theStateMan = G4StateManager::GetStateManager();
+ theStateMan->SetNewState(G4State_GeomClosed);
+
+// Event loop
+ G4int iEvent = 0;
+ for(G4int iTheta=0;iTheta<nTheta;iTheta++)
+ {
+ G4double theta = thetaMin;
+ if(iTheta>0) theta += G4double(iTheta)*thetaSpan/G4double(nTheta-1);
+ G4double aveLength = 0.;
+ G4double aveX0 = 0.;
+ G4double aveLambda = 0.;
+ G4cout << G4endl;
+ G4cout << " Theta(deg) Phi(deg) Length(mm) x0 lambda0" << G4endl;
+ G4cout << G4endl;
+ for(G4int iPhi=0;iPhi<nPhi;iPhi++)
+ {
+ G4Event* anEvent = new G4Event(iEvent++);
+ G4double phi = phiMin;
+ if(iPhi>0) phi += G4double(iPhi)*phiSpan/G4double(nPhi-1);
+ eyeDirection = G4ThreeVector(std::cos(theta)*std::cos(phi),
+ std::cos(theta)*std::sin(phi),
+ std::sin(theta));
+ theRayShooter->Shoot(anEvent,eyePosition,eyeDirection);
+ theMatScannerSteppingAction->Initialize(regionSensitive,theRegion);
+ theEventManager->ProcessOneEvent(anEvent);
+ G4double length = theMatScannerSteppingAction->GetTotalStepLength();
+ G4double x0 = theMatScannerSteppingAction->GetX0();
+ G4double lambda = theMatScannerSteppingAction->GetLambda0();
+
+ G4cout << " "
+ << std::setw(11) << theta/deg << " "
+ << std::setw(11) << phi/deg << " "
+ << std::setw(11) << length/mm << " "
+ << std::setw(11) << x0 << " "
+ << std::setw(11) << lambda << G4endl;
+ aveLength += length/mm;
+ aveX0 += x0;
+ aveLambda += lambda;
+ }
+ if(nPhi>1)
+ {
+ G4cout << G4endl;
+ G4cout << " ave. for theta = " << std::setw(11) << theta/deg << " : "
+ << std::setw(11) << aveLength/nPhi << " "
+ << std::setw(11) << aveX0/nPhi << " "
+ << std::setw(11) << aveLambda/nPhi << G4endl;
+ }
+ }
+
+ theStateMan->SetNewState(G4State_Idle);
+ return;
+}
+
+G4bool G4MaterialScanner::SetRegionName(const G4String& val)
+{
+ G4Region* aRegion = G4RegionStore::GetInstance()->GetRegion(val);
+ if(aRegion)
+ {
+ theRegion = aRegion;
+ regionName = val;
+ return true;
+ }
+ else
+ {
+ G4cerr << "Region <" << val << "> not found. Command ignored." << G4endl;
+ G4cerr << "Defined regions are : " << G4endl;
+ for(size_t i=0;i<G4RegionStore::GetInstance()->size();i++)
+ { G4cerr << " " << (*(G4RegionStore::GetInstance()))[i]->GetName(); }
+ G4cerr << G4endl;
+ return false;
+ }
+}
slic/src
diff -u -r1.65 -r1.66
--- G4Application.cc 10 Apr 2006 21:05:07 -0000 1.65
+++ G4Application.cc 8 May 2006 20:08:30 -0000 1.66
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/G4Application.cc,v 1.65 2006/04/10 21:05:07 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/G4Application.cc,v 1.66 2006/05/08 20:08:30 jeremy Exp $
#include "G4Application.hh"
// slic
@@ -25,6 +25,9 @@
#include "LCDDParser.hh"
#include "StoreInspector.hh"
+#include "G4MatScanMessenger.hh"
+#include "G4MaterialScanner.hh"
+
// geant4
#include "G4RunManager.hh"
#include "G4StateManager.hh"
slic/src
diff -u -r1.12 -r1.13
--- RunManager.cc 19 Dec 2005 23:53:31 -0000 1.12
+++ RunManager.cc 8 May 2006 20:08:30 -0000 1.13
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/RunManager.cc,v 1.12 2005/12/19 23:53:31 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/RunManager.cc,v 1.13 2006/05/08 20:08:30 jeremy Exp $
#include "RunManager.hh"
// lcdd
@@ -12,6 +12,9 @@
#include "G4StateManager.hh"
#include "G4UImanager.hh"
+#include "G4MatScanMessenger.hh"
+#include "G4MaterialScanner.hh"
+
namespace slic
{
@@ -33,6 +36,9 @@
if ( pmgr->enableLimits() ) {
pmgr->setupUserLimitsProcesses();
}
+
+ // Setup material scanner.
+ new G4MatScanMessenger(new G4MaterialScanner());
}
// called before InitializePhysics()
slic/src
diff -u -r1.10 -r1.11
--- SteppingAction.cc 9 Feb 2006 03:05:21 -0000 1.10
+++ SteppingAction.cc 8 May 2006 20:08:31 -0000 1.11
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/SteppingAction.cc,v 1.10 2006/02/09 03:05:21 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/SteppingAction.cc,v 1.11 2006/05/08 20:08:31 jeremy Exp $
#include "SteppingAction.hh"
// slic
@@ -15,7 +15,7 @@
SteppingAction::SteppingAction()
{
-// scanner = new G4MSSteppingAction();
+ scanner = new G4MSSteppingAction();
}
SteppingAction::~SteppingAction()
@@ -27,7 +27,7 @@
TrajectoryManager::instance()->stepping( aStep );
// Materials scanner
-// scanner->UserSteppingAction(aStep);
+ scanner->UserSteppingAction(aStep);
}
}
CVSspam 0.2.8