View Javadoc

1   package org.lcsim.lcio;
2   
3   import hep.io.sio.SIOInputStream;
4   import hep.io.sio.SIOOutputStream;
5   import java.io.IOException;
6   import org.lcsim.event.TrackerData;
7   
8   class SIOTrackerData implements TrackerData
9   {
10     private long cellid;
11     private double time;
12     private double[] chargeValues;
13     
14     SIOTrackerData(SIOInputStream in, int flags, int version) throws IOException
15     {
16        int cellid0 = in.readInt();
17        int cellid1 = 0;
18        if (LCIOUtil.bitTest(flags,LCIOConstants.TRAWBIT_ID1))
19        {
20           cellid1 = in.readInt();
21        }
22        this.cellid = ((long) cellid1)<<32 | cellid0;
23        
24        time = in.readFloat();
25        int n = in.readInt();
26        if (n > 0)
27        {
28           chargeValues = new double[n];
29           for (int i=0; i<n; i++) chargeValues[i] = in.readFloat();
30        }
31        in.readPTag(this);
32     }
33     static void write(TrackerData hit, SIOOutputStream out, int flags) throws IOException
34     {
35        long cellid = hit.getCellID();
36        out.writeInt((int) cellid);
37        if (LCIOUtil.bitTest(flags,LCIOConstants.TRAWBIT_ID1))
38        {
39           out.writeInt((int) (cellid>>32));
40        }
41        out.writeFloat((float) hit.getTime());
42        double[] c = hit.getChargeValues();
43        if (c == null)
44        {
45           out.writeInt(0);
46        }
47        else
48        {
49           out.writeInt(c.length);
50           for (int i=0; i<c.length; i++) out.writeFloat((float) c[i]);
51        }
52        out.writePTag(hit);
53     }
54     
55     
56     public long getCellID()
57     {
58        return cellid;
59     }
60     
61     public double getTime()
62     {
63        return time;
64     }
65     
66     public double[] getChargeValues()
67     {
68        return chargeValues;
69     }
70     
71  }