diff --git a/reconstruction/ai/src/main/java/org/jlab/service/ai/DCClsComboEngine.java b/reconstruction/ai/src/main/java/org/jlab/service/ai/DCClsComboEngine.java index 847caa11ed..aa959e1dea 100644 --- a/reconstruction/ai/src/main/java/org/jlab/service/ai/DCClsComboEngine.java +++ b/reconstruction/ai/src/main/java/org/jlab/service/ai/DCClsComboEngine.java @@ -36,6 +36,9 @@ public class DCClsComboEngine extends ReconstructionEngine { final static String CONF_THREADS = "threads"; + final static String LIMIT_CLSCOMBOS_PERSECTOR = "limitClsCombosPerSector"; + int limitClsCombosPerSector = (int)1e5; + final static String CONF_MODEL_FILE_6CLS = "modelFile6Cls"; final static String CONF_THRESHOLD_6CLS = "threshold6Cls"; String modelFile6Cls = "mlp_64h_4l_6cls.pt"; @@ -51,9 +54,13 @@ public class DCClsComboEngine extends ReconstructionEngine { Criteria criteria5Cls; ZooModel model5Cls; PredictorPool predictors5Cls; - + final static int SUPERLAYERS = 6; + private static final Logger LOGGER = Logger.getLogger(DCClsComboEngine.class.getName()); + private boolean warned6ClsLimit = false; + private boolean warned5ClsLimit = false; + public DCClsComboEngine() { super("DCClsComboEngine","tongtong","1.0"); } @@ -69,6 +76,9 @@ public boolean init() { int threads = Integer.parseInt(getEngineConfigString(CONF_THREADS,"64")); + if (getEngineConfigString(LIMIT_CLSCOMBOS_PERSECTOR) != null) + limitClsCombosPerSector = Integer.parseInt(getEngineConfigString(LIMIT_CLSCOMBOS_PERSECTOR)); + if (getEngineConfigString(CONF_THRESHOLD_6CLS) != null) threshold6Cls = Float.parseFloat(getEngineConfigString(CONF_THRESHOLD_6CLS)); if (getEngineConfigString(CONF_MODEL_FILE_6CLS) != null) @@ -88,7 +98,7 @@ public boolean init() { model6Cls = criteria6Cls.loadModel(); predictors6Cls = new PredictorPool(threads, model6Cls); } catch (NullPointerException | MalformedModelException | IOException | ModelNotFoundException ex) { - Logger.getLogger(DCClsComboEngine.class.getName()).log(Level.SEVERE, null, ex); + LOGGER.log(Level.SEVERE, null, ex); return false; } @@ -111,7 +121,7 @@ public boolean init() { model5Cls = criteria5Cls.loadModel(); predictors5Cls = new PredictorPool(threads, model5Cls); } catch (NullPointerException | MalformedModelException | IOException | ModelNotFoundException ex) { - Logger.getLogger(DCClsComboEngine.class.getName()).log(Level.SEVERE, null, ex); + LOGGER.log(Level.SEVERE, null, ex); return false; } @@ -141,8 +151,9 @@ public boolean processDataEventUser(DataEvent event) { allClusterList.add(cls); map.computeIfAbsent(sector, s -> new HashMap<>()).computeIfAbsent(superlayer, sl -> new ArrayList<>()).add(cls); } - + // Make 6-cluster combos + warned6ClsLimit = false; List all6ClsCombos = new ArrayList(); for(Map> map_sl_clsList : map.values()){ if(map_sl_clsList.size() == 6){ @@ -224,10 +235,12 @@ public boolean processDataEventUser(DataEvent event) { } // Make 5-cluster combos + warned5ClsLimit = false; List all5ClsCombos = new ArrayList<>(); for (Map> map_sl_clsList : map.values()) { if(map_sl_clsList.size() >= 5){ Map> orderedMap = new TreeMap<>(map_sl_clsList); // Sorts entries by superlayer in ascending order + List combos = new ArrayList<>(); generate5ClsCombos(orderedMap, combos); all5ClsCombos.addAll(combos); @@ -340,6 +353,19 @@ public void writeBank(DataEvent event, List clsComboList){ */ public void generate6ClsCombos(Map> map, int sl, DCCluster[] current, List comboList) { + // Limit for combos + if (comboList.size() >= limitClsCombosPerSector) { + if (!warned6ClsLimit) { + LOGGER.log(Level.FINE, String.format( + "6-cluster combo generation reached limit: %d combos per sector. " + + "Further combinations are discarded.", + limitClsCombosPerSector + )); + warned6ClsLimit = true; + } + return; + } + // Base case: if all superlayers have been processed (sl > 6) // then we have a complete 6-cluster combination if (sl > SUPERLAYERS) { @@ -368,7 +394,7 @@ public void generate6ClsCombos(Map> map, int sl, DCClus */ public void generate5ClsCombos(Map> mapSL, List outputList) { - + // Iterate over all possible missing superlayers (1 to 6) for (int missingSL = 1; missingSL <= SUPERLAYERS; missingSL++) { @@ -404,6 +430,19 @@ private void generate5ClsRecursive(Map> mapSL, DCCluster[] current, int idx, List outputList) { + + // Limit for combos + if (outputList.size() >= limitClsCombosPerSector) { + if (!warned5ClsLimit) { + LOGGER.log(Level.FINE, String.format( + "5-cluster combo generation reached limit: %d combos per sector. " + + "Further combinations are discarded.", + limitClsCombosPerSector + )); + warned5ClsLimit = true; + } + return; + } // Base case: all superlayers processed if (sl > SUPERLAYERS) {