#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;

#include "eventchannel.h"

Eventchannel::Eventchannel(Inputparameters& input,Beambeamsystem& bbsystem):
          Readinluminosity(input),bbs(bbsystem)
{

Randy.SetSeed(input.getseed());

}

Eventchannel::~Eventchannel()
{

}

StarlightConstants::event Eventchannel::produceevent(int &ievent)
{

}

void Eventchannel::transform(double betax,double betay,double betaz,double &E,
                             double &px,double &py,double &pz,int &iFbadevent)
{
                                                                                                                                                          
  //     carries out a lorentz transform of the frame.  (Not a
  //     boost!)
  double beta,gamma,gob;
  double E0,px0,py0,pz0;
                                                                                                                                                          
  E0 = E;
  px0 = px;
  py0 = py;
  pz0 = pz;
//cout <<"transform betax, y, z="<<betax<<" "<<betay<<" "<<betaz<<endl;
  beta = sqrt(betax*betax + betay*betay + betaz*betaz);
//cout <<"transform beta= "<<beta<<endl;
  if(beta >= 1.0)  iFbadevent = 1;
  gamma = 1./sqrt(1. - beta*beta);
  gob = (gamma-1)/(beta*beta);
                                                                                                                                                          
  E = gamma*(E0 - betax*px0 - betay*py0 - betaz*pz0);
                                                                                                                                                          
  px = -gamma*betax*E0 + (1. + gob*betax*betax)*px0  +  gob*betax*betay*py0 + gob*betax*betaz*pz0;
                                                                                                                                                          
  py = -gamma*betay*E0 + gob*betay*betax*px0+  (1. + gob*betay*betay)*py0 + gob*betay*betaz*pz0;
                                                                                                                                                          
  pz = -gamma*betaz*E0 +  gob*betaz*betax*px0 +  gob*betaz*betay*py0 + (1. + gob*betaz*betaz)*pz0;
                                                                                                                                                          
}


