You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

For ease of experimenting I extracted some sample data from the DC1 tuple into a simple binary file. The file contains 922782 events, with 4 floats, for time, energy, ascension and declination for each event.

The file can be found on SLAC Unix in ~tonyj/work/glast/glast.dat

It can be read with the attached Java file.

As a sanity check I wrote the world's dumbest analysis program, which simply memory maps the data file, loops over all the data, and applies some simple cuts. No indexing, no bining, no smarts. On my 2Ghz amd64 linux machine it took 149ms to analyze the data file.

Main.java
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import java.nio.channels.FileChannel;
import java.nio.channels.FileChannel.MapMode;

/**
 *
 * @author tonyj
 */
public class Main
{
   
   /** Creates a new instance of Main2 */
   public static void main(String[] args) throws IOException
   {
      File file = new File(args[0]);
      FileInputStream in = new FileInputStream(file);
      FileChannel channel = in.getChannel();
      ByteBuffer buffer = channel.map(MapMode.READ_ONLY,0,file.length());
      buffer.order(ByteOrder.BIG_ENDIAN);
      final int size = buffer.getInt();
      FloatBuffer floats = buffer.asFloatBuffer();
      
      int nAccept = 0;
      float eCut = (float) Math.exp(4);
      long start = System.currentTimeMillis();
      for (int i=0; i<4*size; i += 4)
      {
         float time = floats.get(i);
         if (time < 20000 || time > 70000) continue;
         float energy = floats.get(i+1);
         if (energy < eCut) continue;
         float rightAscension = floats.get(i+2);
         float declination = floats.get(i+3);
         float dRA = rightAscension-180;
         float dDec = declination-0;
         if (dRA*dRA + dDec*dDec > 15*15) continue;
         nAccept++;
         //System.out.printf("%g %g %g %g\n",time,energy,dRA,dDec);
      }
      long stop = System.currentTimeMillis();
      System.out.println("Elapsed "+(stop-start)+"ms");
      System.out.println("Accepted "+nAccept+"/"+size);
      in.close();
      
   }
   
}
Elapsed 149ms
Accepted 2716/922782

Analysis program and plots are attached.

  • No labels