Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
JZCaPA
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Riccardo Longo
JZCaPA
Commits
83466c35
Commit
83466c35
authored
5 years ago
by
Chad Lantz
Browse files
Options
Downloads
Patches
Plain Diff
Added argument flags. Started setting up for multithreading
parent
bbb89587
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
MonteCarlo/zdc.cc
+56
-59
56 additions, 59 deletions
MonteCarlo/zdc.cc
with
56 additions
and
59 deletions
MonteCarlo/zdc.cc
+
56
−
59
View file @
83466c35
...
...
@@ -30,16 +30,13 @@
#include
"DetectorConstruction.hh"
#include
"ActionInitialization.hh"
#include
"PhysicsList.hh"
/*
#ifdef G4MULTITHREADED
#include "
My
MTRunManager.hh"
#include
"
G4
MTRunManager.hh"
#else
#include "
My
RunManager.hh"
#include
"
G4
RunManager.hh"
#endif
*/
#include
"MyRunManager.hh"
#include
"G4UImanager.hh"
...
...
@@ -48,81 +45,81 @@
#include
"Randomize.hh"
#include
<TString.h>
#include
<TEnv.h>
#include
<iostream>
/*
*/
namespace
{
void
PrintUsage
()
{
G4cerr
<<
" Usage: "
<<
G4endl
;
G4cerr
<<
" lightGuide [-m macro ] [-u UIsession] [-t nThreads] [-r seed] [-o outputFileName]"
<<
G4endl
;
G4cerr
<<
" note: -t option is available only for multi-threaded mode."
<<
G4endl
;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
int
main
(
int
argc
,
char
**
argv
)
{
//
Detect interactive mode (if no arguments) and define UI session
//
Evaluate arguments
//
G4UIExecutive
*
ui
=
0
;
if
(
argc
==
1
)
{
ui
=
new
G4UIExecutive
(
argc
,
argv
)
;
if
(
argc
>
9
)
{
PrintUsage
();
return
1
;
}
// Choose the Random engine
G4Random
::
setTheEngine
(
new
CLHEP
::
RanecuEngine
);
// Get some arguments for RunManager
// Aric's fix for finding config file location
TString
m_configFileName
=
std
::
getenv
(
"JZCaPA"
);
m_configFileName
.
Replace
(
m_configFileName
.
Length
()
-
15
,
15
,
"/JZCaPA/MonteCarlo/config/config.cfg"
);
TString
cfgName
=
m_configFileName
;
//std::cout << "config file path = " << cfgName << std::endl;
if
(
argc
==
4
){
TString
arg
;
arg
=
TString
(
argv
[
3
]
);
if
(
arg
.
Contains
(
"config"
)
||
arg
.
Contains
(
"cfg"
)
)
cfgName
=
arg
;
G4String
macro
;
G4String
output
=
""
;
G4long
myseed
=
345354
;
#ifdef G4MULTITHREADED
G4int
nThreads
=
0
;
#endif
for
(
G4int
i
=
1
;
i
<
argc
;
i
=
i
+
2
)
{
if
(
G4String
(
argv
[
i
])
==
"-m"
)
macro
=
argv
[
i
+
1
];
else
if
(
G4String
(
argv
[
i
])
==
"-o"
)
output
=
argv
[
i
+
1
];
else
if
(
G4String
(
argv
[
i
])
==
"-r"
)
myseed
=
atoi
(
argv
[
i
+
1
]);
#ifdef G4MULTITHREADED
else
if
(
G4String
(
argv
[
i
])
==
"-t"
)
{
nThreads
=
G4UIcommand
::
ConvertToInt
(
argv
[
i
+
1
]);
}
#endif
else
{
PrintUsage
();
return
1
;
}
}
std
::
string
outputName
;
outputName
=
"analysis/temp.root"
;
if
(
argc
==
3
)
{
TString
arg
;
arg
=
TString
(
argv
[
2
]);
if
(
arg
.
Contains
(
".root"
)
)
{
outputName
=
arg
;
}
// Instantiate G4UIExecutive if interactive mode
G4UIExecutive
*
ui
=
nullptr
;
if
(
macro
.
size
()
==
0
)
{
ui
=
new
G4UIExecutive
(
argc
,
argv
);
}
// Choose the Random engine
G4Random
::
setTheEngine
(
new
CLHEP
::
RanecuEngine
);
// Construct the default run manager
//
/*
Does not work for now. Need to create multiple root files
for various nodes. Otherwise there is a crash.
(At least I think that is the reason)
#ifdef G4MULTITHREADED
G4MTRunManager* runManager = new MyMTRunManager( sharedData );
runManager->SetNumberOfThreads(7);
G4MTRunManager
*
runManager
=
new
G4MTRunManager
;
if
(
nThreads
>
0
)
runManager
->
SetNumberOfThreads
(
nThreads
);
G4cout
<<
"Using G4MULTITHREADED"
<<
G4endl
;
#else
G4RunManager* runManager = new
My
RunManager
( sharedData )
;
G4RunManager
*
runManager
=
new
G4
RunManager
;
#endif
*/
G4RunManager
*
runManager
=
new
MyRunManager
(
);
// Set mandatory initialization classes
//
// Detector construction
runManager
->
SetUserInitialization
(
new
DetectorConstruction
()
);
// Physics list
TEnv
*
config
=
sharedData
->
GetConfig
();
std
::
string
physicsListName
=
config
->
GetValue
(
"physicsList"
,
"FTFP_BERT"
);
// for now passing constructors directly
// if need to modify something (SetSomething)
// then take it out and add via this pointer.
// G4VModularPhysicsList* physicsList = NULL;
runManager
->
SetUserInitialization
(
new
PhysicsList
(
physicsListName
)
);
runManager
->
SetUserInitialization
(
new
PhysicsList
(
)
);
// User action initialization
runManager
->
SetUserInitialization
(
new
ActionInitialization
()
);
// Initialize visualization
G4VisManager
*
visManager
=
new
G4VisExecutive
;
// G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
...
...
@@ -133,11 +130,10 @@ int main(int argc,char** argv)
// Process macro or start UI session
//
if
(
!
ui
)
{
if
(
macro
.
size
()
)
{
// batch mode
G4String
command
=
"/control/execute "
;
G4String
fileName
=
argv
[
1
]
;
G4String
fileName
=
macro
;
UImanager
->
ApplyCommand
(
command
+
fileName
);
}
...
...
@@ -152,6 +148,7 @@ int main(int argc,char** argv)
delete
visManager
;
delete
runManager
;
return
0
;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment