View Javadoc

1   package org.lcsim.plugin;
2   
3   import org.freehep.record.loop.RecordLoop;
4   import org.freehep.util.FreeHEPLookup;
5   import org.lcsim.event.EventHeader;
6   
7   /**
8    * The methods in this class are made available to scripts via the <code>lcsim</code>
9    * variable.
10   * @author tonyj
11   */
12  public class LCSim
13  {
14     private final FreeHEPLookup lookup;
15     /** Creates a new instance of LCSim */
16     LCSim(FreeHEPLookup lookup)
17     {
18        this.lookup = lookup;
19     }
20     /**
21      * Get the current event.
22      * @return The event, or <code>null</code> if event not available
23      */
24     public EventHeader getCurrentEvent()
25     {
26        try
27        {
28           RecordLoop loop = (RecordLoop) lookup.lookup(RecordLoop.class); 
29           Object event = loop.getRecordSource().getCurrentRecord();
30           return (event instanceof EventHeader) ? (EventHeader) event : null;
31        }
32        catch (Exception x)
33        {
34           return null;
35        }
36     }
37  }