1 added + 5 modified, total 6 files
lcsim
diff -u -r1.6 -r1.7
--- .cvsignore 13 Sep 2005 09:24:28 -0000 1.6
+++ .cvsignore 22 May 2006 18:59:22 -0000 1.7
@@ -1,10 +1,16 @@
-bin
-.project
-.classpath
-*.slcio
-*.aida
-*.heprep
-doc
+FixedConeRecon.slcio
+NearestNeighborRecon.slcio
target
-
-.settings
+build.properties
+test.heprep
+fastmc.aida
+line.aida
+x.aida
+test.slcio
+crash.steer
+mcfastgenerator.slcio
+fastmcgenerator.aida
+test2.slcio
+helix.aida
+mcfast.slcio
+digisim.slcio
lcsim/src/org/lcsim/plugin
diff -u -r1.3 -r1.4
--- LCSim.menus 22 Sep 2005 22:57:00 -0000 1.3
+++ LCSim.menus 22 May 2006 18:59:22 -0000 1.4
@@ -18,4 +18,8 @@
</Menu>
</Menu>
</MenuBar>
+
+ <ToolBar id="lcsim" name="LCSim Toolbar">
+ <Component name="LCSim Event Browser" icon="/org/lcsim/plugin/lcsim.gif" command="LCSimEventBrowserButton" location="100"></Component>
+ </ToolBar>
</MenuSystem>
\ No newline at end of file
lcsim/src/org/lcsim/plugin
diff -u -r1.7 -r1.8
--- LCSimPlugin.java 5 Apr 2006 09:09:12 -0000 1.7
+++ LCSimPlugin.java 22 May 2006 18:59:22 -0000 1.8
@@ -3,9 +3,12 @@
import java.io.IOException;
import java.net.URL;
import java.util.EventObject;
+import java.util.List;
+import javax.swing.JToolBar;
import org.freehep.application.mdi.PageContext;
import org.freehep.application.mdi.PageEvent;
import org.freehep.application.mdi.PageListener;
+import org.freehep.application.mdi.PageManager;
import org.freehep.application.studio.Plugin;
import org.freehep.application.studio.Studio;
import org.freehep.application.studio.StudioListener;
@@ -13,13 +16,20 @@
import org.freehep.jas.event.ClassLoadedEvent;
import org.freehep.jas.event.ClassUnloadEvent;
import org.freehep.jas.event.ScriptEvent;
+import org.freehep.jas.plugin.datasource.FileHandlerDataSource;
import org.freehep.jas.services.ScriptEngine;
import org.freehep.jas.services.WebBrowser;
import org.freehep.record.loop.SequentialRecordLoop;
+import org.freehep.record.loop.event.LoopEvent;
+import org.freehep.record.loop.event.LoopProgressEvent;
+import org.freehep.record.loop.event.RecordLoopListener;
+import org.freehep.util.FreeHEPLookup;
import org.freehep.util.commanddispatcher.CommandProcessor;
+import org.freehep.util.commanddispatcher.CommandState;
import org.freehep.util.template.Template;
import org.freehep.xml.menus.XMLMenuBuilder;
import org.lcsim.conditions.ConditionsManager;
+import org.lcsim.event.EventHeader;
import org.lcsim.plugin.conditions.InteractiveConditionsManagerImplementation;
import org.lcsim.plugin.browser.LCSimEventBrowser;
import org.lcsim.util.Driver;
@@ -31,22 +41,32 @@
/**
*
* @author tonyj
- * @version $Id: LCSimPlugin.java,v 1.7 2006/04/05 09:09:12 tonyj Exp $
+ * @version $Id: LCSimPlugin.java,v 1.8 2006/05/22 18:59:22 tonyj Exp $
*/
public class LCSimPlugin extends Plugin implements StudioListener, PageListener
{
+ private LCSim lcsim;
+ private final LCSimCommands commands = new LCSimCommands();
+ private JToolBar toolbar;
+
protected void init() throws SAXException, IOException
{
Studio app = getApplication();
- lcsim = new LCSim(app.getLookup());
+ FreeHEPLookup lookup = app.getLookup();
+ lcsim = new LCSim(lookup);
XMLMenuBuilder builder = app.getXMLMenuBuilder();
URL xml = getClass().getResource("LCSim.menus");
builder.build(xml);
+
+ toolbar = builder.getToolBar("lcsim");
+ app.addToolBar(toolbar, toolbar.getName());
- app.getLookup().add(new LCSimFileHandler(app),"org.lcsim Plugin");
- app.getLookup().add(new StdhepFileHandler(app),"org.lcsim Plugin");
+ lookup.add(new LCSimFileHandler(app),"org.lcsim Plugin");
+ lookup.add(new StdhepFileHandler(app),"org.lcsim Plugin");
+ lookup.add(new FileHandlerDataSource(new LCSimFileHandler(app)));
+ lookup.add(new FileHandlerDataSource(new StdhepFileHandler(app)));
// Listen for any drivers to be loaded
app.getEventSender().addEventListener(this,ClassLoadEvent.class);
@@ -54,7 +74,7 @@
app.getEventSender().addEventListener(this, ScriptEvent.class);
// Register the command processsor
- app.getCommandTargetManager().add(new LCSimCommands());
+ app.getCommandTargetManager().add(commands);
LCSimEventBrowser.registerTableModels(app.getLookup());
@@ -62,11 +82,34 @@
map.set("title","org.lcsim Examples");
map.set("url","classpath:/org/lcsim/plugin/web/examples.html");
map.set("description","Examples of using the org.lcsim package");
- app.getLookup().add(map,"examples");
+ lookup.add(map,"examples");
ConditionsManager.setDefaultConditionsManager(new InteractiveConditionsManagerImplementation(app));
}
-
+ public boolean canBeShutDown()
+ {
+ return true;
+ }
+
+ protected void shutdown()
+ {
+ Studio app = getApplication();
+ FreeHEPLookup lookup = app.getLookup();
+
+ lookup.remove(lookup.lookup(LCSimFileHandler.class));
+ lookup.remove(lookup.lookup(StdhepFileHandler.class));
+
+ app.getEventSender().removeEventListener(this,ClassLoadEvent.class);
+ app.getEventSender().removeEventListener(this,ClassLoadEvent.class);
+
+ app.getCommandTargetManager().remove(commands);
+ lookup.remove(lookup.lookup(Template.class));
+
+ app.removeToolBar(toolbar);
+
+ SequentialRecordLoop loop = (SequentialRecordLoop) getApplication().getLookup().lookup(SequentialRecordLoop.class);
+ loop.removeRecordLoopListener(commands);
+ }
protected void postInit()
{
try
@@ -79,6 +122,9 @@
{
System.err.println("Warning: Unable to create LCSimHepRepConverter, HepRep plugin probably not installed");
}
+
+ SequentialRecordLoop loop = (SequentialRecordLoop) getApplication().getLookup().lookup(SequentialRecordLoop.class);
+ loop.addRecordLoopListener(commands);
}
public void handleEvent(EventObject event)
{
@@ -149,15 +195,57 @@
}
}
- private LCSim lcsim;
-
- class LCSimCommands extends CommandProcessor
+ class LCSimCommands extends CommandProcessor implements RecordLoopListener
{
public void onLCSimEventBrowser()
{
+ createNewEventBrowser();
+ setChanged();
+ }
+ private void createNewEventBrowser()
+ {
SequentialRecordLoop loop = (SequentialRecordLoop) getApplication().getLookup().lookup(SequentialRecordLoop.class);
LCSimEventBrowser tree = new LCSimEventBrowser(getApplication(),loop);
- getApplication().getPageManager().openPage(tree,"LCSim Event",null);
+ getApplication().getPageManager().openPage(tree,"LCSim Event",null);
+ }
+
+ public void enableLCSimEventBrowserButton(CommandState state)
+ {
+ SequentialRecordLoop loop = (SequentialRecordLoop) getApplication().getLookup().lookup(SequentialRecordLoop.class);
+ try
+ {
+ Object record = loop.getRecordSource().getCurrentRecord();
+ state.setEnabled(record instanceof EventHeader);
+ }
+ catch (Exception x)
+ {
+ state.setEnabled(false);
+ }
+ }
+
+ public void onLCSimEventBrowserButton()
+ {
+ PageManager manager = getApplication().getPageManager();
+ PageContext selected = manager.getSelectedPage();
+ if (selected != null && selected.getPage() instanceof LCSimEventBrowser)
+ {
+ createNewEventBrowser();
+ }
+ else
+ {
+ boolean found = false;
+ List<PageContext> pages = manager.pages();
+ for (PageContext page : pages)
+ {
+ if (page.getPage() instanceof LCSimEventBrowser)
+ {
+ page.requestShow();
+ found = true;
+ break;
+ }
+ }
+ if (!found) createNewEventBrowser();
+ }
setChanged();
}
@@ -167,5 +255,23 @@
WebBrowser wb = (WebBrowser) getApplication().getLookup().lookup(WebBrowser.class);
if (wb != null && help != null) wb.showURL(help);
}
+
+ public void loopBeginning(LoopEvent loopEvent)
+ {
+ }
+
+ public void loopEnded(LoopEvent loopEvent)
+ {
+ setChanged();
+ }
+
+ public void loopReset(LoopEvent loopEvent)
+ {
+ setChanged();
+ }
+
+ public void progress(LoopProgressEvent loopProgressEvent)
+ {
+ }
}
}
\ No newline at end of file
lcsim/src/org/lcsim/event
diff -u -r1.11 -r1.12
--- EventHeader.java 23 Aug 2005 23:41:50 -0000 1.11
+++ EventHeader.java 22 May 2006 18:59:23 -0000 1.12
@@ -16,18 +16,18 @@
/**
* Get the list of MC particles associated with this event.
*/
- public List<MCParticle> getMCParticles();
- public List<Track> getTracks();
- public List<Cluster> getClusters();
- public List<SimCalorimeterHit> getSimCalorimeterHits(String name);
- public List<SimTrackerHit> getSimTrackerHits(String name);
+ List<MCParticle> getMCParticles();
+ List<Track> getTracks();
+ List<Cluster> getClusters();
+ List<SimCalorimeterHit> getSimCalorimeterHits(String name);
+ List<SimTrackerHit> getSimTrackerHits(String name);
/**
* Get a collection of data from the event.
* @param type The type of object requested.
* @return The collection of data.
*/
- public <T> List<List<T>> get(Class<T> type);
+ <T> List<List<T>> get(Class<T> type);
/**
* Obtian a collection of objects associated with this event, specified by type and name.
* This method will throw an exception if the requested data is not found.
@@ -35,25 +35,25 @@
* @param name The name of the requested collection
* @return The resulting collection.
*/
- public <T> List<T> get(Class<T> type, String name);
+ <T> List<T> get(Class<T> type, String name);
/**
* Get the meta data associated with a list obtained from this event.
*/
- public LCMetaData getMetaData(List x);
+ LCMetaData getMetaData(List x);
/**
* The name of the detector, used to obtain geometry and conditions.
*/
- public String getDetectorName();
+ String getDetectorName();
/**
* The creation time of this event (in nS since 1-Jan-1970).
*/
- public long getTimeStamp();
+ long getTimeStamp();
/**
* Get the detector description read from the conditions database
*/
- public Detector getDetector();
+ Detector getDetector();
/**
* Add a collection to the event.
@@ -62,7 +62,7 @@
* @param type The class of objects stored in the collection.
* @param flags The LCIO flags associated with the collection.
*/
- public void put(String name, List collection, Class type, int flags);
+ void put(String name, List collection, Class type, int flags);
/**
* Add a collection to the event.
@@ -72,11 +72,16 @@
* @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);
+ 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 MCFASTRECONSTRUCTEDPARTICLES = "MCFastReconstructedParticles";
+ String TRACKS = "Tracks";
+ String CLUSTERS = "Clusters";
+ String MCFASTRECONSTRUCTEDPARTICLES = "MCFastReconstructedParticles";
+
+ /**
+ * Removes an item from the event
+ */
+ void remove(String name);
/**
* List of elements stored in the event may have meta-data associated with
@@ -84,7 +89,7 @@
* 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
+ public interface LCMetaData
{
/**
* The name of the associated data collection
lcsim/test/org/lcsim/util/event
diff -N BaseLCSimEventTest.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ BaseLCSimEventTest.java 22 May 2006 18:59:23 -0000 1.1
@@ -0,0 +1,36 @@
+package org.lcsim.util.event;
+
+import java.util.List;
+import junit.framework.*;
+import org.lcsim.event.EventHeader;
+
+/**
+ *
+ * @author tonyj
+ */
+public class BaseLCSimEventTest extends TestCase
+{
+
+ public BaseLCSimEventTest(String testName)
+ {
+ super(testName);
+ }
+
+ public static Test suite()
+ {
+ return new TestSuite(BaseLCSimEventTest.class);
+ }
+
+ public void testAddRemove()
+ {
+ LCSimEventGenerator gen = new LCSimEventGenerator("sdjan03");
+ EventHeader event = gen.generate();
+ assertEquals(1,event.keys().size());
+ List particles = event.get(List.class,EventHeader.MC_PARTICLES);
+ assertNotNull(event.getMetaData(particles));
+
+ event.remove(EventHeader.MC_PARTICLES);
+ assertEquals(0,event.keys().size());
+ assertNull(event.getMetaData(particles));
+ }
+}
lcsim/src/org/lcsim/util/event
diff -u -r1.18 -r1.19
--- BaseLCSimEvent.java 1 Apr 2006 12:11:03 -0000 1.18
+++ BaseLCSimEvent.java 22 May 2006 18:59:23 -0000 1.19
@@ -6,6 +6,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.lcsim.conditions.ConditionsManager;
import org.lcsim.conditions.ConditionsManager.ConditionsNotFoundException;
import org.lcsim.event.CalorimeterHit;
@@ -19,22 +20,21 @@
import org.lcsim.geometry.Detector;
/**
- *
+ * A base implementation for EventHeader
* @author Tony Johnson
*/
public class BaseLCSimEvent extends BaseEvent implements EventHeader
{
private String detectorName;
- private Map<ListHolder,LCMetaData> metaDataMap = new HashMap<ListHolder,LCMetaData>();
- private Detector detector;
+ private final Map<ListHolder,LCMetaData> metaDataMap = new HashMap<ListHolder,LCMetaData>();
private ConditionsManager conditionsManager;
- private static final int ns = 1000000;
+ private static final int NANO_SECONDS = 1000000;
private static final String READOUT_NAME = "ReadoutName";
/** Creates a new instance of BaseLCSimEvent */
public BaseLCSimEvent(int run, int event, String detectorName)
{
- this(run,event,detectorName,System.currentTimeMillis()*ns);
+ this(run,event,detectorName,System.currentTimeMillis()*NANO_SECONDS);
}
public BaseLCSimEvent(int run, int event, String detectorName, long timeStamp)
{
@@ -53,7 +53,7 @@
}
public String toString()
{
- return "Run "+getRunNumber()+" Event "+getEventNumber()+" ("+new Date(getTimeStamp()/ns)+") Detector: "+detectorName;
+ return "Run "+getRunNumber()+" Event "+getEventNumber()+" ("+new Date(getTimeStamp()/NANO_SECONDS)+") Detector: "+detectorName;
}
public Detector getDetector()
{
@@ -115,7 +115,10 @@
{
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;
+ for (Object o : list)
+ {
+ if (!type.isAssignableFrom(o.getClass())) type = Object.class;
+ }
metaDataMap.put(new ListHolder(list),new MetaData(name,type,0,null));
}
}
@@ -131,24 +134,26 @@
boolean isValid = false;
for(LCMetaData tmp : metaDataMap.values())
{
- String[] names = tmp.getStringParameters().get(READOUT_NAME);
+ String[] names = tmp.getStringParameters().get(READOUT_NAME);
- if(tmp.getName().equals(readoutName))
- {
- // readoutName already exists as a collection
- // does it have a parent collection?
- if(names == null || names.length == 0) {
- // no parent, original collection
- isOriginal=true;
- break;
- }
- else {
- // yes, reset readoutName from its parent
- readoutName = names[0];
- isValid = true;
- break;
- }
- }
+ if(tmp.getName().equals(readoutName))
+ {
+ // readoutName already exists as a collection
+ // does it have a parent collection?
+ if(names == null || names.length == 0)
+ {
+ // no parent, original collection
+ isOriginal=true;
+ break;
+ }
+ else
+ {
+ // yes, reset readoutName from its parent
+ readoutName = names[0];
+ isValid = true;
+ break;
+ }
+ }
}
// not a valid readout name provided
@@ -157,7 +162,6 @@
LCMetaData meta = new MetaData(name, type, flags, readoutName);
metaDataMap.put(new ListHolder(collection),meta);
// Fixme: This needs to be generalized
-// System.out.println("type="+type+" "+BaseCalorimeterHit.class.isAssignableFrom(type));
if (CalorimeterHit.class.isAssignableFrom(type))
{
for (Object o : collection)
@@ -172,6 +176,16 @@
LCMetaData meta = new MetaData(name, type, flags, intMap, floatMap, stringMap);
metaDataMap.put(new ListHolder(collection),meta);
}
+
+ /**
+ * Removes a collection from the event.
+ */
+ public void remove(String name)
+ {
+ Object collection = get(name);
+ if (collection instanceof List) metaDataMap.remove(new ListHolder((List) collection));
+ super.keys().remove(name);
+ }
public String getDetectorName()
{
@@ -180,9 +194,9 @@
private class MetaData implements LCMetaData
{
- private int flags;
- private String name;
- private Class type;
+ private final int flags;
+ private final String name;
+ private final Class type;
private Map<String, int[]> intMap;
private Map<String, float[]> floatMap;
private Map<String, String[]> stringMap;
@@ -261,7 +275,7 @@
// into the metadata map. ListHolder is a workaround for this.
private class ListHolder
{
- private List list;
+ private final List list;
ListHolder(List list)
{
this.list = list;
CVSspam 0.2.8