126 using namespace KM3NETDAQ;
130 typedef JParallelFileScanner_t::multi_pointer_type multi_pointer_type;
135 JParallelFileScanner_t inputFile;
139 JCalibration_t calibrationFile;
148 JParser<> zap(
"Program to perform fit of muon energy to data.");
155 zap[
'n'] =
make_field(numberOfEvents) = JLimit::max();
163 catch(
const exception& error) {
164 FATAL(error.what() << endl);
182 unique_ptr<JDynamics> dynamics;
188 dynamics->load(calibrationFile);
190 catch(
const exception& error) {
191 if (!calibrationFile.empty()) {
209 JRegressor_t fit(pdfFile);
213 if (!fit.estimator.is_valid()) {
214 FATAL(
"Invalid M-Estimator." << endl);
226 while (inputFile.hasNext()) {
228 STATUS(
"event: " << setw(10) << inputFile.getCounter() <<
'\r');
DEBUG(endl);
230 multi_pointer_type ps = inputFile.next();
235 summary.update(*tev);
238 dynamics->update(*tev);
259 buildL0(*tev, router,
true, back_inserter(dataL0));
262 for (JFIT::JEvt::const_iterator track = cp.begin(); track != cp.end(); ++track) {
271 for (JDataL0_t::const_iterator i = dataL0.begin(); i != dataL0.end(); ++i) {
278 top.insert(i->getPMTIdentifier());
299 for (JDetector::const_iterator module = subdetector.begin(); module != subdetector.end(); ++module) {
301 if (summary.hasSummaryFrame(module->getID())) {
305 for (
size_t i = 0; i != module->size(); ++i) {
311 const double rate_Hz = frame.
getRate(i);
314 data.push_back(
JNPEHit(fit.getNPE(module->getPMT(i), rate_Hz), count));
320 const int NDF =
distance(data.begin(), data.end()) - 1;
331 for (
int i = 0; i !=
N; ++i) {
332 result[i].x = EMin_log + i * (EMax_log - EMin_log) / (N-1);
341 for (
int i = 0; i !=
N; ++i) {
346 const double chi2 = fit(x, data.begin(), data.end());
348 result[i].chi2 = chi2;
349 buffer[chi2] = x.
getE();
352 if (result[i].chi2 < result[j].chi2) {
357 for (
int i = 0; i !=
N; ++i) {
358 DEBUG(
' ' <<
FIXED(5,2) << result[i].x <<
' ' <<
FIXED(9,3) << result[i].chi2);
368 result[4] = result[1];
369 result[2] = result[0];
370 result[0] = JResult(2*result[2].x - result[4].x);
374 result[4] = result[2];
375 result[2] = result[1];
379 result[0] = result[1];
380 result[4] = result[3];
384 result[0] = result[2];
385 result[2] = result[3];
389 result[0] = result[3];
390 result[2] = result[4];
391 result[4] = JResult(2*result[2].x - result[0].x);
395 result[1] = JResult(0.5 * (result[0].x + result[2].x));
396 result[3] = JResult(0.5 * (result[2].x + result[4].x));
398 }
while (result[4].x - result[0].x >
parameters.resolution);
401 if (result[1].chi2 != result[3].chi2) {
403 result[2].x += 0.25 * (result[3].x - result[1].x) * (result[1].chi2 - result[3].chi2) / (result[1].chi2 + result[3].chi2 - 2*result[2].chi2);
404 result[2].chi2 = fit(result[2].x, data.begin(), data.end());
407 const double chi2 = result[2].chi2;
408 const double E = result[2].x.getE();
412 double Emin = numeric_limits<double>::max();
413 double Emax = numeric_limits<double>::lowest();
416 if (i->second < Emin) { Emin = i->second; }
417 if (i->second > Emax) { Emax = i->second; }
420 const double mu_range =
gWater(E);
422 double noise_likelihood = 0.0;
423 int number_of_hits = 0;
426 noise_likelihood += log10(i->getP());
427 number_of_hits += i->getN();
435 out.rbegin()->setE(correct(E));
439 out.rbegin()->setW(track->getW());
455 for (JFIT::JEvt::iterator i = out.begin(); i != out.end(); ++i) {
465 copy(in->begin(), in->end(), back_inserter(out));
double getE() const
Get energy.
Utility class to parse command line options.
double getRate(const int tdc, const double factor=1.0) const
Get count rate.
double position
coverage of detector by available position calibration [0,1]
static JDetectorMechanics getMechanics
Function object to get string mechanics.
static const int JENERGY_ENERGY
uncorrected energy [GeV] from JEnergy.cc
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
Regressor function object for JEnergy fit.
Template specialisation of L0 builder for JHitL0 data type.
static const int JENERGY_MAXIMAL_ENERGY
maximal energy [GeV] from JEnergy.cc
Router for direct addressing of module data in detector data structure.
*fatal Wrong number of arguments esac JCookie sh typeset Z DETECTOR typeset Z SOURCE_RUN typeset Z TARGET_RUN set_variable PARAMETERS_FILE $WORKDIR parameters
General purpose class for parallel reading of objects from a single file or multiple files...
Template specialisation of class JModel to match hit with muon trajectory along z-axis.
Auxiliary class to test history.
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
static const JGeaneWater gWater
Function object for energy loss of muon in sea water.
Auxiliary data structure for floating point format specification.
JFit & add(const int type)
Add event to history.
static const int JENERGY_CHI2
chi2 from JEnergy.cc
static const int JENERGY_NOISE_LIKELIHOOD
log likelihood of every hit being K40 from JEnergy.cc
Data structure for track fit results.
double orientation
coverage of detector by available orientation calibration [0,1]
static const int JENERGY_NDF
number of degrees of freedom from JEnergy.cc
static const int JENERGY_MINIMAL_ENERGY
minimal energy [GeV] from JEnergy.cc
Auxiliary class for defining the range of iterations of objects.
JDirection3D getDirection(const Vec &dir)
Get direction.
Auxiliary class for correction of energy determined by JEnergy.cc.
Auxiliary class for recursive type list generation.
static const int JENERGY_NUMBER_OF_HITS
number of hits from JEnergy.cc
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Data storage class for rate measurements of all PMTs in one module.
Auxiliary class to test history.
JAxis3D getAxis(const Trk &track)
Get axis.
static const int PMT_DISABLE
KM3NeT Data Definitions v2.0.0-15-g59d2e2b https://git.km3net.de/common/km3net-dataformat.
JPosition3D getPosition(const Vec &pos)
Get position.
File router for fast addressing of summary data.
Auxiliary class for simultaneously handling light yields and response of PMT.
void load(const std::string &file_name)
Load mechanical model parameters from file.
then usage $script[distance] fi case set_variable R
Data structure for coverage of dynamic calibrations.
Detector subset without binary search functionality.
Data structure for fit parameters.
static const int JPP_COVERAGE_ORIENTATION
coverage of dynamic orientation calibration from any Jpp application
Dynamic detector calibration.
bool getPMTStatus(const JStatus &status)
Test status of PMT.
static const int JSTART_LENGTH_METRES
distance between first and last hits in metres from JStart.cc
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
Data structure for set of track fit results.
General purpose class for object reading from a list of file names.
Data structure for fit of straight line paralel to z-axis.
void copy(const Head &from, JHead &to)
Copy header from from to to.
Reduced data structure for L1 hit.
Data structure for fit of energy.
Object reading from a list of files.
const JLimit & getLimit() const
Get limit.
JMEstimator * getMEstimator(const int type)
Get M-Estimator.
do set_variable DETECTOR_TXT $WORKDIR detector
bool getDAQStatus(const JDAQFrameStatus &frame, const JStatus &status)
Test status of DAQ.
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
JPosition3D & rotate(const JRotation3D &R)
Rotate.
void select(const JSelector_t &selector)
Select fits.
then usage $script[input file[working directory[option]]] nWhere option can be N
static const int JENERGY_MUON_RANGE_METRES
range of a muon with the reconstructed energy [m] from JEnergy.cc
bool qualitySorter(const JRECONSTRUCTION::JFit &first, const JRECONSTRUCTION::JFit &second)
Comparison of fit results.
static const int JMUONENERGY
then usage $script[input file[working directory[option]]] nWhere option can be E
#define DEBUG(A)
Message macros.
static const int JPP_COVERAGE_POSITION
coverage of dynamic position calibration from any Jpp application