public DetectorArray constructArray2(Gate1D timegate, boolean diagonals, boolean allowbad) {
// Some variables
boolean valid,fail,pileup,veto;
double sum, max, theta, phi;
long t;
DetectorArray result = new DetectorArray();
ArrayList cclist[] = new ArrayList[24];
for(int i=0;i<cclist.length;i++){
cclist[i]= new ArrayList<Detector>(0);
}
for( Detector ge: event.clos.ges){
if(timegate.passes(event.stamp-ge.time)){
((ArrayList<Detector>)cclist[ge.number/4]).add(ge);
}
}
for(int i=0;i<cclist.length;i++){
switch (cclist[i].size()){
case 1:
// Single detector hit case
// Pull out the hit
Detector ge = ((ArrayList<Detector>)cclist[i]).get(0);
// Create and store the new detector object
if((!ge.fail && !ge.piledup && !ge.vetoed ) || allowbad)
result.ges.add(new Detector(i+16,(i/12)+4,ge.theta,ge.phi,ge.e,ge.time,1,ge.valid,ge.fail,ge.piledup,ge.vetoed));
break;
}
}
for( Detector ge: event.ph1s.ges){
if(timegate.passes(event.stamp-ge.time))result.ges.add(ge);
}
return result;