46 inline double g1(
const JGauss&
gauss,
const element_type& point)
48 const double u = (point.getX() - gauss.
mean) / gauss.
sigma;
49 const double fs = gauss.
signal *
exp(-0.5*u*u) / (sqrt(2.0*
PI) * gauss.
sigma);
51 const double f1 = fs + fb;
53 const double y = point.getY();
54 const double dy = (f1 -
y) * (f1 - y);
69 double getChi2(
const int option)
73 for (buffer_type::const_iterator
i = buffer.begin();
i != buffer.end(); ++
i) {
104 virtual void apply(
const double step)
override
121 int main(
int argc,
char **argv)
134 JParser<> zap(
"Program to test JGradient algorithm.");
144 catch(
const exception& error) {
145 FATAL(error.what() << endl);
148 gRandom->SetSeed(seed);
150 if (numberOfEvents == 0) {
152 buffer.push_back(element_type(-3.00000, 16.00000));
153 buffer.push_back(element_type(-2.50000, 22.00000));
154 buffer.push_back(element_type(-2.00000, 70.00000));
155 buffer.push_back(element_type(-1.50000, 152.00000));
156 buffer.push_back(element_type(-1.00000, 261.00000));
157 buffer.push_back(element_type(-0.50000, 337.00000));
158 buffer.push_back(element_type( 0.00000, 378.00000));
159 buffer.push_back(element_type( 0.50000, 360.00000));
160 buffer.push_back(element_type( 1.00000, 253.00000));
161 buffer.push_back(element_type( 1.50000, 129.00000));
162 buffer.push_back(element_type( 2.00000, 72.00000));
163 buffer.push_back(element_type( 2.50000, 22.00000));
164 buffer.push_back(element_type( 3.00000, 11.00000));
170 fit =
JGauss(0.5, 0.5, 700.0, 0.0);
172 gradient.push_back(
JModifier_t(
"mean",
new JGaussEditor(fit,
JGauss(1.0, 0.0, 0.0, 0.0)), 1.0e-2));
173 gradient.push_back(
JModifier_t(
"sigma",
new JGaussEditor(fit,
JGauss(0.0, 1.0, 0.0, 0.0)), 1.0e-2));
174 gradient.push_back(
JModifier_t(
"signal",
new JGaussEditor(fit,
JGauss(0.0, 0.0, 1.0, 0.0)), 5.0e-0));
175 gradient.push_back(
JModifier_t(
"background",
new JGaussEditor(fit,
JGauss(0.0, 0.0, 0.0, 1.0)), 5.0e-1));
186 const size_t nx = 21;
187 const double xmin = -5.0;
188 const double xmax = +5.0;
190 for (
int i = 0;
i != numberOfEvents; ++
i) {
192 STATUS(
"event: " << setw(10) <<
i <<
'\r');
DEBUG(endl);
196 for (
double x = xmin, dx = (xmax - xmin) / (nx - 1);
x < xmax + 0.5*dx;
x += dx) {
198 const double value =
gauss(
x);
200 buffer.push_back(element_type(
x, gRandom->Poisson(value)));
207 fit =
JGauss(0.5, 0.5, 700.0, 0.0);
209 gradient.push_back(
JModifier_t(
"mean",
new JGaussEditor(fit,
JGauss(1.0, 0.0, 0.0, 0.0)), 1.0e-2));
210 gradient.push_back(
JModifier_t(
"sigma",
new JGaussEditor(fit,
JGauss(0.0, 1.0, 0.0, 0.0)), 1.0e-2));
211 gradient.push_back(
JModifier_t(
"signal",
new JGaussEditor(fit,
JGauss(0.0, 0.0, 1.0, 0.0)), 5.0e-0));
212 gradient.push_back(
JModifier_t(
"background",
new JGaussEditor(fit,
JGauss(0.0, 0.0, 0.0, 1.0)), 5.0e-1));
214 const double chi2 = gradient(
getChi2);
216 DEBUG(
"Final value " << fit << endl);
217 DEBUG(
"Chi2 " << chi2 << endl);
219 Q[0].
put(fit.mean - gauss.
mean);
225 for (
int i = 0;
i !=
sizeof(
Q)/
sizeof(Q[0]); ++
i) {
229 for (
int i = 0;
i !=
sizeof(
Q)/
sizeof(Q[0]); ++
i) {
235 ASSERT(Q[2].getSTDev() < precision.signal);
236 ASSERT(Q[3].getSTDev() < precision.background);
Utility class to parse command line options.
Q(UTCMax_s-UTCMin_s)-livetime_s
int main(int argc, char *argv[])
The elements in a collection are sorted according to their abscissa values and a given distance opera...
double getMean(vector< double > &v)
get mean of vector content
const JPolynome f1(1.0, 2.0, 3.0)
Function.
#define ASSERT(A,...)
Assert macro.
I/O formatting auxiliaries.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
static const double PI
Mathematical constants.
Auxiliary data structure for fit parameter.
std::ostream & shortprint(std::ostream &out)
Set short printing.
General purpose messaging.
std::ostream & longprint(std::ostream &out)
Set long printing.
Auxiliary data structure for editable parameter.
Utility class to parse command line options.
then set_variable NUMBER_OF_TESTS else set_variable NUMBER_OF_TESTS fi function gauss()
then if[[!-f $DETECTOR]] then JDetector sh $DETECTOR fi cat $WORKDIR trigger_parameters txt<< EOFtrigger3DMuon.enabled=1;trigger3DMuon.numberOfHits=5;trigger3DMuon.gridAngle_deg=1;ctMin=0.0;TMaxLocal_ns=15.0;EOF set_variable TRIGGEREFFICIENCY_TRIGGERED_EVENTS_ONLY INPUT_FILES=() for((i=1;$i<=$NUMBER_OF_RUNS;++i));do JSirene.sh $DETECTOR $JPP_DATA/genhen.km3net_wpd_V2_0.evt.gz $WORKDIR/sirene_ ${i}.root JTriggerEfficiency.sh $DETECTOR $DETECTOR $WORKDIR/sirene_ ${i}.root $WORKDIR/trigger_efficiency_ ${i}.root $WORKDIR/trigger_parameters.txt $JPP_DATA/PMT_parameters.txt INPUT_FILES+=($WORKDIR/trigger_efficiency_ ${i}.root) done for ANGLE_DEG in $ANGLES_DEG[*];do set_variable SIGMA_NS 3.0 set_variable OUTLIERS 3 set_variable OUTPUT_FILE $WORKDIR/matrix\[${ANGLE_DEG}\deg\].root $JPP_DIR/examples/JReconstruction-f"$INPUT_FILES[*]"-o $OUTPUT_FILE-S ${SIGMA_NS}-A ${ANGLE_DEG}-O ${OUTLIERS}-d ${DEBUG}--!fiif[[$OPTION=="plot"]];then if((0));then for H1 in h0 h1;do JPlot1D-f"$WORKDIR/matrix["${^ANGLES_DEG}" deg].root:${H1}"-y"1 2e3"-Y-L TR-T""-\^"number of events [a.u.]"-> o chi2
double getChi2(const double P)
Get chi2 corresponding to given probability.
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable STRING $argv[2] set_array QUANTILES set_variable FORMULA *[0] exp(-0.5 *(x-[1])*(x-[1])/([2]*[2]))" set_variable MODULE `getModule -a $DETECTOR -L "$STRING 0"` source JAcousticsToolkit.sh typeset -A TRIPODS get_tripods $WORKDIR/tripod.txt TRIPODS XMEAN
#define DEBUG(A)
Message macros.
Double_t g1(const Double_t x)
Function.