Skip to content
Snippets Groups Projects

Testbeam Update

Merged Eric Torrence requested to merge fasermc-dev into master
17 files
+ 491
183
Compare changes
  • Side-by-side
  • Inline
Files
17
@@ -7,23 +7,26 @@
# filepath - fully qualified path, including url if needed, to the input HITS file
# example: "root://eospublic.cern.ch//eos/experiment/faser/sim/GeniePilot/HITS/1/faser.150fbInv.1.001.HITS.pool.root"
#
# runtype - MANDATORY flag to specify the data type (TI12OldMC or TI12MC or TestBeamMC).
# Not extracted (yet) from file path for MC data
# runtype - flag to specify the data type (TI12OldMC or TI12MC or TestBeamMC).
# default to TI12MC
#
import sys
import time
import argparse
a = time.time()
parser = argparse.ArgumentParser(description="Run FASER reconstruction")
parser.add_argument("file_path",
help="Fully qualified path of the raw input file")
parser.add_argument("run_type", nargs="?", default="",
help="Specify run type (if it can't be parsed from path)")
parser.add_argument("-g", "--geom", default="TI12MC",
help="Specify geometry (default: TI12MC, alt: TestBeamMC)")
parser.add_argument("-t", "--tag", default="",
help="Specify tag (to append to output filename)")
help="Specify digi tag (to append to output filename)")
parser.add_argument("--highCaloGain", action='store_true',
help="Use high gain settings for calo PMTs")
parser.add_argument("-n", "--nevents", type=int, default=-1,
parser.add_argument("-n", "--nevts", type=int, default=-1,
help="Specify number of events to process (default: all)")
parser.add_argument("-v", "--verbose", action='store_true',
help="Turn on DEBUG output")
@@ -35,22 +38,11 @@ from pathlib import Path
filepath=Path(args.file_path)
# runtype has been provided
if len(args.run_type) > 0:
runtype=args.run_type
# Extract runtype from path
# Should be directory above run
# i.e.: TestBeamData/Run-004150/Faser-Physics-004150-00000.raw"
else:
if True or len(filepath.parts) < 3:
print("Can't determine run type from path - specify on command line ")
sys.exit(-1)
# runtype = filepath.parts[-3]
runtype= args.geom
print(f"Starting digitization of {filepath.name} with type {runtype}")
if args.nevents > 0:
print(f"Reconstructing {args.nevents} events by command-line option")
if args.nevts > 0:
print(f"Reconstructing {args.nevts} events by command-line option")
# Start digitization
@@ -88,21 +80,26 @@ elif runtype == "TI12MC":
ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-02"
else:
print("Invalid run type found:", runtype)
print("Specify correct type or update list")
print("Invalid geometry type found:", runtype)
print("Specify correct geometry or update list")
sys.exit(-1)
# Must use original input string here, as pathlib mangles double // in path names
ConfigFlags.Input.Files = [ args.file_path ]
filestem = filepath.stem
# Remove any filetype modifier
if filestem[-5:] == "-HITS":
filestem = filestem[:-5]
if len(args.tag) > 0:
filestem += f"-{args.tag}"
print(f"{args.tag} in {filestem}?")
if args.tag in filestem:
print(f"Not adding tag {args.tag} to file {filestem}")
else:
filestem += f"-{args.tag}"
# ConfigFlags.addFlag("Output.xAODFileName", f"{filestem}-xAOD.root")
ConfigFlags.Output.RDOFileName = f"{filestem}-RDO.root"
#
# Play around with this?
# ConfigFlags.Concurrency.NumThreads = 2
@@ -138,59 +135,6 @@ acc.merge(CaloWaveformDigitizationCfg(ConfigFlags, CB_norm=calo_norm))
from ScintDigiAlgs.ScintDigiAlgsConfig import ScintWaveformDigitizationCfg
acc.merge(ScintWaveformDigitizationCfg(ConfigFlags))
# from WaveRecAlgs.WaveRecAlgsConfig import WaveformReconstructionCfg
# acc.merge(WaveformReconstructionCfg(ConfigFlags))
# # Not ready for primetime
# # from CaloRecAlgs.CaloRecAlgsConfig import CalorimeterReconstructionCfg
# # acc.merge(CalorimeterReconstructionCfg(ConfigFlags))
# # Tracker clusters
# from TrackerPrepRawDataFormation.TrackerPrepRawDataFormationConfig import FaserSCT_ClusterizationCfg
# acc.merge(FaserSCT_ClusterizationCfg(ConfigFlags))
# # SpacePoints
# from TrackerSpacePointFormation.TrackerSpacePointFormationConfig import TrackerSpacePointFinderCfg
# acc.merge(TrackerSpacePointFinderCfg(ConfigFlags))
# # Try Dave's fitter
# from TrackerClusterFit.TrackerClusterFitConfig import ClusterFitAlgCfg
# acc.merge(ClusterFitAlgCfg(ConfigFlags))
#
# Configure output
# from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
# itemList = [ "xAOD::EventInfo#*"
# , "xAOD::EventAuxInfo#*"
# , "xAOD::FaserTriggerData#*"
# , "xAOD::FaserTriggerDataAux#*"
# , "FaserSCT_RDO_Container#*"
# # , "Tracker::FaserSCT_ClusterContainer#*"
# # , "FaserSCT_SpacePointContainer#*"
# # , "FaserSCT_SpacePointOverlapCollection#*"
# # , "TrackCollection#*"
# ]
# acc.merge(OutputStreamCfg(ConfigFlags, "xAOD", itemList))
# Waveform reconstruction output
# from WaveRecAlgs.WaveRecAlgsConfig import WaveformReconstructionOutputCfg
# acc.merge(WaveformReconstructionOutputCfg(ConfigFlags))
# Calorimeter reconstruction output
# from CaloRecAlgs.CaloRecAlgsConfig import CalorimeterReconstructionOutputCfg
# acc.merge(CalorimeterReconstructionOutputCfg(ConfigFlags))
# Check what we have
# print( "Writing out xAOD objects:" )
# print( acc.getEventAlgo("OutputStreamxAOD").ItemList )
# Hack to avoid problem with our use of MC databases when isMC = False
# replicaSvc = acc.getService("DBReplicaSvc")
# replicaSvc.COOLSQLiteVetoPattern = ""
# replicaSvc.UseCOOLSQLite = True
# replicaSvc.UseCOOLFrontier = False
# replicaSvc.UseGeomSQLite = True
# Configure verbosity
if args.verbose:
acc.foreach_component("*").OutputLevel = VERBOSE
@@ -204,4 +148,10 @@ acc.foreach_component("*ClassID*").OutputLevel = INFO
acc.getService("MessageSvc").Format = "% F%40W%S%7W%R%T %0W%M"
# Execute and finish
sys.exit(int(acc.run(maxEvents=args.nevents).isFailure()))
sc = acc.run(maxEvents=args.nevts)
b = time.time()
from AthenaCommon.Logging import log
log.info(f"Finish execution in {b-a} seconds")
sys.exit(not sc.isSuccess())
Loading