Skip to content
Open
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -51,9 +54,13 @@ public class DCClsComboEngine extends ReconstructionEngine {
Criteria<float[][], float[]> criteria5Cls;
ZooModel<float[][], float[]> 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");
}
Expand All @@ -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)
Expand All @@ -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;
}

Expand All @@ -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;
}

Expand Down Expand Up @@ -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<DCClusterCombo> all6ClsCombos = new ArrayList();
for(Map<Integer, List<DCCluster>> map_sl_clsList : map.values()){
if(map_sl_clsList.size() == 6){
Expand Down Expand Up @@ -224,10 +235,12 @@ public boolean processDataEventUser(DataEvent event) {
}

// Make 5-cluster combos
warned5ClsLimit = false;
List<DCClusterCombo> all5ClsCombos = new ArrayList<>();
for (Map<Integer, List<DCCluster>> map_sl_clsList : map.values()) {
if(map_sl_clsList.size() >= 5){
Map<Integer, List<DCCluster>> orderedMap = new TreeMap<>(map_sl_clsList); // Sorts entries by superlayer in ascending order

List<DCClusterCombo> combos = new ArrayList<>();
generate5ClsCombos(orderedMap, combos);
all5ClsCombos.addAll(combos);
Expand Down Expand Up @@ -340,6 +353,19 @@ public void writeBank(DataEvent event, List<DCClusterCombo> clsComboList){
*/
public void generate6ClsCombos(Map<Integer, List<DCCluster>> map, int sl, DCCluster[] current, List<DCClusterCombo> 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) {
Expand Down Expand Up @@ -368,7 +394,7 @@ public void generate6ClsCombos(Map<Integer, List<DCCluster>> map, int sl, DCClus
*/
public void generate5ClsCombos(Map<Integer, List<DCCluster>> mapSL,
List<DCClusterCombo> outputList) {

// Iterate over all possible missing superlayers (1 to 6)
for (int missingSL = 1; missingSL <= SUPERLAYERS; missingSL++) {

Expand Down Expand Up @@ -404,6 +430,19 @@ private void generate5ClsRecursive(Map<Integer, List<DCCluster>> mapSL,
DCCluster[] current,
int idx,
List<DCClusterCombo> 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) {
Expand Down
Loading