1#ifndef JSHOWERDIRECTIONPREFIT_INCLUDE
2#define JSHOWERDIRECTIONPREFIT_INCLUDE
72 public JRegressor<JShower3EZ, JAbstractMinimiser>
79 using JRegressor_t::operator();
80 using JRegressor_t::getH1;
81 using JRegressor_t::getH0;
136 for (
auto i = data.begin(); i != data.end(); ++i) {
141 auto H1 = getH1(sh, pmt);
142 auto H0 = getH0(pmt.
getR());
144 const bool hit = pmt.
getN() != 0;
147 for (
size_t j = 0;
j <
Ev.size(); ++
j) {
171 const int max_extensions = 5;
172 int extension_count = 0;
178 auto p = std::min_element(chi2.begin(), chi2.end());
179 size_t idx = p - chi2.begin();
181 bool at_upper_edge = (idx ==
Ev.size() - 1);
183 bool monotonic_tail =
false;
184 if (
Ev.size() >= 3) {
185 size_t n =
Ev.size();
186 monotonic_tail = (chi2[
n-3] > chi2[
n-2]) &&
187 (chi2[
n-2] > chi2[
n-1]);
190 if (!(at_upper_edge && monotonic_tail)) {
191 return {
Ev[idx], *p};
194 if (extension_count >= max_extensions) {
195 return {
Ev[idx], *p};
201 double E_start =
Ev.back();
202 double E_end = 100.0 * E_start;
204 size_t N =
Ev.size();
206 for (
size_t k = 0; k < N; ++k) {
207 double t = double (k) / (N - 1);
208 Ev_ext.push_back(E_start * std::pow(E_end / E_start, t));
211 Ev = std::move(Ev_ext);
223 const storage_type& storage,
225 const int debug = 0):
232 JRegressor_t::debug =
debug;
233 JRegressor_t::T_ns.setRange(parameters.
TMin_ns, parameters.
TMax_ns);
242 for (
int i = 0; i !=
En; ++i) {
268 const JBuildL0 <JHitR0> buildL0;
275 for (JDAQTimeslice::const_iterator i = timeslice.begin(); i != timeslice.end(); ++i) {
277 if (router.
hasModule(i->getModuleID())) {
279 buffer(*i, router.
getModule(i->getModuleID()));
281 buildL0(buffer, back_inserter(data[i->getModuleID()]));
286 if (!module.empty()) {
317 for (JEvt::const_iterator shower = in.begin(); shower != in.end(); ++shower) {
322 const double time = shower->getT();
324 for (
const auto& module : input.
data) {
334 for (
size_t i = 0; i !=
module->size(); ++i) {
336 if (module.getStatus(i)) {
342 return (hit.
getPMT() == pmt && T_ns(hit.
getT()));
348 } match = { JRegressor_t::T_ns + t1, i };
354 const size_t ns = count_if(module.begin(), module.end(), match);
355 const double QE = wip.
QE;
357 JPMT pmt =
module->getPMT(i);
361 data.push_back(
JPMTW0(pmt, QE, module.frame.getRate(i), ns));
370 for (vector<JPMTW0>::const_iterator i = data.begin(); i != data.end(); ++i) {
371 if (i->getN() != 0) start_dir.
add(i->getPosition());
380 for (JOmega3D_t::const_iterator dir = scan_directions.begin(); dir != scan_directions.end(); ++dir) {
403 copy(input.
in.begin(), input.
in.end(), back_inserter(out));
Coverage of dynamical detector calibration.
Auxiliary class to extract a subset of optical modules from a detector.
Data structure for detector geometry and calibration.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Basic data structure for L0 hit.
Direct access to module in detector data structure.
Data regression method for JFIT::JShower3EZ.
Router for direct addressing of module data in detector data structure.
bool hasModule(const JObjectID &id) const
Has module.
const JModule & getModule(const JObjectID &id) const
Get module parameters.
Data structure for a composite optical module.
Auxiliary class for map of PMT parameters.
const JPMTParameters & getPMTParameters(const JPMTIdentifier &id) const
Get PMT parameters.
Data structure for PMT parameters.
double QE
relative quantum efficiency
Data structure for PMT geometry, calibration and status.
Data structure for fit of energy.
Data structure for set of track fit results.
void select(const JSelector_t &selector)
Select fits.
Data structure for fit of straight line in positive z-direction with energy.
JAxis3D & rotate(const JRotation3D &R)
Rotate axis.
Data structure for direction in three dimensions.
Direction set covering (part of) solid angle.
Data structure for position in three dimensions.
Data structure for vector in three dimensions.
JVector3D & add(const JVector3D &vector)
Add vector.
double getLength() const
Get length.
JVector3D & sub(const JVector3D &vector)
Subtract vector.
Data structure for normalised vector in positive z-direction.
const JClass_t & getReference() const
Get reference to object.
class to handle the direction fit of the shower reconstruction, mainly dedicated for ORCA
std::vector< double > computeChi2(const std::vector< double > &Ev, const std::vector< JFIT::JPMTW0 > &data, const JGEOMETRY3D::JRotation3D &R, const JShower3EZ &sh)
Compute chi2 for a set of energies.
const JPMTParametersMap & pmtParameters
std::pair< double, double > findBestEnergy(std::vector< double > Ev, const std::vector< JFIT::JPMTW0 > &data, const JGEOMETRY3D::JRotation3D &R, const JShower3EZ &sh)
Find best energy iteratively increasing the upper threshold if there is suspicion the best-fit is out...
std::vector< module_type > detector_type
input_type getInput(const JModuleRouter &router, const JSummaryRouter &summary, const JDAQEvent &event, const JEvt &in, const coverage_type &coverage) const
Get input data.
JShowerDirectionPrefit(const JShowerDirectionPrefitParameters_t ¶meters, const storage_type &storage, const JPMTParametersMap &pmtParameters, const int debug=0)
Parameterized constructor.
JEvt operator()(const input_type &input)
Fit function.
JRegressor< JShower3EZ, JAbstractMinimiser > JRegressor_t
Router for fast addressing of summary data in KM3NETDAQ::JDAQSummaryslice data structure as a functio...
const JDAQSummaryFrame & getSummaryFrame(const JDAQModuleIdentifier &module) const
Get summary frame.
Reduced data structure for L0 hit.
JPMT_t getPMT() const
Get PMT.
double getT() const
Get calibrated time of hit.
2-dimensional frame with time calibrated data from one optical module.
Data storage class for rate measurements of all PMTs in one module.
static const int JPP_COVERAGE_POSITION
coverage of dynamic position calibration of this event
static const int JPP_COVERAGE_ORIENTATION
coverage of dynamic orientation calibration of this event
double getChi2(const double P)
Get chi2 corresponding to given probability.
double getIndexOfRefraction()
Get average index of refraction of water corresponding to group velocity.
const double getInverseSpeedOfLight()
Get inverse speed of light.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
double getQuality(const double chi2, const int N, const int NDF)
Get quality of fit.
JPosition3D getPosition(const JFit &fit)
Get position.
void copy(const JFIT::JEvt::const_iterator __begin, const JFIT::JEvt::const_iterator __end, Evt &out)
Copy tracks.
bool qualitySorter(const JFit &first, const JFit &second)
Comparison of fit results.
JFit getFit(const JHistory &history, const JTrack3D &track, const double Q, const int NDF, const double energy=0.0, const int status=SINGLE_STAGE)
Get fit.
Auxiliary classes and methods for triggering.
Data structure for coverage of detector by dynamical calibrations.
double position
coverage of detector by available position calibration [0,1]
double orientation
coverage of detector by available orientation calibration [0,1]
Auxiliary class for historical event.
Auxiliary class to test history.
Auxiliary class for handling PMT geometry, rate and response.
int getN() const
Get number of hits.
double getR() const
Get rate.
Template definition of a data regressor of given model.
Auxiliary class for handling module response.
Data structure for fit parameters.
double scanAngle_deg
scanning angle step in [deg]
double Emin_GeV
minimum energy to scan
double TMin_ns
minimum time for local coincidences [ns]
double TMax_ns
maximum time for local coincidences [ns]
double R_Hz
default rate [Hz]
double Emax_GeV
maximum energy to scan
int En
number of points to scan in energy range
double VMax_npe
maximum number of of photo-electrons
size_t numberOfPrefits
number of prefits
double DMax_m
maximal distance to optical module [m]