Skip to content

Commit

Permalink
feat: adding some more options to the odd_full_chain (#3179)
Browse files Browse the repository at this point in the history
This PR adds a few more options to the `full_chain` script, in order to steer it a bit better:

```sh
options:
  -h, --help            show this help message and exit
  --output OUTPUT, -o OUTPUT
                        Output directory
  --events EVENTS, -n EVENTS
                        Number of events
  --skip SKIP, -s SKIP  Number of events
  --edm4hep EDM4HEP     Use edm4hep inputs
  --geant4              Use Geant4 instead of fatras
  --ttbar               Use Pythia8 (ttbar, pile-up 200) instead of particle gun
  --ttbar-pu TTBAR_PU   Number of pile-up events for ttbar
  --gun-particles GUN_PARTICLES
                        Multiplicity (no. of particles) of the particle gun
  --gun-multiplicity GUN_MULTIPLICITY
                        Multiplicity (no. of vertices) of the particle gun
  --gun-eta-range GUN_ETA_RANGE [GUN_ETA_RANGE ...]
                        Eta range of the particle gun
  --gun-pt-range GUN_PT_RANGE [GUN_PT_RANGE ...]
                        Pt range of the particle gun (GeV)
  --digi-config DIGI_CONFIG
                        Digitization configuration file
  --material-config MATERIAL_CONFIG
                        Material map configuration file
  --ambi-solver {greedy,scoring,ML}
                        Set which ambiguity solver to use, default is the classical one
  --ambi-config AMBI_CONFIG
                        Set the configuration file for the Score Based ambiguity resolution
  --MLSeedFilter        Use the Ml seed filter to select seed after the seeding step
  --reco, --no-reco     Switch reco on/off
  --output-root, --no-output-root
                        Switch root output on/off
  --output-csv, --no-output-csv
                        Switch csv output on/off
```

Particularly interesting are the configurations for the particle gun (multiplicity, momentum, eta range) and steering of the output.

With these modification I dropped the `sim_digi_odd` file again.
  • Loading branch information
asalzburger authored May 23, 2024
1 parent 8a8e54a commit 3681185
Show file tree
Hide file tree
Showing 2 changed files with 176 additions and 362 deletions.
293 changes: 176 additions & 117 deletions Examples/Scripts/Python/full_chain_odd.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,38 @@
type=int,
default=200,
)
parser.add_argument(
"--gun-particles",
help="Multiplicity (no. of particles) of the particle gun",
type=int,
default=4,
)
parser.add_argument(
"--gun-multiplicity",
help="Multiplicity of the particle gun",
help="Multiplicity (no. of vertices) of the particle gun",
type=int,
default=200,
)
parser.add_argument(
"--gun-eta-range",
nargs=2,
help="Eta range of the particle gun",
type=float,
default=[-3.0, 3.0],
)
parser.add_argument(
"--gun-pt-range",
nargs=2,
help="Pt range of the particle gun (GeV)",
type=float,
default=[1.0 * u.GeV, 10.0 * u.GeV],
)
parser.add_argument(
"--digi-config", help="Digitization configuration file", type=pathlib.Path
)
parser.add_argument(
"--material-config", help="Material map configuration file", type=pathlib.Path
)
parser.add_argument(
"--ambi-solver",
help="Set which ambiguity solver to use, default is the classical one",
Expand All @@ -91,21 +117,47 @@
help="Use the Ml seed filter to select seed after the seeding step",
action="store_true",
)
parser.add_argument(
"--reco",
help="Switch reco on/off",
default=True,
action=argparse.BooleanOptionalAction,
)
parser.add_argument(
"--output-root",
help="Switch root output on/off",
default=True,
action=argparse.BooleanOptionalAction,
)
parser.add_argument(
"--output-csv",
help="Switch csv output on/off",
default=True,
action=argparse.BooleanOptionalAction,
)

args = vars(parser.parse_args())
args = parser.parse_args()

outputDir = args["output"]
ttbar = args["ttbar"]
g4_simulation = args["geant4"]
ambi_ML = args["ambi_solver"] == "ML"
ambi_scoring = args["ambi_solver"] == "scoring"
ambi_config = args["ambi_config"]
seedFilter_ML = args["MLSeedFilter"]
outputDir = args.output
ambi_ML = args.ambi_solver == "ML"
ambi_scoring = args.ambi_solver == "scoring"
ambi_config = args.ambi_config
seedFilter_ML = args.MLSeedFilter
geoDir = getOpenDataDetectorDirectory()
# acts.examples.dump_args_calls(locals()) # show python binding calls

oddMaterialMap = geoDir / "data/odd-material-maps.root"
oddDigiConfig = geoDir / "config/odd-digi-smearing-config.json"
oddMaterialMap = (
args.material_config
if args.material_config
else geoDir / "data/odd-material-maps.root"
)

oddDigiConfig = (
args.digi_config
if args.digi_config
else geoDir / "config/odd-digi-smearing-config.json"
)

oddSeedingSel = geoDir / "config/odd-seeding-config.json"
oddMaterialDeco = acts.IMaterialDecorator.fromFile(oddMaterialMap)

Expand All @@ -116,17 +168,17 @@
rnd = acts.examples.RandomNumbers(seed=42)

s = acts.examples.Sequencer(
events=args["events"],
skip=args["skip"],
numThreads=1 if g4_simulation else -1,
events=args.events,
skip=args.skip,
numThreads=1 if args.geant4 else -1,
outputDir=str(outputDir),
)

if args["edm4hep"]:
if args.edm4hep:
import acts.examples.edm4hep

edm4hepReader = acts.examples.edm4hep.EDM4hepReader(
inputPath=str(args["edm4hep"]),
inputPath=str(args.edm4hep),
inputSimHits=[
"PixelBarrelReadout",
"PixelEndcapReadout",
Expand Down Expand Up @@ -161,39 +213,45 @@
outputParticles="particles_selected",
)
else:
if not ttbar:
if not args.ttbar:
addParticleGun(
s,
MomentumConfig(1.0 * u.GeV, 10.0 * u.GeV, transverse=True),
EtaConfig(-3.0, 3.0),
MomentumConfig(
args.gun_pt_range[0] * u.GeV,
args.gun_pt_range[1] * u.GeV,
transverse=True,
),
EtaConfig(args.gun_eta_range[0], args.gun_eta_range[1]),
PhiConfig(0.0, 360.0 * u.degree),
ParticleConfig(4, acts.PdgParticle.eMuon, randomizeCharge=True),
ParticleConfig(
args.gun_particles, acts.PdgParticle.eMuon, randomizeCharge=True
),
vtxGen=acts.examples.GaussianVertexGenerator(
mean=acts.Vector4(0, 0, 0, 0),
stddev=acts.Vector4(
0.0125 * u.mm, 0.0125 * u.mm, 55.5 * u.mm, 1.0 * u.ns
),
),
multiplicity=args["gun_multiplicity"],
multiplicity=args.gun_multiplicity,
rnd=rnd,
)
else:
addPythia8(
s,
hardProcess=["Top:qqbar2ttbar=on"],
npileup=args["ttbar_pu"],
npileup=args.ttbar_pu,
vtxGen=acts.examples.GaussianVertexGenerator(
mean=acts.Vector4(0, 0, 0, 0),
stddev=acts.Vector4(
0.0125 * u.mm, 0.0125 * u.mm, 55.5 * u.mm, 5.0 * u.ns
),
),
rnd=rnd,
outputDirRoot=outputDir,
# outputDirCsv=outputDir,
outputDirRoot=outputDir if args.output_root else None,
outputDirCsv=outputDir if args.output_csv else None,
)

if g4_simulation:
if args.geant4:
if s.config.numThreads != 1:
raise ValueError("Geant 4 simulation does not support multi-threading")

Expand All @@ -212,8 +270,8 @@
pt=(150 * u.MeV, None),
removeNeutral=True,
),
outputDirRoot=outputDir,
# outputDirCsv=outputDir,
outputDirRoot=outputDir if args.output_root else None,
outputDirCsv=outputDir if args.output_csv else None,
rnd=rnd,
killVolume=trackingGeometry.worldVolume,
killAfterTime=25 * u.ns,
Expand All @@ -231,12 +289,12 @@
pt=(150 * u.MeV, None),
removeNeutral=True,
)
if ttbar
if args.ttbar
else ParticleSelectorConfig()
),
enableInteractions=True,
outputDirRoot=outputDir,
# outputDirCsv=outputDir,
outputDirRoot=outputDir if args.output_root else None,
outputDirCsv=outputDir if args.output_csv else None,
rnd=rnd,
)

Expand All @@ -245,107 +303,108 @@
trackingGeometry,
field,
digiConfigFile=oddDigiConfig,
outputDirRoot=outputDir,
# outputDirCsv=outputDir,
outputDirRoot=outputDir if args.output_root else None,
outputDirCsv=outputDir if args.output_csv else None,
rnd=rnd,
)

addSeeding(
s,
trackingGeometry,
field,
(
TruthSeedRanges(pt=(1.0 * u.GeV, None), eta=(-3.0, 3.0), nHits=(9, None))
if ttbar
else TruthSeedRanges()
),
geoSelectionConfigFile=oddSeedingSel,
outputDirRoot=outputDir,
# outputDirCsv=outputDir,
)

if seedFilter_ML:
addSeedFilterML(
if args.reco:
addSeeding(
s,
SeedFilterMLDBScanConfig(
epsilonDBScan=0.03, minPointsDBScan=2, minSeedScore=0.1
trackingGeometry,
field,
(
TruthSeedRanges(pt=(1.0 * u.GeV, None), eta=(-3.0, 3.0), nHits=(9, None))
if args.ttbar
else TruthSeedRanges()
),
onnxModelFile=os.path.dirname(__file__)
+ "/MLAmbiguityResolution/seedDuplicateClassifier.onnx",
outputDirRoot=outputDir,
# outputDirCsv=outputDir,
geoSelectionConfigFile=oddSeedingSel,
outputDirRoot=outputDir if args.output_root else None,
outputDirCsv=outputDir if args.output_csv else None,
)

addCKFTracks(
s,
trackingGeometry,
field,
TrackSelectorConfig(
pt=(1.0 * u.GeV if ttbar else 0.0, None),
absEta=(None, 3.0),
loc0=(-4.0 * u.mm, 4.0 * u.mm),
nMeasurementsMin=7,
maxHoles=2,
maxOutliers=2,
),
CkfConfig(
seedDeduplication=True,
stayOnSeed=True,
),
outputDirRoot=outputDir,
writeCovMat=True,
# outputDirCsv=outputDir,
)
if seedFilter_ML:
addSeedFilterML(
s,
SeedFilterMLDBScanConfig(
epsilonDBScan=0.03, minPointsDBScan=2, minSeedScore=0.1
),
onnxModelFile=os.path.dirname(__file__)
+ "/MLAmbiguityResolution/seedDuplicateClassifier.onnx",
outputDirRoot=outputDir if args.output_root else None,
outputDirCsv=outputDir if args.output_csv else None,
)

if ambi_ML:
addAmbiguityResolutionML(
addCKFTracks(
s,
AmbiguityResolutionMLConfig(
maximumSharedHits=3, maximumIterations=1000000, nMeasurementsMin=7
trackingGeometry,
field,
TrackSelectorConfig(
pt=(1.0 * u.GeV if args.ttbar else 0.0, None),
absEta=(None, 3.0),
loc0=(-4.0 * u.mm, 4.0 * u.mm),
nMeasurementsMin=7,
maxHoles=2,
maxOutliers=2,
),
outputDirRoot=outputDir,
# outputDirCsv=outputDir,
onnxModelFile=os.path.dirname(__file__)
+ "/MLAmbiguityResolution/duplicateClassifier.onnx",
)

elif ambi_scoring:
addScoreBasedAmbiguityResolution(
s,
ScoreBasedAmbiguityResolutionConfig(
minScore=0,
minScoreSharedTracks=1,
maxShared=2,
maxSharedTracksPerMeasurement=2,
pTMax=1400,
pTMin=0.5,
phiMax=3.14,
phiMin=-3.14,
etaMax=4,
etaMin=-4,
useAmbiguityFunction=False,
CkfConfig(
seedDeduplication=True,
stayOnSeed=True,
),
outputDirRoot=outputDir,
ambiVolumeFile=ambi_config,
outputDirRoot=outputDir if args.output_root else None,
outputDirCsv=outputDir if args.output_csv else None,
writeCovMat=True,
# outputDirCsv=outputDir,
)
else:
addAmbiguityResolution(

if ambi_ML:
addAmbiguityResolutionML(
s,
AmbiguityResolutionMLConfig(
maximumSharedHits=3, maximumIterations=1000000, nMeasurementsMin=7
),
outputDirRoot=outputDir if args.output_root else None,
outputDirCsv=outputDir if args.output_csv else None,
onnxModelFile=os.path.dirname(__file__)
+ "/MLAmbiguityResolution/duplicateClassifier.onnx",
)

elif ambi_scoring:
addScoreBasedAmbiguityResolution(
s,
ScoreBasedAmbiguityResolutionConfig(
minScore=0,
minScoreSharedTracks=1,
maxShared=2,
maxSharedTracksPerMeasurement=2,
pTMax=1400,
pTMin=0.5,
phiMax=3.14,
phiMin=-3.14,
etaMax=4,
etaMin=-4,
useAmbiguityFunction=False,
),
outputDirRoot=outputDir if args.output_root else None,
outputDirCsv=outputDir if args.output_csv else None,
ambiVolumeFile=ambi_config,
writeCovMat=True,
)
else:
addAmbiguityResolution(
s,
AmbiguityResolutionConfig(
maximumSharedHits=3, maximumIterations=1000000, nMeasurementsMin=7
),
outputDirRoot=outputDir if args.output_root else None,
outputDirCsv=outputDir if args.output_csv else None,
writeCovMat=True,
)

addVertexFitting(
s,
AmbiguityResolutionConfig(
maximumSharedHits=3, maximumIterations=1000000, nMeasurementsMin=7
),
outputDirRoot=outputDir,
writeCovMat=True,
# outputDirCsv=outputDir,
field,
vertexFinder=VertexFinder.Iterative,
outputDirRoot=outputDir if args.output_root else None,
)

addVertexFitting(
s,
field,
vertexFinder=VertexFinder.Iterative,
outputDirRoot=outputDir,
)

s.run()
Loading

0 comments on commit 3681185

Please sign in to comment.