Skip to content
Snippets Groups Projects
Commit c0a38a12 authored by Dave Casper's avatar Dave Casper
Browse files

Merge branch '22.0.49_test-genie-reader' into '22.0.49_test'

Fix barcode problem (again) and clean-up Genie alg

See merge request faser/calypso!186
parents dedfae9d 8cc16767
No related branches found
No related tags found
No related merge requests found
################################################################################
# Package: ReadGenie
################################################################################
# Declare the package name:
atlas_subdir( ReadGenie )
# Install files from the package:
atlas_install_python_modules( python/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} )
\ No newline at end of file
# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
from AthenaCommon.AppMgr import ServiceMgr as svcMgr
from GeneratorModules.EvgenAlg import EvgenAlg
from AthenaPython.PyAthena import StatusCode
import ROOT
__author__ = "Dave Caser <dcasper@uci.edu>"
class GenieReader(EvgenAlg):
def __init__(self, name="GenieReader", MCEventKey="BeamTruthEvent"):
super(GenieReader,self).__init__(name=name)
self.McEventKey = MCEventKey
return
def fillEvent(self, evt):
try:
from AthenaPython.PyAthena import HepMC3 as HepMC
except ImportError:
from AthenaPython.PyAthena import HepMC as HepMC
evt.weights().push_back(1.0)
pos = HepMC.FourVector(self.evtStore["vx"]*1000, self.evtStore["vy"]*1000, self.evtStore["vz"]*1000, 0)
gv = HepMC.GenVertex(pos)
ROOT.SetOwnership(gv, False)
evt.add_vertex(gv)
nParticles = self.evtStore["n"]
pdgc = list(self.evtStore["pdgc"])
status = list(self.evtStore["status"])
px = list(self.evtStore["px"])
py = list(self.evtStore["py"])
pz = list(self.evtStore["pz"])
E = list(self.evtStore["E"])
M = list(self.evtStore["M"])
for i in range(nParticles):
gp = HepMC.GenParticle()
mom = HepMC.FourVector(px[i], py[i], pz[i], E[i])
gp.set_momentum(mom)
gp.set_generated_mass(M[i])
gp.set_pdg_id(pdgc[i])
genie_status = status[i]
if (genie_status == 0): # initial particle
hepmc_status = 4
elif (genie_status == 1): # stable final particle
hepmc_status = 1
elif (genie_status == 3): # decayed particle
hepmc_status = 2
else: # catch-all informational particle
hepmc_status = 3
gp.set_status(hepmc_status)
ROOT.SetOwnership(gp, False)
if (hepmc_status == 4):
gv.add_particle_in(gp)
else:
gv.add_particle_out(gp)
return StatusCode.Success
# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
......@@ -270,7 +270,7 @@ void ISF::FaserTruthSvc::recordIncidentToMCTruth( ISF::IFaserTruthIncident& ti)
if (m_ignoreUndefinedBarcodes) {
ATH_MSG_WARNING("Unable to generate new Particle Barcode. Continuing due to 'IgnoreUndefinedBarcodes'==True");
} else {
ATH_MSG_FATAL("Unable to generate new Particle Barcode in region " << ti.geoID() << ". Aborting");
ATH_MSG_FATAL("Unable to generate new Particle Barcode in region " << ti.geoID() << ", at vertex (" << vtx->position().x() << ", " << vtx->position().y() << ", " << vtx->position().z() << "). Aborting");
abort();
}
}
......
......@@ -163,7 +163,8 @@ def FaserDipoleTruthStrategyCfg(ConfigFlags, name="ISF_FaserDipoleTruthStrategy"
# Save truth in Dipole region
#
kwargs.setdefault('Regions', [FaserRegion.fFaserDipole,
FaserRegion.fFaserNeutrino])
FaserRegion.fFaserNeutrino,
FaserRegion.fFaserCavern])
kwargs.setdefault('ParentMinEkin', 1000.0*MeV)
kwargs.setdefault('ChildMinEkin', 1000.0*MeV)
result.setPrivateTools(ISF__FaserTruthStrategy(name, **kwargs))
......@@ -182,10 +183,10 @@ def FaserTruthStrategyCfg(ConfigFlags, name="ISF_FaserTruthStrategy", **kwargs):
kwargs.setdefault('Regions', [
# FaserRegion.fFaserNeutrino,
FaserRegion.fFaserScintillator,
FaserRegion.fFaserTracker,
FaserRegion.fFaserTracker])
# FaserRegion.fFaserDipole,
# FaserRegion.fFaserCalorimeter,
FaserRegion.fFaserCavern])
# FaserRegion.fFaserCavern])
# kwargs.setdefault('ParentMinEkin', 0.1*MeV)
# kwargs.setdefault('ChildMinEkin', 0.1*MeV)
result.setPrivateTools(ISF__FaserTruthStrategy(name, **kwargs))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment