Test program for fit of quaternions. 
   45     JParser<> zap(
"Test program for fit of quaternions.");
 
   49     zap[
'x'] = 
make_field(
X,               
"tilt angle around x-axis [deg]") = 0.0;
 
   50     zap[
'y'] = 
make_field(
Y,               
"tilt angle around y-axis [deg]") = 0.0;
 
   51     zap[
'z'] = 
make_field(
Z,               
"tilt angle around z-axis [deg]") = 0.0;
 
   52     zap[
'a'] = 
make_field(alpha,           
"twist angle [deg/m]");
 
   60   catch(
const exception &error) {
 
   61     FATAL(error.what() << endl);
 
   65   gRandom->SetSeed(seed);
 
   70   TH1D hc(
"chi2/NDF", NULL, 100, 0.0,  2.0);
 
   71   TH1D h0(
"tilt",     NULL, 100, 0.0,  2.0);
 
   72   TH1D h1(
"twist",    NULL, 100, 0.0,  0.1);
 
   77   const JModel model(JQuaternion3D(JQuaternion3X(
X     * 
PI / 180.0),
 
   78                                    JQuaternion3Y(
Y     * 
PI / 180.0),
 
   79                                    JQuaternion3Z(
Z     * 
PI / 180.0)),
 
   80                      JQuaternion3D(JQuaternion3Z(alpha * 
PI / 180.0)));
 
   86   JSimplex<JModel> simplex;
 
   90   simplex.debug = 
debug;
 
   95   for (
int counter = 0; counter != numberOfEvents; ++counter) {
 
   97     STATUS(
"event: " << setw(10) << counter << 
'\r'); 
DEBUG(endl);
 
  102     const double z1  = 30.0;                       
 
  103     const double dz  = 10.0;                       
 
  104     const double eps = 1.0e-6;                     
 
  108     for (
int i = 1; i <= 
N; ++i) {
 
  110       const double z = z1 + (i - 1) * dz;          
 
  112       data.push_back(JHit(i, z, model(z), max(eps, 
sigma.getLength())));
 
  118       i->mul(JQuaternion3D(JQuaternion3X(gRandom->Gaus(0.0, 
sigma.getX()) * 
PI / 180.0),
 
  119                            JQuaternion3Y(gRandom->Gaus(0.0, 
sigma.getY()) * 
PI / 180.0),
 
  120                            JQuaternion3Z(gRandom->Gaus(0.0, 
sigma.getZ()) * 
PI / 180.0)));
 
  124       DEBUG(
FIXED(4,1) << i->getZ() << 
' ' << 
FIXED(12,8) << i->getQuaternion() << endl);
 
  128     JModel 
result(data.begin(), data.end());      
 
  137       simplex.step.resize(4);
 
  139       simplex.step[0] = JModel(JQuaternion3X(0.50 * 
PI / 180.0), JQuaternion3D::getIdentity());
 
  140       simplex.step[1] = JModel(JQuaternion3Y(0.50 * 
PI / 180.0), JQuaternion3D::getIdentity());
 
  141       simplex.step[2] = JModel(JQuaternion3Z(0.50 * 
PI / 180.0), JQuaternion3D::getIdentity());
 
  142       simplex.step[3] = JModel(JQuaternion3D::getIdentity(), JQuaternion3Z(0.05 * 
PI / 180.0));
 
  144       const double chi2 = simplex(
getChi2, data.begin(), data.end());  
 
  145       const int    ndf  = data.size() * 4 - simplex.step.size();
 
  147       DEBUG(
"number of iterations " << simplex.numberOfIterations << endl);
 
  151       DEBUG(
"chi2 " << chi2 << 
'/' << ndf << endl);
 
  159     h0.Fill(
getAngle(JDirection3D(0.0, 0.0, 1.0).rotate(model .Q0), 
 
  160                      JDirection3D(0.0, 0.0, 1.0).rotate(
result.Q0)));
 
Utility class to parse command line options. 
 
double getAngle(const JQuaternion3D &first, const JQuaternion3D &second)
Get space angle between quanternions. 
 
then JShowerPostfit f $INPUT_FILE o $OUTPUT_FILE N
 
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. 
 
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object 
 
static const double PI
Mathematical constants. 
 
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
 
no fit printf nominal n $STRING awk v X
 
do set_variable MODULE getModule a $WORKDIR detector_a datx L $STRING JEditDetector a $WORKDIR detector_a datx M $MODULE setz o $WORKDIR detector_a datx JEditDetector a $WORKDIR detector_b datx M $MODULE setz o $WORKDIR detector_b datx done echo Output stored at $WORKDIR detector_a datx and $WORKDIR tripod_a txt JDrawDetector2D a $WORKDIR detector_a datx a $WORKDIR detector_b datx L BL o detector $FORMAT $BATCH JDrawDetector2D T $WORKDIR tripod_a txt T $WORKDIR tripod_b txt L BL o tripod $FORMAT $BATCH JCompareDetector a $WORKDIR detector_a datx b $WORKDIR detector_b datx o $WORKDIR abc root &dev null for KEY in X Y Z
 
static int MAXIMUM_ITERATIONS
maximal number of iterations 
 
double getChi2(const double P)
Get chi2 corresponding to given probability. 
 
#define DEBUG(A)
Message macros.