57 int main(
int argc,
char **argv)
61 using namespace KM3NETDAQ;
63 typedef JParallelFileScanner< JTypeList<JDAQEvent, JEvt> > JParallelFileScanner_t;
64 typedef JParallelFileScanner_t::multi_pointer_type multi_pointer_type;
67 JParallelFileScanner_t inputFile;
74 size_t numberOfPrefits;
82 JParser<> zap(
"Program to perform intermediate fit of muon trajectory to data.");
87 zap[
'n'] =
make_field(numberOfEvents) = JLimit::max();
99 catch(
const exception& error) {
100 FATAL(error.what() << endl);
108 const double TMAX_NS = 50.0;
113 load(detectorFile, detector);
115 catch(
const JException& error) {
119 const JModuleRouter moduleRouter(detector);
126 JSuperFrame2D<JHit> buffer;
127 const JBuildL0<JHitL0> buildL0;
128 const JBuildL2<JHitL1> buildL2(2, Tmax_ns, ctMin);
131 typedef JRegressor<JLine3Z, JSimplex> JRegressor_t;
133 JRegressor_t fit(sigma_ns);
135 fit.estimator.reset(
new JMEstimatorLorentzian());
138 JRegressor_t::MAXIMUM_ITERATIONS = 10000;
145 while (inputFile.hasNext()) {
147 STATUS(
"event: " << setw(10) << inputFile.getCounter() <<
'\r');
DEBUG(endl);
149 multi_pointer_type ps = inputFile.next();
155 JEvt::iterator __end = evt->
end();
158 __end = partition(evt->begin(), __end, JHistory::is_not_event(
JMUONSIMPLEX));
161 if (evt->begin() != __end) {
163 copy(evt->begin(), __end, back_inserter(out));
165 if (numberOfPrefits > 0) {
166 advance(__end = evt->begin(), min(numberOfPrefits, out.size()));
169 partial_sort(evt->begin(), __end, evt->end(),
qualitySorter);
171 __end = partition(evt->begin(), __end, JHistory::is_event(evt->begin()->getHistory()));
179 for (JDAQTimeslice::const_iterator i = timeslice.begin(); i != timeslice.end(); ++i) {
181 if (moduleRouter.hasModule(i->getModuleID())) {
183 buffer(*i, moduleRouter.getModule(i->getModuleID()));
185 buildL0(buffer, back_inserter(dataL0));
186 buildL2(buffer, back_inserter(dataL1));
193 for (JEvt::const_iterator track = evt->begin(); track != __end; ++track) {
197 const JModel<JLine1Z> match(tz, roadWidth_m,
JTimeRange(-TMAX_NS, +TMAX_NS));
201 for (JDataL1_t::const_iterator i = dataL1.begin(); i != dataL1.end(); ++i) {
214 data.reserve(data.size() + dataL0.size());
216 JDataR1_t::iterator __end1 = data.end();
218 for (JDataL0_t::iterator i = dataL0.begin(); i != dataL0.end(); ++i) {
220 if (find_if(data.begin(), __end1, bind2nd(equal_to<JDAQModuleIdentifier>(), i->getModuleID())) == __end1) {
236 fit.step[0] = JLine3Z(JLine1Z(JVector3D(0.5, 0.0, 0.0), 0.0));
237 fit.step[1] = JLine3Z(JLine1Z(JVector3D(0.0, 0.5, 0.0), 0.0));
238 fit.step[2] = JLine3Z(JLine1Z(JVector3D(0.0, 0.0, 0.0), 1.0));
239 fit.step[3] = JLine3Z(JLine1Z(JVector3D(), 0.0), JVersor3Z(0.005, 0.0));
240 fit.step[4] = JLine3Z(JLine1Z(JVector3D(), 0.0), JVersor3Z(0.0, 0.005));
242 const int NDF =
getCount(data.begin(), data.end()) - fit.step.size();
246 const double chi2 = fit(JLine3Z(tz), data.begin(), data.end());
248 JTrack3D tb(fit.value);
265 JSingleFileScanner<JRemove<typelist, JEvt>::typelist> io(inputFile);
Data regression method for JFIT::JLine3Z.
Utility class to parse command line options.
double getCount(TH1D *hptr, int muon_threshold)
Recording of objects on file according a format that follows from the file name extension.
Data structure for detector geometry and calibration.
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.
Basic data structure for L0 hit.
JLimit JLimit_t
Type definition of limit.
Basic data structure for time and time over threshold information of hit.
const_iterator< T > end() const
Get end of data.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Parallel scanning of objects from a single file or multiple files according a format that follows fro...
void load(const JString &file_name, JDetector &detector)
Load detector from input file.
General purpose messaging.
counter_type advance(counter_type &counter, const counter_type value, const counter_type limit=std::numeric_limits< counter_type >::max())
Advance counter.
Scanning of objects from multiple files according a format that follows from the extension of each fi...
Direct access to module in detector data structure.
Reduced data structure for L1 hit.
double getQuality(const double chi2, const int NDF)
Get quality of fit.
Utility class to parse command line options.
ROOT TTree parameter settings.
bool qualitySorter(const JFIT::JFit &first, const JFIT::JFit &second)
Comparison of fit results.
void copy(const Head &from, JHead &to)
Copy header from from to to.
JDirection3D getDirection(const Vec &v)
Get direction.
const JLimit & getLimit() const
Get limit.
JPosition3D & rotate(const JRotation3D &R)
Rotate.
Basic data structure for L1 hit.
#define DEBUG(A)
Message macros.
JPosition3D getPosition(const Vec &v)
Get position.
int main(int argc, char *argv[])