|
1 | 1 | package org.jlab.analysis.postprocess; |
2 | 2 |
|
3 | | -import java.io.File; |
4 | | -import java.util.HashMap; |
5 | 3 | import java.util.List; |
6 | | -import java.util.Map; |
7 | 4 | import java.util.TreeMap; |
8 | 5 |
|
9 | 6 | import org.jlab.jnp.hipo4.data.Bank; |
@@ -31,9 +28,6 @@ public class Processor { |
31 | 28 |
|
32 | 29 | public static final String CCDB_TABLES[] = {"/runcontrol/fcup","/runcontrol/slm", |
33 | 30 | "/runcontrol/helicity","/daq/config/scalers/dsc1","/runcontrol/hwp"}; |
34 | | - public static final String DEF_PRELOAD_GLOB = "*.{hipo,h5}"; |
35 | | - |
36 | | - private final String outputPrefix = "tmp_"; |
37 | 31 |
|
38 | 32 | private Bank runConfig = null; |
39 | 33 | private Bank recEvent = null; |
@@ -76,20 +70,18 @@ public Processor(List<String> files, SchemaFactory schema, HelicitySequenceDelay |
76 | 70 | * @return map |
77 | 71 | */ |
78 | 72 | public static TreeMap<Integer,Integer> getEventUnixMap(SchemaFactory schema, List<String> files) { |
79 | | - Bank unix = new Bank(schema.getSchema("RUN::unix")); |
80 | 73 | TreeMap<Integer,Integer> m = new TreeMap<>(); |
81 | 74 | Event e = new Event(); |
| 75 | + Bank b = schema.getBank("RUN::unix");//new Bank(schema.getSchema("RUN::unix")); |
82 | 76 | for (String f : files) { |
83 | 77 | HipoReader r = new HipoReader(); |
84 | 78 | r.setTags(1); |
85 | 79 | r.open(f); |
86 | 80 | while (r.hasNext()) { |
87 | 81 | r.nextEvent(e); |
88 | | - e.read(unix); |
89 | | - int size = unix.getRows(); |
90 | | - for (int i=0; i<size; i++) { |
91 | | - m.put(unix.getInt("event",i), unix.getInt("unixtime",i)); |
92 | | - } |
| 82 | + e.read(b); |
| 83 | + int size = b.getRows(); |
| 84 | + for (int i=0; i<size; i++) m.put(b.getInt("event",i), b.getInt("unixtime",i)); |
93 | 85 | } |
94 | 86 | r.close(); |
95 | 87 | } |
@@ -124,8 +116,8 @@ private void processEventHelicity(DataEvent event, DataBank runcfg, DataBank rec |
124 | 116 | private void processEventHelicity(Event event, Bank runcfg, Bank recevt) { |
125 | 117 | HelicityBit hb = helicitySequence.search(runcfg.getLong("timestamp", 0)); |
126 | 118 | HelicityBit hbraw = helicitySequence.getHalfWavePlate() ? HelicityBit.getFlipped(hb) : hb; |
127 | | - recevt.setByte("helicity",0,hb.value()); |
128 | | - recevt.setByte("helicityRaw",0,hbraw.value()); |
| 119 | + recevt.putByte("helicity",0,hb.value()); |
| 120 | + recevt.putByte("helicityRaw",0,hbraw.value()); |
129 | 121 | Bank helScaler = new Bank(schemaFactory.getSchema("HEL::scaler")); |
130 | 122 | event.read(helScaler); |
131 | 123 | if (helScaler.getRows()>0) { |
@@ -168,11 +160,14 @@ private void processEventScalers(Bank runcfg, Bank recevt) { |
168 | 160 | */ |
169 | 161 | private void processEventUnix(Event event, Bank runcfg) { |
170 | 162 | if (runcfg.getRows() > 0) { |
171 | | - Integer unix = eventUnix.get(eventUnix.floorKey(runcfg.getInt("event",0))); |
172 | | - if (unix != null) { |
173 | | - event.remove(runcfg.getSchema()); |
174 | | - runcfg.putInt("unixtime", 0, unix); |
175 | | - event.write(runcfg); |
| 163 | + Integer key = eventUnix.floorKey(runcfg.getInt("event",0)); |
| 164 | + if (key != null) { |
| 165 | + Integer unix = eventUnix.get(key); |
| 166 | + if (unix != null) { |
| 167 | + event.remove(runcfg.getSchema()); |
| 168 | + runcfg.putInt("unixtime", 0, unix); |
| 169 | + event.write(runcfg); |
| 170 | + } |
176 | 171 | } |
177 | 172 | } |
178 | 173 | } |
@@ -233,36 +228,6 @@ public void processEvent(Event event) { |
233 | 228 | } |
234 | 229 | } |
235 | 230 |
|
236 | | - /** |
237 | | - * Create rebuilt files from preload files. |
238 | | - * @param files |
239 | | - * @return map of rebuilt:preload files |
240 | | - */ |
241 | | - private Map<String,String> rebuild(String dir, List<String> files) { |
242 | | - File d = new File(dir); |
243 | | - if (!d.canWrite()) { |
244 | | - throw new RuntimeException("No write permissions on "+dir); |
245 | | - } |
246 | | - Map<String,String> rebuiltFiles = new HashMap<>(); |
247 | | - for (String preloadFile : files) { |
248 | | - String rebuiltFile = dir+"/"+outputPrefix+preloadFile.replace(dir+"/",""); |
249 | | - Util.rebuildScalers(conman, preloadFile, rebuiltFile); |
250 | | - rebuiltFiles.put(rebuiltFile,preloadFile); |
251 | | - } |
252 | | - return rebuiltFiles; |
253 | | - } |
254 | | - |
255 | | - /** |
256 | | - * Replace files with new ones. |
257 | | - * @param files map of new:old filenames |
258 | | - */ |
259 | | - private static void replace(Map<String,String> files) { |
260 | | - for (String rebuiltFile : files.keySet()) { |
261 | | - new File(files.get(rebuiltFile)).delete(); |
262 | | - new File(rebuiltFile).renameTo(new File(files.get(rebuiltFile))); |
263 | | - } |
264 | | - } |
265 | | - |
266 | 231 | /** |
267 | 232 | * The "postprocess" program. |
268 | 233 | * @param args |
|
0 commit comments