Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
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
2 changes: 1 addition & 1 deletion CustomGUIv2/controller/MyNewMain.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ sap.ui.define(['rootui5/eve7/controller/Main.controller',
},

showEventInfo : function() {
let tinfo = "Event : " + this.fw2gui.eventid + " Sub Run :" + this.fw2gui.subrunid + " Run :" + this.fw2gui.runid;
let tinfo = " Run :" + this.fw2gui.runid + " Sub Run :" + this.fw2gui.subrunid + "Event : " + this.fw2gui.eventid;
document.title = tinfo;
//this.byId("runInput").setValue(this.fw2gui.runid);
//this.byId("eventInput").setValue(this.fw2gui.eventid);
Expand Down
2 changes: 1 addition & 1 deletion CustomGUIv2/view/MyMain.view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<Input id="dateInput" width="100px" />
</OverflowToolbar>
<OverflowToolbar id="otb3">
<Label text="test:">
<Label text="AutoPlay (plcaeholder):">
<layoutData>
<OverflowToolbarLayoutData priority="Disappear" shrinkable="true" minWidth="40px" />
</layoutData>
Expand Down
57 changes: 8 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,53 +4,12 @@ This repo contains the current EventDisplay source code, example fcls, tutorials

The EventDisplay is based on REve which is an updated version of the well-known and widely used TEve ROOT based Event Visualization Software. REve uses modernized infrastcutrue and allows Web Access for remote use.

For more information about REve and the implementation for Mu2e see: https://mu2ewiki.fnal.gov/wiki/Eve7EventDisplay#Examples_of_the_Eve-7_Mu2e_Display.

# Useage

## Sequential on known file
To use the display to scroll through events sequentially utilize either the ```nominal_example``` for nominal Mu2e geometry or ```extracted_example``` for the extracted geometry and run as you would any other .fcl:

```
mu2e -c <chosen_geom.fcl> <filename.art>
```

The current available options for the .fcl are located in the ```examples``` directory. There are four main examples:

* nominal_MDC2020.fcl: with the original CRV geometry, to be used the MDC2020 samples
* nominal_MDC2025.fcl: with the MDC2025 CRV geometry assuming the common GDML
* extracted_MDC2020.fcl: for those still using MDC2020 extracted samples, to be retired
* extracted_MDC2025.fcl: for those doing extracted studies with MDC2025 samples
* nominal_Run1A.fcl: Run1A CRV geometry MDC2025
* nominal_Run2.fcl: full CRV geometry, MDC2025

These .fcl can be edited as you wish (adding or removing certain features), they should provide good starting points for any study.

## Go to an given event

There are a number of ways to go from your analysis to a visualized event. Utilities are provided in both rooutils [cite] and pyutils [https://github.com/Mu2e/pyutils/blob/main/pyutils/pydisplay.py]. There is also a custom script in this repo ```config/EventDisplay.sh``` the usage is as follows:

```
./EventDisplay.sh --run 1201 --subrun 34 --event 15028 --dataset mcs.mu2e.ensembleMDS2cMix1BBTriggered.MDC2020ba_best_v1_3.art
```

if you know the name of the dataset.

If you are working with an ntuple, you may not know all the commands to figure out its parent mcs. In this case run:

```
./EventDisplay.sh --run 1201 --subrun 476 --event 1 --dataset nts.mu2e.ensembleMDS2cMix1BBTriggered.MDC2020ba_best_v1_3_v06_06_00.001201_00000476.root
```

where the run, subrun and event numbers are identified from your analysis to be an event of interest in that root file.



# Tutorial

We are in the process of updating our Analysis Tools Tutorial material. In the meantime, please see: https://mu2ewiki.fnal.gov/wiki/EventDisplayTutorial

# Development

This code is still under development by the Mu2e Analysis Tools Group. The development team current consists of Sophie Middleton, Andy Edmonds and Namitha Chithiraseemadam. Please contact us to contribute.
## Documentation

* [Getting Started](./documentation/GettingStarted.md)
* [Examples](./documentation/examples.md).
* [Fcl Options](./documentation/FclOptions.md).
* [GUI Options](./documentation/GUIOptions.md).
* [EventNavigation](./documentation/EventNavigation.md).
* [Data Product Visualizaton](./documentation/DataProductVisualization.md).

8 changes: 4 additions & 4 deletions config/drawutils.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
int TRKtrans = 98;
int CALtrans = 100;
int CRYtrans = 90;
int CRVtrans = 98;
int Crvtrans = 98;
int BLtrans = 90;//BL = beamline elements

int maxlevel = 8; //8=calocrystals, moved to 10 for PA
Expand All @@ -15,10 +15,10 @@ int GeomLineWidth = 1;
int TRKColor = 432; //kCyan = 432
int CALColor = 432; //kCyan = 432
int BLColor = 432; //kCyan = 432
int CRVColor = 432; //kCyan = 432
int CrvColor = 432; //kCyan = 432

int CRVBarColor = 632;
int CrvBarColor = 632;
int RecoTrackColor = 600; //kGreen
int CRVHitColor = 600; //kBlue
int CrvHitColor = 600; //kBlue
int TrkHitColor = 632; //kBlue
int TrkNoHitColor = 600; //kBlue
79 changes: 79 additions & 0 deletions config/start_RemoteDisplay.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/bin/bash

# Initialize variables
PORT_NUM=""
MACHINE_ID=""
USERNAME=""

# --- Function to open browser based on OS ---
open_browser() {
local url=$1
case "$(uname -s)" in
Darwin)
# macOS
echo "Detected macOS. Opening Google Chrome..."
open -a "Google Chrome" "$url"
;;
Linux)
# Linux variants
echo "Detected Linux. Attempting to open browser..."
# Try specific commands for Chrome/Chromium, fall back to xdg-open
if command -v google-chrome >/dev/null; then
google-chrome "$url"
elif command -v chromium-browser >/dev/null; then
chromium-browser "$url"
else
xdg-open "$url"
fi
;;
CYGWIN*|MINGW*|MSYS*)
# Windows (Git Bash/Cygwin)
echo "Detected Windows. Opening browser..."
cmd.exe /c start "$url"
;;
*)
echo "Unsupported OS. Please open the URL manually: $url"
;;
esac
}

# --- Parse command-line arguments ---
while [[ "$#" -gt 0 ]]; do
case "$1" in
--port)
PORT_NUM="$2"
shift; shift
;;
--machine)
MACHINE_ID="$2"
shift; shift
;;
--user)
USERNAME="$2"
shift; shift
;;
*)
echo "Unknown parameter passed: $1"
echo "Usage: $0 --port <number> --machine <id> --user <name>"
exit 1
;;
esac
done

# --- Validation ---
if [ -z "$PORT_NUM" ] || [ -z "$MACHINE_ID" ] || [ -z "$USERNAME" ]; then
echo "Error: Missing required arguments."
echo "Usage: $0 --port <number> --machine <id> --user <name>"
echo "Example: $0 --port 1234 --machine 05 --user sophie"
exit 1
fi

# --- Execution ---
HOSTNAME="mu2egpvm${MACHINE_ID}.fnal.gov"
URL="http://localhost:${PORT_NUM}/win1/"

open_browser "$URL"

echo "Establishing SSH tunnel for ${USERNAME}@${HOSTNAME} on port ${PORT_NUM}"
ssh -KXY -L "${PORT_NUM}:localhost:${PORT_NUM}" "${USERNAME}@${HOSTNAME}"

113 changes: 113 additions & 0 deletions documentation/DataProductVisualization.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# Data Product Visualization in Mu2e Event Display

This document outlines the purpose and key features of the core C++ functions used in the Mu2e event display to visualize **Monte Carlo (MC)** and **Reconstructed (Reco)** data products. These functions convert abstract data objects into graphical elements using the **ROOT REve** framework, enabling detailed event inspection.

---

## MC Data Visualization

The following function displays simulated particle trajectories.

### $\text{MCInterface::AddMCTrajectoryCollection}$

This function processes collections of $\text{MCTrajectory}$ objects and renders them as colored lines in the detector scene.

| Feature | Description |
| :--- | :--- |
| **Input** | $\text{MCTrajectoryCollection}$ |
| **Visualization** | **$\text{REveLine}$** for each trajectory. |
| **Color Coding** | Line color is assigned based on the **particle's PDG ID** (e.g., electron is red, muon is black). |
| **Filtering** | Draws only particles whose PDG ID is included in the user-defined $\text{particleIds}$ list. |
| **Title Info** | Includes **Particle Name**, **SimParticle ID**, **Parent ID**, **Kinetic Energy**, and **Creation/Stopping Codes** for traceability. |

### $\text{MCInterface::AddSurfaceStepCollection}$

This function visualizes points where a $\text{SimParticle}$ crosses a defined detector or virtual surface.

| Feature | Description |
| :--- | :--- |
| **Input** | $\text{SurfaceStepCollection}$ |
| **Visualization** | **$\text{REvePointSet}$** marker at the step's $\text{midPosition}$. |
| **Color Coding** | Fixed to **kBlack** (in the current implementation) to distinguish them clearly from track lines. |
| **Filtering** | Draws only steps made by particles whose PDG ID is in the user-defined $\text{particleIds}$ list. |
| **Title Info** | Includes the **Surface ID name**, step **Position**, **Time**, **Momentum**, and **Energy Deposit** ($\text{edep}$). |

---

## Reconstructed (Reco) Data Visualization

These functions visualize the output of track fitting and hit clustering algorithms.

### $\text{DataInterface::FillKinKalTrajectory}$

This is the main orchestration function for visualizing reconstructed tracks ($\text{KalSeed}$) and their associated products.

| Feature | Description |
| :--- | :--- |
| **Input** | $\text{KalSeedPtrCollection}$ |
| **Action** | Identifies the successful fit type ($\text{LoopHelix}$, $\text{CentralHelix}$, $\text{KinematicLine}$) and calls specialized functions to draw the trajectory and products. |
| **Output** | Adds a **$\text{REveCompound}$** (**trackproducts**) to the scene, grouping all elements related to a single track. |
| **Trajectory** | Uses $\text{AddKinKalTrajectory}$ to draw the path based on the chosen fit type. |
| **Products** | Calls $\text{AddTrkStrawHit}$ (for hits) and $\text{AddKalIntersection}$ (for material/surface crossings). |

### $\text{DataInterface::AddKinKalTrajectory}$

Renders the smooth, mathematical path of a **$\text{KinKal}$ track fit**.

| Feature | Description |
| :--- | :--- |
| **Input** | $\text{KinKal}$ Trajectory ($\text{LoopHelix}$, $\text{CentralHelix}$, or $\text{KinematicLine}$) |
| **Visualization** | **$\text{REveLine}$** generated by sampling the trajectory's equation across its time range at discrete steps ($\text{0.1}$ time units). |
| **Title Info** | Includes **Particle Name**, **Momentum**, **Fit Parameters** ($\text{lam}$, $\text{rad}$, $\text{omega}$, $\text{d0}$, $\text{z0}$), and **Fit Consistency**. |

### $\text{DataInterface::AddTrkStrawHit}$

Visualizes the individual $\text{Tracker}$ hits that contributed to a track fit.

| Feature | Description |
| :--- | :--- |
| **Input** | $\text{TrkStrawHitSeed}$s from a $\text{KalSeed}$ |
| **Visualization** | A **$\text{REveCompound}$** containing a **$\text{REvePointSet}$** (the hit position) and a **$\text{REveLine}$** (the $2\sigma$ error bar perpendicular to the track/wire). |
| **Color Coding** | Uses **$\text{TrkHitColor}$** but switches to a **$\text{TrkNoHitColor}$** if the full drift constraint was *not* used in the fit. |

### $\text{DataInterface::AddKalIntersection}$

Marks where the track crosses significant surfaces within the detector geometry.

| Feature | Description |
| :--- | :--- |
| **Input** | $\text{KalIntersection}$ objects from a $\text{KalSeed}$ |
| **Visualization** | **$\text{REvePointSet}$** marker. |
| **Color Coding** | **kViolet** for intersections with material (where $\text{dMom} > 0.0$) and **kYellow** for intersections with virtual surfaces. |
| **Title Info** | **Position**, **Time**, **Momentum/dMomentum**, and the name of the **Surface** intersected. |

### $\text{DataInterface::AddTrkHits}$

Visually links reconstructed tracks to the original hit collections.

| Feature | Description |
| :--- | :--- |
| **Input** | $\text{ComboHitCollection}$ and $\text{KalSeedPtrCollection}$ |
| **Visualization** | **$\text{REvePointSet}$** at the position of each $\text{ComboHit}$. |
| **Functionality** | **Filters** the $\text{ComboHits}$ by comparing their $\text{StrawId}$ against a set of $\text{StrawId}$s used in all $\text{KalSeeds}$. This highlights *only* the hits used for tracking. |
| **Efficiency** | Uses a **$\text{std::set}$** to efficiently check $\text{StrawId}$ membership, preventing slow triple-nested loop searches. |

### $\text{DataInterface::AddTimeClusters}$

Visually displays clusters of hits used to determine the initial time ($\text{t0}$) for track seeds.

| Feature | Description |
| :--- | :--- |
| **Input** | $\text{TimeClusterCollection}$ |
| **Visualization** | **$\text{REvePointSet}$** marker at the cluster's central position. |
| **Title Info** | Cluster $\text{t0}$ and error. |

### $\text{DataInterface::AddCosmicTrackFit}$

Draws the simple straight-line fit for cosmic ray data.

| Feature | Description |
| :--- | :--- |
| **Input** | $\text{CosmicTrackSeedCollection}$ |
| **Visualization** | **$\text{REveLine}$** segment. |
| **Functionality** | Draws a line segment between the calculated track positions corresponding to the **first and last Y-coordinates** of the hits used in the fit. |
57 changes: 57 additions & 0 deletions documentation/EventNavigation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
## 🗺️ Event Navigation

During analysis, there are several methods available to navigate to a specific event within the Event Display.

---

### 1. Default Sequential Mode

The **default navigation mode** is sequential.

* By default, the setting `seqMode` is set to `true`.
* The display begins at the **first event**.
* Users can navigate to the next event in the sequence using the **GUI's navigation controls**.

---

### 2. Autoplay

The **Autoplay** option overrides the standard GUI navigation.

* When the "**autoplay**" checkbox is selected, the display will **stream all events sequentially** until it reaches the end of the file.

---

### 3. Go to an Event: GUI

The Event Display GUI includes **text entry boxes** that allow a user to jump directly to an event by specifying its **run** and **event number**.

* **Steps to Use (Currently a Placeholder):**
1. Ensure the display is loaded in `seqMode`.
2. Navigate to the **second event** using the `NextEvent()` function.
3. Enter the desired run and event number into the text boxes.
4. Select the **`Go()`** button, followed immediately by **`NextEvent()`**.

> **Note:** This is **not the recommended method** for navigation and is considered a placeholder feature.

---

### 4. Go to an Event: Scripts (Recommended Method)

The most robust way to navigate to a specific event is by using the custom script located in this repository: `config/EventDisplay.sh`.

#### A. Navigating with the Dataset Name

If you know the name of the **dataset** containing the event, use the following syntax:

```
./EventDisplay.sh --run 1201 --subrun 34 --event 15028 --dataset mcs.mu2e.ensembleMDS2cMix1BBTriggered.MDC2020ba_best_v1_3.art```
```

If you are working with an ntuple, you may not know all the commands to figure out its parent mcs. In this case run:

```
./EventDisplay.sh --run 1201 --subrun 476 --event 1 --dataset nts.mu2e.ensembleMDS2cMix1BBTriggered.MDC2020ba_best_v1_3_v06_06_00.001201_00000476.root
```

where the run, subrun and event numbers are identified from your analysis to be an event of interest in that root file.
Loading