123 using namespace KM3NETDAQ;
126 typedef JParallelFileScanner_t::multi_pointer_type multi_pointer_type;
129 JParallelFileScanner_t inputFile;
140 JParser<> zap(
"Program to perform fit of muon energy to data.");
145 zap[
'n'] =
make_field(numberOfEvents) = JLimit::max();
153 catch(
const exception& error) {
154 FATAL(error.what() << endl);
183 JRegressor_t fit(pdfFile);
187 if (!fit.estimator.is_valid()) {
188 FATAL(
"Invalid M-Estimator." << endl);
200 while (inputFile.hasNext()) {
202 STATUS(
"event: " << setw(10) << inputFile.getCounter() <<
'\r');
DEBUG(endl);
204 multi_pointer_type ps = inputFile.next();
209 summary.update(*tev);
229 buildL0(*tev, router,
true, back_inserter(dataL0));
232 for (JEvt::const_iterator track = cp.begin(); track != cp.end(); ++track) {
241 for (JDataL0_t::const_iterator i = dataL0.begin(); i != dataL0.end(); ++i) {
248 top.insert(i->getPMTIdentifier());
269 for (JDetector::const_iterator module = subdetector.begin(); module != subdetector.end(); ++module) {
271 if (summary.hasSummaryFrame(module->getID())) {
275 for (
size_t i = 0; i != module->size(); ++i) {
281 const double rate_Hz = frame.
getRate(i);
284 data.push_back(
JNPEHit(fit.getNPE(module->getPMT(i), rate_Hz), count));
290 const int NDF =
distance(data.begin(), data.end()) - 1;
301 for (
int i = 0; i !=
N; ++i) {
302 result[i].x = EMin_log + i * (EMax_log - EMin_log) / (N-1);
309 for (
int i = 0; i !=
N; ++i) {
312 result[i].chi2 = fit(result[i].x, data.begin(), data.end());
315 if (result[i].chi2 < result[j].chi2) {
320 for (
int i = 0; i !=
N; ++i) {
321 DEBUG(
' ' <<
FIXED(5,2) << result[i].x <<
' ' <<
FIXED(9,3) << result[i].chi2);
332 result[4] = result[2];
333 result[2] = result[1];
337 result[0] = result[1];
338 result[4] = result[3];
343 result[0] = result[2];
344 result[2] = result[3];
348 result[1] = JResult(0.5 * (result[0].x + result[2].x));
349 result[3] = JResult(0.5 * (result[2].x + result[4].x));
351 }
while (result[4].x - result[0].x >
parameters.resolution);
354 if (result[1].chi2 != result[3].chi2) {
356 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);
357 result[2].chi2 = fit(result[2].x, data.begin(), data.end());
360 const double chi2 = result[2].chi2;
361 const double E = result[2].x.getE();
365 const double mu_range =
gWater(E);
367 double noise_likelihood = 0.0;
368 int number_of_hits = 0;
371 noise_likelihood += log10(i->getP());
372 number_of_hits += i->getN();
380 out.rbegin()->setE(correct(E));
384 out.rbegin()->setW(track->getW());
398 copy(in->begin(), in->end(), back_inserter(out));
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.
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
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 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.
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 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
virtual double getA() const override
Get energy loss constant.
#define DEBUG(A)
Message macros.