diff --git a/Control/CalypsoExample/Digitization/scripts/faser_digi.py b/Control/CalypsoExample/Digitization/scripts/faser_digi.py index 9a1ced5b0ca751c6ff2b975083984c4b9890eee6..34ab8842cfead120ebb326d4a97cc442f406ef8d 100755 --- a/Control/CalypsoExample/Digitization/scripts/faser_digi.py +++ b/Control/CalypsoExample/Digitization/scripts/faser_digi.py @@ -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()) diff --git a/Control/CalypsoExample/Generation/python/faser_parser.py b/Control/CalypsoExample/Generation/python/faser_parser.py new file mode 100644 index 0000000000000000000000000000000000000000..43f98387e7089cfdf258531ec57aeea072b70f53 --- /dev/null +++ b/Control/CalypsoExample/Generation/python/faser_parser.py @@ -0,0 +1,175 @@ +# +# Copyright (C) 2022 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2022 CERN for the benefit of the FASER collaboration +# +# Parser function for particle gun samples +# +def faser_pgparser(): + + import sys + import json + import argparse + + parser = argparse.ArgumentParser(description="Run FASER ParticleGun Simulation") + + parser.add_argument("--conf", action='append', + help="Specify configuration file with default values") + parser.add_argument("--geom", default="TI12MC", + help="Specify geomtery to simulation (default: TI12MC, alt: TestBeamMC)") + + parser.add_argument("--run", default=123456, type=int, + help="Run number to generate") + parser.add_argument("--segment", default=00000, type=int, + help="Segment number to generate") + parser.add_argument("--file_length", default=1000, type=int, + help="Total events per file segement") + + parser.add_argument("--short", default="PG_logE", + help="Short description for filename") + parser.add_argument("--tag", default=None, + help="Generator tag (e.g.: g0000)") + + parser.add_argument("--pid", default=[-13, 13], type=int, nargs='*', + help="Specify PDG ID of particle (note plus/minus different) or list (e.g.: --pid -13 13)") + parser.add_argument("--mass", default=105.66, type=float, + help="Specify particle mass (in MeV)") + parser.add_argument("--radius", default=100., type=float, + help="Specify radius (in mm)") + parser.add_argument("--angle", default=0.005, type=float, + help="Specify angular width (in Rad)") + parser.add_argument("--zpos", default=None, type=float, + help="Specify z position of particles (in mm) (helpful to avoid FASERnu)") + + parser.add_argument("--sampler", default="log", + help="Specify energy sampling (log, lin, const)") + parser.add_argument("--minE", default=10., type=float, + help="Minimum energy in GeV (for log or lin sampler)") + parser.add_argument("--maxE", default=1000., type=float, + help="Maximum energy (or constant) in GeV") + + parser.add_argument("--nevts", default=-1, type=int, + help="Number of events to generate (for debugging)") + parser.add_argument("--dump", action='store_true', + help="Write out full configuration") + parser.add_argument("--noexec", action='store_true', + help="Exit after parsing configuration (no execution)") + + pg_args = parser.parse_args() + + # Get defaults + if pg_args.conf is not None: + for conf_fname in pg_args.conf: + with open(conf_fname, 'r') as f: + parser.set_defaults(**json.load(f)) + + # Reload arguments to override config file with command line + pg_args = parser.parse_args() + + # Print out configuration if requested + if pg_args.dump: + tmp_args = vars(pg_args).copy() + del tmp_args['dump'] # Don't dump the dump value + del tmp_args['conf'] # Don't dump the conf file name either + del tmp_args['nevts'] # Debugging, not part of configuration + del tmp_args['noexec'] # Debugging, not part of configuration + print("Configuration:") + print(json.dumps(tmp_args, indent=4, sort_keys=False)) + + if pg_args.noexec: + sys.exit(0) + + # + # Add some derived quantities + # + + # Create the file name also (could add gentag here) + pg_args.outfile = f"FaserMC-{pg_args.short}-{pg_args.run:06}-{pg_args.segment:05}" + + if pg_args.tag: + pg_args.outfile += f"-{pg_args.tag}" + + pg_args.outfile += "-HITS.root" + + return pg_args + +# All done + +# +# Parser function for Foresee samples +# +def faser_fsparser(): + + import sys + import json + import argparse + + parser = argparse.ArgumentParser(description="Run FASER Foresee Simulation") + + parser.add_argument("--conf", action='append', + help="Specify configuration file with default values") + parser.add_argument("--run", default=123456, type=int, + help="Run number to generate") + parser.add_argument("--segment", default=00000, type=int, + help="Segment number to generate") + parser.add_argument("--file_length", default=1000, type=int, + help="Total events per file segement") + + parser.add_argument("--model", help="Model name") + parser.add_argument("--model_path", help="Path to model phase space file") + + parser.add_argument("--short", default="PG_logE", + help="Short description for filename") + parser.add_argument("--tag", default=None, + help="Generator tag (g0000)") + + parser.add_argument("--pid", default=[-13, 13], type=int, nargs=2, + help="Specify PDG ID of daughter particles") + parser.add_argument("--mass", default=105.66, type=float, + help="Specify particle mass (in MeV)") + + parser.add_argument("--nevts", default=-1, type=int, + help="Number of events to generate (for debugging)") + parser.add_argument("--dump", action='store_true', + help="Write out full configuration") + parser.add_argument("--noexec", action='store_true', + help="Exit after parsing configuration (no execution)") + + fs_args = parser.parse_args() + + # Get defaults + if fs_args.conf is not None: + for conf_fname in fs_args.conf: + with open(conf_fname, 'r') as f: + parser.set_defaults(**json.load(f)) + + # Reload arguments to override config file with command line + fs_args = parser.parse_args() + + # Print out configuration if requested + if fs_args.dump: + tmp_args = vars(fs_args).copy() + del tmp_args['dump'] # Don't dump the dump value + del tmp_args['conf'] # Don't dump the conf file name either + del tmp_args['nevts'] # Debugging, not part of configuration + del tmp_args['noexec'] # Debugging, not part of configuration + print("Configuration:") + print(json.dumps(tmp_args, indent=4, sort_keys=False)) + + if fs_args.noexec: + sys.exit(0) + + # + # Add some derived quantities + # + + # Create the file name also (could add gentag here) + fs_args.outfile = f"FaserMC-{fs_args.short}-{fs_args.run:06}-{fs_args.segment:05}" + + if fs_args.tag: + fs_args.outfile += f"-{fs_args.tag}" + + fs_args.outfile += "-HITS.root" + + return fs_args + +# All done diff --git a/Control/CalypsoExample/Generation/scripts/faserMDC_foresee.py b/Control/CalypsoExample/Generation/scripts/faserMDC_foresee.py index b48bbf861ed4bbac6e0a6fb6cc9fd95da5049138..f16b6a40a0413278097824bb7af63b51811eaa9c 100755 --- a/Control/CalypsoExample/Generation/scripts/faserMDC_foresee.py +++ b/Control/CalypsoExample/Generation/scripts/faserMDC_foresee.py @@ -124,7 +124,7 @@ if __name__ == '__main__': # # MDC geometry configuration # - detectors = ['Veto', 'VetoNu', 'Preshower', 'FaserSCT', 'Ecal', 'Trigger', 'Dipole', 'Emulsion'] + detectors = ['Veto', 'VetoNu', 'Preshower', 'FaserSCT', 'Ecal', 'Trigger', 'Dipole', 'Emulsion', 'Trench'] # # Setup detector flags # diff --git a/Control/CalypsoExample/Generation/scripts/faserMDC_particlegun.py b/Control/CalypsoExample/Generation/scripts/faserMDC_particlegun.py index 12fe153bf0ccc712c8b72992bf27a60260b84bc4..98975a548601209a81b932c7cbbbe03da7184035 100755 --- a/Control/CalypsoExample/Generation/scripts/faserMDC_particlegun.py +++ b/Control/CalypsoExample/Generation/scripts/faserMDC_particlegun.py @@ -135,7 +135,7 @@ if __name__ == '__main__': # # MDC geometry configuration # - detectors = ['Veto', 'VetoNu', 'Preshower', 'FaserSCT', 'Ecal', 'Trigger', 'Dipole', 'Emulsion'] + detectors = ['Veto', 'VetoNu', 'Preshower', 'FaserSCT', 'Ecal', 'Trigger', 'Dipole', 'Emulsion', 'Trench'] # # Setup detector flags # diff --git a/Control/CalypsoExample/Generation/scripts/faser_particlegun.py b/Control/CalypsoExample/Generation/scripts/faser_particlegun.py index ee38005df79c3f6aab97b5c800f3949521110a02..fa5288d8e358e438d810da8db7c103a91bc2780a 100755 --- a/Control/CalypsoExample/Generation/scripts/faser_particlegun.py +++ b/Control/CalypsoExample/Generation/scripts/faser_particlegun.py @@ -2,27 +2,36 @@ """ Produce particle gun samples Derived from G4FaserAlgConfigNew -This is a general low-level script, -although this could be useful for testing. Usage: -faser_particlegun.py <options> - -Control using command-line options: ---evtMax=1000 ---skipEvt=1000 - -Output.HITSFileName=<name> -Sim.Gun='{"pid" : 11, "z": -1500.}' +faserTB_particlegun.py --conf=<config_file> Copyright (C) 2002-2021 CERN for the benefit of the ATLAS and FASER collaborations """ if __name__ == '__main__': + import sys import time a = time.time() # +# Parse command-line options +# + from Generation.faser_parser import faser_pgparser + args = faser_pgparser() +# +# Figure out events to run and skip +# + nskipped = args.segment*args.file_length + if args.nevts > 0: + nevents = args.nevts + else: + nevents = args.file_length +# +# Print out what we are doing +# + print(f"Generating {nevents} evnts into file {args.outfile}") +# # Set up logging and config behaviour # from AthenaCommon.Logging import log @@ -34,21 +43,22 @@ if __name__ == '__main__': # Import and set config flags # from CalypsoConfiguration.AllConfigFlags import ConfigFlags - ConfigFlags.Exec.MaxEvents = 10 # can be overridden from command line with --evtMax=<number> - ConfigFlags.Exec.SkipEvents = 0 # can be overridden from command line with --skipEvt=<number> + ConfigFlags.Exec.MaxEvents = nevents + ConfigFlags.Exec.SkipEvents = nskipped from AthenaConfiguration.Enums import ProductionStep ConfigFlags.Common.ProductionStep = ProductionStep.Simulation # # All these must be specified to avoid auto-configuration # - ConfigFlags.Input.RunNumber = [12345] #Isn't updating - todo: investigate + ConfigFlags.Input.RunNumber = [args.run] ConfigFlags.Input.OverrideRunNumber = True - ConfigFlags.Input.LumiBlockNumber = [1] + ConfigFlags.Input.LumiBlockNumber = [(args.segment+1)] ConfigFlags.Input.isMC = True + ConfigFlags.IOVDb.DatabaseInstance = "OFLP200" # Use MC conditions # # Output file name # - ConfigFlags.Output.HITSFileName = "my.HITS.pool.root" # can be overridden from command line with Output.HITSFileName=<name> + ConfigFlags.Output.HITSFileName = args.outfile # # Sim ConfigFlags # @@ -59,46 +69,86 @@ if __name__ == '__main__': ConfigFlags.addFlag("Sim.Gun",{"Generator" : "SingleParticle"}) # Property bag for particle gun keyword:argument pairs ConfigFlags.addFlag("Sim.Beam.xangle", 0) # Potential beam crossing angles ConfigFlags.addFlag("Sim.Beam.yangle", 0) - - ConfigFlags.GeoModel.FaserVersion = "FASERNU-02" # Geometry set-up - ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-02" # Conditions set-up - ConfigFlags.addFlag("Input.InitialTimeStamp", 0) # To avoid autoconfig + ConfigFlags.addFlag("Sim.Beam.xshift", 0) # Potential beam shift + ConfigFlags.addFlag("Sim.Beam.yshift", 0) + + if args.geom == "TI12MC": + # 2022 TI12 geometry + ConfigFlags.GeoModel.FaserVersion = "FASERNU-02" # Geometry set-up + ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-02" # Conditions set-up + # TI12 detectors + detectors = ['Veto', 'VetoNu', 'Preshower', 'FaserSCT', 'Ecal', 'Trigger', + 'Dipole', 'Emulsion', 'Trench'] + + elif args.geom == "TestBeamMC": + # Define 2021 test beam geometry + ConfigFlags.GeoModel.FaserVersion = "FASER-TB00" # Geometry set-up + ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-TB00" # Conditions set-up + # Testbeam detectors (trigger layers are actually veto counters) + detectors = ['Veto', 'Preshower', 'FaserSCT', 'Ecal'] + + else: + print(f"Unknown geometry {args.geom}!") + sys.exit(1) + + ConfigFlags.addFlag("Input.InitialTimeStamp", 0) # To avoid autoconfig ConfigFlags.GeoModel.Align.Dynamic = False - # # Preset particle gun parameters # - from math import atan + import ParticleGun as PG from AthenaCommon.SystemOfUnits import GeV, TeV, cm, m from AthenaCommon.PhysicalConstants import pi - # 11 - electron, 13 - muon, 22 - photon - import ParticleGun as PG - ConfigFlags.Sim.Gun = { - "Generator" : "SingleParticle", "pid" : 13, - "energy" : PG.LogSampler(10*GeV, 1*TeV), - "theta" : PG.GaussianSampler(0, atan((10*cm)/(7*m)), oneside = True), - "phi" : [0, 2*pi], "mass" : 0.511, "radius" : -10*cm, #"z": -2.0*m, - "randomSeed" : 12345} - -# -# Command-line overrides -# -# These have the format: Sim.Gun='{"pid" : 11}' -# Filename: Output.HITSFileName="test.muon.001.root" -# Also number of events: --evtMax 100 -# Starting at z = -1.5m (-1500.) will miss the veto (for electrons) - - import sys - ConfigFlags.fillFromArgs(sys.argv[1:]) - + if isinstance(args.pid, list): + # Note args.pid is a list, must make this a set for ParticleGun + pidarg = set(args.pid) + else: + # Just pass a single value + pidarg = args.pid + + print(f"Using pid: {args.pid} => {pidarg}") + + # Create the simgun dictionary + # Negative radius gives uniform sampling + # Positive radius gives Gaussian sampling + sg_dict = { + "Generator" : "SingleParticle", + "pid" : pidarg, "mass" : args.mass, + "theta" : PG.GaussianSampler(0, args.angle, oneside = True), + "phi" : [0, 2*pi], "radius" : args.radius, + "randomSeed" : args.outfile + } + + # -1000 is safely upstream of detector (to be checked) + # Note zpos is in mm! + if args.zpos: + sg_dict["z"] = args.zpos + + # Determine energy sampling + if args.sampler == "lin": + sg_dict["energy"] = PG.UniformSampler(args.minE*GeV, args.maxE*GeV) + elif args.sampler == "log": + sg_dict["energy"] = PG.LogSampler(args.minE*GeV, args.maxE*GeV) + elif args.sampler == "const": + sg_dict["energy"] = PG.ConstSampler(args.maxE*GeV) + else: + print(f"Sampler {args.sampler} not known!") + sys.exit(1) + + # Pass this in one go to ConfigFlags + ConfigFlags.Sim.Gun = sg_dict + + doShiftLOS = (ConfigFlags.Sim.Beam.xangle or ConfigFlags.Sim.Beam.yangle or + ConfigFlags.Sim.Beam.xshift or ConfigFlags.Sim.Beam.yshift) + + if doShiftLOS: + pgConfig = ConfigFlags.Sim.Gun + pgConfig["McEventKey"] = "BeamTruthEvent_ATLASCoord" + ConfigFlags.Sim.Gun = pgConfig # # By being a little clever, we can steer the geometry setup from the command line using GeoModel.FaserVersion # -# MDC configuration -# - detectors = ['Veto', 'Preshower', 'FaserSCT', 'Ecal', 'Trigger', 'Dipole', 'Emulsion'] -# # Setup detector flags # from CalypsoConfiguration.DetectorConfigFlags import setupDetectorsFromList @@ -134,20 +184,22 @@ if __name__ == '__main__': # Shift LOS # - if ConfigFlags.Sim.Beam.xangle or ConfigFlags.Sim.Beam.yangle: - MCEventKey = "BeamTruthEventShifted" + if doShiftLOS: import McParticleEvent.Pythonizations from GeneratorUtils.ShiftLOSConfig import ShiftLOSCfg - cfg.merge(ShiftLOSCfg(ConfigFlags, OutputMCEventKey = MCEventKey, - xcross = ConfigFlags.Sim.Beam.xangle, ycross = ConfigFlags.Sim.Beam.yangle)) - else: - MCEventKey = "BeamTruthEvent" + + cfg.merge(ShiftLOSCfg(ConfigFlags, + xcross = ConfigFlags.Sim.Beam.xangle, + ycross = ConfigFlags.Sim.Beam.yangle, + xshift = ConfigFlags.Sim.Beam.xshift, + yshift = ConfigFlags.Sim.Beam.yshift)) + # # Add the G4FaserAlg # from G4FaserAlg.G4FaserAlgConfigNew import G4FaserAlgCfg - cfg.merge(G4FaserAlgCfg(ConfigFlags, InputTruthCollection = MCEventKey)) + cfg.merge(G4FaserAlgCfg(ConfigFlags)) # # Dump config # diff --git a/Control/CalypsoExample/Reconstruction/CMakeLists.txt b/Control/CalypsoExample/Reconstruction/CMakeLists.txt index 5dbb5a46c9943df6d18019963f0387aa3c608c9b..23af9627f673516d4e78d17a75596770ca6e3b4b 100644 --- a/Control/CalypsoExample/Reconstruction/CMakeLists.txt +++ b/Control/CalypsoExample/Reconstruction/CMakeLists.txt @@ -18,16 +18,15 @@ atlas_install_python_modules( python/*.py ) atlas_install_scripts( scripts/*.sh scripts/*.py ) atlas_add_test( ProdRecoTI12 - SCRIPT scripts/faser_reco.py ${CMAKE_CURRENT_SOURCE_DIR}/../rawdata/Faser-Physics-001920-filtered.raw TI12Data + SCRIPT scripts/faser_reco.py --geom=TI12Data ${CMAKE_CURRENT_SOURCE_DIR}/../rawdata/Faser-Physics-001920-filtered.raw PROPERTIES TIMEOUT 300 ) -# Turn this off until we figure out the CKF behavior on testbeam data atlas_add_test( ProdRecoTestBeam - SCRIPT scripts/faser_reco.py ${CMAKE_CURRENT_SOURCE_DIR}/../RAWDATA/Faser-Physics-003613-filtered.raw TestBeamData + SCRIPT scripts/faser_reco.py --geom=TestBeamData ${CMAKE_CURRENT_SOURCE_DIR}/../RAWDATA/Faser-Physics-003613-filtered.raw PROPERTIES TIMEOUT 300 ) atlas_add_test( ProdRecoPilotTracks - SCRIPT scripts/faser_reco.py ${CMAKE_CURRENT_SOURCE_DIR}/../RAWDATA/Faser-Physics-pilot_tracks-filtered.raw TI12Data + SCRIPT scripts/faser_reco.py --geom=TI12Data ${CMAKE_CURRENT_SOURCE_DIR}/../RAWDATA/Faser-Physics-pilot_tracks-filtered.raw PROPERTIES TIMEOUT 300 ) # Test of TI12Data02 geometry (should auto-select from run number) diff --git a/Control/CalypsoExample/Reconstruction/scripts/faser_reco.py b/Control/CalypsoExample/Reconstruction/scripts/faser_reco.py index bcbdf389f95422f17321313f40f4da6d55986323..78c829f43d846ce0912039cfd0f4edef67a20830 100755 --- a/Control/CalypsoExample/Reconstruction/scripts/faser_reco.py +++ b/Control/CalypsoExample/Reconstruction/scripts/faser_reco.py @@ -2,16 +2,16 @@ # # Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration # Run with: -# ./faser_reco.py filepath [runtype] +# ./faser_reco.py [--geom=runtype] filepath # # filepath - fully qualified path, including url if needed, to the input raw data file # example: "root://hepatl30//atlas/local/torrence/faser/commissioning/TestBeamData/Run-004150/Faser-Physics-004150-00000.raw" # # runtype - optionally specify the data type (TI12Data, TI12Data02, TI12Data03 or TestBeamData). -# In a normal file system location, this will be extracted from the directory name, -# but runtype will override this assignment. -# TI12Data02 is needed for the IFT geometry. Script will auto-detect this if read -# from normal file system location. +# +# Options: +# --isMC - needed to reconstruct MC data +# --testBeam - shortcut to specify testbeam geometry # import sys import time @@ -23,8 +23,8 @@ 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="", + help="Specify geometry (if it can't be parsed from run number)\n Values: TI12Data03 (2022 TI12)") parser.add_argument("-r", "--reco", default="", help="Specify reco tag (to append to output filename)") parser.add_argument("-n", "--nevents", type=int, default=-1, @@ -33,7 +33,8 @@ parser.add_argument("-v", "--verbose", action='store_true', help="Turn on DEBUG output") parser.add_argument("--isMC", action='store_true', help="Running on digitised MC rather than data") - +parser.add_argument("--testBeam", action='store_true', + help="Set geometry for 2021 test beam") args = parser.parse_args() @@ -42,12 +43,14 @@ from pathlib import Path filepath=Path(args.file_path) # runtype has been provided -if len(args.run_type) > 0: - runtype=args.run_type +if len(args.geom) > 0: + runtype=args.geom + +# Shortcut for testbeam +elif args.testBeam: + print(f"Use 2021 TestBeam configuration") + runtype = "TestBeamData" -# Extract runtype from path -# Should be directory above run -# i.e.: TestBeamData/Run-004150/Faser-Physics-004150-00000.raw" else: runtype = "TI12Data03" @@ -90,7 +93,10 @@ Configurable.configurableRun3Behavior = True # Flags for this job ConfigFlags.Input.isMC = args.isMC # Needed to bypass autoconfig -ConfigFlags.IOVDb.DatabaseInstance = "OFLP200" # Use MC conditions for now +if args.isMC: + ConfigFlags.IOVDb.DatabaseInstance = "OFLP200" # Use MC conditions +else: + ConfigFlags.IOVDb.DatabaseInstance = "CONDBR3" # Use data conditions ConfigFlags.Input.ProjectName = "data20" ConfigFlags.GeoModel.Align.Dynamic = False @@ -123,13 +129,17 @@ elif runtype == "TI12Data03": else: print("Invalid run type found:", runtype) print("Specify correct type or update list") - sys.exit(-1) + 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[-4:] == "-RDO": + filestem = filestem[:-4] + if len(args.reco) > 0: filestem += f"-{args.reco}" @@ -218,7 +228,11 @@ itemList = [ "xAOD::EventInfo#*" ] # if args.isMC: - # Add truth records here? + # Make xAOD versions of truth + from Reconstruction.xAODTruthCnvAlgConfig import xAODTruthCnvAlgCfg + acc.merge(xAODTruthCnvAlgCfg(ConfigFlags)) + + # Add MC information here itemList.extend( ["McEventCollection#*", "TrackerSimDataCollection#*"] ) acc.merge(OutputStreamCfg(ConfigFlags, "xAOD", itemList)) @@ -244,9 +258,9 @@ if not args.isMC: replicaSvc.UseGeomSQLite = True # Configure verbosity -ConfigFlags.dump() if args.verbose: acc.foreach_component("*").OutputLevel = VERBOSE + ConfigFlags.dump() else: acc.foreach_component("*").OutputLevel = INFO diff --git a/Control/CalypsoExample/Simulation/scripts/faserMDC_simulate.py b/Control/CalypsoExample/Simulation/scripts/faserMDC_simulate.py index 12de492f4070237b59dda273673b994bbc275d37..0fd9622db5de8630ffaef34bd2ae4b6eabe88a5c 100755 --- a/Control/CalypsoExample/Simulation/scripts/faserMDC_simulate.py +++ b/Control/CalypsoExample/Simulation/scripts/faserMDC_simulate.py @@ -160,7 +160,7 @@ if __name__ == '__main__': # # MDC geometry configuration # - detectors = ['Veto', 'VetoNu', 'Preshower', 'FaserSCT', 'Ecal', 'Trigger', 'Dipole', 'Emulsion'] + detectors = ['Veto', 'VetoNu', 'Preshower', 'FaserSCT', 'Ecal', 'Trigger', 'Dipole', 'Emulsion', 'Trench'] # # Setup detector flags # diff --git a/Database/ConnectionManagement/FaserAuthentication/data/dblookup.xml b/Database/ConnectionManagement/FaserAuthentication/data/dblookup.xml index 9cebc2e82b233d6191d7671cf6d9d6997cad23f9..dd6b0f9e1d713c966d59fa41341a414682de90cf 100644 --- a/Database/ConnectionManagement/FaserAuthentication/data/dblookup.xml +++ b/Database/ConnectionManagement/FaserAuthentication/data/dblookup.xml @@ -27,8 +27,8 @@ </logicalservice> <logicalservice name="COOLOFL_TRIGGER"> - <service name="sqlite_file:data/sqlite200/waveform_reco.db" accessMode="read" /> - <service name="sqlite_file:///cvmfs/faser.cern.ch/repo/sw/database/DBRelease/current/sqlite200/waveform_reco.db" accessMode="read" /> + <service name="sqlite_file:data/sqlite200/ALLP200.db" accessMode="read" /> + <service name="sqlite_file:///cvmfs/faser.cern.ch/repo/sw/database/DBRelease/current/sqlite200/ALLP200.db" accessMode="read" /> </logicalservice> </servicelist> diff --git a/DetectorDescription/GeoModel/FaserGeoModel/python/GeoModelInit.py b/DetectorDescription/GeoModel/FaserGeoModel/python/GeoModelInit.py index af1ed16dcb630fd08948f6a648d9deb6d46756e2..d17c8e39d932df7be5a7265d7b4c2403a0546430 100644 --- a/DetectorDescription/GeoModel/FaserGeoModel/python/GeoModelInit.py +++ b/DetectorDescription/GeoModel/FaserGeoModel/python/GeoModelInit.py @@ -95,7 +95,9 @@ def _setupGeoModel(): # Deal with SCT alignment conditions folders and algorithms - conddb.addFolderSplitOnline("SCT","/Tracker/Onl/Align","/Tracker/Align",className="AlignableTransformContainer") + #conddb.addFolderSplitOnline("SCT","/Tracker/Onl/Align","/Tracker/Align",className="AlignableTransformContainer") + print("Override Alignment dbname to OFLP200, fix this when alignment available in CONDBR3") + conddb.addFolder("/Tracker/Align", "SCT_OFL",className="AlignableTransformContainer",db="OFLP200") from AthenaCommon.AlgSequence import AthSequencer condSeq = AthSequencer("AthCondSeq") if not hasattr(condSeq, "FaserSCT_AlignCondAlg"): diff --git a/Scintillator/ScintDigiAlgs/python/ScintDigiAlgsConfig.py b/Scintillator/ScintDigiAlgs/python/ScintDigiAlgsConfig.py index 7436ada49b6448e4d1b12309c8faf8396fae9a1d..407ab913201a42845581e5543e1455b7b89c5867 100644 --- a/Scintillator/ScintDigiAlgs/python/ScintDigiAlgsConfig.py +++ b/Scintillator/ScintDigiAlgs/python/ScintDigiAlgsConfig.py @@ -36,11 +36,15 @@ def ScintWaveformDigitizationCfg(flags): if not flags.Input.isMC: return acc - if "TB" not in flags.GeoModel.FaserVersion: - acc.merge(ScintWaveformDigiCfg(flags, "TimingWaveformDigiAlg", "Trigger")) - acc.merge(ScintWaveformDigiCfg(flags, "VetoWaveformDigiAlg", "Veto")) - acc.merge(ScintWaveformDigiCfg(flags, "VetoNuWaveformDigiAlg", "VetoNu")) - acc.merge(ScintWaveformDigiCfg(flags, "PreshowerWaveformDigiAlg", "Preshower")) + if "TB" in flags.GeoModel.FaserVersion: + acc.merge(ScintWaveformDigiCfg(flags, "VetoWaveformDigiAlg", "Veto")) + acc.merge(ScintWaveformDigiCfg(flags, "PreshowerWaveformDigiAlg", "Preshower")) + else: + acc.merge(ScintWaveformDigiCfg(flags, "TriggerWaveformDigiAlg", "Trigger")) + acc.merge(ScintWaveformDigiCfg(flags, "VetoWaveformDigiAlg", "Veto")) + acc.merge(ScintWaveformDigiCfg(flags, "VetoNuWaveformDigiAlg", "VetoNu")) + acc.merge(ScintWaveformDigiCfg(flags, "PreshowerWaveformDigiAlg", "Preshower")) + acc.merge(ScintWaveformDigitizationOutputCfg(flags)) acc.merge(WaveformCableMappingCfg(flags)) return acc @@ -57,6 +61,11 @@ def ScintWaveformDigiCfg(flags, name="ScintWaveformDigiAlg", source="", **kwargs kwargs.setdefault("WaveformContainerKey", source+"Waveforms") digiAlg = CompFactory.ScintWaveformDigiAlg(name, **kwargs) + + if "TB" in flags.GeoModel.FaserVersion and source == "Veto": + # The testbeam counters were actually VetoNu, so use those parameters + source = "VetoNu" + digiAlg.CB_alpha = dict_CB_param[source]["CB_alpha"] digiAlg.CB_n = dict_CB_param[source]["CB_n"] digiAlg.CB_mean = dict_CB_param[source]["CB_mean"] diff --git a/Tracker/TrackerConditions/FaserSCT_ConditionsData/data/BField_DataConditions.py b/Tracker/TrackerConditions/FaserSCT_ConditionsData/data/BField_DataConditions.py new file mode 100755 index 0000000000000000000000000000000000000000..94846ee80dedb41dbc2354a6662873203aad9cb6 --- /dev/null +++ b/Tracker/TrackerConditions/FaserSCT_ConditionsData/data/BField_DataConditions.py @@ -0,0 +1,85 @@ +#!/bin/env python + +# Use this to add a field map to the CONDBR3 database for real data +# Copied the result from the OFLP200 DB +# Note that the testbeam turns off the field by setting scale = 0 +description = '<timeStamp>run-lumi</timeStamp><addrHeader><address_header clid="1238547719" service_type="71" /></addrHeader><typeName>CondAttrListCollection</typeName>' + +descriptionDCS = '<timeStamp>time</timeStamp><addrHeader><address_header service_type="71" clid="1238547719" /></addrHeader><typeName>CondAttrListCollection</typeName><cache>600</cache>' + +descriptionAlign = '<timeStamp>run-lumi</timeStamp><addrHeader><address_header service_type="256" clid="1170039409" /></addrHeader><typeName>AlignableTransformContainer</typeName>' + +import sys +from PyCool import cool, coral +from CoolConvUtilities.AtlCoolLib import indirectOpen + +dbSvc = cool.DatabaseSvcFactory.databaseService() +connectString = 'sqlite://;schema=ALLP200.db;dbname=CONDBR3' + +print('generating field database') +#dbSvc.dropDatabase( connectString ) +try: + # Open existing instead? + print('Try indirectOpen') + db = indirectOpen( connectString, readOnly=False ) +except Exception as e: + print(e) + print('Problem opening DB, create instead') + db = dbSvc.createDatabase( connectString ) + +glob = db.createFolderSet("/GLOBAL") +glob_bfield = db.createFolderSet("/GLOBAL/BField") + +glob_bfield.createTagRelation("GLOBAL-01", "GLOBAL-BField-01") +glob.createTagRelation("OFLCOND-FASER-01", "GLOBAL-01") + +glob_bfield.createTagRelation("GLOBAL-02", "GLOBAL-BField-02") +glob.createTagRelation("OFLCOND-FASER-02", "GLOBAL-02") + +glob_bfield.createTagRelation("GLOBAL-TB00", "GLOBAL-BField-TB00") +glob.createTagRelation("OFLCOND-FASER-TB00", "GLOBAL-TB00") + +mapSpec = cool.RecordSpecification() +mapSpec.extend( 'FieldType', cool.StorageType.String4k ) +mapSpec.extend( 'MapFileName', cool.StorageType.String4k ) + +mapRecord = cool.Record(mapSpec) +mapRecord['FieldType'] = "GlobalMap" +mapRecord['MapFileName'] = "file:MagneticFieldMaps/FaserFieldTable.root" + +mapFolderSpec = cool.FolderSpecification(cool.FolderVersioning.MULTI_VERSION, mapSpec) +mapFolder = db.createFolder('/GLOBAL/BField/Maps', mapFolderSpec, descriptionDCS, True ) + +mapFolder.storeObject( cool.ValidityKeyMin, cool.ValidityKeyMax, mapRecord, 1, "GLOBAL-BField-Maps-01", True ) +mapFolder.createTagRelation("GLOBAL-BField-01", "GLOBAL-BField-Maps-01") + +mapFolder.storeObject( cool.ValidityKeyMin, cool.ValidityKeyMax, mapRecord, 1, "GLOBAL-BField-Maps-02", True ) +mapFolder.createTagRelation("GLOBAL-BField-02", "GLOBAL-BField-Maps-02") + +mapFolder.storeObject( cool.ValidityKeyMin, cool.ValidityKeyMax, mapRecord, 1, "GLOBAL-BField-Maps-TB00", True ) +mapFolder.createTagRelation("GLOBAL-BField-TB00", "GLOBAL-BField-Maps-TB00") + +scaleSpec = cool.RecordSpecification() +scaleSpec.extend( 'value', cool.StorageType.Float ) + +scaleRecord = cool.Record(scaleSpec) +scaleRecord['value'] = 1.0 + +scaleFolderSpec = cool.FolderSpecification(cool.FolderVersioning.MULTI_VERSION, scaleSpec) +scaleFolder = db.createFolder('/GLOBAL/BField/Scales', scaleFolderSpec, descriptionDCS, True ) + +# Channel names don't seem to be handled properly by Athena +scaleFolder.createChannel( 1, "Dipole_Scale" ) +scaleFolder.storeObject( cool.ValidityKeyMin, cool.ValidityKeyMax, scaleRecord, 1, "GLOBAL-BField-Scale-01", True ) +scaleFolder.createTagRelation("GLOBAL-BField-01", "GLOBAL-BField-Scale-01") + + +scaleFolder.storeObject( cool.ValidityKeyMin, cool.ValidityKeyMax, scaleRecord, 1, "GLOBAL-BField-Scale-02", True ) +scaleFolder.createTagRelation("GLOBAL-BField-02", "GLOBAL-BField-Scale-02") + + +scaleRecord['value'] = 0.0 +scaleFolder.storeObject( cool.ValidityKeyMin, cool.ValidityKeyMax, scaleRecord, 1, "GLOBAL-BField-Scale-TB00", True ) +scaleFolder.createTagRelation("GLOBAL-BField-TB00", "GLOBAL-BField-Scale-TB00") + +db.closeDatabase() diff --git a/Tracker/TrackerConditions/FaserSCT_ConditionsTools/python/FaserSCT_DCSConditionsConfig.py b/Tracker/TrackerConditions/FaserSCT_ConditionsTools/python/FaserSCT_DCSConditionsConfig.py index cc1ddf6c99661d1fdbace11d74e7c3785e90be9e..42b71a58c0ba31f95f196a509134218e01e7e28c 100644 --- a/Tracker/TrackerConditions/FaserSCT_ConditionsTools/python/FaserSCT_DCSConditionsConfig.py +++ b/Tracker/TrackerConditions/FaserSCT_ConditionsTools/python/FaserSCT_DCSConditionsConfig.py @@ -29,7 +29,7 @@ def FaserSCT_DCSConditionsCfg(flags, name="TrackerSCT_DCSConditions", **kwargs): tempFolder = kwargs.get("tempFolder", "/SCT/DCS/MODTEMP") stateFolder = kwargs.get("stateFolder", "/SCT/DCS/CHANSTAT") if tool.ReadAllDBFolders == tool.ReturnHVTemp: - acc.merge(addFolders(flags, stateFolder, dbInstance, className="CondAttrListCollection")) + acc.merge(addFolders(flags, stateFolder, dbInstance, className="CondAttrListCollection",db="OFLP200")) # algo statArgs = { "name": name + "StatCondAlg", @@ -40,7 +40,7 @@ def FaserSCT_DCSConditionsCfg(flags, name="TrackerSCT_DCSConditions", **kwargs): statAlg = FaserSCT_DCSConditionsStatCondAlg(**statArgs) acc.addCondAlgo(statAlg) if tool.ReturnHVTemp: - acc.merge(addFolders(flags, [hvFolder, tempFolder], dbInstance, className="CondAttrListCollection")) + acc.merge(addFolders(flags, [hvFolder, tempFolder], dbInstance, className="CondAttrListCollection",db="OFLP200")) hvAlg = FaserSCT_DCSConditionsHVCondAlg(name=name + "HVCondAlg", ReadKey=hvFolder) acc.addCondAlgo(hvAlg) tempAlg = FaserSCT_DCSConditionsTempCondAlg(name=name + "TempCondAlg", ReadKey=tempFolder) diff --git a/Tracker/TrackerDetDescr/FaserSCT_GeoModel/python/FaserSCT_GeoModelConfig.py b/Tracker/TrackerDetDescr/FaserSCT_GeoModel/python/FaserSCT_GeoModelConfig.py index 26dff64f141ad9f22ff4ac430ef2fbdf98065f7e..038c8c38bb3c6d0daed962726f310867873a4c02 100644 --- a/Tracker/TrackerDetDescr/FaserSCT_GeoModel/python/FaserSCT_GeoModelConfig.py +++ b/Tracker/TrackerDetDescr/FaserSCT_GeoModel/python/FaserSCT_GeoModelConfig.py @@ -2,7 +2,7 @@ from AthenaConfiguration.ComponentFactory import CompFactory from AthenaConfiguration.Enums import ProductionStep -from IOVDbSvc.IOVDbSvcConfig import addFoldersSplitOnline +from IOVDbSvc.IOVDbSvcConfig import addFolders, addFoldersSplitOnline def FaserSCT_GeometryCfg( flags ): from FaserGeoModel.GeoModelConfig import GeoModelCfg @@ -33,10 +33,11 @@ def FaserSCT_GeometryCfg( flags ): # acc.merge(addFoldersSplitOnline(flags,"INDET","/Indet/Onl/AlignL3","/Indet/AlignL3",className="AlignableTransformContainer")) print("FaserSCT dynamic align flag is not supported!") else: + print("Override Alignment dbname to OFLP200, fix this when alignment available in CONDBR3") if flags.Common.Project != "AthSimulation" and (flags.Common.ProductionStep != ProductionStep.Simulation or flags.Overlay.DataOverlay): - acc.merge(addFoldersSplitOnline(flags,"SCT","/Tracker/Onl/Align","/Tracker/Align",className="AlignableTransformContainer")) + acc.merge(addFolders(flags,"/Tracker/Align", "SCT_OFL", className="AlignableTransformContainer", db="OFLP200")) else: - acc.merge(addFoldersSplitOnline(flags,"SCT","/Tracker/Onl/Align","/Tracker/Align")) + acc.merge(addFolders(flags, "/Tracker/Align", "SCT_OFL", db="OFLP200")) if flags.Common.Project != "AthSimulation": # Protection for AthSimulation builds if flags.Common.ProductionStep != ProductionStep.Simulation or flags.Overlay.DataOverlay: FaserSCT_AlignCondAlg = CompFactory.FaserSCT_AlignCondAlg diff --git a/Waveform/WaveRecAlgs/python/WaveRecAlgsConfig.py b/Waveform/WaveRecAlgs/python/WaveRecAlgsConfig.py index 414773bf9dc2e9b8140b33d81a80220c4288e4bf..b02a8b7d2b9b22193ff2a7d5e01efa36a89730cc 100644 --- a/Waveform/WaveRecAlgs/python/WaveRecAlgsConfig.py +++ b/Waveform/WaveRecAlgs/python/WaveRecAlgsConfig.py @@ -19,11 +19,13 @@ def WaveformReconstructionCfg(flags): if not flags.Input.isMC: acc.merge(WaveformClockRecCfg(flags, "ClockRecAlg")) - acc.merge(WaveformHitRecCfg(flags, "TriggerWaveformRecAlg", "Trigger")) + if "TB" not in flags.GeoModel.FaserVersion: + acc.merge(WaveformHitRecCfg(flags, "TriggerWaveformRecAlg", "Trigger")) + acc.merge(WaveformHitRecCfg(flags, "VetoNuWaveformRecAlg", "VetoNu")) + acc.merge(WaveformHitRecCfg(flags, "VetoWaveformRecAlg", "Veto")) acc.merge(WaveformHitRecCfg(flags, "PreshowerWaveformRecAlg", "Preshower")) acc.merge(WaveformHitRecCfg(flags, "CaloWaveformRecAlg", "Calo")) - acc.merge(WaveformHitRecCfg(flags, "VetoNuWaveformRecAlg", "VetoNu")) acc.merge(WaveformTimingCfg(flags)) diff --git a/Waveform/WaveformConditions/WaveCondUtils/scripts/makeTimingDB.py b/Waveform/WaveformConditions/WaveCondUtils/scripts/makeTimingDB.py index b3a1c64a23ad23ae70eaa000e3cbd76064bebfcd..57c3390c087b7f41850716d6ec24aa7d7e7044f6 100755 --- a/Waveform/WaveformConditions/WaveCondUtils/scripts/makeTimingDB.py +++ b/Waveform/WaveformConditions/WaveCondUtils/scripts/makeTimingDB.py @@ -5,7 +5,8 @@ # Can test results with # AtlCoolConsole.py "sqlite://;schema=waveform_reco.db;dbname=OFLP200" -filename = 'waveform_reco.db' +#filename = 'waveform_reco.db' +filename = 'ALLP200.db' # Nominal trigger time in ns nominal_data = { @@ -89,14 +90,21 @@ for run, data in offset_data.items(): from PyCool import cool +from CoolConvUtilities.AtlCoolLib import indirectOpen dbSvc = cool.DatabaseSvcFactory.databaseService() connectString = f'sqlite://;schema={filename};dbname=CONDBR3' -print('Creating database') +print('Opening database') -dbSvc.dropDatabase( connectString ) -db = dbSvc.createDatabase( connectString ) +# Try to open existing, but if not create new +try: + db = indirectOpen(connectString, readOnly=False) +except Exception as e: + print(e) + print("Couldn't open, try creating new") + #dbSvc.dropDatabase( connectString ) + db = dbSvc.createDatabase( connectString ) # Nominal trigger times nominalSpec = cool.RecordSpecification() @@ -176,8 +184,16 @@ for run, data in offset_data.items(): connectString = f'sqlite://;schema={filename};dbname=OFLP200' -dbSvc.dropDatabase( connectString ) -db = dbSvc.createDatabase( connectString ) +print('Opening database') + +# Try to open existing, but if not create new +try: + db = indirectOpen(connectString, readOnly=False) +except Exception as e: + print(e) + print("Couldn't open, try creating new") + #dbSvc.dropDatabase( connectString ) + db = dbSvc.createDatabase( connectString ) # Nominal trigger times nominalSpec = cool.RecordSpecification() diff --git a/Waveform/WaveformConditions/WaveformConditionsTools/python/WaveformTimingConfig.py b/Waveform/WaveformConditions/WaveformConditionsTools/python/WaveformTimingConfig.py index 3b95ed388208d7d4ab51a3d5621ab868d438c433..dec0c3858667fc6dee844f96f82afcf6d5427e47 100644 --- a/Waveform/WaveformConditions/WaveformConditionsTools/python/WaveformTimingConfig.py +++ b/Waveform/WaveformConditions/WaveformConditionsTools/python/WaveformTimingConfig.py @@ -21,12 +21,15 @@ def WaveformTimingCfg(flags, **kwargs): # tool = kwargs.get("WaveformTimingTool", WaveformTimingTool(flags)) # Probably need to figure this out! dbInstance = kwargs.get("dbInstance", "TRIGGER_OFL") - if flags.Input.isMC: - dbname = "OFLP200" - else: - dbname = "CONDBR3" + # This is now set up globally, don't need this here + #if flags.Input.isMC: + # dbname = "OFLP200" + #else: + # dbname = "CONDBR3" - acc.merge(addFolders(flags, "/WAVE/DAQ/Timing", dbInstance, className="AthenaAttributeList", db=dbname)) - acc.merge(addFolders(flags, "/WAVE/DAQ/TimingOffset", dbInstance, className="CondAttrListCollection", db=dbname)) + #acc.merge(addFolders(flags, "/WAVE/DAQ/Timing", dbInstance, className="AthenaAttributeList", db=dbname)) + #acc.merge(addFolders(flags, "/WAVE/DAQ/TimingOffset", dbInstance, className="CondAttrListCollection", db=dbname)) + acc.merge(addFolders(flags, "/WAVE/DAQ/Timing", dbInstance, className="AthenaAttributeList")) + acc.merge(addFolders(flags, "/WAVE/DAQ/TimingOffset", dbInstance, className="CondAttrListCollection")) return acc