84 const double chi2 = std::numeric_limits<double>::max())
98 return chi2 != std::numeric_limits<double>::max();
119 int main(
int argc,
char **argv)
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();
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) {
275 for (
size_t i = 0; i != module->size(); ++i) {
279 !module->getPMT(i).has(JPMT::PMT_DISABLE)) {
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) {
325 result[4] = result[1];
326 result[2] = JResult(0.5 * (result[0].x + result[4].x));
330 result[4] = result[2];
331 result[2] = result[1];
335 result[0] = result[1];
336 result[4] = result[3];
340 result[0] = result[2];
341 result[2] = result[3];
345 result[0] = result[3];
346 result[2] = JResult(0.5 * (result[0].x + result[4].x));
350 result[1] = JResult(0.5 * (result[0].x + result[2].x));
351 result[3] = JResult(0.5 * (result[2].x + result[4].x));
353 }
while (result[4].x - result[0].x >
parameters.resolution);
356 if (result[1].chi2 != result[3].chi2) {
358 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);
359 result[2].chi2 = fit(result[2].x, data.begin(), data.end());
362 const double chi2 = result[2].chi2;
363 const double E = result[2].x.getE();
367 const double mu_range =
gWater(E);
369 double noise_likelihood = 0.0;
370 int number_of_hits = 0;
373 noise_likelihood += log10(i->getP());
374 number_of_hits += i->getN();
382 out.rbegin()->setE(correct(E));
386 out.rbegin()->setW(track->getW());
400 copy(in->begin(), in->end(), back_inserter(out));
Utility class to parse command line options.
ROOT TTree parameter settings.
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.
void update(const JDAQHeader &header)
Update router.
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.
esac print_variable DETECTOR INPUT_FILE OUTPUT_FILE CDF for TYPE in
*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)...
const JDAQSummaryFrame & getSummaryFrame(const JDAQModuleIdentifier &module) const
Get summary frame.
static const JGeaneWater gWater
Function object for energy loss of muon in sea water.
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.
static const int JENERGY_NDF
number of degrees of freedom 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.
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.
Parallel scanning of objects from a single file or multiple files according a format that follows fro...
File router for fast addressing of summary data.
Auxiliary class for simultaneously handling light yields and response of PMT.
void load(const JString &file_name, JDetector &detector)
Load detector from input file.
then usage $script[distance] fi case set_variable R
General purpose messaging.
Detector subset without binary search functionality.
Data structure for fit parameters.
Direct access to module in detector data structure.
Reduced data structure for L1 hit.
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
Data structure for set of track fit results.
Auxiliary class to define a range between two values.
Utility class to parse command line options.
bool hasSummaryFrame(const JDAQModuleIdentifier &module) const
Has summary frame.
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.
JDirection3D getDirection(const Vec &v)
Get direction.
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.
bool getDAQStatus(const JDAQFrameStatus &frame, const JStatus &status)
Test status of DAQ.
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
#define DEBUG(A)
Message macros.
JPosition3D getPosition(const Vec &v)
Get position.
int main(int argc, char *argv[])
virtual double getA() const
Get energy loss constant.