Can anyone explain this code for me
Hi I am new to java, I have a bit of code that I would like explaining, stuff like what are the methods what are the variables what are the arrays, and what the code is doing. Any help would be appreciated. Thanks
Code :
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;
Re: Can anyone explain this code for me
I'd suggest looking through this tutorial on the Java language by Sun: Getting Started, and Learning the Java Language.