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