Difference between revisions of "SoLID Software Detector Simulation"

From Hall A Wiki
Jump to: navigation, search
(materials)
(Link to new wiki)
 
(81 intermediate revisions by one other user not shown)
Line 1: Line 1:
= "'''solid_gemc'''" general info =
+
This page has been moved to [https://solid.jlab.org/wiki/index.php/Software_Detector_Simulation https://solid.jlab.org/wiki/index.php/Software_Detector_Simulation] in the new [https://solid.jlab.org/wiki SoLID Wiki].  Please do not edit this page.
  
SoLID detector simulation program "solid_gemc" is based on "GEMC" with additional hit process routine and outputs for all detector systems in SoLID.
+
= Introduction =
 +
 
 +
SoLID detector simulation program "solid_gemc" is based on "GEMC 2.x" with additional hit process routine and outputs for all detector systems in SoLID.
  
 
It's located SoLID repository https://jlabsvn.jlab.org/svnroot/solid/solid_gemc2 with source codes and detector configuration, field, scripts etc.
 
It's located SoLID repository https://jlabsvn.jlab.org/svnroot/solid/solid_gemc2 with source codes and detector configuration, field, scripts etc.
  
You need both the jlab framework and SoLID repository before you have compile and run solid_gemc, refer to the [[Solid_Software#Installation|installation]] section
+
You need both the jlab framework and SoLID repository before you can compile and run solid_gemc, refer to the [[Solid_Software#quick_start|quick start]] section
  
= quick start =
+
The "set_solid" script is used to setup env
  
== setup ==
+
= general note (Please read this!) =
  
All env variables required are setup by source file "set_solid"
+
''' [https://hallaweb.jlab.org/wiki/index.php/Detector_simulation_general_note general note] for geometry, materiel, mirror, hit processing, calling gemc as library with added functionally etc'''
  
make sure you meet the requirement [https://eic.jlab.org/wiki/index.php/Installation_of_framework#requirement_before_installaion here]
+
= Setup plot =
  
The example below demonstrates how to setup in various cases.
+
They are stored here
  
=== on ifarm with official installation of framework and SoLID repository (demonstration) ===
+
http://hallaweb.jlab.org/12GeV/SoLID/download/sim/setup/
  
The fastest way to see what the simulation look like. You don't need to install any thing, but you can't modify anything either.
+
sort by "Last modified" to see latest
  
login into ifarm with your account
+
= compile and run =
source /home/zwzhao/solid/solid_svn/solid/set_solid
+
follow "[[SoLID_Software_Detector_Simulation#compile_and_run |compile and run]]" to run it (skim compiling)
+
  
=== on ifarm with official installation of framework and your SoLID repository (recommended)===
 
 
You don't need to install the framework, you can modify simulation configuration. This is the best way to run simulation on ifarm and farm nodes. This is recommend way to compare result and produce results.
 
 
cd your_choice_of_solid_repo_path
 
svn co https://jlabsvn.jlab.org/svnroot/solid
 
cd solid
 
edit file set_solid by following the instruction within, you only need to change SoLID_GEMC
 
source set_solid
 
cd $SoLID_GEMC/field
 
wget http://hallaweb.jlab.org/12GeV/SoLID/download/field/gemc2/solenoid_CLEOv8.dat
 
wget http://hallaweb.jlab.org/12GeV/SoLID/download/field/gemc2/solenoid_ptarget.dat
 
follow "[[SoLID_Software_Detector_Simulation#compile_and_run |compile and run]]" to compile and run it
 
 
=== on any machine with your installation of framework and your SoLID repository (expert)===
 
 
This gives you maximum freedom to use any version of framework and ability to work on your local machine, And allow you to modify anything. This is the way to run on your local machine.
 
 
install the framework by following installation instruction
 
cd your_choice_of_solid_repo_path
 
svn co https://jlabsvn.jlab.org/svnroot/solid
 
cd solid
 
edit file set_solid by following the instruction within
 
source set_solid
 
cd $SoLID_GEMC/field
 
wget http://hallaweb.jlab.org/12GeV/SoLID/download/field/gemc2/solenoid_CLEOv8.dat
 
wget http://hallaweb.jlab.org/12GeV/SoLID/download/field/gemc2/solenoid_ptarget.dat
 
follow "[[SoLID_Software_Detector_Simulation#compile_and_run |compile and run]]" to compile and run it
 
 
== compile and run ==
 
 
Once you complete the setup procedure, you can now compile "solid_gemc"
 
Once you complete the setup procedure, you can now compile "solid_gemc"
  
  cd $SoLID_GEMC/source
+
source your set_solid if you haven't done so
 +
  cd $SoLID_GEMC/source/$GEMC_VERSION
 
  scons OPT=1
 
  scons OPT=1
  you need to recompile every time GEMC gets updated
+
  (then go to a clean terminal and source your set_solid so that "solid_gemc" can found in default PATH)
   
+
  solid_gemc    (a empty graphic window with simulation setup should show up and confirm it's working, then you can move on full or subsystem simulation)
after compiling, do the following to run it
+
  
cd $SoLID_GEMC/script
+
= full simulation =
solid_gemc solid_PVDIS_LD2.gcard or  solid_gemc solid_PVDIS_simple.gcard
+
solid_gemc solid_SIDIS_He3.gcard or  solid_gemc solid_SIDIS_He3_simple.gcard
+
solid_gemc solid_SIDIS_NH3.gcard or  solid_gemc solid_SIDIS_NH3_simple.gcard
+
  
= Details =
+
All subsystems have their own "production" version directories "ec,hgc,lgc,gem,mrpc,spd,magnet,baffle,target,beamline,absorber" at
== how to run ==
+
"https://jlabsvn.jlab.org/svnroot/solid/solid_gemc2/geometry/"
  
run "solid_gemc -help" to see running option
+
Run full SoLID simulation in graphic mode with all subsystems together by
 +
source your set_solid
 +
cd $SoLID_GEMC/script
 +
solid_gemc solid_PVDIS_LD2_full.gcard
 +
solid_gemc solid_SIDIS_He3_full.gcard
 +
solid_gemc solid_SIDIS_NH3_full.gcard
 +
solid_gemc solid_JPsi_LH2_full.gcard
  
read the tutorials on the main GEMC website [https://gemc.jlab.org/gemc/Documentation/Documentation.html here]
+
= subsystem simulation =
  
another tutorial[https://clasweb.jlab.org/wiki/images/b/b5/GemcFaq.pptx  GEMC tuturial on 2014/03/06]
+
"solid_gemc" can be used for individual sub-detector systems and the whole detector simulation.
  
Use examples in "study" in the repository [https://jlabsvn.jlab.org/svnroot/solid/study/ here] to see how to create geometry, store hit and analysis results
+
Each of sub-detector systems can do simulation independently and ready to merge it back into the whole system simulation.
  
== geometry ==
+
They are considered "devel" version and located in their individual directories and person responsible as below
 +
         
 +
https://jlabsvn.jlab.org/svnroot/solid/subsystem/ec/ec_segmented_solid_gemc and https://jlabsvn.jlab.org/svnroot/solid/subsystem/ec/analysis/readme   
 +
https://jlabsvn.jlab.org/svnroot/solid/subsystem/hgc/hgc_solid_gemc and  https://jlabsvn.jlab.org/svnroot/solid/subsystem/hgc/analysis/readme   
 +
https://jlabsvn.jlab.org/svnroot/solid/subsystem/lgc/lgc_solid_gemc and  https://jlabsvn.jlab.org/svnroot/solid/subsystem/lgc/analysis/readme                             
 +
https://jlabsvn.jlab.org/svnroot/solid/subsystem/gem/gem_solid_gemc and  https://jlabsvn.jlab.org/svnroot/solid/subsystem/gem/analysis/readme             
 +
https://jlabsvn.jlab.org/svnroot/solid/subsystem/mrpc/mrpc_solid_gemc and  https://jlabsvn.jlab.org/svnroot/solid/subsystem/mrpc/analysis/readme               
 +
https://jlabsvn.jlab.org/svnroot/solid/subsystem/spd/spd_solid_gemc and  https://jlabsvn.jlab.org/svnroot/solid/subsystem/spd/analysis/readme   
 +
https://jlabsvn.jlab.org/svnroot/solid/subsystem/target/target_solid_gemc                         
 +
https://jlabsvn.jlab.org/svnroot/solid/subsystem/magnet/magnet_solid_gemc       
 +
https://jlabsvn.jlab.org/svnroot/solid/subsystem/baffle/baffle_solid_gemc       
 +
https://jlabsvn.jlab.org/svnroot/solid/subsystem/target/target_solid_gemc       
 +
https://jlabsvn.jlab.org/svnroot/solid/subsystem/beamline/beamline_solid_gemc   
 +
https://jlabsvn.jlab.org/svnroot/solid/subsystem/absorber/absorber_solid_gemc   
  
source set_solid
+
These directories should be kept clean so it only has files necessary for simulation, and ready to copy into the "production" area to be used with other subsystems
cd $SoLID_GEMC/geometry
+
read file "changelog"
+
edit perl file to modify geometry, then run commad below to generate new geometry txt files
+
./solid_PVDIS_simple.pl config_solid_PVDIS_simple.dat
+
./solid_PVDIS_LD2.pl config_solid_PVDIS_LD2.dat
+
./solid_SIDIS_He3_simple.pl config_solid_SIDIS_He3_simple.dat
+
./solid_SIDIS_He3.pl config_solid_SIDIS_He3.dat
+
./solid_SIDIS_NH3_simple.pl config_solid_SIDIS_NH3_simple.dat
+
./solid_SIDIS_NH3.pl config_solid_SIDIS_NH3.dat
+
  
== materials ==
+
For all other files, please put them into other directories under the same subsystems.
  
source your set_solid
+
Please refer to "hgc_solid_gemc" and "hgc" as an example
cd $SoLID_GEMC/geometry
+
edit perl file to modify geometry, then run commad below to generate new material txt files
+
./solid_material.pl config_solid_PVDIS_simple.dat
+
./solid_material.pl config_solid_PVDIS_LD2.dat
+
./solid_material.pl config_solid_SIDIS_He3_simple.dat
+
./solid_material.pl config_solid_SIDIS_He3.dat
+
./solid_material.pl config_solid_SIDIS_NH3_simple.dat
+
./solid_material.pl config_solid_SIDIS_NH3.dat
+
  
== hit processing ==
+
Once you think your subsystem devel version is ready, before making it a production version, be sure to test it with full simulation, meaning it has no conflict with any other production subsystem.
  
All quantity should be in "MeV,mm,ns" units
+
copy, paste and modify "$SoLID_GEMC/script/solid_*_full.gcard" to mix your devel version system and other production subsystems to test
  
=== built-in type ===
+
After verify no conflict, you may release it as production version by copying ONLY necessary files like all perl script and txt files without any change into its production directory.
  
"header" bank has entries "evn,evn_type,beamPol,var1,var2,var3,var4,var5,var6,var7,var8" where evn is for event number, evn_type=-1 for simulated event, beamPol for beam polarization, and all other variables are 0 from a particle gun as input or customized from an input file.
+
= analyzing result =
  
"generated" bank has entries "pid,px,py,pz,vx,vy,vz"
+
== example ==
  
"flux" bank has entries "hitn, id" which is a builtin hit processing routine, just record hits on a sensitive detector identified by an integer number id
+
The root tree output can be analysis by some very simple scripts here
 +
https://jlabsvn.jlab.org/svnroot/solid/solid_gemc2/analysis/
  
"true info" records EVERY SINGLE hits, can be turned on for both flux and other customized banks by option like <option name="INTEGRATEDRAW" value="flux,TOF,DC"/>
+
== header tree and generated tree ==
  
pid        particle ID
+
header tree and generated tree are direct passing through from input, either particle gun or lund file produced by a generator, referring to [https://eic.jlab.org/wiki/index.php/Detector_simulation_general_note#input]
mpid        mother particle ID
+
tid        track id
+
mtid        mother track id
+
otid        original track id
+
trackE      track energy
+
totEdep    Total Energy Deposited
+
avg_x      Average global x position
+
avg_y      Average global y position
+
avg_z      Average global z position
+
avg_lx      Average local  x position
+
avg_ly      Average local  y position
+
avg_lz      Average local  z position
+
px     x component of track momentum
+
py     y component of track momentum
+
pz     z component of track momentum
+
vx     x coordinate of primary vertex
+
vy     y coordinate of primary vertex
+
vz     z coordinate of primary vertex
+
mvx     x coordinate of mother vertex
+
mvy     y coordinate of mother vertex
+
mvz     z coordinate of mother vertex
+
avg_t      Average t
+
  
=== customized type ===
+
For generator used for SoLID, "eicRate" and "halld" both use header defined here https://hallaweb.jlab.org/wiki/index.php/Solid_eventgenerator#Output_file
  
need 3 things, hit process routine in c++ code, bank definition and hit definition
+
== flux tree ==
  
For bank definition, it should have "hitn" to record the number of hits and give unique "bankId" and "bankname"
+
detector ID for flux hit processing
  
see examples under https://jlabsvn.jlab.org/svnroot/solid/solid_gemc2/source/hitprocess/ and https://jlabsvn.jlab.org/svnroot/solid/subsystem/gem/gem_gemc/
+
We use built-in flux hit processing for virtual planes near to real detectors to record particles entering or leaving real detectors
  
== input ==
+
Each virtual plane has a unique id to identify it  and it appears in the "id" branch of "flux" tree
  
GEMC take two kinds of input
+
Its ID is defined by 7 digits integer like "abcdefg"
 +
a: detector
 +
    GEM 1, CC 2, EC 3, MRPC 4, SPD 5, muon 6
 +
b: sub-detector
 +
    GEM 1 - 6 layer, LGCC 1, HGCC 2, FAEC 1, LAEC 2, MRPC 1, FASPD 1, LASPD 2, muon forward 1, muon endcap donut 2,muon barrel 3
 +
c: subsub-detector
 +
    GEM 1, CC 1 front, MRPC 1 front,SPD 1 front,EC 1 front 4 rear
 +
d,e,f,g: not used for now
 +
for example, 3110000 is for forward angle EC front plane
 +
see code example here https://jlabsvn.jlab.org/svnroot/solid/study/background/background.C
  
from a particle gun defined in options, for example
+
= field map =
<option name="BEAM_P"  value="e-, 5*GeV, 0*deg, 0*deg"/>
+
<option name="SPREAD_P" value="0*GeV,0*deg,0*deg"/>
+
<option name="BEAM_V"  value="(0, 0, 0)m"/>
+
<option name="SPREAD_V" value="(0.,0)cm"/>
+
  
or from an external LUND txt file (format defined by [https://gemc.jlab.org/gemc/Documentation/Entries/2011/3/18_The_LUND_Format.html here]) pointed by its options
+
https://github.com/JeffersonLab/solid_gemc/blob/master/field/readme
  <option name="INPUT_GEN_FILE" value="LUND, input.dat"/>
+
  
== output ==
+
= old way to run simulation, mainly for background study =
  
Direct output are txt or evio which is JLab DAQ data format
+
== geometry ==
 +
refer to file " $SoLID_GEMC/geometry/changelog" for details
  
use text output to debug
+
source your set_solid
 +
cd $SoLID_GEMC/geometry
 +
edit perl files to modify geometry, then run command below to generate new geometry txt files
 +
./solid_PVDIS_simple.pl config_solid_PVDIS_simple.dat
 +
./solid_PVDIS_LD2.pl config_solid_PVDIS_LD2.dat
 +
./solid_SIDIS_He3_simple.pl config_solid_SIDIS_He3_simple.dat
 +
./solid_SIDIS_He3.pl config_solid_SIDIS_He3.dat
 +
./solid_SIDIS_NH3_simple.pl config_solid_SIDIS_NH3_simple.dat
 +
./solid_SIDIS_NH3.pl config_solid_SIDIS_NH3.dat
  
convert evio to xml by
+
== materials ==
+
evio2xml output.evio
+
  
covert evio to root by
+
source your set_solid
 
+
cd $SoLID_GEMC/geometry
  evio2root -INPUTF=output.evio -B=(file storing bank definition) -WRITE_RAWS=("yes" or "no" as default)
+
  edit the perl file "solid_material.pl" to modify geometry, then run command below to generate new material txt files
 
+
  ./solid_material.pl config_solid_PVDIS_simple.dat
see evio2root option by
+
  ./solid_material.pl config_solid_PVDIS_LD2.dat
 
+
./solid_material.pl config_solid_SIDIS_He3_simple.dat
  evio2root -help-all
+
  ./solid_material.pl config_solid_SIDIS_He3.dat
 
+
  ./solid_material.pl config_solid_SIDIS_NH3_simple.dat
== field map ==
+
  ./solid_material.pl config_solid_SIDIS_NH3.dat
 
+
http://hallaweb.jlab.org/12GeV/SoLID/download/field/gemc2/solenoid_CLEOv8.dat
+
  http://hallaweb.jlab.org/12GeV/SoLID/download/field/gemc2/solenoid_ptarget.dat
+
 
+
= simulation for sub-detector systems =
+
 
+
"solid_gemc" can be used for the whole detector simulation and individual sub-detector systems at the same time.
+
 
+
Each of sub-detector systems can do simulation independently and ready to merge it back into the whole system simulation.
+
 
+
They are located in the repository at
+
 
+
https://jlabsvn.jlab.org/svnroot/solid/subsystem/ec/ec_gemc
+
  https://jlabsvn.jlab.org/svnroot/solid/subsystem/cc/cc_gemc
+
  https://jlabsvn.jlab.org/svnroot/solid/subsystem/gem/gem_gemc
+
  https://jlabsvn.jlab.org/svnroot/solid/subsystem/mrpc/mrpc_gemc
+

Latest revision as of 15:38, 7 December 2020

This page has been moved to https://solid.jlab.org/wiki/index.php/Software_Detector_Simulation in the new SoLID Wiki. Please do not edit this page.

Introduction

SoLID detector simulation program "solid_gemc" is based on "GEMC 2.x" with additional hit process routine and outputs for all detector systems in SoLID.

It's located SoLID repository https://jlabsvn.jlab.org/svnroot/solid/solid_gemc2 with source codes and detector configuration, field, scripts etc.

You need both the jlab framework and SoLID repository before you can compile and run solid_gemc, refer to the quick start section

The "set_solid" script is used to setup env

general note (Please read this!)

general note for geometry, materiel, mirror, hit processing, calling gemc as library with added functionally etc

Setup plot

They are stored here

http://hallaweb.jlab.org/12GeV/SoLID/download/sim/setup/

sort by "Last modified" to see latest

compile and run

Once you complete the setup procedure, you can now compile "solid_gemc"

source your set_solid if you haven't done so
cd $SoLID_GEMC/source/$GEMC_VERSION
scons OPT=1
(then go to a clean terminal and source your set_solid so that "solid_gemc" can found in default PATH)
solid_gemc    (a empty graphic window with simulation setup should show up and confirm it's working, then you can move on full or subsystem simulation)

full simulation

All subsystems have their own "production" version directories "ec,hgc,lgc,gem,mrpc,spd,magnet,baffle,target,beamline,absorber" at "https://jlabsvn.jlab.org/svnroot/solid/solid_gemc2/geometry/"

Run full SoLID simulation in graphic mode with all subsystems together by

source your set_solid
cd $SoLID_GEMC/script
solid_gemc solid_PVDIS_LD2_full.gcard
solid_gemc solid_SIDIS_He3_full.gcard
solid_gemc solid_SIDIS_NH3_full.gcard
solid_gemc solid_JPsi_LH2_full.gcard

subsystem simulation

"solid_gemc" can be used for individual sub-detector systems and the whole detector simulation.

Each of sub-detector systems can do simulation independently and ready to merge it back into the whole system simulation.

They are considered "devel" version and located in their individual directories and person responsible as below

https://jlabsvn.jlab.org/svnroot/solid/subsystem/ec/ec_segmented_solid_gemc and https://jlabsvn.jlab.org/svnroot/solid/subsystem/ec/analysis/readme    
https://jlabsvn.jlab.org/svnroot/solid/subsystem/hgc/hgc_solid_gemc and  https://jlabsvn.jlab.org/svnroot/solid/subsystem/hgc/analysis/readme    
https://jlabsvn.jlab.org/svnroot/solid/subsystem/lgc/lgc_solid_gemc and  https://jlabsvn.jlab.org/svnroot/solid/subsystem/lgc/analysis/readme                              
https://jlabsvn.jlab.org/svnroot/solid/subsystem/gem/gem_solid_gemc and  https://jlabsvn.jlab.org/svnroot/solid/subsystem/gem/analysis/readme               
https://jlabsvn.jlab.org/svnroot/solid/subsystem/mrpc/mrpc_solid_gemc and  https://jlabsvn.jlab.org/svnroot/solid/subsystem/mrpc/analysis/readme                 
https://jlabsvn.jlab.org/svnroot/solid/subsystem/spd/spd_solid_gemc and  https://jlabsvn.jlab.org/svnroot/solid/subsystem/spd/analysis/readme     
https://jlabsvn.jlab.org/svnroot/solid/subsystem/target/target_solid_gemc                          
https://jlabsvn.jlab.org/svnroot/solid/subsystem/magnet/magnet_solid_gemc         
https://jlabsvn.jlab.org/svnroot/solid/subsystem/baffle/baffle_solid_gemc         
https://jlabsvn.jlab.org/svnroot/solid/subsystem/target/target_solid_gemc         
https://jlabsvn.jlab.org/svnroot/solid/subsystem/beamline/beamline_solid_gemc     
https://jlabsvn.jlab.org/svnroot/solid/subsystem/absorber/absorber_solid_gemc     

These directories should be kept clean so it only has files necessary for simulation, and ready to copy into the "production" area to be used with other subsystems

For all other files, please put them into other directories under the same subsystems.

Please refer to "hgc_solid_gemc" and "hgc" as an example

Once you think your subsystem devel version is ready, before making it a production version, be sure to test it with full simulation, meaning it has no conflict with any other production subsystem.

copy, paste and modify "$SoLID_GEMC/script/solid_*_full.gcard" to mix your devel version system and other production subsystems to test

After verify no conflict, you may release it as production version by copying ONLY necessary files like all perl script and txt files without any change into its production directory.

analyzing result

example

The root tree output can be analysis by some very simple scripts here https://jlabsvn.jlab.org/svnroot/solid/solid_gemc2/analysis/

header tree and generated tree

header tree and generated tree are direct passing through from input, either particle gun or lund file produced by a generator, referring to [1]

For generator used for SoLID, "eicRate" and "halld" both use header defined here https://hallaweb.jlab.org/wiki/index.php/Solid_eventgenerator#Output_file

flux tree

detector ID for flux hit processing

We use built-in flux hit processing for virtual planes near to real detectors to record particles entering or leaving real detectors

Each virtual plane has a unique id to identify it and it appears in the "id" branch of "flux" tree

Its ID is defined by 7 digits integer like "abcdefg"
a: detector
   GEM 1, CC 2, EC 3, MRPC 4, SPD 5, muon 6
b: sub-detector
   GEM 1 - 6 layer, LGCC 1, HGCC 2, FAEC 1, LAEC 2, MRPC 1, FASPD 1, LASPD 2, muon forward 1, muon endcap donut 2,muon barrel 3
c: subsub-detector
   GEM 1, CC 1 front, MRPC 1 front,SPD 1 front,EC 1 front 4 rear
d,e,f,g: not used for now
for example, 3110000 is for forward angle EC front plane
see code example here https://jlabsvn.jlab.org/svnroot/solid/study/background/background.C

field map

https://github.com/JeffersonLab/solid_gemc/blob/master/field/readme

old way to run simulation, mainly for background study

geometry

refer to file " $SoLID_GEMC/geometry/changelog" for details

source your set_solid
cd $SoLID_GEMC/geometry
edit perl files to modify geometry, then run command below to generate new geometry txt files
./solid_PVDIS_simple.pl config_solid_PVDIS_simple.dat
./solid_PVDIS_LD2.pl config_solid_PVDIS_LD2.dat
./solid_SIDIS_He3_simple.pl config_solid_SIDIS_He3_simple.dat
./solid_SIDIS_He3.pl config_solid_SIDIS_He3.dat
./solid_SIDIS_NH3_simple.pl config_solid_SIDIS_NH3_simple.dat
./solid_SIDIS_NH3.pl config_solid_SIDIS_NH3.dat

materials

source your set_solid
cd $SoLID_GEMC/geometry
edit the perl file "solid_material.pl" to modify geometry, then run command below to generate new material txt files
./solid_material.pl config_solid_PVDIS_simple.dat
./solid_material.pl config_solid_PVDIS_LD2.dat
./solid_material.pl config_solid_SIDIS_He3_simple.dat
./solid_material.pl config_solid_SIDIS_He3.dat
./solid_material.pl config_solid_SIDIS_NH3_simple.dat
./solid_material.pl config_solid_SIDIS_NH3.dat