Jpp 19.3.0-rc.3
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
13
14#include "JTrigger/JHitL0.hh"
15#include "JTrigger/JBuildL0.hh"
16
17#include "JFit/JFitToolkit.hh"
18#include "JFit/JLine1Z.hh"
19#include "JFit/JLine3Z.hh"
20#include "JFit/JModel.hh"
21#include "JFit/JGandalf.hh"
23
28
29#include "JPhysics/JPDFTable.hh"
31#include "JPhysics/JGeane.hh"
32
34
36
38
39#include "JTools/JRange.hh"
40
41#include "Jeep/JMessage.hh"
42
43#include "JLang/JVectorize.hh"
44
45
46/**
47 * \author eleguirriec, mdejong
48 */
49
50namespace JRECONSTRUCTION {}
51namespace JPP { using namespace JRECONSTRUCTION; }
52
53namespace JRECONSTRUCTION {
54
57 using JFIT::JRegressor;
58 using JFIT::JLine3Z;
59 using JFIT::JGandalf;
60 using JFIT::JTimeRange;
61
62
63 /**
64 * Wrapper class to add features after the final fit of muon trajectory.
65 *
66 * The JMuonGandalf fit uses one or more start values (usually taken from the output of JMuonSimplex).\n
67 * All hits of which the PMT position lies within a set road width (JMuonGandalfParameters_t::roadWidth_m) and
68 * time is within a set window (JMuonGandalfParameters_t::TMin_ns, JMuonGandalfParameters_t::TMax_ns) around the Cherenkov hypothesis are taken.\n
69 * In case there are multiple hits from the same PMT is the specified window,
70 * the first hit is taken and the other hits are discarded.\n
71 * The PDF is accordingly evaluated, i.e.\ the normalised probability for a first hit at the given time of the hit is taken.
72 * The normalisation is consistently based on the specified time window.\n
73 * Note that this hit selection is unbiased with respect to the PDF of a single PMT.
74 */
77 public JRegressor<JLine3Z, JGandalf>
78 {
82
83 using JRegressor_t::operator();
84
85 /**
86 * Constructor
87 *
88 * \param parameters parameters
89 * \param router module router
90 * \param summary summary file router
91 * \param pdf_file PDF file
92 * \param debug debug
93 */
95 const JModuleRouter& router,
97 const std::string& pdf_file,
98 const int debug = 0) :
99 JMuonGandalfParameters_t(parameters),
100 JRegressor_t(pdf_file, JTimeRange(parameters.TMin_ns, parameters.TMax_ns), parameters.TTS_ns),
101 router (router),
103 {
104 using namespace JFIT;
105
106 if (this->getRmax() < roadWidth_m) {
107 roadWidth_m = this->getRmax();
108 }
109
110 JRegressor_t::debug = debug;
111 JRegressor_t::T_ns.setRange(TMin_ns, TMax_ns);
112 JRegressor_t::Vmax_npe = VMax_npe;
113 JRegressor_t::MAXIMUM_ITERATIONS = NMax;
114
115 this->parameters.resize(5);
116
117 this->parameters[0] = JLine3Z::pX();
118 this->parameters[1] = JLine3Z::pY();
119 this->parameters[2] = JLine3Z::pT();
120 this->parameters[3] = JLine3Z::pDX();
121 this->parameters[4] = JLine3Z::pDY();
122 }
123
124
125 /**
126 * Fit function.
127 *
128 * \param event event
129 * \param in start values
130 * \return fit results
131 */
132 JEvt operator()(const KM3NETDAQ::JDAQEvent& event, const JEvt& in)
133 {
134 using namespace std;
135 using namespace JFIT;
136 using namespace JTRIGGER;
137
138 const JBuildL0<hit_type> buildL0;
139
140 buffer_type dataL0;
141
142 buildL0(event, router, true, back_inserter(dataL0));
143
144 return (*this)(dataL0, in);
145 }
146
147
148 /**
149 * Fit function.
150 *
151 * \param data hit data
152 * \param in start values
153 * \return fit results
154 */
155 JEvt operator()(const buffer_type& data, const JEvt& in)
156 {
157 using namespace std;
158 using namespace JFIT;
159 using namespace JGEOMETRY3D;
160
161 JEvt out;
162
163 for (JEvt::const_iterator track = in.begin(); track != in.end(); ++track) {
164
165 const JRotation3D R (getDirection(*track));
166 const JLine1Z tz(getPosition (*track).rotate(R), track->getT());
167 JRange<double> Z_m;
168
169 if (track->hasW(JSTART_LENGTH_METRES) &&
170 track->getW(JSTART_LENGTH_METRES) > 0.0) {
171 Z_m = JZRange(ZMin_m, ZMax_m + track->getW(JSTART_LENGTH_METRES));
172 }
173
174 const JModel<JLine1Z> match(tz, roadWidth_m, JRegressor_t::T_ns, Z_m);
175
176 // hit selection based on start value
177
178 vector<JHitW0> buffer;
179
180 for (buffer_type::const_iterator i = data.begin(); i != data.end(); ++i) {
181
182 JHitW0 hit(*i, summary.getRate(i->getPMTIdentifier(), this->R_Hz));
183
184 hit.rotate(R);
185
186 if (match(hit)) {
187 buffer.push_back(hit);
188 }
189 }
190
191 // select first hit
192
193 std::set<int> string_ids;
194 for (vector<JHitW0>::const_iterator i = buffer.begin(); i != buffer.end(); ++i) {
195 string_ids.insert(router.getModule(((*i).getModuleID())).getString());
196 }
197
198 const int number_of_hits = JLANG::getCount(JLANG::make_array(buffer.begin(), buffer.end(), &JHitW0::getPMTIdentifier));
199 const int number_of_doms = JLANG::getCount(JLANG::make_array(buffer.begin(), buffer.end(), &JHitW0::getModuleIdentifier));
200 const int number_of_lines = string_ids.size();
201
202 const int NDF = number_of_hits - this->parameters.size();
203
204 if (NDF > 0) {
205
206 out.push_back(JFit(*track).add(JMUONFEATURES));
207
208 // set additional values
209
210 out.rbegin()->setW(JMUONFEATURES_NUMBER_OF_HITS , number_of_hits);
211 out.rbegin()->setW(JMUONFEATURES_NUMBER_OF_DOMS , number_of_doms);
212 out.rbegin()->setW(JMUONFEATURES_NUMBER_OF_LINES , number_of_lines);
213
214 }
215 }
216
217 return out;
218 }
219
220
223 int debug;
224 };
225}
226
227#endif
228
Auxiliary methods to evaluate Poisson probabilities and chi2.
Energy loss of muon.
Basic data structure for L0 hit.
Data regression method for JFIT::JLine3Z.
General purpose messaging.
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...
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.
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
static parameter_type pY()
Definition JLine1Z.hh:181
static parameter_type pX()
Definition JLine1Z.hh:180
static parameter_type pT()
Definition JLine1Z.hh:182
Data structure for fit of straight line in positive z-direction.
Definition JLine3Z.hh:40
static parameter_type pDY()
Definition JLine3Z.hh:320
static parameter_type pDX()
Definition JLine3Z.hh:319
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:23
Router for fast addressing of summary data in KM3NETDAQ::JDAQSummaryslice data structure as a functio...
double getRate(const JDAQPMTIdentifier &id, const double rate_Hz) const
Get rate.
Template L0 hit builder.
Definition JBuildL0.hh:38
Data structure for L0 hit.
Definition JHitL0.hh:31
const JDAQModuleIdentifier & getModuleIdentifier() const
Get Module identifier.
const JDAQPMTIdentifier & getPMTIdentifier() const
Get PMT identifier.
static const int JMUONFEATURES
static const int JMUONFEATURES_NUMBER_OF_LINES
number of lines from JMuonFeatures.cc
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 from JMuonFeatures.cc
static const int JMUONFEATURES_NUMBER_OF_DOMS
number of doms from JMuonFeatures.cc
Auxiliary classes and methods for linear and iterative data regression.
Definition JEnergy.hh:15
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).
Model fits to data.
JPosition3D getPosition(const JFit &fit)
Get position.
JDirection3D getDirection(const JFit &fit)
Get direction.
Auxiliary classes and methods for triggering.
Model for fit to acoustics data.
Template definition of a data regressor of given model.
Definition JRegressor.hh:70
Wrapper class to add features after the final fit of muon trajectory.
JEvt operator()(const buffer_type &data, const JEvt &in)
Fit function.
JRegressor< JLine3Z, JGandalf > JRegressor_t
std::vector< hit_type > buffer_type
JEvt operator()(const KM3NETDAQ::JDAQEvent &event, const JEvt &in)
Fit function.
JMuonFeatures(const JMuonGandalfParameters_t &parameters, const JModuleRouter &router, const JSummaryRouter &summary, const std::string &pdf_file, const int debug=0)
Constructor.
const JSummaryRouter & summary
const JModuleRouter & router
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