11 added + 5 modified, total 16 files
LCGO
diff -u -r1.2 -r1.3
--- GeometryReaderTest.xml 30 Oct 2006 10:52:18 -0000 1.2
+++ GeometryReaderTest.xml 5 Nov 2006 16:29:12 -0000 1.3
@@ -1,7 +1,6 @@
-<!-- lccdd xmlns:compact="http://www.lcsim.org/schemas/compact/1.0"
+<lccdd xmlns:compact="http://www.lcsim.org/schemas/compact/1.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
- xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/compact/1.0/compact.xsd" -->
-<lccdd>
+ xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/compact/1.0/compact.xsd" >
<!-- info tag containing author, version, time, unique id (url) -->
<info name="GeometryReaderTest">
<comment>
@@ -44,7 +43,7 @@
</materials>
<detectors>
- <detector name="VXD" geartype="VXDParameters">
+ <detector name="VXD" geartype="VXDParameters" type="UNKNWON" id="42">
<vxdType technology="CCD" />
<shell halfLength="135.000000" gap="0.040000" innerRadius="65.000000" outerRadius="65.493920" radLength="352.759946" />
<layers>
LCGO
diff -u -r1.2 -r1.3
--- test.cc 30 Oct 2006 10:52:18 -0000 1.2
+++ test.cc 5 Nov 2006 16:29:12 -0000 1.3
@@ -11,7 +11,13 @@
#include "hep/gear/base/UnknownParameterException.h"
#include "hep/gear/implementation/GearParametersImpl.h"
+#include "LCIOExceptionHandler.h"
+
+
#include <cmath>
+#include <vector>
+#include <algorithm>
+
using namespace hep::lcgo::xml::reader;
using namespace hep::gear::api ;
@@ -42,22 +48,29 @@
int main(int argc, char *argv[])
{
+ CPPExceptionHandler exHan ;
+ exHan.init() ;
// fg: can't mix C++ and Java exceptions in compilation unit
// --- unexpected and terminate don't work for Java Exceptions...
-// std::set_unexpected( lcgo_unexpected ) ;
-// std::set_terminate( lcgo_unexpected ) ;
+// std::set_unexpected( lcgo_unexpected ) ;
+// std::set_terminate( lcgo_unexpected ) ;
- try{
+ try{
- LCGO lcgo("GeometryReaderTest.xml");
+
+ LCGO lcgo("GeometryReaderTest.xml");
Detector* det = lcgo.getDetector();
Map* constants = det->getConstants();
cout << det << endl;
cout << constants << endl;
+
+ //throw new java::lang::Exception(JvNewStringLatin1(" can even mix c++ with java exception throws " ) );
+// throw CPPException(" can even mix c++ with java exception throws " ) ;
+
testGearAPI( det ) ;
@@ -205,9 +218,9 @@
pImpl->setIntVals( JvNewStringLatin1("SomeCoolNewIntvals") , newIntsC.j_ar() ) ;
- // test iterator
- std::vector<int> stdv ;
- std::copy( newIntsC.begin() , newIntsC.end() , std::back_inserter( stdv ) ) ;
+// // test iterator
+// std::vector<int> stdv ;
+// std::copy( newIntsC.begin() , newIntsC.end() , std::back_inserter( stdv ) ) ;
// --- now modify existing parameters
try{
LCGO/src/cpp
diff -u -r1.2 -r1.3
--- LCGOUtil.cc 30 Oct 2006 10:52:20 -0000 1.2
+++ LCGOUtil.cc 5 Nov 2006 16:29:13 -0000 1.3
@@ -1,5 +1,8 @@
#include "LCGOUtil.h"
#include "hep/gear/api/GearParameters.h"
+#include "java/lang/Exception.h"
+
+
std::ostream& operator << (std::ostream& os, const java::lang::Object* obj)
{
@@ -23,3 +26,25 @@
}
os << "} " << std::endl ;
}
+
+
+ cjstring::cjstring( jstring jstr ) {
+
+
+
+ int l = JvGetStringUTFLength(jstr);
+ char* t = new char[l+1];
+
+ JvGetStringUTFRegion(jstr,0,l,t);
+ *(t+l)='\0';
+ _text = t ;
+
+ delete[] t ;
+
+
+// throw new java::lang::Exception(JvNewStringLatin1(" some Java exception thrown out of nowhere .... ") ) ;
+
+// throw CPPException(" some C++ exception thrown out of nowhere .... " ) ;
+
+
+ } ;
LCGO/src/include
diff -u -r1.2 -r1.3
--- LCGOUtil.h 30 Oct 2006 10:52:21 -0000 1.2
+++ LCGOUtil.h 5 Nov 2006 16:29:13 -0000 1.3
@@ -10,10 +10,30 @@
#include <gcj/array.h>
#include <algorithm>
#include <string>
+#include <exception>
std::ostream& operator << (std::ostream& os, const java::lang::Object* obj);
+ class CPPException : public std::exception {
+
+
+ protected:
+ std::string message ;
+
+ CPPException(){ /*no_op*/ ; }
+
+ public:
+ virtual ~CPPException() throw() { /*no_op*/; }
+
+ CPPException( const std::string& text ){
+ message = "C++ Exception: " + text ;
+ }
+
+ virtual const char* what() const throw() { return message.c_str() ; }
+
+ };
+
/** Conversion of jintArray to std::vector<int> */
class GearIntVec : public std::vector<int>{
@@ -75,21 +95,29 @@
std::string _text ;
public:
+ cjstring() : _text( "" ) {
+
+ std::cout << " _text( \"\" ) " << std::endl ;
+ } ;
+
cjstring( const std::string& str ) : _text( str ) {} ;
cjstring( const char* text) : _text( text ) {} ;
- cjstring( jstring jstr ) {
+ cjstring( jstring jstr ) ;
+// cjstring( jstring jstr ) {
+
+// throw new Exception(" some C++ exception thrown out of nowhere .... " ) ;
- int l = JvGetStringUTFLength(jstr);
- char* t = new char[l+1];
+// int l = JvGetStringUTFLength(jstr);
+// char* t = new char[l+1];
- JvGetStringUTFRegion(jstr,0,l,t);
- *(t+l)='\0';
- _text = t ;
+// JvGetStringUTFRegion(jstr,0,l,t);
+// *(t+l)='\0';
+// _text = t ;
- delete[] t ;
- } ;
+// delete[] t ;
+// } ;
/** Conversion to java string - creates new object on the (java) heap */
operator jstring() {
LCGO/src/java/hep/lcgo/api
diff -N CellIDGeometer.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ CellIDGeometer.java 5 Nov 2006 16:29:13 -0000 1.1
@@ -0,0 +1,37 @@
+package hep.lcgo.api;
+
+import hep.gear.base.Vector3D;
+
+
+public interface CellIDGeometer {
+
+ long getCellIDAt( Vector3D position ) ;
+
+ Vector3D getPositionOf( long cellID ) ;
+
+ int getLayer( long cellID ) ;
+
+ // FIXME: this might reqire conventions for the detector id to
+ // be stored in _every_ cellid ;
+ int getSubdetectorID( long cellID ) ;
+
+ /** Names of the cellid fields that correspond to the
+ * three dimensional coordinates, e.g. "layer", "u", "v"
+ */
+ String[] getCellIDCoordinates() ;
+
+ boolean supportsNeighbors() ;
+
+ long[] getNearestNeighborIDs() ;
+
+ /** Returns the n-th neighbors in every direction, e.g.
+ * getNeighborIDs(2,2,2) would return the next to nearest
+ * neighbors.
+ */
+ long[] getNeighborIDs(int[] deltaCoordinates ) ;
+
+ /** True if the given cellid is withihn the valid range */
+ boolean isValid( long cellID ) ;
+
+}
+
LCGO/src/java/hep/lcgo/api
diff -N DetailedGeometry.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ DetailedGeometry.java 5 Nov 2006 16:29:13 -0000 1.1
@@ -0,0 +1,12 @@
+package hep.lcgo.api;
+
+
+/** Somehow we need to have/get the detailed (geant4) like geometry of
+ * the detector
+ *
+ * @author gaede
+ *
+ */
+public interface DetailedGeometry {
+
+}
LCGO/src/java/hep/lcgo/api
diff -N Detector.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Detector.java 5 Nov 2006 16:29:13 -0000 1.1
@@ -0,0 +1,53 @@
+package hep.lcgo.api;
+
+import java.net.URL;
+import java.util.List;
+
+
+/** Proposal for the detector interface in LCGO
+ *
+ * @author gaede
+ * @version $Id: Detector.java,v 1.1 2006/11/05 16:29:13 gaede Exp $
+ */
+
+public interface Detector {
+
+ /** A name that uniquely defines the detector model */
+ String getName() ;
+
+ /** The author */
+ String getAuthor() ;
+
+ /** The description of the detector model */
+ String getDescritpion() ;
+
+ /** A URL that points to a more detailed description of the detector, e.g.
+ * a paper or report
+ */
+ URL getURL() ;
+
+
+ String[] getSubdetectorNames() ;
+
+ Subdetector getSubdetector(int systemID ) ;
+
+ Subdetector getSubdetector(String name) ;
+
+ /** All subdetectors in this detector - ordered ?*/
+ List getSubdetectors() ;
+
+
+ FieldMap getBField() ;
+
+
+ Parameters getParameters() ;
+
+ /** FIXME: this is probably not what we want - however somehow we need
+ * tp get the deteailed geoemtetry
+ *
+ */
+ DetailedGeometry getDetailedGeometry() ;
+
+
+
+}
LCGO/src/java/hep/lcgo/api
diff -N Envelope.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Envelope.java 5 Nov 2006 16:29:13 -0000 1.1
@@ -0,0 +1,9 @@
+package hep.lcgo.api;
+
+import hep.gear.base.Vector3D;
+
+public interface Envelope {
+
+ boolean contains(Vector3D point) ;
+
+}
LCGO/src/java/hep/lcgo/api
diff -N FieldMap.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ FieldMap.java 5 Nov 2006 16:29:13 -0000 1.1
@@ -0,0 +1,15 @@
+package hep.lcgo.api;
+
+import hep.gear.base.Vector3D;
+
+
+
+public interface FieldMap {
+
+ /** The field at the given position */
+ Vector3D at( Vector3D pos ) ;
+
+ /** Fills the field at the given position into the vector field */
+ void getField( Vector3D pos, Vector3D field) ;
+
+}
LCGO/src/java/hep/lcgo/api
diff -N Parameters.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Parameters.java 5 Nov 2006 16:29:13 -0000 1.1
@@ -0,0 +1,72 @@
+// AID-GENERATED
+// =========================================================================
+// This class was generated by AID - Abstract Interface Definition
+// DO NOT MODIFY, but use the org.freehep.aid.Aid utility to regenerate it.
+// =========================================================================
+
+package hep.lcgo.api;
+
+import hep.gear.base.UnknownParameterException;
+
+/** Abstract interface for a set of parameters that can be used to describe the
+ * geometrical properties of a specific subdetector type for reconstruction.
+ * It basically allows to retrieve named parameters of type int, string and double
+ * and arrays/vectors of these types.
+ * @author F. Gaede, DESY
+ * @version $Id: Parameters.java,v 1.1 2006/11/05 16:29:13 gaede Exp $
+ */
+
+// FIXME: doubles and ints values should support expressions (units ),e.g. 12*cm
+// FIXME: question: should we allow value="bla" and <constant> bla </constant> ?
+
+public interface Parameters {
+
+ /** Integer value for key.
+ * @throws UnknownParameterException
+ */
+ public int getIntValue(String key) throws UnknownParameterException;
+
+ /** Double value for key
+ * @throws UnknownParameterException
+ */
+ public double getDoubleValue(String key) throws UnknownParameterException;
+
+ /** String value for key
+ * @throws UnknownParameterException
+ */
+ public String getStringValue(String key) throws UnknownParameterException;
+
+ /** Integer values for key
+ * @throws UnknownParameterException
+ */
+ public int[] getIntValues(String key) throws UnknownParameterException;
+
+ /** Double values for key
+ * @throws UnknownParameterException
+ */
+ public double[] getDoubleValues(String key) throws UnknownParameterException;
+
+ /** String values for key
+ * @throws UnknownParameterException
+ */
+ public String[] getStringValues(String key) throws UnknownParameterException;
+
+ /** All keys of int variables. */
+ public String[] getIntKeys();
+
+ /** All keys of double variables. */
+ public String[] getDoubleKeys();
+
+ /** All keys of string variables. */
+ public String[] getStringKeys();
+
+ /** All keys of IntVec variables. */
+ public String[] getIntVecKeys();
+
+ /** All keys of DoubleVec variables. */
+ public String[] getDoubleVecKeys();
+
+ /** All keys of StringVec variables. */
+ public String[] getStringVecKeys();
+} // class or interface
+
LCGO/src/java/hep/lcgo/api
diff -N Readout.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Readout.java 5 Nov 2006 16:29:14 -0000 1.1
@@ -0,0 +1,9 @@
+package hep.lcgo.api;
+
+import hep.lcgo.util.id.IDDecoder;
+
+public interface Readout {
+
+ IDDecoder getIDDecoder() ;
+
+}
LCGO/src/java/hep/lcgo/api
diff -N Subdetector.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Subdetector.java 5 Nov 2006 16:29:14 -0000 1.1
@@ -0,0 +1,51 @@
+package hep.lcgo.api;
+
+/** Proposal for the subdetector interface in LCGO
+ *
+ * @author gaede
+ * @version $Id: Subdetector.java,v 1.1 2006/11/05 16:29:14 gaede Exp $
+ */
+
+public interface Subdetector {
+
+
+ public static final int TRACKER = 1 ; ;
+ public static final int CALORIMETER = 2 ;
+
+ public static final String TYPE="type" ;
+ public static final String TECHNOLOGY="technology" ;
+
+
+ /** A name that uniquely defines the subdetector model */
+ String getName() ;
+
+ /** Unique id of this subdetector */
+ int getSystemID() ;
+
+
+ /** The description of the subdetector model */
+ String getDescription() ;
+
+ /** Returns either Subdetector.TRACKER or Subdetector.CALORIMETER
+ * Convenient method using<br>
+ * s.getParameters().getStringValue("Type") == "Calorimeter" ;
+ * */
+ int getType() ;
+
+ /** Convenient for s.getParameters().getStringValue("Technology") ; */
+ String getTechnology() ;
+
+
+ /** FIXME; are parameters and attributes the same thing ? */
+ Parameters getParameters() ;
+
+
+ Readout getReadout() ;
+
+ // NOTE: forward and backward endcap should have _one_ common enevelope
+ Envelope getEnvelope() ;
+}
+
+
+
+
LCGO/src/java/hep/lcgo/util/id
diff -N IDDecoder.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ IDDecoder.java 5 Nov 2006 16:29:14 -0000 1.1
@@ -0,0 +1,83 @@
+package hep.lcgo.util.id ;
+
+/**
+ *
+ * @author tonyj
+ */
+public class IDDecoder
+{
+ private IDDescriptor desc;
+ private long id;
+
+ /** Creates a new instance of IIDecoder */
+ public IDDecoder(IDDescriptor desc)
+ {
+ this.desc = desc;
+ }
+
+ IDDescriptor getDescriptor() { return desc ; }
+
+ public void setID(long id)
+ {
+ this.id = id;
+ }
+
+ public int getFieldIndex(String name)
+ {
+ return desc.indexOf(name);
+ }
+
+ public int getValue(String name)
+ {
+ return getValue(desc.indexOf(name));
+ }
+
+ public int getValue(int index)
+ {
+ int start = desc.fieldStart(index);
+ int length = desc.fieldLength(index);
+ int mask = (1<<length) - 1;
+
+ int result = (int) ((id >> start) & mask);
+ if (desc.isSigned(index))
+ {
+ int signBit = 1<<(length-1);
+ if ((result & signBit) != 0) result -= (1<<length);
+ }
+ return result;
+ }
+
+ public int[] getValues(int[] buffer)
+ {
+ if (buffer.length != desc.fieldCount()) throw new IllegalArgumentException("Invalid buffer length");
+ for (int i=0; i<buffer.length; i++)
+ {
+ buffer[i] = getValue(i);
+ }
+ return buffer;
+ }
+
+ public int getFieldCount()
+ {
+ return desc.fieldCount();
+ }
+
+ public String getFieldName(int index)
+ {
+ return desc.fieldName(index);
+ }
+
+ public String toString()
+ {
+ StringBuffer sb = new StringBuffer();
+ for (int i=0; i<desc.fieldCount();)
+ {
+ sb.append(desc.fieldName(i));
+ sb.append(':');
+ sb.append(getValue(i));
+ if (++i >= desc.fieldCount()) break;
+ sb.append(',');
+ }
+ return sb.toString();
+ }
+}
\ No newline at end of file
LCGO/src/java/hep/lcgo/util/id
diff -N IDDescriptor.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ IDDescriptor.java 5 Nov 2006 16:29:14 -0000 1.1
@@ -0,0 +1,135 @@
+package hep.lcgo.util.id ;
+
+import java.util.HashMap;
+import java.util.Map;
+
+
+/**
+ * Takes a string of the form:
+ *
+ * <pre>
+ * layer:7,system:3,barrel:3,theta:32:11,phi:11
+ * </pre>
+ *
+ * and generates a parsed description of the fields.
+ *
+ * @author tonyj
+ */
+public class IDDescriptor
+{
+ private int[] start;
+ private int[] length;
+ private String[] name;
+ private Map /*<String,Integer>*/ nameMap = new HashMap/*<String,Integer>*/();
+ private int maxBit;
+ private int nfields;
+
+ public IDDescriptor(String idDescriptor) throws IDException
+ {
+ try
+ {
+ String[] fields = idDescriptor.split(",");
+ //int n = fields.length;
+ nfields = fields.length;
+ start = new int[nfields];
+ length = new int[nfields];
+ name = new String[nfields];
+
+ int pos = 0;
+ for (int i = 0; i < nfields; i++)
+ {
+ String[] subFields = fields[i].split(":");
+ if (subFields.length < 2 || subFields.length > 3)
+ throw new RuntimeException("Invalid subfield: " + fields[i]);
+ name[i] = subFields[0].trim();
+ nameMap.put(name[i], new Integer(i) );
+ if (subFields.length == 3)
+ {
+ start[i] = Integer.parseInt(subFields[1]);
+ if (start[i] < 0)
+ throw new RuntimeException(
+ "Invalid field start position: " + start[i]);
+ length[i] = Integer.parseInt(subFields[2]);
+ if (length[i] == 0)
+ throw new RuntimeException("Invalid field length: "
+ + start[i]);
+ }
+ else
+ {
+ start[i] = pos;
+ length[i] = Integer.parseInt(subFields[1]);
+ }
+ pos = start[i] + Math.abs(length[i]);
+ if (pos > maxBit)
+ maxBit = pos;
+ }
+ }
+ catch (RuntimeException x)
+ {
+ throw new IDException("Invalid id descriptor: " + idDescriptor, x);
+ }
+ }
+
+ public int fieldCount()
+ {
+ return name.length;
+ }
+ /**
+ * Returns the index of the specified field.
+ * @throws IllegalArgumentException If the requested field does not exist.
+ */
+ public int indexOf(String name) throws IllegalArgumentException
+ {
+ if (nameMap.get(name) != null)
+ {
+ return ((Integer) nameMap.get( name)).intValue() ;
+ }
+ else
+ {
+ throw new IllegalArgumentException("Invalid field name: "+name);
+ }
+ }
+
+ public int fieldStart(int index)
+ {
+ return start[index];
+ }
+
+ public int fieldLength(int index)
+ {
+ return Math.abs(length[index]);
+ }
+
+ public boolean isSigned(int index)
+ {
+ return length[index] < 0;
+ }
+
+ public String fieldName(int index)
+ {
+ return name[index];
+ }
+
+ public int getMaxBit()
+ {
+ return maxBit;
+ }
+
+ public int size()
+ {
+ return nfields;
+ }
+
+ public int maxIndex()
+ {
+ return nfields - 1;
+ }
+
+ public static class IDException extends Exception
+ {
+ IDException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+ }
+}
LCGO/src/java/hep/lcgo/util/id
diff -N IDEncoder.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ IDEncoder.java 5 Nov 2006 16:29:14 -0000 1.1
@@ -0,0 +1,51 @@
+package hep.lcgo.util.id ;
+
+/**
+ * Does the opposite of IDDecoder
+ * @author tonyj
+ */
+public class IDEncoder
+{
+ private IDDescriptor desc;
+ private long id;
+ /** Creates a new instance of IIDecoder */
+ public IDEncoder(IDDescriptor desc)
+ {
+ this.desc = desc;
+ }
+
+ IDDescriptor getDescriptor() { return desc ; }
+
+
+ public long setValue(String name, int value)
+ {
+ return setValue(desc.indexOf(name),value);
+ }
+ public long setValue(int index, int value)
+ {
+ int start = desc.fieldStart(index);
+ int length = desc.fieldLength(index);
+ long mask = ((1L<<length) - 1) << start;
+ id &= ~mask;
+ id |= (((long) value)<<start) & mask;
+
+ return id;
+ }
+ public long setValues(int[] values)
+ {
+ if (values.length != desc.fieldCount()) throw new IllegalArgumentException("Invalid array length");
+ long result = 0;
+ for (int i=0; i<values.length; i++)
+ {
+ int start = desc.fieldStart(i);
+ int length = desc.fieldLength(i);
+ long mask = ((1L<<length) - 1);
+ result |= (mask & values[i]) << start;
+ }
+ return id = result;
+ }
+ public long getID()
+ {
+ return id;
+ }
+}
LCGO/src/java/hep/lcgo/xml/reader/util
diff -u -r1.1 -r1.2
--- CachingEntityResolver.java 29 Sep 2006 16:27:19 -0000 1.1
+++ CachingEntityResolver.java 5 Nov 2006 16:29:15 -0000 1.2
@@ -1,6 +1,7 @@
package hep.lcgo.xml.reader.util;
import hep.lcgo.util.cache.FileCache;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
@@ -14,7 +15,7 @@
* the tests without a network connection, provided the cache has been previously
* seeded.
* @author tonyj
- * @version $Id: CachingEntityResolver.java,v 1.1 2006/09/29 16:27:19 tonyj Exp $
+ * @version $Id: CachingEntityResolver.java,v 1.2 2006/11/05 16:29:15 gaede Exp $
*/
public class CachingEntityResolver implements EntityResolver
{
CVSspam 0.2.8