1 package org.lcsim.lcio;
2
3 import hep.io.sio.SIOInputStream;
4 import java.util.HashMap;
5 import java.util.Map;
6
7 import org.lcsim.event.base.BaseLCSimEvent;
8
9 import java.io.IOException;
10
11
12
13
14
15 class LCIOEvent extends BaseLCSimEvent
16 {
17 private Map<String,String> blockMap;
18 private SIOLCParameters eventParameters;
19 private static final String WEIGHT = "_weight";
20
21
22
23 LCIOEvent(SIOInputStream in, int version) throws IOException
24 {
25 this(in.readInt(),in.readInt(),in.readLong(),in.readString());
26
27 int nBlockNames = in.readInt();
28 blockMap = new HashMap<String,String>();
29 for (int i = 0; i < nBlockNames; i++)
30 {
31 String blockName = in.readString();
32 String blockType = in.readString();
33
34 blockMap.put(blockName, blockType);
35 }
36 eventParameters = version > 1001 ? new SIOLCParameters(in) : new SIOLCParameters();
37 }
38
39 public Map<String, float[]> getFloatParameters()
40 {
41 return eventParameters.getFloatMap();
42 }
43
44 public Map<String, int[]> getIntegerParameters()
45 {
46 return eventParameters.getIntMap();
47 }
48
49 public Map<String, String[]> getStringParameters()
50 {
51 return eventParameters.getStringMap();
52 }
53
54 public float getWeight()
55 {
56 float[] weights = getFloatParameters().get(WEIGHT);
57 return weights == null || weights.length == 0 ? 1.0f : weights[0];
58 }
59
60 private LCIOEvent(int run, int event, long time, String name)
61 {
62 super(run,event,name,time);
63 }
64 String getBlockType(String type)
65 {
66 return blockMap.get(type);
67 }
68 void put(String name, LCIOCollection collection)
69 {
70 SIOLCParameters parameters = collection.getParameters();
71 super.put(name,collection,collection.getType(),collection.getFlags(),parameters.getIntMap(), parameters.getFloatMap(), parameters.getStringMap());
72 }
73 }