Author: [log in to unmask] Date: Wed Apr 13 12:42:42 2016 New Revision: 4340 Log: Merge in trunk changes to dev branch. Added: java/branches/jeremy-dev2/analysis/src/main/java/org/hps/analysis/trigger/ClusterDiagnosticModule.java - copied unchanged from r4339, java/trunk/analysis/src/main/java/org/hps/analysis/trigger/ClusterDiagnosticModule.java java/branches/jeremy-dev2/analysis/src/main/java/org/hps/analysis/trigger/DiagnosticsManagementDriver.java - copied unchanged from r4339, java/trunk/analysis/src/main/java/org/hps/analysis/trigger/DiagnosticsManagementDriver.java java/branches/jeremy-dev2/analysis/src/main/java/org/hps/analysis/trigger/PairTriggerDiagnosticModule.java - copied unchanged from r4339, java/trunk/analysis/src/main/java/org/hps/analysis/trigger/PairTriggerDiagnosticModule.java java/branches/jeremy-dev2/analysis/src/main/java/org/hps/analysis/trigger/SinglesTriggerDiagnosticModule.java - copied unchanged from r4339, java/trunk/analysis/src/main/java/org/hps/analysis/trigger/SinglesTriggerDiagnosticModule.java java/branches/jeremy-dev2/detector-data/detectors/HPS-EngRun2015-1_5mm-v3-4-fieldmap/HPS-EngRun2015-1_5mm-v3-4-fieldmap.lcdd - copied unchanged from r4339, java/trunk/detector-data/detectors/HPS-EngRun2015-1_5mm-v3-4-fieldmap/HPS-EngRun2015-1_5mm-v3-4-fieldmap.lcdd java/branches/jeremy-dev2/steering-files/src/main/resources/org/hps/steering/readout/PhysicsRun2016TrigPair0.lcsim - copied unchanged from r4339, java/trunk/steering-files/src/main/resources/org/hps/steering/readout/PhysicsRun2016TrigPair0.lcsim Modified: java/branches/jeremy-dev2/ (props changed) java/branches/jeremy-dev2/analysis/pom.xml java/branches/jeremy-dev2/analysis/src/main/java/org/hps/analysis/trigger/SimTriggerData.java java/branches/jeremy-dev2/analysis/src/main/java/org/hps/analysis/trigger/SimTriggerModule.java java/branches/jeremy-dev2/analysis/src/main/java/org/hps/analysis/trigger/util/PairTrigger.java java/branches/jeremy-dev2/analysis/src/main/java/org/hps/analysis/trigger/util/SinglesTrigger.java java/branches/jeremy-dev2/analysis/src/main/java/org/hps/analysis/trigger/util/Trigger.java java/branches/jeremy-dev2/conditions/ (props changed) java/branches/jeremy-dev2/conditions/pom.xml java/branches/jeremy-dev2/conditions/src/main/java/org/hps/conditions/database/DatabaseConditionsManager.java java/branches/jeremy-dev2/crawler/pom.xml java/branches/jeremy-dev2/detector-data/pom.xml java/branches/jeremy-dev2/detector-model/pom.xml java/branches/jeremy-dev2/distribution/ (props changed) java/branches/jeremy-dev2/distribution/pom.xml java/branches/jeremy-dev2/ecal-event-display/pom.xml java/branches/jeremy-dev2/ecal-readout-sim/pom.xml java/branches/jeremy-dev2/ecal-recon/pom.xml java/branches/jeremy-dev2/evio/pom.xml java/branches/jeremy-dev2/evio/src/main/java/org/hps/evio/LCSimEngRunEventBuilder.java java/branches/jeremy-dev2/integration-tests/src/test/java/org/hps/test/it/ReconSteeringTest.java java/branches/jeremy-dev2/job/pom.xml java/branches/jeremy-dev2/logging/pom.xml java/branches/jeremy-dev2/logging/src/main/resources/org/hps/logging/config/logging.properties java/branches/jeremy-dev2/logging/src/main/resources/org/hps/logging/config/test_logging.properties java/branches/jeremy-dev2/monitoring-app/ (props changed) java/branches/jeremy-dev2/monitoring-app/pom.xml java/branches/jeremy-dev2/monitoring-drivers/pom.xml java/branches/jeremy-dev2/monitoring-util/pom.xml java/branches/jeremy-dev2/parent/pom.xml java/branches/jeremy-dev2/plugin/pom.xml java/branches/jeremy-dev2/pom.xml java/branches/jeremy-dev2/recon/pom.xml java/branches/jeremy-dev2/recon/src/main/java/org/hps/recon/particle/HpsReconParticleDriver.java java/branches/jeremy-dev2/recon/src/main/java/org/hps/recon/particle/ReconParticleDriver.java java/branches/jeremy-dev2/recon/src/main/java/org/hps/recon/vertexing/BilliorVertexer.java java/branches/jeremy-dev2/record-util/pom.xml java/branches/jeremy-dev2/record-util/src/main/java/org/hps/record/triggerbank/SSPNumberedTrigger.java java/branches/jeremy-dev2/record-util/src/main/java/org/hps/record/triggerbank/SSPPairTrigger.java java/branches/jeremy-dev2/record-util/src/main/java/org/hps/record/triggerbank/SSPSinglesTrigger.java java/branches/jeremy-dev2/record-util/src/main/java/org/hps/record/triggerbank/TriggerModule.java java/branches/jeremy-dev2/run-database/pom.xml java/branches/jeremy-dev2/run-database/src/main/java/org/hps/run/database/RunManager.java java/branches/jeremy-dev2/steering-files/pom.xml java/branches/jeremy-dev2/tracking/pom.xml java/branches/jeremy-dev2/users/pom.xml java/branches/jeremy-dev2/util/pom.xml Modified: java/branches/jeremy-dev2/analysis/pom.xml ============================================================================= --- java/branches/jeremy-dev2/analysis/pom.xml (original) +++ java/branches/jeremy-dev2/analysis/pom.xml Wed Apr 13 12:42:42 2016 @@ -8,7 +8,7 @@ <groupId>org.hps</groupId> <artifactId>hps-parent</artifactId> <relativePath>../parent/pom.xml</relativePath> - <version>3.8-SNAPSHOT</version> + <version>3.9-SNAPSHOT</version> </parent> <scm> <url>http://java.freehep.org/svn/repos/hps/list/java/trunk/analysis/</url> Modified: java/branches/jeremy-dev2/analysis/src/main/java/org/hps/analysis/trigger/SimTriggerData.java ============================================================================= --- java/branches/jeremy-dev2/analysis/src/main/java/org/hps/analysis/trigger/SimTriggerData.java (original) +++ java/branches/jeremy-dev2/analysis/src/main/java/org/hps/analysis/trigger/SimTriggerData.java Wed Apr 13 12:42:42 2016 @@ -7,34 +7,35 @@ * Class <code>SimTriggerData</code> is a container class that holds * simulated trigger data modules. It is intended to be placed in the * LCIO data stream by the <code>DataTriggerSimDriver</code> to allow - * other classes to access triggers simulated from SSP and reconstructed + * other classes to access triggers simulated from hardware and software * cluster data. * * @author Kyle McCarty <[log in to unmask]> */ public class SimTriggerData { - private final SimTriggerModule<Cluster> reconTriggers; - private final SimTriggerModule<SSPCluster> sspTriggers; + private final SimTriggerModule<Cluster> softwareClusterTriggers; + private final SimTriggerModule<SSPCluster> hardwareClusterTriggers; /** * Instantiates a new <code>SimTriggerData</code> object with empty * trigger results modules. */ SimTriggerData() { - reconTriggers = new SimTriggerModule<Cluster>(); - sspTriggers = new SimTriggerModule<SSPCluster>(); + softwareClusterTriggers = new SimTriggerModule<Cluster>(); + hardwareClusterTriggers = new SimTriggerModule<SSPCluster>(); } /** * Instantiates a new <code>SimTriggerData</code> object that will * contain the argument trigger modules. - * @param reconTriggers - The simulated reconstructed cluster - * triggers module. - * @param sspTriggers - The simulated SSP cluster triggers module. + * @param softwareClusterTriggers - The module containing triggers + * simulated from software simulated clusters. + * @param hardwareClusterTriggers - The module containing triggers + * simulated from hardware reported clusters. */ - SimTriggerData(SimTriggerModule<Cluster> reconTriggers, SimTriggerModule<SSPCluster> sspTriggers) { - this.reconTriggers = reconTriggers; - this.sspTriggers = sspTriggers; + SimTriggerData(SimTriggerModule<Cluster> softwareClusterTriggers, SimTriggerModule<SSPCluster> hardwareClusterTriggers) { + this.softwareClusterTriggers = softwareClusterTriggers; + this.hardwareClusterTriggers = hardwareClusterTriggers; } /** @@ -43,8 +44,9 @@ * @return Returns the trigger data in a <code>SimTriggerModule</code> * object. */ + @Deprecated public SimTriggerModule<SSPCluster> getSimSSPTriggers() { - return sspTriggers; + return hardwareClusterTriggers; } /** @@ -53,7 +55,28 @@ * @return Returns the trigger data in a <code>SimTriggerModule</code> * object. */ + @Deprecated public SimTriggerModule<Cluster> getSimReconTriggers() { - return reconTriggers; + return softwareClusterTriggers; + } + + /** + * Gets the module containing all triggers simulated from hardware + * reported clusters for each of the four production triggers. + * @return Returns the trigger data in a <code>SimTriggerModule</code> + * object. + */ + public SimTriggerModule<SSPCluster> getSimHardwareClusterTriggers() { + return hardwareClusterTriggers; + } + + /** + * Gets the module containing all triggers simulated from software + * simulated clusters for each of the four production triggers. + * @return Returns the trigger data in a <code>SimTriggerModule</code> + * object. + */ + public SimTriggerModule<Cluster> getSimSoftwareClusterTriggers() { + return softwareClusterTriggers; } } Modified: java/branches/jeremy-dev2/analysis/src/main/java/org/hps/analysis/trigger/SimTriggerModule.java ============================================================================= --- java/branches/jeremy-dev2/analysis/src/main/java/org/hps/analysis/trigger/SimTriggerModule.java (original) +++ java/branches/jeremy-dev2/analysis/src/main/java/org/hps/analysis/trigger/SimTriggerModule.java Wed Apr 13 12:42:42 2016 @@ -51,6 +51,28 @@ } /** + * Gets the simulated trigger results for the indicated singles + * trigger. Note that only inputs of <code>0</code> and <code>1</code> + * are allowed. + * @param triggerNumber - A value of either <code>0</code>, to + * obtain the singles 0 trigger results, or <code>1</code>, to + * obtain the singles 1 trigger results. + * @return Returns the trigger results as a <code>List</code> of + * <code>SinglesTrigger</code> objects. + * @throws IllegalArgumentException Occurs if the input argument + * is not either <code>0</code> or <code>1</code>. + */ + public List<SinglesTrigger<E>> getSinglesTriggers(int triggerNumber) { + // Return the appropriate trigger list. + if(triggerNumber == 0) { return getSingles0Triggers(); } + else if(triggerNumber == 1) { return getSingles1Triggers(); } + + // Any other trigger number is not valid and should produce an + // exception. + throw new IllegalArgumentException("Trigger number " + triggerNumber + " is not valid."); + } + + /** * Gets the simulated trigger results for the singles 0 trigger. * @return Returns the trigger results as a <code>List</code> of * <code>SinglesTrigger</code> objects. @@ -66,6 +88,28 @@ */ public List<SinglesTrigger<E>> getSingles1Triggers() { return singles1; + } + + /** + * Gets the simulated trigger results for the indicated pair trigger. + * Note that only inputs of <code>0</code> and <code>1</code> are + * allowed. + * @param triggerNumber - A value of either <code>0</code>, to + * obtain the pair 0 trigger results, or <code>1</code>, to obtain + * the pair 1 trigger results. + * @return Returns the trigger results as a <code>List</code> of + * <code>PairTrigger</code> objects. + * @throws IllegalArgumentException Occurs if the input argument + * is not either <code>0</code> or <code>1</code>. + */ + public List<PairTrigger<E[]>> getPairTriggers(int triggerNumber) { + // Return the appropriate trigger list. + if(triggerNumber == 0) { return getPair0Triggers(); } + else if(triggerNumber == 1) { return getPair1Triggers(); } + + // Any other trigger number is not valid and should produce an + // exception. + throw new IllegalArgumentException("Trigger number " + triggerNumber + " is not valid."); } /** @@ -85,4 +129,4 @@ public List<PairTrigger<E[]>> getPair1Triggers() { return pair1; } -} +} Modified: java/branches/jeremy-dev2/analysis/src/main/java/org/hps/analysis/trigger/util/PairTrigger.java ============================================================================= --- java/branches/jeremy-dev2/analysis/src/main/java/org/hps/analysis/trigger/util/PairTrigger.java (original) +++ java/branches/jeremy-dev2/analysis/src/main/java/org/hps/analysis/trigger/util/PairTrigger.java Wed Apr 13 12:42:42 2016 @@ -163,4 +163,4 @@ getStateEnergySumHigh() ? 1 : 0, getStateEnergyDifference() ? 1 : 0, getStateEnergySlope() ? 1 : 0, getStateCoplanarity() ? 1 : 0); } -} +} Modified: java/branches/jeremy-dev2/analysis/src/main/java/org/hps/analysis/trigger/util/SinglesTrigger.java ============================================================================= --- java/branches/jeremy-dev2/analysis/src/main/java/org/hps/analysis/trigger/util/SinglesTrigger.java (original) +++ java/branches/jeremy-dev2/analysis/src/main/java/org/hps/analysis/trigger/util/SinglesTrigger.java Wed Apr 13 12:42:42 2016 @@ -150,4 +150,4 @@ getStateClusterEnergyLow() ? 1 : 0, getStateClusterEnergyHigh() ? 1 : 0, getStateHitCount() ? 1 : 0); } -} +} Modified: java/branches/jeremy-dev2/analysis/src/main/java/org/hps/analysis/trigger/util/Trigger.java ============================================================================= --- java/branches/jeremy-dev2/analysis/src/main/java/org/hps/analysis/trigger/util/Trigger.java (original) +++ java/branches/jeremy-dev2/analysis/src/main/java/org/hps/analysis/trigger/util/Trigger.java Wed Apr 13 12:42:42 2016 @@ -149,4 +149,4 @@ protected boolean supportsCut(String cut) { return passMap.containsKey(cut); } -} +} Modified: java/branches/jeremy-dev2/conditions/pom.xml ============================================================================= --- java/branches/jeremy-dev2/conditions/pom.xml (original) +++ java/branches/jeremy-dev2/conditions/pom.xml Wed Apr 13 12:42:42 2016 @@ -8,7 +8,7 @@ <groupId>org.hps</groupId> <artifactId>hps-parent</artifactId> <relativePath>../parent/pom.xml</relativePath> - <version>3.8-SNAPSHOT</version> + <version>3.9-SNAPSHOT</version> </parent> <scm> <url>http://java.freehep.org/svn/repos/hps/list/java/trunk/conditions/</url> @@ -51,6 +51,7 @@ <dependency> <groupId>org.hps</groupId> <artifactId>hps-detector-data</artifactId> + <scope>runtime</scope> </dependency> <dependency> <groupId>org.hps</groupId> @@ -60,6 +61,7 @@ <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> + <scope>runtime</scope> </dependency> <dependency> <groupId>org.reflections</groupId> Modified: java/branches/jeremy-dev2/conditions/src/main/java/org/hps/conditions/database/DatabaseConditionsManager.java ============================================================================= --- java/branches/jeremy-dev2/conditions/src/main/java/org/hps/conditions/database/DatabaseConditionsManager.java (original) +++ java/branches/jeremy-dev2/conditions/src/main/java/org/hps/conditions/database/DatabaseConditionsManager.java Wed Apr 13 12:42:42 2016 @@ -9,7 +9,6 @@ import java.io.IOException; import java.io.InputStream; import java.sql.Connection; -import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; @@ -49,10 +48,8 @@ import org.lcsim.util.loop.DetectorConditionsConverter; /** - * <p> * This class provides the top-level API for accessing database conditions, as well as configuring the database - * connection, initializing all required components, and loading required converters and table meta data. It is - * registered as the global <code>ConditionsManager</code> in the constructor. + * connection, initializing all required components, and loading required converters and table meta data. * <p> * Differences between Test Run and Engineering Run configurations are handled automatically. * @@ -80,7 +77,6 @@ + DEFAULT_DATABASE + "?" + "user=" + DEFAULT_USER + "&" + "password=" + DEFAULT_PASSWORD; - // + "max-connections=" + DEFAULT_MAX_CONNECTIONS + "&" /** * Name of system property that can be used to specify custom database connection parameters in a file. @@ -113,7 +109,7 @@ private static final int TEST_RUN_MAX_RUN = 1365; /** - * Data source initialized with default settings. + * The underlying SQL <code>DataSource</code> used to create a database connection. */ private DataSource dataSource; @@ -123,12 +119,7 @@ private Connection connection; /** - * True to cache all known conditions sets (from keys) during initialization. - */ - private boolean cacheAllConditions = false; - - /** - * The current set of conditions for the run. + * The current set of conditions records for the run. */ private ConditionsRecordCollection conditionsRecordCollection = null; @@ -138,7 +129,7 @@ private final ConditionsTagCollection conditionsTagCollection = new ConditionsTagCollection(); /** - * Create the global registry of conditions object converters. + * The global registry of conditions object converters. */ private final ConverterRegistry converters = ConverterRegistry.create(); @@ -148,7 +139,7 @@ private ConditionsConverter ecalConverter; /** - * The default ECAL detector name in the detector geometry. + * The ECAL detector name in the detector geometry. */ private String ecalName = "Ecal"; @@ -207,7 +198,6 @@ * @return the <code>DataSource</code> for connecting to the conditions database */ private static DataSource createDefaultDataSource() { - LOGGER.info("creating default data source"); return createDataSource(DEFAULT_CONNECTION_URI); } @@ -233,23 +223,18 @@ } if (properties.containsKey("user")) { user = properties.getProperty("user"); - LOGGER.info("user prop = " + user); } if (properties.containsKey("password")) { password = properties.getProperty("password"); - LOGGER.info("password prop = " + password); } if (properties.containsKey("hostname")) { host = properties.getProperty("hostname"); - LOGGER.info("host prop = " + host); } if (properties.containsKey("port")) { port = Integer.parseInt(properties.getProperty("port")); - LOGGER.info("port prop = " + port); } if (properties.containsKey("database")) { database = properties.getProperty("database"); - LOGGER.info("database prop = " + database); } String connectionUri = "jdbc:mysql://" + host + ":" + port + "/" @@ -257,9 +242,8 @@ + "user=" + user + "&" + "password=" + password; - LOGGER.info("returning db connection URL " + connectionUri); - - // + "max-connections=" + DEFAULT_MAX_CONNECTIONS + "&" + LOGGER.info("Conditions database URI " + connectionUri); + return connectionUri; } @@ -303,6 +287,7 @@ /** * Reset the global static instance of the conditions manager to a new object. */ + // FIXME: Not even sure this method should exist! --JM public static synchronized void resetInstance() { // Create a new instance if necessary, which will install it globally as the default. @@ -311,7 +296,7 @@ // Register default conditions manager. ConditionsManager.setDefaultConditionsManager(dbManager); - LOGGER.info("DatabaseConditionsManager instance is reset"); + LOGGER.info("DatabaseConditionsManager instance is now reset."); } /** @@ -330,7 +315,6 @@ // Create the default data source if alternate connection info was not provided. if (this.dataSource == null) { - LOGGER.fine("creating default data source"); dataSource = createDefaultDataSource(); } @@ -352,17 +336,17 @@ */ public void addTag(final String tag) { if (!this.tags.contains(tag)) { - LOGGER.info("adding tag " + tag); + LOGGER.config("Using conditions tag " + tag); final ConditionsTagCollection findConditionsTag = this.getCachedConditions(ConditionsTagCollection.class, tag).getCachedData(); if (findConditionsTag.size() == 0) { throw new IllegalArgumentException("The tag " + tag + " does not exist in the database."); } - LOGGER.info("adding conditions tag " + tag + " with " + conditionsTagCollection.size() + " records"); + LOGGER.config("Using conditions tag " + tag + " with " + conditionsTagCollection.size() + " records"); this.conditionsTagCollection.addAll(findConditionsTag); this.tags.add(tag); } else { - LOGGER.warning("tag " + tag + " is already added"); + LOGGER.warning("Tag " + tag + " is already being used."); } } @@ -380,10 +364,11 @@ /** * Cache conditions sets for all known tables. */ + /* private void cacheConditionsSets() { for (final TableMetaData meta : this.tableRegistry.values()) { try { - LOGGER.fine("caching conditions " + meta.getKey() + " with type " + LOGGER.fine("Caching conditions " + meta.getKey() + " with type " + meta.getCollectionClass().getCanonicalName()); this.getCachedConditions(meta.getCollectionClass(), meta.getKey()); } catch (final Exception e) { @@ -391,6 +376,7 @@ } } } + */ /** * Clear the tags used to filter the {@link org.hps.conditions.api.ConditionsRecord}s. @@ -480,9 +466,10 @@ public synchronized void freeze() { if (this.getDetector() != null && this.getRun() != -1) { this.isFrozen = true; - LOGGER.config("conditions system is frozen"); + LOGGER.config("Conditions system is frozen."); } else { - LOGGER.warning("conditions system cannot be frozen because it is not initialized yet"); + // FIXME: Should this throw an exception instead? + LOGGER.warning("Conditions system cannot be frozen because it is not initialized."); } } @@ -501,7 +488,7 @@ * @return the set of available conditions tags */ public Set<String> getAvailableTags() { - LOGGER.fine("getting list of available conditions tags"); + LOGGER.fine("Fetching list of available conditions tags ..."); final Set<String> tags = new LinkedHashSet<String>(); Statement statement = null; ResultSet resultSet = null; @@ -519,7 +506,7 @@ } final StringBuffer sb = new StringBuffer(); - sb.append("found unique conditions tags: "); + sb.append("Found conditions tags: "); for (final String tag : tags) { sb.append(tag + " "); } @@ -537,8 +524,6 @@ */ public synchronized int getCollectionId(final ConditionsObjectCollection<?> collection, final String description) throws SQLException { - - final String caller = Thread.currentThread().getStackTrace()[2].getClassName(); final String log = "created by " + System.getProperty("user.name") + " using " + caller.substring(caller.lastIndexOf('.') + 1); @@ -585,6 +570,7 @@ if (this.run == -1 || this.detectorName == null) { throw new IllegalStateException("Conditions system is not initialized."); } + // If the collection is null then the new conditions records need to be retrieved from the database. if (this.conditionsRecordCollection == null) { @@ -637,14 +623,10 @@ * @return the JDBC connection */ public Connection getConnection() { - LOGGER.info("getting db connection"); try { if (this.connection == null || this.connection.isClosed()) { - LOGGER.info("creating new db connection"); connection = dataSource.getConnection(); - } else { - LOGGER.info("using existing connection"); - } + } } catch (SQLException e) { throw new RuntimeException(e); } @@ -746,27 +728,17 @@ this.conditionsRecordCollection = null; // Call the super class's setDetector method to construct the detector object and activate conditions listeners. - LOGGER.fine("calling set detector"); super.setDetector(detectorName, runNumber); - LOGGER.fine("done calling set detector"); - - // Should all conditions sets be cached? - if (this.cacheAllConditions) { - // Cache the conditions sets of all registered converters. - LOGGER.fine("caching conditions sets"); - this.cacheConditionsSets(); - } - + // Should the conditions system be frozen now? if (this.freezeAfterInitialize) { // Freeze the conditions system so subsequent updates will be ignored. this.freeze(); - LOGGER.config("system was frozen after initialization"); } this.isInitialized = true; - LOGGER.info("Conditions system initialized successfully."); + LOGGER.info("Conditions system was initialized successfully."); } /** @@ -833,23 +805,10 @@ LOGGER.config("freezeAfterInitialize = " + this.freezeAfterInitialize); } - element = node.getChild("cacheAllCondition"); - if (element != null) { - this.cacheAllConditions = Boolean.parseBoolean(element.getText()); - LOGGER.config("cacheAllConditions = " + this.cacheAllConditions); - } - element = node.getChild("isTestRun"); if (element != null) { this.isTestRun = Boolean.parseBoolean(element.getText()); LOGGER.config("isTestRun = " + this.isTestRun); - } - - element = node.getChild("loginTimeout"); - if (element != null) { - final Integer timeout = Integer.parseInt(element.getText()); - DriverManager.setLoginTimeout(timeout); - LOGGER.config("loginTimeout = " + timeout); } } @@ -877,6 +836,7 @@ // Load the default converters. this.svtConverter = new SvtConditionsConverter(); this.ecalConverter = new EcalConditionsConverter(); + LOGGER.config("registering default conditions converters"); } this.registerConditionsConverter(this.svtConverter); this.registerConditionsConverter(this.ecalConverter); @@ -928,7 +888,7 @@ if (!this.isInitialized || !detectorName.equals(this.getDetector()) || runNumber != this.getRun()) { if (!this.isFrozen) { - LOGGER.info("new detector " + detectorName + " and run #" + runNumber); + LOGGER.info("New detector " + detectorName + " and run " + runNumber); this.initialize(detectorName, runNumber); } else { LOGGER.finest("Conditions changed but will be ignored because manager is frozen."); @@ -975,7 +935,7 @@ + " does not exist."); } this.setConnectionProperties(f); - LOGGER.info("connection setup from system property " + CONNECTION_PROPERTY_FILE + " = " + LOGGER.info("Connection was setup from system property " + CONNECTION_PROPERTY_FILE + " = " + systemPropertiesConnectionPath); } } @@ -989,7 +949,7 @@ CONNECTION_PROPERTY_RESOURCE); if (systemPropertiesConnectionResource != null) { this.setConnectionResource(systemPropertiesConnectionResource); - LOGGER.info("connection setup from system property " + CONNECTION_PROPERTY_FILE + " = " + LOGGER.info("Connection was setup from system property " + CONNECTION_PROPERTY_FILE + " = " + systemPropertiesConnectionResource); } } @@ -1027,6 +987,6 @@ */ public synchronized void unfreeze() { this.isFrozen = false; - LOGGER.info("conditions system unfrozen"); + LOGGER.info("Conditions system was unfrozen."); } } Modified: java/branches/jeremy-dev2/crawler/pom.xml ============================================================================= --- java/branches/jeremy-dev2/crawler/pom.xml (original) +++ java/branches/jeremy-dev2/crawler/pom.xml Wed Apr 13 12:42:42 2016 @@ -7,7 +7,7 @@ <groupId>org.hps</groupId> <artifactId>hps-parent</artifactId> <relativePath>../parent/pom.xml</relativePath> - <version>3.8-SNAPSHOT</version> + <version>3.9-SNAPSHOT</version> </parent> <scm> <url>http://java.freehep.org/svn/repos/hps/list/java/trunk/crawler/</url> Modified: java/branches/jeremy-dev2/detector-data/pom.xml ============================================================================= --- java/branches/jeremy-dev2/detector-data/pom.xml (original) +++ java/branches/jeremy-dev2/detector-data/pom.xml Wed Apr 13 12:42:42 2016 @@ -8,7 +8,7 @@ <groupId>org.hps</groupId> <artifactId>hps-parent</artifactId> <relativePath>../parent/pom.xml</relativePath> - <version>3.8-SNAPSHOT</version> + <version>3.9-SNAPSHOT</version> </parent> <scm> <url>http://java.freehep.org/svn/repos/hps/list/java/trunk/detector-data/</url> Modified: java/branches/jeremy-dev2/detector-model/pom.xml ============================================================================= --- java/branches/jeremy-dev2/detector-model/pom.xml (original) +++ java/branches/jeremy-dev2/detector-model/pom.xml Wed Apr 13 12:42:42 2016 @@ -8,7 +8,7 @@ <groupId>org.hps</groupId> <artifactId>hps-parent</artifactId> <relativePath>../parent/pom.xml</relativePath> - <version>3.8-SNAPSHOT</version> + <version>3.9-SNAPSHOT</version> </parent> <build> <plugins> Modified: java/branches/jeremy-dev2/distribution/pom.xml ============================================================================= --- java/branches/jeremy-dev2/distribution/pom.xml (original) +++ java/branches/jeremy-dev2/distribution/pom.xml Wed Apr 13 12:42:42 2016 @@ -13,7 +13,7 @@ <groupId>org.hps</groupId> <artifactId>hps-parent</artifactId> <relativePath>../parent/pom.xml</relativePath> - <version>3.8-SNAPSHOT</version> + <version>3.9-SNAPSHOT</version> </parent> <scm> <url>http://java.freehep.org/svn/repos/hps/list/java/trunk/distribution/</url> Modified: java/branches/jeremy-dev2/ecal-event-display/pom.xml ============================================================================= --- java/branches/jeremy-dev2/ecal-event-display/pom.xml (original) +++ java/branches/jeremy-dev2/ecal-event-display/pom.xml Wed Apr 13 12:42:42 2016 @@ -7,7 +7,7 @@ <groupId>org.hps</groupId> <artifactId>hps-parent</artifactId> <relativePath>../parent/pom.xml</relativePath> - <version>3.8-SNAPSHOT</version> + <version>3.9-SNAPSHOT</version> </parent> <scm> <url>http://java.freehep.org/svn/repos/hps/list/java/trunk/ecal-event-display/</url> Modified: java/branches/jeremy-dev2/ecal-readout-sim/pom.xml ============================================================================= --- java/branches/jeremy-dev2/ecal-readout-sim/pom.xml (original) +++ java/branches/jeremy-dev2/ecal-readout-sim/pom.xml Wed Apr 13 12:42:42 2016 @@ -8,7 +8,7 @@ <groupId>org.hps</groupId> <artifactId>hps-parent</artifactId> <relativePath>../parent/pom.xml</relativePath> - <version>3.8-SNAPSHOT</version> + <version>3.9-SNAPSHOT</version> </parent> <scm> <url>http://java.freehep.org/svn/repos/hps/list/java/trunk/ecal-readout-sim/</url> Modified: java/branches/jeremy-dev2/ecal-recon/pom.xml ============================================================================= --- java/branches/jeremy-dev2/ecal-recon/pom.xml (original) +++ java/branches/jeremy-dev2/ecal-recon/pom.xml Wed Apr 13 12:42:42 2016 @@ -8,7 +8,7 @@ <groupId>org.hps</groupId> <artifactId>hps-parent</artifactId> <relativePath>../parent/pom.xml</relativePath> - <version>3.8-SNAPSHOT</version> + <version>3.9-SNAPSHOT</version> </parent> <scm> <url>http://java.freehep.org/svn/repos/hps/list/java/trunk/ecal-recon/</url> Modified: java/branches/jeremy-dev2/evio/pom.xml ============================================================================= --- java/branches/jeremy-dev2/evio/pom.xml (original) +++ java/branches/jeremy-dev2/evio/pom.xml Wed Apr 13 12:42:42 2016 @@ -8,7 +8,7 @@ <groupId>org.hps</groupId> <artifactId>hps-parent</artifactId> <relativePath>../parent/pom.xml</relativePath> - <version>3.8-SNAPSHOT</version> + <version>3.9-SNAPSHOT</version> </parent> <scm> <url>http://java.freehep.org/svn/repos/hps/list/java/trunk/evio/</url> Modified: java/branches/jeremy-dev2/evio/src/main/java/org/hps/evio/LCSimEngRunEventBuilder.java ============================================================================= --- java/branches/jeremy-dev2/evio/src/main/java/org/hps/evio/LCSimEngRunEventBuilder.java (original) +++ java/branches/jeremy-dev2/evio/src/main/java/org/hps/evio/LCSimEngRunEventBuilder.java Wed Apr 13 12:42:42 2016 @@ -121,6 +121,14 @@ } else { LOGGER.info("Run manager is not initialized; TI time offset not available."); } + /* Make sure connection is closed immediately. --JM */ + try { + LOGGER.info("Closing run manager db connection ..."); + RunManager.getRunManager().closeConnection(); + LOGGER.info("Run manager db connection was closed."); + } catch (Exception e) { + e.printStackTrace(); + } } /** @@ -162,7 +170,11 @@ LOGGER.finest("created new LCSim event " + lcsimEvent.getEventNumber()); // Put DAQ Configuration info into lcsimEvent. - triggerConfigReader.getDAQConfig(evioEvent, lcsimEvent); + try { + triggerConfigReader.getDAQConfig(evioEvent, lcsimEvent); + } catch (final Exception e) { + LOGGER.log(Level.SEVERE,"DAQ CONFIG BROKEN.",e); + } // Make RawCalorimeterHit collection, combining top and bottom section // of ECal into one list. Modified: java/branches/jeremy-dev2/integration-tests/src/test/java/org/hps/test/it/ReconSteeringTest.java ============================================================================= --- java/branches/jeremy-dev2/integration-tests/src/test/java/org/hps/test/it/ReconSteeringTest.java (original) +++ java/branches/jeremy-dev2/integration-tests/src/test/java/org/hps/test/it/ReconSteeringTest.java Wed Apr 13 12:42:42 2016 @@ -28,7 +28,7 @@ job.addVariableDefinition("outputFile", outputFile.getPath()); job.addInputFile(inputFile); job.setup(STEERING_RESOURCE); - job.setNumberOfEvents(1000); + job.setNumberOfEvents(2); job.run(); System.out.println("Done processing " + job.getLCSimLoop().getTotalCountableConsumed() + " events."); Modified: java/branches/jeremy-dev2/job/pom.xml ============================================================================= --- java/branches/jeremy-dev2/job/pom.xml (original) +++ java/branches/jeremy-dev2/job/pom.xml Wed Apr 13 12:42:42 2016 @@ -7,7 +7,7 @@ <groupId>org.hps</groupId> <artifactId>hps-parent</artifactId> <relativePath>../parent/pom.xml</relativePath> - <version>3.8-SNAPSHOT</version> + <version>3.9-SNAPSHOT</version> </parent> <scm> <url>http://java.freehep.org/svn/repos/hps/list/java/trunk/job/</url> Modified: java/branches/jeremy-dev2/logging/pom.xml ============================================================================= --- java/branches/jeremy-dev2/logging/pom.xml (original) +++ java/branches/jeremy-dev2/logging/pom.xml Wed Apr 13 12:42:42 2016 @@ -7,7 +7,7 @@ <groupId>org.hps</groupId> <artifactId>hps-parent</artifactId> <relativePath>../parent/pom.xml</relativePath> - <version>3.8-SNAPSHOT</version> + <version>3.9-SNAPSHOT</version> </parent> <scm> <url>http://java.freehep.org/svn/repos/hps/list/java/trunk/logging/</url> Modified: java/branches/jeremy-dev2/logging/src/main/resources/org/hps/logging/config/logging.properties ============================================================================= --- java/branches/jeremy-dev2/logging/src/main/resources/org/hps/logging/config/logging.properties (original) +++ java/branches/jeremy-dev2/logging/src/main/resources/org/hps/logging/config/logging.properties Wed Apr 13 12:42:42 2016 @@ -18,12 +18,12 @@ java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter # turn minuit logging off -org.freehep.math.minuit = OFF +org.freehep.math.minuit.level = OFF # lcsim job org.lcsim.job.level = CONFIG org.lcsim.job.EventMarkerDriver.level = ALL -org.lcsim.job.EventPrintLoopAdapter = ALL +org.lcsim.job.EventPrintLoopAdapter.level = ALL # conditions org.hps.conditions.api.level = WARNING Modified: java/branches/jeremy-dev2/logging/src/main/resources/org/hps/logging/config/test_logging.properties ============================================================================= --- java/branches/jeremy-dev2/logging/src/main/resources/org/hps/logging/config/test_logging.properties (original) +++ java/branches/jeremy-dev2/logging/src/main/resources/org/hps/logging/config/test_logging.properties Wed Apr 13 12:42:42 2016 @@ -18,16 +18,16 @@ java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter # turn minuit off -org.freehep.math.minuit = OFF +org.freehep.math.minuit.level = OFF # lcsim job org.lcsim.job.level = CONFIG org.lcsim.job.EventMarkerDriver.level = OFF -org.lcsim.job.EventPrintLoopAdapter = ALL +org.lcsim.job.EventPrintLoopAdapter.level = ALL # conditions -org.hps.conditions.api.level = WARNING -org.hps.conditions.database.level = WARNING +org.hps.conditions.api.level = ALL +org.hps.conditions.database.level = ALL org.hps.conditions.cli.level = WARNING org.hps.conditions.ecal.level = WARNING org.hps.conditions.svt.level = WARNING Modified: java/branches/jeremy-dev2/monitoring-app/pom.xml ============================================================================= --- java/branches/jeremy-dev2/monitoring-app/pom.xml (original) +++ java/branches/jeremy-dev2/monitoring-app/pom.xml Wed Apr 13 12:42:42 2016 @@ -7,7 +7,7 @@ <groupId>org.hps</groupId> <artifactId>hps-parent</artifactId> <relativePath>../parent/pom.xml</relativePath> - <version>3.8-SNAPSHOT</version> + <version>3.9-SNAPSHOT</version> </parent> <scm> <url>http://java.freehep.org/svn/repos/hps/list/java/trunk/monitoring-app/</url> Modified: java/branches/jeremy-dev2/monitoring-drivers/pom.xml ============================================================================= --- java/branches/jeremy-dev2/monitoring-drivers/pom.xml (original) +++ java/branches/jeremy-dev2/monitoring-drivers/pom.xml Wed Apr 13 12:42:42 2016 @@ -7,7 +7,7 @@ <groupId>org.hps</groupId> <artifactId>hps-parent</artifactId> <relativePath>../parent/pom.xml</relativePath> - <version>3.8-SNAPSHOT</version> + <version>3.9-SNAPSHOT</version> </parent> <scm> <url>http://java.freehep.org/svn/repos/hps/list/java/trunk/monitoring-drivers/</url> Modified: java/branches/jeremy-dev2/monitoring-util/pom.xml ============================================================================= --- java/branches/jeremy-dev2/monitoring-util/pom.xml (original) +++ java/branches/jeremy-dev2/monitoring-util/pom.xml Wed Apr 13 12:42:42 2016 @@ -7,7 +7,7 @@ <groupId>org.hps</groupId> <artifactId>hps-parent</artifactId> <relativePath>../parent/pom.xml</relativePath> - <version>3.8-SNAPSHOT</version> + <version>3.9-SNAPSHOT</version> </parent> <scm> <url>http://java.freehep.org/svn/repos/hps/list/java/trunk/monitoring-util/</url> Modified: java/branches/jeremy-dev2/parent/pom.xml ============================================================================= --- java/branches/jeremy-dev2/parent/pom.xml (original) +++ java/branches/jeremy-dev2/parent/pom.xml Wed Apr 13 12:42:42 2016 @@ -6,14 +6,14 @@ <groupId>org.hps</groupId> <artifactId>hps-parent</artifactId> <packaging>pom</packaging> - <version>3.8-SNAPSHOT</version> + <version>3.9-SNAPSHOT</version> <name>parent</name> <description>HPS Java parent POM</description> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <org.lcsim.cacheDir>${user.home}</org.lcsim.cacheDir> - <lcsimVersion>3.5-SNAPSHOT</lcsimVersion> + <lcsimVersion>3.6</lcsimVersion> <skipSite>false</skipSite> <skipPlugin>false</skipPlugin> </properties> @@ -143,112 +143,112 @@ <dependency> <groupId>org.hps</groupId> <artifactId>hps-util</artifactId> - <version>3.8-SNAPSHOT</version> + <version>3.9-SNAPSHOT</version> </dependency> <dependency> <groupId>org.hps</groupId> <artifactId>hps-detector-data</artifactId> - <version>3.8-SNAPSHOT</version> + <version>3.9-SNAPSHOT</version> </dependency> <dependency> <groupId>org.hps</groupId> <artifactId>hps-detector-model</artifactId> - <version>3.8-SNAPSHOT</version> + <version>3.9-SNAPSHOT</version> </dependency> <dependency> <groupId>org.hps</groupId> <artifactId>hps-conditions</artifactId> - <version>3.8-SNAPSHOT</version> + <version>3.9-SNAPSHOT</version> </dependency> <dependency> <groupId>org.hps</groupId> <artifactId>hps-ecal-recon</artifactId> - <version>3.8-SNAPSHOT</version> + <version>3.9-SNAPSHOT</version> </dependency> <dependency> <groupId>org.hps</groupId> <artifactId>hps-ecal-readout-sim</artifactId> - <version>3.8-SNAPSHOT</version> + <version>3.9-SNAPSHOT</version> </dependency> <dependency> <groupId>org.hps</groupId> <artifactId>hps-tracking</artifactId> - <version>3.8-SNAPSHOT</version> + <version>3.9-SNAPSHOT</version> </dependency> <dependency> <groupId>org.hps</groupId> <artifactId>hps-evio</artifactId> - <version>3.8-SNAPSHOT</version> + <version>3.9-SNAPSHOT</version> </dependency> <dependency> <groupId>org.hps</groupId> <artifactId>hps-recon</artifactId> - <version>3.8-SNAPSHOT</version> + <version>3.9-SNAPSHOT</version> </dependency> <dependency> <groupId>org.hps</groupId> <artifactId>hps-analysis</artifactId> - <version>3.8-SNAPSHOT</version> + <version>3.9-SNAPSHOT</version> </dependency> <dependency> <groupId>org.hps</groupId> <artifactId>hps-monitoring-drivers</artifactId> - <version>3.8-SNAPSHOT</version> + <version>3.9-SNAPSHOT</version> </dependency> <dependency> <groupId>org.hps</groupId> <artifactId>hps-monitoring-app</artifactId> - <version>3.8-SNAPSHOT</version> + <version>3.9-SNAPSHOT</version> </dependency> <dependency> <groupId>org.hps</groupId> <artifactId>hps-users</artifactId> - <version>3.8-SNAPSHOT</version> + <version>3.9-SNAPSHOT</version> </dependency> <dependency> <groupId>org.hps</groupId> <artifactId>hps-steering-files</artifactId> - <version>3.8-SNAPSHOT</version> + <version>3.9-SNAPSHOT</version> </dependency> <dependency> <groupId>org.hps</groupId> <artifactId>hps-distribution</artifactId> - <version>3.8-SNAPSHOT</version> + <version>3.9-SNAPSHOT</version> </dependency> <dependency> <groupId>org.hps</groupId> <artifactId>hps-ecal-event-display</artifactId> - <version>3.8-SNAPSHOT</version> + <version>3.9-SNAPSHOT</version> </dependency> <dependency> <groupId>org.hps</groupId> <artifactId>hps-record-util</artifactId> - <version>3.8-SNAPSHOT</version> + <version>3.9-SNAPSHOT</version> </dependency> <dependency> <groupId>org.hps</groupId> <artifactId>hps-monitoring-util</artifactId> - <version>3.8-SNAPSHOT</version> + <version>3.9-SNAPSHOT</version> </dependency> <dependency> <groupId>org.hps</groupId> <artifactId>hps-run-database</artifactId> - <version>3.8-SNAPSHOT</version> + <version>3.9-SNAPSHOT</version> </dependency> <dependency> <groupId>org.hps</groupId> <artifactId>hps-crawler</artifactId> - <version>3.8-SNAPSHOT</version> + <version>3.9-SNAPSHOT</version> </dependency> <dependency> <groupId>org.hps</groupId> <artifactId>hps-job</artifactId> - <version>3.8-SNAPSHOT</version> + <version>3.9-SNAPSHOT</version> </dependency> <dependency> <groupId>org.hps</groupId> <artifactId>hps-logging</artifactId> - <version>3.8-SNAPSHOT</version> + <version>3.9-SNAPSHOT</version> </dependency> <!-- Next are external dependencies used in multiple modules. --> <dependency> Modified: java/branches/jeremy-dev2/plugin/pom.xml ============================================================================= --- java/branches/jeremy-dev2/plugin/pom.xml (original) +++ java/branches/jeremy-dev2/plugin/pom.xml Wed Apr 13 12:42:42 2016 @@ -7,7 +7,7 @@ <groupId>org.hps</groupId> <artifactId>hps-parent</artifactId> <relativePath>../parent/pom.xml</relativePath> - <version>3.8-SNAPSHOT</version> + <version>3.9-SNAPSHOT</version> </parent> <scm> <url>http://java.freehep.org/svn/repos/hps/list/java/trunk/plugin/</url> Modified: java/branches/jeremy-dev2/pom.xml ============================================================================= --- java/branches/jeremy-dev2/pom.xml (original) +++ java/branches/jeremy-dev2/pom.xml Wed Apr 13 12:42:42 2016 @@ -9,7 +9,7 @@ <groupId>org.hps</groupId> <artifactId>hps-parent</artifactId> <relativePath>parent/pom.xml</relativePath> - <version>3.8-SNAPSHOT</version> + <version>3.9-SNAPSHOT</version> </parent> <scm> <url>svn://svn.freehep.org/hps/java/trunk/</url> Modified: java/branches/jeremy-dev2/recon/pom.xml ============================================================================= --- java/branches/jeremy-dev2/recon/pom.xml (original) +++ java/branches/jeremy-dev2/recon/pom.xml Wed Apr 13 12:42:42 2016 @@ -8,7 +8,7 @@ <groupId>org.hps</groupId> <artifactId>hps-parent</artifactId> <relativePath>../parent/pom.xml</relativePath> - <version>3.8-SNAPSHOT</version> + <version>3.9-SNAPSHOT</version> </parent> <scm> <url>http://java.freehep.org/svn/repos/hps/list/java/trunk/recon/</url> Modified: java/branches/jeremy-dev2/recon/src/main/java/org/hps/recon/particle/HpsReconParticleDriver.java ============================================================================= --- java/branches/jeremy-dev2/recon/src/main/java/org/hps/recon/particle/HpsReconParticleDriver.java (original) +++ java/branches/jeremy-dev2/recon/src/main/java/org/hps/recon/particle/HpsReconParticleDriver.java Wed Apr 13 12:42:42 2016 @@ -242,6 +242,7 @@ BilliorVertexer vtxFitter = new BilliorVertexer(bField); // TODO: The beam size should come from the conditions database. vtxFitter.setBeamSize(beamSize); + vtxFitter.setDebug(debug); // Perform the vertexing based on the specified constraint. switch (constraint) { Modified: java/branches/jeremy-dev2/recon/src/main/java/org/hps/recon/particle/ReconParticleDriver.java ============================================================================= --- java/branches/jeremy-dev2/recon/src/main/java/org/hps/recon/particle/ReconParticleDriver.java (original) +++ java/branches/jeremy-dev2/recon/src/main/java/org/hps/recon/particle/ReconParticleDriver.java Wed Apr 13 12:42:42 2016 @@ -573,7 +573,7 @@ /** * Indicates whether debug text should be output or not. */ - private boolean debug = false; + protected boolean debug = false; /** * The simple name of the class used for debug print statements. Modified: java/branches/jeremy-dev2/recon/src/main/java/org/hps/recon/vertexing/BilliorVertexer.java ============================================================================= --- java/branches/jeremy-dev2/recon/src/main/java/org/hps/recon/vertexing/BilliorVertexer.java (original) +++ java/branches/jeremy-dev2/recon/src/main/java/org/hps/recon/vertexing/BilliorVertexer.java Wed Apr 13 12:42:42 2016 @@ -16,394 +16,97 @@ /** * @version $Id: BilliorVertexer.java,v 1.3 2013/03/13 19:24:20 mgraham Exp $ - * @version Vertex tracks using least-squares method laid out by billior etal used in the HPS Java package. + * @version Vertex tracks using least-squares method laid out by billior etal + * used in the HPS Java package. */ public class BilliorVertexer { // the value of the magnetic field in the vicinity of the vertex // default is a constant field along the z axis private boolean _debug = false; - private double _bField; - private boolean _beamspotConstraint = true; - private boolean _targetConstraint = false; - private double[] _beamSize = {0.001, 0.01, 0.01}; //10um in y and z + private final double _bField; + private boolean _beamspotConstraint; + private boolean _targetConstraint; + private String _constraintType; + private final double[] _beamSize = {0.001, 0.01, 0.01}; //10um in y and z + private final double[] _beamPosition = {0.0, 0.0, 0.0}; //origin private int _ntracks; - private List<Matrix> paramList = new ArrayList<Matrix>(); - private List<Matrix> WList = new ArrayList<Matrix>(); - private List<Matrix> DList = new ArrayList<Matrix>(); - private List<Matrix> EList = new ArrayList<Matrix>(); - private Matrix A; - private Matrix T; - private List<Matrix> BList = new ArrayList<Matrix>(); - private List<Matrix> CinvList = new ArrayList<Matrix>(); - private List<Matrix> CList = new ArrayList<Matrix>(); - private List<Matrix> UList = new ArrayList<Matrix>(); - private List<Matrix> dqList = new ArrayList<Matrix>(); - private double[] _v0 = {0.0, 0.0, 0.0}; + private double[] _v0 = {0.0, 0.0, 0.0}; //initial guess for unconstrained vertex fit // private double[] _vertexPosition = {0., 0.0, 0.0}; - private Matrix _vertexPosition = new BasicMatrix(3, 1); - private Matrix _covVtx = new BasicMatrix(3, 3); - private List<Matrix> _pFit = new ArrayList<Matrix>(); + private Matrix _vertexPosition; + private Matrix _covVtx; + private List<Matrix> _pFit; ;//theta,phi_v,rho - private List<Matrix> covVtxMomList = new ArrayList<Matrix>(); - private Matrix[][] covMomList = new Matrix[2][2];//max 2 tracks...just make this bigger for more + private List<Matrix> covVtxMomList; + private Matrix[][] covMomList;//max 2 tracks...just make this bigger for more private Matrix _constrainedFit; private Matrix _constrainedCov; private double _chiSq; - private String _constraintType="Unspecified"; - // constructor - public BilliorVertexer() { - } public BilliorVertexer(double bField) { _bField = bField; - _constraintType="Unconstrained"; - _beamspotConstraint =false; + _constraintType = "Unconstrained"; + _beamspotConstraint = false; _targetConstraint = false; } - - public BilliorVertexer(double bField,boolean bsConst, boolean constToBS) { + + public BilliorVertexer(double bField, boolean bsConst, boolean constToBS) { _bField = bField; - _beamspotConstraint =bsConst; + _beamspotConstraint = bsConst; _targetConstraint = constToBS; - if(_beamspotConstraint&&_targetConstraint) + if (_beamspotConstraint && _targetConstraint) { System.out.println("BilliorVertexer::Warning!!! Setting both _beamspotConstraint and _targetConstraint to true!"); - if(_beamspotConstraint) - _constraintType="BeamspotConstrained"; - if(_targetConstraint) - _constraintType="TargetConstrained"; + } + if (_beamspotConstraint) { + _constraintType = "BeamspotConstrained"; + } + if (_targetConstraint) { + _constraintType = "TargetConstrained"; + } + } + + public void setDebug(boolean debug) { + _debug = debug; } public BilliorVertex fitVertex(List<BilliorTrack> tracks) { _ntracks = tracks.size(); follow1985Paper(tracks); - if (_beamspotConstraint) - addV0fromBSConstraint(); - else if (_targetConstraint) - constrainV0toBS(); - Map<Integer,Hep3Vector> pFitMap=new HashMap<Integer,Hep3Vector>(); - for(int i=0;i<tracks.size();i++){ - Hep3Vector pFit=new BasicHep3Vector(this.getFittedMomentum(i)); - pFitMap.put(i, pFit); - } - Hep3Vector vert=new BasicHep3Vector(_vertexPosition.e(0, 0),_vertexPosition.e(1, 0),_vertexPosition.e(2, 0)); - Hep3Vector vertDet=CoordinateTransformations.transformVectorToDetector(vert); - SymmetricMatrix covVtxDet=CoordinateTransformations.transformCovarianceToDetector(new SymmetricMatrix( _covVtx)); - return new BilliorVertex(vertDet,covVtxDet,_chiSq,getInvMass(),pFitMap,_constraintType); - } - - public BilliorVertex fitFastVertex(List<BilliorTrack> tracks) { - _ntracks = tracks.size(); - fastVertex(tracks); - Hep3Vector vert=new BasicHep3Vector(_vertexPosition.e(0, 0),_vertexPosition.e(1, 0),_vertexPosition.e(2, 0)); - return new BilliorVertex((Hep3Vector)_vertexPosition,_covVtx,_chiSq,getInvMass()); - } - - private void calculateCovariance() { - for (int i = 0; i < _ntracks; i++) { - BasicMatrix b = (BasicMatrix) BList.get(i); - BasicMatrix cinv = (BasicMatrix) CinvList.get(i); - BasicMatrix bt = (BasicMatrix) MatrixOp.transposed(b); - covVtxMomList.add((MatrixOp.mult(-1, MatrixOp.mult(_covVtx, MatrixOp.mult(b, cinv))))); - for (int j = 0; j < _ntracks; j++) { - BasicMatrix bj = (BasicMatrix) BList.get(j); - BasicMatrix cjinv = (BasicMatrix) CinvList.get(j); - BasicMatrix tmp = (BasicMatrix) MatrixOp.mult(cinv, MatrixOp.mult(bt, MatrixOp.mult(_covVtx, MatrixOp.mult(bj, cjinv)))); - if (i == j) - tmp = (BasicMatrix) MatrixOp.add(tmp, cinv); - covMomList[i][j] = tmp; - } - } - } - - private void calculateMomenta() { - - for (int i = 0; i < _ntracks; i++) { - BasicMatrix params = (BasicMatrix) paramList.get(i); - BasicMatrix b = (BasicMatrix) BList.get(i); - BasicMatrix cinv = (BasicMatrix) CinvList.get(i); - BasicMatrix u = (BasicMatrix) UList.get(i); - //not sure following line is correct...mg 10/21/10 - BasicMatrix CinvU = (BasicMatrix) MatrixOp.mult(cinv, u); - BasicMatrix CinvBTdV = (BasicMatrix) MatrixOp.mult(-1, MatrixOp.mult(cinv, MatrixOp.mult(MatrixOp.transposed(b), _vertexPosition))); -// if(_debug)System.out.println(" B = "+b.toString()); -// if(_debug)System.out.println(" cinv = "+cinv.toString()); -// if(_debug)System.out.println(" u = "+u.toString()); -// if(_debug)System.out.println(" CinvU = "+CinvU.toString()); -// if(_debug)System.out.println(" CinvBTdV = "+CinvBTdV.toString()); - BasicMatrix tmpP = (BasicMatrix) MatrixOp.add(CinvBTdV, CinvU); - tmpP.setElement(0, 0, tmpP.e(0, 0) + params.e(2, 0)); - tmpP.setElement(1, 0, tmpP.e(1, 0) + params.e(3, 0)); - tmpP.setElement(2, 0, tmpP.e(2, 0) + params.e(4, 0)); - _pFit.add(tmpP); -// if(_debug)System.out.println("Track "+i+" orig parameters = "+params); -// if(_debug)System.out.println("Track "+i+" deltaP = "+MatrixOp.add(CinvBTdV, CinvU)); -// if(_debug)System.out.println("Track " + i + " _pFit = " + tmpP); - } - } - - private void calculateVertexPosition() { - BasicMatrix tmpcov = new BasicMatrix(3, 3); - BasicMatrix tmp = new BasicMatrix(3, 1); - for (int i = 0; i < _ntracks; i++) { - BasicMatrix b = (BasicMatrix) BList.get(i); - BasicMatrix cinv = (BasicMatrix) CinvList.get(i); - BasicMatrix u = (BasicMatrix) UList.get(i); -// if(_debug)System.out.println("Cinv matrix " + cinv.toString()); -// if(_debug)System.out.println("B matrix " + b.toString()); -// if(_debug)System.out.println("U matrix " + u.toString()); - BasicMatrix bt = (BasicMatrix) MatrixOp.transposed(b); - // if(_debug)System.out.println("Adding this to tmpcov : " + MatrixOp.mult(-1, MatrixOp.mult(b, MatrixOp.mult(cinv, bt)))); - if (i == 0) { - tmpcov = (BasicMatrix) MatrixOp.mult(-1, MatrixOp.mult(b, MatrixOp.mult(cinv, bt))); - tmp = (BasicMatrix) MatrixOp.mult(-1, MatrixOp.mult(b, MatrixOp.mult(cinv, u))); - } else { - tmpcov = (BasicMatrix) MatrixOp.add(tmpcov, MatrixOp.mult(-1, MatrixOp.mult(b, MatrixOp.mult(cinv, bt)))); - tmp = (BasicMatrix) MatrixOp.add(tmp, MatrixOp.mult(-1, MatrixOp.mult(b, MatrixOp.mult(cinv, u)))); - } -// if(_debug)System.out.println("tmpCov matrix " + tmpcov.toString()); -// if(_debug)System.out.println("tmp matrix " + tmp.toString()); - } -// -// if(_debug)System.out.println("A matrix " + A.toString()); -// if(_debug)System.out.println("tmpCov matrix " + tmpcov.toString()); -// if(_debug)System.out.println("sum of A and tmpCov = " + MatrixOp.add(A, tmpcov).toString()); - _covVtx = MatrixOp.inverse(MatrixOp.add(A, tmpcov)); -// if(_debug)System.out.println("_covVtx matrix " + _covVtx.toString()); -// if(_debug)System.out.println("T matrix " + T.toString()); - _vertexPosition = (BasicMatrix) MatrixOp.mult(_covVtx, MatrixOp.add(T, tmp)); - - } - - private void makeOtherMatrices() { - BasicMatrix tmpA = new BasicMatrix(3, 3); - BasicMatrix tmpT = new BasicMatrix(3, 1); - - for (int i = 0; i < _ntracks; i++) { - BasicMatrix tmpD = (BasicMatrix) DList.get(i); - BasicMatrix tmpE = (BasicMatrix) EList.get(i); - BasicMatrix dq = (BasicMatrix) dqList.get(i); - BasicMatrix tmpW = (BasicMatrix) WList.get(i); - - if (i == 0) { - tmpA = (BasicMatrix) MatrixOp.mult(MatrixOp.transposed(tmpD), MatrixOp.mult(tmpW, tmpD)); - tmpT = (BasicMatrix) MatrixOp.mult(MatrixOp.transposed(tmpD), MatrixOp.mult(tmpW, dq)); - } else { - tmpT = (BasicMatrix) MatrixOp.add(tmpT, MatrixOp.mult(MatrixOp.transposed(tmpD), MatrixOp.mult(tmpW, dq))); - tmpA = (BasicMatrix) MatrixOp.add(tmpA, MatrixOp.mult(MatrixOp.transposed(tmpD), MatrixOp.mult(tmpW, tmpD))); - } - BList.add(MatrixOp.mult(MatrixOp.transposed(tmpD), MatrixOp.mult(tmpW, tmpE))); - BasicMatrix tmpC = (BasicMatrix) MatrixOp.mult(MatrixOp.transposed(tmpE), MatrixOp.mult(tmpW, tmpE)); - CList.add(tmpC); - CinvList.add(MatrixOp.inverse(tmpC)); - UList.add(MatrixOp.mult(MatrixOp.transposed(tmpE), MatrixOp.mult(tmpW, dq))); - - } - A = tmpA; - T = tmpT; - } - - private void calculateChisq() { - _chiSq = 0; - for (int i = 0; i < _ntracks; i++) { - BasicMatrix params = (BasicMatrix) paramList.get(i); - BasicMatrix d = (BasicMatrix) DList.get(i); - BasicMatrix e = (BasicMatrix) EList.get(i); - BasicMatrix w = (BasicMatrix) WList.get(i); - BasicMatrix pi = (BasicMatrix) _pFit.get(i); - BasicMatrix Vtilde = (BasicMatrix) MatrixOp.mult(d, _vertexPosition); - BasicMatrix Trtilde = (BasicMatrix) MatrixOp.mult(e, pi); - BasicMatrix ptilde = (BasicMatrix) MatrixOp.add(Vtilde, Trtilde); - // if(_debug)System.out.println("Vtilde = "+Vtilde); - // if(_debug)System.out.println("Trtilde = "+Trtilde); - BasicMatrix resid = (BasicMatrix) MatrixOp.add(params, MatrixOp.mult(-1, ptilde)); - BasicMatrix residT = (BasicMatrix) MatrixOp.transposed(resid); -// if(_debug)System.out.println("ptilde = "+ptilde); -// if(_debug)System.out.println("params = "+params); -// if(_debug)System.out.println("resid = "+resid); -// if(_debug)System.out.println("Covariance = "+MatrixOp.inverse(w)); -// if(_debug)System.out.println("Weight = "+w); - _chiSq = _chiSq + (MatrixOp.mult(residT, MatrixOp.mult(w, resid))).e(0, 0); -// if(_debug)System.out.println("_chiSq = "+_chiSq); - } - } - - private void fastVertex(List<BilliorTrack> tracks) { - boolean firstTrack = true; - BasicMatrix sumwi = new BasicMatrix(3, 3); - BasicMatrix sumwiXi = new BasicMatrix(3, 1); - BasicMatrix dX = new BasicMatrix(3, 1); - - for (BilliorTrack bt : tracks) { - double[] par = bt.parameters(); -// if(_debug)System.out.println("Track parameters = (" + par[0] + ", " + par[1] + ", " + par[2] + ", " + par[3] + ", " + par[4] + ")"); - double cotth = 1. / tan(par[2]); - double phiv = par[3]; - double cosf = cos(phiv); - double sinf = sin(phiv); - - double xi = par[0] * sin(par[3]); - double yi = -par[0] * cos(par[3]); - double zi = par[1]; - - dX.setElement(0, 0, xi); - dX.setElement(1, 0, yi); - dX.setElement(2, 0, zi); - - BasicMatrix tmpD = new BasicMatrix(2, 3); - tmpD.setElement(0, 0, sinf); - tmpD.setElement(0, 1, -cosf); - tmpD.setElement(1, 0, -cotth * cosf); - tmpD.setElement(1, 1, -cotth * sinf); - tmpD.setElement(1, 2, 1); - BasicMatrix trkCov = new BasicMatrix(2, 2); - trkCov.setElement(0, 0, bt.covariance().e(0, 0)); - trkCov.setElement(0, 1, bt.covariance().e(0, 1)); - trkCov.setElement(1, 0, bt.covariance().e(1, 0)); - trkCov.setElement(1, 1, bt.covariance().e(1, 1)); - BasicMatrix tmpW = (BasicMatrix) MatrixOp.inverse(trkCov); - BasicMatrix wi = (BasicMatrix) MatrixOp.mult(MatrixOp.transposed(tmpD), MatrixOp.mult(tmpW, tmpD)); - if (firstTrack) { - sumwi = wi; - sumwiXi = (BasicMatrix) MatrixOp.mult(wi, dX); - } else { - sumwi = (BasicMatrix) MatrixOp.add(sumwi, wi); - sumwiXi = (BasicMatrix) MatrixOp.add(sumwiXi, MatrixOp.mult(wi, dX)); - } - firstTrack = false; - } - _covVtx = MatrixOp.inverse(sumwi); - if (_debug) - System.out.println("fastVertex::_covVtx matrix " + _covVtx.toString()); - _vertexPosition = (BasicMatrix) MatrixOp.mult(_covVtx, sumwiXi); - _chiSq = 0; - //get the chisq - for (BilliorTrack bt : tracks) { - double[] par = bt.parameters(); -// if(_debug)System.out.println("Track parameters = (" + par[0] + ", " + par[1] + ", " + par[2] + ", " + par[3] + ", " + par[4] + ")"); - double cotth = 1. / tan(par[2]); - double phiv = par[3]; - double cosf = cos(phiv); - double sinf = sin(phiv); - - double xi = par[0] * sin(par[3]); - double yi = -par[0] * cos(par[3]); - double zi = par[1]; - //this is xi - fitted vertex now - dX.setElement(0, 0, xi - _vertexPosition.e(0, 0)); - dX.setElement(1, 0, yi - _vertexPosition.e(1, 0)); - dX.setElement(2, 0, zi - _vertexPosition.e(2, 0)); - - BasicMatrix tmpD = new BasicMatrix(2, 3); - tmpD.setElement(0, 0, sinf); - tmpD.setElement(0, 1, -cosf); - tmpD.setElement(1, 0, -cotth * cosf); - tmpD.setElement(1, 1, -cotth * sinf); - tmpD.setElement(1, 2, 1); - BasicMatrix trkCov = new BasicMatrix(2, 2); - trkCov.setElement(0, 0, bt.covariance().e(0, 0)); - trkCov.setElement(0, 1, bt.covariance().e(0, 1)); - trkCov.setElement(1, 0, bt.covariance().e(1, 0)); - trkCov.setElement(1, 1, bt.covariance().e(1, 1)); - BasicMatrix tmpW = (BasicMatrix) MatrixOp.inverse(trkCov); - BasicMatrix wi = (BasicMatrix) MatrixOp.mult(MatrixOp.transposed(tmpD), MatrixOp.mult(tmpW, tmpD)); - _chiSq += MatrixOp.mult(MatrixOp.transposed(dX), MatrixOp.mult(wi, dX)).e(0, 0); - } - } - - private void makeDerivativeMatrices(List<BilliorTrack> tracks) { - - //DList.clear(); - //EList.clear(); - //paramList.clear(); - //dqList.clear(); - //WList.clear(); - BasicMatrix dq = new BasicMatrix(5, 1); - BasicMatrix tmpW = new BasicMatrix(5, 5); - for (BilliorTrack bt : tracks) { - double[] par = bt.parameters(); - BasicMatrix tmpPar = new BasicMatrix(5, 1); - tmpPar.setElement(0, 0, par[0]); - tmpPar.setElement(1, 0, par[1]); - tmpPar.setElement(2, 0, par[2]); - tmpPar.setElement(3, 0, par[3]); - tmpPar.setElement(4, 0, par[4]); - paramList.add(tmpPar); - double cotth = 1. / tan(par[2]); - double uu = _v0[0] * cos(par[3]) + _v0[1] * sin(par[3]);//Q - double vv = _v0[1] * cos(par[3]) - _v0[0] * sin(par[3]);//R - double eps = -vv - .5 * uu * uu * par[4]; - double zp = _v0[2] - uu * (1 - vv * par[4]) * cotth; - // * phi at vertex with these parameters - double phiv = par[3] + uu * par[4]; - double cosf = cos(phiv); - double sinf = sin(phiv); - - BasicMatrix tmpD = new BasicMatrix(5, 3); - tmpD.setElement(0, 0, sinf); - tmpD.setElement(0, 1, -cosf); - tmpD.setElement(1, 0, -cotth * cosf); - tmpD.setElement(1, 1, -cotth * sinf); - tmpD.setElement(1, 2, 1); - tmpD.setElement(3, 0, -par[4] * cosf); - tmpD.setElement(3, 1, -par[4] * sinf); - - BasicMatrix tmpE = new BasicMatrix(5, 3); - tmpE.setElement(0, 1, uu); - tmpE.setElement(0, 2, -uu * uu / 2); - tmpE.setElement(1, 0, uu * (1 + cotth * cotth)); - tmpE.setElement(1, 1, -vv * cotth); - tmpE.setElement(1, 2, uu * vv * cotth); - tmpE.setElement(3, 1, 1); - tmpE.setElement(3, 2, -uu); - tmpE.setElement(2, 0, 1); //partial(theta)/dtheta - tmpE.setElement(4, 2, 1); //partial (rho)/drho - DList.add(tmpD); - EList.add(tmpE); - - double deps = par[0] - eps; - double dzp = par[1] - zp; - double dphi = par[3] - phiv; - - dq.setElement(0, 0, deps); - dq.setElement(1, 0, dzp); - dq.setElement(3, 0, dphi); - dqList.add(dq); - tmpW = (BasicMatrix) MatrixOp.inverse(bt.covariance()); - WList.add(tmpW); - - if (_debug) - System.out.println("makeDerivativeMatrices::Params = \n" + tmpPar); - if (_debug) - System.out.println("D = \n" + tmpD); - if (_debug) - System.out.println("E = \n" + tmpE); - if (_debug) - System.out.println("dq = \n" + dq); - if (_debug) - System.out.println("W = \n" + tmpW); - } - - } - - /* Add the constraint that V0 points back to beamspot + if (_beamspotConstraint) { + applyBSconstraint(true); + } else if (_targetConstraint) { + applyBSconstraint(false); + } + Map<Integer, Hep3Vector> pFitMap = new HashMap<Integer, Hep3Vector>(); + for (int i = 0; i < tracks.size(); i++) { + Hep3Vector pFit = new BasicHep3Vector(this.getFittedMomentum(i)); + pFitMap.put(i, pFit); + } + Hep3Vector vert = new BasicHep3Vector(_vertexPosition.e(0, 0), _vertexPosition.e(1, 0), _vertexPosition.e(2, 0)); + Hep3Vector vertDet = CoordinateTransformations.transformVectorToDetector(vert); + SymmetricMatrix covVtxDet = CoordinateTransformations.transformCovarianceToDetector(new SymmetricMatrix(_covVtx)); + return new BilliorVertex(vertDet, covVtxDet, _chiSq, getInvMass(), pFitMap, _constraintType); + } + + /* Add the constraint that V0 is at/points back to beamspot * this method is based on progressive least squares fit * using the unconstrained fit result as the (k-1) fit * * all notation is taken from: * W. Hulsbergen, NIM 552 (2005) 566-575 */ - private void addV0fromBSConstraint() { - BasicMatrix Hk = new BasicMatrix(3 * (_ntracks + 1), 3); + private void applyBSconstraint(boolean pointback) { + String methodName = pointback ? "constrainV0toBS" : "constrainV0toTarget"; BasicMatrix Ckm1 = new BasicMatrix(3 * (_ntracks + 1), 3 * (_ntracks + 1)); BasicMatrix Xkm1 = new BasicMatrix(3 * (_ntracks + 1), 1); MatrixOp.setSubMatrix(Ckm1, _covVtx, 0, 0); MatrixOp.setSubMatrix(Xkm1, _vertexPosition, 0, 0); int n = 1; for (Matrix covVtxMom : covVtxMomList) { - if (_debug) - System.out.println("addV0fromBSConstraint::Track " + n + " covVtxMom : " + covVtxMom.toString()); + if (_debug) { + System.out.println(methodName + "::Track " + n + " covVtxMom : " + covVtxMom.toString()); + } MatrixOp.setSubMatrix(Ckm1, covVtxMom, 0, 3 * n); MatrixOp.setSubMatrix(Ckm1, MatrixOp.transposed(covVtxMom), 3 * n, 0); n++; @@ -411,10 +114,12 @@ for (int i = 0; i < _ntracks; i++) { BasicMatrix pi = (BasicMatrix) _pFit.get(i); MatrixOp.setSubMatrix(Xkm1, pi, 3 * (i + 1), 0); - if (_debug) - System.out.println("addV0fromBSConstraint::Track " + i + " p : " + pi.toString()); - for (int j = 0; j < _ntracks; j++) + if (_debug) { + System.out.println(methodName + "::Track " + i + " p : " + pi.toString()); + } + for (int j = 0; j < _ntracks; j++) { MatrixOp.setSubMatrix(Ckm1, covMomList[i][j], 3 * (i + 1), 3 * (j + 1)); + } } // now calculate the derivative matrix for the beam constraint. @@ -443,56 +148,16 @@ pztot += pz; } //calculate the position of the A' at X=0 - BasicMatrix rk = new BasicMatrix(3, 1); - if (_debug) - System.out.println("addV0fromBSConstraint::Vx = " + Vx + "; Vy = " + Vy + "; Vz = " + Vz + "; pxtot = " + pxtot + "; pytot = " + pytot + "; pztot = " + pztot); - rk.setElement(0, 0, 0); - rk.setElement(1, 0, 0 - (Vy - pytot / pxtot * Vx)); - rk.setElement(2, 0, 0 - (Vz - pztot / pxtot * Vx)); - -// ok, can set the derivitives wrt to V - Hk.setElement(0, 0, 0); - Hk.setElement(0, 1, pytot / pxtot); - Hk.setElement(0, 2, pztot / pxtot); - Hk.setElement(1, 0, 0); - Hk.setElement(1, 1, 1); - Hk.setElement(1, 2, 0); - Hk.setElement(2, 0, 0); - Hk.setElement(2, 1, 0); - Hk.setElement(2, 2, 1); -//ok, loop over tracks again to set the derivitives wrt track momenta (theta,phi,rho) - for (int i = 0; i < _ntracks; i++) { - BasicMatrix pi = (BasicMatrix) _pFit.get(i); - double theta = pi.e(0, 0); - double phiv = pi.e(1, 0); - double rho = pi.e(2, 0); - double Pt = Math.abs((1. / rho) * _bField * Constants.fieldConversion); - double px = Pt * Math.cos(phiv); - double py = Pt * Math.sin(phiv); - double pz = Pt * 1 / Math.tan(theta); - //derivities wrt theta - Hk.setElement(3 * (i + 1), 0, 0); - Hk.setElement(3 * (i + 1), 1, 0); - Hk.setElement(3 * (i + 1), 2, -Pt / Math.pow(sin(theta), 2) * Vx); - //derivities wrt phi - Hk.setElement(3 * (i + 1) + 1, 0, 0); - Hk.setElement(3 * (i + 1) + 1, 1, - (Pt * Pt * cos(phiv) * sin(phiv) / (pxtot * pxtot)) * Vx); - Hk.setElement(3 * (i + 1) + 1, 2, (Pt * sin(phiv) / (pxtot * pxtot)) * Vx * pztot); - //derivities wrt rho - Hk.setElement(3 * (i + 1) + 2, 0, 0); -// Hk.setElement(3 * (i + 1) + 2, 1, -// (pytot / pxtot - 1) * (Pt / rho) * (1 / pxtot) * Vx); -// Hk.setElement(3 * (i + 1) + 2, 2, -// (pztot / pxtot - 1) * (Pt / rho) * (1 / pxtot) * Vx); - Hk.setElement(3 * (i + 1) + 2, 1, - (cos(phiv) * pytot / pxtot - sin(phiv)) * (Pt / rho) * (1 / pxtot) * Vx); - Hk.setElement(3 * (i + 1) + 2, 2, - (cos(phiv) * pztot / pxtot - sin(phiv)) * (Pt / rho) * (1 / pxtot) * Vx); - // if(_debug)System.out.println("pxtot = "+pxtot+"; rho = "+rho+"; Pt = "+Pt); - // if(_debug)System.out.println("cos(phiv)*pytot / pxtot - sin(phiv) = "+(cos(phiv)*pytot / pxtot - sin(phiv))); - // if(_debug)System.out.println("Pt/(rho*pxtot) = "+(Pt / rho) * (1 / pxtot)); - } + BasicMatrix rk = makeRk(Vx, Vy, Vz, pxtot, pytot, pztot, pointback); + if (_debug) { + System.out.println(methodName + "::rk = " + rk); + } + + BasicMatrix Hk = makeHk(_ntracks, pxtot, pytot, pztot, pointback); + if (_debug) { + System.out.println(methodName + "::Hk = " + Hk); + } + // the beam covariance BasicMatrix Vk = new BasicMatrix(3, 3); Vk.setElement(0, 0, _beamSize[0] * _beamSize[0]); @@ -501,15 +166,18 @@ //now do the matrix operations to get the constrained parameters BasicMatrix Hkt = (BasicMatrix) MatrixOp.transposed(Hk); - if (_debug) - System.out.println("addV0fromBSConstraint::Ckm1Hk = " + MatrixOp.mult(Ckm1, Hk)); + if (_debug) { + System.out.println(methodName + "::Ckm1Hk = " + MatrixOp.mult(Ckm1, Hk)); + } BasicMatrix Rk = (BasicMatrix) MatrixOp.mult(Hkt, MatrixOp.mult(Ckm1, Hk)); - if (_debug) + if (_debug) { System.out.println("Pre Vk: Rk = " + Rk.toString()); + } Rk = (BasicMatrix) MatrixOp.add(Rk, Vk); - if (_debug) + if (_debug) { System.out.println("Post Vk: Rk = " + Rk.toString()); + } BasicMatrix Rkinv = (BasicMatrix) MatrixOp.inverse(Rk); BasicMatrix Kk = (BasicMatrix) MatrixOp.mult(Ckm1, MatrixOp.mult(Hk, Rkinv)); @@ -540,6 +208,10 @@ // if(_debug)System.out.println("With Constraint : " + _vertexPosition.toString()); // if(_debug)System.out.println("With Constraint : " + _covVtx.toString()); + if (_debug) { + System.out.println("Constrained vertex: " + _vertexPosition); + } + for (int i = 0; i < _ntracks; i++) { BasicMatrix ptmp = (BasicMatrix) MatrixOp.getSubMatrix(_constrainedFit, 3 * (i + 1), 0, 3, 1); _pFit.set(i, ptmp); @@ -547,70 +219,28 @@ // if(_debug)System.out.println("Unconstrained chi^2 = "+_chiSq); //ok...add to the chi^2 - if (_debug) - System.out.println(MatrixOp.mult(MatrixOp.transposed(rk), MatrixOp.mult(Rkinv, rk))); + if (_debug) { + System.out.println("Chisq contribution: " + MatrixOp.mult(MatrixOp.transposed(rk), MatrixOp.mult(Rkinv, rk))); + } _chiSq += MatrixOp.mult(MatrixOp.transposed(rk), MatrixOp.mult(Rkinv, rk)).e(0, 0); // if(_debug)System.out.println("Constrained chi^2 = "+_chiSq); } - private void constrainV0toBS() { - BasicMatrix Hk = new BasicMatrix(3 * (_ntracks + 1), 3); - BasicMatrix Ckm1 = new BasicMatrix(3 * (_ntracks + 1), 3 * (_ntracks + 1)); - BasicMatrix Xkm1 = new BasicMatrix(3 * (_ntracks + 1), 1); - MatrixOp.setSubMatrix(Ckm1, _covVtx, 0, 0); - MatrixOp.setSubMatrix(Xkm1, _vertexPosition, 0, 0); - - int n = 1; - for (Matrix covVtxMom : covVtxMomList) { - if (_debug) - System.out.println("constrainV0toBS::Track " + n + " covVtxMom : " + covVtxMom.toString()); - MatrixOp.setSubMatrix(Ckm1, covVtxMom, 0, 3 * n); - MatrixOp.setSubMatrix(Ckm1, MatrixOp.transposed(covVtxMom), 3 * n, 0); - n++; - } - for (int i = 0; i < _ntracks; i++) { - BasicMatrix pi = (BasicMatrix) _pFit.get(i); - MatrixOp.setSubMatrix(Xkm1, pi, 3 * (i + 1), 0); - // if(_debug)System.out.println("Track "+i+" p : " + pi.toString()); - for (int j = 0; j < _ntracks; j++) - MatrixOp.setSubMatrix(Ckm1, covMomList[i][j], 3 * (i + 1), 3 * (j + 1)); - } - // now calculate the derivative matrix for the beam constraint. - // the beamspot is assumed to be at bvec=(0,0,0) - // the V0 production position is Vbvec=(0,0,0) - // where ptot=sum_i (pi) - // need derivites wrt to the vertex position and momentum (theta,phi_v,rho) + private BasicMatrix makeHk(int ntracks, double pxtot, double pytot, double pztot, boolean bscon) { double Vx = _vertexPosition.e(0, 0); - double Vy = _vertexPosition.e(1, 0); - double Vz = _vertexPosition.e(2, 0); - //first, get the sum of momenta... - double pxtot = 0; - double pytot = 0; - double pztot = 0; - for (int i = 0; i < _ntracks; i++) { - BasicMatrix pi = (BasicMatrix) _pFit.get(i); - double theta = pi.e(0, 0); - double phiv = pi.e(1, 0); - double rho = pi.e(2, 0); - double Pt = Math.abs((1. / rho) * _bField * Constants.fieldConversion); - double px = Pt * Math.cos(phiv); - double py = Pt * Math.sin(phiv); - double pz = Pt * 1 / Math.tan(theta); - pxtot += px; - pytot += py; - pztot += pz; - } - //calculate the position of the A' at X=0 - BasicMatrix rk = new BasicMatrix(3, 1); - // if(_debug)System.out.println("Vx = " + Vx + "; Vy = " + Vy + "; Vz = " + Vz + "; pxtot = " + pxtot + "; pytot = " + pytot + "; pztot = " + pztot); - rk.setElement(0, 0, -Vx); - rk.setElement(1, 0, -Vy); - rk.setElement(2, 0, -Vz); - +// double Vy = _vertexPosition.e(1, 0); +// double Vz = _vertexPosition.e(2, 0); + BasicMatrix Hk = new BasicMatrix(3 * (ntracks + 1), 3); // ok, can set the derivitives wrt to V - Hk.setElement(0, 0, 1); - Hk.setElement(0, 1, 0); - Hk.setElement(0, 2, 0); + if (bscon) { + Hk.setElement(0, 0, 0); + Hk.setElement(0, 1, pytot / pxtot); + Hk.setElement(0, 2, pztot / pxtot); + } else { + Hk.setElement(0, 0, 1); + Hk.setElement(0, 1, 0); + Hk.setElement(0, 2, 0); + } Hk.setElement(1, 0, 0); Hk.setElement(1, 1, 1); Hk.setElement(1, 2, 0); @@ -618,92 +248,73 @@ Hk.setElement(2, 1, 0); Hk.setElement(2, 2, 1); //ok, loop over tracks again to set the derivitives wrt track momenta (theta,phi,rho) - for (int i = 0; i < _ntracks; i++) { + for (int i = 0; i < ntracks; i++) { BasicMatrix pi = (BasicMatrix) _pFit.get(i); double theta = pi.e(0, 0); double phiv = pi.e(1, 0); double rho = pi.e(2, 0); double Pt = Math.abs((1. / rho) * _bField * Constants.fieldConversion); - double px = Pt * Math.cos(phiv); - double py = Pt * Math.sin(phiv); - double pz = Pt * 1 / Math.tan(theta); +// double px = Pt * Math.cos(phiv); +// double py = Pt * Math.sin(phiv); +// double pz = Pt * 1 / Math.tan(theta); //derivities wrt theta Hk.setElement(3 * (i + 1), 0, 0); Hk.setElement(3 * (i + 1), 1, 0); - Hk.setElement(3 * (i + 1), 2, 0); + if (bscon) { + Hk.setElement(3 * (i + 1), 2, + -Pt / Math.pow(sin(theta), 2) * Vx); + } else { + Hk.setElement(3 * (i + 1), 2, 0); + } //derivities wrt phi Hk.setElement(3 * (i + 1) + 1, 0, 0); - Hk.setElement(3 * (i + 1) + 1, 1, - 0); - Hk.setElement(3 * (i + 1) + 1, 2, 0); + if (bscon) { + Hk.setElement(3 * (i + 1) + 1, 1, + (Pt * Pt * cos(phiv) * sin(phiv) / (pxtot * pxtot)) * Vx); + Hk.setElement(3 * (i + 1) + 1, 2, + (Pt * sin(phiv) / (pxtot * pxtot)) * Vx * pztot); + } else { + Hk.setElement(3 * (i + 1) + 1, 1, 0); + Hk.setElement(3 * (i + 1) + 1, 2, 0); + } //derivities wrt rho Hk.setElement(3 * (i + 1) + 2, 0, 0); // Hk.setElement(3 * (i + 1) + 2, 1, // (pytot / pxtot - 1) * (Pt / rho) * (1 / pxtot) * Vx); // Hk.setElement(3 * (i + 1) + 2, 2, // (pztot / pxtot - 1) * (Pt / rho) * (1 / pxtot) * Vx); - Hk.setElement(3 * (i + 1) + 2, 1, - 0); - Hk.setElement(3 * (i + 1) + 2, 2, - 0); + if (bscon) { + Hk.setElement(3 * (i + 1) + 2, 1, + (cos(phiv) * pytot / pxtot - sin(phiv)) * (Pt / rho) * (1 / pxtot) * Vx); + Hk.setElement(3 * (i + 1) + 2, 2, + (cos(phiv) * pztot / pxtot - sin(phiv)) * (Pt / rho) * (1 / pxtot) * Vx); + } else { + Hk.setElement(3 * (i + 1) + 2, 1, 0); + Hk.setElement(3 * (i + 1) + 2, 2, 0); + } // if(_debug)System.out.println("pxtot = "+pxtot+"; rho = "+rho+"; Pt = "+Pt); // if(_debug)System.out.println("cos(phiv)*pytot / pxtot - sin(phiv) = "+(cos(phiv)*pytot / pxtot - sin(phiv))); // if(_debug)System.out.println("Pt/(rho*pxtot) = "+(Pt / rho) * (1 / pxtot)); } - // the beam covariance - BasicMatrix Vk = new BasicMatrix(3, 3); - Vk.setElement(0, 0, _beamSize[0] * _beamSize[0]); - Vk.setElement(1, 1, _beamSize[1] * _beamSize[1]); - Vk.setElement(2, 2, _beamSize[2] * _beamSize[2]); - - //now do the matrix operations to get the constrained parameters - BasicMatrix Hkt = (BasicMatrix) MatrixOp.transposed(Hk); -// if(_debug)System.out.println("Ckm1Hk = " + MatrixOp.mult(Ckm1, Hk)); - - BasicMatrix Rk = (BasicMatrix) MatrixOp.mult(Hkt, MatrixOp.mult(Ckm1, Hk)); -// if(_debug)System.out.println("Pre Vk: Rk = " + Rk.toString()); - Rk = (BasicMatrix) MatrixOp.add(Rk, Vk); - BasicMatrix Rkinv = (BasicMatrix) MatrixOp.inverse(Rk); - BasicMatrix Kk = (BasicMatrix) MatrixOp.mult(Ckm1, MatrixOp.mult(Hk, Rkinv)); - -// if(_debug)System.out.println("Ckm1 = " + Ckm1.toString()); -// if(_debug)System.out.println("Hk = " + Hk.toString()); -// if(_debug)System.out.println("Rk = " + Rk.toString()); -// if(_debug)System.out.println("Vk = " + Vk.toString()); -// if(_debug)System.out.println("rk = " + rk.toString()); -// if(_debug)System.out.println("Kk = " + Kk.toString()); - _constrainedFit = MatrixOp.mult(Kk, rk); - _constrainedFit = MatrixOp.add(_constrainedFit, Xkm1);//Xk - - //ok, get the new covariance - BasicMatrix RkKkt = (BasicMatrix) MatrixOp.mult(Rk, MatrixOp.transposed(Kk)); - BasicMatrix HkCkm1 = (BasicMatrix) MatrixOp.mult(Hkt, Ckm1); - RkKkt = (BasicMatrix) MatrixOp.mult(1, RkKkt); - HkCkm1 = (BasicMatrix) MatrixOp.mult(-2, HkCkm1); - BasicMatrix sumMatrix = (BasicMatrix) MatrixOp.mult(Kk, MatrixOp.add(HkCkm1, RkKkt)); - _constrainedCov = (BasicMatrix) MatrixOp.add(Ckm1, sumMatrix); - - //update the regular parameter names to the constrained result -// if(_debug)System.out.println("Without Constraint : " + _vertexPosition.toString()); -// if(_debug)System.out.println("Without Constraint: x= "+_vertexPosition.e(0,0)); - // if(_debug)System.out.println(_constrainedFit.toString()); -// if(_debug)System.out.println("Without Constraint : " + _covVtx.toString()); - _vertexPosition = (BasicMatrix) MatrixOp.getSubMatrix(_constrainedFit, 0, 0, 3, 1); - _covVtx = (BasicMatrix) MatrixOp.getSubMatrix(_constrainedCov, 0, 0, 3, 3); -// if(_debug)System.out.println("With Constraint : " + _vertexPosition.toString()); -// if(_debug)System.out.println("With Constraint : " + _covVtx.toString()); - - for (int i = 0; i < _ntracks; i++) { - BasicMatrix ptmp = (BasicMatrix) MatrixOp.getSubMatrix(_constrainedFit, 3 * (i + 1), 0, 3, 1); - _pFit.set(i, ptmp); - } - -// if(_debug)System.out.println("Unconstrained chi^2 = "+_chiSq); - //ok...add to the chi^2 - if (_debug) - System.out.println(MatrixOp.mult(MatrixOp.transposed(rk), MatrixOp.mult(Rkinv, rk))); - _chiSq += MatrixOp.mult(MatrixOp.transposed(rk), MatrixOp.mult(Rkinv, rk)).e(0, 0); -// if(_debug)System.out.println("Constrained chi^2 = "+_chiSq); + return Hk; + } + + public BasicMatrix makeRk(double Vx, double Vy, double Vz, double pxtot, double pytot, double pztot, boolean bscon) { + //calculate the position of the A' at X=0 + BasicMatrix rk = new BasicMatrix(3, 1); + if (_debug) { + System.out.println("makeRk::Vx = " + Vx + "; Vy = " + Vy + "; Vz = " + Vz + "; pxtot = " + pxtot + "; pytot = " + pytot + "; pztot = " + pztot); + } + if (bscon) { + rk.setElement(0, 0, 0); + rk.setElement(1, 0, _beamPosition[1] - (Vy - pytot / pxtot * (Vx - _beamPosition[0]))); + rk.setElement(2, 0, _beamPosition[2] - (Vz - pztot / pxtot * (Vx - _beamPosition[0]))); + } else { + rk.setElement(0, 0, _beamPosition[0] - Vx); + rk.setElement(1, 0, _beamPosition[1] - Vy); + rk.setElement(2, 0, _beamPosition[2] - Vz); + } + return rk; } public void setV0(double[] v0) { @@ -716,15 +327,23 @@ _beamSize[2] = bs[2]; } + public void setBeamPosition(double[] bp) { + _beamPosition[0] = bp[0]; + _beamPosition[1] = bp[1]; + _beamPosition[2] = bp[2]; + } + public void doBeamSpotConstraint(boolean bsconst) { _beamspotConstraint = bsconst; - _constraintType="BeamspotConstrained"; - + _targetConstraint = false; + _constraintType = "BeamspotConstrained"; + } public void doTargetConstraint(boolean bsconst) { + _beamspotConstraint = false; _targetConstraint = bsconst; - _constraintType="TargetConstrained"; + _constraintType = "TargetConstrained"; } public double getChiSq() { @@ -742,12 +361,12 @@ mom[0] = Pt * Math.cos(phiv); mom[1] = Pt * Math.sin(phiv); mom[2] = Pt * 1 / Math.tan(theta); - if (_debug){ - System.out.println("getFittedMomentum:: "+mom[0] + "; " + mom[1] + "; " + mom[2]); - - System.out.println("pT= "+Pt+"; phi = "+phiv+"; B = "+ _bField); - } - return mom; + if (_debug) { + System.out.println("getFittedMomentum:: " + mom[0] + "; " + mom[1] + "; " + mom[2]); + + System.out.println("pT= " + Pt + "; phi = " + phiv + "; B = " + _bField); + } + return mom; } private double getInvMass() { @@ -772,15 +391,17 @@ double psum = Math.sqrt(pxsum * pxsum + pysum * pysum + pzsum * pzsum); double evtmass = esum * esum - psum * psum; - if (evtmass > 0) + if (evtmass > 0) { return Math.sqrt(evtmass); - else + } else { return -99; - } - + } + } + + @Override public String toString() { - StringBuffer sb = new StringBuffer("Vertex at : \nx= " + _vertexPosition.e(0, 0) + " +/- " + Math.sqrt(_covVtx.e(0, 0)) + "\ny= " + _vertexPosition.e(1, 0) + " +/- " + Math.sqrt(_covVtx.e(1, 1)) + "\nz= " + _vertexPosition.e(2, 0) + " +/- " + Math.sqrt(_covVtx.e(2, 2))); - return sb.toString(); + String sb = "Vertex at : \nx= " + _vertexPosition.e(0, 0) + " +/- " + Math.sqrt(_covVtx.e(0, 0)) + "\ny= " + _vertexPosition.e(1, 0) + " +/- " + Math.sqrt(_covVtx.e(1, 1)) + "\nz= " + _vertexPosition.e(2, 0) + " +/- " + Math.sqrt(_covVtx.e(2, 2)); + return sb; } private void follow1985Paper(List<BilliorTrack> tracks) { @@ -789,8 +410,8 @@ v0.setElement(0, 0, _v0[0]); v0.setElement(1, 0, _v0[1]); v0.setElement(2, 0, _v0[2]); - List<Matrix> params = new ArrayList<Matrix>(); - List<Matrix> q0s = new ArrayList<Matrix>(); +// List<Matrix> params = new ArrayList<Matrix>(); +// List<Matrix> q0s = new ArrayList<Matrix>(); List<Matrix> Gs = new ArrayList<Matrix>(); List<Matrix> Ds = new ArrayList<Matrix>(); List<Matrix> Es = new ArrayList<Matrix>(); @@ -809,13 +430,11 @@ tmpPar.setElement(2, 0, par[2]); tmpPar.setElement(3, 0, par[3]); tmpPar.setElement(4, 0, par[4]); - params.add(tmpPar); +// params.add(tmpPar); double theta = par[2]; - double phiv = par[3]; +// double phiv = par[3]; double rho = par[4]; - double Pt = Math.abs((1. / rho) * _bField * Constants.fieldConversion); - - +// double Pt = Math.abs((1. / rho) * _bField * Constants.fieldConversion); double cotth = 1. / tan(par[2]); double uu = v0.e(0, 0) * cos(par[3]) + v0.e(1, 0) * sin(par[3]);//Q @@ -833,15 +452,15 @@ BasicMatrix q0 = new BasicMatrix(3, 1); /* this looks just wrong... - q0.setElement(0, 0, Pt * Math.cos(phiv)); - q0.setElement(1, 0, Pt * Math.sin(phiv)); - q0.setElement(2, 0, Pt * 1 / Math.tan(theta)); - q0s.add(q0); + q0.setElement(0, 0, Pt * Math.cos(phiv)); + q0.setElement(1, 0, Pt * Math.sin(phiv)); + q0.setElement(2, 0, Pt * 1 / Math.tan(theta)); + q0s.add(q0); */ q0.setElement(0, 0, theta); q0.setElement(1, 0, phiVert); q0.setElement(2, 0, rho); - q0s.add(q0); +// q0s.add(q0); double cosf = cos(phiVert); double sinf = sin(phiVert); @@ -875,10 +494,11 @@ BasicMatrix tmpG = (BasicMatrix) MatrixOp.inverse(bt.covariance()); Gs.add(tmpG); - if (firstTrack) + if (firstTrack) { D0 = (BasicMatrix) MatrixOp.mult(MatrixOp.transposed(tmpA), MatrixOp.mult(tmpG, tmpA)); - else + } else { D0 = (BasicMatrix) MatrixOp.add(D0, MatrixOp.mult(MatrixOp.transposed(tmpA), MatrixOp.mult(tmpG, tmpA))); + } BasicMatrix tmpDi = (BasicMatrix) MatrixOp.mult(MatrixOp.transposed(tmpA), MatrixOp.mult(tmpG, tmpB)); BasicMatrix tmpEi = (BasicMatrix) MatrixOp.mult(MatrixOp.transposed(tmpB), MatrixOp.mult(tmpG, tmpB)); @@ -904,19 +524,21 @@ BasicMatrix beIbTg = (BasicMatrix) MatrixOp.mult(b, MatrixOp.mult(MatrixOp.inverse(e), MatrixOp.mult(MatrixOp.transposed(b), g))); BasicMatrix MinusaTgbeIbTg = (BasicMatrix) MatrixOp.mult(-1, MatrixOp.mult(aTg, beIbTg)); - if (firstTrack) + if (firstTrack) { bigsum = (BasicMatrix) MatrixOp.mult(MatrixOp.add(aTg, MinusaTgbeIbTg), p); - else + } else { bigsum = (BasicMatrix) MatrixOp.add(bigsum, MatrixOp.mult(MatrixOp.add(aTg, MinusaTgbeIbTg), p)); + } } BasicMatrix covVtx = (BasicMatrix) MatrixOp.inverse(tmpCovVtx); BasicMatrix xtilde = (BasicMatrix) MatrixOp.mult(covVtx, bigsum); - if (_debug) + if (_debug) { System.out.println("follow1985Paper::Vertex at : \nx= " + xtilde.e(0, 0) + " +/- " + Math.sqrt(covVtx.e(0, 0)) + "\ny= " + xtilde.e(1, 0) + " +/- " + Math.sqrt(covVtx.e(1, 1)) + "\nz= " + xtilde.e(2, 0) + " +/- " + Math.sqrt(covVtx.e(2, 2))); + } //ok, now the momentum - List<Matrix> qtildes = new ArrayList<Matrix>(); - List<Matrix> ptildes = new ArrayList<Matrix>(); +// List<Matrix> qtildes = new ArrayList<Matrix>(); +// List<Matrix> ptildes = new ArrayList<Matrix>(); List<Matrix> C0j = new ArrayList<Matrix>(); List<Matrix> pfit = new ArrayList<Matrix>(); Matrix[][] Cij = new Matrix[2][2];//max 2 tracks...just make this bigger for more @@ -934,32 +556,38 @@ BasicMatrix second = (BasicMatrix) MatrixOp.mult(MatrixOp.inverse(e), MatrixOp.mult(MatrixOp.transposed(b), g)); second = (BasicMatrix) MatrixOp.mult(second, p); BasicMatrix qtilde = (BasicMatrix) MatrixOp.add(first, second); - qtildes.add(qtilde); +// qtildes.add(qtilde); BasicMatrix ptilde = (BasicMatrix) MatrixOp.add(MatrixOp.mult(a, xtilde), MatrixOp.mult(b, qtilde)); - ptildes.add(ptilde); +// ptildes.add(ptilde); chisq += MatrixOp.mult(MatrixOp.transposed(MatrixOp.add(p, MatrixOp.mult(-1, ptilde))), MatrixOp.mult(g, MatrixOp.add(p, MatrixOp.mult(-1, ptilde)))).e(0, 0); - if (_debug) + if (_debug) { System.out.println("\n\nfollow1985Paper::Track #" + j); - if (_debug) + } + if (_debug) { System.out.println("eps(meas) = " + p.e(0, 0) + " eps(fit) =" + ptilde.e(0, 0)); - if (_debug) + } + if (_debug) { System.out.println("zp(meas) = " + p.e(1, 0) + " zp(fit) =" + ptilde.e(1, 0)); - if (_debug) + } + if (_debug) { System.out.println("theta(meas) = " + p.e(2, 0) + " theta(fit) =" + ptilde.e(2, 0)); - if (_debug) + } + if (_debug) { System.out.println("phi(meas) = " + p.e(3, 0) + " phi(fit) =" + ptilde.e(3, 0)); - if (_debug) + } + if (_debug) { System.out.println("rho(meas) = " + p.e(4, 0) + " rho(fit) =" + ptilde.e(4, 0)); + } BasicMatrix tmpC0j = (BasicMatrix) MatrixOp.mult(-1, MatrixOp.mult(covVtx, MatrixOp.mult(d, MatrixOp.inverse(e)))); C0j.add(tmpC0j); for (int i = 0; i < _ntracks; i++) { - BasicMatrix ai = (BasicMatrix) As.get(i); - BasicMatrix bi = (BasicMatrix) Bs.get(i); - BasicMatrix di = (BasicMatrix) Ds.get(i); - BasicMatrix ei = (BasicMatrix) Es.get(i); - BasicMatrix gi = (BasicMatrix) Gs.get(i); - BasicMatrix pi = (BasicMatrix) pis.get(i); +// BasicMatrix ai = (BasicMatrix) As.get(i); +// BasicMatrix bi = (BasicMatrix) Bs.get(i); +// BasicMatrix di = (BasicMatrix) Ds.get(i); +// BasicMatrix ei = (BasicMatrix) Es.get(i); +// BasicMatrix gi = (BasicMatrix) Gs.get(i); +// BasicMatrix pi = (BasicMatrix) pis.get(i); BasicMatrix tmpCij = (BasicMatrix) MatrixOp.mult(-1, MatrixOp.mult(MatrixOp.inverse(e), MatrixOp.mult(MatrixOp.transposed(d), tmpC0j))); Cij[i][j] = tmpCij; } @@ -970,8 +598,9 @@ pfit.add(tmppfit); } - if (_debug) + if (_debug) { System.out.println("follow1985Paper::chi^2 = " + chisq); + } _chiSq = chisq; _covVtx = covVtx; Modified: java/branches/jeremy-dev2/record-util/pom.xml ============================================================================= --- java/branches/jeremy-dev2/record-util/pom.xml (original) +++ java/branches/jeremy-dev2/record-util/pom.xml Wed Apr 13 12:42:42 2016 @@ -7,7 +7,7 @@ <groupId>org.hps</groupId> <artifactId>hps-parent</artifactId> <relativePath>../parent/pom.xml</relativePath> - <version>3.8-SNAPSHOT</version> + <version>3.9-SNAPSHOT</version> </parent> <scm> <url>http://java.freehep.org/svn/repos/hps/list/java/trunk/record-util/</url> Modified: java/branches/jeremy-dev2/record-util/src/main/java/org/hps/record/triggerbank/SSPNumberedTrigger.java ============================================================================= --- java/branches/jeremy-dev2/record-util/src/main/java/org/hps/record/triggerbank/SSPNumberedTrigger.java (original) +++ java/branches/jeremy-dev2/record-util/src/main/java/org/hps/record/triggerbank/SSPNumberedTrigger.java Wed Apr 13 12:42:42 2016 @@ -21,12 +21,38 @@ } /** + * Gets the number of the trigger which generated this object. + * @return Returns either <code>0</code> or </code>1</code>. + */ + public abstract int getTriggerNumber(); + + /** + * Indicates whether the trigger was reported by the trigger number + * 0 trigger. + * @return <code>true</code> if the trigger was reported by the + * trigger number 0 trigger and <code>false</code> if by either + * the trigger number 1 or an unknown trigger. + */ + public abstract boolean isTrigger0(); + + /** + * Indicates whether the trigger was reported by the trigger number + * 1 trigger. + * @return <code>true</code> if the trigger was reported by the + * trigger number 1 trigger and <code>false</code> if by either + * the trigger number 0 or an unknown trigger. + */ + public abstract boolean isTrigger1(); + + + /** * Indicates whether the trigger was reported by the first of the * singles triggers. * @return <code>true</code> if the trigger was reported by the * first trigger and <code>false</code> if it was reported by the * second trigger. */ + @Deprecated public abstract boolean isFirstTrigger(); /** @@ -36,5 +62,6 @@ * second trigger and <code>false</code> if it was reported by * the first trigger. */ + @Deprecated public abstract boolean isSecondTrigger(); -} +} Modified: java/branches/jeremy-dev2/record-util/src/main/java/org/hps/record/triggerbank/SSPPairTrigger.java ============================================================================= --- java/branches/jeremy-dev2/record-util/src/main/java/org/hps/record/triggerbank/SSPPairTrigger.java (original) +++ java/branches/jeremy-dev2/record-util/src/main/java/org/hps/record/triggerbank/SSPPairTrigger.java Wed Apr 13 12:42:42 2016 @@ -20,13 +20,30 @@ } @Override - public boolean isFirstTrigger() { + public int getTriggerNumber() { + if(isFirstTrigger()) { return 0; } + else if(isSecondTrigger()) { return 1; } + else { return -1; } + } + + @Override + public boolean isTrigger0() { return (type == SSPData.TRIG_TYPE_PAIR0); } @Override + public boolean isTrigger1() { + return (type == SSPData.TRIG_TYPE_PAIR1); + } + + @Override + public boolean isFirstTrigger() { + return isTrigger0(); + } + + @Override public boolean isSecondTrigger() { - return (type == SSPData.TRIG_TYPE_PAIR1); + return isTrigger1(); } /** Modified: java/branches/jeremy-dev2/record-util/src/main/java/org/hps/record/triggerbank/SSPSinglesTrigger.java ============================================================================= --- java/branches/jeremy-dev2/record-util/src/main/java/org/hps/record/triggerbank/SSPSinglesTrigger.java (original) +++ java/branches/jeremy-dev2/record-util/src/main/java/org/hps/record/triggerbank/SSPSinglesTrigger.java Wed Apr 13 12:42:42 2016 @@ -26,13 +26,30 @@ } @Override - public boolean isFirstTrigger() { + public int getTriggerNumber() { + if(isFirstTrigger()) { return 0; } + else if(isSecondTrigger()) { return 1; } + else { return -1; } + } + + @Override + public boolean isTrigger0() { return (type == SSPData.TRIG_TYPE_SINGLES0_BOT) || (type == SSPData.TRIG_TYPE_SINGLES0_TOP); } @Override + public boolean isTrigger1() { + return (type == SSPData.TRIG_TYPE_SINGLES1_BOT) || (type == SSPData.TRIG_TYPE_SINGLES1_TOP); + } + + @Override + public boolean isFirstTrigger() { + return isTrigger0(); + } + + @Override public boolean isSecondTrigger() { - return (type == SSPData.TRIG_TYPE_SINGLES1_BOT) || (type == SSPData.TRIG_TYPE_SINGLES1_TOP); + return isTrigger1(); } /** Modified: java/branches/jeremy-dev2/record-util/src/main/java/org/hps/record/triggerbank/TriggerModule.java ============================================================================= --- java/branches/jeremy-dev2/record-util/src/main/java/org/hps/record/triggerbank/TriggerModule.java (original) +++ java/branches/jeremy-dev2/record-util/src/main/java/org/hps/record/triggerbank/TriggerModule.java Wed Apr 13 12:42:42 2016 @@ -444,6 +444,38 @@ } /** + * Gets the angle between the cluster and the centerpoint of the + * calorimeter. + * @param cluster - The cluster for which to calculate the angle. + * @return Returns the cluster angle as an <code>int</code> in units + * of degrees. + */ + public static int getClusterAngle(Cluster cluster) { + // Get the cluster position. + double x = getClusterX(cluster); + double y = getClusterY(cluster); + + // Return the cluster angle. + return getClusterAngle(x, y); + } + + /** + * Gets the angle between the cluster and the centerpoint of the + * calorimeter. + * @param cluster - The cluster for which to calculate the angle. + * @return Returns the cluster angle as an <code>int</code> in units + * of degrees. + */ + public static int getClusterAngle(SSPCluster cluster) { + // Get the cluster position. + double x = getClusterX(cluster); + double y = getClusterY(cluster); + + // Return the cluster angle. + return getClusterAngle(x, y); + } + + /** * Calculates the distance between the origin and a cluster. * @param cluster - The cluster pair from which the value should * be calculated. @@ -1260,6 +1292,18 @@ } /** + * Gets the angle between the cluster and the centerpoint of the + * calorimeter. + * @param x - The cluster seed x-position. + * @param y - The cluster seed y-position. + * @return Returns the cluster angle as an <code>int</code> in units + * of degrees. + */ + private static int getClusterAngle(double x, double y) { + return (int) Math.round(Math.atan(x / y) * 180.0 / Math.PI); + } + + /** * Calculates the distance between the origin and a cluster. * @param x - The cluster's x-position. * @param z - The cluster's z-position. @@ -1309,7 +1353,7 @@ // Get the cluster angles. int[] clusterAngle = new int[2]; for(int i = 0; i < 2; i++) { - clusterAngle[i] = (int) Math.round(Math.atan(x[i] / y[i]) * 180.0 / Math.PI); + clusterAngle[i] = getClusterAngle(x[i], y[i]); //(int) Math.round(Math.atan(x[i] / y[i]) * 180.0 / Math.PI); } // Calculate the coplanarity cut value. @@ -1738,4 +1782,4 @@ { 340.013, 97.070, -87.790 } } }; -} +} Modified: java/branches/jeremy-dev2/run-database/pom.xml ============================================================================= --- java/branches/jeremy-dev2/run-database/pom.xml (original) +++ java/branches/jeremy-dev2/run-database/pom.xml Wed Apr 13 12:42:42 2016 @@ -7,7 +7,7 @@ <groupId>org.hps</groupId> <artifactId>hps-parent</artifactId> <relativePath>../parent/pom.xml</relativePath> - <version>3.8-SNAPSHOT</version> + <version>3.9-SNAPSHOT</version> </parent> <scm> <url>http://java.freehep.org/svn/repos/hps/list/java/trunk/run-database/</url> Modified: java/branches/jeremy-dev2/run-database/src/main/java/org/hps/run/database/RunManager.java ============================================================================= --- java/branches/jeremy-dev2/run-database/src/main/java/org/hps/run/database/RunManager.java (original) +++ java/branches/jeremy-dev2/run-database/src/main/java/org/hps/run/database/RunManager.java Wed Apr 13 12:42:42 2016 @@ -108,7 +108,9 @@ } String uri = "jdbc:mysql://" + host + ":" + port + "/" + database + "?" + "user=" + user + "&" + "password=" + password; - LOGGER.config("run db URI " + uri); + + LOGGER.config("run database URI " + uri); + return DatabaseUtilities.createDataSource(uri); } Modified: java/branches/jeremy-dev2/steering-files/pom.xml ============================================================================= --- java/branches/jeremy-dev2/steering-files/pom.xml (original) +++ java/branches/jeremy-dev2/steering-files/pom.xml Wed Apr 13 12:42:42 2016 @@ -8,7 +8,7 @@ <groupId>org.hps</groupId> <artifactId>hps-parent</artifactId> <relativePath>../parent/pom.xml</relativePath> - <version>3.8-SNAPSHOT</version> + <version>3.9-SNAPSHOT</version> </parent> <scm> <url>http://java.freehep.org/svn/repos/hps/list/java/trunk/steering-files/</url> Modified: java/branches/jeremy-dev2/tracking/pom.xml ============================================================================= --- java/branches/jeremy-dev2/tracking/pom.xml (original) +++ java/branches/jeremy-dev2/tracking/pom.xml Wed Apr 13 12:42:42 2016 @@ -8,7 +8,7 @@ <groupId>org.hps</groupId> <artifactId>hps-parent</artifactId> <relativePath>../parent/pom.xml</relativePath> - <version>3.8-SNAPSHOT</version> + <version>3.9-SNAPSHOT</version> </parent> <scm> <url>http://java.freehep.org/svn/repos/hps/list/java/trunk/tracking/</url> Modified: java/branches/jeremy-dev2/users/pom.xml ============================================================================= --- java/branches/jeremy-dev2/users/pom.xml (original) +++ java/branches/jeremy-dev2/users/pom.xml Wed Apr 13 12:42:42 2016 @@ -7,7 +7,7 @@ <groupId>org.hps</groupId> <artifactId>hps-parent</artifactId> <relativePath>../parent/pom.xml</relativePath> - <version>3.8-SNAPSHOT</version> + <version>3.9-SNAPSHOT</version> </parent> <scm> <url>http://java.freehep.org/svn/repos/hps/list/java/trunk/users/</url> Modified: java/branches/jeremy-dev2/util/pom.xml ============================================================================= --- java/branches/jeremy-dev2/util/pom.xml (original) +++ java/branches/jeremy-dev2/util/pom.xml Wed Apr 13 12:42:42 2016 @@ -7,7 +7,7 @@ <groupId>org.hps</groupId> <artifactId>hps-parent</artifactId> <relativePath>../parent/pom.xml</relativePath> - <version>3.8-SNAPSHOT</version> + <version>3.9-SNAPSHOT</version> </parent> <scm> <url>http://java.freehep.org/svn/repos/hps/list/java/trunk/util/</url>