Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use real run numbers for geometry #422

Draft
wants to merge 32 commits into
base: development
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
9806724
remove unused stuff
Aug 22, 2023
287d9ce
add detectorChanged method (and remove unused imports)
Aug 22, 2023
b6a1bca
fix formatting
Aug 22, 2023
45e8178
implement all detectorChanged hooks (and cleanup/formatting)
Aug 22, 2023
bd0a8a4
synchronize and count changes
Aug 22, 2023
4f11001
allow nulls
Aug 22, 2023
a7a662d
add empty list check
Aug 22, 2023
1e5b979
cleanup/formatting
Aug 22, 2023
d802587
use the same wrapper used in clara/recon-util
Aug 22, 2023
5174d52
hardcode it to 11 for now
Aug 22, 2023
bb222a8
implement detectorChanged for cvt
Aug 22, 2023
0bc0d3f
implement detector changed for dc
Aug 22, 2023
747e590
use the same wrapper used in clara/recon-util
Aug 22, 2023
76ce967
fix logic oops
Aug 22, 2023
380e71c
rename processDataEvent/processEvent
Aug 28, 2023
a7c16c3
make MLTDEngine respect run number like everyone else, unless overrid…
Sep 19, 2023
cd8d2cc
add newly-required methods
Sep 19, 2023
3efa7ff
restore initialization
Sep 19, 2023
37014f8
allow run number override from YAML
Oct 17, 2023
f912152
add missing overrides
baltzell Oct 18, 2024
2661edd
remove mc/data check
baltzell Oct 18, 2024
f4eb9fa
test against gemc/dev
baltzell Nov 7, 2024
2a2118c
fix overrides (maintainence of never-ending PR)
baltzell Jan 3, 2025
9101ba9
processDataEvent should be final
baltzell Jan 3, 2025
b456000
cleanup script
baltzell Jan 3, 2025
0035170
remove unused/unnecessary script
baltzell Jan 3, 2025
9bf356a
disable workflow for now
baltzell Jan 3, 2025
544b65b
shorter name, for github web display
baltzell Jan 3, 2025
f1627c7
add neutron test
baltzell Jan 3, 2025
b6c5fee
remove leftovers
baltzell Jan 8, 2025
36f749a
abort on error
baltzell Jan 9, 2025
7e0a6b4
ci bugfix
baltzell Jan 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
# tests
#############################################################################

test_coatjava:
pid:
needs: [ build ]
strategy:
fail-fast: true
Expand All @@ -78,14 +78,16 @@ jobs:
id:
- kpp
- eb-ep
- eb-en
- eb-eg
- eb-epc
- eb-enc
- eb-eftpi
include:
# run all tests on ubuntu
# run selected tests on ubuntu
- { id: kpp, cmd: ./run-advanced-tests.sh }
- { id: eb-ep, cmd: ./run-eb-tests.sh -100 electronproton }
- { id: eb-en, cmd: ./run-eb-tests.sh -100 electronneutron }
- { id: eb-eg, cmd: ./run-eb-tests.sh -100 electrongamma }
- { id: eb-epc, cmd: ./run-eb-tests.sh -100 electronprotonC }
- { id: eb-enc, cmd: ./run-eb-tests.sh -100 electronneutronC }
Expand Down Expand Up @@ -136,7 +138,7 @@ jobs:
final:
needs:
- build
- test_coatjava
- pid
- test_run-groovy
runs-on: ubuntu-latest
steps:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
workflow_dispatch:

jobs:
if: false
validation:
uses: JeffersonLab/clas12-validation/.github/workflows/ci.yml@main
with:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public static JsonObject Map2Json(Map<String,Object> map) {
ret.add(topKey,Map2Json((Map)entry.getValue()));
}
else {
ret.add(topKey, entry.getValue().toString());
ret.add(topKey, entry.getValue() == null ? null : entry.getValue().toString());
}
}
return ret;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ public void init(){
public void processEvent(DataEvent event){
for(Map.Entry<String,ReconstructionEngine> engine : this.processorEngines.entrySet()){
try {
engine.getValue().filterEvent(event);
engine.getValue().processDataEvent(event);
} catch (Exception e){
LOGGER.log(Level.SEVERE, "[Exception] >>>>> engine : {0}\n\n", engine.getKey());
e.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
Expand Down Expand Up @@ -60,14 +61,22 @@ public abstract class ReconstructionEngine implements Engine {
volatile boolean dropOutputBanks = false;
private final Set<String> outputBanks = new HashSet<>();

private volatile List<Integer> runNumbers = new ArrayList<>();

private boolean ignoreInvalidRunNumbers = true;

private int runNumberOverride = -1;

volatile long triggerMask = 0xFFFFFFFFFFFFFFFFL;

String engineName = "UnknownEngine";
String engineAuthor = "N.T.";
String engineVersion = "0.0";
String engineDescription = "CLARA Engine";
String engineName = "UnknownEngine";
String engineAuthor = "N.T.";
String engineVersion = "0.0";
String engineDescription = "CLARA Engine";

abstract public boolean processDataEventUser(DataEvent event);
abstract public boolean init();
abstract public void detectorChanged(int runNumber);

public ReconstructionEngine(String name, String author, String version){
engineName = name;
Expand Down Expand Up @@ -108,9 +117,6 @@ protected RawBank getRawBankReader(String bankName, OrderType... order) {
return new RawDataBank(bankName, order);
}

abstract public boolean processDataEvent(DataEvent event);
abstract public boolean init();

/**
* Use a map just to avoid name clash in ConstantsManager.
* @param tables map of table names to #indices
Expand Down Expand Up @@ -187,6 +193,9 @@ public EngineData configure(EngineData ed) {
engineDictionary = new SchemaFactory();
LOGGER.log(Level.INFO,"--- engine configuration is called " + this.getDescription());
try {
if (this.getEngineConfigString("runNumberOverride")!=null) {
this.runNumberOverride = Integer.valueOf(this.getEngineConfigString("runNumberOverride"));
}
if (this.getEngineConfigString("rawBankGroup")!=null) {
this.rawBankOrders = RawBank.getFilterGroup(this.getEngineConfigString("rawBankGroup"));
}
Expand Down Expand Up @@ -227,8 +236,7 @@ public EngineData configure(EngineData ed) {
}

protected String getStringConfigParameter(String jsonString,
String key) throws Exception {
Object js;
String key) throws Exception {
String variation = "";
try {
JSONObject base = new JSONObject(jsonString);
Expand All @@ -238,13 +246,6 @@ protected String getStringConfigParameter(String jsonString,
} else {
LOGGER.log(Level.WARNING,"[JSON]" + this.getName() + " **** warning **** does not contain key = " + key);
}
/*
js = base.get(key);
if (js instanceof String) {
return (String) js;
} else {
throw new Exception("JSONObject[" + "] not a string.");
}*/
} catch (JSONException e) {
throw new Exception(e.getMessage());
}
Expand Down Expand Up @@ -345,17 +346,22 @@ public void dropBanks(DataEvent event) {
}
}
}

public boolean checkRunNumber(DataEvent event) {
if (!this.ignoreInvalidRunNumbers) return true;
int run = 0;
if (event.hasBank("RUN::config")) {
run = event.getBank("RUN::config").getInt("run",0);

public synchronized boolean checkRunNumber(DataEvent event) {
int r = runNumberOverride;
if (r <= 0 && event.hasBank("RUN::config")) {
r = event.getBank("RUN::config").getInt("run",0);
}
return run>0;
if (r > 0) {
if (this.runNumbers.isEmpty() || r != this.runNumbers.get(this.runNumbers.size()-1)) {
this.runNumbers.add(r);
this.detectorChanged(11);
}
}
return !this.ignoreInvalidRunNumbers || r>0;
}

public void filterEvent(DataEvent dataEvent) {
public final void processDataEvent(DataEvent dataEvent) {
if (!this.wroteConfig) {
this.wroteConfig = true;
JsonUtils.extend(dataEvent, CONFIG_BANK_NAME, "json", this.generateConfig());
Expand All @@ -365,7 +371,7 @@ public void filterEvent(DataEvent dataEvent) {
}
if(this.applyTriggerMask(dataEvent)) {
if (this.checkRunNumber(dataEvent)) {
this.processDataEvent(dataEvent);
this.processDataEventUser(dataEvent);
}
}
}
Expand Down Expand Up @@ -404,7 +410,7 @@ public EngineData execute(EngineData input) {
}

try {
this.filterEvent(dataEventHipo);
this.processDataEvent(dataEventHipo);
output.setData(mt, dataEventHipo.getHipoEvent());
} catch (Exception e) {
String msg = String.format("Error processing input event%n%n%s", ClaraUtil.reportException(e));
Expand Down Expand Up @@ -446,42 +452,6 @@ public EngineData execute(EngineData input) {
}

return input;
/*
if (!mt.equalsIgnoreCase()) {
String msg = String.format("Wrong input type: %s", mt);
output.setStatus(EngineStatus.ERROR);
output.setDescription(msg);
return output;
}*/
/*
EvioDataEvent dataevent = null;

try {
ByteBuffer bb = (ByteBuffer) input.getData();
byte[] buffer = bb.array();
ByteOrder endianness = bb.order();
dataevent = new EvioDataEvent(buffer, endianness, EvioFactory.getDictionary());
} catch (Exception e) {
String msg = String.format("Error reading input event%n%n%s", ClaraUtil.reportException(e));
output.setStatus(EngineStatus.ERROR);
output.setDescription(msg);
return output;
}

try {
this.processDataEvent(dataevent);
ByteBuffer bbo = dataevent.getEventBuffer();
//byte[] buffero = bbo.array();
output.setData(mt, bbo);
} catch (Exception e) {
String msg = String.format("Error processing input event%n%n%s", ClaraUtil.reportException(e));
output.setStatus(EngineStatus.ERROR);
output.setDescription(msg);
return output;
}

return output;
*/
}

@Override
Expand Down Expand Up @@ -556,16 +526,21 @@ public Reco(){
super("a","b","c");
}
@Override
public boolean processDataEvent(DataEvent event) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
public boolean processDataEventUser(DataEvent event) {
throw new UnsupportedOperationException("Not supported yet.");
}

@Override
public boolean init() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}

}

@Override
public void detectorChanged(int runNumber) {
throw new UnsupportedOperationException("Not supported yet.");
}
}

public static void main(String[] args){
System.setProperty("CLAS12DIR", "/Users/gavalian/Work/Software/project-3a.0.0/Distribution/clas12-offline-software/coatjava");
try {
Expand All @@ -586,7 +561,6 @@ public static void main(String[] args){
"\"timestamp\":333\n" +
"}";
System.out.println(json);
//json = "{ \"ccdb\":{\"run\":10,\"variation\":\"default\"}, \"variation\":\"cosmic\"}";
Reco reco = new Reco();
String variation = reco.getStringConfigParameter(json, "variation");
System.out.println(" Variation : " + variation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public boolean init() {
}

@Override
public boolean processDataEvent(DataEvent event) {
public boolean processDataEventUser(DataEvent event) {

// No CCDB table, hardcoded parameters in the extractor:
mode3.update(6, null, event, "BMT::wf", "BMT::adc");
Expand All @@ -47,4 +47,7 @@ public boolean processDataEvent(DataEvent event) {
return true;
}

@Override
public void detectorChanged(int runNumber) {}

}
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ private void loadTables() {
}

@Override
public boolean processDataEvent(DataEvent event) {
public boolean processDataEventUser(DataEvent event) {
DataBank bank = event.getBank("RUN::config");
// Load the constants
// -------------------
Expand Down Expand Up @@ -195,4 +195,6 @@ public boolean init() {
return true;
}

@Override
public void detectorChanged(int runNumber) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,11 @@ public NDList processInput(TranslatorContext translatorContext, float[] floats)
return true;
}

@Override
public void detectorChanged(int runNumber) {}

@Override
public boolean processDataEvent(DataEvent event) {
public boolean processDataEventUser(DataEvent event) {

int runNo = 10;
int eventNo = 777;
Expand Down Expand Up @@ -277,7 +279,7 @@ public static void main(String[] args) {
// System.out.println("*********** NEXT EVENT ************");
// event.show();

en.processDataEvent(event);
en.processDataEventUser(event);
writer.writeEvent(event);

}
Expand Down
Loading
Loading