87 const double chi2 = std::numeric_limits<double>::max())
101 return chi2 != std::numeric_limits<double>::max();
122 int main(
int argc,
char **argv)
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) {
313 const double rate_Hz = summary.getRate(
id);
314 const size_t count = top.count(
id);
316 data.push_back(
JNPEHit(fit.getNPE(module->getPMT(i), rate_Hz), count));
322 const int NDF =
distance(data.begin(), data.end()) - 1;
333 for (
int i = 0; i !=
N; ++i) {
334 result[i].x = EMin_log + i * (EMax_log - EMin_log) / (N-1);
343 for (
int i = 0; i !=
N; ++i) {
348 const double chi2 = fit(x, data.begin(), data.end());
350 result[i].chi2 = chi2;
351 buffer[chi2] = x.
getE();
354 if (result[i].chi2 < result[j].chi2) {
359 for (
int i = 0; i !=
N; ++i) {
360 DEBUG(
' ' <<
FIXED(5,2) << result[i].x <<
' ' <<
FIXED(9,3) << result[i].chi2);
370 result[4] = result[1];
371 result[2] = result[0];
372 result[0] = JResult(2*result[2].x - result[4].x);
376 result[4] = result[2];
377 result[2] = result[1];
381 result[0] = result[1];
382 result[4] = result[3];
386 result[0] = result[2];
387 result[2] = result[3];
391 result[0] = result[3];
392 result[2] = result[4];
393 result[4] = JResult(2*result[2].x - result[0].x);
397 result[1] = JResult(0.5 * (result[0].x + result[2].x));
398 result[3] = JResult(0.5 * (result[2].x + result[4].x));
400 }
while (result[4].x - result[0].x >
parameters.resolution);
403 if (result[1].chi2 != result[3].chi2) {
405 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);
406 result[2].chi2 = fit(result[2].x, data.begin(), data.end());
409 const double chi2 = result[2].chi2;
410 const double E = result[2].x.getE();
414 double Emin = numeric_limits<double>::max();
415 double Emax = numeric_limits<double>::lowest();
418 if (i->second < Emin) { Emin = i->second; }
419 if (i->second > Emax) { Emax = i->second; }
422 const double mu_range =
gWater(E);
424 double noise_likelihood = 0.0;
425 int number_of_hits = 0;
428 noise_likelihood += log10(
getP(i->getY0(), i->getN()));
429 number_of_hits += i->getN();
437 out.rbegin()->setE(correct(E));
441 out.rbegin()->setW(track->getW());
457 for (JFIT::JEvt::iterator i = out.begin(); i != out.end(); ++i) {
467 copy(in->begin(), in->end(), back_inserter(out));
double getE() const
Get energy.
Utility class to parse command line options.
int main(int argc, char *argv[])
ROOT TTree parameter settings of various packages.
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
Recording of objects on file according a format that follows from the file name extension.
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.
Basic data structure for time and time over threshold information of hit.
JFit & add(const int type)
Add event to history.
static const int JENERGY_CHI2
chi2 from JEnergy.cc
Data structure for detector geometry and calibration.
Various implementations of functional maps.
static const int JENERGY_NOISE_LIKELIHOOD
log likelihood of every hit being K40 from JEnergy.cc
Basic data structure for L0 hit.
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
Scanning of objects from a single file according a format that follows from the extension of each fil...
Auxiliary class to extract a subset of optical modules from a detector.
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.
Parallel scanning of objects from a single file or multiple files according a format that follows fro...
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.
Dynamic detector calibration.
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.
General purpose messaging.
Data structure for coverage of dynamic calibrations.
Detector subset without binary search functionality.
Data structure for fit parameters.
double getP(const double expval, bool hit)
Get Poisson probability to observe a hit or not for given expectation value for the number of hits...
Direct access to module in detector data structure.
static const int JPP_COVERAGE_ORIENTATION
coverage of dynamic orientation calibration from any Jpp application
Reduced data structure for L1 hit.
Dynamic detector calibration.
then echo Variable JPP_DIR undefined exit fi source $JPP_DIR setenv sh $JPP_DIR set_variable NORTH set_variable EAST set_variable SOUTH set_variable WEST set_variable WORKDIR tmp set_variable R set_variable CT set_variable YMAX set_variable YMIN if do_usage *then usage $script[distance] fi case set_variable R
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.
Auxiliary class to define a range between two values.
General purpose class for object reading from a list of file names.
Utility class to parse command line options.
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
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.
Data regression method for JFIT::JEnergy.
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
Maximum likelihood estimator (M-estimators).
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
static const int JPP_COVERAGE_POSITION
coverage of dynamic position calibration from any Jpp application