12 modified files
lcsim/src/org/lcsim/event
diff -u -r1.8 -r1.9
--- EventHeader.java 19 Jul 2005 23:51:51 -0000 1.8
+++ EventHeader.java 26 Jul 2005 14:44:33 -0000 1.9
@@ -2,6 +2,7 @@
import hep.physics.event.generator.MCEvent;
import java.util.List;
+import java.util.Map;
import org.lcsim.geometry.Detector;
import org.lcsim.geometry.IDDecoder;
@@ -63,6 +64,16 @@
*/
public void put(String name, List collection, Class type, int flags);
+ /**
+ * Add a collection to the event.
+ * @param name The name used to stored this collection in the event.
+ * @param collection The data collection
+ * @param type The class of objects stored in the collection.
+ * @param flags The LCIO flags associated with the collection.
+ * @param readoutName The name of the readout to be used to decode hits in this collection
+ */
+ public void put(String name, List collection, Class type, int flags, String readoutName);
+
public final static String TRACKS = "Tracks";
public final static String CLUSTERS = "Clusters";
public final static String RECONSTRUCTEDPARTICLES = "Reconstructed Particles";
@@ -70,6 +81,8 @@
/**
* List of elements stored in the event may have meta-data associated with
* them. This interface allows this meta-data to be extracted.
+ * LCIO allows arbitrary maps of int, float or strings to be stored
+ * with each collection and these can also be accessed via this interface.
*/
public static interface LCMetaData
{
@@ -90,5 +103,9 @@
* data collection. Primarily used for calorimeter and tracker hits.
*/
IDDecoder getIDDecoder();
+
+ Map<String,int[]> getIntegerParameters();
+ Map<String,float[]> getFloatParameters();
+ Map<String,String[]> getStringParameters();
}
}
\ No newline at end of file
lcsim/src/org/lcsim/plugin/browser
diff -u -r1.3 -r1.4
--- CollectionTable.java 21 Jul 2005 00:30:50 -0000 1.3
+++ CollectionTable.java 26 Jul 2005 14:44:34 -0000 1.4
@@ -9,6 +9,7 @@
import java.lang.reflect.Array;
import java.util.Collection;
import java.util.List;
+import java.util.Map;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
@@ -29,7 +30,7 @@
/**
*
* @author tonyj
- * @version $Id: CollectionTable.java,v 1.3 2005/07/21 00:30:50 tonyj Exp $
+ * @version $Id: CollectionTable.java,v 1.4 2005/07/26 14:44:34 tonyj Exp $
*/
class CollectionTable extends JPanel implements ActionListener
{
@@ -88,40 +89,71 @@
Class type = meta.getType();
int flag = meta.getFlags();
- String tableText = ("Collection: "+meta.getName()
- +" size:"+coll.size()
- +" flags:"+Integer.toHexString(flag));
+ StringBuffer tableText = new StringBuffer();
+ tableText.append("Collection: ").append(meta.getName());
+ tableText.append(" size:").append(coll.size());
+ tableText.append(" flags:").append(Integer.toHexString(flag));
- m_tableLabel.setText( tableText ) ;
+ for (Map.Entry<String,int[]> entry : meta.getIntegerParameters().entrySet())
+ {
+ tableText.append( "\n ").append(entry.getKey()).append(":\t");
+ for(int v : entry.getValue())
+ {
+ tableText.append(v);
+ tableText.append(", ");
+ }
+ if (entry.getValue().length > 0) tableText.setLength(tableText.length()-2);
+ }
+ for (Map.Entry<String,float[]> entry : meta.getFloatParameters().entrySet())
+ {
+ tableText.append( "\n ").append(entry.getKey()).append(":\t");
+ for(float v : entry.getValue())
+ {
+ tableText.append(v);
+ tableText.append(", ");
+ }
+ if (entry.getValue().length > 0) tableText.setLength(tableText.length()-2);
+ }
+ for (Map.Entry<String,String[]> entry : meta.getStringParameters().entrySet())
+ {
+ tableText.append( "\n ").append(entry.getKey()).append(":\t");
+ for(String v : entry.getValue())
+ {
+ tableText.append(v);
+ tableText.append(", ");
+ }
+ if (entry.getValue().length > 0) tableText.setLength(tableText.length()-2);
+ }
+ m_tableLabel.setText(tableText.toString()) ;
try
{
- Template template = new Template(EventBrowserTableModel.class);
- Result result = m_app.getLookup().lookup(template);
- Collection<EventBrowserTableModel> models = (Collection<EventBrowserTableModel>) result.allInstances();
-
- boolean ok = false;
- for (EventBrowserTableModel model : models)
- {
- if (model.canDisplay(type))
- {
- model.setData(meta,coll);
- m_table.setModel(model);
- ok = true;
- break;
- }
- }
- if (!ok)
- {
- m_table.setModel(emptyTable);
-
- }
- cardLayout.first(panel);
+ Template template = new Template(EventBrowserTableModel.class);
+ Result result = m_app.getLookup().lookup(template);
+ Collection<EventBrowserTableModel> models = (Collection<EventBrowserTableModel>) result.allInstances();
+
+ boolean ok = false;
+ for (EventBrowserTableModel model : models)
+ {
+ if (model.canDisplay(type))
+ {
+ model.setData(meta,coll);
+ m_table.setModel(model);
+ ok = true;
+ break;
+ }
+ }
+ if (!ok)
+ {
+ m_table.setModel(emptyTable);
+
+ }
+ cardLayout.first(panel);
}
catch (Exception x)
{
- error = x;
- cardLayout.last(panel);
+ error = x;
+ cardLayout.last(panel);
}
}
else
@@ -131,7 +163,7 @@
cardLayout.first(panel);
}
}
-
+
public void actionPerformed(ActionEvent actionEvent)
{
Application.error(this,"Error displaying collection", error);
lcsim/src/org/lcsim/plugin/browser
diff -u -r1.6 -r1.7
--- LCSimEventBrowser.java 21 Jul 2005 00:30:50 -0000 1.6
+++ LCSimEventBrowser.java 26 Jul 2005 14:44:34 -0000 1.7
@@ -4,6 +4,8 @@
import java.awt.CardLayout;
import java.awt.Dimension;
import java.awt.Font;
+import java.util.ArrayList;
+import java.util.Collections;
import org.freehep.record.loop.SequentialRecordLoop;
import org.freehep.record.loop.event.LoopEvent;
import org.freehep.record.loop.event.LoopProgressEvent;
@@ -20,7 +22,6 @@
import javax.swing.tree.TreeModel;
import javax.swing.tree.TreePath;
import java.util.List;
-import java.util.Set;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
@@ -134,7 +135,8 @@
m_lce = (EventHeader) event;
m_table.setEvent(m_lce);
DefaultMutableTreeNode root = new DefaultMutableTreeNode("Event");
- Set<String> collections = m_lce.keys();
+ List<String> collections = new ArrayList<String>(m_lce.keys());
+ Collections.sort(collections);
int selectedRow = -1;
int i = 0;
for (String name : collections)
lcsim/src/org/lcsim/util/event
diff -u -r1.12 -r1.13
--- BaseLCSimEvent.java 19 Jul 2005 23:51:52 -0000 1.12
+++ BaseLCSimEvent.java 26 Jul 2005 14:44:34 -0000 1.13
@@ -10,6 +10,7 @@
import org.lcsim.conditions.ConditionsManager.ConditionsNotFoundException;
import org.lcsim.event.Cluster;
import org.lcsim.event.EventHeader;
+import org.lcsim.event.EventHeader.LCMetaData;
import org.lcsim.event.MCParticle;
import org.lcsim.event.SimCalorimeterHit;
import org.lcsim.event.SimTrackerHit;
@@ -23,10 +24,11 @@
public class BaseLCSimEvent extends BaseEvent implements EventHeader
{
private String detectorName;
- private Map<List,LCMetaData> metaDataMap = new HashMap<List,LCMetaData>();
+ private Map<ListHolder,LCMetaData> metaDataMap = new HashMap<ListHolder,LCMetaData>();
private Detector detector;
private ConditionsManager conditionsManager;
private static final int ns = 1000000;
+ private static final String READOUT_NAME = "ReadoutName";
/** Creates a new instance of BaseLCSimEvent */
public BaseLCSimEvent(int run, int event, String detectorName)
@@ -61,7 +63,7 @@
{
return get(MCParticle.class,MC_PARTICLES);
}
-
+
public List<Track> getTracks()
{
return get(Track.class,TRACKS);
@@ -71,40 +73,40 @@
{
return get(Cluster.class,CLUSTERS);
}
-
+
public List<SimCalorimeterHit> getSimCalorimeterHits(String name)
{
return get(SimCalorimeterHit.class,name);
}
-
+
public List<SimTrackerHit> getSimTrackerHits(String name)
{
return get(SimTrackerHit.class,name);
}
-
+
public <T> List<T> get(Class<T> type, String name)
{
return (List<T>) get(name);
}
-
+
public <T> List<List<T>> get(Class<T> type)
{
List<List<T>> result = new ArrayList<List<T>>();
- for (Map.Entry<List,LCMetaData> entry : metaDataMap.entrySet())
+ for (Map.Entry<ListHolder,LCMetaData> entry : metaDataMap.entrySet())
{
if (type.isAssignableFrom(entry.getValue().getType()))
{
- result.add(entry.getKey());
+ result.add(entry.getKey().getList());
}
}
return result;
}
-
+
public LCMetaData getMetaData(List x)
{
- return metaDataMap.get(x);
+ return metaDataMap.get(new ListHolder(x));
}
-
+
public void put(String name, Object component)
{
super.put(name, component);
@@ -113,34 +115,55 @@
List list = (List) component;
Class type = list.isEmpty() ? Object.class : list.get(0).getClass();
for (Object o : list) if (!type.isAssignableFrom(o.getClass())) type = Object.class;
- metaDataMap.put(list,new MetaData(name,type,0));
+ metaDataMap.put(new ListHolder(list),new MetaData(name,type,0,null));
}
}
-
- public void put(String name, List component, Class type, int flags)
+ public void put(String name, List collection, Class type, int flags)
{
- super.put(name,component);
- metaDataMap.put(component,new MetaData(name,type,flags));
+ put(name,collection,type,flags,null);
}
-
+ public void put(String name, List collection, Class type, int flags, String readoutName)
+ {
+ super.put(name,collection);
+ metaDataMap.put(new ListHolder(collection),new MetaData(name,type,flags,readoutName));
+ }
+ protected void put(String name, List collection, Class type, int flags, Map intMap, Map floatMap, Map stringMap)
+ {
+ super.put(name,collection);
+ metaDataMap.put(new ListHolder(collection),new MetaData(name, type, flags, intMap, floatMap, stringMap));
+ }
+
public String getDetectorName()
{
return detectorName;
}
-
+
private class MetaData implements LCMetaData
{
private int flags;
private String name;
private Class type;
+ private Map<String, int[]> intMap;
+ private Map<String, float[]> floatMap;
+ private Map<String, String[]> stringMap;
- MetaData(String name, Class type, int flags)
+ MetaData(String name, Class type, int flags, String readoutName)
{
this.name = name;
this.type = type;
this.flags = flags;
+ if (readoutName != null) getStringParameters().put(READOUT_NAME,new String[]{ readoutName });
}
-
+ MetaData(String name, Class type, int flags, Map intMap, Map floatMap, Map stringMap)
+ {
+ this.name = name;
+ this.type = type;
+ this.flags = flags;
+ this.intMap = intMap;
+ this.floatMap = floatMap;
+ this.stringMap = stringMap;
+ }
+
public int getFlags()
{
return flags;
@@ -155,10 +178,66 @@
{
return type;
}
-
+
public org.lcsim.geometry.IDDecoder getIDDecoder()
{
- return getDetector().getDecoder(name);
+ // If the IDDecoder name is explicitly set then use it, otherwise
+ // use the name of the collection itself.
+ String readoutName = name;
+ if (stringMap != null)
+ {
+ String[] names = stringMap.get(READOUT_NAME);
+ if (names != null && names.length >= 1) readoutName = names[0];
+ }
+ org.lcsim.geometry.IDDecoder result = getDetector().getDecoder(readoutName);
+ if (result == null) throw new RuntimeException("Could not find decoder for collection: "+name+" readout: "+readoutName);
+ return result;
+ }
+
+ public Map<String, int[]> getIntegerParameters()
+ {
+ if (intMap == null) intMap = new HashMap<String, int[]>();
+ return intMap;
+ }
+
+ public Map<String, float[]> getFloatParameters()
+ {
+ if (floatMap == null) floatMap = new HashMap<String, float[]>();
+ return floatMap;
+ }
+
+ public Map<String, String[]> getStringParameters()
+ {
+ if (stringMap == null) stringMap = new HashMap<String, String[]>();
+ return stringMap;
+ }
+ }
+ // All empty lists are considered equal, but we need to put several different possibly empty lists
+ // into the metadata map. ListHolder is a workaround for this.
+ private class ListHolder
+ {
+ private List list;
+ ListHolder(List list)
+ {
+ this.list = list;
+ }
+ List getList()
+ {
+ return list;
+ }
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof ListHolder)
+ {
+ ListHolder that= (ListHolder) obj;
+ return this.list == that.list;
+ }
+ return false;
+ }
+
+ public int hashCode()
+ {
+ return list.hashCode();
}
}
}
\ No newline at end of file
lcsim/src/org/lcsim/util/lcio
diff -u -r1.3 -r1.4
--- AbstractBlockHandler.java 3 May 2005 02:04:41 -0000 1.3
+++ AbstractBlockHandler.java 26 Jul 2005 14:44:34 -0000 1.4
@@ -6,7 +6,7 @@
import hep.lcd.io.sio.SIOWriter;
import java.io.IOException;
import java.util.List;
-import org.lcsim.event.EventHeader;
+import java.util.Map;
import org.lcsim.event.EventHeader.LCMetaData;
/**
@@ -27,13 +27,13 @@
int flags = in.readInt();
- SIOLCParameters colParameters = null ;
+ SIOLCParameters colParameters = null;
if( version > 1001 )
{
colParameters = new SIOLCParameters(in) ;
}
int n = in.readInt();
- LCIOCollection collection = new LCIOCollection(getClassForType(), flags, n);
+ LCIOCollection collection = new LCIOCollection(getClassForType(), flags, n, colParameters);
addCollectionElements(collection,in,n,version);
event.put(block.getBlockName(),collection);
}
@@ -44,9 +44,11 @@
SIOOutputStream out = writer.createBlock(md.getName(), LCIOConstants.MAJORVERSION, LCIOConstants.MINORVERSION);
int flags = md.getFlags();
out.writeInt(flags);
- out.writeInt(0);
- out.writeInt(0);
- out.writeInt(0);
+ Map<String,int[]> intMap = md.getIntegerParameters();
+ Map<String,float[]> floatMap = md.getFloatParameters();
+ Map<String,String[]> stringMap = md.getStringParameters();
+ SIOLCParameters colParameters = null;
+ SIOLCParameters.write(intMap,floatMap,stringMap,out);
out.writeInt(collection.size());
for (Object element : collection)
{
lcsim/src/org/lcsim/util/lcio
diff -u -r1.5 -r1.6
--- HandlerManager.java 20 Jul 2005 21:09:43 -0000 1.5
+++ HandlerManager.java 26 Jul 2005 14:44:34 -0000 1.6
@@ -1,6 +1,7 @@
package org.lcsim.util.lcio;
import java.util.HashMap;
+import java.util.LinkedHashMap;
import java.util.Map;
/**
@@ -10,7 +11,7 @@
class HandlerManager
{
private Map<String,LCIOBlockHandler> handlerForType = new HashMap<String,LCIOBlockHandler>();
- private Map<Class,LCIOBlockHandler> handlerForClass = new HashMap<Class,LCIOBlockHandler>();
+ private Map<Class,LCIOBlockHandler> handlerForClass = new LinkedHashMap<Class,LCIOBlockHandler>();
private void register(LCIOBlockHandler handler)
{
handlerForType.put(handler.getType(),handler);
@@ -20,6 +21,8 @@
/** Creates a new instance of HandlerManager */
private HandlerManager()
{
+ // Note: order is important, most specific (e.g. SimCalorimeterHit) must come
+ // before less speicifc (e.g. CalorimeterHit).
register(new SIOSimCalorimeterHitBlockHandler());
register(new SIOSimTrackerHitBlockHandler());
register(new SIOMCParticleBlockHandler());
@@ -56,7 +59,6 @@
}
}
}
-// System.out.println("HM: type="+type+", handler="+handler);
return handler;
}
}
lcsim/src/org/lcsim/util/lcio
diff -u -r1.2 -r1.3
--- LCIOCollection.java 28 Feb 2005 08:11:19 -0000 1.2
+++ LCIOCollection.java 26 Jul 2005 14:44:34 -0000 1.3
@@ -11,11 +11,14 @@
{
private Class type;
private int flags;
- LCIOCollection(Class type, int flags, int size)
+ private SIOLCParameters parameters;
+
+ LCIOCollection(Class type, int flags, int size, SIOLCParameters parameters)
{
super(size);
this.flags = flags;
this.type = type;
+ this.parameters = parameters;
}
public Class getType()
@@ -37,4 +40,9 @@
{
return type.hashCode();
}
+
+ public SIOLCParameters getParameters()
+ {
+ return parameters;
+ }
}
lcsim/src/org/lcsim/util/lcio
diff -u -r1.4 -r1.5
--- LCIOConstants.java 21 Jul 2005 17:14:25 -0000 1.4
+++ LCIOConstants.java 26 Jul 2005 14:44:35 -0000 1.5
@@ -1,9 +1,3 @@
-/*
- * LCIOConstants.java
- *
- * Created on February 13, 2005, 9:54 AM
- */
-
package org.lcsim.util.lcio;
/**
@@ -39,8 +33,8 @@
// cellid1 stored
public final static int RCHBIT_NO_PTR = 28;
- // 1: pointer tag not added
- public final static int RCHBIT_TIME = 27;
+ // 1: pointer tag not added
+ public final static int RCHBIT_TIME = 27;
// 1: time information stored
// SimTrackerHit
lcsim/src/org/lcsim/util/lcio
diff -u -r1.3 -r1.4
--- LCIOEvent.java 3 Mar 2005 21:56:02 -0000 1.3
+++ LCIOEvent.java 26 Jul 2005 14:44:35 -0000 1.4
@@ -39,6 +39,7 @@
}
void put(String name, LCIOCollection collection)
{
- super.put(name,collection,collection.getType(),collection.getFlags());
+ SIOLCParameters parameters = collection.getParameters();
+ super.put(name,collection,collection.getType(),collection.getFlags(),parameters.getIntMap(), parameters.getFloatMap(), parameters.getStringMap());
}
}
lcsim/src/org/lcsim/util/lcio
diff -u -r1.1 -r1.2
--- SIOLCParameters.java 14 Feb 2005 05:41:59 -0000 1.1
+++ SIOLCParameters.java 26 Jul 2005 14:44:35 -0000 1.2
@@ -1,22 +1,38 @@
package org.lcsim.util.lcio;
import hep.lcd.io.sio.SIOInputStream;
+import hep.lcd.io.sio.SIOOutputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
+import org.lcsim.event.EventHeader.LCMetaData;
/**
*
* @author Frank Gaede
- * @version $Id: SIOLCParameters.java,v 1.1 2005/02/14 05:41:59 tonyj Exp $
+ * @version $Id: SIOLCParameters.java,v 1.2 2005/07/26 14:44:35 tonyj Exp $
*/
class SIOLCParameters
{
- private Map _intMap = new HashMap();
- private Map _floatMap = new HashMap();
- private Map _stringMap = new HashMap();
+ private Map<String,int[]> _intMap = new HashMap<String,int[]>();
+ private Map<String,float[]> _floatMap = new HashMap<String,float[]>();
+ private Map<String,String[]> _stringMap = new HashMap<String,String[]>();
+
+
+ Map<String,int[]> getIntMap()
+ {
+ return _intMap;
+ }
+ Map<String,float[]> getFloatMap()
+ {
+ return _floatMap;
+ }
+ Map<String,String[]> getStringMap()
+ {
+ return _stringMap;
+ }
SIOLCParameters(SIOInputStream in) throws IOException
{
int nIntParameters = in.readInt();
@@ -57,4 +73,40 @@
_stringMap.put( key , sv ) ;
}
}
+ static void write(Map<String,int[]> intMap, Map<String,float[]> floatMap, Map<String,String[]> stringMap, SIOOutputStream out) throws IOException
+ {
+ out.writeInt(intMap.size());
+ for (Map.Entry<String,int[]> entry : intMap.entrySet())
+ {
+ out.writeString(entry.getKey());
+ int[] values = entry.getValue();
+ out.writeInt(values.length) ;
+ for (int v : values)
+ {
+ out.writeInt(v);
+ }
+ }
+ out.writeInt(floatMap.size());
+ for (Map.Entry<String,float[]> entry : floatMap.entrySet())
+ {
+ out.writeString(entry.getKey());
+ float[] values = entry.getValue();
+ out.writeInt(values.length) ;
+ for (float v : values)
+ {
+ out.writeFloat(v);
+ }
+ }
+ out.writeInt(stringMap.size());
+ for (Map.Entry<String,String[]> entry : stringMap.entrySet())
+ {
+ out.writeString(entry.getKey());
+ String[] values = entry.getValue();
+ out.writeInt(values.length) ;
+ for (String v : values)
+ {
+ out.writeString(v);
+ }
+ }
+ }
}
lcsim/src/org/lcsim/util/lcio
diff -u -r1.2 -r1.3
--- SIOSimCalorimeterHitBlockHandler.java 16 Feb 2005 07:28:06 -0000 1.2
+++ SIOSimCalorimeterHitBlockHandler.java 26 Jul 2005 14:44:35 -0000 1.3
@@ -13,7 +13,7 @@
class SIOSimCalorimeterHitBlockHandler extends AbstractBlockHandler
{
public String getType() { return "SimCalorimeterHit"; }
- public Class getClassForType() { return SIOSimCalorimeterHit.class; }
+ public Class getClassForType() { return SimCalorimeterHit.class; }
public void addCollectionElements(LCIOCollection collection, SIOInputStream in, int n, int version) throws IOException
{
for (int i = 0; i < n; i++)
lcsim/src/org/lcsim/util/lcio
diff -u -r1.2 -r1.3
--- SIOSimTrackerHitBlockHandler.java 16 Feb 2005 07:28:06 -0000 1.2
+++ SIOSimTrackerHitBlockHandler.java 26 Jul 2005 14:44:35 -0000 1.3
@@ -13,7 +13,7 @@
class SIOSimTrackerHitBlockHandler extends AbstractBlockHandler
{
public String getType() { return "SimTrackerHit"; }
- public Class getClassForType() { return SIOSimTrackerHit.class; }
+ public Class getClassForType() { return SimTrackerHit.class; }
public void addCollectionElements(LCIOCollection collection, SIOInputStream in, int n, int version) throws IOException
{
for (int i = 0; i < n; i++)
CVSspam 0.2.8