Skip to content

Commit 38a77d0

Browse files
committed
Fix conversion and analysis scripts. Improving docs
1 parent bc75c3c commit 38a77d0

File tree

90 files changed

+1541
-46
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+1541
-46
lines changed

csv_convert/csv_mcpart_lambda.cxx

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -103,23 +103,48 @@ void process_event(const podio::Frame&event, int evt_id) {
103103
for (const auto& lam: particles) {
104104
if (lam.getPDG() != 3122) continue; // not Λ⁰
105105

106-
106+
int decay_type = 4; // 0 - not decayed, 1 - p-piminus, 2 - n-pizero, 3 - shower/recharge, 4 - other (what?)
107107

108108
// -----------------------------------------------------------------
109109
// classify decay channel & pick final-state pointers
110110
// -----------------------------------------------------------------
111111
std::optional<MCParticle> prot, pimin, neut, pi0, gam1, gam2;
112112

113-
for (const auto& daughter: lam.getDaughters()) {
114-
switch (daughter.getPDG()) {
115-
case 2212: prot = daughter; // p
116-
break;
117-
case -211: pimin = daughter; // π-
118-
break;
119-
case 2112: neut = daughter; // n
120-
break;
121-
case 111: pi0 = daughter; // π0
113+
auto daughters = lam.getDaughters();
114+
115+
if (daughters.size() == 0) {
116+
decay_type = 0; // didn't decayed. Maybe went out of the volume
117+
} else if (daughters.size() == 2) {
118+
if (daughters.at(0).getPDG() == 2212 && daughters.at(1).getPDG() == -211) {
119+
decay_type = 1; // p-piminus
120+
prot = daughters.at(0);
121+
pimin = daughters.at(1);
122+
}
123+
124+
if (daughters.at(1).getPDG() == 2212 && daughters.at(0).getPDG() == -211) {
125+
decay_type = 1; // p-piminus
126+
prot = daughters.at(1);
127+
pimin = daughters.at(0);
128+
}
129+
130+
if (daughters.at(0).getPDG() == 2112 && daughters.at(1).getPDG() == 111) {
131+
decay_type = 2; // n-pizero
132+
neut = daughters.at(0);
133+
pi0 = daughters.at(1);
134+
}
135+
136+
if (daughters.at(1).getPDG() == 2112 && daughters.at(0).getPDG() == 111) {
137+
decay_type = 2; // n-pizero
138+
neut = daughters.at(1);
139+
pi0 = daughters.at(0);
140+
}
141+
} else {
142+
// ... so ... it is complicated...
143+
for (const auto& daughter: daughters) {
144+
if (daughter.getPDG() == 3122) {
145+
decay_type = 3; // It is recharging lambda - shower
122146
break;
147+
}
123148
}
124149
}
125150

@@ -141,12 +166,11 @@ void process_event(const podio::Frame&event, int evt_id) {
141166
fmt::print("(!!!) WARNING: I see neut && prot at evt_id={}\n", evt_id);
142167
}
143168

144-
145169
// -----------------------------------------------------------------
146170
// output
147171
// -----------------------------------------------------------------
148172
if (!header_written) {
149-
csv << "event,lam_is_first,"
173+
csv << "event,lam_is_first,lam_decay,"
150174
<< make_particle_header("lam") << ','
151175
<< make_particle_header("prot") << ','
152176
<< make_particle_header("pimin") << ','
@@ -158,7 +182,9 @@ void process_event(const podio::Frame&event, int evt_id) {
158182
}
159183

160184
// Call the new string-returning function to build the output line
161-
csv << evt_id << ',' << static_cast<int>(is_first_lambda) << ','
185+
csv << evt_id << ','
186+
<< static_cast<int>(is_first_lambda) << ','
187+
<< decay_type << ','
162188
<< particle_to_csv(lam) << ','
163189
<< particle_to_csv(prot) << ','
164190
<< particle_to_csv(pimin) << ','

docs/.vitepress/config.mts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ export default withMermaid({
5252
{ text: 'Campaign log', link: '/campaigns' },
5353
]
5454
},
55+
{
56+
text: 'Campaign 2025-08',
57+
items: [
58+
{ text: 'Acceptance', link: '/campaign-2025-08/campaign-2025-08' },
59+
{ text: 'EG comparison', link: '/campaign-2025-08/eg-comparison' },
60+
{ text: 'Acceptance', link: '/campaign-2025-08/acceptance' },
61+
]
62+
},
5563
{
5664
text: 'Analysis',
5765
link: '/analysis',
@@ -75,7 +83,7 @@ export default withMermaid({
7583
]
7684
},
7785
{
78-
text: 'Results',
86+
text: 'Other',
7987
items: [
8088
{ text: 'Publications', link: '/publications' },
8189
{ text: 'Generator plots', link: '/eg-plots' },
Lines changed: 274 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,274 @@
1+
<template>
2+
<div class="acceptance-plot">
3+
<h3 v-if="title">{{ title }}</h3>
4+
<p v-if="description" class="description">{{ description }}</p>
5+
6+
<div class="plot-controls">
7+
<label :for="'energy-select-' + plotId">Energy Mode:</label>
8+
<select
9+
:id="'energy-select-' + plotId"
10+
v-model="localEnergyMode"
11+
@change="loadImages"
12+
>
13+
<option value="">-- Select energy mode --</option>
14+
<option value="5x41">5×41</option>
15+
<option value="10x100">10×100</option>
16+
<option value="10x130">10×130</option>
17+
<option value="18x75">18×75</option>
18+
<option value="5x41_vs_10x100">5×41 vs 10×100</option>
19+
<option value="5x41_vs_18x75">5×41 vs 18×75</option>
20+
<option value="10x100_vs_10x130">10×100 vs 10×130</option>
21+
<option value="10x100_vs_18x75">10×100 vs 18×75</option>
22+
<option value="10x130_vs_18x75">10×130 vs 18×75</option>
23+
</select>
24+
</div>
25+
26+
<div v-if="currentImages.length > 0" class="images-container">
27+
<div
28+
v-for="(img, index) in currentImages"
29+
:key="index"
30+
class="image-wrapper"
31+
>
32+
<h4 v-if="img.label" class="image-label">{{ img.label }}</h4>
33+
<img
34+
:src="img.src"
35+
:alt="img.alt"
36+
@error="handleImageError"
37+
class="plot-image"
38+
/>
39+
</div>
40+
</div>
41+
42+
<div v-else-if="localEnergyMode" class="no-data">
43+
No plot available for selected energy mode
44+
</div>
45+
</div>
46+
</template>
47+
48+
<script setup lang="ts">
49+
import { ref, computed, watch, inject, onMounted } from 'vue'
50+
import { withBase } from 'vitepress'
51+
52+
// Props
53+
const props = defineProps<{
54+
plotName: string
55+
title?: string
56+
description?: string
57+
}>()
58+
59+
// Unique ID for this plot instance
60+
const plotId = Math.random().toString(36).substr(2, 9)
61+
62+
// Inject global energy mode
63+
const globalEnergyMode = inject<any>('globalEnergyMode', ref(''))
64+
65+
// Local energy mode (can be overridden by user)
66+
const localEnergyMode = ref('')
67+
68+
// Current images to display
69+
interface PlotImage {
70+
src: string
71+
alt: string
72+
label?: string
73+
}
74+
75+
const currentImages = ref<PlotImage[]>([])
76+
77+
// Watch global mode changes
78+
watch(globalEnergyMode, (newMode) => {
79+
if (newMode) {
80+
localEnergyMode.value = newMode
81+
loadImages()
82+
}
83+
})
84+
85+
// Watch local mode changes
86+
watch(localEnergyMode, () => {
87+
loadImages()
88+
})
89+
90+
// Load images based on selected mode
91+
function loadImages() {
92+
if (!localEnergyMode.value) {
93+
currentImages.value = []
94+
return
95+
}
96+
97+
const mode = localEnergyMode.value
98+
const images: PlotImage[] = []
99+
100+
if (mode.includes('_vs_')) {
101+
// Comparison mode: show two plots
102+
const [energy1, energy2] = mode.split('_vs_')
103+
104+
images.push({
105+
src: withBase(`/analysis/campaign-2025-08/acceptance/${energy1}/${props.plotName}`),
106+
alt: `${props.title || props.plotName} - ${energy1}`,
107+
label: `${energy1.replace('x', '×')} GeV`
108+
})
109+
110+
images.push({
111+
src: withBase(`/analysis/campaign-2025-08/acceptance/${energy2}/${props.plotName}`),
112+
alt: `${props.title || props.plotName} - ${energy2}`,
113+
label: `${energy2.replace('x', '×')} GeV`
114+
})
115+
} else {
116+
// Single energy mode
117+
images.push({
118+
src: withBase(`/analysis/campaign-2025-08/acceptance/${mode}/${props.plotName}`),
119+
alt: `${props.title || props.plotName} - ${mode}`,
120+
label: undefined
121+
})
122+
}
123+
124+
currentImages.value = images
125+
}
126+
127+
// Handle image loading errors
128+
function handleImageError(event: Event) {
129+
const img = event.target as HTMLImageElement
130+
console.warn(`Failed to load image: ${img.src}`)
131+
}
132+
133+
// Initialize on mount
134+
onMounted(() => {
135+
if (globalEnergyMode.value) {
136+
localEnergyMode.value = globalEnergyMode.value
137+
loadImages()
138+
}
139+
})
140+
</script>
141+
142+
<style scoped>
143+
.acceptance-plot {
144+
margin: 3rem 0;
145+
padding: 1.5rem;
146+
background-color: var(--vp-c-bg-soft);
147+
border-radius: 8px;
148+
border: 1px solid var(--vp-c-divider);
149+
}
150+
151+
.acceptance-plot h3 {
152+
margin-top: 0;
153+
margin-bottom: 0.5rem;
154+
color: var(--vp-c-text-1);
155+
}
156+
157+
.description {
158+
margin-bottom: 1rem;
159+
color: var(--vp-c-text-2);
160+
font-size: 14px;
161+
}
162+
163+
.plot-controls {
164+
margin-bottom: 1.5rem;
165+
padding: 0.75rem;
166+
background-color: var(--vp-c-bg);
167+
border-radius: 4px;
168+
border: 1px solid var(--vp-c-divider);
169+
}
170+
171+
.plot-controls label {
172+
display: block;
173+
margin-bottom: 0.5rem;
174+
font-weight: 600;
175+
color: var(--vp-c-text-1);
176+
font-size: 14px;
177+
}
178+
179+
.plot-controls select {
180+
width: 100%;
181+
max-width: 400px;
182+
padding: 0.5rem;
183+
border: 1px solid var(--vp-c-divider);
184+
border-radius: 4px;
185+
background-color: var(--vp-c-bg);
186+
color: var(--vp-c-text-1);
187+
font-size: 14px;
188+
cursor: pointer;
189+
}
190+
191+
.plot-controls select:hover {
192+
border-color: var(--vp-c-brand);
193+
}
194+
195+
.plot-controls select:focus {
196+
outline: none;
197+
border-color: var(--vp-c-brand);
198+
box-shadow: 0 0 0 2px var(--vp-c-brand-soft);
199+
}
200+
201+
.images-container {
202+
display: flex;
203+
flex-direction: column;
204+
gap: 2rem;
205+
}
206+
207+
.image-wrapper {
208+
text-align: center;
209+
}
210+
211+
.image-label {
212+
margin-bottom: 0.5rem;
213+
font-size: 16px;
214+
font-weight: 600;
215+
color: var(--vp-c-brand);
216+
}
217+
218+
.plot-image {
219+
width: 100%;
220+
max-width: 100%;
221+
height: auto;
222+
border-radius: 4px;
223+
border: 1px solid var(--vp-c-divider);
224+
background-color: var(--vp-c-bg);
225+
}
226+
227+
.no-data {
228+
padding: 2rem;
229+
text-align: center;
230+
color: var(--vp-c-text-2);
231+
font-style: italic;
232+
}
233+
234+
/* Dark mode adjustments */
235+
.dark .acceptance-plot {
236+
background-color: var(--vp-c-bg-elv);
237+
}
238+
239+
.dark .plot-controls {
240+
background-color: var(--vp-c-bg-soft);
241+
}
242+
243+
.dark .plot-controls select {
244+
background-color: var(--vp-c-bg-elv);
245+
}
246+
247+
/* Responsive design */
248+
@media (max-width: 768px) {
249+
.acceptance-plot {
250+
padding: 1rem;
251+
}
252+
253+
.plot-controls {
254+
padding: 0.5rem;
255+
}
256+
257+
.image-label {
258+
font-size: 14px;
259+
}
260+
}
261+
262+
/* For comparison view, show images side by side on larger screens */
263+
@media (min-width: 1200px) {
264+
.images-container {
265+
flex-direction: row;
266+
flex-wrap: wrap;
267+
}
268+
269+
.image-wrapper {
270+
flex: 1;
271+
min-width: 45%;
272+
}
273+
}
274+
</style>

0 commit comments

Comments
 (0)