Back to home page

EIC code displayed by LXR

 
 

    


Warning, /firebird/packages/epic/src/with-epic.ts is written in an unsupported language. File is not indexed.

0001 /**
0002  * The ePIC experiment pack: everything Firebird knows about the ePIC
0003  * detector, contributed through the public extension API. The flagship app
0004  * installs it with `provideFirebird(withEpic({...}))`; an installation for
0005  * another experiment leaves it out and writes its own pack the same way.
0006  *
0007  * Heavy parts (geometry rules, themes, post-processors, the collision intro)
0008  * load through dynamic imports: an application references this file from its
0009  * app.config.ts, so everything it imports statically lands in the initial
0010  * bundle.
0011  */
0012 
0013 import {
0014   FirebirdFeature,
0015   firebirdPack,
0016   withCameraLimits,
0017   withCameraPreset,
0018   withCollisionIntro,
0019   withConfigDefaults,
0020   withDefaultGeometry,
0021   withGeometryPostProcessor,
0022   withGeometryTheme,
0023   withRootGeometryRules,
0024   withToolbarAction,
0025   withUrlAlias,
0026 } from '@dexvis/firebird-ng';
0027 import { withEpicDataCatalog } from './epic-data-catalog';
0028 
0029 /**
0030  * Options of `withEpic()`. Each option sets a config DEFAULT, the lowest
0031  * precedence tier: server config.jsonc, a value the user saved on the config
0032  * page, and a `?config.<key>=` URL value override it.
0033  */
0034 export interface EpicOptions {
0035   /**
0036    * URL of the geometry shown when nothing else selects one (config key
0037    * `geometry.selectedGeometry`); `epic://` URLs work. Default: the full ePIC
0038    * detector, `https://seeeic.org/g/epic/artifacts/tgeo/epic_craterlake.root`.
0039    */
0040   geometry?: string;
0041 }
0042 
0043 const EPIC_ARTIFACTS = 'https://seeeic.org/g/epic/artifacts/';
0044 
0045 /**
0046  * The ePIC pack as one feature with the id `epic`: the `epic://` alias, the
0047  * ePIC datasets of the data selector, TGeo cleanup rules and cut lists, the
0048  * cool2, cool2no and cad geometry themes, the dRICH mirror and detector
0049  * grouping post-processors, the Cherenkov collections kept out of MC-truth
0050  * trajectories, the ePIC camera views and limits, and the collision intro
0051  * with its toolbar button. Installed twice, it takes effect once: the later
0052  * call replaces the earlier one at the earlier position.
0053  *
0054  * ```ts
0055  * provideFirebird(withEpic({ geometry: 'epic://tgeo/epic_ip6.root' }))
0056  * ```
0057  */
0058 export function withEpic(options: EpicOptions = {}): FirebirdFeature {
0059   return firebirdPack('epic',
0060     // Where data lives. The default geometry is the URL the catalog's
0061     // full-detector entries use, so a fresh install shows that preset as the
0062     // active one.
0063     withUrlAlias('epic://', EPIC_ARTIFACTS),
0064     withDefaultGeometry(options.geometry ?? `${EPIC_ARTIFACTS}tgeo/epic_craterlake.root`),
0065     withEpicDataCatalog(),
0066 
0067     // Geometry pipeline: TGeo cleanup and cut lists, themes, post-processing.
0068     // The pack selects its rule set and theme through config defaults, so a
0069     // user's choice on the config page still overrides them.
0070     withConfigDefaults({
0071       'geometry.rootFilterName': 'default',
0072       'geometry.themeName': 'cool2',
0073     }),
0074     withRootGeometryRules(() => import('./epic-geometry-rules').then(m => m.epicRootGeometryRules)),
0075     withGeometryTheme({
0076       id: 'cool2', label: 'Cool2 - modern colors by detector type',
0077       load: () => import('./cool2-geometry-ruleset').then(m => m.cool2ColorRules),
0078     }),
0079     withGeometryTheme({
0080       id: 'cool2no', label: 'Cool2 No Outline - no outline for performance',
0081       load: () => import('./cool2no-geometry-ruleset').then(m => m.cool2NoOutlineColorRules),
0082     }),
0083     withGeometryTheme({
0084       id: 'cad', label: 'CAD - like colors, optimized',
0085       load: () => import('./cad-geometry-ruleset').then(m => m.cadColorRules),
0086     }),
0087     withGeometryPostProcessor({
0088       id: 'epic.prettifier',
0089       load: () => import('./epic-geometry-post-processors').then(m => m.EpicGeometryPrettifier),
0090     }),
0091     withGeometryPostProcessor({
0092       id: 'epic.arranger',
0093       load: () => import('./epic-geometry-post-processors').then(m => m.EpicDetectorArranger),
0094     }),
0095 
0096     // Event conversion: the DIRC, dRICH and pfRICH sim hits are photon
0097     // detections attributed to the emitting charged particle. Joined into
0098     // that particle's MC-truth trajectory, they draw zigzags along the
0099     // photosensor planes, so the browser conversion keeps them out of the
0100     // trajectories (they still show as hits). pyrobird's server conversion
0101     // excludes the same list by default.
0102     withConfigDefaults({
0103       'events.trajectoryExcludedCollections': 'DIRCBarHits,DRICHHits,PFRICHHits',
0104     }),
0105 
0106     // Camera: the ePIC views, and limits sized for the ePIC hall (a 15 m
0107     // scene radius) instead of the loaded geometry's bounding sphere.
0108     withCameraLimits({ minDistance: 750, maxDistance: 75000 }),
0109     withCameraPreset({ name: 'home', label: 'Home', position: [0, 7000, 0], target: [0, 0, 0], up: [1, 0, 0] }),
0110     withCameraPreset({ name: 'center', label: 'Center', position: [-3600, 2900, -4700], target: [0, 0, 0], up: [0, 1, 0] }),
0111     withCameraPreset({ name: 'farforward', label: 'Far forward', position: [8000, 7500, 40000], target: [0, 0, 30000], up: [0, 1, 0] }),
0112 
0113     // The beams colliding before an event plays, and its toolbar button
0114     withCollisionIntro(() => import('./epic-collision-intro').then(m => m.EpicCollisionIntro)),
0115     withToolbarAction({
0116       id: 'collision', icon: 'close_fullscreen', label: 'Collision',
0117       tooltip: 'Animate with beam particles collision',
0118       command: { type: 'animate-collision' },
0119     }),
0120   );
0121 }