14 #include "TGraphErrors.h" 
   15 #include "TGraphSmooth.h" 
   31 int main(
int argc, 
char **argv)
 
   47     JParser<> zap(
"Auxiliary program to model transition time distribution generator from data.");
 
   61   catch(
const exception &error) {
 
   62     FATAL(error.what() << endl);
 
   66   const TRegexp regexp(
"V[0-9]+");
 
   68   TString buffer(inputFile.c_str());
 
   71   Ssiz_t pos = buffer.Index(regexp, &len);
 
   76     buffer  = buffer(pos+1, len-1);
 
   90   ifstream 
in(inputFile.c_str());
 
   94     for (Double_t x = 0.0, y; 
in >> y; x += xbin) {
 
   98       EY.push_back(sqrt(y));
 
  103     in.ignore(numeric_limits<streamsize>::max(), 
'\n');
 
  105     for (Double_t x, y, dy, rms; 
in >> x >> y >> dy >> rms; ) {
 
  119     FATAL(
"Not enough points." << endl);
 
  124     xbin = (X[
N-1] - X[0]) / (
N - 1);
 
  126     NOTICE(
"Bin width [ns] " << xbin << endl);
 
  131   TH1D 
h1(
"h1", NULL, 
N, X[0] - 0.5*xbin, X[
N-1] + 0.5*xbin);
 
  135   for (
int i = 0; i != 
N; ++i) {
 
  136     h1.SetBinContent(i+1, 
Y [i]);
 
  137     h1.SetBinError  (i+1, EY[i]);
 
  143   TF1 f1(
"f1", 
"[0]*exp(-0.5*(x-[1])*(x-[1])/([2]*[2])) + [3]");
 
  150   Double_t sigma = 2.0;
 
  153   for (
int i = 0; i != 
N; ++i) {
 
  160   f1.SetParameter(0, ymax);
 
  161   f1.SetParameter(1, x0);
 
  162   f1.SetParameter(2, sigma);
 
  163   f1.SetParameter(3, ymin);  
 
  166   h1.Fit(&f1, 
"LL", 
"same", x0 - 5 * sigma, x0 + 5 * sigma);
 
  171   ymax  = f1.GetParameter(0);
 
  172   x0    = f1.GetParameter(1);
 
  173   sigma = f1.GetParameter(2);
 
  174   ymin  = f1.GetParameter(3);
 
  178     for (JVector_t::iterator x = X.begin(); x != X.end(); ++x) {
 
  182     f1.SetParameter(1, x0 = 0);    
 
  185       f1.SetParameter(3, 1e-4 * ymax);    
 
  195   for (
int i = 0; i != 
N; ++i) {
 
  197     const Double_t x = X[i];
 
  198     const Double_t y = 
Y[i];      
 
  202     if      (x < x0 - 5.0 * sigma)
 
  204     else if (x > x0 + 5.0 * sigma)
 
  208   NOTICE(
"Number of pulses: " << yy      << endl);
 
  209   NOTICE(
"Pre-pulses:       " << yl / yy << endl);
 
  210   NOTICE(
"Delayed pulses:   " << yr / yy << endl);
 
  219     while (n1 != 
N - 1 && 
Y[n1] == 0) ++n1;
 
  220     while (n2 !=   0   && 
Y[n2] == 0) --n2;
 
  226       FATAL(
"No non-zero data." << endl);
 
  229     X  = JVector_t(X .data() + n1, X .data() + n2);
 
  230     Y  = JVector_t(
Y .data() + n1, 
Y .data() + n2);
 
  231     EX = JVector_t(EX.data() + n1, EX.data() + n2);
 
  232     EY = JVector_t(EY.data() + n1, EY.data() + n2);
 
  237   TGraphErrors g0(
N, X.data(), 
Y.data(), EX.data(), EY.data());
 
  250     for (
int i = 0; i != 
N; ++i) {
 
  252       const Double_t x = g1.GetX()[i];
 
  253       const Double_t 
f = f1.Eval(x);
 
  261     TGraphSmooth   gs(
"gs");
 
  263     TGraph* gout = gs.SmoothSuper(&g1, 
"", bass, span, 
false, g1.GetEY());
 
  268     for (
int i = 0; i != 
N; ++i) {
 
  269       g1.GetY()[i] = gout->GetY()[i];
 
  275     for (
int i = 0; i != 
N; ++i) {
 
  277       const Double_t x = g1.GetX()[i];
 
  278       const Double_t 
f = f1.Eval(x);
 
  291     for (
int i = 0; i != 
N; ++i) {
 
  297     for (
int i = 0; i != 
N; ++i) {
 
  301     ofstream out(pdf.c_str());
 
  303     const Double_t xmin = g2.GetX()[ 0 ];
 
  304     const Double_t xmax = g2.GetX()[
N-1];
 
  306     for (Double_t x = xmin, dx = (xmax - xmin) / 
numberOfBins; x <= xmax + 0.5*dx; x += dx) {
 
  310           << showpos   << 
FIXED(7,2) << x 
 
  312           << noshowpos << 
FIXED(6,4) << g2.Eval(x) 
 
  323     for (
int i = 0, 
j = 1; 
j != 
N; ++i, ++
j) {
 
  324       g2.GetY()[
j] += g2.GetY()[i];
 
  327     const Double_t ymin = g2.GetY()[ 0 ];
 
  328     const Double_t ymax = g2.GetY()[
N-1];
 
  330     for (
int i = 0; i != 
N; ++i) {
 
  332       const Double_t x = g2.GetX()[i];
 
  333       const Double_t y = g2.GetY()[i];
 
  335       g2.GetX()[i] = (y - ymin) / ymax;
 
  336       g2.GetY()[i] =  x + 0.5 * xbin;
 
  339     ofstream out(
cdf.c_str());
 
  341     const Double_t xmin = 0.0;
 
  342     const Double_t xmax = 1.0;
 
  344     for (Double_t x = xmin, dx = (xmax - xmin) / 
numberOfBins; x <= xmax + 0.5*dx; x += dx) {
 
  348           << noshowpos << 
FIXED(6,4) << x 
 
  350           << showpos   << 
FIXED(9,5) << g2.Eval(x) 
 
  362     const Double_t xmin = X[ 0 ];
 
  363     const Double_t xmax = X[
N-1];
 
  364     const Double_t dx   = (xmax - xmin) / 
N;
 
  366     TH1D h2(
"pmt", NULL, 
N, xmin - 0.5*dx, xmax + 0.5*dx);
 
  372     for (
int i = 0; i != 
N; ++i) {
 
  378     for (
int i = 0; i != 
N; ++i) {
 
  380       h2.SetBinContent(i+1, 
Y [i]/W);
 
  381       h2.SetBinError  (i+1, EY[i]/W);
 
Utility class to parse command line options. 
 
do set_array DAQHEADER JPrintDAQHeader f
 
then for HISTOGRAM in h0 h1
 
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. 
 
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
 
Utility class to parse command line options. 
 
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
 
then usage $script[input file[working directory[option]]] nWhere option can be N
 
int numberOfBins
number of bins for average CDF integral of optical module 
 
Double_t g1(const Double_t x)
Function. 
 
int main(int argc, char *argv[])