/** determine the best matching target beam position vector (x, y) */ public BeamPosition getMatchingTargetBeamPosition( final List<BpmAgent> xBpmAgents, final List<BpmAgent> yBpmAgents) throws Exception { // TODO: much has changed since the original code was written. X and Y should be abstracted to // avoid code duplication. final TransferMapProbe probe = getProbe(SEQUENCE); final Scenario scenario = getScenario(SEQUENCE, probe); scenario.resync(); scenario.run(); final Trajectory<TransferMapState> trajectory = scenario.getTrajectory(); final AcceleratorNode targetNode = SEQUENCE.getNodesOfType("Tgt").get(0); // @SuppressWarnings("unchecked") // final double[] xTargetBeamPositionAndError = // X_BEAM_POSITION_MATCHER.getMatchingTargetBeamPositionAndError( targetNode, xBpmAgents, // (Trajectory<TransferMapState>)trajectory ); final double[] xTargetBeamPositionAndError = X_BEAM_POSITION_MATCHER.getMatchingTargetBeamPositionAndError( targetNode, xBpmAgents, trajectory); final double xTargetPosition = xTargetBeamPositionAndError[0]; final double xTargetPositionError = xTargetBeamPositionAndError[1]; // @SuppressWarnings("unchecked") // final double[] yTargetBeamPositionAndError = // Y_BEAM_POSITION_MATCHER.getMatchingTargetBeamPositionAndError( targetNode, yBpmAgents, // (Trajectory<TransferMapState>)trajectory ); final double[] yTargetBeamPositionAndError = Y_BEAM_POSITION_MATCHER.getMatchingTargetBeamPositionAndError( targetNode, yBpmAgents, trajectory); final double yTargetPosition = yTargetBeamPositionAndError[0]; final double yTargetPositionError = yTargetBeamPositionAndError[1]; return new BeamPosition( xTargetPosition, xTargetPositionError, yTargetPosition, yTargetPositionError); }
protected static Scenario getScenario(final AcceleratorSeq sequence, final Probe<?> probe) throws Exception { final Scenario scenario = Scenario.newScenarioFor(sequence); scenario.setSynchronizationMode(Scenario.SYNC_MODE_RF_DESIGN); scenario.setStartNode("RTBT_Diag:BPM15"); scenario.setProbe(probe); return scenario; }
protected Trajectory<TransferMapState> calculateTrajectory(final AcceleratorSeq sequence) throws Exception { _sequence = sequence; final PVLoggerSnapshot snapshot = _snapshot; final Scenario scenario = getScenario(snapshot.getDataSource()); scenario.run(); final Trajectory<TransferMapState> trajectory = scenario.getTrajectory(); _trajectory = trajectory; return trajectory; }
/** get a scenario with the specified probe and data source */ protected Scenario getScenario(final TransferMapProbe probe, final PVLoggerDataSource dataSource) throws Exception { final Scenario scenario = Scenario.newScenarioFor(_sequence); scenario.setSynchronizationMode(Scenario.SYNC_MODE_DESIGN); final Scenario loggerScenario = dataSource.setModelSource(_sequence, scenario); loggerScenario.setStartNode("RTBT_Diag:BPM15"); loggerScenario.setProbe(probe); return loggerScenario; }