Jpp test-rotations-old-57-g407471f53
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 void model(JShower3EZ& value)
73 {
74 using namespace std;
75
76
77 double Tx = value.getDX();
78 double Ty = value.getDY();
79 double E = max(0.0,value.getE());
80 const double u = hypot(Tx, Ty);
81
82 if (u > 1.0) {
83 Tx /= u;
84 Ty /= u;
85 }
86
87 value = JShower3EZ(static_cast<const JPoint4D&>(value), JVersor3Z(Tx,Ty), E, value.getBy());
88
89 }
90
91 /**
92 * Template specialisation for storage of PDF tables.
93 */
94 template<>
96 {
103
109
110
111 static const int NUMBER_OF_PDFS = 2;
112
114
115 /**
116 * Default constructor.
117 */
120
121 /**
122 * Constructor
123 *
124 * The PDF file descriptor should contain the wild card character JPHYSICS::WILDCARD which
125 * will be replaced by the corresponding PDF types listed in JRegressorStorage<JShower3Z, JSimplex>::pdf_t.
126 *
127 * \param T_ns time range [ns]
128 * \param fileDescriptor PDF file descriptor
129 */
130
131 JRegressorStorage(const std::string& fileDescriptor, const JTimeRange& T_ns):
132 T_ns(T_ns)
133 {
134 using namespace std;
135 using namespace JPP;
136
137 const JPDF_t::JSupervisor supervisor(new JPDF_t::JDefaultResult(JMATH::zero));
138
139 for (int i = 0; i != NUMBER_OF_PDFS; ++i) {
140
141 const string file_name = getFilename(fileDescriptor, pdf_t[i]);
142
143 JPDF_t _pdf;
144 _pdf.load(file_name.c_str());
145
146 _pdf.setExceptionHandler(supervisor);
147
148 _npe[ i ] = JNPE_t(_pdf, T_ns);
149 }
150 // Add NPEs
151 for (int i = 1; i < NUMBER_OF_PDFS; i += 2) {
152
153 _npe[ i ].add(_npe[i-1]);
154
155 JNPE_t buffer;
156
157 _npe[i-1].swap(buffer);
158 }
159 }
160
161
162
163 /**
164 * Get NPEs.
165 *
166 * \return PDFs
167 */
168 const JNPEs_t& getNPE() const
169 {
170 return _npe;
171 }
172
173 /**
174 * PDF types.
175 */
176 static const JPDFType_t pdf_t[NUMBER_OF_PDFS];
177 JTimeRange T_ns; //!< Time window with respect to Cherenkov hypothesis [ns]
178
179 private:
180 JNPEs_t _npe; //!< PDFs
181 };
182
183 /**
184 * PDF types.
185 */
187 DIRECT_LIGHT_FROM_EMSHOWER,
188 SCATTERED_LIGHT_FROM_EMSHOWER
189 };
190
191 /**
192 * Regressor function object for JShower3EZ fit using JGandalf minimiser.
193 */
194 template<>
196 public JAbstractRegressor<JShower3EZ, JSimplex>,
197 public JRegressorStorage <JShower3EZ, JSimplex>
198 {
199 using JAbstractRegressor<JShower3EZ, JSimplex>::operator();
200
202
203 /**
204 * Default constructor
205 */
207 storage_type(),
208 npe(getNPE()),
209 estimator()
210 {}
211
212 /**
213 * Constructor.
214 *
215 * The PDF file descriptor should contain the wild card character JPHYSICS::WILDCARD which
216 * will be replaced by the PDF types listed in JRegressorStorage<JShower3EZ, JSimplex>::pdf_t.
217 *
218 * \param fileDescriptor PDF file descriptor
219 */
220 JRegressor(const std::string& fileDescriptor, const JTimeRange& T_ns) :
221 storage_type(fileDescriptor, T_ns),
222 npe(getNPE()),
223 estimator(new JMEstimatorNull())
224 {}
225
226 /**
227 * Constructor.
228 *
229 * \param storage PDF storage
230 */
231 JRegressor(const storage_type& storage) :
232 npe(storage.getNPE()),
233 estimator(new JMEstimatorNull())
234 {
235 T_ns = storage.T_ns;
236 }
237
238
239 /**
240 * Fit function.
241 * This method is used to determine the chi2 of given PMT with respect to shower hypothesis.
242 *
243 * \param shower shower
244 * \param pmt pmt
245 * \return chi2
246 */
247 double operator()(const JShower3EZ& shower, const JPMTW0& pmt) const
248 {
249 using namespace JPP;
250
251 JPosition3D D(pmt.getPosition());
252 JDirection3D U(pmt.getDirection());
253
254 D.sub(shower.getPosition());
255
256 const double z = D.getDot(shower.getDirection());
257 const double x = D.getX();
258 const double y = D.getY();
259 const double cd = z/D.getLength(); // cosine angle between shower direction and PMT position
260
261 U.rotate(JRotation3Z(-atan2(y,x))); // rotate PMT axis to x-z plane
262
263 const double theta = getPMTAngle(U.getTheta());
264 const double phi = getPMTAngle(U.getPhi());
265
266 JNPE_t::result_type H0 = getH0(pmt.getR()); // background hypothesis value for time integrated PDF.
267 JNPE_t::result_type H1 = getH1(D.getLength(), cd, theta, phi, shower.getE()); // signal hypothesis value for time integrated PDF.
268
269 if (get_value(H1) >= Vmax_npe) {
270 H1 *= Vmax_npe / get_value(H1);
271 }
272
273 H1 += H0; // now H1 is signal + background
274
275 const bool hit = pmt.getN() != 0;
276 const double u = getChi2(get_value(H1), hit) - getChi2(get_value(H0), hit); // - log likelihood ratio
277
278 return estimator->getRho(u);
279 }
280
281 /**
282 * Get background hypothesis value for time integrated PDF.
283 *
284 * \param R_Hz rate [Hz]
285 * \return hypothesis value
286 */
287 JNPE_t::result_type getH0(const double R_Hz) const
288 {
289 return JNPE_t::result_type(R_Hz * 1e-9 * T_ns.getLength());
290 }
291
292 /**
293 * Get signal hypothesis value for time integrated PDF.
294 *
295 * \param D PMT distance from shower [m]
296 * \param cd cosine angle between shower direction and PMT position
297 * \param theta PMT zenith angle [deg]
298 * \param phi PMT azimuth angle [deg]
299 * \param E shower energy [GeV]
300 * \return hypothesis value
301 */
303 const double cd,
304 const double theta,
305 const double phi,
306 const double E) const
307 {
309
310 for (int i = 0; i != NUMBER_OF_PDFS; ++i) {
311
312 if (!npe[i].empty() && D <= npe[i].getXmax()) {
313
314 try {
315
316 JNPE_t::result_type y1 = E * npe[i](std::max(D, npe[i].getXmin()), cd, theta, phi);
317
318 // safety measure
319
320 if(y1 < 0){
321 y1 = 0;
322 }
323
324 h1 += y1;
325
326 }
327 catch(JLANG::JException& error) {
328 ERROR(error << std::endl);
329 }
330 }
331 }
332
333 return h1;
334 }
335
336
337 static double Vmax_npe; //!< Maximal integral of PDF [npe]
338
339 const JNPEs_t& npe;
340
341 std::shared_ptr<JMEstimator> estimator; //!< M-Estimator function
342 };
343
344 /**
345 * Template specialisation for storage of PDF tables.
346 */
347 template<>
349 {
356
362
363
364 static const int NUMBER_OF_PDFS = 2;
365
367
368 /**
369 * Default constructor.
370 */
373
374 /**
375 * Parameterized constructor
376 *
377 * The PDF file descriptor should contain the wild card character JPHYSICS::WILDCARD which
378 * will be replaced by the corresponding PDF types listed in JRegressorStorage<JShower3Z, JGandalf>::pdf_t.
379 *
380 * \param fileDescriptor PDF file descriptor
381 * \param T_ns time range [ns]
382
383 */
384
385 JRegressorStorage(const std::string& fileDescriptor, const JTimeRange& T_ns):
386 T_ns(T_ns)
387 {
388 using namespace std;
389 using namespace JPP;
390
391 const JPDF_t::JSupervisor supervisor(new JPDF_t::JDefaultResult(JMATH::zero));
392
393 for (int i = 0; i != NUMBER_OF_PDFS; ++i) {
394
395 const string file_name = getFilename(fileDescriptor, pdf_t[i]);
396
397 JPDF_t _pdf;
398 _pdf.load(file_name.c_str());
399
400 _pdf.setExceptionHandler(supervisor);
401
402 _npe[i] = JNPE_t(_pdf, T_ns);
403
404 }
405
406 // Add PDFs
407 for (int i = 1; i < NUMBER_OF_PDFS; i += 2) {
408
409 _npe[ i ].add(_npe[i-1]);
410
411 JNPE_t buffer;
412
413 _npe[i-1].swap(buffer);
414 }
415 }
416
417
418 /**
419 * Get NPEs.
420 *
421 * \return PDFs
422 */
423 const JNPEs_t& getNPE() const
424 {
425 return _npe;
426 }
427
428 /**
429 * PDF types.
430 */
431 static const JPDFType_t pdf_t[NUMBER_OF_PDFS];
432 JTimeRange T_ns; //!< Time window with respect to Cherenkov hypothesis [ns]
433
434 private:
435 JNPEs_t _npe; //!< PDFs
436 };
437
438 /**
439 * PDF types.
440 */
442 DIRECT_LIGHT_FROM_EMSHOWER,
443 SCATTERED_LIGHT_FROM_EMSHOWER
444 };
445
446 /**
447 * Regressor function object for JShower3EZ fit using JGandalf minimiser.
448 */
449 template<>
451 public JAbstractRegressor<JShower3EZ, JGandalf>,
452 public JRegressorStorage <JShower3EZ, JGandalf>
453 {
454 using JAbstractRegressor<JShower3EZ, JGandalf>::operator();
455
456 typedef JRegressorStorage<JShower3EZ, JGandalf> storage_type;
457
458 /**
459 * Default constructor
460 */
461 JRegressor() :
462 storage_type(),
463 npe(getNPE()),
464 estimator()
465 {}
466
467 /**
468 * Constructor.
469 *
470 * The PDF file descriptor should contain the wild card character JPHYSICS::WILDCARD which
471 * will be replaced by the PDF types listed in JRegressorStorage<JShower3EZ, JSimplex>::pdf_t.
472 *
473 * \param fileDescriptor PDF file descriptor
474 * \param T_ns time range [ns]
475 */
476 JRegressor(const std::string& fileDescriptor, const JTimeRange& T_ns) :
477 storage_type(fileDescriptor, T_ns),
478 npe(getNPE()),
479 estimator(new JMEstimatorNull())
480 {}
481
482 /**
483 * Constructor.
484 *
485 * \param storage PDF storage
486 */
487 JRegressor(const storage_type& storage) :
488 npe(storage.getNPE()),
489 estimator(new JMEstimatorNull())
490 {
491 T_ns = storage.T_ns;
492 }
493
494
495 /**
496 * Fit function.
497 * This method is used to determine the chi2 of given PMT with respect to shower hypothesis.
498 *
499 * \param shower shower
500 * \param pmt pmt
501 * \return chi2
502 */
503 result_type operator()(const JShower3EZ& shower, const JPMTW0& pmt) const
504 {
505 using namespace JPP;
506 using namespace std;
507
508 JPosition3D D(pmt.getPosition());
509 JDirection3D U(pmt.getDirection());
510
511 D.sub(shower.getPosition());
512
513 const double x = D.getX();
514 const double y = D.getY();
515 const double d = D.getLength();
516 const double cd = D.getDot(shower.getDirection())/d; // cosine angle between shower direction and PMT position
517
518 U.rotate(JRotation3Z(-atan2(y,x))); // rotate PMT axis to x-z plane
519
520 const double theta = getPMTAngle(U.getTheta());
521 const double phi = getPMTAngle(U.getPhi());
522
523 JNPE_t::result_type H0 = getH0(pmt.getR()); // background hypothesis value for time integrated PDF.
524 JNPE_t::result_type H1 = getH1(d, cd, theta, phi, shower.getE()); // signal hypothesis value for time integrated PDF.
525
526 if (get_value(H1) >= Vmax_npe) {
527 H1 *= Vmax_npe / get_value(H1);
528 }
529
530 double signal_npe = get_value(H1);
531
532 H1 += H0; // now H1 is signal + background
533
534 double expectation = get_value(H1);
535
536 const bool hit = pmt.getN() != 0;
537 const double u = H1.getChi2(hit) - H0.getChi2(hit);
538
539 result_type result;
540
541 result.chi2 = estimator->getRho(u);
542
543 double energy_gradient = signal_npe/shower.getE(); // dP/dE
544 if(hit) energy_gradient *= -exp(-expectation)/(1-exp(-expectation)); //dchi2/d(H1), if !hit is 1
545
546 result.gradient = JShower3EZ(JPoint4D(JVector3D(0, // d(cos_th0)/d(x)
547 0, // d(cos_th0)/d(y)
548 0), // d(cos_th0)/d(z)
549 0.0), // d(cos_th0)/d(t)
550 JVersor3Z(x/d, // d(cos_th0)/d(dx)
551 y/d), // d(cos_th0)/d(dy)
552 energy_gradient); // d(chi2)/d(E)
553
554 result.gradient.mul(estimator->getPsi(u));
555 static_cast<JShower3Z&>(result.gradient).mul(H1.getDerivativeOfChi2(hit) - H0.getDerivativeOfChi2(hit)); // x d(chi2)/d(cos_th0)
556
557 return result;
558 }
559
560 /**
561 * Get background hypothesis value for time integrated PDF.
562 *
563 * \param R_Hz rate [Hz]
564 * \return hypothesis value
565 */
566 JNPE_t::result_type getH0(const double R_Hz) const
567 {
568 return JNPE_t::result_type(R_Hz * 1e-9 * T_ns.getLength(), 0.0);
569 }
570
571 /**
572 * Get signal hypothesis value for time integrated PDF.
573 *
574 * \param D PMT distance from shower [m]
575 * \param cd cosine angle between shower direction and PMT position
576 * \param theta PMT zenith angle [deg]
577 * \param phi PMT azimuth angle [deg]
578 * \param E shower energy [GeV]
579 * \return hypothesis value
580 */
581 JNPE_t::result_type getH1(const double D,
582 const double cd,
583 const double theta,
584 const double phi,
585 const double E) const
586 {
587 JNPE_t::result_type h1 = JMATH::zero;
588
589 for (int i = 0; i != NUMBER_OF_PDFS; ++i) {
590
591 if (!npe[i].empty() && D <= npe[i].getXmax()) {
592
593 try {
594
595 JNPE_t::result_type y1 = E * npe[i](std::max(D, npe[i].getXmin()), cd, theta, phi);
596
597 if (get_value(y1) > 0.0) {
598 h1 += y1;
599 }
600
601 }
602 catch(JLANG::JException& error) {
603 ERROR(error << std::endl);
604 }
605 }
606 }
607
608 return h1;
609 }
610
611
612 static double Vmax_npe; //!< Maximal integral of PDF [npe]
613
614 const JNPEs_t& npe;
615
616 std::shared_ptr<JMEstimator> estimator; //!< M-Estimator function
617 };
618
619
620
621 /**
622 * Template specialisation for storage of PDF tables.
623 */
624 template<>
626 {
633
639
640
641 static const int NUMBER_OF_PDFS = 2;
642
644
645 /**
646 * Default constructor.
647 */
650
651 /**
652 * Parameterized constructor
653 *
654 * The PDF file descriptor should contain the wild card character JPHYSICS::WILDCARD which
655 * will be replaced by the corresponding PDF types listed in JRegressorStorage<JShower3Z, JAbstractMinimiser>::pdf_t.
656 *
657 * \param fileDescriptor PDF file descriptor
658 * \param T_ns time range [ns]
659
660 */
661
662 JRegressorStorage(const std::string& fileDescriptor, const JTimeRange& T_ns):
663 T_ns(T_ns)
664 {
665 using namespace std;
666 using namespace JPP;
667
668 const JPDF_t::JSupervisor supervisor(new JPDF_t::JDefaultResult(JMATH::zero));
669
670 for (int i = 0; i != NUMBER_OF_PDFS; ++i) {
671
672 const string file_name = getFilename(fileDescriptor, pdf_t[i]);
673
674 JPDF_t _pdf;
675 _pdf.load(file_name.c_str());
676
677 _pdf.setExceptionHandler(supervisor);
678
679 _npe[i] = JNPE_t(_pdf, T_ns);
680
681 }
682
683 // Add PDFs
684 for (int i = 1; i < NUMBER_OF_PDFS; i += 2) {
685
686 _npe[i].add(_npe[i-1]);
687
688 JNPE_t buffer;
689
690 _npe[i-1].swap(buffer);
691 }
692 }
693
694
695
696 /**
697 * Get NPEs.
698 *
699 * \return PDFs
700 */
701 const JNPEs_t& getNPE() const
702 {
703 return _npe;
704 }
705
706 /**
707 * PDF types.
708 */
709 static const JPDFType_t pdf_t[NUMBER_OF_PDFS];
710 JTimeRange T_ns; //!< Time window with respect to Cherenkov hypothesis [ns]
711
712 private:
713 JNPEs_t _npe; //!< PDFs
714 };
715
716 /**
717 * PDF types.
718 */
720 DIRECT_LIGHT_FROM_EMSHOWER,
721 SCATTERED_LIGHT_FROM_EMSHOWER
722 };
723
724 /**
725 * Regressor function object for JShower3EZ fit using JGandalf minimiser.
726 */
727 template<>
729 public JAbstractRegressor<JShower3EZ, JAbstractMinimiser>,
730 public JRegressorStorage <JShower3EZ, JAbstractMinimiser>
731 {
733
735
736 /**
737 * Default constructor
738 */
739 JRegressor() :
740 storage_type(),
741 npe(getNPE()),
742 estimator()
743 {}
744
745 /**
746 * Constructor.
747 *
748 * The PDF file descriptor should contain the wild card character JPHYSICS::WILDCARD which
749 * will be replaced by the PDF types listed in JRegressorStorage<JShower3EZ, JSimplex>::pdf_t.
750 *
751 * \param fileDescriptor PDF file descriptor
752 * \param T_ns time range [ns]
753
754 */
755 JRegressor(const std::string& fileDescriptor, const JTimeRange& T_ns) :
756 storage_type(fileDescriptor, T_ns),
757 npe(getNPE()),
758 estimator(new JMEstimatorNull())
759 {}
760
761 /**
762 * Constructor.
763 *
764 * \param storage PDF storage
765 */
766 JRegressor(const storage_type& storage) :
767 npe(storage.getNPE()),
768 estimator(new JMEstimatorNull())
769 {
770 T_ns = storage.T_ns;
771 }
772
773 /**
774 * Fit function.
775 * This method is used to determine the chi2 of given PMT with respect to shower hypothesis.
776 *
777 * \param shower shower
778 * \param pmt pmt
779 * \return chi2
780 */
781 double operator()(const JShower3EZ& shower, const JPMTW0& pmt) const
782 {
783 using namespace JPP;
784
785 JPosition3D D(pmt.getPosition());
786 JDirection3D U(pmt.getDirection());
787
788 D.sub(shower.getPosition());
789
790 const double z = D.getDot(shower.getDirection());
791 const double x = D.getX();
792 const double y = D.getY();
793 const double cd = z/D.getLength(); // cosine angle between shower direction and PMT position
794
795 U.rotate(JRotation3Z(-atan2(y,x))); // rotate PMT axis to x-z plane
796
797 const double theta = getPMTAngle(U.getTheta());
798 const double phi = getPMTAngle(U.getPhi());
799
800 JNPE_t::result_type H0 = getH0(pmt.getR()); // background hypothesis value for time integrated PDF.
801 JNPE_t::result_type H1 = getH1(D.getLength(), cd, theta, phi, shower.getE()); // signal hypothesis value for time integrated PDF.
802
803 if (get_value(H1) >= Vmax_npe) {
804 H1 *= Vmax_npe / get_value(H1);
805 }
806
807 H1 += H0; // now H1 is signal + background
808
809 const bool hit = pmt.getN() != 0;
810 const double u = getChi2(get_value(H1), hit) - getChi2(get_value(H0), hit); // -log likelihood ratio
811
812 return estimator->getRho(u);
813 }
814
815 /**
816 * Get background hypothesis value for time integrated PDF.
817 *
818 * \param R_Hz rate [Hz]
819 * \return hypothesis value
820 */
821 JNPE_t::result_type getH0(const double R_Hz) const
822 {
823 return JNPE_t::result_type(R_Hz * 1e-9 * T_ns.getLength());
824 }
825
826 /**
827 * Get signal hypothesis value for time integrated PDF.
828 *
829 * \param D PMT distance from shower [m]
830 * \param cd cosine angle between shower direction and PMT position
831 * \param theta PMT zenith angle [deg]
832 * \param phi PMT azimuth angle [deg]
833 * \param E shower energy [GeV]
834 * \return hypothesis value
835 */
836 JNPE_t::result_type getH1(const double D,
837 const double cd,
838 const double theta,
839 const double phi,
840 const double E) const
841 {
842 JNPE_t::result_type h1 = JMATH::zero;
843
844 for (int i = 0; i != NUMBER_OF_PDFS; ++i) {
845
846 if (!npe[i].empty() && D <= npe[i].getXmax()) {
847
848 try {
849
850 JNPE_t::result_type y1 = E * npe[i](std::max(D, npe[i].getXmin()), cd, theta, phi);
851
852 // safety measure
853
854 if(y1 < 0){
855 y1 = 0;
856 }
857
858 h1 += y1;
859
860 }
861 catch(JLANG::JException& error) {
862 ERROR(error << std::endl);
863 }
864 }
865 }
866
867 return h1;
868 }
869
870 /**
871 * Get signal hypothesis value for time integrated PDF.
872 *
873 * \param shower shower
874 * \param pmt pmt
875 * \return hypothesis value
876 */
877 JNPE_t::result_type getH1(const JShower3EZ& shower, const JPMTW0& pmt) const
878 {
879 using namespace JPP;
880
881 JPosition3D D(pmt.getPosition());
882 JDirection3D U(pmt.getDirection());
883
884
885 const double z = D.getDot(shower.getDirection());
886 const double x = D.getX();
887 const double y = D.getY();
888 const double cd = z/D.getLength(); // cosine angle between shower direction and PMT position
889
890 U.rotate(JRotation3Z(-atan2(y,x))); // rotate PMT axis to x-z plane
891
892 const double theta = getPMTAngle(U.getTheta());
893 const double phi = getPMTAngle(U.getPhi());
894
895 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.
896
897 if (get_value(H1) >= Vmax_npe) {
898 H1 *= Vmax_npe / get_value(H1);
899 }
900
901 return H1;
902 }
903 static double Vmax_npe; //!< Maximal integral of PDF [npe]
904
905 const JNPEs_t& npe;
906
907 std::shared_ptr<JMEstimator> estimator; //!< M-Estimator function
908 };
909
910 /**
911 * Default values.
912 */
913 double JRegressor<JShower3EZ, JSimplex>::Vmax_npe = std::numeric_limits<double>::max();
914
915 double JRegressor<JShower3EZ, JGandalf>::Vmax_npe = std::numeric_limits<double>::max();
916
917 double JRegressor<JShower3EZ, JAbstractMinimiser>::Vmax_npe = std::numeric_limits<double>::max();
918
919
920
921}
922
923#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.
Definition JEnergy.hh:15
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:67
double getR() const
Get rate.
Definition JPMTW0.hh:56
JTOOLS::JMapList< JTOOLS::JPolint0FunctionalMap, JTOOLS::JMapList< JTOOLS::JPolint0FunctionalMap, JTOOLS::JMapList< JTOOLS::JPolint0FunctionalGridMap, JTOOLS::JMapList< JTOOLS::JPolint0FunctionalGridMap > > > > 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::JMapList< JTOOLS::JPolint0FunctionalMap, JTOOLS::JMapList< JTOOLS::JPolint0FunctionalGridMap, JTOOLS::JMapList< JTOOLS::JPolint0FunctionalGridMap > > > > 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.
JPHYSICS::JPDFTable< JFunction1D_t, JPDFMaplist_t > JPDF_t
JRegressorStorage(const std::string &fileDescriptor, const JTimeRange &T_ns)
Parameterized constructor.
JTOOLS::JMapList< JTOOLS::JPolint0FunctionalMap, JTOOLS::JMapList< JTOOLS::JPolint0FunctionalMap, JTOOLS::JMapList< JTOOLS::JPolint0FunctionalGridMap, JTOOLS::JMapList< JTOOLS::JPolint0FunctionalGridMap > > > > JPDFMaplist_t
JTOOLS::JMapList< JTOOLS::JPolint1FunctionalMap, JTOOLS::JMapList< JTOOLS::JPolint1FunctionalMapH, JTOOLS::JMapList< JTOOLS::JPolint1FunctionalGridMap, JTOOLS::JMapList< JTOOLS::JPolint1FunctionalGridMap > > > > 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
std::array< JNPE_t, NUMBER_OF_PDFS > JNPEs_t
NPEs.
JTOOLS::JMapList< JTOOLS::JPolint0FunctionalMap, JTOOLS::JMapList< JTOOLS::JPolint0FunctionalMap, JTOOLS::JMapList< JTOOLS::JPolint0FunctionalGridMap, JTOOLS::JMapList< JTOOLS::JPolint0FunctionalGridMap > > > > JNPEMaplist_t
JTOOLS::JMapList< JTOOLS::JPolint0FunctionalMap, JTOOLS::JMapList< JTOOLS::JPolint0FunctionalMap, JTOOLS::JMapList< JTOOLS::JPolint0FunctionalGridMap, JTOOLS::JMapList< JTOOLS::JPolint0FunctionalGridMap > > > > 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.
Map list.
Definition JMapList.hh:25
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.