Back to home page

EIC code displayed by LXR

 
 

    


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: "*/EcalBarrelTracker*",
0060       editRules: [
0061         {pattern: "*", action: EditActions.SetGeoBit, geoBit: GeoAttBits.kVisDaughters},
0062         {pattern: "*/stave*", action: EditActions.RemoveChildren},
0063         {pattern: "*/stave*", action: EditActions.SetGeoBit, geoBit: GeoAttBits.kVisThis},
0064         {pattern: "*/stave*", action: EditActions.UnsetGeoBit, geoBit: GeoAttBits.kVisNone},
0065         {pattern: "*/stave*", action: EditActions.UnsetGeoBit, geoBit: GeoAttBits.kVisDaughters},
0066       ]
0067     },
0068     {
0069       namePattern: "*/EcalBarrelImaging*",
0070       editRules: [
0071         {pattern: "*/stav*", action: EditActions.RemoveChildren},
0072         {pattern: "*", action: EditActions.SetGeoBit, geoBit: GeoAttBits.kVisDaughters},
0073       ]
0074     },
0075     {
0076       namePattern: "*/DRICH*",
0077       editRules: [
0078         {pattern: "*/DRICH_cooling*", action: EditActions.RemoveSiblings},
0079       ]
0080     },
0081     {
0082       namePattern: "*/DIRC*",
0083       editRules: [
0084         {pattern: "*/Envelope_box*", action: EditActions.RemoveChildren},
0085         {pattern: "*/Envelope_box*", action: EditActions.SetGeoBit, geoBit: GeoAttBits.kVisThis},
0086         {pattern: "*/Envelope_box*", action: EditActions.UnsetGeoBit, geoBit: GeoAttBits.kVisNone},
0087         {pattern: "*/Envelope_box*", action: EditActions.UnsetGeoBit, geoBit: GeoAttBits.kVisDaughters},
0088         {pattern: "*/Envelope_lens_vol*", action: EditActions.Remove},
0089       ]
0090     },
0091     {
0092       namePattern: "*/EcalEndcapN*",
0093       editRules: [
0094         {pattern: "*/crystal*", action: EditActions.RemoveSiblings},
0095       ]
0096     },
0097     {
0098       namePattern: "*/EcalEndcapP_*",
0099       editRules: [
0100         {pattern: "*/EcalEndcapP_layer1_0*", action: EditActions.UnsetGeoBit, geoBit: GeoAttBits.kVisDaughters},
0101         {pattern: "*/EcalEndcapP_layer1_0*", action: EditActions.RemoveChildren},
0102       ]
0103     },
0104     {
0105       namePattern: "*/LFHCAL_*",
0106       editRules: [
0107         {pattern: "*/LFHCAL_8M*", action: EditActions.RemoveChildren},
0108         {pattern: "*/LFHCAL_8M*", action: EditActions.SetGeoBit, geoBit: GeoAttBits.kVisThis},
0109         {pattern: "*/LFHCAL_8M*", action: EditActions.UnsetGeoBit, geoBit: GeoAttBits.kVisNone},
0110         {pattern: "*/LFHCAL_8M*", action: EditActions.UnsetGeoBit, geoBit: GeoAttBits.kVisDaughters},
0111         {pattern: "*/LFHCAL_4M*", action: EditActions.RemoveChildren},
0112         {pattern: "*/LFHCAL_4M*", action: EditActions.SetGeoBit, geoBit: GeoAttBits.kVisThis},
0113         {pattern: "*/LFHCAL_4M*", action: EditActions.UnsetGeoBit, geoBit: GeoAttBits.kVisNone},
0114         {pattern: "*/LFHCAL_4M*", action: EditActions.UnsetGeoBit, geoBit: GeoAttBits.kVisDaughters},
0115       ]
0116     },
0117     {
0118       namePattern: "*/HcalEndcapPInsert_23*",
0119       editRules: [
0120         {pattern: "*/*layer*slice1_*", action: EditActions.RemoveSiblings},
0121       ]
0122     },
0123     {
0124       namePattern: "*/HcalBarrel*",
0125       editRules: [
0126         {pattern: "*/Tile*", action: EditActions.Remove},
0127         {pattern: "*/ChimneyTile*", action: EditActions.Remove},
0128       ]
0129     },
0130     {
0131       namePattern: "*/EndcapTOF*",
0132       editRules: [
0133         {pattern: "*/suppbar*", action: EditActions.Remove},
0134         {pattern: "*/component_hyb*", action: EditActions.Remove},
0135       ]
0136     },
0137     {
0138       namePattern: "*/VertexBarrelSubAssembly*",
0139       editRules: [
0140         {pattern: "*/biasing*", action: EditActions.Remove},
0141         {pattern: "*/readout*", action: EditActions.Remove},
0142         {pattern: "*/backbone*", action: EditActions.Remove},
0143       ]
0144 
0145     },
0146     {
0147       namePattern: "*/BarrelTOF*",
0148       editRules: [
0149         {pattern: "*/component_sensor*", action: EditActions.Remove},
0150         {pattern: "*/component_ASIC*", action: EditActions.Remove},
0151         {pattern: "*/cooling*", action: EditActions.Remove},
0152       ]
0153     },
0154     {
0155       namePattern: "*/BeamPipe_assembly*",
0156       editRules: [
0157         //{pattern: "*/*vacuum*", action: EditActions.Remove},
0158         {pattern: "*/*", action: EditActions.SetGeoBit, geoBit: GeoAttBits.kVisThis},
0159 
0160       ]
0161     },
0162 
0163     {
0164       namePattern: "*/LumiSpecCAL*",
0165       editRules: [
0166         {pattern: "*/module_vol*", action: EditActions.RemoveChildren}
0167       ]
0168     },
0169 
0170   ]
0171 
0172   public process(rootGeoManager:any):any {
0173 
0174     // console.log("[RootGeometryProcessor] Filtered top level detectors: ", result);
0175     console.time(`[RootGeometryProcessor] Processing time`);
0176 
0177     // >oO
0178     // analyzeGeoNodes(rootGeoManager, 1);
0179     // Now we go with the fine-tuning of each detector
0180     for(let detector of this.subDetectorsRules) {
0181       let topDetNode = findSingleGeoNode(rootGeoManager, detector.namePattern, 1);
0182       // console.log(`Processing ${topDetNode}`);
0183       if(!topDetNode) {
0184         continue;
0185       }
0186       // console.time(`[RootGeometryProcessor] Process sub-detector: ${detector.namePattern}`);
0187       for(let rule of detector.editRules) {
0188 
0189         editGeoNodes(topDetNode, [rule])
0190       }
0191       // console.timeEnd(`[RootGeometryProcessor] Process sub-detector: ${detector.namePattern}`);
0192     }
0193 
0194     console.timeEnd(`[RootGeometryProcessor] Processing time`);
0195     console.log(`[RootGeometryProcessor] Done processing ${this.subDetectorsRules.length} detectors`);
0196   }
0197 }