#include <iostream>
#include <iomanip>
#include <math.h>

#include "track.hh"

using namespace std;


int main()
{

  // initialize random number generator with time, to produce different
  // results every time
  srandom(time(NULL));

  // allocate arrays to store positions and angles of particle at 
  // origin and all planes
  state states[11];

  // initilize first element at origin
  states[0].x = 0.;
  states[0].y = 0.;
  states[0].theta = unirandom(-30., 30.);
  
  // loop over all detector planes
  for (int i=1; i<10; i++) {
    
    // extrapolate track
    states[i] = extrapolate(states[i-1],i);

    // scatter
    scatter(&(states[i]));

  }

  for (int i=0; i<10; i++) {

    cout << i 
         << ":  x = " << setw(9) << states[i].x
         << "   y = " << setw(9) << states[i].y
         << "   theta = " << setw(9) << states[i].theta
         << endl;
  }
}