Jpp 20.0.0-195-g190c9e876
the software that should make you happy
Loading...
Searching...
No Matches
JMuonFeatures.hh
Go to the documentation of this file.
1#ifndef __JRECONSTRUCTION__JMUONFEATURES__
2#define __JRECONSTRUCTION__JMUONFEATURES__
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/JLine1Z.hh"
21#include "JFit/JLine3Z.hh"
22#include "JFit/JModel.hh"
23#include "JFit/JGandalf.hh"
25
30
31#include "JPhysics/JPDFTable.hh"
33#include "JPhysics/JGeane.hh"
34
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 eleguirriec, mdejong
53 */
54
55namespace JRECONSTRUCTION {}
56namespace JPP { using namespace JRECONSTRUCTION; }
57
58namespace JRECONSTRUCTION {
59
64 using JFIT::JRegressor;
65 using JFIT::JLine3Z;
66 using JFIT::JGandalf;
67 using JFIT::JTimeRange;
69
70
71 /**
72 * Wrapper class to add features after the final fit of muon trajectory.
73 *
74 * JMuonFeatures computes value of number of hists, number of doms and number of lines from the hits of an event.
75 * Note that no values computed at previous steps are modified.
76 */
79 public JRegressor<JLine3Z, JGandalf>
80 {
82 struct hit_type :
83 public JHitW0,
84 public JLocation
85 {};
87
88 /**
89 * Input data type.
90 */
91 struct input_type :
92 public JDAQEventHeader
93 {
94 /**
95 * Default constructor.
96 */
98 {}
99
100
101 /**
102 * Constructor.
103 *
104 * \param header header
105 * \param in start values
106 * \param coverage coverage
107 */
109 const JEvt& in,
110 const coverage_type& coverage) :
111 JDAQEventHeader(header),
112 in(in),
114 {}
115
119 };
120
121 /**
122 * Constructor
123 *
124 * \param parameters parameters
125 * \param storage storage
126 * \param debug debug
127 */
129 const storage_type& storage,
130 const int debug = 0) :
131 JMuonGandalfParameters_t(parameters),
132 JRegressor_t(storage)
133 {
134 using namespace JFIT;
135
136 if (this->getRmax() < roadWidth_m) {
137 roadWidth_m = this->getRmax();
138 }
139
142 JRegressor_t::Vmax_npe = VMax_npe;
143 }
144
145 /**
146 * Get input data.
147 *
148 * \param router module router
149 * \param summary summary data
150 * \param event event
151 * \param in start values
152 * \param coverage coverage
153 * \return input data
154 */
156 const JSummaryRouter& summary,
157 const JDAQEvent& event,
158 const JEvt& in,
159 const coverage_type& coverage) const
160 {
161 using namespace std;
162 using namespace JTRIGGER;
163
164 const JBuildL0<JHitL0> buildL0;
165
166 input_type input(event.getDAQEventHeader(), in, coverage);
167
168 vector<JHitL0> data;
169
170 buildL0(event, router, true, back_inserter(data));
171
172 for (const auto& hit : data) {
173
174 const int type = 0;
175 const double QE = 1.0;
176 const double R_Hz = summary.getRate(hit.getPMTIdentifier(), this->R_Hz);
177
178 input.data.push_back( { JHitW0(hit, type, QE, R_Hz), router.getModule(hit.getModuleID()).getLocation() } );
179 }
180
181 return input;
182 }
183
184
185 /**
186 * Fit function.
187 *
188 * \param input input data
189 * \return fit results
190 */
192 {
193 using namespace std;
194 using namespace JFIT;
195 using namespace JGEOMETRY3D;
196
197 JEvent event(JMUONFEATURES);
198
199 JEvt out;
200
201 const buffer_type& data = input.data;
202
203 // select start values
204
205 JEvt in = input.in;
206
208
209 if (!in.empty()) {
210 in.select(JHistory::is_event(in.begin()->getHistory()));
211 }
212
213 for (JEvt::const_iterator track = in.begin(); track != in.end(); ++track) {
214
215 const JRotation3D R (getDirection(*track));
216 const JLine1Z tz(getPosition (*track).rotate(R), track->getT());
217 JRange<double> Z_m;
218
219 if (track->hasW(JSTART_LENGTH_METRES) &&
220 track->getW(JSTART_LENGTH_METRES) > 0.0) {
221 Z_m = JZRange(ZMin_m, ZMax_m + track->getW(JSTART_LENGTH_METRES));
222 }
223
224 const JModel<JLine1Z> match(tz, roadWidth_m, JRegressor_t::T_ns, Z_m);
225
226 // hit selection based on start value
227
228 buffer_type buffer;
229
230 for (buffer_type::const_iterator i = data.begin(); i != data.end(); ++i) {
231
232 hit_type hit(*i);
233
234 hit.rotate(R);
235
236 if (match(hit)) {
237 buffer.push_back(hit);
238 }
239 }
240
241 const int number_of_hits = JLANG::getCount(JLANG::make_array(buffer.begin(), buffer.end(), &hit_type::getPMTIdentifier));
242 const int number_of_doms = JLANG::getCount(JLANG::make_array(buffer.begin(), buffer.end(), &hit_type::getModuleIdentifier));
243 const int number_of_lines = JLANG::getCount(JLANG::make_array(buffer.begin(), buffer.end(), &hit_type::getString));
244
245 out.push_back(JFit(*track).add(JMUONFEATURES));
246
247 // set additional values
248
249 out.rbegin()->setW(JMUONFEATURES_NUMBER_OF_HITS , number_of_hits);
250 out.rbegin()->setW(JMUONFEATURES_NUMBER_OF_DOMS , number_of_doms);
251 out.rbegin()->setW(JMUONFEATURES_NUMBER_OF_LINES , number_of_lines);
252 }
253
254 // apply default sorter
255
256 sort(out.begin(), out.end(), qualitySorter);
257
258 copy(input.in.begin(), input.in.end(), back_inserter(out));
259
260 return out;
261 }
262 };
263}
264
265#endif
266
Coverage of dynamical detector calibration.
Auxiliary methods to evaluate Poisson probabilities and chi2.
Energy loss of muon.
Basic data structure for L0 hit.
Data regression method for JFIT::JLine3Z.
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.
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
const JLocation & getLocation() const
Get location.
Definition JLocation.hh:70
int getString() const
Get string number.
Definition JLocation.hh:135
Router for direct addressing of module data in detector data structure.
const JModule & getModule(const JObjectID &id) const
Get module parameters.
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.
Fit method based on the Levenberg-Marquardt method.
Definition JGandalf.hh:87
Data structure for fit of straight line paralel to z-axis.
Definition JLine1Z.hh:29
Data structure for fit of straight line in positive z-direction.
Definition JLine3Z.hh:40
JAxis3D & rotate(const JRotation3D &R)
Rotate axis.
Definition JAxis3D.hh:225
JPosition3D & rotate(const JRotation3D &R)
Rotate.
Auxiliary class for a hit with background rate value.
Definition JHitW0.hh:25
Router for fast addressing of summary data in KM3NETDAQ::JDAQSummaryslice data structure as a functio...
double getRate(const JDAQPMTIdentifier &id) const
Get rate.
void setRange(const range_type &range)
Set range.
Definition JRange.hh:146
Template L0 hit builder.
Definition JBuildL0.hh:38
const JDAQEventHeader & getDAQEventHeader() const
Get DAQ event header.
const JDAQModuleIdentifier & getModuleIdentifier() const
Get Module identifier.
const JDAQPMTIdentifier & getPMTIdentifier() const
Get PMT identifier.
static const int JMUONFEATURES_NUMBER_OF_LINES
number of lines see JRECONSTRUCTION::JMuonFeatures
static const int JSTART_LENGTH_METRES
distance between projected positions on the track of optical modules for which the response does not ...
static const int JMUONFEATURES_NUMBER_OF_HITS
number of hits see JRECONSTRUCTION::JMuonFeatures
static const int JMUONFEATURES_NUMBER_OF_DOMS
number of doms see JRECONSTRUCTION::JMuonFeatures
Auxiliary classes and methods for linear and iterative data regression.
JTOOLS::JRange< double > JZRange
Auxiliary classes and methods for 3D geometrical objects and operations.
Definition JAngle3D.hh:19
const array_type< JValue_t > & make_array(const JValue_t(&array)[N])
Method to create array of values.
Definition JVectorize.hh:54
size_t getCount(const array_type< T > &buffer, const JCompare_t &compare)
Count number of unique values.
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.
JDirection3D getDirection(const JFit &fit)
Get direction.
Auxiliary classes and methods for triggering.
Model for fit to acoustics data.
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 definition of a data regressor of given model.
Definition JRegressor.hh:70
input_type(const JDAQEventHeader &header, const JEvt &in, const coverage_type &coverage)
Constructor.
Wrapper class to add features after the final fit of muon trajectory.
JMuonFeatures(const JMuonGandalfParameters_t &parameters, const storage_type &storage, const int debug=0)
Constructor.
JEvt operator()(const input_type &input)
Fit function.
JRegressor< JLine3Z, JGandalf > JRegressor_t
std::vector< hit_type > buffer_type
input_type getInput(const JModuleRouter &router, const JSummaryRouter &summary, const JDAQEvent &event, const JEvt &in, const coverage_type &coverage) const
Get input data.
double TMin_ns
minimal time w.r.t. Cherenkov hypothesis [ns]
double TMax_ns
maximal time w.r.t. Cherenkov hypothesis [ns]
double VMax_npe
maximum number of of photo-electrons