37{
40
41 struct {
42 double XMIN = -0.2*PI;
43 double XMAX = +0.2*PI;
44 double FACTOR = 1.0;
46 } parameters;
47
52 string option;
54
55 try {
56
58
63
64 JParser<> zap(
"Program to fit histogram in output of JMuonCompass.cc.");
65
67 zap[
'f'] =
make_field(inputFile,
"input files (output from JMuonCompass).");
71 "\nUse option -AA to also correct compass calibrations.");
72 zap[
'O'] =
make_field(option,
"ROOT fit option, see TH1::Fit.") =
"";
74
76 }
77 catch(const exception &error) {
79 }
80
81
83
84
86
87 try {
89 }
92 }
93
95
96 if (option.find('S') == string::npos) { option += 'S'; }
98
100
102
104
105 TFile in(i->c_str(),
"exist");
106
107 if (!in.IsOpen()) {
108 FATAL(
"File " << *i <<
" not opened." <<
endl);
109 }
110
111 TH2D* p =
dynamic_cast<TH2D*
>(in.Get(h2_t));
112
114 FATAL(
"File " << *i <<
" has no histogram <" << h2_t <<
">." <<
endl);
115 }
116
118 h2 = (
TH2D*) p->Clone();
119 else
120 h2->Add(p);
121
122 h2->SetDirectory(0);
123
124 in.Close();
125 }
126
128 FATAL(
"No histogram <" << h2_t <<
">." <<
endl);
129 }
130
131
132
133 struct result_type {
134
135 result_type() :
136 value(0.0),
137 error(0.0)
138 {}
139
140 result_type(double value,
141 double error) :
142 value(value),
143 error(error)
144 {}
145
146 double value;
147 double error;
148 };
149
151
152 map_type zmap;
153
154
155
156
159
161
164
166 strings.size(), -0.5, strings.size() - 0.5,
167 floors.getUpperLimit(), 1 - 0.5,
floors.getUpperLimit() + 0.5);
168
171 }
174 }
175
178
179
181
183
184 const int index =
ix - 1;
185 const JModule&
module = detector[index];
186
187 if (
module.getFloor() == 0) {
188 continue;
189 }
190
192
194
195
196
200
202
203 h1.SetBinContent(
iy, h2->GetBinContent(
ix,
iy));
204 h1.SetBinError (
iy, h2->GetEntries() * 1.0e-7 * parameters.FACTOR);
205
208
211 }
212
215 }
216
217 if (
ymax -
ymin >= parameters.YMIN) {
218
219 Double_t xmin = x0 + parameters.XMIN;
220 Double_t xmax = x0 + parameters.XMAX;
221
223
225 if (xmax >
y_axis->GetXmax()) {
Rx = -PI; }
226
227
228
230
232
236
237 h1.Reset();
238
240
242
244
245 if (i < 1) { i += (
Int_t) (2.0*PI /
dx); }
247
248 h1.SetBinContent(i, h2->GetBinContent(
ix,
iy));
249 h1.SetBinError (i, h2->GetEntries() * 1.0e-7 * parameters.FACTOR);
250 }
251 }
252
254 if (xmax >
y_axis->GetXmax()) { xmax =
y_axis->GetXmax(); xmin = xmax - 0.8*PI; }
255
256 TF1* f1 = new TF1("f1", "[0] - [1]*cos(x - [2])");
257
258 f1->SetParameter(0, 0.5 * (
ymin +
ymax));
259 f1->SetParameter(1, 0.5 * (
ymax -
ymin));
260 f1->SetParameter(2, x0);
261
262 f1->SetParError(0, 0.01*(
ymin+
ymax));
263 f1->SetParError(1, 0.01*(
ymin+
ymax));
264 f1->SetParError(2, 0.05);
265
267
268 for (int i = 0; i != f1->GetNpar(); ++i) {
269 DEBUG(left <<
setw(12) << f1->GetParName (i) <<
' ' <<
271 }
272
273
274
276
277 const bool status =
result->IsValid();
278
279
280
282 f1->SetParameter(2, f1->GetParameter(2) -
Rx);
283 }
284
288 <<
setw(16) << h1.GetName() <<
' '
289 <<
FIXED(7,3) << f1->GetParameter(2) <<
" +/- "
290 <<
FIXED(7,3) << f1->GetParError(2) <<
" [rad] "
294 << (status ?
"" :
"failed") <<
endl;
295 }
296
297 if (status) {
298 zmap[index] = result_type(f1->GetParameter(2), f1->GetParError(2));
299 }
300
301 struct {
305 strings.getIndex(
module.getString()) + 1,
306 module .getFloor()
307 };
308
309 if (status) {
310 H2d .SetBinContent(
H2.ix,
H2.iy, f1->GetParameter(2));
311 }
314 }
315 {
316 H2q->SetBinContent(
H2.ix,
H2.iy, status ? +1.0 : -1.0);
317 }
318
319 h1.Write();
320
321 delete f1;
322 }
323 }
324
325 if (zmap.empty()) {
327 }
328
329 for (map_type::const_iterator i = zmap.begin(); i != zmap.end(); ++i) {
330 h0.SetBinContent(i->first, i->second.value);
331 h0.SetBinError (i->first, i->second.error);
332 }
333
335
337
339
340 for (map_type::const_iterator i = zmap.begin(); i != zmap.end(); ++i) {
341
342 JModule&
module = detector[i->first];
343 const JVector3D center =
module.getPosition();
344
345 module.sub(center);
346
347 module.rotate(JRotation3Z(i->second.value));
348
349 module.add(center);
350
352 module.setQuaternion(module.getQuaternion() * JQuaternion3Z(i->second.value));
353 }
354 }
355
357 }
358
359 h0 .Write();
360 h2 ->Write();
364
365 out.Close();
366}
#define DEBUG(A)
Message macros.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
#define MAKE_CSTRING(A)
Make C-string.
#define gmake_property(A)
macros to convert (template) parameter to JPropertiesElement object
Router for direct addressing of module data in detector data structure.
Data structure for a composite optical module.
Utility class to parse parameter values.
Data structure for vector in three dimensions.
Template definition of a multi-dimensional oscillation probability interpolation table.
Auxiliary class to handle multiple boolean-like I/O.
Utility class to parse command line options.
floor_range getRangeOfFloors(const JDetector &detector)
Get range of floors.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
void store(const std::string &file_name, const JDetector &detector)
Store detector to output file.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary data structure for floating point format specification.
Router for mapping of string identifier to index.
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Auxiliary data structure for floating point format specification.