Project Structure¶
This page provides a map of the codebase for developers who need to understand or modify the framework internals.
Directory Layout¶
OneStopCoffea/
+-- analyzer/ # The framework code
| +-- core/ # Core runtime and interfaces
| | +-- analysis.py # Analysis loading (loadAnalysis)
| | +-- analysis_modules.py # Module base classes and lifecycle
| | +-- analyzer.py # Analyzer: pipeline execution engine
| | +-- columns.py # Column, TrackedColumns, provenance
| | +-- datasets.py # Dataset and sample definitions
| | +-- era.py # Era definitions
| | +-- event_collection.py # FileSet, SourceDescription
| | +-- executors/ # Executor implementations
| | | +-- executor.py # Base Executor class
| | | +-- immediate_exec.py # Single-process executor
| | | +-- dask_exec.py # Dask and Condor executors
| | | \-- premade_executors.py # Pre-configured executor instances
| | +-- param_specs.py # ParameterSpec for dynamic parameters
| | +-- results.py # Result types and serialization
| | +-- run_builders.py # RunBuilder strategies
| | +-- running.py # High-level run/patch orchestration
| | +-- serialization.py # cattrs converter setup
| | \-- caching.py # Disk cache configuration
| |
| +-- modules/ # Analysis modules
| | +-- common/ # Built-in modules
| | | +-- jets.py # Jet filtering, corrections, combinatorics
| | | +-- selection.py # SelectOnColumns, NObjFilter
| | | +-- histogram_builder.py # HistogramBuilder, SimpleHistogram
| | | +-- electrons.py # Electron selection
| | | +-- muons.py # Muon selection
| | | +-- bjet_sf.py # B-jet scale factors
| | | +-- categories.py # Category axis definitions
| | | +-- hlt_selection.py # Trigger selection
| | | +-- event_level_corrections.py # Pileup, prefiring, etc.
| | | +-- skimming.py # Event skimming to files
| | | \-- ...
| | \-- utils/ # Module utilities
| |
| +-- postprocessing/ # Postprocessing framework
| | +-- running.py # Postprocessor loading and execution
| | +-- processors.py # BasePostprocessor
| | +-- basic_histograms.py # Histogram1D, RatioPlot, etc.
| | +-- cutflows.py # CutflowTable, PlotSelectionFlow
| | +-- combine.py # CombineDatacard
| | +-- aggregate_plots.py # Significance2D, etc.
| | +-- grouping.py # GroupBuilder
| | +-- style.py # StyleSet, StyleRule, CMS colors
| | +-- transforms/ # Transform classes
| | | +-- registry.py # Transform base classes
| | | +-- hist_transforms.py # Histogram transforms
| | | \-- data_transforms.py # Data transforms
| | \-- plots/ # Plotting functions
| | +-- plots_1d.py # 1D plot rendering
| | +-- plots_2d.py # 2D plot rendering
| | \-- common.py # PlotConfiguration
| |
| +-- cli/ # Command-line interface
| | \-- cli.py # Click commands
| |
| +-- utils/ # Shared utilities
| | +-- querying.py # Pattern matching system
| | +-- structure_tools.py # Tree operations, metadata tools
| | \-- yamlload.py # Jinja2 + YAML loading
| |
| +-- configuration.py # Global configuration (CONFIG)
| \-- logging.py # Logging setup
|
+-- analyzer_resources/ # Data files
| +-- datasets/ # Dataset YAML definitions
| +-- eras/ # Era YAML definitions
| \-- static/ # Fonts, styles
|
+-- configurations/ # Example analysis configurations
| +-- example.yaml
| \-- single_stop/ # Single stop analysis configs
|
+-- docs/ # Documentation
\-- osca # Wrapper script
Key Files¶
The most important files for understanding the framework:
File |
Role |
|---|---|
|
Module base class, lifecycle, |
|
|
|
Pipeline execution, caching logic, multi-run orchestration |
|
All result types, serialization, |
|
|
|
|
|
Pattern matching DSL ( |
|
|
|
All CLI commands |
The Serialization System¶
The framework uses cattrs for converting between YAML/dict representations and Python objects.
This is the mechanism that makes the configuration-driven approach work.
A central Converter is set up in core/serialization.py, with hooks registered for:
Tagged unions: Module classes are resolved by
module_name, executors byexecutor_name, run builders bystrategy_name, transforms byname, and postprocessors byname.Custom types:
Column,Pattern,MetadataExpr,SampleType, etc., have custom structure/unstructure hooks.Subclass resolution:
include_subclassesfromcattrs.strategiesautomatically discovers all subclasses of base types.
This is why importing module files (via extra_module_paths) before parsing the configuration is essential – the subclass list is built at import time.
Library Dependencies¶
Library |
Purpose |
|---|---|
|
Reading NanoAOD data and manipulating columnar event data. |
|
Distributed execution. |
|
Dataclass definitions and YAML deserialization. |
|
CLI framework. |
|
Histogram objects. |
|
CMS-style plotting. |
|
Compression for result files. |
|
Disk-based caching for dataset and provenance lookups. |
|
Pretty printing and terminal UIs. |
|
Template rendering for configuration files. |