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

Auxiliary class to to determine muon energy. More...

#include <JMuonEnergy.hh>

Inheritance diagram for JRECONSTRUCTION::JMuonEnergy:
JRECONSTRUCTION::JMuonEnergyParameters_t JFIT::JRegressor< JModel_t, JMinimiser_t > TObject

Classes

struct  input_type
 Input data type. More...
 
struct  JResult
 Auxiliary class for energy estimation. More...
 

Public Types

typedef JRegressor< JEnergyJRegressor_t
 
typedef JModuleL0 module_type
 
typedef std::vector< module_typedetector_type
 

Public Member Functions

 JMuonEnergy (const JMuonEnergyParameters_t &parameters, const storage_type &storage, const JPMTParametersMap &pmtParameters, const JEnergyCorrection &correct, 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 JMuonEnergyParameters_t &parameters) const
 Equality.
 
 ClassDef (JMuonEnergyParameters_t, 2)
 

Public Attributes

const JPMTParametersMappmtParameters
 
const JEnergyCorrectioncorrect
 
double roadWidth_m
 road width [m]
 
double R_Hz
 default rate [Hz]
 
size_t numberOfPrefits
 number of prefits
 
double EMin_log
 minimal energy [log10(GeV)]
 
double EMax_log
 maximal energy [log10(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-position [m]
 
double resolution
 energy resolution [log10(GeV)]
 
int mestimator
 M-estimator (see JFIT::JMEstimator_t)
 

Detailed Description

Auxiliary class to to determine muon energy.

Definition at line 66 of file JMuonEnergy.hh.

Member Typedef Documentation

◆ JRegressor_t

◆ module_type

◆ detector_type

Constructor & Destructor Documentation

◆ JMuonEnergy()

JRECONSTRUCTION::JMuonEnergy::JMuonEnergy ( const JMuonEnergyParameters_t & parameters,
const storage_type & storage,
const JPMTParametersMap & pmtParameters,
const JEnergyCorrection & correct,
const int debug = 0 )
inline

Constructor.

Parameters
parametersparameters
storagestorage
pmtParametersPMT parameters
correctenergy correction
debugdebug

Definition at line 120 of file JMuonEnergy.hh.

124 :
125 JMuonEnergyParameters_t(parameters),
126 JRegressor_t (storage),
129 {
130 using namespace JPP;
131
132 if (this->getRmax() < roadWidth_m) {
133 roadWidth_m = this->getRmax();
134 }
135
136 JRegressor_t::debug = debug;
137
138 this->estimator.reset(getMEstimator(mestimator));
139 }
int debug
debug level
Definition JSirene.cc:74
const JPMTParametersMap & pmtParameters
const JEnergyCorrection & correct
JRegressor< JEnergy > JRegressor_t
JMEstimator * getMEstimator(const int type)
Get M-Estimator.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
int mestimator
M-estimator (see JFIT::JMEstimator_t)

Member Function Documentation

◆ getInput()

input_type JRECONSTRUCTION::JMuonEnergy::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 152 of file JMuonEnergy.hh.

157 {
158 using namespace std;
159 using namespace JTRIGGER;
160
161 input_type input(event.getDAQEventHeader(), in, coverage);
162
163 const JBuildL0 <JHitR0> buildL0;
165
166 const JDAQTimeslice timeslice(event, true);
167
168 JSuperFrame2D<JHit> buffer;
169
170 for (JDAQTimeslice::const_iterator i = timeslice.begin(); i != timeslice.end(); ++i) {
171
172 if (router.hasModule(i->getModuleID())) {
173
174 buffer(*i, router.getModule(i->getModuleID()));
175
176 buildL0(buffer, back_inserter(data[i->getModuleID()]));
177 }
178 }
179
180 for (const auto& module : router.getReference()) {
181 if (!module.empty()) {
182 input.data.push_back(module_type(module, summary.getSummaryFrame(module.getID(), R_Hz), data[module.getID()]));
183 }
184 }
185
186 return input;
187 }
bool hasModule(const JObjectID &id) const
Has module.
const JModule & getModule(const JObjectID &id) const
Get module parameters.
const JClass_t & getReference() const
Get reference to object.
Definition JReference.hh:38
const JDAQSummaryFrame & getSummaryFrame(const JDAQModuleIdentifier &module) const
Get summary frame.
2-dimensional frame with time calibrated data from one optical module.
const JDAQEventHeader & getDAQEventHeader() const
Get DAQ event header.
Auxiliary classes and methods for triggering.

◆ operator()()

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

Fit function.

Parameters
inputinput data
Returns
fit results

Definition at line 228 of file JMuonEnergy.hh.

229 {
230 using namespace std;
231 using namespace JPP;
232
233 JEvent event(JMUONENERGY);
234
235 JEvt out;
236
237 // select start values
238
239 JEvt in = input.in;
240
241 in.select(numberOfPrefits, qualitySorter);
242
243 if (!in.empty()) {
244 in.select(JHistory::is_event(in.begin()->getHistory()));
245 }
246
247 for (JEvt::const_iterator track = in.begin(); track != in.end(); ++track) {
248
249 JFit fit(*track);
250
251 // move track
252
253 if (fit.getW(JSTART_LENGTH_METRES, 0.0) > 0.0) {
254
255 fit.move(fit.getW(JSTART_ZMIN_M), getSpeedOfLight());
256
257 fit.setW(JSTART_ZMIN_M, 0.0);
258 fit.setW(JSTART_ZMAX_M, fit.getW(JSTART_LENGTH_METRES));
259 }
260
261 const JRotation3D R (getDirection(fit));
262 const JLine1Z tz(getPosition (fit).rotate(R), fit.getT());
263
264 double zmin = numeric_limits<double>::lowest();
265
266 if (fit.getW(JSTART_LENGTH_METRES, 0.0) > 0.0) {
267 zmin = this->ZMin_m;
268 }
269
271
272 for (const auto& module : input.data) {
273
274 JPosition3D pos(module->getPosition());
275
276 pos.transform(R, tz.getPosition());
277
278 if (pos.getX() <= roadWidth_m) {
279
280 const double z1 = pos.getZ() - pos.getX() / getTanThetaC();
281 const double t1 = tz .getT() + (pos.getZ() + pos.getX() * getKappaC()) * getInverseSpeedOfLight();
282
283 if (z1 >= zmin) {
284
285 for (size_t i = 0; i != module->size(); ++i) {
286
287 if (module.getStatus(i)) {
288
289 const struct {
290
291 bool operator()(const JHitR0& hit) const
292 {
293 return (hit.getPMT() == pmt && T_ns(hit.getT()));
294 }
295
296 const JTimeRange T_ns;
297 const size_t pmt;
298
299 } match = { T_ns + t1, i };
300
301 const JPMTIdentifier id(module->getID(), i);
302
304
305 const size_t ns = count_if(module.begin(), module.end(), match);
306 const double QE = wip.QE;
307 const double ps = getSurvivalProbability(wip);
308
309 JPMT pmt = module->getPMT(i);
310
311 pmt.transform(R, tz.getPosition());
312
313 const JNPE npe = this->getNPE(pmt, module.frame.getRate(i));
314
315 const JNPEHit hit(npe, ns, QE, ps);
316
317 DEBUG("hit: " << setw(8) << module->getID() << '.' << FILL(2,'0') << i << ' '
318 << FIXED(7,3) << hypot(pmt.getX(), pmt.getY()) << ' '
319 << FIXED(7,3) << module.frame.getRate(i) * 1.0e-3 << ' '
320 << SCIENTIFIC(9,3) << hit.getY0() << ' '
321 << SCIENTIFIC(9,3) << hit.getY1() << ' '
322 << SCIENTIFIC(9,3) << hit.getYA() << ' '
323 << SCIENTIFIC(9,3) << hit.getYB() << ' '
324 << setw(2) << hit.getN() << ' '
325 << FIXED(6,3) << hit.getQE() << ' '
326 << FIXED(6,3) << hit.getPS() << endl);
327
328 data.push_back(hit);
329 }
330 }
331 }
332 }
333 }
334
335 const int NDF = distance(data.begin(), data.end()) - 1;
336
337 if (NDF >= 0) {
338
339 // 5-point search between given limits
340
341 const int N = 5;
342
343 JResult result[N];
344
345 for (int i = 0; i != N; ++i) {
346 result[i].x = EMin_log + i * (EMax_log - EMin_log) / (N-1);
347 }
348
349 map<double, double> buffer;
350
351 do {
352
353 int j = 0;
354
355 for (int i = 0; i != N; ++i) {
356
357 if (!result[i]) {
358
359 const JEnergy x = result[i].x;
360 const double chi2 = (*this)(x, data.begin(), data.end());
361
362 result[i].chi2 = chi2;
363 buffer[chi2] = x.getE();
364 }
365
366 if (result[i].chi2 < result[j].chi2) {
367 j = i;
368 }
369 }
370
371
372 for (int i = 0; i != N; ++i) {
373 DEBUG(' ' << FIXED(5,2) << result[i].x << ' ' << FIXED(9,3) << result[i].chi2);
374 }
375 DEBUG(endl);
376
377 // squeeze range
378
379 switch (j) {
380
381 case 0:
382 result[4] = result[1];
383 result[2] = result[0];
384 result[0] = JResult(2*result[2].x - result[4].x);
385 break;
386
387 case 1:
388 result[4] = result[2];
389 result[2] = result[1];
390 break;
391
392 case 2:
393 result[0] = result[1];
394 result[4] = result[3];
395 break;
396
397 case 3:
398 result[0] = result[2];
399 result[2] = result[3];
400 break;
401
402 case 4:
403 result[0] = result[3];
404 result[2] = result[4];
405 result[4] = JResult(2*result[2].x - result[0].x);
406 break;
407 }
408
409 result[1] = JResult(0.5 * (result[0].x + result[2].x));
410 result[3] = JResult(0.5 * (result[2].x + result[4].x));
411
412 } while (result[4].x - result[0].x > resolution);
413
414
415 if (result[1].chi2 != result[3].chi2) {
416
417 result[2].x += 0.25 * (result[3].x - result[1].x) * (result[1].chi2 - result[3].chi2) / (result[1].chi2 + result[3].chi2 - 2*result[2].chi2);
418 result[2].chi2 = (*this)(result[2].x, data.begin(), data.end());
419
420 }
421
422 const double chi2 = result[2].chi2;
423 const double E = result[2].x.getE();
424
425 // calculate additional variables
426
427 double Emin = numeric_limits<double>::max();
428 double Emax = numeric_limits<double>::lowest();
429
430 for (map<double, double>::const_iterator i = buffer.begin(); i != buffer.end() && i->first <= chi2 + 1.0; ++i) {
431 if (i->second < Emin) { Emin = i->second; }
432 if (i->second > Emax) { Emax = i->second; }
433 }
434
435 const double mu_range = gWater(E); // range of a muon with the reconstructed energy
436
437 double noise_likelihood = 0.0; // log-likelihood of every hit being from K40
438 int number_of_hits = 0; // number of hits selected for JEnergy
439
440 for (vector<JNPEHit>::const_iterator i = data.begin(); i != data.end(); ++i) {
441 noise_likelihood += log10(getP(i->getY0(), i->getN())); // probability of getting the observed multiplicity with K40
442 number_of_hits += i->getN(); // hit multiplicity
443 }
444
445 fit.push_back(event());
446
447 // set corrected energy
448
449 fit.setE(pow(10.0, correct(log10(E))));
450
451 out.push_back(fit);
452
453 // set additional values
454
455 out.rbegin()->setW(JENERGY_ENERGY, E);
456 out.rbegin()->setW(JENERGY_CHI2, chi2);
457 out.rbegin()->setW(JENERGY_MUON_RANGE_METRES, mu_range);
458 out.rbegin()->setW(JENERGY_NOISE_LIKELIHOOD, noise_likelihood);
459 out.rbegin()->setW(JENERGY_NDF, NDF);
460 out.rbegin()->setW(JENERGY_NUMBER_OF_HITS, number_of_hits);
461 out.rbegin()->setW(JENERGY_MINIMAL_ENERGY, Emin);
462 out.rbegin()->setW(JENERGY_MAXIMAL_ENERGY, Emax);
463 out.rbegin()->setW(JPP_COVERAGE_ORIENTATION, input.coverage.orientation);
464 out.rbegin()->setW(JPP_COVERAGE_POSITION, input.coverage.position);
465 }
466 }
467
468 // apply default sorter
469
470 sort(out.begin(), out.end(), qualitySorter);
471
472 copy(input.in.begin(), input.in.end(), back_inserter(out));
473
474 return out;
475 }
#define DEBUG(A)
Message macros.
Definition JMessage.hh:62
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
const JPMTParameters & getPMTParameters(const JPMTIdentifier &id) const
Get PMT parameters.
Data structure for PMT parameters.
double QE
relative quantum efficiency
Data structure for PMT geometry, calibration and status.
Definition JPMT.hh:49
Data structure for fit of energy.
Data structure for fit of straight line paralel to z-axis.
Definition JLine1Z.hh:29
void transform(const JAxis3D &axis)
Transform axis to reference frame of given axis.
Definition JAxis3D.hh:359
Data structure for position in three dimensions.
double getY() const
Get y position.
Definition JVector3D.hh:104
double getX() const
Get x position.
Definition JVector3D.hh:94
JEvt operator()(const input_type &input)
Fit function.
Reduced data structure for L0 hit.
Definition JHitR0.hh:27
JPMT_t getPMT() const
Get PMT.
Definition JHitR0.hh:60
int getN() const
Get count.
Definition JHitR0.hh:71
double getT() const
Get calibrated time of hit.
static const int JSTART_ZMAX_M
end position of track see JRECONSTRUCTION::JMuonStart
static const int JENERGY_NDF
number of degrees of freedom see JRECONSTRUCTION::JMuonEnergy
static const int JENERGY_ENERGY
uncorrected energy [GeV] see JRECONSTRUCTION::JMuonEnergy
static const int JENERGY_NOISE_LIKELIHOOD
log likelihood of every hit being K40 see JRECONSTRUCTION::JMuonEnergy
static const int JENERGY_CHI2
chi2 see JRECONSTRUCTION::JMuonEnergy
static const int JENERGY_MUON_RANGE_METRES
range of a muon with the reconstructed energy [m] see JRECONSTRUCTION::JMuonEnergy
static const int JPP_COVERAGE_POSITION
coverage of dynamic position calibration of this event
static const int JENERGY_NUMBER_OF_HITS
number of hits see JRECONSTRUCTION::JMuonEnergy
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 JPP_COVERAGE_ORIENTATION
coverage of dynamic orientation calibration of this event
static const int JENERGY_MINIMAL_ENERGY
minimal energy [GeV] see JRECONSTRUCTION::JMuonEnergy
static const int JENERGY_MAXIMAL_ENERGY
maximal energy [GeV] see JRECONSTRUCTION::JMuonEnergy
double getNPE(const Hit &hit)
Get true charge of hit.
double getP(const double E1, const double E2, const double ED, const int M_min, const int M_max)
Get coincidence probability of two PMTs within one module due to random background.
double getSurvivalProbability(const JPMTParameters &parameters)
Get model dependent probability that a one photo-electron hit survives the simulation of the PMT assu...
T pow(const T &x, const double y)
Power .
Definition JMath.hh:97
double getKappaC()
Get average R-dependence of arrival time of Cherenkov light (a.k.a.
const double getInverseSpeedOfLight()
Get inverse speed of light.
static const JGeaneWater gWater
Function object for energy loss of muon in sea water.
Definition JGeane.hh:381
double getTanThetaC()
Get average tangent of Cherenkov angle of water corresponding to group velocity.
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.
return result
Definition JPolint.hh:862
int j
Definition JPolint.hh:801
Auxiliary data structure for sequence of same character.
Definition JManip.hh:330
Auxiliary data structure for floating point format specification.
Definition JManip.hh:448
Acoustic event fit.
Acoustic single fit.
Auxiliary class to test history.
Definition JHistory.hh:157
Auxiliary class for simultaneously handling light yields and response of PMT.
Definition JNPEHit.hh:21
Auxiliary class for handling various light yields.
Definition JNPE.hh:31
double resolution
energy resolution [log10(GeV)]
double EMin_log
minimal energy [log10(GeV)]
double EMax_log
maximal energy [log10(GeV)]
Auxiliary data structure for floating point format specification.
Definition JManip.hh:488

◆ reset()

void JRECONSTRUCTION::JMuonEnergyParameters_t::reset ( )
inlineinherited

Reset fit parameters.

Definition at line 44 of file JMuonEnergyParameters_t.hh.

45 {
46 roadWidth_m = std::numeric_limits<double>::max();
47 R_Hz = 6.0e3;
49 EMin_log = 1.0;
50 EMax_log = 8.0;
51 TMin_ns = -50.0;
52 TMax_ns = +450.0;
53 ZMin_m = std::numeric_limits<double>::lowest();
54 resolution = 0.01;
56 }
@ EM_NORMAL
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::JMuonEnergyParameters_t::equals ( const JMuonEnergyParameters_t & parameters) const
inlineinherited

Equality.

Parameters
parametersfit parameters
Returns
true if equals; else false

Definition at line 64 of file JMuonEnergyParameters_t.hh.

65 {
66 return (this->roadWidth_m == parameters.roadWidth_m &&
67 this->R_Hz == parameters.R_Hz &&
68 this->numberOfPrefits == parameters.numberOfPrefits &&
69 this->EMin_log == parameters.EMin_log &&
70 this->EMax_log == parameters.EMax_log &&
71 this->TMin_ns == parameters.TMin_ns &&
72 this->TMax_ns == parameters.TMax_ns &&
73 this->ZMin_m == parameters.ZMin_m &&
74 this->resolution == parameters.resolution &&
75 this->mestimator == parameters.mestimator);
76 }

◆ ClassDef()

JRECONSTRUCTION::JMuonEnergyParameters_t::ClassDef ( JMuonEnergyParameters_t ,
2  )
inherited

Member Data Documentation

◆ pmtParameters

const JPMTParametersMap& JRECONSTRUCTION::JMuonEnergy::pmtParameters

Definition at line 477 of file JMuonEnergy.hh.

◆ correct

const JEnergyCorrection& JRECONSTRUCTION::JMuonEnergy::correct

Definition at line 478 of file JMuonEnergy.hh.

◆ roadWidth_m

double JRECONSTRUCTION::JMuonEnergyParameters_t::roadWidth_m
inherited

road width [m]

Definition at line 80 of file JMuonEnergyParameters_t.hh.

◆ R_Hz

double JRECONSTRUCTION::JMuonEnergyParameters_t::R_Hz
inherited

default rate [Hz]

Definition at line 81 of file JMuonEnergyParameters_t.hh.

◆ numberOfPrefits

size_t JRECONSTRUCTION::JMuonEnergyParameters_t::numberOfPrefits
inherited

number of prefits

Definition at line 82 of file JMuonEnergyParameters_t.hh.

◆ EMin_log

double JRECONSTRUCTION::JMuonEnergyParameters_t::EMin_log
inherited

minimal energy [log10(GeV)]

Definition at line 83 of file JMuonEnergyParameters_t.hh.

◆ EMax_log

double JRECONSTRUCTION::JMuonEnergyParameters_t::EMax_log
inherited

maximal energy [log10(GeV)]

Definition at line 84 of file JMuonEnergyParameters_t.hh.

◆ TMin_ns

double JRECONSTRUCTION::JMuonEnergyParameters_t::TMin_ns
inherited

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

Definition at line 85 of file JMuonEnergyParameters_t.hh.

◆ TMax_ns

double JRECONSTRUCTION::JMuonEnergyParameters_t::TMax_ns
inherited

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

Definition at line 86 of file JMuonEnergyParameters_t.hh.

◆ ZMin_m

double JRECONSTRUCTION::JMuonEnergyParameters_t::ZMin_m
inherited

minimal z-position [m]

Definition at line 87 of file JMuonEnergyParameters_t.hh.

◆ resolution

double JRECONSTRUCTION::JMuonEnergyParameters_t::resolution
inherited

energy resolution [log10(GeV)]

Definition at line 88 of file JMuonEnergyParameters_t.hh.

◆ mestimator

int JRECONSTRUCTION::JMuonEnergyParameters_t::mestimator
inherited

M-estimator (see JFIT::JMEstimator_t)

Definition at line 89 of file JMuonEnergyParameters_t.hh.


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