Jpp 21.0.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
JShowerFeatures.hh
Go to the documentation of this file.
1#ifndef __JRECONSTRUCTION__JSHOWERFEATURES__
2#define __JRECONSTRUCTION__JSHOWERFEATURES__
3
4#include <string>
5#include <iostream>
6#include <iomanip>
7#include <vector>
8#include <algorithm>
9
10#include <map>
11
15
16#include "JTrigger/JHitL0.hh"
17#include "JTrigger/JBuildL0.hh"
18
19#include "JFit/JFitToolkit.hh"
20#include "JFit/JModel.hh"
22
28
29
30#include "JPhysics/JPDFTable.hh"
32#include "JPhysics/JGeane.hh"
33
37
39
41
43
44#include "JTools/JRange.hh"
45
46#include "Jeep/JMessage.hh"
47
48#include "JLang/JVectorize.hh"
49
50
51/**
52 * \author vcarretero
53 */
54
55namespace JRECONSTRUCTION {}
56namespace JPP { using namespace JRECONSTRUCTION; }
57
58namespace JRECONSTRUCTION {
59
66 using JFIT::JRegressor;
67 using JFIT::JEnergy;
68 using JFIT::JShower3EZ;
71
72 /**
73 * Wrapper class to add features after the final fit of shower
74 *
75 * Note that no values computed at previous steps are modified.
76 */
79 public JRegressor<JShower3EZ, JAbstractMinimiser>
80 {
82
86 /**
87 * Input data type.
88 */
89 struct input_type :
90 public JDAQEventHeader
91 {
92 /**
93 * Default constructor.
94 */
96 {}
97
98
99 /**
100 * Constructor.
101 *
102 * \param header header
103 * \param in start values
104 * \param coverage coverage
105 */
107 const JEvt& in,
108 const coverage_type& coverage) :
109 JDAQEventHeader(header),
110 in(in),
112 {}
113
117 };
118
119 /**
120 * Constructor
121 *
122 * \param parameters parameters
123 * \param storage storage
124 * \param pmtParameters PMT parameters
125 * \param debug debug
126 */
128 const storage_type& storage,
130 const int debug = 0) :
131 JShowerFitParameters_t(parameters),
132 JRegressor_t(storage),
134 {
135 using namespace JFIT;
136
139 }
140
141 /**
142 * Get input data.
143 *
144 * \param router module router
145 * \param summary summary data
146 * \param event event
147 * \param in start values
148 * \param coverage coverage
149 * \return input data
150 */
152 const JSummaryRouter& summary,
153 const JDAQEvent& event,
154 const JEvt& in,
155 const coverage_type& coverage) const
156 {
157 using namespace std;
158 using namespace JTRIGGER;
159
160 input_type input(event.getDAQEventHeader(), in, coverage);
161
162 const JBuildL0 <JHitR0> buildL0;
164
165 const JDAQTimeslice timeslice(event, true);
166
167 JSuperFrame2D<JHit> buffer;
168
169 for (JDAQTimeslice::const_iterator i = timeslice.begin(); i != timeslice.end(); ++i) {
170
171 if (router.hasModule(i->getModuleID())) {
172
173 buffer(*i, router.getModule(i->getModuleID()));
174
175 buildL0(buffer, back_inserter(data[i->getModuleID()]));
176 }
177 }
178
179 for (const auto& module : router.getReference()) {
180 if (!module.empty()) {
181 input.data.push_back(module_type(module, summary.getSummaryFrame(module.getID(), R_Hz), data[module.getID()]));
182 }
183 }
184
185 return input;
186 }
187
188
189 /**
190 * Fit function.
191 *
192 * \param input input data
193 * \return fit results
194 */
196 {
197 using namespace std;
198 using namespace JFIT;
199 using namespace JGEOMETRY3D;
200
201 JEvent event(JSHOWERFEATURES);
202
203 JEvt out;
204
205 JEvt in = input.in;
206
208
209 if (!in.empty()) {
210 in.select(JHistory::is_event(in.begin()->getHistory()));
211 }
212
213 // Computation of max pmt getting a hit in a DOM for a given event, snapshot
214
215 struct {
216 size_t nhits = 0;
217 int id = -1;
218 } snapshot;
219
220 for (const auto& module : input.data) {
221 if (module.size() != 0) {
222
223 size_t snapshot_hits = 0;
224
225 for (size_t i = 0; i != module->size(); ++i) {
226
227 if (module.getStatus(i)) {
228
229 const size_t nhits = std::count_if(
230 module.begin(),
231 module.end(),
232 [i](const JHitR0& hit) {
233 return hit.getPMT() == i;
234 }
235 );
236
237 if (nhits > 0) snapshot_hits++;
238 }
239 }
240
241 if (snapshot_hits > snapshot.nhits){
242 snapshot.nhits = snapshot_hits;
243 snapshot.id = module->getID();
244 }
245 }
246 }
247
248 for (JEvt::const_iterator shower = in.begin(); shower != in.end(); ++shower) {
249
250 //Computation of the minimal distance from jshower vertex to a module
251 struct {
252 double Dmin = numeric_limits<double>::max();
253 int id = -1;
254 } vertex;
255
256 for (const auto& module : input.data) {
257 if (module->getFloor() != 0) {
258
259 const double D = getDistance(module->getPosition(), getPosition(*shower));
260
261 if (D < vertex.Dmin) {
262
263 vertex.Dmin = D;
264 vertex.id = module->getID();
265
266 }
267 }
268 }
269
270 out.push_back(JFit(*shower).add(JSHOWERFEATURES));
271 out.rbegin()->setW(JSHOWERFEATURES_DMIN, vertex.Dmin);
272 out.rbegin()->setW(JSHOWERFEATURES_DMIN_MODULEID, vertex.id);
273 out.rbegin()->setW(JSHOWERFEATURES_NSNAPSHOT, snapshot.nhits);
274 out.rbegin()->setW(JSHOWERFEATURES_NSNAPSHOT_MODULEID, snapshot.id);
275
276 }
277
278 // apply default sorter
279
280 sort(out.begin(), out.end(), qualitySorter);
281
282 copy(input.in.begin(), input.in.end(), back_inserter(out));
283
284 return out;
285 }
286
288
289 };
290
291}
292
293#endif
294
Coverage of dynamical detector calibration.
Auxiliary methods to evaluate Poisson probabilities and chi2.
Energy loss of muon.
Basic data structure for L0 hit.
Logical location of module.
General purpose messaging.
int debug
debug level
Definition JSirene.cc:74
Direct access to module in detector data structure.
Auxiliary methods for PDF calculations.
Auxiliary class to define a range between two values.
Data regression method for JFIT::JShower3EZ.
Auxiliary methods to convert data members or return values of member methods of a set of objects to a...
Logical location of module.
Definition JLocation.hh:40
Router for direct addressing of module data in detector data structure.
bool hasModule(const JModuleIdentifier &id) const
Has module.
const JModule & getModule(const JModuleIdentifier &id) const
Get module parameters.
Auxiliary class for map of PMT parameters.
Abstract minimiser.
Definition JRegressor.hh:27
Data structure for fit of energy.
Data structure for set of track fit results.
void select(const JSelector_t &selector)
Select fits.
JFit & add(const int type)
Add event to history.
Data structure for fit of straight line in positive z-direction with energy.
Definition JShower3EZ.hh:30
const JClass_t & getReference() const
Get reference to object.
Definition JReference.hh:38
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.
void setRange(const range_type &range)
Set range.
Definition JRange.hh:146
Reduced data structure for L0 hit.
Definition JHitR0.hh:29
2-dimensional frame with time calibrated data from one optical module.
const JDAQEventHeader & getDAQEventHeader() const
Get DAQ event header.
static const int JSHOWERFEATURES_DMIN
mininal distance between shower vertex and any optical module [m] see JRECONSTRUCTION::JShowerFeature...
static const int JSHOWERFEATURES_NSNAPSHOT
maximum number of PMT with at least one snapshot hit in any DOM see JRECONSTRUCTION::JShowerFeatures
static const int JSHOWERFEATURES_DMIN_MODULEID
optical module identifier for which the distance to the shower vertex was mininal see JRECONSTRUCTION...
static const int JSHOWERFEATURES_NSNAPSHOT_MODULEID
optical module identifier for which the number of PMT with at least one snapshot hit was maximal see ...
Auxiliary classes and methods for linear and iterative data regression.
Auxiliary classes and methods for 3D geometrical objects and operations.
Definition JAngle3D.hh:19
double getDistance(const JFirst_t &first, const JSecond_t &second)
Get distance between objects.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
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.
Auxiliary classes and methods for triggering.
Data structure for coverage of detector by dynamical calibrations.
Definition JCoverage.hh:19
static int debug
debug level (default is off).
Definition JMessage.hh:45
Auxiliary class for historical event.
Definition JHistory.hh:40
Auxiliary class to test history.
Definition JHistory.hh:157
JTimeRange T_ns
Time window with respect to Cherenkov hypothesis [ns].
Template data structure for storage of internal data.
Template definition of a data regressor of given model.
Definition JRegressor.hh:70
Auxiliary class for handling module response.
Definition JModuleL0.hh:45
input_type(const JDAQEventHeader &header, const JEvt &in, const coverage_type &coverage)
Constructor.
Wrapper class to add features after the final fit of shower.
std::vector< module_type > detector_type
const JPMTParametersMap & pmtParameters
JEvt operator()(const input_type &input)
Fit function.
input_type getInput(const JModuleRouter &router, const JSummaryRouter &summary, const JDAQEvent &event, const JEvt &in, const coverage_type &coverage) const
Get input data.
JRegressor< JShower3EZ, JAbstractMinimiser > JRegressor_t
JShowerFeatures(const JShowerFitParameters_t &parameters, const storage_type &storage, const JPMTParametersMap &pmtParameters, const int debug=0)
Constructor.
JRegressorStorage< JShower3EZ, JFIT::JAbstractMinimiser > storage_type
Data structure for fit parameters.
double TMax_ns
maximum time for local coincidences [ns]
double TMin_ns
minimum time for local coincidences [ns]