Skip to content

Commit 83de27a

Browse files
committed
cleanup/bugfix
1 parent dadd3cb commit 83de27a

1 file changed

Lines changed: 14 additions & 49 deletions

File tree

  • common-tools/clas-analysis/src/main/java/org/jlab/analysis/postprocess

common-tools/clas-analysis/src/main/java/org/jlab/analysis/postprocess/Processor.java

Lines changed: 14 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
package org.jlab.analysis.postprocess;
22

3-
import java.io.File;
4-
import java.util.HashMap;
53
import java.util.List;
6-
import java.util.Map;
74
import java.util.TreeMap;
85

96
import org.jlab.jnp.hipo4.data.Bank;
@@ -31,9 +28,6 @@ public class Processor {
3128

3229
public static final String CCDB_TABLES[] = {"/runcontrol/fcup","/runcontrol/slm",
3330
"/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_";
3731

3832
private Bank runConfig = null;
3933
private Bank recEvent = null;
@@ -76,20 +70,18 @@ public Processor(List<String> files, SchemaFactory schema, HelicitySequenceDelay
7670
* @return map
7771
*/
7872
public static TreeMap<Integer,Integer> getEventUnixMap(SchemaFactory schema, List<String> files) {
79-
Bank unix = new Bank(schema.getSchema("RUN::unix"));
8073
TreeMap<Integer,Integer> m = new TreeMap<>();
8174
Event e = new Event();
75+
Bank b = schema.getBank("RUN::unix");//new Bank(schema.getSchema("RUN::unix"));
8276
for (String f : files) {
8377
HipoReader r = new HipoReader();
8478
r.setTags(1);
8579
r.open(f);
8680
while (r.hasNext()) {
8781
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));
9385
}
9486
r.close();
9587
}
@@ -124,8 +116,8 @@ private void processEventHelicity(DataEvent event, DataBank runcfg, DataBank rec
124116
private void processEventHelicity(Event event, Bank runcfg, Bank recevt) {
125117
HelicityBit hb = helicitySequence.search(runcfg.getLong("timestamp", 0));
126118
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());
129121
Bank helScaler = new Bank(schemaFactory.getSchema("HEL::scaler"));
130122
event.read(helScaler);
131123
if (helScaler.getRows()>0) {
@@ -168,11 +160,14 @@ private void processEventScalers(Bank runcfg, Bank recevt) {
168160
*/
169161
private void processEventUnix(Event event, Bank runcfg) {
170162
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+
}
176171
}
177172
}
178173
}
@@ -233,36 +228,6 @@ public void processEvent(Event event) {
233228
}
234229
}
235230

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-
266231
/**
267232
* The "postprocess" program.
268233
* @param args

0 commit comments

Comments
 (0)