12 #include "TGraphErrors.h" 
   13 #include "TGraphSmooth.h" 
   28   const char* 
const h0_1 = 
"h0";
 
   37 int main(
int argc, 
char **argv)
 
   42   typedef   JRange<double>  JRange_t;
 
   55     JParser<> zap(
"Auxiliary program to model transition time distribution generator from data.");
 
   57     zap[
'f'] = 
make_field(inputFile,    
"input file (output from JPulsar)");
 
   59     zap[
'B'] = 
make_field(bass,         
"see TGraphSmooth")                                                = 0.00;
 
   60     zap[
'S'] = 
make_field(span,         
"see TGraphSmooth")                                                = 0.01;
 
   61     zap[
'P'] = 
make_field(pdf,          
"PDF output file; for inclusion in JPMTTransitTimeProbability.hh") = 
"";
 
   62     zap[
'C'] = 
make_field(
cdf,          
"CDF output file; for inclusion in JPMTTransitTimeGenerator.hh")   = 
"";
 
   63     zap[
'T'] = 
make_field(T_ns,         
"time range for PDF and CDF")                                      = JRange_t(-20.0, +100.0);
 
   68   catch(
const exception &error) {
 
   69     FATAL(error.what() << endl);
 
   75   TFile 
in(inputFile.c_str(), 
"exist");
 
   78     FATAL(
"File " << inputFile << 
" not opened." << endl);
 
   81   h1 = 
dynamic_cast<TH1D*
>(
in.Get(h0_1));
 
   84     FATAL(
"No histogram <" << h0_1 << 
">." << endl);
 
   90   TF1 
f1(
"f1", 
"[0]*exp(-0.5*(x-[1])*(x-[1])/([2]*[2])) + [3]");
 
   99   for (Int_t 
i = 1; 
i <= h1->GetNbinsX(); ++
i) {
 
  101     const Double_t 
x = h1->GetBinCenter (
i);
 
  102     const Double_t 
y = h1->GetBinContent(
i);
 
  110   f1.SetParameter(0, ymax);
 
  111   f1.SetParameter(1, x0);
 
  112   f1.SetParameter(2, 
sigma);
 
  113   f1.SetParameter(3, ymin);  
 
  117   h1->Fit(&f1, 
"LL", 
"same", x0 - 5 * 
sigma, x0 + 5 * 
sigma);
 
  121   ymax  = f1.GetParameter(0);
 
  122   x0    = f1.GetParameter(1);
 
  123   sigma = f1.GetParameter(2);
 
  124   ymin  = f1.GetParameter(3);
 
  136   for (Int_t 
i = 1; 
i <= h1->GetNbinsX(); ++
i) {
 
  138     const Double_t 
x = h1->GetBinCenter (
i);
 
  139     const Double_t 
y = h1->GetBinContent(
i);
 
  145       if      (x < x0 - 5.0 * 
sigma)
 
  147       else if (x > x0 + 5.0 * 
sigma)
 
  167   NOTICE(
"Number of pulses: " << yy      << endl);
 
  168   NOTICE(
"Pre-pulses:       " << yl / yy << endl);
 
  169   NOTICE(
"Delayed pulses:   " << yr / yy << endl);
 
  181   for (Int_t 
i = 1; 
i <= h1->GetNbinsX(); ++
i) {
 
  183     const Double_t 
x = h1->GetBinCenter (
i)  -  x0;   
 
  184     const Double_t 
y = h1->GetBinContent(
i)  -  y0;   
 
  190       EY.push_back(sqrt(y));
 
  194   const int N = 
X.size();
 
  197     FATAL(
"Not enough points." << endl);
 
  201   TGraphErrors g0(
N, 
X.data(), 
Y.data(), EX.data(), EY.data());
 
  212   for (
int i = 0; 
i != 
N; ++
i) {
 
  214     const Double_t 
x = g1.GetX()[
i];
 
  215     const Double_t 
f = f1.Eval(x + x0);
 
  224   TGraphSmooth gs(
"gs");
 
  226   TGraph* gout = gs.SmoothSuper(&g1, 
"", bass, span, 
false);
 
  231   for (
int i = 0; 
i != 
N; ++
i) {
 
  232     g1.GetY()[
i] = gout->GetY()[
i];
 
  238   for (
int i = 0; 
i != 
N; ++
i) {
 
  240     const Double_t 
x = g1.GetX()[
i];
 
  241     const Double_t 
f = f1.Eval(x + x0);
 
  256     for (
int i = 0; 
i != 
N; ++
i) {
 
  260     for (
int i = 0; 
i != 
N; ++
i) {
 
  264     ofstream out(pdf.c_str());
 
  266     out << 
"\t// produced by JLegolas.cc" << endl;
 
  268     const Double_t 
xmin = T_ns.getLowerLimit();
 
  269     const Double_t 
xmax = T_ns.getUpperLimit();
 
  270     const Double_t dx   = 0.25;
 
  272     for (Double_t 
x = xmin; 
x <= xmax + 0.5*dx; 
x += dx) {
 
  274       Double_t 
y = g2.Eval(
x);
 
  282           << showpos   << 
FIXED(7,2) << 
x  
  284           << noshowpos << 
FIXED(8,6) << y
 
  297     for (
int i = 0; 
i+1 != 
N; ++
i) {
 
  298       g2.GetY()[
i+1] += g2.GetY()[
i];
 
  302       const Double_t 
xmin = g2.GetX()[ 0 ];
 
  303       const Double_t 
xmax = g2.GetX()[
N-1];
 
  304       const Double_t dx   = (xmax - 
xmin) / 
N;
 
  306       const Double_t ymin = g2.GetY()[ 0 ];
 
  307       const Double_t ymax = g2.GetY()[
N-1];
 
  309       for (
int i = 0; 
i != 
N; ++
i) {
 
  311         const Double_t 
x = g2.GetX()[
i];
 
  312         const Double_t 
y = g2.GetY()[
i];
 
  314         g2.GetX()[
i] = (y - ymin) / ymax;
 
  315         g2.GetY()[
i] =  x + 0.5 * dx;
 
  319     ofstream out(
cdf.c_str());
 
  321     out << 
"\t// produced by JLegolas.cc" << endl;
 
  323     const Double_t 
xmin = 0.0;
 
  324     const Double_t 
xmax = 1.0;
 
  325     const Double_t dx   = 0.001;
 
  327     for (Double_t 
x = xmin; 
x <= xmax + 0.5*dx; 
x += dx) {
 
  331           << noshowpos << 
FIXED(6,4) << 
x  
  333           << showpos   << 
FIXED(9,5) << g2.Eval(
x) 
 
  345     const Double_t 
xmin = 
X[ 0 ];
 
  346     const Double_t 
xmax = 
X[
N-1];
 
  347     const Double_t dx   = (xmax - 
xmin) / 
N;
 
  349     TH1D h2(
"pmt", NULL, 
N, xmin - 0.5*dx, xmax + 0.5*dx);
 
  357     for (
int i = 0; 
i != 
N; ++
i) {
 
  363     for (
int i = 0; 
i != 
N; ++
i) {
 
  365       h2.SetBinContent(
i+1, 
Y [
i]/W);
 
  366       h2.SetBinError  (
i+1, EY[
i]/W);
 
Utility class to parse command line options. 
 
int main(int argc, char *argv[])
 
then fatal Wrong number of arguments fi set_variable STRING $argv[1] set_variable DETECTORXY_TXT $WORKDIR $DETECTORXY_TXT tail read X Y CHI2 RMS printf optimum n $X $Y $CHI2 $RMS awk v Y
 
Auxiliary data structure for floating point format specification. 
 
const JPolynome f1(1.0, 2.0, 3.0)
Function. 
 
I/O formatting auxiliaries. 
 
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object 
 
General purpose messaging. 
 
then for FUNCTION in pdf npe cdf
 
then usage $script< input file >[option[primary[working directory]]] nWhere option can be N
 
Auxiliary class to define a range between two values. 
 
then fatal The output file must have the wildcard in the e g root fi eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
 
Utility class to parse command line options. 
 
then JHobbit a $DETECTOR f
 
no fit printf nominal n $STRING awk v X
 
Double_t g1(const Double_t x)
Function.