# jeffersonlab/simc_gfortran architecture

> Architecture diagram of the GitHub repository jeffersonlab/simc_gfortran, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jeffersonlab/simc_gfortran
- Repository: https://github.com/jeffersonlab/simc_gfortran

## Overview

SIMC is Hall C/A’s FORTRAN Monte Carlo for coincidence-reaction studies. The principal workflow is to configure a reaction, generate events with physics and spectrometer effects, and write simulation output; separate utilities can convert that output to PAW ntuples or ROOT trees, and hcana reconstruction can recompute kinematics from a ROOT tree. README-documented capabilities include elastic, exclusive, semi-inclusive and rho reactions, plus radiative effects, energy loss, scattering, decay and spectrometer optics. Several implementation links are not shown because the sampled source does not establish their callers.

Main entry points: [`simc.f`](https://github.com/jeffersonlab/simc_gfortran/blob/master/simc.f) (SIMC driver), [`infiles`](https://github.com/jeffersonlab/simc_gfortran/tree/master/infiles) (Reaction inputs), [`event.f`](https://github.com/jeffersonlab/simc_gfortran/blob/master/event.f) (Event generation), [`util/ntuple`](https://github.com/jeffersonlab/simc_gfortran/tree/master/util/ntuple) (PAW converter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_simulation["Simulation"]
  node_inputs["Reaction inputs"]
  node_simc["SIMC driver<br/>[simc.f]"]
  node_events["Event generation<br/>[event.f]"]
end

subgraph group_physics["Physics models"]
  node_elastic["Elastic models<br/>[physics_proton.f]"]
  node_pion["Pion models<br/>[physics_pion.f]"]
  node_kaon["Kaon models<br/>[physics_kaon.f]"]
  node_semi["Semi-inclusive models<br/>[semi_physics.f]"]
  node_rho["Rho models<br/>[rho_physics.f]"]
  node_target["Target effects<br/>[target.f]"]
  node_radiation["Radiative effects<br/>[radc.f]"]
  node_energy["Energy loss<br/>[enerloss_new.f]"]
  node_scattering["Multiple scattering<br/>[musc.f]"]
  node_decay["Particle decay<br/>[rho_decay.f]"]
end

subgraph group_detectors["Spectrometers"]
  node_hms["HMS transport"]
  node_shms["SHMS transport"]
  node_sos["SOS transport"]
  node_hrs["HRS transport"]
  node_calorimeter["BigCal response"]
end

subgraph group_analysis["Output and analysis"]
  node_result["Simulation output"]
  node_ntuple["PAW converter"]
  node_rootwriter["ROOT converter"]
  node_reconstruction["Kinematics reconstruction"]
end

node_researcher(("Researcher"))

node_researcher -->|"configures"| node_inputs
node_researcher -->|"runs"| node_simc
node_inputs -->|"configures"| node_simc
node_simc -->|"generates"| node_events
node_simc -->|"writes"| node_result
node_simc -.->|"converts output"| node_ntuple
node_simc -.->|"converts output"| node_rootwriter
node_result -.->|"reads ROOT tree"| node_reconstruction

click node_inputs "https://github.com/jeffersonlab/simc_gfortran/tree/master/infiles"
click node_simc "https://github.com/jeffersonlab/simc_gfortran/blob/master/simc.f"
click node_events "https://github.com/jeffersonlab/simc_gfortran/blob/master/event.f"
click node_elastic "https://github.com/jeffersonlab/simc_gfortran/blob/master/physics_proton.f"
click node_pion "https://github.com/jeffersonlab/simc_gfortran/blob/master/physics_pion.f"
click node_kaon "https://github.com/jeffersonlab/simc_gfortran/blob/master/physics_kaon.f"
click node_semi "https://github.com/jeffersonlab/simc_gfortran/blob/master/semi_physics.f"
click node_rho "https://github.com/jeffersonlab/simc_gfortran/blob/master/rho_physics.f"
click node_target "https://github.com/jeffersonlab/simc_gfortran/blob/master/target.f"
click node_radiation "https://github.com/jeffersonlab/simc_gfortran/blob/master/radc.f"
click node_energy "https://github.com/jeffersonlab/simc_gfortran/blob/master/enerloss_new.f"
click node_scattering "https://github.com/jeffersonlab/simc_gfortran/blob/master/shared/musc.f"
click node_decay "https://github.com/jeffersonlab/simc_gfortran/blob/master/rho_decay.f"
click node_hms "https://github.com/jeffersonlab/simc_gfortran/tree/master/hms"
click node_shms "https://github.com/jeffersonlab/simc_gfortran/tree/master/shms"
click node_sos "https://github.com/jeffersonlab/simc_gfortran/tree/master/sos"
click node_hrs "https://github.com/jeffersonlab/simc_gfortran/tree/master/hrsl"
click node_calorimeter "https://github.com/jeffersonlab/simc_gfortran/tree/master/calo"
click node_ntuple "https://github.com/jeffersonlab/simc_gfortran/tree/master/util/ntuple"
click node_rootwriter "https://github.com/jeffersonlab/simc_gfortran/tree/master/util/root_tree"
click node_reconstruction "https://github.com/jeffersonlab/simc_gfortran/tree/master/util/recon_hcana"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_inputs,node_simc,node_events toneBlue
class node_elastic,node_pion,node_kaon,node_semi,node_rho,node_target,node_radiation,node_energy,node_scattering,node_decay toneAmber
class node_hms,node_shms,node_sos,node_hrs,node_calorimeter toneMint
class node_result,node_ntuple,node_rootwriter,node_reconstruction toneRose
class node_researcher toneIndigo
```

## Components

### Simulation

- [Reaction inputs](https://github.com/jeffersonlab/simc_gfortran/tree/master/infiles): `infiles`
- [SIMC driver](https://github.com/jeffersonlab/simc_gfortran/blob/master/simc.f): `simc.f`
- [Event generation](https://github.com/jeffersonlab/simc_gfortran/blob/master/event.f): `event.f`

### Physics models

- [Elastic models](https://github.com/jeffersonlab/simc_gfortran/blob/master/physics_proton.f): `physics_proton.f`
- [Pion models](https://github.com/jeffersonlab/simc_gfortran/blob/master/physics_pion.f): `physics_pion.f`
- [Kaon models](https://github.com/jeffersonlab/simc_gfortran/blob/master/physics_kaon.f): `physics_kaon.f`
- [Semi-inclusive models](https://github.com/jeffersonlab/simc_gfortran/blob/master/semi_physics.f): `semi_physics.f`
- [Rho models](https://github.com/jeffersonlab/simc_gfortran/blob/master/rho_physics.f): `rho_physics.f`
- [Target effects](https://github.com/jeffersonlab/simc_gfortran/blob/master/target.f): `target.f`
- [Radiative effects](https://github.com/jeffersonlab/simc_gfortran/blob/master/radc.f): `radc.f`
- [Energy loss](https://github.com/jeffersonlab/simc_gfortran/blob/master/enerloss_new.f): `enerloss_new.f`
- [Multiple scattering](https://github.com/jeffersonlab/simc_gfortran/blob/master/shared/musc.f): `shared/musc.f`
- [Particle decay](https://github.com/jeffersonlab/simc_gfortran/blob/master/rho_decay.f): `rho_decay.f`

### Spectrometers

- [HMS transport](https://github.com/jeffersonlab/simc_gfortran/tree/master/hms): `hms`
- [SHMS transport](https://github.com/jeffersonlab/simc_gfortran/tree/master/shms): `shms`
- [SOS transport](https://github.com/jeffersonlab/simc_gfortran/tree/master/sos): `sos`
- [HRS transport](https://github.com/jeffersonlab/simc_gfortran/tree/master/hrsl): `hrsl`
- [BigCal response](https://github.com/jeffersonlab/simc_gfortran/tree/master/calo): `calo`

### Output and analysis

- **Simulation output**
- [PAW converter](https://github.com/jeffersonlab/simc_gfortran/tree/master/util/ntuple): `util/ntuple`
- [ROOT converter](https://github.com/jeffersonlab/simc_gfortran/tree/master/util/root_tree): `util/root_tree`
- [Kinematics reconstruction](https://github.com/jeffersonlab/simc_gfortran/tree/master/util/recon_hcana): `util/recon_hcana`

### Other components

- **Researcher**

## Connections

- Researcher → Reaction inputs: configures
- Researcher → SIMC driver: runs
- Reaction inputs → SIMC driver: configures
- SIMC driver → Event generation: generates
- SIMC driver → Simulation output: writes
- SIMC driver → PAW converter: converts output
- SIMC driver → ROOT converter: converts output
- Simulation output → Kinematics reconstruction: reads ROOT tree
