36 using namespace JMATH;
48 JParser<> zap(
"Program to calculate time offsets from FitL1dtSlices output");
50 zap[
'f'] =
make_field(inputFile,
"input file") =
"nall.txt";
51 zap[
'a'] =
make_field(detectorFile,
"detector file");
52 zap[
'r'] =
make_field(idu_ref,
"reference DU set to t=0") = 0;
53 zap[
'm'] =
make_field(min_cont,
"minimal content" ) = 5;
57 if (zap.read(argc, argv) != 0) {
61 catch(
const exception &error) {
62 FATAL(error.what() << endl);
77 TMatrixD variance(1,1);
78 TMatrixD combimatrix(1,number_of_strings);
80 int du1,du2,du1_name,du2_name,nei;
81 int duarr[number_of_strings];
82 double off1,off2,offset,max1,max2;
85 combimatrix(0,idu_ref)=1;
89 std::ifstream file(inputFile);
92 while (file >> du1 >> du2 >> off1 >> off2 >> offset >> max1 >> max2 >> du1_name >> du2_name >> nei)
94 if (max1 > min_cont and max2 > min_cont and max1 < 50. and max2 < 50.){
96 combimatrix.ResizeTo(npairs+1,number_of_strings);
97 combimatrix(npairs,du1) = +1;
98 combimatrix(npairs,du2) = -1;
100 means.ResizeTo(npairs+1);
101 means[npairs]=offset;
118 TMatrixD combimatrix_T(number_of_strings,npairs);
120 combimatrix_T.Transpose(combimatrix);
122 TMatrixD pseudo = combimatrix_T * combimatrix;
124 TMatrixD pseudoinverse = pseudo.Invert();
126 TVectorD offsets = pseudoinverse * combimatrix_T * means;
128 TVectorD residues = (combimatrix * offsets) - means;
130 std::cout.precision(3);
132 for (
int ii=0;ii<number_of_strings;ii++){
133 cout << duarr[ii] <<
" " << offsets[ii] << endl;
137 for (
int ii=0;ii<npairs;ii++){
138 sumres+=fabs(residues[ii]);
140 cout << -1 <<
" " << sumres/double(npairs) << endl;
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Utility class to parse command line options.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
static const JStringCounter getNumberOfStrings
Function object to count unique strings.
Auxiliary classes and methods for mathematical operations.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).