Skip to content

Commit 9784b8b

Browse files
author
David Webber
committed
Merging -r 256:270 of branches/dev/PhysicsLists into trunk. Users should not see any change in functionality; The default physics list is the former WCSimPhysicsList. One minor bug is the WCSim hadronic model (GHEISHA, BERTINI, BINARY) is no longer selectable from jobOptions.mac since the physics list isn't yet instantiated when this macro is read. BINARY is the default. Suggestions are welcome.
1 parent 88c2812 commit 9784b8b

10 files changed

+239
-14
lines changed

GNUmakefile

+3-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ libWCSim.a : $(ROOTOBJS)
5858
$(RM) $@
5959
ar clq $@ $(ROOTOBJS)
6060

61-
rootcint : $(ROOTSRC)
61+
./src/WCSimRootDict.cc : $(ROOTSRC)
6262
rootcint -f ./src/WCSimRootDict.cc -c -I./include -I$(shell root-config --incdir) WCSimRootEvent.hh WCSimRootGeom.hh WCSimPmtInfo.hh WCSimRootLinkDef.hh
6363

64+
rootcint: ./src/WCSimRootDict.cc
65+
6466
include $(G4INSTALL)/config/binmake.gmk

WCSim.cc

+14-6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#include "WCSimDetectorConstruction.hh"
77
#include "WCSimPhysicsList.hh"
88
#include "WCSimPhysicsMessenger.hh"
9+
#include "WCSimPhysicsListFactory.hh"
10+
#include "WCSimPhysicsListFactoryMessenger.hh"
911
#include "WCSimTuningParameters.hh"
1012
#include "WCSimTuningMessenger.hh"
1113
#include "WCSimPrimaryGeneratorAction.hh"
@@ -24,7 +26,7 @@ int main(int argc,char** argv)
2426

2527
// get the pointer to the UI manager
2628
G4UImanager* UI = G4UImanager::GetUIpointer();
27-
29+
2830
// Set up the tuning parameters that need to be read before the detector
2931
// construction is done
3032
WCSimTuningParameters* tuningpars = new WCSimTuningParameters();
@@ -41,7 +43,9 @@ int main(int argc,char** argv)
4143

4244
runManager->SetUserInitialization(WCSimdetector);
4345

44-
runManager->SetUserInitialization(new WCSimPhysicsList);
46+
// Added selectable physics lists 2010-07 by DMW
47+
// Set up the messenger hooks here, initialize the actual list after loading jobOptions.mac
48+
WCSimPhysicsListFactory *physFactory = new WCSimPhysicsListFactory();
4549

4650
//=================================
4751
// Added by JLR 2005-07-05
@@ -53,6 +57,10 @@ int main(int argc,char** argv)
5357
// Currently, default model is set to BINARY
5458
UI->ApplyCommand("/control/execute jobOptions.mac");
5559

60+
// Initialize the physics factory to register the selected physics.
61+
physFactory->InitializeList();
62+
runManager->SetUserInitialization(physFactory);
63+
5664
// Visualization
5765
G4VisManager* visManager = new WCSimVisManager;
5866
visManager->Initialize();
@@ -62,19 +70,19 @@ int main(int argc,char** argv)
6270
WCSimPrimaryGeneratorAction(WCSimdetector);
6371
runManager->SetUserAction(myGeneratorAction);
6472

65-
6673

6774
WCSimRunAction* myRunAction = new WCSimRunAction(WCSimdetector);
6875
runManager->SetUserAction(myRunAction);
6976

7077
runManager->SetUserAction(new WCSimEventAction(myRunAction, WCSimdetector,
71-
myGeneratorAction));
78+
myGeneratorAction));
7279
runManager->SetUserAction(new WCSimTrackingAction);
7380

7481
runManager->SetUserAction(new WCSimStackingAction(WCSimdetector));
7582

7683
runManager->SetUserAction(new WCSimSteppingAction);
7784

85+
7886
// Initialize G4 kernel
7987
runManager->Initialize();
8088

@@ -83,13 +91,13 @@ int main(int argc,char** argv)
8391

8492
// Start UI Session
8593
G4UIsession* session = new G4UIterminal(new G4UItcsh);
86-
94+
8795
// Visualization Macro
8896
UI->ApplyCommand("/control/execute vis.mac");
8997

9098
// Start Interactive Mode
9199
session->SessionStart();
92-
100+
93101
delete session;
94102
}
95103
else // Batch mode

include/WCSimPhysicsList.hh

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11

22
#ifndef WCSimPhysicsList_h
33
#define WCSimPhysicsList_h 1
4-
#include "G4VUserPhysicsList.hh"
4+
//#include "G4VUserPhysicsList.hh"
5+
#include "G4VPhysicsConstructor.hh"
56
#include "WCSimPhysicsMessenger.hh"
67
#include "globals.hh"
78

8-
class WCSimPhysicsList: public G4VUserPhysicsList
9+
//class WCSimPhysicsList: public G4VUserPhysicsList
10+
class WCSimPhysicsList: public G4VPhysicsConstructor
911
{
1012
public:
1113
WCSimPhysicsList();

include/WCSimPhysicsListFactory.hh

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#ifndef WCSimPhysicsListFactory_h
2+
#define WCSimPhysicsListFactory_h 1
3+
4+
#include "globals.hh"
5+
#include "G4VModularPhysicsList.hh"
6+
#include "G4PhysListFactory.hh"
7+
#include "G4UnitsTable.hh"
8+
#include "G4OpticalPhysics.hh"
9+
10+
#include "WCSimPhysicsListFactoryMessenger.hh"
11+
#include "WCSimPhysicsList.hh"
12+
13+
//class WCSimPhysicsList;
14+
15+
class WCSimPhysicsListFactory : public G4VModularPhysicsList
16+
{
17+
public:
18+
WCSimPhysicsListFactory();
19+
~WCSimPhysicsListFactory();
20+
21+
void SetList(G4String newvalue); // called by messenger
22+
void InitializeList();
23+
24+
//G4String GetPhysicsListName() {return PhysicsListName;}
25+
26+
void ConstructParticle();
27+
void ConstructProcess();
28+
void SetCuts();
29+
private:
30+
31+
G4String PhysicsListName;
32+
G4String ValidListsString;
33+
34+
WCSimPhysicsListFactoryMessenger* PhysicsMessenger;
35+
G4PhysListFactory* factory;
36+
};
37+
38+
#endif
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#ifndef WCSimPhysicsListFactoryMessenger_h
2+
#define WCSimPhysicsListFactoryMessenger_h 1
3+
4+
#include "globals.hh"
5+
#include "G4UImessenger.hh"
6+
7+
class WCSimPhysicsListFactory;
8+
class G4UIdirectory;
9+
class G4UIcommand;
10+
class G4UIcmdWithAString;
11+
12+
class WCSimPhysicsListFactoryMessenger: public G4UImessenger
13+
{
14+
public:
15+
WCSimPhysicsListFactoryMessenger(WCSimPhysicsListFactory*, G4String);
16+
~WCSimPhysicsListFactoryMessenger();
17+
18+
void SetNewValue(G4UIcommand* command, G4String newValue);
19+
20+
private:
21+
WCSimPhysicsListFactory* thisWCSimPhysicsListFactory;
22+
G4String ValidListsString;
23+
24+
G4UIdirectory* WCSimDir;
25+
G4UIcmdWithAString* physListCmd;
26+
27+
};
28+
29+
#endif

jobOptions.mac

+8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1+
#/WCSim/physics/list QGSP_BIC_HP #preferred?
2+
/WCSim/physics/list WCSim #old list
3+
#/WCSim/physics/list LBE #broken
4+
5+
16
# Choose hadronic interaction model.
7+
# Note: WCSim physics list only
8+
# Note2: Probably broken because this file is read before WCSim object instantiation
29
# Options:
310
# GHEISHA (Original Geant4 model)
411
# BERTINI (Bertini intra-nuclear cascade model)
512
# BINARY (Binary intra-nuclear cascade model) -- this is the default
613
/WCSim/physics/secondaries/model BINARY
14+

src/WCSimPhysicsList.cc

+6-4
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@
2424
#include "G4HadronCaptureProcess.hh" //amb79
2525

2626

27-
WCSimPhysicsList::WCSimPhysicsList(): G4VUserPhysicsList(), PhysicsMessenger(0)
27+
//WCSimPhysicsList::WCSimPhysicsList(): G4VUserPhysicsList(), PhysicsMessenger(0)
28+
WCSimPhysicsList::WCSimPhysicsList(): G4VPhysicsConstructor(), PhysicsMessenger(0)
2829
{
29-
defaultCutValue = 1.0*mm;
30+
//defaultCutValue = 1.0*mm;
3031
SetVerboseLevel(1);
3132

3233
PhysicsMessenger = new WCSimPhysicsMessenger(this);
@@ -60,7 +61,7 @@ void WCSimPhysicsList::ConstructParticle()
6061

6162
void WCSimPhysicsList::ConstructProcess()
6263
{
63-
AddTransportation();
64+
//AddTransportation();
6465
ConstructEM();
6566
ConstructlArStepLimiter();
6667
ConstructGeneral();
@@ -721,7 +722,7 @@ void WCSimPhysicsList::SetSecondaryHad(G4String hadval)
721722
}
722723

723724
//----set cut values----
724-
725+
/*
725726
void WCSimPhysicsList::SetCuts()
726727
{
727728
if (verboseLevel >0){
@@ -738,3 +739,4 @@ void WCSimPhysicsList::SetCuts()
738739
739740
if (verboseLevel>0) DumpCutValuesTable();
740741
}
742+
*/

src/WCSimPhysicsListFactory.cc

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
#include "WCSimPhysicsListFactory.hh"
2+
3+
/* This code draws upon examples/extended/fields/field04 for inspiration */
4+
5+
6+
7+
WCSimPhysicsListFactory::WCSimPhysicsListFactory() : G4VModularPhysicsList()
8+
{
9+
defaultCutValue = 1.0*mm;
10+
SetVerboseLevel(1);
11+
12+
PhysicsListName="NULL_LIST"; // default list is set in WCSimPhysicsListFactoryMessenger to QGSP_BERT
13+
factory = new G4PhysListFactory();
14+
// TODO create opticalPhyscics object?
15+
16+
std::vector<G4String> ValidListsVector = factory->AvailablePhysLists();
17+
ValidListsVector.push_back("WCSim");// add deprecated WCSimPhysicsList.cc as a selectable option
18+
G4int nlists = ValidListsVector.size();
19+
G4cout << "There are " << nlists << " available physics lists, and they are: " << G4endl;
20+
for (G4int i=0; i<nlists; i++){
21+
G4cout << " " << ValidListsVector[i] << G4endl;
22+
ValidListsString += ValidListsVector[i];
23+
ValidListsString += " ";
24+
}
25+
//G4cout << "ValidListsString=" << ValidListsString << G4endl;
26+
27+
PhysicsMessenger = new WCSimPhysicsListFactoryMessenger(this, ValidListsString);
28+
29+
}
30+
31+
WCSimPhysicsListFactory::~WCSimPhysicsListFactory()
32+
{
33+
delete PhysicsMessenger;
34+
PhysicsMessenger = NULL;
35+
36+
}
37+
38+
void WCSimPhysicsListFactory::ConstructParticle()
39+
{
40+
G4VModularPhysicsList::ConstructParticle();
41+
}
42+
43+
void WCSimPhysicsListFactory::ConstructProcess()
44+
{
45+
G4VModularPhysicsList::ConstructProcess();
46+
}
47+
48+
void WCSimPhysicsListFactory::SetCuts()
49+
{
50+
// same as WCSimPhysicsList
51+
if (verboseLevel >0){
52+
G4cout << "WCSimPhysicsListFactory::SetCuts:";
53+
G4cout << "CutLength : " << G4BestUnit(defaultCutValue,"Length") << G4endl;
54+
}
55+
56+
// set cut values for gamma at first and for e- second and next for e+,
57+
// because some processes for e+/e- need cut values for gamma
58+
//
59+
SetCutValue(defaultCutValue, "gamma");
60+
SetCutValue(defaultCutValue, "e-");
61+
SetCutValue(defaultCutValue, "e+");
62+
63+
if (verboseLevel>0) DumpCutValuesTable();
64+
65+
}
66+
67+
void WCSimPhysicsListFactory::SetList(G4String newvalue){
68+
G4cout << "Setting Physics list to " << newvalue << " and delaying initialization" << G4endl;
69+
PhysicsListName = newvalue;
70+
}
71+
72+
void WCSimPhysicsListFactory::InitializeList(){
73+
G4cout << "Initializing physics list " << PhysicsListName << G4endl;
74+
75+
G4VModularPhysicsList* phys = 0;
76+
77+
if (factory->IsReferencePhysList(PhysicsListName)) {
78+
phys=factory->GetReferencePhysList(PhysicsListName);
79+
for (G4int i = 0; ; ++i) {
80+
G4VPhysicsConstructor* elem =
81+
const_cast<G4VPhysicsConstructor*> (phys->GetPhysics(i));
82+
if (elem == NULL) break;
83+
G4cout << "RegisterPhysics: " << elem->GetPhysicsName() << G4endl;
84+
RegisterPhysics(elem);
85+
}
86+
G4cout << "RegisterPhysics: OpticalPhysics" << G4endl;
87+
RegisterPhysics(new G4OpticalPhysics());
88+
} else if (PhysicsListName == "WCSim") {
89+
//G4cout << "WCSim physics list not yet implemented" << G4endl;
90+
G4cout << "RegisterPhysics: WCSim" << G4endl;
91+
RegisterPhysics(new WCSimPhysicsList());
92+
} else {
93+
G4cout << "Physics list " << PhysicsListName << " is not understood" << G4endl;
94+
}
95+
}
+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#include "WCSimPhysicsListFactoryMessenger.hh"
2+
#include "WCSimPhysicsListFactory.hh"
3+
4+
#include "G4UIdirectory.hh"
5+
#include "G4ios.hh"
6+
#include "globals.hh"
7+
#include "G4UIcmdWithAString.hh"
8+
9+
WCSimPhysicsListFactoryMessenger::WCSimPhysicsListFactoryMessenger(WCSimPhysicsListFactory* WCSimPhysFactory, G4String inValidListsString)
10+
:thisWCSimPhysicsListFactory(WCSimPhysFactory), ValidListsString(inValidListsString)
11+
{
12+
13+
// G4String defaultList="QGSP_BIC_HP";
14+
G4String defaultList="WCSim";
15+
16+
physListCmd = new G4UIcmdWithAString("/WCSim/physics/list",this);
17+
G4String cmd_hint = "Available options: " + ValidListsString;
18+
physListCmd->SetGuidance(cmd_hint);
19+
physListCmd->SetGuidance("See http://geant4.cern.ch/support/proc_mod_catalog/physics_lists/useCases.shtml");
20+
physListCmd->SetGuidance(" http://geant4.cern.ch/support/proc_mod_catalog/physics_lists/referencePL.shtml");
21+
physListCmd->SetGuidance("Note: The WCSim option selects a deprecated physics list, but is useful for comparisons");
22+
physListCmd->SetGuidance("Note: I think physics list is locked-in after initialization");
23+
24+
physListCmd->SetDefaultValue(defaultList);
25+
physListCmd->SetCandidates(ValidListsString); // TODO get list of physics lists from G4PhysicsListFactory
26+
27+
SetNewValue(physListCmd, defaultList);
28+
}
29+
30+
WCSimPhysicsListFactoryMessenger::~WCSimPhysicsListFactoryMessenger()
31+
{
32+
delete physListCmd;
33+
//delete WCSimDir;
34+
}
35+
36+
void WCSimPhysicsListFactoryMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
37+
{
38+
if (command == physListCmd)
39+
thisWCSimPhysicsListFactory->SetList(newValue);
40+
41+
}

vis.mac

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
/WCSim/SavePi0 false
3030

3131
/vis/scene/create
32-
/vis/open OGLIX
32+
/vis/open OGLSX
3333
/vis/viewer/set/upVector 0 0 1
3434
/vis/viewer/set/viewpointThetaPhi 45 45 deg
3535
#/vis/viewer/set/viewpointThetaPhi 120 90 deg

0 commit comments

Comments
 (0)