63 using namespace KM3NETDAQ;
65 typedef JParallelFileScanner< JTypeList<JDAQEvent, JEvt> > JParallelFileScanner_t;
66 typedef JParallelFileScanner_t::multi_pointer_type multi_pointer_type;
69 JParallelFileScanner_t inputFile;
76 size_t numberOfPrefits;
83 JParser<> zap(
"Program to perform fit of muon path to data.");
88 zap[
'n'] =
make_field(numberOfEvents) = JLimit::max();
90 zap[
'R'] =
make_field(roadWidth_m) = numeric_limits<double>::max();
99 catch(
const exception& error) {
100 FATAL(error.what() << endl);
111 load(detectorFile, detector);
113 catch(
const JException& error) {
117 const JModuleRouter moduleRouter(detector);
121 const JBuildL0<JHitL0> buildL0;
124 typedef JRegressor<JLine3Z, JGandalf> JRegressor_t;
127 JRegressor_t::T_ns.setRange(-50.0, +50.0);
128 JRegressor_t::Vmax_npe = 10.0;
129 JRegressor_t::MAXIMUM_ITERATIONS = 10000;
131 JRegressor_t fit(pdfFile, TTS_ns);
133 fit.estimator.reset(
new JMEstimatorLorentzian());
135 fit.parameters.resize(4);
137 fit.parameters[0] = JLine3Z::pX();
138 fit.parameters[1] = JLine3Z::pY();
139 fit.parameters[2] = JLine3Z::pDX();
140 fit.parameters[3] = JLine3Z::pDY();
142 if (fit.getRmax() < roadWidth_m) {
144 roadWidth_m = fit.getRmax();
146 WARNING(
"Set road width to [m] " << roadWidth_m << endl);
149 const double Rmax_m = 100.0;
150 const double Tmax_ns = 10.0;
157 while (inputFile.hasNext()) {
159 STATUS(
"event: " << setw(10) << inputFile.getCounter() <<
'\r');
DEBUG(endl);
161 multi_pointer_type ps = inputFile.next();
169 JEvt::iterator __end = evt->
end();
171 if (numberOfPrefits > 0) {
172 advance(__end = evt->begin(), min(numberOfPrefits, evt->size()));
175 partial_sort(evt->begin(), __end, evt->end(),
qualitySorter);
180 buildL0(*tev, moduleRouter,
true, back_inserter(dataL0));
183 if (dataL0.size() >= fit.parameters.size()) {
185 for (JEvt::const_iterator track = evt->begin(); track != __end; ++track) {
189 const JModel<JLine1Z> match(tz, roadWidth_m, JRegressor_t::T_ns);
197 for (JDataL0_t::const_iterator i = dataL0.begin(); i != dataL0.end(); ++i) {
199 JHitW0 hit(*i, R_Hz);
205 top.insert(hit.getPMTIdentifier());
207 const double t1 = hit.getT() - tz.getT(hit);
209 if (tz.getDistance(hit) <= Rmax_m && t1 >= -Tmax_ns && t1 <= +Tmax_ns) {
210 Z.include(hit.getZ() - tz.getDistance(hit) /
getTanThetaC());
218 for (JDetector::const_iterator module = detector.begin(); module != detector.end(); ++module) {
220 JPosition3D pos(module->getPosition());
224 if (tz.getDistance(pos) <= roadWidth_m && Z(pos.getZ() - tz.getDistance(pos) /
getTanThetaC())) {
226 for (
unsigned int i = 0; i != module->size(); ++i) {
230 JPMT pmt(module->getPMT(i));
234 buffer.push_back(JPMTW0(pmt, R_Hz, top.count(
id)));
240 const int NDF = buffer.size() - fit.parameters.size();
246 if (track->getE() > 0.1)
247 fit.E_GeV = track->getE();
251 const double chi2 = fit(JLine3Z(tz), buffer.begin(), buffer.end());
253 JTrack3D tb(fit.value);
271 JSingleFileScanner<JRemove<typelist, JEvt>::typelist> io(inputFile);
Utility class to parse command line options.
JFit getFit(const JHistory &history, const JTrack3D &track, const double Q, const int NDF, const double energy=0.0, const int status=0)
Get fit.
JLimit JLimit_t
Type definition of limit.
const_iterator< T > end() const
Get end of data.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
void load(const JString &file_name, JDetector &detector)
Load detector from input file.
counter_type advance(counter_type &counter, const counter_type value, const counter_type limit=std::numeric_limits< counter_type >::max())
Advance counter.
double getQuality(const double chi2, const int NDF)
Get quality of fit.
bool qualitySorter(const JFIT::JFit &first, const JFIT::JFit &second)
Comparison of fit results.
JDirection3D getDirection(const Vec &v)
Get direction.
const JLimit & getLimit() const
Get limit.
JPosition3D & rotate(const JRotation3D &R)
Rotate.
#define DEBUG(A)
Message macros.
JPosition3D getPosition(const Vec &v)
Get position.