Jpp 20.0.0-195-g190c9e876
the software that should make you happy
Loading...
Searching...
No Matches
JRECONSTRUCTION::JMuonGandalf Struct Reference

Wrapper class to make final fit of muon trajectory. More...

#include <JMuonGandalf.hh>

Inheritance diagram for JRECONSTRUCTION::JMuonGandalf:
JRECONSTRUCTION::JMuonGandalfParameters_t JFIT::JRegressor< JModel_t, JMinimiser_t > TObject

Classes

struct  input_type
 Input data type. More...
 

Public Types

typedef JRegressor< JLine3Z, JGandalfJRegressor_t
 
typedef JHitW0 hit_type
 
typedef std::vector< hit_typebuffer_type
 

Public Member Functions

 JMuonGandalf (const JMuonGandalfParameters_t &parameters, const storage_type &storage, const JPMTParametersMap &pmtParameters, const int debug=0)
 Constructor.
 
input_type getInput (const JModuleRouter &router, const JSummaryRouter &summary, const JDAQEvent &event, const JEvt &in, const coverage_type &coverage) const
 Get input data.
 
JEvt operator() (const input_type &input)
 Fit function.
 
void reset ()
 Reset fit parameters.
 
bool equals (const JMuonGandalfParameters_t &parameters) const
 Equality.
 
 ClassDef (JMuonGandalfParameters_t, 3)
 

Public Attributes

const JPMTParametersMappmtParameters
 
double roadWidth_m
 road width [m]
 
double R_Hz
 default rate [Hz]
 
size_t numberOfPrefits
 number of prefits
 
double TTS_ns
 transition-time spread [ns]
 
double E_GeV
 energy [GeV]
 
double TMin_ns
 minimal time w.r.t. Cherenkov hypothesis [ns]
 
double TMax_ns
 maximal time w.r.t. Cherenkov hypothesis [ns]
 
double ZMin_m
 minimal z-positon [m]
 
double ZMax_m
 maximal z-positon [m]
 
double VMax_npe
 maximum number of of photo-electrons
 
double cosLR
 maximal cosine space angle likelihood ratio test
 
int NMax
 maximum number of iterations
 

Detailed Description

Wrapper class to make final fit of muon trajectory.

The JMuonGandalf fit uses one or more start values (usually taken from the output of JMuonSimplex).
All hits of which the PMT position lies within a set road width (JMuonGandalfParameters_t::roadWidth_m) and time is within a set window (JMuonGandalfParameters_t::TMin_ns, JMuonGandalfParameters_t::TMax_ns) around the Cherenkov hypothesis are taken.
In case there are multiple hits from the same PMT is the specified window, the first hit is taken and the other hits are discarded.
The PDF is accordingly evaluated, i.e. the normalised probability for a first hit at the given time of the hit is taken. The normalisation is consistently based on the specified time window.
Note that this hit selection is unbiased with respect to the PDF of a single PMT.

Definition at line 82 of file JMuonGandalf.hh.

Member Typedef Documentation

◆ JRegressor_t

◆ hit_type

◆ buffer_type

Constructor & Destructor Documentation

◆ JMuonGandalf()

JRECONSTRUCTION::JMuonGandalf::JMuonGandalf ( const JMuonGandalfParameters_t & parameters,
const storage_type & storage,
const JPMTParametersMap & pmtParameters,
const int debug = 0 )
inline

Constructor.

Parameters
parametersparameters
storagestorage
pmtParametersPMT parameters
debugdebug

Definition at line 134 of file JMuonGandalf.hh.

137 :
138 JMuonGandalfParameters_t(parameters),
139 JRegressor_t(storage),
141 {
142 if (this->getRmax() < roadWidth_m) {
143 roadWidth_m = this->getRmax();
144 }
145
146 JRegressor_t::debug = debug;
147 JRegressor_t::Vmax_npe = VMax_npe;
148 JRegressor_t::MAXIMUM_ITERATIONS = NMax;
149
150 this->parameters.resize(5);
151
152 this->parameters[0] = JLine3Z::pX();
153 this->parameters[1] = JLine3Z::pY();
154 this->parameters[2] = JLine3Z::pT();
155 this->parameters[3] = JLine3Z::pDX();
156 this->parameters[4] = JLine3Z::pDY();
157 }
int debug
debug level
Definition JSirene.cc:74
static parameter_type pY()
Definition JLine1Z.hh:181
static parameter_type pX()
Definition JLine1Z.hh:180
static parameter_type pT()
Definition JLine1Z.hh:182
static parameter_type pDY()
Definition JLine3Z.hh:320
static parameter_type pDX()
Definition JLine3Z.hh:319
double VMax_npe
maximum number of of photo-electrons
const JPMTParametersMap & pmtParameters
JRegressor< JLine3Z, JGandalf > JRegressor_t

Member Function Documentation

◆ getInput()

input_type JRECONSTRUCTION::JMuonGandalf::getInput ( const JModuleRouter & router,
const JSummaryRouter & summary,
const JDAQEvent & event,
const JEvt & in,
const coverage_type & coverage ) const
inline

Get input data.

Parameters
routermodule router
summarysummary data
eventevent
instart values
coveragecoverage
Returns
input data

Definition at line 170 of file JMuonGandalf.hh.

175 {
176 using namespace std;
177 using namespace JPP;
178
179 const JBuildL0<JHitL0> buildL0;
180
181 input_type input(event.getDAQEventHeader(), in, coverage);
182
184
185 buildL0(event, router, true, back_inserter(data));
186
187 for (auto& hit : data) {
188
189 const JPMTIdentifier id(hit.getModuleID(), hit.getPMTAddress());
190
192
193 const int type = wip.getType();
194 const double QE = wip.QE;
195 const double R_Hz = summary.getRate(hit.getPMTIdentifier(), this->R_Hz);
196
197 input.data.push_back(hit_type(hit, type, QE, R_Hz));
198 }
199
200 return input;
201 }
const JPMTParameters & getPMTParameters(const JPMTIdentifier &id) const
Get PMT parameters.
Data structure for PMT parameters.
double QE
relative quantum efficiency
int getType() const
Get type for for time-slewing correction.
double getRate(const JDAQPMTIdentifier &id) const
Get rate.
Template L0 hit builder.
Definition JBuildL0.hh:38
const JDAQEventHeader & getDAQEventHeader() const
Get DAQ event header.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).

◆ operator()()

JEvt JRECONSTRUCTION::JMuonGandalf::operator() ( const input_type & input)
inline

Fit function.

Parameters
inputinput data
Returns
fit results

Definition at line 210 of file JMuonGandalf.hh.

211 {
212 using namespace std;
213 using namespace JFIT;
214 using namespace JGEOMETRY3D;
215
216 JEvent event(JMUONGANDALF);
217
218 JEvt out;
219
220 const buffer_type& data = input.data;
221
222 // select start values
223
224 JEvt in = input.in;
225
226 in.select(numberOfPrefits, qualitySorter);
227
228 if (!in.empty()) {
229 in.select(JHistory::is_event(in.begin()->getHistory()));
230 }
231
232 for (JEvt::const_iterator track = in.begin(); track != in.end(); ++track) {
233
234 const JRotation3D R (getDirection(*track));
235 const JLine1Z tz(getPosition (*track).rotate(R), track->getT());
236 JRange<double> Z_m;
237
238 if (track->getW(JSTART_LENGTH_METRES, 0.0) > 0.0) {
239 Z_m = JZRange(track->getW(JSTART_ZMIN_M) + ZMin_m,
240 track->getW(JSTART_ZMAX_M) + ZMax_m);
241 }
242
243 const JModel<JLine1Z> match(tz, roadWidth_m, T_ns, Z_m);
244
245 // hit selection based on start value
246
247 buffer_type buffer;
248
249 for (buffer_type::const_iterator i = data.begin(); i != data.end(); ++i) {
250
251 hit_type hit(*i);
252
253 hit.rotate(R);
254
255 if (match(hit)) {
256 buffer.push_back(hit);
257 }
258 }
259
260 // select first hit
261
262 sort(buffer.begin(), buffer.end(), JHitL0::compare);
263
264 buffer_type::iterator __end = unique(buffer.begin(), buffer.end(), equal_to<JDAQPMTIdentifier>());
265
266
267 const int NDF = distance(buffer.begin(), __end) - this->parameters.size();
268
269 if (NDF > 0) {
270
271 // set fit parameters
272
273 if (this->JMuonGandalfParameters_t::E_GeV > 0.1)
274 JRegressor_t::E_GeV = this->JMuonGandalfParameters_t::E_GeV;
275 else
276 JRegressor_t::E_GeV = track->getE();
277
278 const double chi2 = (*this)(JLine3Z(tz), buffer.begin(), __end);
279
280 // check error matrix
281
282 bool status = true;
283
284 for (size_t i = 0; i != this->V.size(); ++i) {
285 if (std::isnan(this->V(i,i)) || this->V(i,i) <= 0.0) {
286 status = false;
287 }
288 }
289
290 if (status) {
291
292 JTrack3D tb(this->value);
293
294 tb.rotate_back(R);
295
296 out.push_back(getFit(JHistory(track->getHistory(), event()), tb, getQuality(chi2), NDF));
297
298 // set additional values
299
300 const size_t N = this->V.size();
301
302 TMatrixDSym M(N);
303
304 for (size_t row = 0; row != N; ++row) {
305 for (size_t col = 0; col != N; ++col) {
306 M(row,col) = this->V(row,col);
307 }
308 }
309
310 const TMatrixDSymEigen E(M);
311 const TVectorD& Y = E.GetEigenValues();
312
313 out.rbegin()->setV(this->V.size(), this->V);
314
315 out.rbegin()->setW(track->getW());
316 out.rbegin()->setW(JGANDALF_BETA0_RAD, sqrt(this->error.getDX() * this->error.getDX() +
317 this->error.getDY() * this->error.getDY()));
318 out.rbegin()->setW(JGANDALF_BETA1_RAD, sqrt(this->error.getDX() * this->error.getDY()));
319 out.rbegin()->setW(JGANDALF_NUMBER_OF_HITS, distance(buffer.begin(), __end));
320 out.rbegin()->setW(JGANDALF_LAMBDA, Y.GetNrows() != 0 ? Y[0] : 0.0);
321 out.rbegin()->setW(JGANDALF_NUMBER_OF_ITERATIONS, this->numberOfIterations);
322 out.rbegin()->setW(JPP_COVERAGE_ORIENTATION, input.coverage.orientation);
323 out.rbegin()->setW(JPP_COVERAGE_POSITION, input.coverage.position);
324 }
325 }
326 }
327
328 {
329 for (JEvt::iterator i = out.begin(); i != out.end(); ++i) {
330
331 double Q = numeric_limits<double>::max();
332
333 for (JEvt::iterator p = out.begin(); p != out.end(); ++p) {
334 if (p != i) {
335 if (getDot(getDirection(*i), getDirection(*p)) <= cosLR) {
336 if (i->getQ() - p->getQ() < Q) {
337 Q = i->getQ() - p->getQ();
338 }
339 }
340 }
341 }
342
343 i->setW(JGANDALF_LIKELIHOOD_RATIO, Q);
344 }
345 }
346
347 // apply default sorter
348
349 sort(out.begin(), out.end(), qualitySorter);
350
351 copy(input.in.begin(), input.in.end(), back_inserter(out));
352
353 return out;
354 }
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
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
JPosition3D & rotate(const JRotation3D &R)
Rotate.
Range of values.
Definition JRange.hh:42
static const int JGANDALF_LIKELIHOOD_RATIO
likelihood ratio between this and best alternative fit see JRECONSTRUCTION::JMuonGandalf
static const int JSTART_ZMAX_M
end position of track see JRECONSTRUCTION::JMuonStart
static const int JGANDALF_LAMBDA
largest eigenvalue of error matrix see JRECONSTRUCTION::JMuonGandalf
static const int JPP_COVERAGE_POSITION
coverage of dynamic position calibration of this event
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 JSTART_ZMIN_M
start position of track see JRECONSTRUCTION::JMuonStart
static const int JGANDALF_BETA0_RAD
ile KM3NeT Data Definitions v3.6.2-4-g8b3df20 https://git.km3net.de/common/km3net-dataformat
static const int JGANDALF_NUMBER_OF_ITERATIONS
number of iterations see JRECONSTRUCTION::JMuonGandalf
static const int JPP_COVERAGE_ORIENTATION
coverage of dynamic orientation calibration of this event
static const int JGANDALF_BETA1_RAD
uncertainty on the reconstructed track direction from the error matrix [rad] see JRECONSTRUCTION::JMu...
static const int JGANDALF_NUMBER_OF_HITS
number of hits see JRECONSTRUCTION::JMuonGandalf
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
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.
double getDot(const JFit &first, const JFit &second)
Get dot product.
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.
JDirection3D getDirection(const JFit &fit)
Get direction.
Acoustic event fit.
Model for fit to acoustics data.
Transmission with position.
Definition JBillabong.cc:70
Auxiliary class to test history.
Definition JHistory.hh:157
double cosLR
maximal cosine space angle likelihood ratio test
Auxiliary data structure for sorting of hits.
Definition JHitL0.hh:85

◆ reset()

void JRECONSTRUCTION::JMuonGandalfParameters_t::reset ( )
inlineinherited

Reset fit parameters.

Definition at line 41 of file JMuonGandalfParameters_t.hh.

42 {
43 roadWidth_m = std::numeric_limits<double>::max();
44 R_Hz = 6.0e3;
46 TTS_ns = 2;
47 E_GeV = 1.0e3;
48 TMin_ns = -50.0;
49 TMax_ns = +450.0;
50 ZMin_m = 0.0;
51 ZMax_m = 0.0;
52 VMax_npe = 10.0;
53 cosLR = 0.7;
54 NMax = 1000;
55 }
double TMin_ns
minimal time w.r.t. Cherenkov hypothesis [ns]
double TMax_ns
maximal time w.r.t. Cherenkov hypothesis [ns]

◆ equals()

bool JRECONSTRUCTION::JMuonGandalfParameters_t::equals ( const JMuonGandalfParameters_t & parameters) const
inlineinherited

Equality.

Parameters
parametersfit parameters
Returns
true if equals; else false

Definition at line 63 of file JMuonGandalfParameters_t.hh.

64 {
65 return (this->roadWidth_m == parameters.roadWidth_m &&
66 this->R_Hz == parameters.R_Hz &&
67 this->numberOfPrefits == parameters.numberOfPrefits &&
68 this->TTS_ns == parameters.TTS_ns &&
69 this->E_GeV == parameters.E_GeV &&
70 this->TMin_ns == parameters.TMin_ns &&
71 this->TMax_ns == parameters.TMax_ns &&
72 this->ZMin_m == parameters.ZMin_m &&
73 this->ZMax_m == parameters.ZMax_m &&
74 this->VMax_npe == parameters.VMax_npe &&
75 this->cosLR == parameters.cosLR &&
76 this->NMax == parameters.NMax);
77 }

◆ ClassDef()

JRECONSTRUCTION::JMuonGandalfParameters_t::ClassDef ( JMuonGandalfParameters_t ,
3  )
inherited

Member Data Documentation

◆ pmtParameters

const JPMTParametersMap& JRECONSTRUCTION::JMuonGandalf::pmtParameters

Definition at line 356 of file JMuonGandalf.hh.

◆ roadWidth_m

double JRECONSTRUCTION::JMuonGandalfParameters_t::roadWidth_m
inherited

road width [m]

Definition at line 81 of file JMuonGandalfParameters_t.hh.

◆ R_Hz

double JRECONSTRUCTION::JMuonGandalfParameters_t::R_Hz
inherited

default rate [Hz]

Definition at line 82 of file JMuonGandalfParameters_t.hh.

◆ numberOfPrefits

size_t JRECONSTRUCTION::JMuonGandalfParameters_t::numberOfPrefits
inherited

number of prefits

Definition at line 83 of file JMuonGandalfParameters_t.hh.

◆ TTS_ns

double JRECONSTRUCTION::JMuonGandalfParameters_t::TTS_ns
inherited

transition-time spread [ns]

Definition at line 84 of file JMuonGandalfParameters_t.hh.

◆ E_GeV

double JRECONSTRUCTION::JMuonGandalfParameters_t::E_GeV
inherited

energy [GeV]

Definition at line 85 of file JMuonGandalfParameters_t.hh.

◆ TMin_ns

double JRECONSTRUCTION::JMuonGandalfParameters_t::TMin_ns
inherited

minimal time w.r.t. Cherenkov hypothesis [ns]

Definition at line 86 of file JMuonGandalfParameters_t.hh.

◆ TMax_ns

double JRECONSTRUCTION::JMuonGandalfParameters_t::TMax_ns
inherited

maximal time w.r.t. Cherenkov hypothesis [ns]

Definition at line 87 of file JMuonGandalfParameters_t.hh.

◆ ZMin_m

double JRECONSTRUCTION::JMuonGandalfParameters_t::ZMin_m
inherited

minimal z-positon [m]

Definition at line 88 of file JMuonGandalfParameters_t.hh.

◆ ZMax_m

double JRECONSTRUCTION::JMuonGandalfParameters_t::ZMax_m
inherited

maximal z-positon [m]

Definition at line 89 of file JMuonGandalfParameters_t.hh.

◆ VMax_npe

double JRECONSTRUCTION::JMuonGandalfParameters_t::VMax_npe
inherited

maximum number of of photo-electrons

Definition at line 90 of file JMuonGandalfParameters_t.hh.

◆ cosLR

double JRECONSTRUCTION::JMuonGandalfParameters_t::cosLR
inherited

maximal cosine space angle likelihood ratio test

Definition at line 91 of file JMuonGandalfParameters_t.hh.

◆ NMax

int JRECONSTRUCTION::JMuonGandalfParameters_t::NMax
inherited

maximum number of iterations

Definition at line 92 of file JMuonGandalfParameters_t.hh.


The documentation for this struct was generated from the following file: