View Javadoc

1   package org.lcsim.lcio;
2   
3   import hep.io.sio.SIOInputStream;
4   import hep.io.sio.SIOOutputStream;
5   
6   import java.io.IOException;
7   import org.lcsim.event.ParticleID;
8   
9   /**
10   *
11   * @author Tony Johnson
12   * @version $Id: SIOParticleID.java,v 1.3 2013/02/01 00:25:54 jeremy Exp $
13   */
14  class SIOParticleID implements ParticleID
15  {
16     SIOParticleID(SIOInputStream in, int flags, int versionr) throws IOException
17     {
18        likelihood = in.readFloat();
19        type = in.readInt();
20        pdg = in.readInt();
21        algorithmType =in.readInt() ;
22        int n = in.readInt();
23        parameters = new double[n];
24        for (int i=0; i<n; i++) parameters[i] = in.readFloat();
25     }
26  
27     static void write(ParticleID id, SIOOutputStream out, int flags) throws IOException
28     {
29           out.writeFloat((float) id.getLikelihood());
30           out.writeInt(id.getType());
31           out.writeInt(id.getPDG());
32           out.writeInt(id.getAlgorithmType());
33           double[] pars = id.getParameters();
34           int n = pars == null ? 0 : pars.length;
35           out.writeInt(n);
36           for (int i=0; i<n; i++) out.writeFloat((float)pars[i]);
37  
38     }
39  
40     public int getAlgorithmType()
41     {
42        return algorithmType;
43     }
44  
45     public double getLikelihood()
46     {
47        return likelihood;
48     }
49  
50     public int getPDG()
51     {
52        return pdg;
53     }
54  
55     public double[] getParameters()
56     {
57        return parameters;
58     }
59  
60     public int getType()
61     {
62        return type;
63     }
64     private int algorithmType;
65     private double likelihood;
66     private int pdg;
67     private double[] parameters;
68     private int type;
69  
70  }