Jpp 21.0.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
JReconstruction/JEvtToolkit.hh
Go to the documentation of this file.
1#ifndef __JRECONSTRUCTION__JEVTTOOLKIT__
2#define __JRECONSTRUCTION__JEVTTOOLKIT__
3
4#include <string>
5#include <istream>
6#include <ostream>
7#include <map>
8#include <algorithm>
9#include <cmath>
10
14
15#include "JLang/JException.hh"
16#include "JLang/JPredicate.hh"
17#include "JLang/JFind_if.hh"
18#include "JTools/JRange.hh"
31#include "JMath/JMathToolkit.hh"
32#include "JMath/JConstants.hh"
33#include "JTools/JRange.hh"
35
36#include "JFit/JLine1Z.hh"
37#include "JFit/JShower3EZ.hh"
38#include "JFit/JPoint4D.hh"
39
43
44
45/**
46 * \author mdejong
47 */
48namespace JRECONSTRUCTION {}
49namespace JPP { using namespace JRECONSTRUCTION; }
50
51/**
52 * Model fits to data.
53 */
54namespace JRECONSTRUCTION {
55
68 using JTOOLS::JRange;
69 using JFIT::JLine1Z;
70 using JFIT::JShower3Z;
71 using JFIT::JPoint4D;
72
73 static const int JVETO_NPE = 11; //!< number of photo-electrons
74 static const int JVETO_NUMBER_OF_HITS = 12; //!< number of hits
75
76
77 /**
78 * Auxiliary data structure to get weight of given fit.
79 */
80 static struct JWeight :
81 public std::map<std::string, int>
82 {
83 /**
84 * Default constructor.
85 */
87 {
88#define MAKE_ENTRY(A) std::make_pair(#A, A)
89
90 this->insert(MAKE_ENTRY(JGANDALF_BETA0_RAD));
91 this->insert(MAKE_ENTRY(JGANDALF_BETA1_RAD));
94 this->insert(MAKE_ENTRY(JENERGY_ENERGY));
95 this->insert(MAKE_ENTRY(JENERGY_CHI2));
96 this->insert(MAKE_ENTRY(JGANDALF_LAMBDA));
98 this->insert(MAKE_ENTRY(JSTART_ZMIN_M));
99 this->insert(MAKE_ENTRY(JSTART_ZMAX_M));
100 this->insert(MAKE_ENTRY(JSTART_NPE_MIP_TOTAL));
101 this->insert(MAKE_ENTRY(JSTART_NPE_MIP_MISSED));
102 this->insert(MAKE_ENTRY(JSTART_LENGTH_METRES));
103 this->insert(MAKE_ENTRY(JSTART_BACKGROUND_LOGP));
104 this->insert(MAKE_ENTRY(JVETO_NPE));
105 this->insert(MAKE_ENTRY(JVETO_NUMBER_OF_HITS));
108 this->insert(MAKE_ENTRY(JENERGY_NDF));
109 this->insert(MAKE_ENTRY(JENERGY_NUMBER_OF_HITS));
111 this->insert(MAKE_ENTRY(JPP_COVERAGE_POSITION));
112 this->insert(MAKE_ENTRY(JENERGY_MINIMAL_ENERGY));
113 this->insert(MAKE_ENTRY(JENERGY_MAXIMAL_ENERGY));
114 this->insert(MAKE_ENTRY(JSHOWERFIT_ENERGY));
115 this->insert(MAKE_ENTRY(AASHOWERFIT_ENERGY));
117
118#undef MAKE_ENTRY
119 }
120
121
122 /**
123 * Has weight.
124 *
125 * \param key key
126 * \return true if valid key; else false
127 */
128 bool operator()(const std::string& key) const
129 {
130 return this->count(key) != 0;
131 }
132
133
134 /**
135 * Get weight.
136 *
137 * \param fit fit
138 * \param key key
139 * \param value default value
140 * \return value
141 */
142 double operator()(const JFit& fit, const std::string& key, const double value) const
143 {
144 const_iterator p = this->find(key);
145
146 if (p != this->end() && fit.hasW(p->second))
147 return fit.getW(p->second);
148 else
149 return value;
150 }
151
152
153 /**
154 * Get weight.
155 *
156 * \param fit fir
157 * \param key key
158 * \param value default value
159 * \return value
160 */
161 double operator()(const Trk& fit, const std::string& key, const double value) const
162 {
163 const_iterator p = this->find(key);
164
165 if (p != this->end() && fit.fitinf.size() > (size_t) p->second)
166 return fit.fitinf[p->second];
167 else
168 return value;
169 }
170
172
173
174 /**
175 * Get position.
176 *
177 * \param fit fit
178 * \return position
179 */
180 inline JPosition3D getPosition(const JFit& fit)
181 {
182 return JPosition3D(fit.getX(), fit.getY(), fit.getZ());
183 }
184
185 /**
186 * Get point.
187 *
188 * \param fit fit
189 * \return point
190 */
191 inline JPoint4D getPoint(const JFit& fit)
192 {
193 return JPoint4D(getPosition(fit), fit.getT());
194 }
195
196 /**
197 * Get direction.
198 *
199 * \param fit fit
200 * \return direction
201 */
202 inline JDirection3D getDirection(const JFit& fit)
203 {
204 return JDirection3D(fit.getDX(), fit.getDY(), fit.getDZ());
205 }
206
207
208 /**
209 * Get vertex.
210 *
211 * \param fit fit
212 * \return vertex
213 */
214 inline JVertex3D getVertex(const JFit& fit)
215 {
216 return JVertex3D(getPosition(fit), fit.getT());
217 }
218
219
220 /**
221 * Get axis.
222 *
223 * \param fit fit
224 * \return axis
225 */
226 inline JAxis3D getAxis(const JFit& fit)
227 {
228 return JAxis3D(getPosition(fit), getDirection(fit));
229 }
230
231
232 /**
233 * Get track.
234 *
235 * \param fit fit
236 * \return track
237 */
238 inline JTrack3E getTrack(const JFit& fit)
239 {
240 return JTrack3E(JTrack3D(getAxis(fit), fit.getT()), fit.getE());
241 }
242
243
244 /**
245 * Get shower.
246 *
247 * \param fit fit
248 * \return shower
249 */
250 inline JShower3E getShower(const JFit& fit)
251 {
252 return JShower3E(JShower3D(getVertex(fit), getDirection(fit)), fit.getE());
253 }
254
255
256 /**
257 * Get fit.
258 *
259 * \param history history
260 * \param track track
261 * \param Q quality
262 * \param NDF number of degrees of freedom
263 * \param energy Energy, which would be set as 0, if the fit does not reconstruct energy
264 * \param status status of the fit as defined in enum JFitStatus.hh
265 * \return fit
266 */
267 inline JFit getFit(const JHistory& history,
268 const JTrack3D& track,
269 const double Q,
270 const int NDF,
271 const double energy = 0.0,
272 const int status = SINGLE_STAGE)
273 {
274 return JFit(history,
275 track.getX(), track.getY(), track.getZ(),
276 track.getDX(), track.getDY(), track.getDZ(),
277 track.getT(),
278 Q, NDF,
279 energy, status);
280 }
281
282
283 /**
284 * Get fit.
285 *
286 * \param history history
287 * \param track track
288 * \param angle angle
289 * \param Q quality
290 * \param NDF number of degrees of freedom
291 * \param energy Energy, which would be set as 0, if the fit does not reconstruct energy
292 * \param status status of the fit as defined in JFitStatus.hh
293 * \return fit
294 */
295 inline JFit getFit(const JHistory& history,
296 const JLine1Z& track,
297 const JAngle3D& angle,
298 const double Q,
299 const int NDF,
300 const double energy = 0.0,
301 const int status = SINGLE_STAGE)
302 {
303 return JFit(history,
304 track.getX(), track.getY(), track.getZ(),
305 angle.getDX(), angle.getDY(), angle.getDZ(),
306 track.getT(),
307 Q, NDF,
308 energy, status);
309 }
310
311
312 /**
313 * Get fit.
314 *
315 * \param history history
316 * \param shower shower
317 * \param Q quality
318 * \param NDF number of degrees of freedom
319 * \param energy Energy, which would be set as 0, if the fit does not reconstruct energy
320 * \param status status of the fit as defined in enum JFitStatus.hh
321 * \return fit
322 */
323 inline JFit getFit(const JHistory& history,
324 const JShower3D& shower,
325 const double Q,
326 const int NDF,
327 const double energy = 0.0,
328 const int status = SINGLE_STAGE)
329 {
330 return JFit(history,
331 shower.getX(), shower.getY(), shower.getZ(),
332 shower.getDX(), shower.getDY(), shower.getDZ(),
333 shower.getT(),
334 Q, NDF,
335 energy, status);
336 }
337
338
339 /**
340 * Get dot product.
341 *
342 * \param first first fit
343 * \param second second fit
344 * \return dot product
345 */
346 inline double getDot(const JFit& first, const JFit& second)
347 {
348 return JMATH::getDot(getDirection(first), getDirection(second));
349 }
350
351
352 /**
353 * Get dot product.
354 *
355 * \param fit fit
356 * \param dir direction
357 * \return dot product
358 */
359 inline double getDot(const JFit& fit, const JDirection3D& dir)
360 {
361 return JMATH::getDot(getDirection(fit), dir);
362 }
363
364
365 /**
366 * Get space angle.
367 *
368 * \param first first fit
369 * \param second second fit
370 * \return angle [deg]
371 */
372 inline double getAngle(const JFit& first, const JFit& second)
373 {
374 return JMATH::getAngle(getDirection(first), getDirection(second));
375 }
376
377
378 /**
379 * Get space angle.
380 *
381 * \param fit fit
382 * \param dir direction
383 * \return angle [deg]
384 */
385 inline double getAngle(const JFit& fit, const JDirection3D& dir)
386 {
387 return JMATH::getAngle(getDirection(fit), dir);
388 }
389
390
391 /**
392 * Get quality of fit.\n
393 * The larger the quality, the better the fit.
394 *
395 * \param chi2 chi2
396 * \param N number of hits
397 * \param NDF number of degrees of freedom
398 * \return quality
399 */
400 inline double getQuality(const double chi2, const int N, const int NDF)
401 {
402 return N - 0.25 * chi2 / NDF;
403 }
404
405
406 /**
407 * Get quality of fit.\n
408 * The larger the quality, the better the fit.
409 *
410 * \param chi2 chi2
411 * \param NDF number of degrees of freedom
412 * \return quality
413 */
414 inline double getQuality(const double chi2, const int NDF)
415 {
416 return NDF - 0.25 * chi2 / NDF;
417 }
418
419
420 /**
421 * Get quality of fit.\n
422 * The larger the quality, the better the fit.
423 *
424 * \param chi2 chi2
425 * \return quality
426 */
427 inline double getQuality(const double chi2)
428 {
429 return -chi2;
430 }
431
432
433 /**
434 * Comparison of fit results.
435 *
436 * \param first first fit
437 * \param second second fit
438 * \return true if first fit has better quality than second; else false
439 */
440 inline bool qualitySorter(const JFit& first, const JFit& second)
441 {
442 if (first.getHistory().size() == second.getHistory().size())
443 return first.getQ() > second.getQ();
444 else
445 return first.getHistory().size() > second.getHistory().size();
446 }
447
448
449 /**
450 * General purpose sorter of fit results.
451 *
452 * The default constructor will sort fit results according the method JRECONSTRUCTION::qualitySorter.\n
453 * A different method can dynamically be loaded from a (shared) library using class JEEP::JFunctionAdaptor.
454 * For the definition of an alternative method, see e.g.\ quality_sorter.cc
455 */
457 public JFunctionAdaptor<bool, const JFit&, const JFit&>
458 {
461
462
463 /**
464 * Default constructor.
465 */
469 };
470
471
472 /**
473 * Test whether given fit has specified history.
474 *
475 * \param fit fit
476 * \param type application type
477 * \return true if type in history; else false
478 */
479 inline bool has_history(const JFit& fit, const int type)
480 {
481 return std::find_if(fit.getHistory().begin(),
482 fit.getHistory().end(),
483 JLANG::make_predicate(&JEvent::type, type)) != fit.getHistory().end();
484 }
485
486
487 /**
488 * Test whether given fit has specified history.
489 *
490 * \param fit fit
491 * \param range application type range
492 * \return true if type in history; else false
493 */
494 inline bool has_history(const JFit& fit, const JRange<int>& range)
495 {
496 return std::find_if(fit.getHistory().begin(),
497 fit.getHistory().end(),
498 JLANG::make_find_if(&JEvent::type, range)) != fit.getHistory().end();
499 }
500
501
502 /**
503 * Test whether given fit has muon prefit in history.
504 *
505 * \param fit fit
506 * \return true if muon prefit in history; else false
507 */
508 inline bool has_muon_prefit(const JFit& fit)
509 {
510 return has_history(fit, JMUONPREFIT);
511 }
512
513
514 /**
515 * Test whether given fit has muon simplex in history.
516 *
517 * \param fit fit
518 * \return true if muon simplex in history; else false
519 */
520 inline bool has_muon_simplex(const JFit& fit)
521 {
522 return has_history(fit, JMUONSIMPLEX);
523 }
524
525
526 /**
527 * Test whether given fit has muon gandalf in history.
528 *
529 * \param fit fit
530 * \return true if muon gandalf in history; else false
531 */
532 inline bool has_muon_gandalf(const JFit& fit)
533 {
534 return has_history(fit, JMUONGANDALF);
535 }
536
537
538 /**
539 * Test whether given fit has muon energy in history.
540 *
541 * \param fit fit
542 * \return true if muon energy in history; else false
543 */
544 inline bool has_muon_energy(const JFit& fit)
545 {
546 return has_history(fit, JMUONENERGY);
547 }
548
549
550 /**
551 * Test whether given fit has muon start in history.
552 *
553 * \param fit fit
554 * \return true if muon start in history; else false
555 */
556 inline bool has_muon_start(const JFit& fit)
557 {
558 return has_history(fit, JMUONSTART);
559 }
560
561
562 /**
563 * Test whether given fit has muon fit in history.
564 *
565 * \param fit fit
566 * \return true if muon fit in history; else false
567 */
568 inline bool has_muon_fit(const JFit& fit)
569 {
571 }
572
573
574 /**
575 * Test whether given fit has shower prefit in history.
576 *
577 * \param fit fit
578 * \return true if shower prefit in history; else false
579 */
580 inline bool has_shower_prefit(const JFit& fit)
581 {
582 return has_history(fit, JSHOWERPREFIT);
583 }
584
585
586 /**
587 * Test whether given fit has shower position fit in history.
588 *
589 * \param fit fit
590 * \return true if shower position fit in history; else false
591 */
592 inline bool has_shower_positionfit(const JFit& fit)
593 {
594 return has_history(fit, JSHOWERPOSITIONFIT);
595 }
596
597
598 /**
599 * Test whether given fit has shower complete fit in history.
600 *
601 * \param fit fit
602 * \return true if shower complete fit in history; else false
603 */
604 inline bool has_shower_completefit(const JFit& fit)
605 {
606 return has_history(fit, JSHOWERCOMPLETEFIT);
607 }
608
609
610 /**
611 * Test whether given fit has shower fit in history.
612 *
613 * \param fit fit
614 * \return true if shower fit in history; else false
615 */
616 inline bool has_shower_fit(const JFit& fit)
617 {
619 }
620
621
622 /**
623 * Test whether given event has a track according selection.\n
624 * The track selector corresponds to the function operator <tt>bool selector(const JFit&);</tt>.
625 *
626 * \param evt event
627 * \param selector track selector
628 * \return true if at least one corresponding track; else false
629 */
630 template<class JTrackSelector_t>
631 inline bool has_reconstructed_track(const JEvt& evt, JTrackSelector_t selector)
632 {
633 return std::find_if(evt.begin(), evt.end(), selector) != evt.end();
634 }
635
636
637 /**
638 * Test whether given event has a track with muon reconstruction.
639 *
640 * \param evt event
641 * \return true if at least one reconstructed muon; else false
642 */
643 inline bool has_reconstructed_muon(const JEvt& evt)
644 {
646 }
647
648
649 /**
650 * Test whether given event has a track with shower reconstruction.
651 *
652 * \param evt event
653 * \return true if at least one reconstructed shower; else false
654 */
655 inline bool has_reconstructed_shower(const JEvt& evt)
656 {
658 }
659
660
661 /**
662 * Get best reconstructed track.\n
663 * The track selector corresponds to the function operator <tt>bool selector(const Trk&);</tt> and
664 * the track comparator to <tt>bool comparator(const Trk&, const Trk&);</tt>.
665 *
666 * \param evt event
667 * \param selector track selector
668 * \param comparator track comparator
669 * \return track
670 */
671 template<class JTrackSelector_t, class JQualitySorter_t>
672 inline const JFit& get_best_reconstructed_track(const JEvt& evt,
673 JTrackSelector_t selector,
674 JQualitySorter_t comparator)
675 {
676 JEvt::const_iterator p = std::find_if(evt.begin(), evt.end(), selector);
677
678 for (JEvt::const_iterator i = p; i != evt.end(); ++i) {
679 if (selector(*i) && comparator(*i, *p)) {
680 p = i;
681 }
682 }
683
684 if (p != evt.end())
685 return *p;
686 else
687 THROW(JIndexOutOfRange, "This event has no fit with given selector.");
688 }
689
690
691 /**
692 * Get best reconstructed muon.
693 *
694 * \param evt event
695 * \return track
696 */
697 inline const JFit& get_best_reconstructed_muon(const JEvt& evt)
698 {
700 }
701
702
703 /**
704 * Get best reconstructed shower.
705 *
706 * \param evt event
707 * \return track
708 */
709 inline const JFit& get_best_reconstructed_shower(const JEvt& evt)
710 {
712 }
713
714
715 /**
716 * Auxiliary class to compare fit results with respect to a reference direction (e.g.\ true muon).
717 * The sort operation results in an ordered set of fit results with increasing angle between
718 * the reference direction and that of the fit results.
719 */
720 class JPointing {
721 public:
722 /**
723 * Default constructor.
724 */
726 {}
727
728
729 /**
730 * Constructor.
731 *
732 * \param dir reference direction
733 */
735 {
736 this->dir = dir;
737 }
738
739
740 /**
741 * Constructor.
742 *
743 * \param fit fit
744 */
745 JPointing(const JFit& fit)
746 {
748 }
749
750
751 /**
752 * Get direction.
753 *
754 * \return direction
755 */
757 {
758 return dir;
759 }
760
761
762 /**
763 * Get angle between reference direction and fit result.
764 *
765 * \param fit fit
766 * \return angle [deg]
767 */
768 inline double getAngle(const JFit& fit) const
769 {
770 const double dot = getDot(fit, dir);
771
772 if (dot >= +1.0)
773 return 0.0;
774 else if (dot <= -1.0)
775 return 180.0;
776 else
777 return acos(dot) * 180.0 / JMATH::PI;
778 }
779
780
781 /**
782 * Comparison of fit results.
783 *
784 * \param first first fit
785 * \param second second fit
786 * \return true if first fit better; else false
787 */
788 inline bool operator()(const JFit& first, const JFit& second) const
789 {
790 return getDot(first, dir) > getDot(second, dir);
791 }
792
793
794 /**
795 * Select best fit result.
796 *
797 * \param __begin begin of fit results
798 * \param __end end of fit results
799 * \return best fit result
800 */
801 template<class T>
802 inline T operator()(T __begin, T __end) const
803 {
804 return std::min_element(__begin, __end, *this);
805 }
806
807 protected:
809 };
810
811
812 /**
813 * Auxiliary class to compare fit results with respect to a reference 4D-position.
814 * The sort operation results in an ordered set of fit results with increasing distance between
815 * the reference position and that of the fit results.
816 */
817 class JPoint {
818 public:
819 /**
820 * Constructor.
821 *
822 * \param point reference position
823 */
825 {
826 this->point = point;
827 }
828
829 /**
830 * Constructor.
831 *
832 * \param fit fit
833 */
834 JPoint(const JFit& fit)
835 {
836 this->point = getPoint(fit);
837 }
838
839 /**
840 * Comparison of fit results.
841 *
842 * \param first first fit
843 * \param second second fit
844 * \return true if first fit better; else false
845 */
846 inline bool operator()(const JFit& first, const JFit& second) const
847 {
848 return this->point.get4Distance(getPoint(first)) < this->point.get4Distance(getPoint(second));
849 }
850
851 /**
852 * Select best fit result.
853 *
854 * \param __begin begin of fit results
855 * \param __end end of fit results
856 * \return best fit result
857 */
858 template<class T>
859 inline T operator()(T __begin, T __end) const
860 {
861 return std::min_element(__begin, __end, *this);
862 }
863
864 protected:
866 };
867
868
869 /**
870 * Auxiliary class to compare fit results with respect to a reference position.
871 * The sort operation results in an ordered set of fit results with increasing distance between
872 * the reference position and that of the fit results.
873 */
874 class JPosition {
875 public:
876 /**
877 * Constructor.
878 *
879 * \param pos reference position
880 */
882 {
883 this->pos = pos;
884 }
885
886 /**
887 * Comparison of fit results.
888 *
889 * \param first first fit
890 * \param second second fit
891 * \return true if first fit better; else false
892 */
893 inline bool operator()(const JFit& first, const JFit& second) const
894 {
895 return this->pos.getDistance(getPosition(first)) < this->pos.getDistance(getPosition(second));
896 }
897
898 /**
899 * Select best fit result.
900 *
901 * \param __begin begin of fit results
902 * \param __end end of fit results
903 * \return best fit result
904 */
905 template<class T>
906 inline T operator()(T __begin, T __end) const
907 {
908 return std::min_element(__begin, __end, *this);
909 }
910
911 protected:
913 };
914
915
916
917 /**
918 * Auxiliary class to compare fit results with respect to a reference energy.
919 * The sort operation results in an ordered set of fit results with increasing difference between
920 * the reference energy and that of the fit results.
921 */
923 public:
924 /**
925 * Constructor.
926 *
927 * \param E reference energy
928 */
930 {
931 this->energy = E;
932 }
933
934 /**
935 * Comparison of fit results.
936 *
937 * \param first first fit
938 * \param second second fit
939 * \return true if first fit better; else false
940 */
941 inline bool operator()(const JFit& first, const JFit& second) const
942 {
943 return fabs(this->energy - first.getE()) < fabs(this->energy - second.getE());
944 }
945
946 /**
947 * Select best fit result.
948 *
949 * \param __begin begin of fit results
950 * \param __end end of fit results
951 * \return best fit result
952 */
953 template<class T>
954 inline T operator()(T __begin, T __end) const
955 {
956 return std::min_element(__begin, __end, *this);
957 }
958
959 protected:
960 double energy;
961 };
962
963
964 /**
965 * Gridify set of fits.
966 *
967 * \param __begin begin of fits
968 * \param __end end of fits
969 * \param N number of directions in grid
970 * \return end of fits sorted by quality
971 */
972 inline JEvt::iterator gridify(JEvt::iterator __begin, JEvt::iterator __end, const int N)
973 {
974 using namespace std;
975 using namespace JPP;
976
977 static const double MINIMAL_ANGLE_DEG = 60.0;
978
979 // estimate grid angle
980
981 double angle_deg = 10.0 * sqrt((double) 240 / (double) N);
982
983 if (angle_deg > MINIMAL_ANGLE_DEG) {
984 angle_deg = MINIMAL_ANGLE_DEG;
985 }
986
987 const JOmega3D ps(angle_deg * PI/180.0);
988
989 JEvt::iterator out = __begin;
990
991 for (JOmega3D_t::const_iterator dir = ps.begin(); dir != ps.end() && out != __end; ++dir) {
992
993 const JPointing pointing(*dir);
994
995 sort(out, __end, pointing);
996
997 JEvt::iterator p = out;
998
999 for (JEvt::iterator i = out; i != __end && pointing.getAngle(*i) <= angle_deg; ++i) {
1000 if (qualitySorter(*i, *p)) {
1001 p = i;
1002 }
1003 }
1004
1005 swap(*(out++), *p);
1006 }
1007
1008 sort(__begin, out, qualitySorter);
1009
1010 return out;
1011 }
1012
1013
1014 /**
1015 * Auxiliary class to evaluate atmospheric muon hypothesis.
1016 * The hypothesis is tested by means of the difference in quality
1017 * between the best upward and best downward track.
1018 */
1020 public:
1021 /**
1022 * Default constructor.
1023 */
1025 dot1(0.0),
1026 dot2(0.0)
1027 {}
1028
1029
1030 /**
1031 * Constructor.
1032 *
1033 * \param theta1 upper hemisphere angle [deg]
1034 * \param theta2 lower hemisphere angle [deg]
1035 */
1036 JAtmosphericMuon(const double theta1,
1037 const double theta2) :
1038 dot1(cos(theta1 * JMATH::PI/180.0)),
1039 dot2(cos(theta2 * JMATH::PI/180.0))
1040 {}
1041
1042
1043 /**
1044 * Test is event is atmospheric muon.
1045 *
1046 * \param __begin begin of data
1047 * \param __end end of data
1048 * \return negative if preferably down / positive if preferably up
1049 */
1050 double operator()(JEvt::const_iterator __begin,
1051 JEvt::const_iterator __end) const
1052 {
1053 double Qup = 0.0;
1054 double Qdown = 0.0;
1055
1056 for (JEvt::const_iterator i = __begin; i != __end; ++i) {
1057
1058 if (i->getDZ() >= dot1) {
1059
1060 if (i->getQ() > Qup) {
1061 Qup = i->getQ();
1062 }
1063
1064 } else if (i->getDZ() <= dot2) {
1065
1066 if (i->getQ() > Qdown) {
1067 Qdown = i->getQ();
1068 }
1069 }
1070 }
1071
1072 return Qup - Qdown;
1073 }
1074
1075
1076 /**
1077 * Read atmospheric muon analyser from input.
1078 *
1079 * \param in input stream
1080 * \param object atmospheric muon analyser
1081 * \return input stream
1082 */
1083 friend inline std::istream& operator>>(std::istream& in, JAtmosphericMuon& object)
1084 {
1085 double theta1, theta2;
1086
1087 in >> theta1 >> theta2;
1088
1089 object.dot1 = cos(theta1 * JMATH::PI/180.0);
1090 object.dot2 = cos(theta2 * JMATH::PI/180.0);
1091
1092 return in;
1093 }
1094
1095
1096 /**
1097 * Write atmospheric muon analyser to output.
1098 *
1099 * \param out output stream
1100 * \param object atmospheric muon analyser
1101 * \return output stream
1102 */
1103 friend inline std::ostream& operator<<(std::ostream& out, const JAtmosphericMuon& object)
1104 {
1105 out << acos(object.dot1) * 180.0 / JMATH::PI << ' '
1106 << acos(object.dot2) * 180.0 / JMATH::PI;
1107
1108 return out;
1109 }
1110
1111
1112 double dot1;
1113 double dot2;
1114 };
1115}
1116
1117#endif
Exceptions.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition for fit results.
Binary methods for member methods.
Mathematical constants.
Auxiliary class to define a range between two values.
#define MAKE_ENTRY(A)
static const int JMUONBEGIN
begin range of reconstruction stages
static const int JSHOWEREND
end range of reconstruction stages
static const int JSHOWERBEGIN
begin range of reconstruction stages
static const int JMUONEND
end range of reconstruction stages
Data structure for set of track fit results.
Data structure for track fit results with history and optional associated values.
double getDZ() const
Get Z-slope.
double getDY() const
Get Y-slope.
double getZ() const
Get Z-position.
double getE() const
Get energy.
double getDX() const
Get X-slope.
double getY() const
Get Y-position.
double getQ() const
Get quality.
const std::vector< double > & getW() const
Get associated values.
double getT() const
Get time.
bool hasW(const int i) const
Check availability of value.
double getX() const
Get X-position.
Data structure for fit of straight line paralel to z-axis.
Definition JLine1Z.hh:29
double getT(const JVector3D &pos) const
Get arrival time of Cherenkov light at given position.
Definition JLine1Z.hh:114
double getZ(const JPosition3D &pos) const
Get point of emission of Cherenkov light along muon path.
Definition JLine1Z.hh:134
Data structure for vertex fit.
Definition JPoint4D.hh:24
double get4Distance(JPoint4D point) const
Computes the 4-D distance using the reduced speed of light.
Definition JPoint4D.hh:61
Data structure for cascade in positive z-direction.
Definition JShower3Z.hh:36
Data structure for angles in three dimensions.
Definition JAngle3D.hh:35
double getDY() const
Get y direction.
Definition JAngle3D.hh:119
double getDZ() const
Get z direction.
Definition JAngle3D.hh:130
double getDX() const
Get x direction.
Definition JAngle3D.hh:108
Axis object.
Definition JAxis3D.hh:41
Data structure for direction in three dimensions.
Direction set covering (part of) solid angle.
Definition JOmega3D.hh:68
Data structure for position in three dimensions.
double getT(const JVector3D &pos) const
Get arrival time of Cherenkov light at given position.
Definition JShower3D.hh:97
3D shower with energy.
Definition JShower3E.hh:31
double getT(const JVector3D &pos) const
Get arrival time of Cherenkov light at given position.
Definition JTrack3D.hh:87
3D track with energy.
Definition JTrack3E.hh:34
Data structure for vector in three dimensions.
Definition JVector3D.hh:36
double getY() const
Get y position.
Definition JVector3D.hh:104
double getDistance(const JVector3D &pos) const
Get distance to point.
Definition JVector3D.hh:270
double getZ() const
Get z position.
Definition JVector3D.hh:115
double getX() const
Get x position.
Definition JVector3D.hh:94
double getDY() const
Get y direction.
Definition JVersor3D.hh:106
double getDX() const
Get x direction.
Definition JVersor3D.hh:95
double getDZ() const
Get z direction.
Definition JVersor3D.hh:117
Exception for accessing an index in a collection that is outside of its range.
Definition JException.hh:92
Auxiliary class to evaluate atmospheric muon hypothesis.
friend std::ostream & operator<<(std::ostream &out, const JAtmosphericMuon &object)
Write atmospheric muon analyser to output.
JAtmosphericMuon(const double theta1, const double theta2)
Constructor.
friend std::istream & operator>>(std::istream &in, JAtmosphericMuon &object)
Read atmospheric muon analyser from input.
double operator()(JEvt::const_iterator __begin, JEvt::const_iterator __end) const
Test is event is atmospheric muon.
Auxiliary class to compare fit results with respect to a reference 4D-position.
JPoint(const JFit &fit)
Constructor.
JPoint(JPoint4D point)
Constructor.
bool operator()(const JFit &first, const JFit &second) const
Comparison of fit results.
T operator()(T __begin, T __end) const
Select best fit result.
Auxiliary class to compare fit results with respect to a reference direction (e.g....
bool operator()(const JFit &first, const JFit &second) const
Comparison of fit results.
JPointing(const JFit &fit)
Constructor.
T operator()(T __begin, T __end) const
Select best fit result.
JPointing(const JDirection3D &dir)
Constructor.
JDirection3D getDirection() const
Get direction.
double getAngle(const JFit &fit) const
Get angle between reference direction and fit result.
Auxiliary class to compare fit results with respect to a reference position.
bool operator()(const JFit &first, const JFit &second) const
Comparison of fit results.
T operator()(T __begin, T __end) const
Select best fit result.
Auxiliary class to compare fit results with respect to a reference energy.
T operator()(T __begin, T __end) const
Select best fit result.
bool operator()(const JFit &first, const JFit &second) const
Comparison of fit results.
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 JENERGY_NDF
number of degrees of freedom see JRECONSTRUCTION::JMuonEnergy
static const int JGANDALF_LAMBDA
largest eigenvalue of error matrix see JRECONSTRUCTION::JMuonGandalf
static const int JENERGY_ENERGY
uncorrected energy [GeV] see JRECONSTRUCTION::JMuonEnergy
static const int AASHOWERFIT_NUMBER_OF_HITS
number of hits used
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 JSTART_NPE_MIP_TOTAL
number of photo-electrons along the whole track see JRECONSTRUCTION::JMuonStart
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 JGANDALF_BETA0_RAD
ile KM3NeT Data Definitions v3.6.2-10-g294bec6 https://git.km3net.de/common/km3net-dataformat
static const int JGANDALF_NUMBER_OF_ITERATIONS
number of iterations see JRECONSTRUCTION::JMuonGandalf
static const int JSHOWERFIT_ENERGY
uncorrected energy [GeV] see JRECONSTRUCTION::JShowerFit
static const int JPP_COVERAGE_ORIENTATION
coverage of dynamic orientation calibration of this event
static const int JSTART_BACKGROUND_LOGP
summed logarithm of background probabilities see JRECONSTRUCTION::JMuonStart
static const int JGANDALF_BETA1_RAD
uncertainty on the reconstructed track direction from the error matrix [rad] see JRECONSTRUCTION::JMu...
static const int JENERGY_MINIMAL_ENERGY
minimal energy [GeV] see JRECONSTRUCTION::JMuonEnergy
static const int AASHOWERFIT_ENERGY
uncorrected energy [GeV]
static const int JSTART_NPE_MIP_MISSED
number of photo-electrons missed see JRECONSTRUCTION::JMuonStart
static const int JENERGY_MAXIMAL_ENERGY
maximal energy [GeV] see JRECONSTRUCTION::JMuonEnergy
static const int JGANDALF_NUMBER_OF_HITS
number of hits see JRECONSTRUCTION::JMuonGandalf
JPredicate< JResult_t T::*, JComparison::eq > make_predicate(JResult_t T::*member, const JResult_t value)
Helper method to create predicate for data member.
JFind_if< JResult_t T::*, JPredicate_t > make_find_if(JResult_t T::*member, const JPredicate_t &predicate)
Helper method to create find_if for data member.
Definition JFind_if.hh:119
double getAngle(const JFirst_t &first, const JSecond_t &second)
Get space angle between objects.
double getDot(const JFirst_t &first, const JSecond_t &second)
Get dot product of objects.
static const double PI
Mathematical constants.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
double getQuality(const double chi2, const int N, const int NDF)
Get quality of fit.
bool has_shower_fit(const JFit &fit)
Test whether given fit has shower fit in history.
bool has_muon_gandalf(const JFit &fit)
Test whether given fit has muon gandalf in history.
JPosition3D getPosition(const JFit &fit)
Get position.
const JFit & get_best_reconstructed_muon(const JEvt &evt)
Get best reconstructed muon.
static const int JVETO_NPE
number of photo-electrons
bool qualitySorter(const JFit &first, const JFit &second)
Comparison of fit results.
JAxis3D getAxis(const JFit &fit)
Get axis.
double getDot(const JFit &first, const JFit &second)
Get dot product.
const JFit & get_best_reconstructed_track(const JEvt &evt, JTrackSelector_t selector, JQualitySorter_t comparator)
Get best reconstructed track.
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.
JTrack3E getTrack(const JFit &fit)
Get track.
bool has_history(const JFit &fit, const int type)
Test whether given fit has specified history.
double getAngle(const JFit &first, const JFit &second)
Get space angle.
JVertex3D getVertex(const JFit &fit)
Get vertex.
JShower3E getShower(const JFit &fit)
Get shower.
bool has_shower_prefit(const JFit &fit)
Test whether given fit has shower prefit in history.
bool has_muon_energy(const JFit &fit)
Test whether given fit has muon energy in history.
bool has_muon_fit(const JFit &fit)
Test whether given fit has muon fit in history.
JDirection3D getDirection(const JFit &fit)
Get direction.
JRECONSTRUCTION::JWeight getWeight
bool has_reconstructed_shower(const JEvt &evt)
Test whether given event has a track with shower reconstruction.
bool has_shower_completefit(const JFit &fit)
Test whether given fit has shower complete fit in history.
static const int JVETO_NUMBER_OF_HITS
number of hits
bool has_muon_prefit(const JFit &fit)
Test whether given fit has muon prefit in history.
bool has_muon_start(const JFit &fit)
Test whether given fit has muon start in history.
JPoint4D getPoint(const JFit &fit)
Get point.
bool has_shower_positionfit(const JFit &fit)
Test whether given fit has shower position fit in history.
const JFit & get_best_reconstructed_shower(const JEvt &evt)
Get best reconstructed shower.
bool has_muon_simplex(const JFit &fit)
Test whether given fit has muon simplex in history.
JEvt::iterator gridify(JEvt::iterator __begin, JEvt::iterator __end, const int N)
Gridify set of fits.
bool has_reconstructed_track(const JEvt &evt, JTrackSelector_t selector)
Test whether given event has a track according selection.
bool has_reconstructed_muon(const JEvt &evt)
Test whether given event has a track with muon reconstruction.
JReturn_t(*) pF(Args...)
Type definition of method.
int type
application type
Definition JHistory.hh:136
Container for historical events.
Definition JHistory.hh:151
const JHistory & getHistory() const
Get history.
Definition JHistory.hh:301
General purpose sorter of fit results.
JFunctionAdaptor< bool, const JFit &, const JFit & > function_adaptor_type
Auxiliary data structure to get weight of given fit.
double operator()(const Trk &fit, const std::string &key, const double value) const
Get weight.
bool operator()(const std::string &key) const
Has weight.
double operator()(const JFit &fit, const std::string &key, const double value) const
Get weight.
The Trk class represents a Monte Carlo (MC) particle as well as a reconstructed track/shower.
Definition Trk.hh:15
std::vector< double > fitinf
place to store additional fit info, see km3net-dataformat/definitions/fitparameters....
Definition Trk.hh:32