Print

Print


Commit in projects/lcsim/trunk/event-model/src/main/java/org/lcsim/event/base on MAIN
BaseLCSimEvent.java+145-1793075 -> 3076
formatting

projects/lcsim/trunk/event-model/src/main/java/org/lcsim/event/base
BaseLCSimEvent.java 3075 -> 3076
--- projects/lcsim/trunk/event-model/src/main/java/org/lcsim/event/base/BaseLCSimEvent.java	2014-04-03 15:54:52 UTC (rev 3075)
+++ projects/lcsim/trunk/event-model/src/main/java/org/lcsim/event/base/BaseLCSimEvent.java	2014-04-03 16:39:11 UTC (rev 3076)
@@ -32,220 +32,200 @@
  * A base implementation for EventHeader
  * @author Tony Johnson
  */
-public class BaseLCSimEvent extends BaseEvent implements EventHeader
-{
+public class BaseLCSimEvent extends BaseEvent implements EventHeader {
+
     private String detectorName;
-    private final Map<List,LCMetaData> metaDataMap = new IdentityHashMap<List,LCMetaData>();
+    private final Map<List, LCMetaData> metaDataMap = new IdentityHashMap<List, LCMetaData>();
     private ConditionsManager conditionsManager = ConditionsManager.defaultInstance();
     private static final int NANO_SECONDS = 1000000;
     public 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()*NANO_SECONDS);
+    public BaseLCSimEvent(int run, int event, String detectorName) {
+        this(run, event, detectorName, System.currentTimeMillis() * NANO_SECONDS);
     }
-    
-    public BaseLCSimEvent(int run, int event, String detectorName, long timeStamp)
-    {
-        super(run,event,timeStamp);
+
+    public BaseLCSimEvent(int run, int event, String detectorName, long timeStamp) {
+        super(run, event, timeStamp);
         this.detectorName = detectorName;
-        try
-        {
-            conditionsManager.setDetector(detectorName,run);
+        try {
+            conditionsManager.setDetector(detectorName, run);
+        } catch (ConditionsNotFoundException x) {
+            throw new RuntimeException("Please see http://confluence.slac.stanford.edu/display/ilc/Conditions+database", x);
         }
-        catch (ConditionsNotFoundException x)
-        {
-            throw new RuntimeException("Please see http://confluence.slac.stanford.edu/display/ilc/Conditions+database",x);
-        }
     }
     
-    //public String getInputFile()
-    //{
-    //    return (String)get("INPUT_FILE");
-    //}
-    
-    public String toString()
-    {
-        return "Run "+getRunNumber()+" Event "+getEventNumber()+" ("+new Date(getTimeStamp()/NANO_SECONDS)+") Detector: "+detectorName;
+    public BaseLCSimEvent(int run, int event, String detectorName, long timeStamp, boolean triggerConditionsUpdate) {
+        super(run, event, timeStamp);
+        this.detectorName = detectorName;
+        if (triggerConditionsUpdate) {
+            try {
+                conditionsManager.setDetector(detectorName, run);
+            } catch (ConditionsNotFoundException x) {
+                throw new RuntimeException("Please see http://confluence.slac.stanford.edu/display/ilc/Conditions+database", x);
+            }
+        }
     }
-    
-    public Detector getDetector()
-    {
-        return conditionsManager.getCachedConditions(Detector.class,"compact.xml").getCachedData();
+
+    // public String getInputFile()
+    // {
+    // return (String)get("INPUT_FILE");
+    // }
+
+    public String toString() {
+        return "Run " + getRunNumber() + " Event " + getEventNumber() + " (" + new Date(getTimeStamp() / NANO_SECONDS) + ") Detector: " + detectorName;
     }
 
-    public List<MCParticle> getMCParticles()
-    {
-        return get(MCParticle.class,MC_PARTICLES);
+    public Detector getDetector() {
+        return conditionsManager.getCachedConditions(Detector.class, "compact.xml").getCachedData();
     }
 
-    public List<Track> getTracks()
-    {
-        return get(Track.class,TRACKS);
+    public List<MCParticle> getMCParticles() {
+        return get(MCParticle.class, MC_PARTICLES);
     }
 
-    public List<Cluster> getClusters()
-    {
-        return get(Cluster.class,CLUSTERS);
+    public List<Track> getTracks() {
+        return get(Track.class, TRACKS);
     }
 
-    public List<SimCalorimeterHit> getSimCalorimeterHits(String name)
-    {
-        return get(SimCalorimeterHit.class,name);
+    public List<Cluster> getClusters() {
+        return get(Cluster.class, CLUSTERS);
     }
 
-    public List<SimTrackerHit> getSimTrackerHits(String name)
-    {
-        return get(SimTrackerHit.class,name);
+    public List<SimCalorimeterHit> getSimCalorimeterHits(String name) {
+        return get(SimCalorimeterHit.class, name);
     }
 
-    public <T> List<T> get(Class<T> type, String 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)
-    {
+    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())
-        {
-            if (type.isAssignableFrom(entry.getValue().getType()))
-            {
+        for (Map.Entry<List, LCMetaData> entry : metaDataMap.entrySet()) {
+            if (type.isAssignableFrom(entry.getValue().getType())) {
                 result.add(entry.getKey());
             }
         }
         return result;
     }
-    
-    public Collection<LCMetaData> getMetaData()
-    {
-    	return metaDataMap.values();
+
+    public Collection<LCMetaData> getMetaData() {
+        return metaDataMap.values();
     }
-    
-    public Set<List> getLists()
-    {
-    	return metaDataMap.keySet();
+
+    public Set<List> getLists() {
+        return metaDataMap.keySet();
     }
 
-    public LCMetaData getMetaData(List x)
-    {
+    public LCMetaData getMetaData(List x) {
         return metaDataMap.get(x);
     }
 
-    public void put(String name, Object component)
-    {
+    public void put(String name, Object component) {
         super.put(name, component);
-        if (component instanceof List)
-        {
+        if (component instanceof List) {
             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(list,new MetaData(name,type,0,null));
+            metaDataMap.put(list, new MetaData(name, type, 0, null));
         }
     }
-    
-    public void put(String name, List collection, Class type, int flags)
-    {
-        put(name,collection,type,flags,null);
+
+    public void put(String name, List collection, Class type, int flags) {
+        put(name, collection, type, flags, null);
     }
-    
-    public void put(String name, List collection, Class type, int flags, String readoutName)
-    {
-        super.put(name,collection);
-        
+
+    public void put(String name, List collection, Class type, int flags, String readoutName) {
+        super.put(name, collection);
+
         LCMetaData meta = new MetaData(name, type, flags, readoutName);
-        metaDataMap.put(collection,meta);
+        metaDataMap.put(collection, meta);
 
         setCollectionMetaData(collection, type, meta);
     }
 
     private void setCollectionMetaData(List collection, Class type, LCMetaData meta) {
-        //System.out.println("setCollectionMetaData");
+        // System.out.println("setCollectionMetaData");
         // Set MetaData on collection objects.
         if (HasMetaData.class.isAssignableFrom(type)) {
             for (Object o : collection) {
                 if (o instanceof HasMetaData) {
-                    ((HasMetaData)o).setMetaData(meta);
+                    ((HasMetaData) o).setMetaData(meta);
                 }
             }
         }
     }
-    
-    protected void put(String name, List collection, Class type, int flags, Map intMap, Map floatMap, Map stringMap)
-    {
-        super.put(name,collection);
+
+    protected void put(String name, List collection, Class type, int flags, Map intMap, Map floatMap, Map stringMap) {
+        super.put(name, collection);
         LCMetaData meta = new MetaData(name, type, flags, intMap, floatMap, stringMap);
-        metaDataMap.put(collection,meta);
+        metaDataMap.put(collection, meta);
     }
 
     /**
      * Removes a collection from the event.
      */
-    public void remove(String name)
-    {
+    public void remove(String name) {
         Object collection = get(name);
-        if (collection instanceof List) metaDataMap.remove((List) collection);
+        if (collection instanceof List)
+            metaDataMap.remove((List) collection);
         super.keys().remove(name);
     }
 
-    public String getDetectorName()
-    {
+    public String getDetectorName() {
         return detectorName;
     }
 
-    public boolean hasCollection(Class type, String name)
-    {
-        if (!hasItem(name)) return false;
+    public boolean hasCollection(Class type, String name) {
+        if (!hasItem(name))
+            return false;
         Object collection = get(name);
-        if (!(collection instanceof List)) return false;
+        if (!(collection instanceof List))
+            return false;
         return type.isAssignableFrom(metaDataMap.get(collection).getType());
     }
-    
-    public boolean hasCollection(Class type)
-    {
-        for (LCMetaData meta : metaDataMap.values())
-        {
-            if (type.isAssignableFrom(meta.getType()))
-            {
+
+    public boolean hasCollection(Class type) {
+        for (LCMetaData meta : metaDataMap.values()) {
+            if (type.isAssignableFrom(meta.getType())) {
                 return true;
             }
         }
-        return false;      
+        return false;
     }
-    
-    public boolean hasItem(String name)
-    {
+
+    public boolean hasItem(String name) {
         return super.keys().contains(name);
     }
-    
-    public Map<String, int[]> getIntegerParameters()
-    {
-        return Collections.<String, int[]>emptyMap();
 
+    public Map<String, int[]> getIntegerParameters() {
+        return Collections.<String, int[]> emptyMap();
+
     }
 
-    public Map<String, float[]> getFloatParameters()
-    {
-        return Collections.<String, float[]>emptyMap();
+    public Map<String, float[]> getFloatParameters() {
+        return Collections.<String, float[]> emptyMap();
 
     }
 
-    public Map<String, String[]> getStringParameters()
-    {
-        return Collections.<String, String[]>emptyMap();
+    public Map<String, String[]> getStringParameters() {
+        return Collections.<String, String[]> emptyMap();
     }
-    
-    public float getWeight()
-    {
+
+    public float getWeight() {
         return 1.0f;
     }
 
-    private class MetaData implements LCMetaData
-    {
+    private class MetaData implements LCMetaData {
+
         private int flags;
         private final String name;
         private final Class type;
@@ -254,15 +234,15 @@
         private Map<String, String[]> stringMap;
         private transient IDDecoder dec;
 
-        MetaData(String name, Class type, int flags, String readoutName)
-        {
+        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 });
+            if (readoutName != null)
+                getStringParameters().put(READOUT_NAME, new String[] { readoutName });
         }
-        MetaData(String name, Class type, int flags, Map intMap, Map floatMap, Map stringMap)
-        {
+
+        MetaData(String name, Class type, int flags, Map intMap, Map floatMap, Map stringMap) {
             this.name = name;
             this.type = type;
             this.flags = flags;
@@ -271,53 +251,48 @@
             this.stringMap = stringMap;
         }
 
-        public int getFlags()
-        {
+        public int getFlags() {
             return flags;
         }
 
-        public String getName()
-        {
+        public String getName() {
             return name;
         }
 
-        public Class getType()
-        {
+        public Class getType() {
             return type;
         }
 
-        public  org.lcsim.geometry.IDDecoder getIDDecoder()
-        {
-            if (dec == null) dec = findIDDecoder();
+        public org.lcsim.geometry.IDDecoder getIDDecoder() {
+            if (dec == null)
+                dec = findIDDecoder();
             return dec;
         }
 
-        public org.lcsim.geometry.IDDecoder findIDDecoder()
-        {
-            // If the IDDecoder name is explicitly set then use it, otherwise 
+        public org.lcsim.geometry.IDDecoder findIDDecoder() {
+            // If the IDDecoder name is explicitly set then use it, otherwise
             // use the name of the collection itself.
             String readoutName = name;
-            if (stringMap != null)
-            {
+            if (stringMap != null) {
                 String[] names = stringMap.get(READOUT_NAME);
-                if (names != null && names.length >= 1) readoutName = names[0];
+                if (names != null && names.length >= 1)
+                    readoutName = names[0];
             }
 
             // Find the IDDecoder using the Detector.
-            org.lcsim.geometry.IDDecoder result=null;
+            org.lcsim.geometry.IDDecoder result = null;
             try {
                 result = getDetector().getDecoder(readoutName);
+            } catch (RuntimeException x) {
             }
-            catch (RuntimeException x)
-            {}
 
-            // Detector lookup failed.  Attempt to use the CellIDEncoding collection parameter.
+            // Detector lookup failed. Attempt to use the CellIDEncoding collection parameter.
             if (result == null)
                 result = createIDDecoderFromCellIDEncoding();
 
             // If both methods failed, then there is a problem.
-            if (result == null) 
-                throw new RuntimeException("Could not find or create an IDDecoder for the collection: "+name+", readout: "+readoutName);
+            if (result == null)
+                throw new RuntimeException("Could not find or create an IDDecoder for the collection: " + name + ", readout: " + readoutName);
 
             return result;
         }
@@ -326,66 +301,57 @@
          * Make an IDDecoder for this MetaData using the CellIDEncoding parameter.
          * @return An IDDecoder made built from the CellIDEncoding.
          */
-        private IDDecoder createIDDecoderFromCellIDEncoding()
-        {
+        private IDDecoder createIDDecoderFromCellIDEncoding() {
             String[] cellIdEncoding = getStringParameters().get("CellIDEncoding");
             IDDecoder result = null;
-            if (cellIdEncoding != null)
-            {
+            if (cellIdEncoding != null) {
                 result = new BaseIDDecoder();
                 try {
                     IDDescriptor desc = new IDDescriptor(cellIdEncoding[0]);
                     result.setIDDescription(desc);
-                }
-                catch (IDDescriptor.IDException x)
-                {
+                } catch (IDDescriptor.IDException x) {
                     throw new RuntimeException(x);
                 }
-            }          
+            }
             return result;
         }
 
-        public Map<String, int[]> getIntegerParameters()
-        {
-            if (intMap == null) intMap = new HashMap<String, int[]>();
+        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[]>();
+        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[]>();
+        public Map<String, String[]> getStringParameters() {
+            if (stringMap == null)
+                stringMap = new HashMap<String, String[]>();
             return stringMap;
         }
 
-        public EventHeader getEvent()
-        {
+        public EventHeader getEvent() {
             return BaseLCSimEvent.this;
         }
 
-        public void setSubset(boolean isSubset)
-        {
-            flags = LCIOUtil.bitSet(flags,LCIOConstants.BITSubset,isSubset);
+        public void setSubset(boolean isSubset) {
+            flags = LCIOUtil.bitSet(flags, LCIOConstants.BITSubset, isSubset);
         }
 
-        public boolean isSubset()
-        {
-            return LCIOUtil.bitTest(flags,LCIOConstants.BITSubset);
+        public boolean isSubset() {
+            return LCIOUtil.bitTest(flags, LCIOConstants.BITSubset);
         }
 
-        public void setTransient(boolean isTransient)
-        {
-            flags = LCIOUtil.bitSet(flags,LCIOConstants.BITTransient,isTransient);
+        public void setTransient(boolean isTransient) {
+            flags = LCIOUtil.bitSet(flags, LCIOConstants.BITTransient, isTransient);
         }
 
-        public boolean isTransient()
-        {
-            return LCIOUtil.bitTest(flags,LCIOConstants.BITTransient);
+        public boolean isTransient() {
+            return LCIOUtil.bitTest(flags, LCIOConstants.BITTransient);
         }
     }
 }
SVNspam 0.1


Use REPLY-ALL to reply to list

To unsubscribe from the LCDET-SVN list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCDET-SVN&A=1