Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Python
__pycache__/
*.pyc

# C++ build artifacts
*.o
*.out
*.exe

# ROOT / analysis outputs
*.root

# ROOT dictionary files
*.pcm
*Dict.cxx
*Dict.h

# Libraries
*.a
*.so

# macOS
.DS_Store

# IDE
.vscode/

# Automatic dependency files
*.d

# Core dumps
core*

# Editor backup files
*~
\#*#
45 changes: 41 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,41 @@
This repository is for standalone scripts.
Place python scripts in the python directory, and c++ scripts in the cpp directory, and shell scripts in the bash directory.
For c++, please include a Makefile to compile your application, unless it is to run as ROOT macro (though compiled scripts are preferred for compile-time error checking).
For python scipts, please specify your environment and all python modules, including versions, your script relies on.
# ANNIE Helper Scripts

A repository for small standalone scripts that are detached from the ToolAnalysis.
For debugging, validation, ML training, and similar scripts.

Please note that ToolAnalysis remains the primary software framework for ANNIE. This repository is intended to host standalone helper scripts and utilities that complement the main codebase.

## Repository Structure

```text
.
├── cpp/
├── docs/
│ ├── script_catalog.md
│ └── script_header_template.md
├── python/
├── .gitignore
└── README.md
```

## Directory Description

| Directory | Description |
| --------- | ------------------------------------------------------- |
| `cpp/` | C++ analysis and utility scripts |
| `python/` | Python analysis and utility scripts |
| `docs/` | Script catalog and templates |


## Repository Guidelines

When adding new scripts to this repository:

* Place scripts in the appropriate sub-directory (`cpp/` or `python/`).
* The sub-directory name should reflect the primary purpose of the script(s) it contains.
* All scripts must include the standard metadata header defined in `docs/script_header_template.md`.
* Each script directory must contain a `README.md` describing the script, its inputs, outputs, dependencies (if applicable), and usage.
* Add all new scripts to `docs/script_catalog.md`.
* Update documentation whenever script functionality changes.
* For c++ scripts, please include a Makefile to compile your application, unless it is to run as ROOT macro (though compiled scripts are preferred for compile-time error checking).
* For python scripts, please specify your environment and all python modules, including versions which your script relies on.
99 changes: 99 additions & 0 deletions cpp/offsetFit_MultipleLAPPD/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# offsetFit_MultipleLAPPD

This script performs LAPPD timing offset fitting and takes `LAPPDTree.root` (produced by the `LAPPD_EB` toolchain) as input.

## Requirements

* All LAPPD events must appear in sequence.
* All CTC events must appear in sequence.

## Procedure

1. Load `LAPPDTree.root`.
2. Load the `TimeStamp` tree and obtain the run number and part file number.
3. For each unique run number and part file number, perform the fit.
4. For each LAPPD ID:

a. Loop over the `TimeStamp` tree and load:

* Data timestamp
* Data beamgate
* PPS for Board 0 and Board 1

b. Loop over the `Trig` (or `GTrig`) tree and load:

* CTC PPS (Trigger Word = 32)
* Target trigger word

5. Find the number of resets in the LAPPD PPS stream:

* There must be at least one event in each reset.
* Based on the event index order, only fit before the reset that does not contain a data event.
* Save the data event and PPS index ordering.

6. Use the target trigger word to perform the offset fit.
7. Save the offset for:

* LAPPD ID
* Run Number
* Part File Number
* Event Index
* Reset Number

8. Print information to output files.

## Input Arguments

The script takes five input arguments:

| Argument | Description |
| ---------------------- | ------------------------------------------------------------ |
| `filename` | Input file (`LAPPDTree.root`) |
| `fitTargetTriggerWord` | Undelayed Beam Trigger (14) for beam runs, 47 for laser runs |
| `triggerGrouped` | 1 for beam runs, 0 for laser runs |
| `intervalInSeconds` | See table below |
| `processPfNumber` | 0 |

### intervalInSeconds

| Run Range | Value |
| ------------------------ | ----- |
| Run < 5140 | 10 |
| Run = 6139 (Beam run) | 10 |
| Run ≥ 5140 (except 6139) | 5 |

## Usage

### Beam Runs

#### Runs < 5140

```bash
root -l -q 'offsetFit_MultipleLAPPD.cpp("LAPPDTree.root", 14, 1, 10, 0)'
```

#### Runs ≥ 5140 (except Run 6139)

```bash
root -l -q 'offsetFit_MultipleLAPPD.cpp("LAPPDTree.root", 14, 1, 5, 0)'
```

#### Run 6139

```bash
root -l -q 'offsetFit_MultipleLAPPD.cpp("LAPPDTree.root", 14, 1, 10, 0)'
```

### Laser Runs

#### Runs < 5140

```bash
root -l -q 'offsetFit_MultipleLAPPD.cpp("LAPPDTree.root", 47, 0, 10, 0)'
```

#### Runs ≥ 5140

```bash
root -l -q 'offsetFit_MultipleLAPPD.cpp("LAPPDTree.root", 47, 0, 5, 0)'
```
Loading