Skip to content
Merged
Show file tree
Hide file tree
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
@@ -1,16 +1,10 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.jlab.detector.base;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.jlab.detector.base.DetectorDescriptor;
import org.jlab.utils.groups.IndexedList;

/**
Expand All @@ -19,7 +13,7 @@
*/
public class DetectorCollection<T> {

private IndexedList<T> collection = new IndexedList<T>(3);
private IndexedList<T> collection = new IndexedList<>(3);
private String collectionName = "undefined";

public void setName(String name){
Expand Down Expand Up @@ -67,7 +61,7 @@ public T getObjectForKey(Long key){
*/
public List<T> getList(){
Collection<T> vc = this.collection.getMap().values();
List<T> list = new ArrayList<T>();
List<T> list = new ArrayList<>();
for(T c : vc){
list.add(c);
}
Expand All @@ -79,7 +73,7 @@ public List<T> getList(){
*/
public Set<Integer> getSectors(){
Set<Long> list = this.collection.getMap().keySet();
Set<Integer> sectors = new HashSet<Integer>();
Set<Integer> sectors = new HashSet<>();

for(Long item : list){
int sect = this.collection.getIndexGenerator().getIndex(item, 0);
Expand All @@ -95,7 +89,7 @@ public Set<Integer> getSectors(){
*/
public Set<Integer> getLayers(int sector){
Set<Long> list = this.collection.getMap().keySet();
Set<Integer> layers = new HashSet<Integer>();
Set<Integer> layers = new HashSet<>();
for(Long item : list){
int sect = this.collection.getIndexGenerator().getIndex(item, 0);
if(sect==sector){
Expand All @@ -113,7 +107,7 @@ public Set<Integer> getLayers(int sector){
*/
public Set<Integer> getComponents(int sector, int layer){
Set<Long> list = this.collection.getMap().keySet();
Set<Integer> components = new HashSet<Integer>();
Set<Integer> components = new HashSet<>();
for(Long item : list){
int sect = this.collection.getIndexGenerator().getIndex(item, 0);
int lay = this.collection.getIndexGenerator().getIndex(item, 1);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.jlab.detector.base;


/**
*
* @author gavalian
Expand Down Expand Up @@ -158,7 +152,5 @@ public int compareTo(DetectorDescriptor o) {
} else {
return 1;
}
//return 0;
//return 1;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.jlab.detector.base;

import java.util.HashMap;

/**
*
* @author gavalian
Expand Down Expand Up @@ -37,6 +39,16 @@ public enum DetectorType {

private final int detectorId;
private final String detectorName;

private static final HashMap<String,DetectorType> stringLookup = new HashMap<>();
private static final HashMap<Integer,DetectorType> intLookup = new HashMap<>();

static {
for (DetectorType t : values()) {
stringLookup.put(t.getName(), t);
intLookup.put(t.getDetectorId(), t);
}
}

DetectorType(){
detectorId = 0;
Expand Down Expand Up @@ -70,11 +82,7 @@ public int getDetectorId() {
* @return
*/
public static DetectorType getType(String name) {
name = name.trim();
for(DetectorType id: DetectorType.values())
if (id.getName().equalsIgnoreCase(name))
return id;
return UNDEFINED;
return stringLookup.getOrDefault(name.trim(), UNDEFINED);
}

/**
Expand All @@ -83,10 +91,6 @@ public static DetectorType getType(String name) {
* @return
*/
public static DetectorType getType(Integer detId) {

for(DetectorType id: DetectorType.values())
if (id.getDetectorId() == detId)
return id;
return UNDEFINED;
return intLookup.getOrDefault(detId, UNDEFINED);
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.jlab.detector.base;

import org.jlab.detector.calib.utils.DatabaseConstantProvider;
Expand All @@ -24,12 +19,7 @@ public class GeometryFactory {
public static int SYSTEM_TILTED = 2;
public static int SYSTEM_CLAS = 3;

//private volatile

public GeometryFactory(){

}

public GeometryFactory(){}

/**
* Load constants for given detector, with RUN and VARIATION specified
Expand All @@ -39,16 +29,18 @@ public GeometryFactory(){
* @return
*/
public static ConstantProvider getConstants(DetectorType type, int run, String variation){

DatabaseConstantProvider provider = new DatabaseConstantProvider(run,variation);

if(type==DetectorType.DC){
provider.loadTable("/geometry/dc/dc");
provider.loadTable("/geometry/dc/region");
provider.loadTable("/geometry/dc/superlayer");
provider.loadTable("/geometry/dc/layer");
provider.loadTable("/geometry/dc/alignment");
provider.loadTable("/geometry/dc/ministagger");
provider.loadTable("/geometry/dc/endplatesbow");
provider.loadTable("/geometry/dc/feedthroughs");
provider.loadTable("/geometry/dc/endplatesbow");
provider.loadTable("/geometry/dc/feedthroughs");
}

if(type==DetectorType.ECAL){
Expand Down