124 using namespace KM3NETDAQ;
127 typedef JParallelFileScanner_t::multi_pointer_type multi_pointer_type;
130 JParallelFileScanner_t inputFile;
141 JParser<> zap(
"Program to perform fit of muon energy to data.");
146 zap[
'n'] =
make_field(numberOfEvents) = JLimit::max();
154 catch(
const exception& error) {
155 FATAL(error.what() << endl);
184 JRegressor_t fit(pdfFile);
188 if (!fit.estimator.is_valid()) {
189 FATAL(
"Invalid M-Estimator." << endl);
201 while (inputFile.hasNext()) {
203 STATUS(
"event: " << setw(10) << inputFile.getCounter() <<
'\r');
DEBUG(endl);
205 multi_pointer_type ps = inputFile.next();
210 summary.update(*tev);
230 buildL0(*tev, router,
true, back_inserter(dataL0));
233 for (JEvt::const_iterator track = cp.begin(); track != cp.end(); ++track) {
242 for (JDataL0_t::const_iterator i = dataL0.begin(); i != dataL0.end(); ++i) {
249 top.insert(i->getPMTIdentifier());
270 for (JDetector::const_iterator module = subdetector.begin(); module != subdetector.end(); ++module) {
272 if (summary.hasSummaryFrame(module->getID())) {
276 for (
size_t i = 0; i != module->size(); ++i) {
282 const double rate_Hz = frame.
getRate(i);
285 data.push_back(
JNPEHit(fit.getNPE(module->getPMT(i), rate_Hz), count));
291 const int NDF =
distance(data.begin(), data.end()) - 1;
302 for (
int i = 0; i !=
N; ++i) {
303 result[i].x = EMin_log + i * (EMax_log - EMin_log) / (N-1);
312 for (
int i = 0; i !=
N; ++i) {
317 const double chi2 = fit(x, data.begin(), data.end());
319 result[i].chi2 = chi2;
320 buffer[chi2] = x.
getE();
323 if (result[i].chi2 < result[j].chi2) {
328 for (
int i = 0; i !=
N; ++i) {
329 DEBUG(
' ' <<
FIXED(5,2) << result[i].x <<
' ' <<
FIXED(9,3) << result[i].chi2);
339 result[0] = JResult(2*result[0].x - result[2].x);
340 result[4] = result[2];
341 result[2] = result[0];
345 result[4] = result[2];
346 result[2] = result[1];
350 result[0] = result[1];
351 result[4] = result[3];
355 result[0] = result[2];
356 result[2] = result[3];
360 result[0] = result[2];
361 result[2] = result[4];
362 result[4] = JResult(2*result[4].x - result[2].x);
366 result[1] = JResult(0.5 * (result[0].x + result[2].x));
367 result[3] = JResult(0.5 * (result[2].x + result[4].x));
369 }
while (result[4].x - result[0].x >
parameters.resolution);
372 if (result[1].chi2 != result[3].chi2) {
374 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);
375 result[2].chi2 = fit(result[2].x, data.begin(), data.end());
378 const double chi2 = result[2].chi2;
379 const double E = result[2].x.getE();
383 double Emin = numeric_limits<double>::max();
384 double Emax = numeric_limits<double>::lowest();
387 if (i->second < Emin) { Emin = i->second; }
388 if (i->second > Emax) { Emax = i->second; }
391 const double mu_range =
gWater(E);
393 double noise_likelihood = 0.0;
394 int number_of_hits = 0;
397 noise_likelihood += log10(i->getP());
398 number_of_hits += i->getN();
406 out.rbegin()->setE(correct(E));
410 out.rbegin()->setW(track->getW());
426 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.
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
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.
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-14-gbeccebb 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.
then usage $script[distance] fi case set_variable R
Detector subset without binary search functionality.
Data structure for fit parameters.
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 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.
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.