Warning, /firebird/packages/root2dex/src/edm4hep.spec.ts is written in an unsupported language. File is not indexed.
0001 /**
0002 * Which sim hit collections feed the MC-truth trajectories. The converter is
0003 * experiment-neutral: it excludes nothing unless the caller names
0004 * collections in `trajectoryExcludedCollections`.
0005 */
0006
0007 import { describe, expect, it } from 'vitest';
0008 import { existsSync } from 'node:fs';
0009 import { resolve } from 'node:path';
0010 import { Root2DexConverter, type ConvertOptions } from './convert';
0011 import { EDM4HEP_SIM_HIT_TYPE } from './edm4hep';
0012
0013 const SIM_FILE = resolve(__dirname, '../../../pyrobird/tests/unit_tests/data/k_lambda_10x100_2evt.edm4hep.root');
0014
0015 describe('edm4hep trajectory sources', () => {
0016 it.runIf(existsSync(SIM_FILE))('joins every sim hit collection unless told to exclude some', async () => {
0017 const converter = await Root2DexConverter.open(SIM_FILE);
0018 const hitCollections = converter.file.collectionsOfType(EDM4HEP_SIM_HIT_TYPE);
0019 expect(hitCollections.length).toBeGreaterThan(1);
0020
0021 /** The collections the trajectory piece of entry 0 was built from. */
0022 const trajectorySources = async (options: ConvertOptions) => {
0023 const event = await converter.convertEntry(0, { ...options, collections: ['mc_trajectories'] });
0024 const trajectories = event.pieces.find(piece => piece.type === 'PointTrajectory');
0025 return (trajectories?.origin as { collections: string[] }).collections;
0026 };
0027
0028 expect(await trajectorySources({})).toEqual(hitCollections);
0029 const [excluded, ...kept] = hitCollections;
0030 expect(await trajectorySources({ trajectoryExcludedCollections: [excluded] })).toEqual(kept);
0031 });
0032 });