Jpp 20.0.0-rc.2
the software that should make you happy
Loading...
Searching...
No Matches
JShowerPointSimplex.hh
Go to the documentation of this file.
1#ifndef JSHOWERPOINTSIMPLEX_INCLUDE
2#define JSHOWERPOINTSIMPLEX_INCLUDE
3
4#include <string>
5#include <iostream>
6#include <set>
7#include <vector>
8#include <algorithm>
9#include <memory>
10#include <math.h>
11
15
16#include "JTrigger/JHit.hh"
18#include "JTrigger/JHitR1.hh"
19#include "JTrigger/JBuildL0.hh"
20#include "JTrigger/JBuildL2.hh"
22#include "JTrigger/JMatch3G.hh"
23#include "JTrigger/JBind2nd.hh"
24
25#include "JFit/JFitToolkit.hh"
26#include "JFit/JEstimator.hh"
27#include "JFit/JPoint4D.hh"
28#include "JFit/JModel.hh"
29#include "JFit/JSimplex.hh"
30#include "JFit/JGandalf.hh"
32
36
37#include "JLang/JPredicate.hh"
38
45
49
51
53#include "JTools/JRange.hh"
54
55/**
56 * \author adomi, vcarretero
57 */
58namespace JRECONSTRUCTION {}
59namespace JPP { using namespace JRECONSTRUCTION; }
60
61namespace JRECONSTRUCTION {
62
66 using JFIT::JPoint4D;
67 using JFIT::JGandalf;
68 using JFIT::JRegressor;
69
70 /**
71 * class to handle the second position fit of the shower reconstruction, mainly dedicated for ORCA
72 */
74
76 public JRegressor<JPoint4D, JGandalf>
77 {
78 public:
82
83 using JRegressor_t::operator();
84
85 /**
86 * Input data type.
87 */
88 struct input_type :
89 public JDAQEventHeader
90 {
91 /**
92 * Default constructor.
93 */
95 {}
96
97
98 /**
99 * Constructor.
100 *
101 * \param header header
102 * \param in start values
103 * \param coverage coverage
104 */
105 input_type(const JDAQEventHeader& header, const JEvt& in, const coverage_type& coverage) :
106 JDAQEventHeader(header),
107 in(in),
109 {}
110
115 };
116
117 public:
118
119 /**
120 * Parameterized constructor
121 *
122 * \param parameters struct that holds default-optimized parameters for the reconstruction.
123 * \param debug debug
124 */
126 const int debug = 0):
128 JRegressor_t(parameters.sigma_ns)
129 {
130 using namespace JPP;
131
132 JRegressor_t::debug = debug;
133 JRegressor_t::MAXIMUM_ITERATIONS = NMax;
134 JRegressor_t::EPSILON = 1e-4;
135
136 this->estimator.reset(getMEstimator(parameters.mestimator));
137 this->parameters.resize(4);
138 this->parameters[0] = JPoint4D::pX();
139 this->parameters[1] = JPoint4D::pY();
140 this->parameters[2] = JPoint4D::pZ();
141 this->parameters[3] = JPoint4D::pT();
142 }
143 /**
144 * Get input data.
145 *
146 * \param router module router
147 * \param event event
148 * \param in start values
149 * \param coverage coverage
150 * \return input data
151 */
152 input_type getInput(const JModuleRouter& router, const KM3NETDAQ::JDAQEvent& event, const JEvt& in, const coverage_type& coverage) const
153 {
154 using namespace std;
155 using namespace KM3NETDAQ;
156 using namespace JTRIGGER;
157 const JBuildL0<hit_type> buildL0;
159
160 input_type input(event.getDAQEventHeader(), in, coverage);
161
162 buffer_type& dataL0 = input.dataL0;
163 buffer_type& dataL1 = input.dataL1;
164
165 buildL0(JDAQTimeslice(event, true), router, back_inserter(dataL0));
166 buildL2(JDAQTimeslice(event, false), router, back_inserter(dataL1)); // false = triggered
167
168 return input;
169 }
170
171 /**
172 * Fit function.
173 *
174 * \param input input data
175 * \return fit results
176 */
178 {
179 using namespace std;
180 using namespace JPP;
181
183
184 JEvt out;
185
186 const buffer_type& dataL0 = input.dataL0;
187 const buffer_type& dataL1 = input.dataL1;
188
189 // select start values
190
191 JEvt in = input.in;
192
194
195 if (!in.empty()) {
196 in.select(JHistory::is_event(in.begin()->getHistory()));
197 }
198
199 for (JEvt::const_iterator shower = in.begin(); shower != in.end(); ++shower) {
200
201 JPoint4D vx(getPosition(*shower), shower->getT());
202
204
205 buffer_type data;
206
207 data.reserve(dataL0.size() + dataL1.size());
208
209 for (buffer_type::const_iterator i = dataL1.begin(); i != dataL1.end(); ++i) {
210
211 if (match(*i)) {
212 data.push_back(*i);
213 }
214 }
215
216 buffer_type::iterator __end = data.end();
217
218 for (buffer_type::const_iterator i = dataL0.begin(); i != dataL0.end(); ++i) {
219 if (find_if(data.begin(), __end, make_predicate(&hit_type::getModuleID, i->getModuleID())) == __end) {
220 if (match(*i)) {
221 data.push_back(*i);
222 }
223 }
224 }
225
226 const int NDF = getCount(data.begin(), data.end()) - this->parameters.size();
227
228 if (NDF > 0) {
229
230 double chi2 = (*this)(vx, data.begin(), data.end());
231
232 JShower3D result(JVertex3D(this->value.getPosition(), this->value.getT()), JDirection3D());
233
234 out.push_back(getFit(JHistory(shower->getHistory(), event()), result, getQuality(chi2, NDF), NDF, shower->getE()));
235
236 // set additional values
237
238 out.rbegin()->setW(JPP_COVERAGE_ORIENTATION, input.coverage.orientation);
239 out.rbegin()->setW(JPP_COVERAGE_POSITION, input.coverage.position);
240 }
241 }
242
243 // apply default sorter
244
245 sort(out.begin(), out.end(), qualitySorter);
246
247 copy(input.in.begin(), input.in.end(), back_inserter(out));
248
249 return out;
250 }
251
252
253 };
254}
255#endif
256
Algorithms for hit clustering and sorting.
Coverage of dynamical detector calibration.
Auxiliary class to extract a subset of optical modules from a detector.
Data structure for detector geometry and calibration.
Linear fit methods.
Auxiliary methods to evaluate Poisson probabilities and chi2.
Reduced data structure for L1 hit.
Match operator for Cherenkov light from shower in any direction.
int debug
debug level
Definition JSirene.cc:72
Direct access to module in detector data structure.
Auxiliary class to define a range between two values.
Basic data structure for time and time over threshold information of hit.
Router for direct addressing of module data in detector data structure.
Data structure for set of track fit results.
void select(const JSelector_t &selector)
Select fits.
Fit method based on the Levenberg-Marquardt method.
Definition JGandalf.hh:87
Data structure for vertex fit.
Definition JPoint4D.hh:24
static parameter_type pT()
Definition JPoint4D.hh:61
static parameter_type pZ()
Definition JPoint4D.hh:60
static parameter_type pX()
Definition JPoint4D.hh:58
static parameter_type pY()
Definition JPoint4D.hh:59
Data structure for direction in three dimensions.
class to handle the second position fit of the shower reconstruction, mainly dedicated for ORCA
JRegressor< JPoint4D, JGandalf > JRegressor_t
JEvt operator()(const input_type &input)
Fit function.
JShowerPointSimplex(const JShowerPointSimplexParameters_t &parameters, const int debug=0)
Parameterized constructor.
input_type getInput(const JModuleRouter &router, const KM3NETDAQ::JDAQEvent &event, const JEvt &in, const coverage_type &coverage) const
Get input data.
Template L0 hit builder.
Definition JBuildL0.hh:38
Template L2 builder.
Definition JBuildL2.hh:49
Reduced data structure for L1 hit.
Definition JHitR1.hh:35
const JDAQEventHeader & getDAQEventHeader() const
Get DAQ event header.
int getModuleID() const
Get module identifier.
static const int JPP_COVERAGE_POSITION
coverage of dynamic position calibration from any Jpp application
static const int JPP_COVERAGE_ORIENTATION
coverage of dynamic orientation calibration from any Jpp application
JMEstimator * getMEstimator(const int type)
Get M-Estimator.
size_t getCount(const array_type< T > &buffer, const JCompare_t &compare)
Count number of unique values.
JTOOLS::JRange< double > JTimeRange
Type definition for time range (unit [ns]).
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.
JFIT::JHistory JHistory
Definition JHistory.hh:455
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.
return result
Definition JPolint.hh:862
Auxiliary classes and methods for triggering.
KM3NeT DAQ data structures and auxiliaries.
Definition DataQueue.cc:39
Data structure for coverage of detector by dynamical calibrations.
Definition JCoverage.hh:19
double position
coverage of detector by available position calibration [0,1]
Definition JCoverage.hh:42
double orientation
coverage of detector by available orientation calibration [0,1]
Definition JCoverage.hh:41
Auxiliary class for historical event.
Definition JHistory.hh:40
Auxiliary class to test history.
Definition JHistory.hh:157
Auxiliary class to match data points with given model.
Template definition of a data regressor of given model.
Definition JRegressor.hh:70
double TMin_ns
minimum time for local coincidences [ns]
double TMaxLocal_ns
time window for local coincidences [ns]
double TMax_ns
maximum time for local coincidences [ns]
double ctMin
minimal cosine space angle between PMT axes
double DMax_m
maximal distance to optical module [m]
input_type(const JDAQEventHeader &header, const JEvt &in, const coverage_type &coverage)
Constructor.
Data structure for L2 parameters.