Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,13 @@ add_subdirectory(veto)
add_subdirectory(TimeDet)
add_subdirectory(UpstreamTagger)
add_subdirectory(strawtubes)
add_subdirectory (prestrawdetector)
add_subdirectory(shipgen)
add_subdirectory(field)
add_subdirectory(muonShieldOptimization)
add_subdirectory(tests)


add_custom_target(
geometry.link ALL
COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_SOURCE_DIR}/geometry
Expand Down
8 changes: 8 additions & 0 deletions geometry/prestrawdetector_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Geometry configuration of PSD (prestrawdetector) in FairShip

PSD:
width: 300 # Aperture width (x) in cm (half length)
height: 300 # Aperture height (y) in cm (half length)
wall_thickness: 0.001 # Straw wall thickness in cm
z_position: 8350.0 # Z position in cm
material: "air" # material
6 changes: 4 additions & 2 deletions macro/ShipReco.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def mem_monitor():
, required=False, choices=['FH','AR','TemplateMatching'], default='')
parser.add_argument("-dy", dest="dy", help="Max height of tank", required=False, default=None,type=int)
parser.add_argument("--Debug", dest="Debug", help="Switch on debugging", required=False, action="store_true")
parser.add_argument("--digiOnly", dest="digionly", help="only digitization", default=False, required=False, action="store_true")

options = parser.parse_args()
vertexing = not options.noVertexing
Expand Down Expand Up @@ -131,8 +132,9 @@ def mem_monitor():
print('event ', global_variables.iEvent)
rc = SHiP.sTree.GetEvent(global_variables.iEvent)
SHiP.digitize()
SHiP.reconstruct()
SHiP.recoTree.Fill()
if not options.digionly:
SHiP.reconstruct()
SHiP.recoTree.Fill()
# memory monitoring
# mem_monitor()
# end loop over events
Expand Down
26 changes: 24 additions & 2 deletions macro/run_simScript.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from backports import tdirectory634
DownScaleDiMuon = False

from update_config import update_config
# Default HNL parameters
theHNLMass = 1.0*u.GeV
theProductionCouplings = theDecayCouplings = None
Expand Down Expand Up @@ -172,9 +173,15 @@
parser.add_argument("--noSND", dest="SND", help="Deactivate SND. NOOP, as it currently defaults to off.", action='store_false')
parser.add_argument("--target-yaml", help="Path to the yaml target config file", default=os.path.expandvars("$FAIRSHIP/geometry/target_config_Jun25.yaml"))


# sst-decoupling flags
parser.add_argument("--decouple", dest="decouple", help="Decoupling flag", required=False, default=False, action='store_true')
parser.add_argument("--useJSON", dest="json", help="Geometry tuning from json file", required=False, default=False, action='store_true')
parser.add_argument("--prestraw", dest="PSD", help="Prestrawdetector flag", required=False, default=False, action='store_true')
parser.add_argument("--ttreegen", dest="ttreegen", help="Use events from ttree as input", required=False, action="store_true")

options = parser.parse_args()
if options.json:
update_config(options, os.path.expandvars('$FAIRSHIP/sstDecouplingTools/sst.json'), 'options')
# Handle SND_design: allow 'all' (case-insensitive) or list of ints
available_snd_designs = [1, 2] # Extend this list as new designs are added
if any(str(x).lower() == 'all' for x in options.SND_design):
Expand Down Expand Up @@ -256,6 +263,13 @@
SND_design=options.SND_design,
TARGET_YAML=options.target_yaml
)
print(ship_geo)
if options.json:
update_config(ship_geo, os.path.expandvars('$FAIRSHIP/sstDecouplingTools/sst.json'), 'geometry')

if options.PSD:
ship_geo.PSD = options.PSD
ship_geo.decouple = options.decouple

# Output file name, add dy to be able to setup geometry with ambiguities.
if options.command == "PG":
Expand All @@ -264,7 +278,7 @@
tag = f"Genie-{mcEngine}"
simEngine = "Genie"
else:
for g in ["pythia8", "evtcalc", "pythia6", "nuradio", "ntuple", "muonback", "mudis", "fixedTarget", "cosmics"]:
for g in ["pythia8", "evtcalc", "pythia6", "nuradio", "ntuple", "muonback", "mudis", "fixedTarget", "cosmics", "ttreegen"]:
if getattr(options, g):
simEngine = g.capitalize()
break
Expand Down Expand Up @@ -387,7 +401,15 @@
P6gen.SetMom(50.*u.GeV)
P6gen.SetTarget("gamma/mu+","n0") # default "gamma/mu-","p+"
primGen.AddGenerator(P6gen)
# -----TTree generator--------------------------------------

if options.ttreegen:
primGen.SetTarget(0.0, 0.0)
print(f"Opening input file for ttree generator: {inputFile}")
TtreeGen = ROOT.PrestrawGenerator()
TtreeGen.Init(inputFile, options.firstEvent)
primGen.AddGenerator(TtreeGen)
options.nEvents = TtreeGen.GetNevents()
# -----EvtCalc--------------------------------------
if options.evtcalc:
primGen.SetTarget(0.0, 0.0)
Expand Down
25 changes: 25 additions & 0 deletions macro/update_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import json
from ShipGeoConfig import AttrDict

def update_config(global_config, my_config, name):
with open(my_config) as f:
data = json.load(f)
new_values = AttrDict(data[name])
if name == 'geometry':
stations = new_values.positions
global_config.TrackStation1.z=stations[0]
global_config.TrackStation2.z=stations[1]
global_config.TrackStation3.z=stations[2]
global_config.TrackStation4.z=stations[3]
print(f'Station Z-positions {stations}')
#global_config.strawtubes.ViewAngle = new_values.angles
#print(f"ship_geo.VA was set to {data['angles']}")
# if 'magnetic_strength' in data:
# ship_geo.magnetic_strength = data['magnetic_strength']
# print(f'ship_geo.magnetic_strength was set to {data["magnetic_strength"]}')

global_config.z = global_config.TrackStation2.z + 0.5 * (global_config.TrackStation3.z - global_config.TrackStation2.z)
global_config.Bfield.z = global_config.z
if name == 'options':
global_config.theSeed = new_values.theSeed
global_config.nEvents = new_values.nEvents
30 changes: 30 additions & 0 deletions prestrawdetector/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
set(INCLUDE_DIRECTORIES
${CMAKE_SOURCE_DIR}/shipdata
${CMAKE_SOURCE_DIR}/prestrawdetector
${genfit2_INCDIR}
)

include_directories(${INCLUDE_DIRECTORIES} ${VMC_INCLUDE_DIRS} ${FAIRROOT_INCLUDE_DIR})
include_directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES})

set(LINK_DIRECTORIES
${ROOT_LIBRARY_DIR}
${FAIRROOT_LIBRARY_DIR}
${genfit2_LIBDIR}
)

link_directories( ${LINK_DIRECTORIES})

set(SRCS
#Put here your sourcefiles
prestrawdetector.cxx
prestrawdetectorPoint.cxx
)

Set(LINKDEF prestrawdetectorLinkDef.h)
Set(LIBRARY_NAME prestrawdetector)
Set(DEPENDENCIES
Base ShipData FairLogger::FairLogger
)

GENERATE_LIBRARY()
Loading