#ifndef JSHOWERPOSITIONFIT_INCLUDE #define JSHOWERPOSITIONFIT_INCLUDE #include #include #include #include #include #include #include #include "km3net-dataformat/online/JDAQTimeslice.hh" #include "km3net-dataformat/online/JDAQSummaryslice.hh" #include "JTrigger/JHit.hh" #include "JTrigger/JTimeslice.hh" #include "JTrigger/JHitL0.hh" #include "JTrigger/JHitL1.hh" #include "JTrigger/JHitR1.hh" #include "JTrigger/JBuildL0.hh" #include "JTrigger/JBuildL2.hh" #include "JTrigger/JAlgorithm.hh" #include "JTrigger/JMatch3G.hh" #include "JTrigger/JBind2nd.hh" #include "JSupport/JSummaryFileRouter.hh" #include "JFit/JFitToolkit.hh" #include "JFit/JEstimator.hh" #include "JFit/JPoint4E.hh" #include "JFit/JModel.hh" #include "JFit/JSimplex.hh" #include "JFit/JShowerBrightPointRegressor.hh" #include "JReconstruction/JHitW0.hh" #include "JReconstruction/JEvt.hh" #include "JReconstruction/JEvtToolkit.hh" #include "JReconstruction/JShowerParameters.hh" #include "JGeometry3D/JVector3D.hh" #include "JGeometry3D/JShower3D.hh" #include "JGeometry3D/JShower3E.hh" #include "JGeometry3D/JTrack3D.hh" #include "JGeometry3D/JTrack3E.hh" #include "JGeometry3D/JGeometry3DToolkit.hh" #include "JDetector/JModuleRouter.hh" #include "JDetector/JDetector.hh" #include "JDetector/JDetectorSubset.hh" #include "JTools/JPermutation.hh" #include "JTools/JRange.hh" #include "JLang/JSharedPointer.hh" /** * \author adomi, vcarretero */ namespace JRECONSTRUCTION {} namespace JPP { using namespace JRECONSTRUCTION; } namespace JRECONSTRUCTION { using JDETECTOR::JModuleRouter; using JSUPPORT::JSummaryRouter; using JFIT::JPoint4D; using JFIT::JPoint4E; using JFIT::JGandalf; using JFIT::JRegressor; /** * class to handle the second position fit of the shower reconstruction, mainly dedicated for ORCA */ class JShowerPositionFit : public JShowerPositionFitParameters_t, public JRegressor { typedef JRegressor JRegressor_t; using JRegressor_t::operator(); std::vector Ev; public: /** * Parameterized constructor * * \param parameters struct that holds default-optimized parameters for the reconstruction * \param router module router, this is built via detector file. * \param summary summary router * \param pdfFile file name with PDF * \param debug debug */ JShowerPositionFit(const JShowerPositionFitParameters_t& parameters, const JModuleRouter& router, const JSummaryRouter& summary, const std::string pdfFile, const int debug = 0): JShowerPositionFitParameters_t(parameters), JRegressor_t(pdfFile, parameters.TTS_ns), router(router), summary(summary) { using namespace JPP; JRegressor_t::debug = debug; JRegressor_t::T_ns.setRange(parameters.TMin_ns, parameters.TMax_ns); JRegressor_t::Vmax_npe = VMax_npe; JRegressor_t::MAXIMUM_ITERATIONS = NMax; JRegressor_t::EPSILON = 1e-3; if (Emin_GeV > Emax_GeV || En <= 1) { THROW(JException, "Invalid energy input " << Emin_GeV << ' ' << Emax_GeV << ' ' << En); } const double base = std::pow((Emax_GeV / Emin_GeV), 1.0 / (En - 1)); for (int i = 0; i != En; ++i) { Ev.push_back(Emin_GeV * std::pow(base, i)); } this->parameters.resize(4); this->parameters[0] = JPoint4E::pX(); this->parameters[1] = JPoint4E::pY(); this->parameters[2] = JPoint4E::pZ(); this->parameters[3] = JPoint4E::pT(); } /** * Declaration of the member function that actually performs the reconstruction * * \param event which is a JDAQEvent * \param in input fits */ JEvt operator()(const KM3NETDAQ::JDAQEvent& event, const JFIT::JEvt &in) { using namespace std; using namespace JPP; typedef vector JDataL0_t; const JBuildL0 buildL0; JEvt out; JDataL0_t dataL0; buildL0(JDAQTimeslice(event, true), router, back_inserter(dataL0)); for (JEvt::const_iterator shower = in.begin(); shower != in.end(); ++shower) { JPoint4D vx(getPosition(*shower), shower->getT()); vector data; const JFIT::JModel match(vx, DMax_m, JRegressor_t::T_ns); for (JDataL0_t::const_iterator i = dataL0.begin(); i != dataL0.end(); ++i) { const double rate_Hz = summary.getRate(*i); if (match(*i)) { data.push_back(JHitW0(*i, rate_Hz)); } } // select first hit sort(data.begin(), data.end(), JHitL0::compare); vector::iterator __end = unique(data.begin(), data.end(), equal_to()); const int NDF = distance(data.begin(), __end) - this->parameters.size(); if (NDF > 0) { // set fit parameters for (vector::iterator i = Ev.begin(); i != Ev.end(); ++i) { JPoint4E sh(vx, *i); double chi2 = (*this)(sh, data.begin(), __end); JShower3E sh_fit(this->value.getPosition(), JDirection3D(), this->value.getT(), this->value.getE()); out.push_back(getFit(JHistory(shower->getHistory()).add(JSHOWERPOSITIONFIT), sh_fit, getQuality(chi2), NDF, sh_fit.getE())); } } } return out; } const JModuleRouter& router; const JSummaryRouter& summary; }; } #endif