42int main(
int argc, 
char **argv)
 
   47  string              fileDescriptor;
 
   50  size_t              elong_sample_count;
 
   51  size_t              cosine_angle_count; 
 
   61    JParser<> zap(
"Program to create interpolation tables of the PDF of the arrival time of the Cherenkov light from a shower.");
 
   63    zap[
'F'] = 
make_field(fileDescriptor,         
"file name descriptor for PDF tables");
 
   66    zap[
'e'] = 
make_field(epsilon,                
"precision for integration")  = 1.0e-10;
 
   69    zap[
'C'] = 
make_field(cosine_angle_count,     
"points for cosine angle")    = 60;
 
   70    zap[
'N'] = 
make_field(elong_sample_count,     
"points for elongation")      = 20;
 
   71    zap[
'T'] = 
make_field(TTS,                    
"sigma of time bluring [ns]") = 2.0;
 
   72    zap[
'O'] = 
make_field(option,                 
"optional transformation");
 
   77  catch(
const exception &error) {
 
   78    FATAL(error.what() << endl);
 
   82  if (cosine_angle_count == 0) {
 
   83    FATAL(
"Invalid option -C <" << cosine_angle_count << 
">" << endl);
 
  108  DEBUG(
"Memory " << 
FIXED(5,1) << getMemoryUsage() << 
"%" << endl);
 
  110    const string file_name = getFilename(fileDescriptor, SCATTERED_LIGHT_FROM_EMSHOWER);
 
  112    NOTICE(
"loading input from file " << file_name << 
"... " << flush);
 
  114    i_pdf.load(file_name.c_str());
 
  118  DEBUG(
"Memory " << 
FIXED(5,1) << getMemoryUsage() << 
"%" << endl);
 
  122    const string file_name = getFilename(fileDescriptor, DIRECT_LIGHT_FROM_EMSHOWER);
 
  124    NOTICE(
"loading input from file " << file_name << 
"... " << flush);
 
  126    pdf.load(file_name.c_str());
 
  129    DEBUG(
"Memory " << 
FIXED(5,1) << getMemoryUsage() << 
"%" << endl);
 
  131    pdf.setExceptionHandler(
new JPDF4d_t::JDefaultResult(
JMATH::zero));
 
  133    NOTICE(
"Add PDF... " << flush);
 
  143    if (
debug >= debug_t) {
 
  144      timer.
print(cout, unit_t);
 
  149  DEBUG(
"Memory " << 
FIXED(5,1) << getMemoryUsage() << 
"%" << endl);
 
  151  i_pdf.setExceptionHandler(
new JPDF4d_t::JDefaultResult(
JMATH::zero));
 
  155    NOTICE(
"Smearing combined table with sigma [ns] = " << TTS << 
" ..." << flush);
 
  164  const JFunction4DTransformer_t* i_transformer = 
dynamic_cast<JFunction4DTransformer_t*
>(i_pdf.transformer->clone());
 
  165  const JFunction5DTransformer_t* o_transformer = (i_transformer != NULL ? 
new JFunction5DTransformer_t(*i_transformer) : NULL);
 
  167  if (o_transformer != NULL && 
debug >= debug_t) {
 
  168    o_transformer->print(cout);
 
  220  JQuadrature qeant(-1.0, +1.0, cosine_angle_count, geanx);
 
  269  const double grid  = 7.0;                                       
 
  270  const double alpha = 2.0 * sqrt(1.0 - cos(grid * PI / 180.0));  
 
  272  NOTICE(
"building multi-dimensional function object" << endl);
 
  274  for (
const double E : Es) {
 
  276    DEBUG(
"E: " << E << endl);
 
  280    for (
size_t i = 0; i != elong_sample_count ; ++i ){
 
  282      const double fraction = (double) (i + 0.5) / (double) elong_sample_count;
 
  283      const double len      = geanz.getLength(pow(10.0, E), fraction, 1e-6);
 
  285      DEBUG(
"fraction: " << fraction << 
", length [m]: "<< len << endl);
 
  287      elong_lengths.push_back(len);
 
  290    if (elong_lengths.empty()) {
 
  291      elong_lengths.push_back(0.0);
 
  295    for (
const double D_m : Ds) {
 
  297      DEBUG(
"D_m: " << D_m << endl);
 
  299      for (
const double cd : C) {
 
  301        NOTICE(
"Memory " << 
FIXED(5,1) << getMemoryUsage() << 
"%" << endl);
 
  303        const unsigned int number_of_theta_points = max(2u, (
unsigned int) (180.0/(1.4 * grid)));
 
  305        for (
double theta = 0.0; theta <= PI + epsilon; theta += PI/number_of_theta_points) {
 
  307          const unsigned int number_of_phi_points = max(2u, (
unsigned int) (PI * sin(theta) / alpha));
 
  309          for (
double phi = 0.0; phi <= PI + epsilon; phi += PI/number_of_phi_points) {
 
  311            JFunction1D_t& f1 = o_pdf[E][D_m][cd][theta][phi];
 
  313            f1.reserve(X.size());
 
  315            const JArray_t 
array(E, D_m, cd, theta, phi);
 
  317            double t_old = (o_transformer != NULL ? o_transformer->getXn(
array, *X.begin()) : *X.begin());
 
  322              const double t = (o_transformer != NULL ? o_transformer->getXn(
array, *x) : *x);
 
  326              for (
const double Z : elong_lengths) {
 
  328                const double Z0 = cd * D_m;
 
  329                const double Z1 = Z0 - Z;
 
  331                const double D_m_prime = sqrt(D_m * D_m + Z1 * Z1 - Z0 * Z0);
 
  332                const double cd_prime  = Z1 / D_m_prime;
 
  333                const double t_prime   = t - (Z) / getSpeedOfLight() - (D_m_prime - D_m) * getIndexOfRefraction() / getSpeedOfLight();
 
  335                y += i_pdf(D_m_prime, cd_prime, theta, phi, t_prime);
 
  338              y /= (double) elong_lengths.size();
 
  343                  WARNING(
"dt < 0 " << *x << 
' ' << D_m << 
' ' << t << 
' ' << y << endl);
 
  368  NOTICE(
"Memory " << 
FIXED(5,1) << getMemoryUsage() << 
"%" << endl);
 
  372  if (o_transformer != NULL && option) {
 
  374    NOTICE(
"transform... " << flush);
 
  376    o_pdf.transform(*o_transformer);
 
  390    FATAL(error.what() << endl);