Skip to content
Snippets Groups Projects
Commit fd70f81c authored by Eric Torrence's avatar Eric Torrence
Browse files

Production Reco Scripts

parent 1e8d4433
No related branches found
No related tags found
No related merge requests found
################################################################################
# Package: Reconstruction
################################################################################
# Declare the package name:
atlas_subdir( Reconstruction )
# Component(s) in the package:
#atlas_add_component( GeoModelTest
# src/GeoModelTestAlg.cxx
# src/components/GeoModelTest_entries.cxx
# INCLUDE_DIRS ${GEOMODEL_INCLUDE_DIRS}
# LINK_LIBRARIES ${GEOMODEL_LIBRARIES} AthenaBaseComps GeoModelFaserUtilities ScintReadoutGeometry TrackerReadoutGeometry MagFieldInterfaces MagFieldElements MagFieldConditions )
#atlas_add_test( ReconstructionTest
# SCRIPT python ${CMAKE_CURRENT_SOURCE_DIR}/python/GeoModelTestConfig.py
# PROPERTIES WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
# PROPERTIES TIMEOUT 300 )
# Install files from the package:
#atlas_install_joboptions( share/*.py )
#atlas_install_python_modules( python/*.py )
atlas_install_scripts( scripts/*.sh scripts/*.py )
This package stores the production reconstruction scripts.
The following scripts run production reconstruction jobs:
* `faser_reco.py` - this is the python script for the main reconstruction job.
* `submit_faser_reco.sh` - bash script to set up the environment and run the faser_reco job. This can be called from condor or other batch scheduling systems.
Production reco is intended to be run from a specific git tag.
To see the available tags, use
```
git tag -l "reco/*"
```
and to check out a tag simply use the tag name in the checkout command
```
git checkout reco/r0001
```
To make a production reco tag, the easiest is to just tag a commit
```
git tag -a reco/r0001 9fceb02 -m "tag message"
```
This needs to be pushed to the upstream master
```
git push origin reco/r0001
git push upstream reco/r0001
```
If you need to delete a tag from the repository
```
git push origin --delete reco/r0001
```
To checkout a branch based on a tag (to be able to make fixes):
```
git checkout -b mybranch reco/r0001
```
To find the updated files between two tags, and the changes in those files
```
git diff tag1 tag2 --stat
git diff tag1 tag2 -- filename
```
#!/usr/bin/env python
#
# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
# Run with:
# ./faser_reco.py filepath [runtype]
#
# 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 - optional flag to specify the data type (TI12Data or TestBeamData).
# In a normal file system location, this will be extracted from the directory name,
# but runtype will override this assignment.
#
import sys
import argparse
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("-r", "--reco", default="",
help="Specify reco tag (to append to output filename)")
parser.add_argument("-n", "--nevents", type=int, default=-1,
help="Specify number of events to process (default: all)")
args = parser.parse_args()
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 len(filepath.parts) < 3:
print("Can't determine run type from path - specify on command line instead")
sys.exit(-1)
runtype = filepath.parts[-3]
print(f"Starting reconstruction of {filepath.name} with type {runtype}")
if args.nevents > 0:
print(f"Reconstructing {args.nevents} events by command-line option")
# Start reconstruction
from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
from AthenaConfiguration.ComponentFactory import CompFactory
from AthenaCommon.Constants import VERBOSE, INFO
from AthenaCommon.Configurable import Configurable
from CalypsoConfiguration.AllConfigFlags import ConfigFlags
Configurable.configurableRun3Behavior = True
# Flags for this job
ConfigFlags.Input.isMC = False # Needed to bypass autoconfig
ConfigFlags.IOVDb.DatabaseInstance = "OFLP200" # Use MC conditions for now
ConfigFlags.Input.ProjectName = "data20"
ConfigFlags.GeoModel.Align.Dynamic = False
# TI12 Cosmics geometry
if runtype == "TI12Data":
ConfigFlags.GeoModel.FaserVersion = "FASER-01"
ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-01"
# Testbeam setup
elif runtype == "TestBeamData":
ConfigFlags.GeoModel.FaserVersion = "FASER-TB00"
ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-02"
else:
print("Invalid run type found:", runtype)
print("Specify correct type 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
if len(args.reco) > 0:
filestem += f"-{args.reco}"
ConfigFlags.addFlag("Output.xAODFileName", f"{filestem}-xAOD.root")
ConfigFlags.Output.ESDFileName = f"{filestem}-ESD.root"
#
# Play around with this?
# ConfigFlags.Concurrency.NumThreads = 2
# ConfigFlags.Concurrency.NumConcurrentEvents = 2
ConfigFlags.lock()
#
# Configure components
from CalypsoConfiguration.MainServicesConfig import MainServicesCfg
from AthenaPoolCnvSvc.PoolWriteConfig import PoolWriteCfg
acc = MainServicesCfg(ConfigFlags)
acc.merge(PoolWriteCfg(ConfigFlags))
#
# Set up RAW data access
from FaserByteStreamCnvSvc.FaserByteStreamCnvSvcConfig import FaserByteStreamCnvSvcCfg
acc.merge(FaserByteStreamCnvSvcCfg(ConfigFlags))
#
# Needed, or move to MainServicesCfg?
from FaserGeoModel.FaserGeoModelConfig import FaserGeometryCfg
acc.merge(FaserGeometryCfg(ConfigFlags))
# Set up algorithms
from WaveRecAlgs.WaveRecAlgsConfig import WaveformReconstructionCfg
acc.merge(WaveformReconstructionCfg(ConfigFlags))
# Tracker clusters
from TrackerPrepRawDataFormation.TrackerPrepRawDataFormationConfig import FaserSCT_ClusterizationCfg
acc.merge(FaserSCT_ClusterizationCfg(ConfigFlags))
# ... try 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#*"
#, "Tracker::SCT_SpacePointContainer#*"
#, "Tracker::SCT_SpacePointOverlapCollection#*"
, "TrackCollection#*"
]
acc.merge(OutputStreamCfg(ConfigFlags, "xAOD", itemList))
# Waveform reconstruction
from WaveRecAlgs.WaveRecAlgsConfig import WaveformReconstructionOutputCfg
acc.merge(WaveformReconstructionOutputCfg(ConfigFlags))
# Check what we have
print( "Writing out xAOD objects:" )
print( acc.getEventAlgo("OutputStreamxAOD").ItemList )
# Configure verbosity
# ConfigFlags.dump()
# logging.getLogger('forcomps').setLevel(VERBOSE)
# acc.foreach_component("*").OutputLevel = VERBOSE
acc.foreach_component("*").OutputLevel = INFO
acc.foreach_component("*ClassID*").OutputLevel = INFO
# log.setLevel(VERBOSE)
#acc.getService("FaserByteStreamInputSvc").DumpFlag = True
#acc.getService("FaserEventSelector").OutputLevel = VERBOSE
#acc.getService("FaserByteStreamInputSvc").OutputLevel = VERBOSE
#acc.getService("FaserByteStreamCnvSvc").OutputLevel = VERBOSE
#acc.getService("FaserByteStreamAddressProviderSvc").OutputLevel = VERBOSE
acc.getService("MessageSvc").Format = "% F%40W%S%7W%R%T %0W%M"
# Execute and finish
sys.exit(int(acc.run(maxEvents=args.nevents).isFailure()))
#!/bin/bash
# Used with a condor file to submit to vanilla universe
#
# Usage:
# submit_faser_reco.sh file_path [release_directory] [working_directory]
#
# file_path - full file name (with path)
# release_directory - optional path to release install directory (default pwd)
# working_directory - optional path to output directory location (default pwd)
#
# The release directory must already be set up
# (so an unqualified asetup can set up the release properly)
#
# Script will use git describe to find the release tag.
# If this matches reco/r???? it will be passed to the reco job
#
#----------------------------------------
#
# Parse command-line options
file_path=${1}
release_directory=${2}
working_directory=${3}
#
# Set defaults if arguments aren't provided
if [ -z "$file_path" ]
then
echo "No file_path specified!"
exit 1
fi
#
if [ -z "$release_directory" ]
then
release_directory=`pwd`
fi
#
if [ -z "$working_directory" ]
then
working_directory=`pwd`
fi
starting_directory=`pwd`
#
# Now extract the run number and file stem
#
# First, get the filename
file_name=$(basename "$file_path")
#
# Now split based on '.' to get stem
defaultIFS=$IFS
IFS='.'
read file_stem ext <<< "$file_name"
#
# Finally extract the run number
IFS='-'
# Read the split words into an array based on delimiter
read faser type run_number segment <<< "$file_stem"
#
# Set the IFS delimeter back or else echo doesn't work...
IFS=$defaultIFS
#
# Make output directory if needed
output_directory="$working_directory/Run-$run_number"
mkdir -p "$output_directory"
#
# This magic redirects everything in this script to our log file
exec >& "$output_directory/$file_stem.log"
echo `date` - $HOSTNAME
echo "File: $file_name"
echo "Release: $release_directory"
echo "Output: $output_directory"
echo "Starting: $starting_directory"
#
# Set up the release (do this automatically)?
export ATLAS_LOCAL_ROOT_BASE=/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase
source $ATLAS_LOCAL_ROOT_BASE/user/atlasLocalSetup.sh
#
# Try automatic
# Always go back to the starting directory in case paths are relative
cd "$starting_directory"
cd "$release_directory"
asetup
source build/x8*/setup.sh
#
# Do this by hand
# asetup --input="$release_directory/calypso/asetup.faser" Athena,22.0.40
# source "$release_directory/build/x8*/setup.sh"
#
#
# Try to find a release tag
cd calypso
recotag=`git describe`
if [[ "$recotag" == "reco/r"???? ]]; then
rtag=`echo "$recotag" | cut -c 6-11`
echo "Found reco tag: $rtag"
fi
#
# Move to the run directory
cd "$starting_directory"
cd "$output_directory"
#
# Remove any previous directory if it exists
if [[ -e "$file_stem" ]]; then
echo "Remove previous directory $file_stem"
rm -rf "$file_stem"
fi
#
# Make run directory
mkdir "$file_stem"
cd "$file_stem"
#
# Run job
if [ -z "$rtag" ]
then
faser_reco.py "$file_path"
else
faser_reco.py "--reco=$rtag" "$file_path"
fi
#
# Print out ending time
date
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