33int main(
int argc,
char **argv)
37 using namespace JMATH;
49 JParser<> zap(
"Program to calculate time offsets from FitL1dtSlices output");
51 zap[
'f'] =
make_field(inputFile,
"input file") =
"nall.txt";
52 zap[
'a'] =
make_field(detectorFile,
"detector file");
53 zap[
'r'] =
make_field(idu_ref,
"reference DU set to t=0") = 0;
54 zap[
'm'] =
make_field(min_cont,
"minimal content" ) = 5;
58 if (zap.
read(argc, argv) != 0) {
62 catch(
const exception &error) {
63 FATAL(error.what() << endl);
75 const int number_of_strings = getNumberOfStrings(
detector);
78 TMatrixD variance(1,1);
79 TMatrixD combimatrix(1,number_of_strings);
81 int du1,du2,du1_name,du2_name,nei;
82 int duarr[number_of_strings];
83 double off1,off2,offset,max1,max2;
86 combimatrix(0,idu_ref)=1;
90 std::ifstream file(inputFile);
93 while (file >> du1 >> du2 >> off1 >> off2 >> offset >> max1 >> max2 >> du1_name >> du2_name >> nei)
95 if (max1 > min_cont and max2 > min_cont and max1 < 50. and max2 < 50.){
97 combimatrix.ResizeTo(npairs+1,number_of_strings);
98 combimatrix(npairs,du1) = +1;
99 combimatrix(npairs,du2) = -1;
101 means.ResizeTo(npairs+1);
102 means[npairs]=offset;
119 TMatrixD combimatrix_T(number_of_strings,npairs);
121 combimatrix_T.Transpose(combimatrix);
123 TMatrixD pseudo = combimatrix_T * combimatrix;
125 TMatrixD pseudoinverse = pseudo.Invert();
127 TVectorD offsets = pseudoinverse * combimatrix_T * means;
129 TVectorD residues = (combimatrix * offsets) - means;
131 std::cout.precision(3);
133 for (
int ii=0;ii<number_of_strings;ii++){
134 cout << duarr[ii] <<
" " << offsets[ii] << endl;
138 for (
int ii=0;ii<npairs;ii++){
139 sumres+=fabs(residues[ii]);
141 cout << -1 <<
" " << sumres/double(npairs) << endl;