Warning, /firebird/firebird-ng/src/app/data-pipelines/root-geometry.processor.ts is written in an unsupported language. File is not indexed.
0001 //import { openFile } from '../../../jsroot/core.mjs';
0002 //import * as ROOT from '../../../jsroot/build;
0003 import {
0004 analyzeGeoNodes,
0005 findSingleGeoNode,
0006 } from '../../lib-root-geometry/root-geo-navigation';
0007 import {EditActions, GeoNodeEditRule, removeGeoNode} from "../../lib-root-geometry/root-geo-edit";
0008 import {GeoAttBits} from "../../lib-root-geometry/root-geo-attribute-bits";
0009 import {editGeoNodes} from "../../lib-root-geometry/root-geo-edit";
0010
0011
0012 export class DetectorGeometryFineTuning {
0013 namePattern: string = "";
0014 editRules: GeoNodeEditRule[] = [];
0015 }
0016
0017
0018 export function pruneTopLevelDetectors(geoManager: any, removeNames: string[]): any {
0019 const volume = geoManager.fMasterVolume === undefined ? geoManager.fVolume : geoManager.fMasterVolume;
0020 const nodes: any[] = volume?.fNodes?.arr ?? [];
0021 let removedNodes: any[] = [];
0022
0023 // Don't have nodes? Have problems?
0024 if(!nodes.length) {
0025 return {nodes, removedNodes};
0026 }
0027
0028 // Collect nodes to remove
0029 for(let node of nodes) {
0030 let isRemoving = removeNames.some(substr => node.fName.startsWith(substr))
0031 if(isRemoving) {
0032 removedNodes.push(node);
0033 }
0034 }
0035
0036 // Now remove nodes
0037 for(let node of removedNodes) {
0038 removeGeoNode(node);
0039 }
0040
0041 return {nodes, removedNodes}
0042 }
0043
0044 export class RootGeometryProcessor {
0045
0046
0047 subDetectorsRules: DetectorGeometryFineTuning[] = [
0048 {
0049 namePattern: "*/EcalBarrelScFi*",
0050 editRules: [
0051 {pattern: "*/fiber_grid*", action: EditActions.Remove},
0052 {pattern: "*", action: EditActions.SetGeoBit, geoBit: GeoAttBits.kVisDaughters},
0053 {pattern: "*/*layer*", action: EditActions.SetGeoBit, geoBit: GeoAttBits.kVisThis},
0054 {pattern: "*/*layer*", action: EditActions.UnsetGeoBit, geoBit: GeoAttBits.kVisNone},
0055 {pattern: "*/*layer*", action: EditActions.UnsetGeoBit, geoBit: GeoAttBits.kVisDaughters},
0056 ]
0057 },
0058 {
0059 namePattern: "*/EcalBarrelImaging*",
0060 editRules: [
0061 {pattern: "*/stav*", action: EditActions.RemoveChildren},
0062 {pattern: "*", action: EditActions.SetGeoBit, geoBit: GeoAttBits.kVisDaughters},
0063 ]
0064 },
0065 {
0066 namePattern: "*/DRICH*",
0067 editRules: [
0068 {pattern: "*/DRICH_cooling*", action: EditActions.RemoveSiblings},
0069 ]
0070 },
0071 {
0072 namePattern: "*/DIRC*",
0073 editRules: [
0074 {pattern: "*/Envelope_box*", action: EditActions.RemoveChildren},
0075 {pattern: "*/Envelope_box*", action: EditActions.SetGeoBit, geoBit: GeoAttBits.kVisThis},
0076 {pattern: "*/Envelope_box*", action: EditActions.UnsetGeoBit, geoBit: GeoAttBits.kVisNone},
0077 {pattern: "*/Envelope_box*", action: EditActions.UnsetGeoBit, geoBit: GeoAttBits.kVisDaughters},
0078 {pattern: "*/Envelope_lens_vol*", action: EditActions.Remove},
0079 ]
0080 },
0081 {
0082 namePattern: "*/EcalEndcapN*",
0083 editRules: [
0084 {pattern: "*/crystal*", action: EditActions.RemoveSiblings},
0085 ]
0086 },
0087 {
0088 namePattern: "*/EcalEndcapP_*",
0089 editRules: [
0090 {pattern: "*/EcalEndcapP_layer1_0*", action: EditActions.UnsetGeoBit, geoBit: GeoAttBits.kVisDaughters},
0091 {pattern: "*/EcalEndcapP_layer1_0*", action: EditActions.RemoveChildren},
0092 ]
0093 },
0094 {
0095 namePattern: "*/LFHCAL_*",
0096 editRules: [
0097 {pattern: "*/LFHCAL_8M*", action: EditActions.RemoveChildren},
0098 {pattern: "*/LFHCAL_8M*", action: EditActions.SetGeoBit, geoBit: GeoAttBits.kVisThis},
0099 {pattern: "*/LFHCAL_8M*", action: EditActions.UnsetGeoBit, geoBit: GeoAttBits.kVisNone},
0100 {pattern: "*/LFHCAL_8M*", action: EditActions.UnsetGeoBit, geoBit: GeoAttBits.kVisDaughters},
0101 {pattern: "*/LFHCAL_4M*", action: EditActions.RemoveChildren},
0102 {pattern: "*/LFHCAL_4M*", action: EditActions.SetGeoBit, geoBit: GeoAttBits.kVisThis},
0103 {pattern: "*/LFHCAL_4M*", action: EditActions.UnsetGeoBit, geoBit: GeoAttBits.kVisNone},
0104 {pattern: "*/LFHCAL_4M*", action: EditActions.UnsetGeoBit, geoBit: GeoAttBits.kVisDaughters},
0105 ]
0106 },
0107 {
0108 namePattern: "*/HcalEndcapPInsert_23*",
0109 editRules: [
0110 {pattern: "*/*layer*slice1_*", action: EditActions.RemoveSiblings},
0111 ]
0112 },
0113 {
0114 namePattern: "*/HcalBarrel*",
0115 editRules: [
0116 {pattern: "*/Tile*", action: EditActions.Remove},
0117 {pattern: "*/ChimneyTile*", action: EditActions.Remove},
0118 ]
0119 },
0120 {
0121 namePattern: "*/EndcapTOF*",
0122 editRules: [
0123 {pattern: "*/suppbar*", action: EditActions.Remove},
0124 {pattern: "*/component_hyb*", action: EditActions.Remove},
0125 ]
0126 },
0127 {
0128 namePattern: "*/BarrelTOF*",
0129 editRules: [
0130 {pattern: "*/component_sensor*", action: EditActions.Remove},
0131 {pattern: "*/component_ASIC*", action: EditActions.Remove},
0132 {pattern: "*/cooling*", action: EditActions.Remove},
0133 ]
0134 },
0135
0136 ]
0137
0138 public process(rootGeoManager:any):any {
0139
0140 // console.log("[RootGeometryProcessor] Filtered top level detectors: ", result);
0141 console.time(`[RootGeometryProcessor] Processing time`);
0142
0143 // >oO
0144 // analyzeGeoNodes(rootGeoManager, 1);
0145 // Now we go with the fine-tuning of each detector
0146 for(let detector of this.subDetectorsRules) {
0147 let topDetNode = findSingleGeoNode(rootGeoManager, detector.namePattern, 1);
0148 // console.log(`Processing ${topDetNode}`);
0149 if(!topDetNode) {
0150 continue;
0151 }
0152 // console.time(`[RootGeometryProcessor] Process sub-detector: ${detector.namePattern}`);
0153 for(let rule of detector.editRules) {
0154
0155 editGeoNodes(topDetNode, [rule])
0156 }
0157 // console.timeEnd(`[RootGeometryProcessor] Process sub-detector: ${detector.namePattern}`);
0158 }
0159
0160 console.timeEnd(`[RootGeometryProcessor] Processing time`);
0161 console.log(`[RootGeometryProcessor] Done processing ${this.subDetectorsRules.length} detectors`);
0162 }
0163 }