LISTSERV mailing list manager LISTSERV 16.5

Help for HPS-SVN Archives


HPS-SVN Archives

HPS-SVN Archives


HPS-SVN@LISTSERV.SLAC.STANFORD.EDU


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

HPS-SVN Home

HPS-SVN Home

HPS-SVN  November 2014

HPS-SVN November 2014

Subject:

r1442 - in /java/trunk/tracking/src/main/java/org/hps/recon/tracking/gbl: GblData.java GblTrajectory.java HpsGblRefitter.java MilleBinary.java

From:

[log in to unmask]

Reply-To:

Notification of commits to the hps svn repository <[log in to unmask]>

Date:

Wed, 5 Nov 2014 21:46:09 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (231 lines)

Author: ngraf
Date: Wed Nov  5 13:46:05 2014
New Revision: 1442

Log:
Enable writing of millepedeII binary files.

Modified:
    java/trunk/tracking/src/main/java/org/hps/recon/tracking/gbl/GblData.java   (contents, props changed)
    java/trunk/tracking/src/main/java/org/hps/recon/tracking/gbl/GblTrajectory.java   (contents, props changed)
    java/trunk/tracking/src/main/java/org/hps/recon/tracking/gbl/HpsGblRefitter.java   (contents, props changed)
    java/trunk/tracking/src/main/java/org/hps/recon/tracking/gbl/MilleBinary.java   (contents, props changed)

Modified: java/trunk/tracking/src/main/java/org/hps/recon/tracking/gbl/GblData.java
 =============================================================================
--- java/trunk/tracking/src/main/java/org/hps/recon/tracking/gbl/GblData.java	(original)
+++ java/trunk/tracking/src/main/java/org/hps/recon/tracking/gbl/GblData.java	Wed Nov  5 13:46:05 2014
@@ -1,5 +1,6 @@
 package org.hps.recon.tracking.gbl;
 
+import static java.lang.Math.sqrt;
 import java.util.ArrayList;
 import java.util.List;
 import org.hps.recon.tracking.gbl.matrix.Matrix;
@@ -270,27 +271,27 @@
         return theParameters.size();
     }
 
-//
-///// Get all Data for MP-II binary record.
-///**
-// * \param [out] fValue Value
-// * \param [out] fErr Error
-// * \param [out] indLocal List of labels of local parameters
-// * \param [out] derLocal List of derivatives for local parameters
-// * \param [out] labGlobal List of labels of global parameters
-// * \param [out] derGlobal List of derivatives for global parameters
-// */
-//void getAllData(float &fValue, float &fErr,
-//		std::vector<unsigned int>* &indLocal, std::vector<double>* &derLocal,
-//		std::vector<int>* &labGlobal, std::vector<double>* &derGlobal) {
-//	fValue = theValue;
-//	fErr = 1.0 / sqrt(thePrecision);
-//	indLocal = &theParameters;
-//	derLocal = &theDerivatives;
-//	labGlobal = &globalLabels;
-//	derGlobal = &globalDerivatives;
-//}
-//
+
+/// Get all Data for MP-II binary record.
+/**
+ * \param [out] fValue Value
+ * \param [out] fErr Error
+ * \param [out] indLocal List of labels of local parameters
+ * \param [out] derLocal List of derivatives for local parameters
+ * \param [out] labGlobal List of labels of global parameters
+ * \param [out] derGlobal List of derivatives for global parameters
+ */
+void getAllData(float[] floats,
+		List<Integer> indLocal, List<Double> derLocal,
+		List<Integer> labGlobal, List<Double> derGlobal) {
+	floats[0] = (float)theValue;
+	floats[1] = (float) (1.0 / sqrt(thePrecision));
+	indLocal.addAll(theParameters);
+	derLocal.addAll(theDerivatives);
+	labGlobal.addAll(globalLabels);
+	derGlobal.addAll(globalDerivatives);
+}
+
 ///// Get data for residual (and errors).
 ///**
 // * \param [out] aResidual Measurement-Prediction

Modified: java/trunk/tracking/src/main/java/org/hps/recon/tracking/gbl/GblTrajectory.java
 =============================================================================
--- java/trunk/tracking/src/main/java/org/hps/recon/tracking/gbl/GblTrajectory.java	(original)
+++ java/trunk/tracking/src/main/java/org/hps/recon/tracking/gbl/GblTrajectory.java	Wed Nov  5 13:46:05 2014
@@ -34,11 +34,6 @@
     public void fit(double m_chi2, int m_ndf, int m_lost_weight)
     {
         // TODO Auto-generated method stub
-    }
-
-    public void milleOut(MilleBinary mille)
-    {
-        // TODO implement binary writeout of millepedeII data
     }
 
     /**
@@ -756,30 +751,27 @@
         return ierr;
     }
 
-    //TODO Implement the millepedeII output
-///// Write trajectory to Millepede-II binary file.
-//void milleOut(MilleBinary &aMille) {
-//	float fValue;
-//	float fErr;
-//	List< int>* indLocal;
-//	List<double>* derLocal;
-//	List<int>* labGlobal;
-//	List<double>* derGlobal;
-//
-//	if (not constructOK)
-//		return;
-//
-////   data: measurements, kinks and external seed
-//	List<GblData>::iterator itData;
-//	for (itData = theData.begin(); itData != theData.end(); ++itData) {
-//		itData->getAllData(fValue, fErr, indLocal, derLocal, labGlobal,
-//				derGlobal);
-//		aMille.addData(fValue, fErr, *indLocal, *derLocal, *labGlobal,
-//				*derGlobal);
-//	}
-//	aMille.writeRecord();
-//}
+
+// Write trajectory to Millepede-II binary file.
+    public void milleOut(MilleBinary aMille)
+    {
+        if (!constructOK) {
+            throw new RuntimeException("GblTrajectory milleOut not properly constructed");
+        }
+//   data: measurements, kinks and external seed
+        for (GblData d : theData) {
+            float[] floats = new float[2]; // fValue , fErr
+            List<Integer> indLocal = new ArrayList<Integer>();
+            List<Double> derLocal = new ArrayList<Double>();
+            List<Integer> labGlobal = new ArrayList<Integer>();
+            List<Double> derGlobal = new ArrayList<Double>();
+            d.getAllData(floats, indLocal, derLocal, labGlobal, derGlobal);
+            aMille.addData(floats[0], floats[1], indLocal, derLocal, labGlobal, derGlobal);
+        }
+        aMille.writeRecord();
+    }
 /// Print GblTrajectory
+
     /**
      * \param [in] level print level (0: minimum, >0: more)
      */

Modified: java/trunk/tracking/src/main/java/org/hps/recon/tracking/gbl/HpsGblRefitter.java
 =============================================================================
--- java/trunk/tracking/src/main/java/org/hps/recon/tracking/gbl/HpsGblRefitter.java	(original)
+++ java/trunk/tracking/src/main/java/org/hps/recon/tracking/gbl/HpsGblRefitter.java	Wed Nov  5 13:46:05 2014
@@ -23,9 +23,9 @@
 import org.hps.recon.tracking.gbl.matrix.Vector;
 
 /**
- * A Driver which refits tracks using GBL. 
- * Modeled on the hps-dst code written by Per Hansson and Omar Moreno. 
- * Requires the GBL Collections and Relations to be present in the event.
+ * A Driver which refits tracks using GBL. Modeled on the hps-dst code written
+ * by Per Hansson and Omar Moreno. Requires the GBL Collections and Relations to
+ * be present in the event.
  *
  * @author Norman A Graf
  *
@@ -39,9 +39,43 @@
     private final String track2GblTrackRelationName = "TrackToGBLTrack";
     private final String gblTrack2StripRelationName = "GBLTrackToStripData";
 
+    private MilleBinary mille;
+    private String milleBinaryFileName = MilleBinary.DEFAULT_OUTPUT_FILE_NAME;
+    private boolean writeMilleBinary = false;
+
     public void setDebug(boolean debug)
     {
         _debug = debug;
+    }
+
+    public void setMilleBinaryFileName(String filename)
+    {
+        milleBinaryFileName = filename;
+    }
+
+    public void setWriteMilleBinary(boolean writeMillepedeFile)
+    {
+        writeMilleBinary = writeMillepedeFile;
+    }
+
+    public HpsGblRefitter()
+    {
+    }
+
+    @Override
+    protected void startOfData()
+    {
+        if (writeMilleBinary) {
+            mille = new MilleBinary(milleBinaryFileName);
+        }
+    }
+
+    @Override
+    protected void endOfData()
+    {
+        if (writeMilleBinary) {
+            mille.close();
+        }
     }
 
     @Override
@@ -376,7 +410,9 @@
         }
 
 //	// write to MP binary file
-//	traj.milleOut(mille);
+        if (writeMilleBinary) {
+            traj.milleOut(mille);
+        }
 //
         return 0;
     }

Modified: java/trunk/tracking/src/main/java/org/hps/recon/tracking/gbl/MilleBinary.java
 =============================================================================
--- java/trunk/tracking/src/main/java/org/hps/recon/tracking/gbl/MilleBinary.java	(original)
+++ java/trunk/tracking/src/main/java/org/hps/recon/tracking/gbl/MilleBinary.java	Wed Nov  5 13:46:05 2014
@@ -123,8 +123,8 @@
      */
         public void writeRecord()
     {
-        int recordLength = _intBuffer.size() * 2;
-        ByteBuffer b = ByteBuffer.allocate((recordLength + 1) * 2);
+        int recordLength = _intBuffer.size() * 2 * 4; // writing both ints and floats, each is 4 bytes
+        ByteBuffer b = ByteBuffer.allocate((recordLength + 1) * 2); // writing one extra word per collection
         b.order(ByteOrder.LITTLE_ENDIAN);
         b.putInt(recordLength);
         for (Float f : _floatBuffer) {

Top of Message | Previous Page | Permalink

Advanced Options


Options

Log In

Log In

Get Password

Get Password


Search Archives

Search Archives


Subscribe or Unsubscribe

Subscribe or Unsubscribe


Archives

November 2017
August 2017
July 2017
January 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013

ATOM RSS1 RSS2



LISTSERV.SLAC.STANFORD.EDU

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager

Privacy Notice, Security Notice and Terms of Use