# provakar1994/bbcal_replay architecture

> Architecture diagram of the GitHub repository provakar1994/bbcal_replay, 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/provakar1994/bbcal_replay
- Repository: https://github.com/provakar1994/bbcal_replay

## Overview

BBCal_replay is a ROOT-macro toolkit for replaying detector data and calibrating or inspecting the Shower (SH), PreShower (PS), combined calorimeter, and HCal. The principal workflow is raw run replay into ROOT event data, followed by cosmic or beam-based calibration and production of gain/HV outputs. The tree and README document further analysis capabilities; source excerpts are limited, so links between unsampled macros are not inferred.

Main entry points: [`replay/replay_BBCal.C`](https://github.com/provakar1994/bbcal_replay/blob/master/replay/replay_BBCal.C) (BBCal replay), [`replay/replay_gmn_PD.C`](https://github.com/provakar1994/bbcal_replay/blob/master/replay/replay_gmn_PD.C) (GMn replay), [`macros/Shower_macros`](https://github.com/provakar1994/bbcal_replay/tree/master/macros/Shower_macros) (SH cosmic calibration), [`macros/PreShower_macros`](https://github.com/provakar1994/bbcal_replay/tree/master/macros/PreShower_macros) (PS cosmic calibration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_replay["Replay"]
  node_bbc_replay["BBCal replay<br/>[replay_BBCal.C]"]
  node_gmn_replay["GMn replay<br/>[replay_gmn_PD.C]"]
end

subgraph group_calibration["Calibration"]
  node_cosmic_sh["SH cosmic calibration"]
  node_cosmic_ps["PS cosmic calibration"]
  node_cosmic_gain["Cosmic ADC gain"]
  node_hv_sh["SH HV setting"]
  node_hv_ps["PS HV setting"]
  node_beam_cal["Beam energy calibration"]
end

subgraph group_analysis["Analysis"]
  node_combined_analysis["Combined analysis"]
  node_event_display["Event display<br/>[bbcal_clustD.C]"]
end

subgraph group_detectors["Detector-specific"]
  node_sh_analysis["SH analysis"]
  node_ps_analysis["PS analysis"]
  node_hcal_cal["HCal calibration<br/>[hcal_eng_cal_PD.C]"]
end

node_operator(("Operator"))
node_raw[("CODA runs")]
node_event_data[("ROOT event data")]
node_hv_output["HV set files"]
node_gain_output["Gain coefficients"]
node_plots["Histograms and plots"]

node_operator -->|"runs replay"| node_bbc_replay
node_operator -->|"runs replay"| node_gmn_replay
node_raw -->|"reads segments"| node_bbc_replay
node_raw -->|"reads segments"| node_gmn_replay
node_bbc_replay -->|"writes ROOT"| node_event_data
node_gmn_replay -->|"writes ROOT"| node_event_data
node_operator -->|"runs analysis"| node_cosmic_sh
node_operator -->|"runs analysis"| node_cosmic_ps
node_operator -->|"runs analysis"| node_cosmic_gain
node_event_data -->|"reads events"| node_cosmic_sh
node_event_data -->|"reads events"| node_cosmic_ps
node_event_data -->|"reads events"| node_cosmic_gain
node_cosmic_sh -->|"supplies calibration"| node_hv_sh
node_cosmic_ps -->|"supplies calibration"| node_hv_ps
node_hv_sh -->|"writes settings"| node_hv_output
node_hv_ps -->|"writes settings"| node_hv_output
node_operator -->|"runs calibration"| node_beam_cal
node_event_data -->|"reads events"| node_beam_cal
node_beam_cal -->|"writes coefficients"| node_gain_output
node_operator -->|"runs macros"| node_sh_analysis
node_operator -->|"runs macros"| node_ps_analysis
node_operator -->|"runs macros"| node_combined_analysis
node_operator -->|"opens events"| node_event_display
node_event_data -->|"reads tree"| node_event_display
node_operator -->|"runs calibration"| node_hcal_cal
node_event_data -->|"reads events"| node_hcal_cal
node_sh_analysis -->|"produces plots"| node_plots
node_ps_analysis -->|"produces plots"| node_plots
node_combined_analysis -->|"produces plots"| node_plots
node_event_display -->|"renders display"| node_plots
node_hcal_cal -->|"writes histograms"| node_plots

click node_bbc_replay "https://github.com/provakar1994/bbcal_replay/blob/master/replay/replay_BBCal.C"
click node_gmn_replay "https://github.com/provakar1994/bbcal_replay/blob/master/replay/replay_gmn_PD.C"
click node_cosmic_sh "https://github.com/provakar1994/bbcal_replay/tree/master/macros/Shower_macros"
click node_cosmic_ps "https://github.com/provakar1994/bbcal_replay/tree/master/macros/PreShower_macros"
click node_cosmic_gain "https://github.com/provakar1994/bbcal_replay/blob/master/macros/Combined_macros/calculate_adcGain_cos.C"
click node_hv_sh "https://github.com/provakar1994/bbcal_replay/tree/master/macros/Shower_macros"
click node_hv_ps "https://github.com/provakar1994/bbcal_replay/tree/master/macros/PreShower_macros"
click node_beam_cal "https://github.com/provakar1994/bbcal_replay/blob/master/macros/Combined_macros/bbcal_eng_calib_w_h2.C"
click node_sh_analysis "https://github.com/provakar1994/bbcal_replay/tree/master/macros/Shower_macros"
click node_ps_analysis "https://github.com/provakar1994/bbcal_replay/tree/master/macros/PreShower_macros"
click node_combined_analysis "https://github.com/provakar1994/bbcal_replay/tree/master/macros/Combined_macros"
click node_event_display "https://github.com/provakar1994/bbcal_replay/blob/master/macros/Event_disp_macros/bbcal_clustD.C"
click node_hcal_cal "https://github.com/provakar1994/bbcal_replay/blob/master/macros/hcal/hcal_eng_cal_PD.C"

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_bbc_replay,node_gmn_replay toneBlue
class node_cosmic_sh,node_cosmic_ps,node_cosmic_gain,node_hv_sh,node_hv_ps,node_beam_cal,node_raw,node_event_data toneAmber
class node_combined_analysis,node_event_display toneMint
class node_sh_analysis,node_ps_analysis,node_hcal_cal toneRose
class node_operator,node_hv_output,node_gain_output,node_plots toneIndigo
```

## Components

### Replay

- [BBCal replay](https://github.com/provakar1994/bbcal_replay/blob/master/replay/replay_BBCal.C): `replay/replay_BBCal.C`
- [GMn replay](https://github.com/provakar1994/bbcal_replay/blob/master/replay/replay_gmn_PD.C): `replay/replay_gmn_PD.C`

### Calibration

- [SH cosmic calibration](https://github.com/provakar1994/bbcal_replay/tree/master/macros/Shower_macros): `macros/Shower_macros`
- [PS cosmic calibration](https://github.com/provakar1994/bbcal_replay/tree/master/macros/PreShower_macros): `macros/PreShower_macros`
- [Cosmic ADC gain](https://github.com/provakar1994/bbcal_replay/blob/master/macros/Combined_macros/calculate_adcGain_cos.C): `macros/Combined_macros/calculate_adcGain_cos.C`
- [SH HV setting](https://github.com/provakar1994/bbcal_replay/tree/master/macros/Shower_macros): `macros/Shower_macros`
- [PS HV setting](https://github.com/provakar1994/bbcal_replay/tree/master/macros/PreShower_macros): `macros/PreShower_macros`
- [Beam energy calibration](https://github.com/provakar1994/bbcal_replay/blob/master/macros/Combined_macros/bbcal_eng_calib_w_h2.C): `macros/Combined_macros/bbcal_eng_calib_w_h2.C`

### Analysis

- [Combined analysis](https://github.com/provakar1994/bbcal_replay/tree/master/macros/Combined_macros): `macros/Combined_macros`
- [Event display](https://github.com/provakar1994/bbcal_replay/blob/master/macros/Event_disp_macros/bbcal_clustD.C): `macros/Event_disp_macros/bbcal_clustD.C`

### Detector-specific

- [SH analysis](https://github.com/provakar1994/bbcal_replay/tree/master/macros/Shower_macros): `macros/Shower_macros`
- [PS analysis](https://github.com/provakar1994/bbcal_replay/tree/master/macros/PreShower_macros): `macros/PreShower_macros`
- [HCal calibration](https://github.com/provakar1994/bbcal_replay/blob/master/macros/hcal/hcal_eng_cal_PD.C): `macros/hcal/hcal_eng_cal_PD.C`

### Other components

- **Operator**
- **CODA runs**
- **ROOT event data**
- **HV set files**
- **Gain coefficients**
- **Histograms and plots**

## Connections

- Operator → BBCal replay: runs replay
- Operator → GMn replay: runs replay
- CODA runs → BBCal replay: reads segments
- CODA runs → GMn replay: reads segments
- BBCal replay → ROOT event data: writes ROOT
- GMn replay → ROOT event data: writes ROOT
- Operator → SH cosmic calibration: runs analysis
- Operator → PS cosmic calibration: runs analysis
- Operator → Cosmic ADC gain: runs analysis
- ROOT event data → SH cosmic calibration: reads events
- ROOT event data → PS cosmic calibration: reads events
- ROOT event data → Cosmic ADC gain: reads events
- SH cosmic calibration → SH HV setting: supplies calibration
- PS cosmic calibration → PS HV setting: supplies calibration
- SH HV setting → HV set files: writes settings
- PS HV setting → HV set files: writes settings
- Operator → Beam energy calibration: runs calibration
- ROOT event data → Beam energy calibration: reads events
- Beam energy calibration → Gain coefficients: writes coefficients
- Operator → SH analysis: runs macros
- Operator → PS analysis: runs macros
- Operator → Combined analysis: runs macros
- Operator → Event display: opens events
- ROOT event data → Event display: reads tree
- Operator → HCal calibration: runs calibration
- ROOT event data → HCal calibration: reads events
- SH analysis → Histograms and plots: produces plots
- PS analysis → Histograms and plots: produces plots
- Combined analysis → Histograms and plots: produces plots
- Event display → Histograms and plots: renders display
- HCal calibration → Histograms and plots: writes histograms
