Jpp 20.0.0-195-g190c9e876
the software that should make you happy
Loading...
Searching...
No Matches
JShower3EZRegressor.hh
Go to the documentation of this file.
1#ifndef __JFIT__JSHOWER3EZREGRESSOR__
2#define __JFIT__JSHOWER3EZREGRESSOR__
3
4#include <array>
5
10
14#include "JTools/JRange.hh"
15#include "JTools/JResult.hh"
19
23
24#include "JMath/JZero.hh"
25
26#include "JFit/JTimeRange.hh"
27#include "JFit/JPMTW0.hh"
28#include "JFit/JSimplex.hh"
29#include "JFit/JGandalf.hh"
30#include "JFit/JMEstimator.hh"
31#include "JFit/JRegressor.hh"
32#include "JFit/JShower3EZ.hh"
33#include "JFit/JFitToolkit.hh"
34#include "JFit/JLine3Z.hh"
35
36#include "Jeep/JMessage.hh"
37
38/**
39 * \file
40 * Data regression method for JFIT::JShower3EZ.
41 * \author mdejong, vcarretero
42 */
43
44
45namespace JFIT {
46
51
52 /**
53 * Constrain PMT angle to [0,pi].
54 *
55 * \param angle angle [rad]
56 * \return angle [rad]
57 */
58 inline double getPMTAngle(const double angle)
59 {
60 const double epsilon = 1.0e-6;
61 const JTOOLS::JRange<double> range(epsilon, JMATH::PI - epsilon);
62
63 return range.constrain(fabs(angle));
64 }
65
66
67 /**
68 * Function to constrain the versor and energy during the fit, to prevent unphysical values.
69 *
70 * \param value model (I/O)
71 */
72 inline void model(JShower3EZ& value)
73 {
74 using namespace std;
75
76 const double Emin = 0.1; // [GeV]
77
78 double Tx = value.getDX();
79 double Ty = value.getDY();
80
81 const double E = max(Emin, value.getE());
82 const double u = hypot(Tx, Ty);
83
84 if (u > 1.0) {
85 Tx /= u;
86 Ty /= u;
87 }
88
89 value = JShower3EZ(static_cast<const JPoint4D&>(value), JVersor3Z(Tx,Ty), E, value.getBy());
90 }
91
92
93 /**
94 * Template specialisation for storage of PDF tables.
95 */
96 template<>
98 {
105
111
112
113 static const int NUMBER_OF_PDFS = 2;
114
116
117 /**
118 * Default constructor.
119 */
122
123 /**
124 * Constructor
125 *
126 * The PDF file descriptor should contain the wild card character JPHYSICS::WILDCARD which
127 * will be replaced by the corresponding PDF types listed in JRegressorStorage<JShower3Z, JSimplex>::pdf_t.
128 *
129 * \param T_ns time range [ns]
130 * \param fileDescriptor PDF file descriptor
131 */
132
133 JRegressorStorage(const std::string& fileDescriptor, const JTimeRange& T_ns):
134 T_ns(T_ns)
135 {
136 using namespace std;
137 using namespace JPP;
138
139 const JPDF_t::JSupervisor supervisor(new JPDF_t::JDefaultResult(JMATH::zero));
140
141 for (int i = 0; i != NUMBER_OF_PDFS; ++i) {
142
143 const string file_name = getFilename(fileDescriptor, pdf_t[i]);
144
145 JPDF_t _pdf;
146 _pdf.load(file_name.c_str());
147
148 _pdf.setExceptionHandler(supervisor);
149
150 _npe[ i ] = JNPE_t(_pdf, T_ns);
151 }
152 // Add NPEs
153 for (int i = 1; i < NUMBER_OF_PDFS; i += 2) {
154
155 _npe[ i ].add(_npe[i-1]);
156
157 JNPE_t buffer;
158
159 _npe[i-1].swap(buffer);
160 }
161 }
162
163
164
165 /**
166 * Get NPEs.
167 *
168 * \return PDFs
169 */
170 const JNPEs_t& getNPE() const
171 {
172 return _npe;
173 }
174
175 /**
176 * PDF types.
177 */
178 static const JPDFType_t pdf_t[NUMBER_OF_PDFS];
179 JTimeRange T_ns; //!< Time window with respect to Cherenkov hypothesis [ns]
180
181 private:
182 JNPEs_t _npe; //!< PDFs
183 };
184
185 /**
186 * PDF types.
187 */
189 DIRECT_LIGHT_FROM_EMSHOWER,
190 SCATTERED_LIGHT_FROM_EMSHOWER
191 };
192
193 /**
194 * Regressor function object for JShower3EZ fit using JGandalf minimiser.
195 */
196 template<>
198 public JAbstractRegressor<JShower3EZ, JSimplex>,
199 public JRegressorStorage <JShower3EZ, JSimplex>
200 {
201 using JAbstractRegressor<JShower3EZ, JSimplex>::operator();
202
204
205 /**
206 * Default constructor
207 */
209 storage_type(),
210 npe(getNPE()),
211 estimator()
212 {}
213
214 /**
215 * Constructor.
216 *
217 * The PDF file descriptor should contain the wild card character JPHYSICS::WILDCARD which
218 * will be replaced by the PDF types listed in JRegressorStorage<JShower3EZ, JSimplex>::pdf_t.
219 *
220 * \param fileDescriptor PDF file descriptor
221 * \param T_ns time range [ns]
222 */
223 JRegressor(const std::string& fileDescriptor, const JTimeRange& T_ns) :
224 storage_type(fileDescriptor, T_ns),
225 npe(getNPE()),
226 estimator(new JMEstimatorNull())
227 {}
228
229 /**
230 * Constructor.
231 *
232 * \param storage PDF storage
233 */
234 JRegressor(const storage_type& storage) :
235 npe(storage.getNPE()),
236 estimator(new JMEstimatorNull())
237 {
238 T_ns = storage.T_ns;
239 }
240
241
242 /**
243 * Fit function.
244 * This method is used to determine the chi2 of given PMT with respect to shower hypothesis.
245 *
246 * \param shower shower
247 * \param pmt pmt
248 * \return chi2
249 */
250 double operator()(const JShower3EZ& shower, const JPMTW0& pmt) const
251 {
252 using namespace JPP;
253
254 JPosition3D D(pmt.getPosition());
255 JDirection3D U(pmt.getDirection());
256
257 D.sub(shower.getPosition());
258
259 const double z = D.getDot(shower.getDirection());
260 const double x = D.getX();
261 const double y = D.getY();
262 const double cd = z/D.getLength(); // cosine angle between shower direction and PMT position
263
264 U.rotate(JRotation3Z(-atan2(y,x))); // rotate PMT axis to x-z plane
265
266 const double theta = getPMTAngle(U.getTheta());
267 const double phi = getPMTAngle(U.getPhi());
268
269 JNPE_t::result_type H0 = getH0(pmt.getR()); // background hypothesis value for time integrated PDF.
270 JNPE_t::result_type H1 = getH1(D.getLength(), cd, theta, phi, shower.getE()); // signal hypothesis value for time integrated PDF.
271
272 H1 *= pmt.getQE();
273
274 if (get_value(H1) >= Vmax_npe) {
275 H1 *= Vmax_npe / get_value(H1);
276 }
277
278 H1 += H0; // now H1 is signal + background
279
280 const bool hit = pmt.getN() != 0;
281 const double u = getChi2(get_value(H1), hit) - getChi2(get_value(H0), hit); // - log likelihood ratio
282
283 return estimator->getRho(u);
284 }
285
286 /**
287 * Get background hypothesis value for time integrated PDF.
288 *
289 * \param R_Hz rate [Hz]
290 * \return hypothesis value
291 */
292 JNPE_t::result_type getH0(const double R_Hz) const
293 {
294 return JNPE_t::result_type(R_Hz * 1e-9 * T_ns.getLength());
295 }
296
297 /**
298 * Get signal hypothesis value for time integrated PDF.
299 *
300 * \param D PMT distance from shower [m]
301 * \param cd cosine angle between shower direction and PMT position
302 * \param theta PMT zenith angle [deg]
303 * \param phi PMT azimuth angle [deg]
304 * \param E shower energy [GeV]
305 * \return hypothesis value
306 */
308 const double cd,
309 const double theta,
310 const double phi,
311 const double E) const
312 {
314
315 for (int i = 0; i != NUMBER_OF_PDFS; ++i) {
316
317 if (!npe[i].empty() && D <= npe[i].getXmax()) {
318
319 try {
320
321 JNPE_t::result_type y1 = E * npe[i](std::max(D, npe[i].getXmin()), cd, theta, phi);
322
323 // safety measure
324
325 if(y1 < 0){
326 y1 = 0;
327 }
328
329 h1 += y1;
330
331 }
332 catch(JLANG::JException& error) {
333 ERROR(error << std::endl);
334 }
335 }
336 }
337
338 return h1;
339 }
340
341
342 static double Vmax_npe; //!< Maximal integral of PDF [npe]
343
344 const JNPEs_t& npe;
345
346 std::shared_ptr<JMEstimator> estimator; //!< M-Estimator function
347 };
348
349 /**
350 * Template specialisation for storage of PDF tables.
351 */
352 template<>
354 {
361
367
368
369 static const int NUMBER_OF_PDFS = 2;
370
372
373 /**
374 * Default constructor.
375 */
378
379 /**
380 * Parameterized constructor
381 *
382 * The PDF file descriptor should contain the wild card character JPHYSICS::WILDCARD which
383 * will be replaced by the corresponding PDF types listed in JRegressorStorage<JShower3Z, JGandalf>::pdf_t.
384 *
385 * \param fileDescriptor PDF file descriptor
386 * \param T_ns time range [ns]
387
388 */
389
390 JRegressorStorage(const std::string& fileDescriptor, const JTimeRange& T_ns):
391 T_ns(T_ns)
392 {
393 using namespace std;
394 using namespace JPP;
395
396 const JPDF_t::JSupervisor supervisor(new JPDF_t::JDefaultResult(JMATH::zero));
397
398 for (int i = 0; i != NUMBER_OF_PDFS; ++i) {
399
400 const string file_name = getFilename(fileDescriptor, pdf_t[i]);
401
402 JPDF_t _pdf;
403 _pdf.load(file_name.c_str());
404
405 _pdf.setExceptionHandler(supervisor);
406
407 _npe[i] = JNPE_t(_pdf, T_ns);
408
409 }
410
411 // Add PDFs
412 for (int i = 1; i < NUMBER_OF_PDFS; i += 2) {
413
414 _npe[ i ].add(_npe[i-1]);
415
416 JNPE_t buffer;
417
418 _npe[i-1].swap(buffer);
419 }
420 }
421
422
423 /**
424 * Get NPEs.
425 *
426 * \return PDFs
427 */
428 const JNPEs_t& getNPE() const
429 {
430 return _npe;
431 }
432
433 /**
434 * PDF types.
435 */
436 static const JPDFType_t pdf_t[NUMBER_OF_PDFS];
437 JTimeRange T_ns; //!< Time window with respect to Cherenkov hypothesis [ns]
438
439 private:
440 JNPEs_t _npe; //!< PDFs
441 };
442
443 /**
444 * PDF types.
445 */
447 DIRECT_LIGHT_FROM_EMSHOWER,
448 SCATTERED_LIGHT_FROM_EMSHOWER
449 };
450
451 /**
452 * Regressor function object for JShower3EZ fit using JGandalf minimiser.
453 */
454 template<>
456 public JAbstractRegressor<JShower3EZ, JGandalf>,
457 public JRegressorStorage <JShower3EZ, JGandalf>
458 {
459 using JAbstractRegressor<JShower3EZ, JGandalf>::operator();
460
461 typedef JRegressorStorage<JShower3EZ, JGandalf> storage_type;
462
463 /**
464 * Default constructor
465 */
466 JRegressor() :
467 storage_type(),
468 npe(getNPE()),
469 estimator()
470 {}
471
472 /**
473 * Constructor.
474 *
475 * The PDF file descriptor should contain the wild card character JPHYSICS::WILDCARD which
476 * will be replaced by the PDF types listed in JRegressorStorage<JShower3EZ, JSimplex>::pdf_t.
477 *
478 * \param fileDescriptor PDF file descriptor
479 * \param T_ns time range [ns]
480 */
481 JRegressor(const std::string& fileDescriptor, const JTimeRange& T_ns) :
482 storage_type(fileDescriptor, T_ns),
483 npe(getNPE()),
484 estimator(new JMEstimatorNull())
485 {}
486
487 /**
488 * Constructor.
489 *
490 * \param storage PDF storage
491 */
492 JRegressor(const storage_type& storage) :
493 npe(storage.getNPE()),
494 estimator(new JMEstimatorNull())
495 {
496 T_ns = storage.T_ns;
497 }
498
499
500 /**
501 * Fit function.
502 * This method is used to determine the chi2 of given PMT with respect to shower hypothesis.
503 *
504 * \param shower shower
505 * \param pmt pmt
506 * \return chi2
507 */
508 result_type operator()(const JShower3EZ& shower, const JPMTW0& pmt) const
509 {
510 using namespace JPP;
511 using namespace std;
512
513 JPosition3D D(pmt.getPosition());
514 JDirection3D U(pmt.getDirection());
515
516 D.sub(shower.getPosition());
517
518 const double x = D.getX();
519 const double y = D.getY();
520 const double d = D.getLength();
521 const double cd = D.getDot(shower.getDirection())/d; // cosine angle between shower direction and PMT position
522
523 U.rotate(JRotation3Z(-atan2(y,x))); // rotate PMT axis to x-z plane
524
525 const double theta = getPMTAngle(U.getTheta());
526 const double phi = getPMTAngle(U.getPhi());
527
528 JNPE_t::result_type H0 = getH0(pmt.getR()); // background hypothesis value for time integrated PDF.
529 JNPE_t::result_type H1 = getH1(d, cd, theta, phi, shower.getE()); // signal hypothesis value for time integrated PDF.
530
531 H1 *= pmt.getQE();
532
533 if (get_value(H1) >= Vmax_npe) {
534 H1 *= Vmax_npe / get_value(H1);
535 }
536
537 const double signal_npe = get_value(H1);
538
539 H1 += H0;
540
541 const double expectation = get_value(H1);
542
543 const bool hit = pmt.getN() != 0;
544 const double u = H1.getChi2(hit) - H0.getChi2(hit);
545
546 result_type result;
547
548 result.chi2 = estimator->getRho(u);
549
550 double energy_gradient = signal_npe/shower.getE(); // dP/dE
551
552 if (hit) {
553 energy_gradient *= -exp(-expectation)/(1-exp(-expectation)); // dchi2/d(H1), if !hit is 1
554 }
555
556 result.gradient = JShower3EZ(JPoint4D(JVector3D(0, // d(cos_th0)/d(x)
557 0, // d(cos_th0)/d(y)
558 0), // d(cos_th0)/d(z)
559 0.0), // d(cos_th0)/d(t)
560 JVersor3Z(x/d, // d(cos_th0)/d(dx)
561 y/d), // d(cos_th0)/d(dy)
562 energy_gradient); // d(chi2)/d(E)
563
564 result.gradient.mul(estimator->getPsi(u));
565
566 static_cast<JShower3Z&>(result.gradient).mul(H1.getDerivativeOfChi2(hit) - H0.getDerivativeOfChi2(hit)); // x d(chi2)/d(cos_th0)
567
568 return result;
569 }
570
571 /**
572 * Get background hypothesis value for time integrated PDF.
573 *
574 * \param R_Hz rate [Hz]
575 * \return hypothesis value
576 */
577 JNPE_t::result_type getH0(const double R_Hz) const
578 {
579 return JNPE_t::result_type(R_Hz * 1e-9 * T_ns.getLength(), 0.0);
580 }
581
582 /**
583 * Get signal hypothesis value for time integrated PDF.
584 *
585 * \param D PMT distance from shower [m]
586 * \param cd cosine angle between shower direction and PMT position
587 * \param theta PMT zenith angle [deg]
588 * \param phi PMT azimuth angle [deg]
589 * \param E shower energy [GeV]
590 * \return hypothesis value
591 */
592 JNPE_t::result_type getH1(const double D,
593 const double cd,
594 const double theta,
595 const double phi,
596 const double E) const
597 {
598 JNPE_t::result_type h1 = JMATH::zero;
599
600 for (int i = 0; i != NUMBER_OF_PDFS; ++i) {
601
602 if (!npe[i].empty() && D <= npe[i].getXmax()) {
603
604 try {
605
606 JNPE_t::result_type y1 = E * npe[i](std::max(D, npe[i].getXmin()), cd, theta, phi);
607
608 if (get_value(y1) > 0.0) {
609 h1 += y1;
610 }
611
612 }
613 catch(JLANG::JException& error) {
614 ERROR(error << std::endl);
615 }
616 }
617 }
618
619 return h1;
620 }
621
622
623 static double Vmax_npe; //!< Maximal integral of PDF [npe]
624
625 const JNPEs_t& npe;
626
627 std::shared_ptr<JMEstimator> estimator; //!< M-Estimator function
628 };
629
630
631
632 /**
633 * Template specialisation for storage of PDF tables.
634 */
635 template<>
637 {
644
650
651
652 static const int NUMBER_OF_PDFS = 2;
653
655
656 /**
657 * Default constructor.
658 */
661
662 /**
663 * Parameterized constructor
664 *
665 * The PDF file descriptor should contain the wild card character JPHYSICS::WILDCARD which
666 * will be replaced by the corresponding PDF types listed in JRegressorStorage<JShower3Z, JAbstractMinimiser>::pdf_t.
667 *
668 * \param fileDescriptor PDF file descriptor
669 * \param T_ns time range [ns]
670
671 */
672
673 JRegressorStorage(const std::string& fileDescriptor, const JTimeRange& T_ns):
674 T_ns(T_ns)
675 {
676 using namespace std;
677 using namespace JPP;
678
679 const JPDF_t::JSupervisor supervisor(new JPDF_t::JDefaultResult(JMATH::zero));
680
681 for (int i = 0; i != NUMBER_OF_PDFS; ++i) {
682
683 const string file_name = getFilename(fileDescriptor, pdf_t[i]);
684
685 JPDF_t _pdf;
686 _pdf.load(file_name.c_str());
687
688 _pdf.setExceptionHandler(supervisor);
689
690 _npe[i] = JNPE_t(_pdf, T_ns);
691
692 }
693
694 // Add PDFs
695 for (int i = 1; i < NUMBER_OF_PDFS; i += 2) {
696
697 _npe[i].add(_npe[i-1]);
698
699 JNPE_t buffer;
700
701 _npe[i-1].swap(buffer);
702 }
703 }
704
705
706
707 /**
708 * Get NPEs.
709 *
710 * \return PDFs
711 */
712 const JNPEs_t& getNPE() const
713 {
714 return _npe;
715 }
716
717 /**
718 * PDF types.
719 */
720 static const JPDFType_t pdf_t[NUMBER_OF_PDFS];
721 JTimeRange T_ns; //!< Time window with respect to Cherenkov hypothesis [ns]
722
723 private:
724 JNPEs_t _npe; //!< PDFs
725 };
726
727 /**
728 * PDF types.
729 */
731 DIRECT_LIGHT_FROM_EMSHOWER,
732 SCATTERED_LIGHT_FROM_EMSHOWER
733 };
734
735 /**
736 * Regressor function object for JShower3EZ fit using JGandalf minimiser.
737 */
738 template<>
740 public JAbstractRegressor<JShower3EZ, JAbstractMinimiser>,
741 public JRegressorStorage <JShower3EZ, JAbstractMinimiser>
742 {
744
746
747 /**
748 * Default constructor
749 */
750 JRegressor() :
751 storage_type(),
752 npe(getNPE()),
753 estimator()
754 {}
755
756 /**
757 * Constructor.
758 *
759 * The PDF file descriptor should contain the wild card character JPHYSICS::WILDCARD which
760 * will be replaced by the PDF types listed in JRegressorStorage<JShower3EZ, JSimplex>::pdf_t.
761 *
762 * \param fileDescriptor PDF file descriptor
763 * \param T_ns time range [ns]
764
765 */
766 JRegressor(const std::string& fileDescriptor, const JTimeRange& T_ns) :
767 storage_type(fileDescriptor, T_ns),
768 npe(getNPE()),
769 estimator(new JMEstimatorNull())
770 {}
771
772 /**
773 * Constructor.
774 *
775 * \param storage PDF storage
776 */
777 JRegressor(const storage_type& storage) :
778 npe(storage.getNPE()),
779 estimator(new JMEstimatorNull())
780 {
781 T_ns = storage.T_ns;
782 }
783
784 /**
785 * Fit function.
786 * This method is used to determine the chi2 of given PMT with respect to shower hypothesis.
787 *
788 * \param shower shower
789 * \param pmt pmt
790 * \return chi2
791 */
792 double operator()(const JShower3EZ& shower, const JPMTW0& pmt) const
793 {
794 using namespace JPP;
795
796 JPosition3D D(pmt.getPosition());
797 JDirection3D U(pmt.getDirection());
798
799 D.sub(shower.getPosition());
800
801 const double z = D.getDot(shower.getDirection());
802 const double x = D.getX();
803 const double y = D.getY();
804 const double cd = z/D.getLength(); // cosine angle between shower direction and PMT position
805
806 U.rotate(JRotation3Z(-atan2(y,x))); // rotate PMT axis to x-z plane
807
808 const double theta = getPMTAngle(U.getTheta());
809 const double phi = getPMTAngle(U.getPhi());
810
811 JNPE_t::result_type H0 = getH0(pmt.getR()); // background hypothesis value for time integrated PDF.
812 JNPE_t::result_type H1 = getH1(D.getLength(), cd, theta, phi, shower.getE()); // signal hypothesis value for time integrated PDF.
813
814 H1 *= pmt.getQE();
815
816 if (get_value(H1) >= Vmax_npe) {
817 H1 *= Vmax_npe / get_value(H1);
818 }
819
820 H1 += H0;
821
822 const bool hit = pmt.getN() != 0;
823 const double u = getChi2(get_value(H1), hit) - getChi2(get_value(H0), hit); // -log likelihood ratio
824
825 return estimator->getRho(u);
826 }
827
828 /**
829 * Get background hypothesis value for time integrated PDF.
830 *
831 * \param R_Hz rate [Hz]
832 * \return hypothesis value
833 */
834 JNPE_t::result_type getH0(const double R_Hz) const
835 {
836 return JNPE_t::result_type(R_Hz * 1e-9 * T_ns.getLength());
837 }
838
839 /**
840 * Get signal hypothesis value for time integrated PDF.
841 *
842 * \param D PMT distance from shower [m]
843 * \param cd cosine angle between shower direction and PMT position
844 * \param theta PMT zenith angle [deg]
845 * \param phi PMT azimuth angle [deg]
846 * \param E shower energy [GeV]
847 * \return hypothesis value
848 */
849 JNPE_t::result_type getH1(const double D,
850 const double cd,
851 const double theta,
852 const double phi,
853 const double E) const
854 {
855 JNPE_t::result_type h1 = JMATH::zero;
856
857 for (int i = 0; i != NUMBER_OF_PDFS; ++i) {
858
859 if (!npe[i].empty() && D <= npe[i].getXmax()) {
860
861 try {
862
863 JNPE_t::result_type y1 = E * npe[i](std::max(D, npe[i].getXmin()), cd, theta, phi);
864
865 // safety measure
866
867 if(y1 < 0){
868 y1 = 0;
869 }
870
871 h1 += y1;
872
873 }
874 catch(JLANG::JException& error) {
875 ERROR(error << std::endl);
876 }
877 }
878 }
879
880 return h1;
881 }
882
883 /**
884 * Get signal hypothesis value for time integrated PDF.
885 *
886 * \param shower shower
887 * \param pmt pmt
888 * \return hypothesis value
889 */
890 JNPE_t::result_type getH1(const JShower3EZ& shower, const JPMTW0& pmt) const
891 {
892 using namespace JPP;
893
894 JPosition3D D(pmt.getPosition());
895 JDirection3D U(pmt.getDirection());
896
897
898 const double z = D.getDot(shower.getDirection());
899 const double x = D.getX();
900 const double y = D.getY();
901 const double cd = z/D.getLength(); // cosine angle between shower direction and PMT position
902
903 U.rotate(JRotation3Z(-atan2(y,x))); // rotate PMT axis to x-z plane
904
905 const double theta = getPMTAngle(U.getTheta());
906 const double phi = getPMTAngle(U.getPhi());
907
908 JNPE_t::result_type H1 = getH1(D.getLength(), cd, theta, phi, 1.0); // signal hypothesis value for time integrated PDF. E=1 because it is linear with E.
909
910 H1 *= pmt.getQE();
911
912 if (get_value(H1) >= Vmax_npe) {
913 H1 *= Vmax_npe / get_value(H1);
914 }
915
916 return H1;
917 }
918
919 static double Vmax_npe; //!< Maximal integral of PDF [npe]
920
921 const JNPEs_t& npe;
922
923 std::shared_ptr<JMEstimator> estimator; //!< M-Estimator function
924 };
925
926 /**
927 * Default values.
928 */
929 double JRegressor<JShower3EZ, JSimplex>::Vmax_npe = std::numeric_limits<double>::max();
930 double JRegressor<JShower3EZ, JGandalf>::Vmax_npe = std::numeric_limits<double>::max();
931 double JRegressor<JShower3EZ, JAbstractMinimiser>::Vmax_npe = std::numeric_limits<double>::max();
932}
933
934#endif
Auxiliary methods to evaluate Poisson probabilities and chi2.
Various implementations of functional maps.
Maximum likelihood estimator (M-estimators).
General purpose messaging.
#define ERROR(A)
Definition JMessage.hh:66
Auxiliary methods for PDF calculations.
Numbering scheme for PDF types.
Physics constants.
Auxiliary class to define a range between two values.
General purpose data regression method.
This include file containes various data structures that can be used as specific return types for the...
Definition of zero value for any class.
Place holder for custom implementation.
Abstract minimiser.
Definition JRegressor.hh:27
Fit method based on the Levenberg-Marquardt method.
Definition JGandalf.hh:87
Data structure for vertex fit.
Definition JPoint4D.hh:24
Data structure for fit of straight line in positive z-direction with energy.
Definition JShower3EZ.hh:30
double getBy() const
Get bjorken y.
Definition JShower3EZ.hh:76
double getE() const
Get E.
Definition JShower3EZ.hh:86
Data structure for cascade in positive z-direction.
Definition JShower3Z.hh:36
const JVersor3Z & getDirection() const
Get direction.
Definition JVersor3Z.hh:81
Simple fit method based on Powell's algorithm, see reference: Numerical Recipes in C++,...
Definition JSimplex.hh:44
Data structure for direction in three dimensions.
JDirection3D & rotate(const JRotation3D &R)
Rotate.
const JDirection3D & getDirection() const
Get direction.
Data structure for position in three dimensions.
double getDot(const JAngle3D &angle) const
Get dot product.
const JPosition3D & getPosition() const
Get position.
Rotation around Z-axis.
Data structure for vector in three dimensions.
Definition JVector3D.hh:36
double getY() const
Get y position.
Definition JVector3D.hh:104
double getLength() const
Get length.
Definition JVector3D.hh:246
JVector3D & sub(const JVector3D &vector)
Subtract vector.
Definition JVector3D.hh:158
double getX() const
Get x position.
Definition JVector3D.hh:94
double getTheta() const
Get theta angle.
Definition JVersor3D.hh:128
double getPhi() const
Get phi angle.
Definition JVersor3D.hh:144
Data structure for normalised vector in positive z-direction.
Definition JVersor3Z.hh:41
double getDY() const
Get y direction.
Definition JVersor3Z.hh:158
double getDX() const
Get x direction.
Definition JVersor3Z.hh:147
General exception.
Definition JException.hh:24
Custom class for integrated values of the PDF of the arrival time of Cherenkov light.
Definition JNPETable.hh:46
Multi-dimensional PDF table for arrival time of Cherenkov light.
Definition JPDFTable.hh:44
void setExceptionHandler(const typename function_type::supervisor_type &supervisor)
Set the supervisor for handling of exceptions.
Range of values.
Definition JRange.hh:42
T constrain(argument_type x) const
Constrain value to range.
Definition JRange.hh:350
double getNPE(const Hit &hit)
Get true charge of hit.
Auxiliary classes and methods for linear and iterative data regression.
double getPMTAngle(const double angle)
Constrain PMT angle to [0,pi].
double getChi2(const double P)
Get chi2 corresponding to given probability.
void model(JModel_t &value)
Auxiliary function to constrain model during fit.
Definition JGandalf.hh:57
static const JZero zero
Function object to assign zero value.
Definition JZero.hh:105
static const double PI
Mathematical constants.
JPDFType_t
PDF types.
Definition JPDFTypes.hh:24
@ SCATTERED_LIGHT_FROM_EMSHOWER
scattered light from EM shower
Definition JPDFTypes.hh:38
@ DIRECT_LIGHT_FROM_EMSHOWER
direct light from EM shower
Definition JPDFTypes.hh:37
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
JResultEvaluator< JResult_t >::result_type get_value(const JResult_t &value)
Helper method to recursively evaluate a to function value.
Definition JResult.hh:998
Abstract class for global fit method.
Definition JRegressor.hh:79
Null M-estimator.
Auxiliary class for handling PMT geometry, rate and response.
Definition JPMTW0.hh:24
int getN() const
Get number of hits.
Definition JPMTW0.hh:82
double getR() const
Get rate.
Definition JPMTW0.hh:71
double getQE() const
Get relative quantum efficiency.
Definition JPMTW0.hh:60
JTOOLS::JMAPLIST< JTOOLS::JPolint0FunctionalMap, JTOOLS::JPolint0FunctionalMap, JTOOLS::JPolint0FunctionalGridMap, JTOOLS::JPolint0FunctionalGridMap >::maplist JPDFMaplist_t
JPHYSICS::JPDFTable< JFunction1D_t, JPDFMaplist_t > JPDF_t
JTimeRange T_ns
Time window with respect to Cherenkov hypothesis [ns].
JPHYSICS::JNPETable< double, double, JNPEMaplist_t > JNPE_t
JTOOLS::JMAPLIST< JTOOLS::JPolint0FunctionalMap, JTOOLS::JPolint0FunctionalMap, JTOOLS::JPolint0FunctionalGridMap, JTOOLS::JPolint0FunctionalGridMap >::maplist JNPEMaplist_t
JRegressorStorage(const std::string &fileDescriptor, const JTimeRange &T_ns)
Parameterized constructor.
JTimeRange T_ns
Time window with respect to Cherenkov hypothesis [ns].
std::array< JNPE_t, NUMBER_OF_PDFS > JNPEs_t
NPEs.
JTOOLS::JMAPLIST< JTOOLS::JPolint0FunctionalMap, JTOOLS::JPolint0FunctionalMap, JTOOLS::JPolint0FunctionalGridMap, JTOOLS::JPolint0FunctionalGridMap >::maplist JPDFMaplist_t
JPHYSICS::JPDFTable< JFunction1D_t, JPDFMaplist_t > JPDF_t
JRegressorStorage(const std::string &fileDescriptor, const JTimeRange &T_ns)
Parameterized constructor.
JTOOLS::JMAPLIST< JTOOLS::JPolint1FunctionalMap, JTOOLS::JPolint1FunctionalMapH, JTOOLS::JPolint1FunctionalGridMap, JTOOLS::JPolint1FunctionalGridMap >::maplist JNPEMaplist_t
JPHYSICS::JNPETable< double, double, JNPEMaplist_t > JNPE_t
Template specialisation for storage of PDF tables.
JPHYSICS::JPDFTable< JFunction1D_t, JPDFMaplist_t > JPDF_t
JTOOLS::JMAPLIST< JTOOLS::JPolint0FunctionalMap, JTOOLS::JPolint0FunctionalMap, JTOOLS::JPolint0FunctionalGridMap, JTOOLS::JPolint0FunctionalGridMap >::maplist JNPEMaplist_t
std::array< JNPE_t, NUMBER_OF_PDFS > JNPEs_t
NPEs.
JTOOLS::JMAPLIST< JTOOLS::JPolint0FunctionalMap, JTOOLS::JPolint0FunctionalMap, JTOOLS::JPolint0FunctionalGridMap, JTOOLS::JPolint0FunctionalGridMap >::maplist JPDFMaplist_t
JPHYSICS::JNPETable< double, double, JNPEMaplist_t > JNPE_t
JTimeRange T_ns
Time window with respect to Cherenkov hypothesis [ns].
JRegressorStorage(const std::string &fileDescriptor, const JTimeRange &T_ns)
Constructor.
Template data structure for storage of internal data.
JRegressor(const std::string &fileDescriptor, const JTimeRange &T_ns)
Constructor.
JRegressorStorage< JShower3EZ, JSimplex > storage_type
std::shared_ptr< JMEstimator > estimator
M-Estimator function.
static double Vmax_npe
Maximal integral of PDF [npe].
JNPE_t::result_type getH0(const double R_Hz) const
Get background hypothesis value for time integrated PDF.
JNPE_t::result_type getH1(const double D, const double cd, const double theta, const double phi, const double E) const
Get signal hypothesis value for time integrated PDF.
double operator()(const JShower3EZ &shower, const JPMTW0 &pmt) const
Fit function.
JRegressor(const storage_type &storage)
Constructor.
Template definition of a data regressor of given model.
Definition JRegressor.hh:70
void load(const char *file_name)
Load from input file.
Auxiliary class for recursive map list generation.
Definition JMapList.hh:109
Type definition of a zero degree polynomial interpolation based on a JGridMap implementation.
Type definition of a zero degree polynomial interpolation based on a JMap implementation.
Type definition of a 1st degree polynomial interpolation with result type double.
Type definition of a 1st degree polynomial interpolation based on a JGridMap implementation.
Type definition of a 1st degree polynomial interpolation based on a JMap implementation.
Type definition of a 1st degree polynomial interpolation based on a JMap implementation.