33{
36 using namespace JMATH;
37
38 string inputFile;
39 string detectorFile;
40 string option;
41 double min_cont;
42 int idu_ref;
44
45
46 try {
47
48 JParser<> zap(
"Program to calculate time offsets from FitL1dtSlices output");
49
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;
55
56
57 if (zap.read(argc, argv) != 0) {
58 return 1;
59 }
60 }
61 catch(const exception &error) {
62 FATAL(error.what() << endl);
63 }
64
66
67 try {
69 }
72 }
73
74 const int number_of_strings = getNumberOfStrings(
detector);
75
76 TVectorD means(1);
77 TMatrixD variance(1,1);
78 TMatrixD combimatrix(1,number_of_strings);
79
80 int du1,du2,du1_name,du2_name,nei;
81 int duarr[number_of_strings];
82 double off1,off2,offset,max1,max2;
83
84 means[0]=0.;
85 combimatrix(0,idu_ref)=1;
86
87 int npairs = 1;
88
89 std::ifstream file(inputFile);
90
91
92 while (file >> du1 >> du2 >> off1 >> off2 >> offset >> max1 >> max2 >> du1_name >> du2_name >> nei)
93 {
94 if (max1 > min_cont and max2 > min_cont and max1 < 50. and max2 < 50.){
95
96 combimatrix.ResizeTo(npairs+1,number_of_strings);
97 combimatrix(npairs,du1) = +1;
98 combimatrix(npairs,du2) = -1;
99
100 means.ResizeTo(npairs+1);
101 means[npairs]=offset;
102
103 duarr[du1]=du1_name;
104 duarr[du2]=du2_name;
105 npairs+=1;
106 }
107 }
108
109
110
111
112
113
114
115
116
117
118 TMatrixD combimatrix_T(number_of_strings,npairs);
119
120 combimatrix_T.Transpose(combimatrix);
121
122 TMatrixD pseudo = combimatrix_T * combimatrix;
123
124 TMatrixD pseudoinverse = pseudo.Invert();
125
126 TVectorD offsets = pseudoinverse * combimatrix_T * means;
127
128 TVectorD residues = (combimatrix * offsets) - means;
129
130 std::cout.precision(3);
131
132 for (int ii=0;ii<number_of_strings;ii++){
133 cout << duarr[ii] << " " << offsets[ii] << endl;
134 }
135
136 double sumres=0.;
137 for (int ii=0;ii<npairs;ii++){
138 sumres+=fabs(residues[ii]);
139 }
140 cout << -1 << " " << sumres/double(npairs) << endl;
141
142 return 1;
143
144
145}
#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.
Auxiliary classes and methods for mathematical operations.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).