Jpp 21.0.0
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"
30#include "JMath/JMathToolkit.hh"
31#include "JMath/JConstants.hh"
32#include "JTools/JRange.hh"
34
35#include "JFit/JLine1Z.hh"
36#include "JFit/JShower3EZ.hh"
37#include "JFit/JPoint4D.hh"
38
42
43
44/**
45 * \author mdejong
46 */
47namespace JRECONSTRUCTION {}
48namespace JPP { using namespace JRECONSTRUCTION; }
49
50/**
51 * Model fits to data.
52 */
53namespace JRECONSTRUCTION {
54
67 using JTOOLS::JRange;
68 using JFIT::JLine1Z;
69 using JFIT::JShower3Z;
70 using JFIT::JPoint4D;
71
72 static const int JVETO_NPE = 11; //!< number of photo-electrons
73 static const int JVETO_NUMBER_OF_HITS = 12; //!< number of hits
74
75
76 /**
77 * Auxiliary data structure to get weight of given fit.
78 */
79 static struct JWeight :
80 public std::map<std::string, int>
81 {
82 /**
83 * Default constructor.
84 */
86 {
87#define MAKE_ENTRY(A) std::make_pair(#A, A)
88
89 this->insert(MAKE_ENTRY(JGANDALF_BETA0_RAD));
90 this->insert(MAKE_ENTRY(JGANDALF_BETA1_RAD));
93 this->insert(MAKE_ENTRY(JENERGY_ENERGY));
94 this->insert(MAKE_ENTRY(JENERGY_CHI2));
95 this->insert(MAKE_ENTRY(JGANDALF_LAMBDA));
97 this->insert(MAKE_ENTRY(JSTART_ZMIN_M));
98 this->insert(MAKE_ENTRY(JSTART_ZMAX_M));
99 this->insert(MAKE_ENTRY(JSTART_NPE_MIP_TOTAL));
100 this->insert(MAKE_ENTRY(JSTART_NPE_MIP_MISSED));
101 this->insert(MAKE_ENTRY(JSTART_LENGTH_METRES));
102 this->insert(MAKE_ENTRY(JSTART_BACKGROUND_LOGP));
103 this->insert(MAKE_ENTRY(JVETO_NPE));
104 this->insert(MAKE_ENTRY(JVETO_NUMBER_OF_HITS));
107 this->insert(MAKE_ENTRY(JENERGY_NDF));
108 this->insert(MAKE_ENTRY(JENERGY_NUMBER_OF_HITS));
110 this->insert(MAKE_ENTRY(JPP_COVERAGE_POSITION));
111 this->insert(MAKE_ENTRY(JENERGY_MINIMAL_ENERGY));
112 this->insert(MAKE_ENTRY(JENERGY_MAXIMAL_ENERGY));
113 this->insert(MAKE_ENTRY(JSHOWERFIT_ENERGY));
114 this->insert(MAKE_ENTRY(AASHOWERFIT_ENERGY));
116
117#undef MAKE_ENTRY
118 }
119
120
121 /**
122 * Has weight.
123 *
124 * \param key key
125 * \return true if valid key; else false
126 */
127 bool operator()(const std::string& key) const
128 {
129 return this->count(key) != 0;
130 }
131
132
133 /**
134 * Get weight.
135 *
136 * \param fit fit
137 * \param key key
138 * \param value default value
139 * \return value
140 */
141 double operator()(const JFit& fit, const std::string& key, const double value) const
142 {
143 const_iterator p = this->find(key);
144
145 if (p != this->end() && fit.hasW(p->second))
146 return fit.getW(p->second);
147 else
148 return value;
149 }
150
151
152 /**
153 * Get weight.
154 *
155 * \param fit fir
156 * \param key key
157 * \param value default value
158 * \return value
159 */
160 double operator()(const Trk& fit, const std::string& key, const double value) const
161 {
162 const_iterator p = this->find(key);
163
164 if (p != this->end() && fit.fitinf.size() > (size_t) p->second)
165 return fit.fitinf[p->second];
166 else
167 return value;
168 }
169
171
172
173 /**
174 * Get position.
175 *
176 * \param fit fit
177 * \return position
178 */
179 inline JPosition3D getPosition(const JFit& fit)
180 {
181 return JPosition3D(fit.getX(), fit.getY(), fit.getZ());
182 }
183
184 /**
185 * Get point.
186 *
187 * \param fit fit
188 * \return point
189 */
190 inline JPoint4D getPoint(const JFit& fit)
191 {
192 return JPoint4D(getPosition(fit), fit.getT());
193 }
194
195 /**
196 * Get direction.
197 *
198 * \param fit fit
199 * \return direction
200 */
201 inline JDirection3D getDirection(const JFit& fit)
202 {
203 return JDirection3D(fit.getDX(), fit.getDY(), fit.getDZ());
204 }
205
206
207 /**
208 * Get vertex.
209 *
210 * \param fit fit
211 * \return vertex
212 */
213 inline JVertex3D getVertex(const JFit& fit)
214 {
215 return JVertex3D(getPosition(fit), fit.getT());
216 }
217
218
219 /**
220 * Get axis.
221 *
222 * \param fit fit
223 * \return axis
224 */
225 inline JAxis3D getAxis(const JFit& fit)
226 {
227 return JAxis3D(getPosition(fit), getDirection(fit));
228 }
229
230
231 /**
232 * Get track.
233 *
234 * \param fit fit
235 * \return track
236 */
237 inline JTrack3E getTrack(const JFit& fit)
238 {
239 return JTrack3E(JTrack3D(getAxis(fit), fit.getT()), fit.getE());
240 }
241
242
243 /**
244 * Get shower.
245 *
246 * \param fit fit
247 * \return shower
248 */
249 inline JShower3E getShower(const JFit& fit)
250 {
251 return JShower3E(JShower3D(getVertex(fit), getDirection(fit)), fit.getE());
252 }
253
254
255 /**
256 * Get fit.
257 *
258 * \param history history
259 * \param track track
260 * \param Q quality
261 * \param NDF number of degrees of freedom
262 * \param energy Energy, which would be set as 0, if the fit does not reconstruct energy
263 * \param status status of the fit as defined in enum JFitStatus.hh
264 * \return fit
265 */
266 inline JFit getFit(const JHistory& history,
267 const JTrack3D& track,
268 const double Q,
269 const int NDF,
270 const double energy = 0.0,
271 const int status = SINGLE_STAGE)
272 {
273 return JFit(history,
274 track.getX(), track.getY(), track.getZ(),
275 track.getDX(), track.getDY(), track.getDZ(),
276 track.getT(),
277 Q, NDF,
278 energy, status);
279 }
280
281
282 /**
283 * Get fit.
284 *
285 * \param history history
286 * \param track track
287 * \param angle angle
288 * \param Q quality
289 * \param NDF number of degrees of freedom
290 * \param energy Energy, which would be set as 0, if the fit does not reconstruct energy
291 * \param status status of the fit as defined in JFitStatus.hh
292 * \return fit
293 */
294 inline JFit getFit(const JHistory& history,
295 const JLine1Z& track,
296 const JAngle3D& angle,
297 const double Q,
298 const int NDF,
299 const double energy = 0.0,
300 const int status = SINGLE_STAGE)
301 {
302 return JFit(history,
303 track.getX(), track.getY(), track.getZ(),
304 angle.getDX(), angle.getDY(), angle.getDZ(),
305 track.getT(),
306 Q, NDF,
307 energy, status);
308 }
309
310
311 /**
312 * Get fit.
313 *
314 * \param history history
315 * \param shower shower
316 * \param Q quality
317 * \param NDF number of degrees of freedom
318 * \param energy Energy, which would be set as 0, if the fit does not reconstruct energy
319 * \param status status of the fit as defined in enum JFitStatus.hh
320 * \return fit
321 */
322 inline JFit getFit(const JHistory& history,
323 const JShower3D& shower,
324 const double Q,
325 const int NDF,
326 const double energy = 0.0,
327 const int status = SINGLE_STAGE)
328 {
329 return JFit(history,
330 shower.getX(), shower.getY(), shower.getZ(),
331 shower.getDX(), shower.getDY(), shower.getDZ(),
332 shower.getT(),
333 Q, NDF,
334 energy, status);
335 }
336
337
338 /**
339 * Get dot product.
340 *
341 * \param first first fit
342 * \param second second fit
343 * \return dot product
344 */
345 inline double getDot(const JFit& first, const JFit& second)
346 {
347 return JMATH::getDot(getDirection(first), getDirection(second));
348 }
349
350
351 /**
352 * Get dot product.
353 *
354 * \param fit fit
355 * \param dir direction
356 * \return dot product
357 */
358 inline double getDot(const JFit& fit, const JDirection3D& dir)
359 {
360 return JMATH::getDot(getDirection(fit), dir);
361 }
362
363
364 /**
365 * Get space angle.
366 *
367 * \param first first fit
368 * \param second second fit
369 * \return angle [deg]
370 */
371 inline double getAngle(const JFit& first, const JFit& second)
372 {
373 return JMATH::getAngle(getDirection(first), getDirection(second));
374 }
375
376
377 /**
378 * Get space angle.
379 *
380 * \param fit fit
381 * \param dir direction
382 * \return angle [deg]
383 */
384 inline double getAngle(const JFit& fit, const JDirection3D& dir)
385 {
386 return JMATH::getAngle(getDirection(fit), dir);
387 }
388
389
390 /**
391 * Get quality of fit.\n
392 * The larger the quality, the better the fit.
393 *
394 * \param chi2 chi2
395 * \param N number of hits
396 * \param NDF number of degrees of freedom
397 * \return quality
398 */
399 inline double getQuality(const double chi2, const int N, const int NDF)
400 {
401 return N - 0.25 * chi2 / NDF;
402 }
403
404
405 /**
406 * Get quality of fit.\n
407 * The larger the quality, the better the fit.
408 *
409 * \param chi2 chi2
410 * \param NDF number of degrees of freedom
411 * \return quality
412 */
413 inline double getQuality(const double chi2, const int NDF)
414 {
415 return NDF - 0.25 * chi2 / NDF;
416 }
417
418
419 /**
420 * Get quality of fit.\n
421 * The larger the quality, the better the fit.
422 *
423 * \param chi2 chi2
424 * \return quality
425 */
426 inline double getQuality(const double chi2)
427 {
428 return -chi2;
429 }
430
431
432 /**
433 * Comparison of fit results.
434 *
435 * \param first first fit
436 * \param second second fit
437 * \return true if first fit has better quality than second; else false
438 */
439 inline bool qualitySorter(const JFit& first, const JFit& second)
440 {
441 if (first.getHistory().size() == second.getHistory().size())
442 return first.getQ() > second.getQ();
443 else
444 return first.getHistory().size() > second.getHistory().size();
445 }
446
447
448 /**
449 * General purpose sorter of fit results.
450 *
451 * The default constructor will sort fit results according the method JRECONSTRUCTION::qualitySorter.\n
452 * A different method can dynamically be loaded from a (shared) library using class JEEP::JFunctionAdaptor.
453 * For the definition of an alternative method, see e.g.\ quality_sorter.cc
454 */
456 public JFunctionAdaptor<bool, const JFit&, const JFit&>
457 {
460
461
462 /**
463 * Default constructor.
464 */
468 };
469
470
471 /**
472 * Test whether given fit has specified history.
473 *
474 * \param fit fit
475 * \param type application type
476 * \return true if type in history; else false
477 */
478 inline bool has_history(const JFit& fit, const int type)
479 {
480 return std::find_if(fit.getHistory().begin(),
481 fit.getHistory().end(),
482 JLANG::make_predicate(&JEvent::type, type)) != fit.getHistory().end();
483 }
484
485
486 /**
487 * Test whether given fit has specified history.
488 *
489 * \param fit fit
490 * \param range application type range
491 * \return true if type in history; else false
492 */
493 inline bool has_history(const JFit& fit, const JRange<int>& range)
494 {
495 return std::find_if(fit.getHistory().begin(),
496 fit.getHistory().end(),
497 JLANG::make_find_if(&JEvent::type, range)) != fit.getHistory().end();
498 }
499
500
501 /**
502 * Test whether given fit has muon prefit in history.
503 *
504 * \param fit fit
505 * \return true if muon prefit in history; else false
506 */
507 inline bool has_muon_prefit(const JFit& fit)
508 {
509 return has_history(fit, JMUONPREFIT);
510 }
511
512
513 /**
514 * Test whether given fit has muon simplex in history.
515 *
516 * \param fit fit
517 * \return true if muon simplex in history; else false
518 */
519 inline bool has_muon_simplex(const JFit& fit)
520 {
521 return has_history(fit, JMUONSIMPLEX);
522 }
523
524
525 /**
526 * Test whether given fit has muon gandalf in history.
527 *
528 * \param fit fit
529 * \return true if muon gandalf in history; else false
530 */
531 inline bool has_muon_gandalf(const JFit& fit)
532 {
533 return has_history(fit, JMUONGANDALF);
534 }
535
536
537 /**
538 * Test whether given fit has muon energy in history.
539 *
540 * \param fit fit
541 * \return true if muon energy in history; else false
542 */
543 inline bool has_muon_energy(const JFit& fit)
544 {
545 return has_history(fit, JMUONENERGY);
546 }
547
548
549 /**
550 * Test whether given fit has muon start in history.
551 *
552 * \param fit fit
553 * \return true if muon start in history; else false
554 */
555 inline bool has_muon_start(const JFit& fit)
556 {
557 return has_history(fit, JMUONSTART);
558 }
559
560
561 /**
562 * Test whether given fit has muon fit in history.
563 *
564 * \param fit fit
565 * \return true if muon fit in history; else false
566 */
567 inline bool has_muon_fit(const JFit& fit)
568 {
570 }
571
572
573 /**
574 * Test whether given fit has shower prefit in history.
575 *
576 * \param fit fit
577 * \return true if shower prefit in history; else false
578 */
579 inline bool has_shower_prefit(const JFit& fit)
580 {
581 return has_history(fit, JSHOWERPREFIT);
582 }
583
584
585 /**
586 * Test whether given fit has shower position fit in history.
587 *
588 * \param fit fit
589 * \return true if shower position fit in history; else false
590 */
591 inline bool has_shower_positionfit(const JFit& fit)
592 {
593 return has_history(fit, JSHOWERPOSITIONFIT);
594 }
595
596
597 /**
598 * Test whether given fit has shower complete fit in history.
599 *
600 * \param fit fit
601 * \return true if shower complete fit in history; else false
602 */
603 inline bool has_shower_completefit(const JFit& fit)
604 {
605 return has_history(fit, JSHOWERCOMPLETEFIT);
606 }
607
608
609 /**
610 * Test whether given fit has shower fit in history.
611 *
612 * \param fit fit
613 * \return true if shower fit in history; else false
614 */
615 inline bool has_shower_fit(const JFit& fit)
616 {
618 }
619
620
621 /**
622 * Test whether given event has a track according selection.\n
623 * The track selector corresponds to the function operator <tt>bool selector(const JFit&);</tt>.
624 *
625 * \param evt event
626 * \param selector track selector
627 * \return true if at least one corresponding track; else false
628 */
629 template<class JTrackSelector_t>
630 inline bool has_reconstructed_track(const JEvt& evt, JTrackSelector_t selector)
631 {
632 return std::find_if(evt.begin(), evt.end(), selector) != evt.end();
633 }
634
635
636 /**
637 * Test whether given event has a track with muon reconstruction.
638 *
639 * \param evt event
640 * \return true if at least one reconstructed muon; else false
641 */
642 inline bool has_reconstructed_muon(const JEvt& evt)
643 {
645 }
646
647
648 /**
649 * Test whether given event has a track with shower reconstruction.
650 *
651 * \param evt event
652 * \return true if at least one reconstructed shower; else false
653 */
654 inline bool has_reconstructed_shower(const JEvt& evt)
655 {
657 }
658
659
660 /**
661 * Get best reconstructed track.\n
662 * The track selector corresponds to the function operator <tt>bool selector(const Trk&);</tt> and
663 * the track comparator to <tt>bool comparator(const Trk&, const Trk&);</tt>.
664 *
665 * \param evt event
666 * \param selector track selector
667 * \param comparator track comparator
668 * \return track
669 */
670 template<class JTrackSelector_t, class JQualitySorter_t>
671 inline const JFit& get_best_reconstructed_track(const JEvt& evt,
672 JTrackSelector_t selector,
673 JQualitySorter_t comparator)
674 {
675 JEvt::const_iterator p = std::find_if(evt.begin(), evt.end(), selector);
676
677 for (JEvt::const_iterator i = p; i != evt.end(); ++i) {
678 if (selector(*i) && comparator(*i, *p)) {
679 p = i;
680 }
681 }
682
683 if (p != evt.end())
684 return *p;
685 else
686 THROW(JIndexOutOfRange, "This event has no fit with given selector.");
687 }
688
689
690 /**
691 * Get best reconstructed muon.
692 *
693 * \param evt event
694 * \return track
695 */
696 inline const JFit& get_best_reconstructed_muon(const JEvt& evt)
697 {
699 }
700
701
702 /**
703 * Get best reconstructed shower.
704 *
705 * \param evt event
706 * \return track
707 */
708 inline const JFit& get_best_reconstructed_shower(const JEvt& evt)
709 {
711 }
712
713
714 /**
715 * Auxiliary class to compare fit results with respect to a reference direction (e.g.\ true muon).
716 * The sort operation results in an ordered set of fit results with increasing angle between
717 * the reference direction and that of the fit results.
718 */
719 class JPointing :
720 public JDirection3D
721 {
722 public:
723
725
726 /**
727 * Default constructor.
728 */
730 {}
731
732
733 /**
734 * Constructor.
735 *
736 * \param dir reference direction
737 */
739 JDirection3D(dir)
740 {}
741
742
743 /**
744 * Constructor.
745 *
746 * \param fit fit
747 */
748 JPointing(const JFit& fit) :
750 {}
751
752
753 /**
754 * Get dot product.
755 *
756 * \param fit fit
757 * \return dot product
758 */
759 inline double getDot(const JFit& fit) const
760 {
761 const double dot = JRECONSTRUCTION::getDot(fit, this->getDirection());
762
763 if (dot >= +1.0)
764 return +1.0;
765 else if (dot <= -1.0)
766 return -1.0;
767 else
768 return dot;
769 }
770
771
772 /**
773 * Get angle between reference direction and fit result.
774 *
775 * \param fit fit
776 * \return angle [deg]
777 */
778 inline double getAngle(const JFit& fit) const
779 {
780 return acos(this->getDot(fit)) * 180.0 / JMATH::PI;
781 }
782
783
784 /**
785 * Comparison of fit results.
786 *
787 * \param first first fit
788 * \param second second fit
789 * \return true if first fit better; else false
790 */
791 inline bool operator()(const JFit& first, const JFit& second) const
792 {
793 return this->getDot(first) > this->getDot(second);
794 }
795
796
797 /**
798 * Select best fit result.
799 *
800 * \param __begin begin of fit results
801 * \param __end end of fit results
802 * \return best fit result
803 */
804 template<class T>
805 inline T operator()(T __begin, T __end) const
806 {
807 return std::min_element(__begin, __end, *this);
808 }
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 * Auxiliary class to evaluate atmospheric muon hypothesis.
966 * The hypothesis is tested by means of the difference in quality
967 * between the best upward and best downward track.
968 */
970 public:
971 /**
972 * Default constructor.
973 */
975 dot1(0.0),
976 dot2(0.0)
977 {}
978
979
980 /**
981 * Constructor.
982 *
983 * \param theta1 upper hemisphere angle [deg]
984 * \param theta2 lower hemisphere angle [deg]
985 */
986 JAtmosphericMuon(const double theta1,
987 const double theta2) :
988 dot1(cos(theta1 * JMATH::PI/180.0)),
989 dot2(cos(theta2 * JMATH::PI/180.0))
990 {}
991
992
993 /**
994 * Test is event is atmospheric muon.
995 *
996 * \param __begin begin of data
997 * \param __end end of data
998 * \return negative if preferably down / positive if preferably up
999 */
1000 double operator()(JEvt::const_iterator __begin,
1001 JEvt::const_iterator __end) const
1002 {
1003 double Qup = 0.0;
1004 double Qdown = 0.0;
1005
1006 for (JEvt::const_iterator i = __begin; i != __end; ++i) {
1007
1008 if (i->getDZ() >= dot1) {
1009
1010 if (i->getQ() > Qup) {
1011 Qup = i->getQ();
1012 }
1013
1014 } else if (i->getDZ() <= dot2) {
1015
1016 if (i->getQ() > Qdown) {
1017 Qdown = i->getQ();
1018 }
1019 }
1020 }
1021
1022 return Qup - Qdown;
1023 }
1024
1025
1026 /**
1027 * Read atmospheric muon analyser from input.
1028 *
1029 * \param in input stream
1030 * \param object atmospheric muon analyser
1031 * \return input stream
1032 */
1033 friend inline std::istream& operator>>(std::istream& in, JAtmosphericMuon& object)
1034 {
1035 double theta1, theta2;
1036
1037 in >> theta1 >> theta2;
1038
1039 object.dot1 = cos(theta1 * JMATH::PI/180.0);
1040 object.dot2 = cos(theta2 * JMATH::PI/180.0);
1041
1042 return in;
1043 }
1044
1045
1046 /**
1047 * Write atmospheric muon analyser to output.
1048 *
1049 * \param out output stream
1050 * \param object atmospheric muon analyser
1051 * \return output stream
1052 */
1053 friend inline std::ostream& operator<<(std::ostream& out, const JAtmosphericMuon& object)
1054 {
1055 out << acos(object.dot1) * 180.0 / JMATH::PI << ' '
1056 << acos(object.dot2) * 180.0 / JMATH::PI;
1057
1058 return out;
1059 }
1060
1061
1062 double dot1;
1063 double dot2;
1064 };
1065}
1066
1067#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.
const JDirection3D & getDirection() const
Get direction.
double getDot(const JAngle3D &angle) const
Get dot product.
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.
double getDot(const JFit &fit) const
Get dot product.
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.5 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.
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