36{
   39 
   41 
   44  double         E;
   45  double         D;
   46  double         cd;
   48  int            numberOfEvents;
   51 
   52  try { 
   53 
   54    JParser<> zap(
"Program to verify generation of arrival times of Cherenkov photons from a shower using tabulated CDF.");
 
   55 
   58    zap[
'E'] = 
make_field(E,         
"muon energy [GeV]")          = 1.0;
 
   60    zap[
'c'] = 
make_field(cd,        
"cosine emission angle");
 
   61    zap[
'D'] = 
make_field(dir,       
"(theta, phi) of PMT [rad]");
 
   65 
   66    zap(argc, argv);
   67  }
   68  catch(const exception& error) {
   69    FATAL(error.what() << endl);
 
   70  }
   71 
   72 
   74  
   75  
   81 
   82  const int N = inputFile.size();
   83 
   84  JCDF_t cdf [N];
   85 
   86  try {
   87 
   88    for (int i = 0; i != N; ++i) {
   89 
   90      NOTICE(
"loading input from file " << inputFile[i] << 
"... " << flush);
 
   91 
   92      cdf [i].load(inputFile[i].c_str());
   93 
   95    }
   96  }
   99  }
  100 
  101 
  103 
  104    for ( ; ; ) {
  105 
  107 
  108      cout << "> " << flush;
  110 
  111      cout << " --> ";
  112 
  113      for (int i = 0; i != N; ++i) {
  114 
  115        try {
  116        
  117          const double npe = cdf[i].getNPE (D, cd, dir.
getTheta(), dir.
getPhi()) * E;
 
  118          const double t   = cdf[i].getTime(D, cd, dir.
getTheta(), dir.
getPhi(), x);
 
  119 
  120          cout << 
' ' << 
FIXED(6,2) << t << 
' ' << 
FIXED(5,2) << npe;
 
  121        }
  122        catch(const exception& error) {
  123          ERROR(error.what() << endl);
 
  124        }
  125      }
  126 
  127      cout << endl;
  128    }
  129 
  130    return 0;
  131  }
  132  
  133 
  134  int function = 0;
  135 
  136  if (inputFile.size() == 1 && 
getPDFType(inputFile[0]) == DIRECT_LIGHT_FROM_EMSHOWER) {
 
  137    function = 1;
  138  }
  139 
  140  TH1D* h0 = NULL;
  141 
  142  
  143  const double t0   =  0.0;                                   
  144 
  146 
  148 
  150 
  151    {
  152      for ( ; 
x <  -10.0; 
x +=  5.0) { X.push_back(t0 + x); }
 
  153      for ( ; 
x <  +20.0; 
x +=  1.0) { X.push_back(t0 + x); }
 
  154      for ( ; 
x <  +50.0; 
x +=  2.0) { X.push_back(t0 + x); }
 
  155    }
  156    if (function != 1) {
  157      for ( ; 
x < +100.0; 
x +=  5.0) { X.push_back(t0 + x); }
 
  158      for ( ; 
x < +250.0; 
x += 10.0) { X.push_back(t0 + x); }
 
  159      for ( ; 
x < +500.0; 
x += 25.0) { X.push_back(t0 + x); }
 
  160      for ( ; 
x < +900.0; 
x += 50.0) { X.push_back(t0 + x); }
 
  161    }
  162 
  163    h0 = new TH1D("h0", NULL,  X.size() - 1, X.data());
  164 
  165  } else {
  166 
  168  }
  169 
  170  h0->Sumw2();
  171  
  172  JManager<int, TH1D> H1(new TH1D("h1[%]", NULL, 100000, 0.0, +1.0));
  173  
  174  for (int i = 0; i != N; ++i) {
  175 
  176    for (
int j = 1; 
j <= H1->GetNbinsX(); ++
j) {
 
  177    
  178      try {
  179      
  180        const double x = H1->GetBinCenter(j);
 
  181        const double t = cdf[i].getTime(D, cd, dir.
getTheta(), dir.
getPhi(), x);
 
  182      
  183        H1[i]->SetBinContent(j, t);
  184      }
  185      catch(const exception& error) {
  186        ERROR(error.what() << endl);
 
  187      }
  188    }
  189  }
  190    
  191  if (numberOfEvents > 0) {
  192  
  194    
  196    
  197    for (int counter = 0; counter != numberOfEvents; ++counter) {
  198      
  199      if (counter%1000== 0) { 
  201      }
  202      
  204      
  205      for (int i = 0; i != N; ++i) {
  206 
  207        try {
  208        
  209          const double npe = cdf[i].getNPE(D, cd, dir.
getTheta(), dir.
getPhi()) * E;
 
  210        
  211          for (int j = gRandom->Poisson(npe); j != 0; --j) {
  212          
  213            const double x = gRandom->Rndm();
 
  214            const double t = cdf[i].getTime(D, cd, dir.
getTheta(), dir.
getPhi(), x);
 
  215          
  216            h0->Fill(t + t0);
  217          }
  218        }
  219        catch(const exception& error) {
  220          NOTICE(error.what() << endl);
 
  221        }
  222      }
  223      
  225    }
  227  
  228    const double W = 1.0 / (double) numberOfEvents;
  229    
  231      timer.
print(cout, W);
 
  232    }
  233 
  235  }
  236 
  238 
  239  out << *h0 << H1;
  240  
  241  out.Write();
  242  out.Close();
  243}
#define DEBUG(A)
Message macros.
 
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
 
Auxiliary class for CPU timing and usage.
 
void print(std::ostream &out, const JScale_t scale=milli_t) const
Print timer data.
 
Data structure for angles in three dimensions.
 
double getTheta() const
Get theta angle.
 
double getPhi() const
Get phi angle.
 
virtual const char * what() const override
Get error message.
 
Utility class to parse command line options.
 
Multi-dimensional CDF table for arrival time of Cherenkov light.
 
void convertToPDF(TH1 &h1, const std::string &option="NW", const double factor=1.0)
Convert 1D histogram to PDF.
 
int getPDFType(const std::string &file_name)
Get PDF type.
 
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
 
Auxiliary data structure for floating point format specification.