56{
60
62 typedef JParallelFileScanner_t::multi_pointer_type multi_pointer_type;
64
65 JParallelFileScanner_t inputFile;
68 string detectorFile;
69 JCalibration_t calibrationFile;
70 double Tmax_s;
71 string pdfFile;
75
76 try {
77
79
80 JParser<> zap(
"Program to perform compass calibration using reconstructed muon trajectories.");
81
87 zap[
'T'] =
make_field(Tmax_s,
"dynamical update time [s]") = 100.0;
92
93 zap(argc, argv);
94 }
95 catch(const exception& error) {
96 FATAL(error.what() << endl);
97 }
98
99
102 }
103
105
106 try {
108 }
111 }
112
113 unique_ptr<JDynamics> dynamics;
114
115 if (!calibrationFile.empty()) {
116
117 try {
118
120
121 dynamics->load(calibrationFile);
122 }
123 catch(const exception& error) {
125 }
126 }
127
129
131
133
135
138
140
142 const int ny = 101;
143
144 TH2D h2(
h2_t, NULL, nx, -0.5, nx - 0.5, ny, -PI, +PI);
145
146 while (inputFile.hasNext()) {
147
148 STATUS(
"event: " << setw(10) << inputFile.getCounter() <<
'\r');
DEBUG(endl);
149
150 multi_pointer_type ps = inputFile.next();
151
154
155 summary.update(*tev);
156
157 if (dynamics) {
158 dynamics->update(*tev);
159 }
160
162
163 JDataL0_t dataL0;
164
165 buildL0(*tev, router, true, back_inserter(dataL0));
166
167 for (JFIT::JEvt::const_iterator track = in->begin(); track != in->end(); ++track) {
168
172
175 }
176
178
179
180
182
183 for (JDataL0_t::const_iterator i = dataL0.begin(); i != dataL0.end(); ++i) {
184
186
188
189 const int type = wip.
getType();
190 const double QE = wip.
QE;
191 const double R_Hz = summary.getRate(i->getPMTIdentifier(), parameters.
R_Hz);
192
193 JHitW0 hit(*i, type, QE, R_Hz);
194
195 hit.rotate(R);
196
197 if (match(hit)) {
198 data[hit.getModuleID()].push_back(hit);
199 }
200 }
201
203
204 for (auto& i : data) {
205
206 const JModule& module = router.getModule(i.first);
207
208
209
211
212 JDataW0_t::iterator __end = unique(i.second.begin(), i.second.end(), equal_to<JDAQPMTIdentifier>());
213
214 for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
215
216 const double x = router.getIndex(i.first);
217 const double y = h2.GetYaxis()->GetBinCenter(iy);
218
220
221 double chi2 = 0.0;
222
223 for (JDataW0_t::const_iterator p = i.second.begin(); p != __end; ++p) {
224
226
227 hit.rotate_back(R);
228
230 hit.rotate(Rz);
232
233 hit.rotate(R);
234
235 chi2 += fit(ta, hit);
236 }
237
238 h2.Fill(x, y, chi2);
239 }
240 }
241 }
242 }
244
246
248
249 out << h2;
250
251 out.Write();
252 out.Close();
253}
#define DEBUG(A)
Message macros.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Router for direct addressing of module data in detector data structure.
Data structure for a composite optical module.
Auxiliary class for map of PMT parameters.
const JPMTParameters & getPMTParameters(const JPMTIdentifier &id) const
Get PMT parameters.
Data structure for PMT parameters.
double QE
relative quantum efficiency
int getType() const
Get type for for time-slewing correction.
Data structure for set of track fit results.
void select(const JSelector_t &selector)
Select fits.
Data structure for fit of straight line paralel to z-axis.
Data structure for fit of straight line in positive z-direction.
JPosition3D & rotate(const JRotation3D &R)
Rotate.
const JPosition3D & getPosition() const
Get position.
Utility class to parse command line options.
Auxiliary class for a hit with background rate value.
General purpose class for object reading from a list of file names.
General purpose class for parallel reading of objects from a single file or multiple files.
File router for fast addressing of summary data.
static const int JSTART_LENGTH_METRES
distance between projected positions on the track of optical modules for which the response does not ...
JDirection3D getDirection(const Vec &dir)
Get direction.
JPosition3D getPosition(const Vec &pos)
Get position.
JTOOLS::JRange< double > JTimeRange
Type definition for time range (unit [s]).
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
JTOOLS::JRange< double > JZRange
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
bool qualitySorter(const JFit &first, const JFit &second)
Comparison of fit results.
const char *const h2_t
Name of histogram with results from JMuonCompass.cc.
bool putObject(TDirectory &dir, const TObject &object)
Write object to ROOT directory.
static const JModuleCounter getNumberOfModules
Function object to count unique modules.
KM3NeT DAQ data structures and auxiliaries.
Dynamic detector calibration.
Auxiliary class to match data points with given model.
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Data structure for fit parameters.
double TTS_ns
transition-time spread [ns]
double TMin_ns
minimal time w.r.t. Cherenkov hypothesis [ns]
double roadWidth_m
road width [m]
double TMax_ns
maximal time w.r.t. Cherenkov hypothesis [ns]
double ZMax_m
maximal z-positon [m]
double ZMin_m
minimal z-positon [m]
double R_Hz
default rate [Hz]
size_t numberOfPrefits
number of prefits
Wrapper class to make final fit of muon trajectory.
Auxiliary class for defining the range of iterations of objects.
const JLimit & getLimit() const
Get limit.
static counter_type max()
Get maximum counter value.
Auxiliary data structure for sorting of hits.