Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add kaon validation + fix tracking seeder settings in ecal validation #1421

Merged
merged 2 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
21 changes: 10 additions & 11 deletions .github/validation_samples/ecal_pn/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@
seederRecoil.out_seed_collection = "RecoilRecoSeeds"
seederRecoil.bfield = 1.5
seederRecoil.pmin = 0.1
seederRecoil.pmax = 4.
seederRecoil.d0min = -0.5
seederRecoil.d0max = 0.5
seederRecoil.z0max = 10.
seederRecoil.pmax = 12.
seederRecoil.d0min = -40.0
seederRecoil.d0max = 40.0
seederRecoil.z0max = 50.

# Producer for running the CKF track finding starting from the found seeds.
tracking_tagger = tracking.CKFProcessor("Tagger_TrackFinder")
Expand Down Expand Up @@ -169,12 +169,11 @@
from LDMX.DQM import dqm
from LDMX.Tracking import dqm as tkdqm

# currently this does not fill anything
#seed_recoil_dqm = tkdqm.TrackingRecoDQM("SeedRecoilTrackerDQM")
#seed_recoil_dqm.buildHistograms()
#seed_recoil_dqm.track_collection = seederRecoil.out_seed_collection
#seed_recoil_dqm.truth_collection = "RecoilTruthTracks"
#seed_recoil_dqm.title = ""
seed_recoil_dqm = tkdqm.TrackingRecoDQM("SeedRecoilTrackerDQM")
seed_recoil_dqm.buildHistograms()
seed_recoil_dqm.track_collection = seederRecoil.out_seed_collection
seed_recoil_dqm.truth_collection = "RecoilTruthTracks"
seed_recoil_dqm.title = ""

recoil_dqm = tkdqm.TrackingRecoDQM("RecoilTrackerDQM")
recoil_dqm.buildHistograms()
Expand Down Expand Up @@ -202,6 +201,6 @@
trigScintTrack,
count, TriggerProcessor('trigger', 8000.),
dqm.PhotoNuclearDQM(verbose=True),
# seed_recoil_dqm,
seed_recoil_dqm,
recoil_dqm,
] + dqm.all_dqm)
159 changes: 159 additions & 0 deletions .github/validation_samples/kaon_enhanced/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
import os
import sys

from LDMX.Framework import ldmxcfg

thisPassName = 'test'
p=ldmxcfg.Process(thisPassName)

p.termLogLevel = 0
# This need to be set but has no meaning given p.totalEvents
p.maxEvents = 1
# kaon-focused sample takes about twice as long as normal PN,
# so we ask for half as many events such that validation jobs stay
# time-limited by the PN
p.totalEvents = int(os.environ['LDMX_NUM_EVENTS']) // 2
p.run = int(os.environ['LDMX_RUN_NUMBER'])

from LDMX.SimCore import generators as gen
from LDMX.SimCore import bias_operators
from LDMX.SimCore import kaon_physics
from LDMX.SimCore import photonuclear_models as pn
from LDMX.Biasing import ecal
from LDMX.Biasing import filters
from LDMX.Biasing import particle_filter
from LDMX.Biasing import util
from LDMX.Biasing import include as includeBiasing

detector = 'ldmx-det-v14-8gev'
generator=gen.single_8gev_e_upstream_tagger()
bias_factor = 550.
bias_treshold = 5000.

mySim = ecal.photo_nuclear(detector, generator)
mySim.description = f'8 GeV ECal Kaon PN simulation, xsec bias {bias_factor}'
mySim.biasing_operators = [ bias_operators.PhotoNuclear('ecal',bias_factor,bias_treshold,only_children_of_primary = True) ]

# Configure the sequence in which user actions should be called.
includeBiasing.library()
mySim.actions.clear()
mySim.actions.extend([
filters.TaggerVetoFilter(thresh=2*3800.),
# Only consider events where a hard brem occurs
filters.TargetBremFilter(recoil_max_p = 2*1500.,brem_min_e = 2*2500.),
# Only consider events where a PN reaction happnes in the ECal
filters.EcalProcessFilter(),
# Tag all photo-nuclear tracks to persist them to the event.
util.TrackProcessFilter.photo_nuclear()
])

# set up "upKaon" parameters which reduces the charged kaon lifetimes by a factor 1/50
# and forces decays to be into one of the leptonic decay modes.
mySim.kaon_parameters = kaon_physics.KaonPhysics.upKaons()

# Alternative pn models
myModel = pn.BertiniAtLeastNProductsModel.kaon()
# Count all (not stopped) particles as "hard"
myModel.hard_particle_threshold=0.
# Apply the model to any nucleus
myModel.zmin = 0
# Apply the model for photonuclear reactions with > 5000 MeV photons
myModel.emin = 5000.
# PDG ids for K^0_L, K^0_S, K^0, K^+, and K^- respectively
myModel.pdg_ids = [130, 310, 311, 321, -321]
# Require at least 1 hard particle from the list above
myModel.min_products = 1

# Change the default model to the kaon producing model
mySim.photonuclear_model = myModel

# Add the filter at the end of the current list of user actions.
# Filter for events with a kaon daughter
myFilter = particle_filter.PhotoNuclearProductsFilter.kaon()
mySim.actions.extend([myFilter])

# Loading calorimeter and TS processors
import LDMX.Ecal.EcalGeometry
import LDMX.Ecal.ecal_hardcoded_conditions
import LDMX.Hcal.HcalGeometry
import LDMX.Hcal.hcal_hardcoded_conditions

from LDMX.Ecal import digi as eDigi
from LDMX.Ecal import vetos
from LDMX.Hcal import digi as hDigi
from LDMX.Hcal import hcal

from LDMX.TrigScint.trigScint import TrigScintDigiProducer
from LDMX.TrigScint.trigScint import TrigScintClusterProducer
from LDMX.TrigScint.trigScint import trigScintTrack

from LDMX.Recon.electronCounter import ElectronCounter

#TS digi + clustering + track chain
tsDigisDown =TrigScintDigiProducer.pad1()
tsDigisTag =TrigScintDigiProducer.pad2()
tsDigisUp =TrigScintDigiProducer.pad3()

tsDigis = [tsDigisDown, tsDigisTag, tsDigisUp]
for d in tsDigis :
d.randomSeed = 1

tsClustersDown =TrigScintClusterProducer.pad1()
tsClustersTag =TrigScintClusterProducer.pad2()
tsClustersUp =TrigScintClusterProducer.pad3()

tsClustersDown.input_collection = tsDigisDown.output_collection
tsClustersTag.input_collection = tsDigisTag.output_collection
tsClustersUp.input_collection = tsDigisUp.output_collection

#make sure to pick up the right pass
tsClustersTag.input_pass_name = thisPassName
tsClustersUp.input_pass_name = tsClustersTag.input_pass_name
tsClustersDown.input_pass_name = tsClustersTag.input_pass_name

trigScintTrack.input_pass_name = thisPassName
trigScintTrack.seeding_collection = tsClustersTag.output_collection

# ECAL part
ecalReco =eDigi.EcalRecProducer()
ecalDigi = eDigi.EcalDigiProducer()
ecalVeto =vetos.EcalVetoProcessor()

# HCAL part
hcalDigi =hDigi.HcalDigiProducer()
hcalReco =hDigi.HcalRecProducer()
hcalVeto =hcal.HcalVetoProcessor()

# electron counter for trigger processor
eCount = ElectronCounter( 1, "ElectronCounter") # first argument is number of electrons in simulation
eCount.input_pass_name = ''
from LDMX.Recon.simpleTrigger import TriggerProcessor
simpleTrig = TriggerProcessor("simpleTrig",8000.)
simpleTrig.input_pass=thisPassName

# Load DQM
from LDMX.DQM import dqm

p.sequence=[
mySim,
ecalDigi,
ecalReco,
ecalVeto,
*tsDigis,
tsClustersTag,
tsClustersUp,
tsClustersDown,
trigScintTrack,
eCount,
simpleTrig,
hcalDigi,
hcalReco,
hcalVeto,
dqm.PhotoNuclearDQM(verbose=False)
]

p.sequence.extend(dqm.all_dqm)


p.histogramFile = f'hist.root'
p.outputFiles = [f'events.root']
Loading