lcsim/sandbox
diff -N DummyTrackStateRelationTest.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ DummyTrackStateRelationTest.java 17 Mar 2010 02:20:03 -0000 1.1
@@ -0,0 +1,149 @@
+package org.lcsim;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.GenericObject;
+import org.lcsim.event.Track;
+import org.lcsim.util.Driver;
+import org.lcsim.util.loop.LCIODriver;
+import org.lcsim.util.loop.LCSimLoop;
+
+/**
+ * Adds dummy TrackState relations to existing LCIO Tracks
+ * for input to Pandora PFA New.
+ *
+ * @author jeremym
+ */
+public class DummyTrackStateRelationTest extends TestCase
+{
+ public void testDummyTrackStates() throws Exception
+ {
+ File file = new File("./sidloi3_tracking.slcio");
+ LCSimLoop loop = new LCSimLoop();
+ loop.setLCIORecordSource(file);
+ loop.add(new DummyTrackStateDriver());
+ LCIODriver writer = new LCIODriver("sidloi3_tracking_incDummyTrackStates.slcio");
+ String writeonly[] = {
+ "Tracks", "HelicalTrackHits",
+ "StateAtStart", "StateAtEnd", "StateAtECal",
+ "EcalBarrelHits", "EcalEndcapHits", "HcalBarrelHits", "HcalEndcapHits"};
+ writer.setWriteOnlyCollections(writeonly);
+ loop.add(writer);
+ loop.loop(2);
+ loop.dispose();
+ }
+
+ class DummyTrackStateDriver extends Driver
+ {
+ public void process(EventHeader event)
+ {
+ List<Track> tracks = event.get(Track.class, "Tracks");
+
+ // Setup start lists.
+ //List<LCRelation> startRelations = new ArrayList<LCRelation>();
+ List<GenericObject> startObjs = new ArrayList<GenericObject>();
+
+ // Setup end lists.
+ //List<LCRelation> endRelations = new ArrayList<LCRelation>();
+ List<GenericObject> endObjs = new ArrayList<GenericObject>();
+
+ // Setup ECal lists.
+ //List<LCRelation> ecalRelations = new ArrayList<LCRelation>();
+ List<GenericObject> ecalObjs = new ArrayList<GenericObject>();
+
+ for (Track track : tracks)
+ {
+ // Make start state.
+ MyTrackState startState = new MyTrackState(1.0f,2.0f,3.0f,4.0f,5.0f,6.0f);
+ startObjs.add(startState);
+ //LCRelation startRel = new MyLCRelation(track,startState);
+ //startRelations.add(startRel);
+
+ // Make ECal state.
+ MyTrackState ecalState = new MyTrackState(1.1f,2.1f,3.1f,4.1f,5.1f,6.1f);
+ ecalObjs.add(ecalState);
+ //LCRelation ecalRel = new MyLCRelation(track,ecalState);
+ //ecalRelations.add(ecalRel);
+
+ // Make end state.
+ MyTrackState endState = new MyTrackState(1.2f,2.2f,3.2f,4.2f,5.2f,6.2f);
+ endObjs.add(endState);
+ //LCRelation endRel = new MyLCRelation(track,endState);
+ //endRelations.add(endRel);
+ }
+
+ //int flag = 1 << LCIOConstants.GOBIT_FIXED;
+
+ // Write out start states.
+ event.put("StateAtStart", startObjs, GenericObject.class, 0);
+ //event.put("Tracks_StateAtStart", startRelations, LCRelation.class, 0);
+
+ // Write out ecal states.
+ event.put("StateAtECal", ecalObjs, GenericObject.class, 0);
+ //event.put("Tracks_StateAtECal", ecalRelations, LCRelation.class, 0);
+
+ // Write out end states.
+ event.put("StateAtEnd", endObjs, GenericObject.class, 0);
+ //event.put("Tracks_StateAtEnd", endRelations, LCRelation.class, 0);
+ }
+ }
+
+ /**
+ * Dummy implmementation of TrackState for Pandora PFA New input.
+ * @author jeremym
+ */
+ class MyTrackState implements GenericObject
+ {
+ List<Float> vals = new ArrayList<Float>();
+
+ MyTrackState(float x, float y, float z, float px, float py, float pz)
+ {
+ vals.add(x);
+ vals.add(y);
+ vals.add(z);
+ vals.add(px);
+ vals.add(py);
+ vals.add(pz);
+ }
+
+ public double getDoubleVal(int index)
+ {
+ return 0;
+ }
+
+ public float getFloatVal(int index)
+ {
+ return vals.get(index);
+ }
+
+ public int getIntVal(int index)
+ {
+ return 0;
+ }
+
+ public int getNDouble()
+ {
+ return 0;
+ }
+
+ public int getNFloat()
+ {
+ return 6;
+ }
+
+ public int getNInt()
+ {
+ return 0;
+ }
+
+ public boolean isFixedSize()
+ {
+ return true;
+ }
+ }
+}