Jpp 20.0.0-195-g190c9e876
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
13
14#include "JLang/JException.hh"
15#include "JLang/JPredicate.hh"
16#include "JLang/JFind_if.hh"
17#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
152
153
154 /**
155 * Get position.
156 *
157 * \param fit fit
158 * \return position
159 */
160 inline JPosition3D getPosition(const JFit& fit)
161 {
162 return JPosition3D(fit.getX(), fit.getY(), fit.getZ());
163 }
164
165 /**
166 * Get point.
167 *
168 * \param fit fit
169 * \return point
170 */
171 inline JPoint4D getPoint(const JFit& fit)
172 {
173 return JPoint4D(getPosition(fit), fit.getT());
174 }
175
176 /**
177 * Get direction.
178 *
179 * \param fit fit
180 * \return direction
181 */
182 inline JDirection3D getDirection(const JFit& fit)
183 {
184 return JDirection3D(fit.getDX(), fit.getDY(), fit.getDZ());
185 }
186
187
188 /**
189 * Get vertex.
190 *
191 * \param fit fit
192 * \return vertex
193 */
194 inline JVertex3D getVertex(const JFit& fit)
195 {
196 return JVertex3D(getPosition(fit), fit.getT());
197 }
198
199
200 /**
201 * Get axis.
202 *
203 * \param fit fit
204 * \return axis
205 */
206 inline JAxis3D getAxis(const JFit& fit)
207 {
208 return JAxis3D(getPosition(fit), getDirection(fit));
209 }
210
211
212 /**
213 * Get track.
214 *
215 * \param fit fit
216 * \return track
217 */
218 inline JTrack3E getTrack(const JFit& fit)
219 {
220 return JTrack3E(JTrack3D(getAxis(fit), fit.getT()), fit.getE());
221 }
222
223
224 /**
225 * Get shower.
226 *
227 * \param fit fit
228 * \return shower
229 */
230 inline JShower3E getShower(const JFit& fit)
231 {
232 return JShower3E(JShower3D(getVertex(fit), getDirection(fit)), fit.getE());
233 }
234
235
236 /**
237 * Get fit.
238 *
239 * \param history history
240 * \param track track
241 * \param Q quality
242 * \param NDF number of degrees of freedom
243 * \param energy Energy, which would be set as 0, if the fit does not reconstruct energy
244 * \param status status of the fit as defined in enum JFitStatus.hh
245 * \return fit
246 */
247 inline JFit getFit(const JHistory& history,
248 const JTrack3D& track,
249 const double Q,
250 const int NDF,
251 const double energy = 0.0,
252 const int status = SINGLE_STAGE)
253 {
254 return JFit(history,
255 track.getX(), track.getY(), track.getZ(),
256 track.getDX(), track.getDY(), track.getDZ(),
257 track.getT(),
258 Q, NDF,
259 energy, status);
260 }
261
262
263 /**
264 * Get fit.
265 *
266 * \param history history
267 * \param track track
268 * \param angle angle
269 * \param Q quality
270 * \param NDF number of degrees of freedom
271 * \param energy Energy, which would be set as 0, if the fit does not reconstruct energy
272 * \param status status of the fit as defined in JFitStatus.hh
273 * \return fit
274 */
275 inline JFit getFit(const JHistory& history,
276 const JLine1Z& track,
277 const JAngle3D& angle,
278 const double Q,
279 const int NDF,
280 const double energy = 0.0,
281 const int status = SINGLE_STAGE)
282 {
283 return JFit(history,
284 track.getX(), track.getY(), track.getZ(),
285 angle.getDX(), angle.getDY(), angle.getDZ(),
286 track.getT(),
287 Q, NDF,
288 energy, status);
289 }
290
291
292 /**
293 * Get fit.
294 *
295 * \param history history
296 * \param shower shower
297 * \param Q quality
298 * \param NDF number of degrees of freedom
299 * \param energy Energy, which would be set as 0, if the fit does not reconstruct energy
300 * \param status status of the fit as defined in enum JFitStatus.hh
301 * \return fit
302 */
303 inline JFit getFit(const JHistory& history,
304 const JShower3D& shower,
305 const double Q,
306 const int NDF,
307 const double energy = 0.0,
308 const int status = SINGLE_STAGE)
309 {
310 return JFit(history,
311 shower.getX(), shower.getY(), shower.getZ(),
312 shower.getDX(), shower.getDY(), shower.getDZ(),
313 shower.getT(),
314 Q, NDF,
315 energy, status);
316 }
317
318
319 /**
320 * Get dot product.
321 *
322 * \param first first fit
323 * \param second second fit
324 * \return dot product
325 */
326 inline double getDot(const JFit& first, const JFit& second)
327 {
328 return JMATH::getDot(getDirection(first), getDirection(second));
329 }
330
331
332 /**
333 * Get dot product.
334 *
335 * \param fit fit
336 * \param dir direction
337 * \return dot product
338 */
339 inline double getDot(const JFit& fit, const JDirection3D& dir)
340 {
341 return JMATH::getDot(getDirection(fit), dir);
342 }
343
344
345 /**
346 * Get space angle.
347 *
348 * \param first first fit
349 * \param second second fit
350 * \return angle [deg]
351 */
352 inline double getAngle(const JFit& first, const JFit& second)
353 {
354 return JMATH::getAngle(getDirection(first), getDirection(second));
355 }
356
357
358 /**
359 * Get space angle.
360 *
361 * \param fit fit
362 * \param dir direction
363 * \return angle [deg]
364 */
365 inline double getAngle(const JFit& fit, const JDirection3D& dir)
366 {
367 return JMATH::getAngle(getDirection(fit), dir);
368 }
369
370
371 /**
372 * Get quality of fit.\n
373 * The larger the quality, the better the fit.
374 *
375 * \param chi2 chi2
376 * \param N number of hits
377 * \param NDF number of degrees of freedom
378 * \return quality
379 */
380 inline double getQuality(const double chi2, const int N, const int NDF)
381 {
382 return N - 0.25 * chi2 / NDF;
383 }
384
385
386 /**
387 * Get quality of fit.\n
388 * The larger the quality, the better the fit.
389 *
390 * \param chi2 chi2
391 * \param NDF number of degrees of freedom
392 * \return quality
393 */
394 inline double getQuality(const double chi2, const int NDF)
395 {
396 return NDF - 0.25 * chi2 / NDF;
397 }
398
399
400 /**
401 * Get quality of fit.\n
402 * The larger the quality, the better the fit.
403 *
404 * \param chi2 chi2
405 * \return quality
406 */
407 inline double getQuality(const double chi2)
408 {
409 return -chi2;
410 }
411
412
413 /**
414 * Comparison of fit results.
415 *
416 * \param first first fit
417 * \param second second fit
418 * \return true if first fit has better quality than second; else false
419 */
420 inline bool qualitySorter(const JFit& first, const JFit& second)
421 {
422 if (first.getHistory().size() == second.getHistory().size())
423 return first.getQ() > second.getQ();
424 else
425 return first.getHistory().size() > second.getHistory().size();
426 }
427
428
429 /**
430 * General purpose sorter of fit results.
431 *
432 * The default constructor will sort fit results according the method JRECONSTRUCTION::qualitySorter.\n
433 * A different method can dynamically be loaded from a (shared) library using class JEEP::JFunctionAdaptor.
434 * For the definition of an alternative method, see e.g.\ quality_sorter.cc
435 */
437 public JFunctionAdaptor<bool, const JFit&, const JFit&>
438 {
441
442
443 /**
444 * Default constructor.
445 */
449 };
450
451
452 /**
453 * Test whether given fit has specified history.
454 *
455 * \param fit fit
456 * \param type application type
457 * \return true if type in history; else false
458 */
459 inline bool has_history(const JFit& fit, const int type)
460 {
461 return std::find_if(fit.getHistory().begin(),
462 fit.getHistory().end(),
463 JLANG::make_predicate(&JEvent::type, type)) != fit.getHistory().end();
464 }
465
466
467 /**
468 * Test whether given fit has specified history.
469 *
470 * \param fit fit
471 * \param range application type range
472 * \return true if type in history; else false
473 */
474 inline bool has_history(const JFit& fit, const JRange<int>& range)
475 {
476 return std::find_if(fit.getHistory().begin(),
477 fit.getHistory().end(),
478 JLANG::make_find_if(&JEvent::type, range)) != fit.getHistory().end();
479 }
480
481
482 /**
483 * Test whether given fit has muon prefit in history.
484 *
485 * \param fit fit
486 * \return true if muon prefit in history; else false
487 */
488 inline bool has_muon_prefit(const JFit& fit)
489 {
490 return has_history(fit, JMUONPREFIT);
491 }
492
493
494 /**
495 * Test whether given fit has muon simplex in history.
496 *
497 * \param fit fit
498 * \return true if muon simplex in history; else false
499 */
500 inline bool has_muon_simplex(const JFit& fit)
501 {
502 return has_history(fit, JMUONSIMPLEX);
503 }
504
505
506 /**
507 * Test whether given fit has muon gandalf in history.
508 *
509 * \param fit fit
510 * \return true if muon gandalf in history; else false
511 */
512 inline bool has_muon_gandalf(const JFit& fit)
513 {
514 return has_history(fit, JMUONGANDALF);
515 }
516
517
518 /**
519 * Test whether given fit has muon energy in history.
520 *
521 * \param fit fit
522 * \return true if muon energy in history; else false
523 */
524 inline bool has_muon_energy(const JFit& fit)
525 {
526 return has_history(fit, JMUONENERGY);
527 }
528
529
530 /**
531 * Test whether given fit has muon start in history.
532 *
533 * \param fit fit
534 * \return true if muon start in history; else false
535 */
536 inline bool has_muon_start(const JFit& fit)
537 {
538 return has_history(fit, JMUONSTART);
539 }
540
541
542 /**
543 * Test whether given fit has muon fit in history.
544 *
545 * \param fit fit
546 * \return true if muon fit in history; else false
547 */
548 inline bool has_muon_fit(const JFit& fit)
549 {
551 }
552
553
554 /**
555 * Test whether given fit has shower prefit in history.
556 *
557 * \param fit fit
558 * \return true if shower prefit in history; else false
559 */
560 inline bool has_shower_prefit(const JFit& fit)
561 {
562 return has_history(fit, JSHOWERPREFIT);
563 }
564
565
566 /**
567 * Test whether given fit has shower position fit in history.
568 *
569 * \param fit fit
570 * \return true if shower position fit in history; else false
571 */
572 inline bool has_shower_positionfit(const JFit& fit)
573 {
574 return has_history(fit, JSHOWERPOSITIONFIT);
575 }
576
577
578 /**
579 * Test whether given fit has shower complete fit in history.
580 *
581 * \param fit fit
582 * \return true if shower complete fit in history; else false
583 */
584 inline bool has_shower_completefit(const JFit& fit)
585 {
586 return has_history(fit, JSHOWERCOMPLETEFIT);
587 }
588
589
590 /**
591 * Test whether given fit has shower fit in history.
592 *
593 * \param fit fit
594 * \return true if shower fit in history; else false
595 */
596 inline bool has_shower_fit(const JFit& fit)
597 {
599 }
600
601
602 /**
603 * Test whether given event has a track according selection.\n
604 * The track selector corresponds to the function operator <tt>bool selector(const JFit&);</tt>.
605 *
606 * \param evt event
607 * \param selector track selector
608 * \return true if at least one corresponding track; else false
609 */
610 template<class JTrackSelector_t>
611 inline bool has_reconstructed_track(const JEvt& evt, JTrackSelector_t selector)
612 {
613 return std::find_if(evt.begin(), evt.end(), selector) != evt.end();
614 }
615
616
617 /**
618 * Test whether given event has a track with muon reconstruction.
619 *
620 * \param evt event
621 * \return true if at least one reconstructed muon; else false
622 */
623 inline bool has_reconstructed_muon(const JEvt& evt)
624 {
626 }
627
628
629 /**
630 * Test whether given event has a track with shower reconstruction.
631 *
632 * \param evt event
633 * \return true if at least one reconstructed shower; else false
634 */
635 inline bool has_reconstructed_shower(const JEvt& evt)
636 {
638 }
639
640
641 /**
642 * Get best reconstructed track.\n
643 * The track selector corresponds to the function operator <tt>bool selector(const Trk&);</tt> and
644 * the track comparator to <tt>bool comparator(const Trk&, const Trk&);</tt>.
645 *
646 * \param evt event
647 * \param selector track selector
648 * \param comparator track comparator
649 * \return track
650 */
651 template<class JTrackSelector_t, class JQualitySorter_t>
652 inline const JFit& get_best_reconstructed_track(const JEvt& evt,
653 JTrackSelector_t selector,
654 JQualitySorter_t comparator)
655 {
656 JEvt::const_iterator p = std::find_if(evt.begin(), evt.end(), selector);
657
658 for (JEvt::const_iterator i = p; i != evt.end(); ++i) {
659 if (selector(*i) && comparator(*i, *p)) {
660 p = i;
661 }
662 }
663
664 if (p != evt.end())
665 return *p;
666 else
667 THROW(JIndexOutOfRange, "This event has no fit with given selector.");
668 }
669
670
671 /**
672 * Get best reconstructed muon.
673 *
674 * \param evt event
675 * \return track
676 */
677 inline const JFit& get_best_reconstructed_muon(const JEvt& evt)
678 {
680 }
681
682
683 /**
684 * Get best reconstructed shower.
685 *
686 * \param evt event
687 * \return track
688 */
689 inline const JFit& get_best_reconstructed_shower(const JEvt& evt)
690 {
692 }
693
694
695 /**
696 * Auxiliary class to compare fit results with respect to a reference direction (e.g.\ true muon).
697 * The sort operation results in an ordered set of fit results with increasing angle between
698 * the reference direction and that of the fit results.
699 */
700 class JPointing {
701 public:
702 /**
703 * Default constructor.
704 */
706 {}
707
708
709 /**
710 * Constructor.
711 *
712 * \param dir reference direction
713 */
715 {
716 this->dir = dir;
717 }
718
719
720 /**
721 * Constructor.
722 *
723 * \param fit fit
724 */
725 JPointing(const JFit& fit)
726 {
728 }
729
730
731 /**
732 * Get direction.
733 *
734 * \return direction
735 */
737 {
738 return dir;
739 }
740
741
742 /**
743 * Get angle between reference direction and fit result.
744 *
745 * \param fit fit
746 * \return angle [deg]
747 */
748 inline double getAngle(const JFit& fit) const
749 {
750 const double dot = getDot(fit, dir);
751
752 if (dot >= +1.0)
753 return 0.0;
754 else if (dot <= -1.0)
755 return 180.0;
756 else
757 return acos(dot) * 180.0 / JMATH::PI;
758 }
759
760
761 /**
762 * Comparison of fit results.
763 *
764 * \param first first fit
765 * \param second second fit
766 * \return true if first fit better; else false
767 */
768 inline bool operator()(const JFit& first, const JFit& second) const
769 {
770 return getDot(first, dir) > getDot(second, dir);
771 }
772
773
774 /**
775 * Select best fit result.
776 *
777 * \param __begin begin of fit results
778 * \param __end end of fit results
779 * \return best fit result
780 */
781 template<class T>
782 inline T operator()(T __begin, T __end) const
783 {
784 return std::min_element(__begin, __end, *this);
785 }
786
787 protected:
789 };
790
791
792 /**
793 * Auxiliary class to compare fit results with respect to a reference 4D-position.
794 * The sort operation results in an ordered set of fit results with increasing distance between
795 * the reference position and that of the fit results.
796 */
797 class JPoint {
798 public:
799 /**
800 * Constructor.
801 *
802 * \param point reference position
803 */
805 {
806 this->point = point;
807 }
808
809 /**
810 * Constructor.
811 *
812 * \param fit fit
813 */
814 JPoint(const JFit& fit)
815 {
816 this->point = getPoint(fit);
817 }
818
819 /**
820 * Comparison of fit results.
821 *
822 * \param first first fit
823 * \param second second fit
824 * \return true if first fit better; else false
825 */
826 inline bool operator()(const JFit& first, const JFit& second) const
827 {
828 return this->point.get4Distance(getPoint(first)) < this->point.get4Distance(getPoint(second));
829 }
830
831 /**
832 * Select best fit result.
833 *
834 * \param __begin begin of fit results
835 * \param __end end of fit results
836 * \return best fit result
837 */
838 template<class T>
839 inline T operator()(T __begin, T __end) const
840 {
841 return std::min_element(__begin, __end, *this);
842 }
843
844 protected:
846 };
847
848
849 /**
850 * Auxiliary class to compare fit results with respect to a reference position.
851 * The sort operation results in an ordered set of fit results with increasing distance between
852 * the reference position and that of the fit results.
853 */
854 class JPosition {
855 public:
856 /**
857 * Constructor.
858 *
859 * \param pos reference position
860 */
862 {
863 this->pos = pos;
864 }
865
866 /**
867 * Comparison of fit results.
868 *
869 * \param first first fit
870 * \param second second fit
871 * \return true if first fit better; else false
872 */
873 inline bool operator()(const JFit& first, const JFit& second) const
874 {
875 return this->pos.getDistance(getPosition(first)) < this->pos.getDistance(getPosition(second));
876 }
877
878 /**
879 * Select best fit result.
880 *
881 * \param __begin begin of fit results
882 * \param __end end of fit results
883 * \return best fit result
884 */
885 template<class T>
886 inline T operator()(T __begin, T __end) const
887 {
888 return std::min_element(__begin, __end, *this);
889 }
890
891 protected:
893 };
894
895
896
897 /**
898 * Auxiliary class to compare fit results with respect to a reference energy.
899 * The sort operation results in an ordered set of fit results with increasing difference between
900 * the reference energy and that of the fit results.
901 */
903 public:
904 /**
905 * Constructor.
906 *
907 * \param E reference energy
908 */
910 {
911 this->energy = E;
912 }
913
914 /**
915 * Comparison of fit results.
916 *
917 * \param first first fit
918 * \param second second fit
919 * \return true if first fit better; else false
920 */
921 inline bool operator()(const JFit& first, const JFit& second) const
922 {
923 return fabs(this->energy - first.getE()) < fabs(this->energy - second.getE());
924 }
925
926 /**
927 * Select best fit result.
928 *
929 * \param __begin begin of fit results
930 * \param __end end of fit results
931 * \return best fit result
932 */
933 template<class T>
934 inline T operator()(T __begin, T __end) const
935 {
936 return std::min_element(__begin, __end, *this);
937 }
938
939 protected:
940 double energy;
941 };
942
943
944 /**
945 * Gridify set of fits.
946 *
947 * \param __begin begin of fits
948 * \param __end end of fits
949 * \param N number of directions in grid
950 * \return end of fits sorted by quality
951 */
952 inline JEvt::iterator gridify(JEvt::iterator __begin, JEvt::iterator __end, const int N)
953 {
954 using namespace std;
955 using namespace JPP;
956
957 static const double MINIMAL_ANGLE_DEG = 60.0;
958
959 // estimate grid angle
960
961 double angle_deg = 10.0 * sqrt((double) 240 / (double) N);
962
963 if (angle_deg > MINIMAL_ANGLE_DEG) {
964 angle_deg = MINIMAL_ANGLE_DEG;
965 }
966
967 const JOmega3D ps(angle_deg * PI/180.0);
968
969 JEvt::iterator out = __begin;
970
971 for (JOmega3D_t::const_iterator dir = ps.begin(); dir != ps.end() && out != __end; ++dir) {
972
973 const JPointing pointing(*dir);
974
975 sort(out, __end, pointing);
976
977 JEvt::iterator p = out;
978
979 for (JEvt::iterator i = out; i != __end && pointing.getAngle(*i) <= angle_deg; ++i) {
980 if (qualitySorter(*i, *p)) {
981 p = i;
982 }
983 }
984
985 swap(*(out++), *p);
986 }
987
988 sort(__begin, out, qualitySorter);
989
990 return out;
991 }
992
993
994 /**
995 * Auxiliary class to evaluate atmospheric muon hypothesis.
996 * The hypothesis is tested by means of the difference in quality
997 * between the best upward and best downward track.
998 */
1000 public:
1001 /**
1002 * Default constructor.
1003 */
1005 dot1(0.0),
1006 dot2(0.0)
1007 {}
1008
1009
1010 /**
1011 * Constructor.
1012 *
1013 * \param theta1 upper hemisphere angle [deg]
1014 * \param theta2 lower hemisphere angle [deg]
1015 */
1016 JAtmosphericMuon(const double theta1,
1017 const double theta2) :
1018 dot1(cos(theta1 * JMATH::PI/180.0)),
1019 dot2(cos(theta2 * JMATH::PI/180.0))
1020 {}
1021
1022
1023 /**
1024 * Test is event is atmospheric muon.
1025 *
1026 * \param __begin begin of data
1027 * \param __end end of data
1028 * \return negative if preferably down / positive if preferably up
1029 */
1030 double operator()(JEvt::const_iterator __begin,
1031 JEvt::const_iterator __end) const
1032 {
1033 double Qup = 0.0;
1034 double Qdown = 0.0;
1035
1036 for (JEvt::const_iterator i = __begin; i != __end; ++i) {
1037
1038 if (i->getDZ() >= dot1) {
1039
1040 if (i->getQ() > Qup) {
1041 Qup = i->getQ();
1042 }
1043
1044 } else if (i->getDZ() <= dot2) {
1045
1046 if (i->getQ() > Qdown) {
1047 Qdown = i->getQ();
1048 }
1049 }
1050 }
1051
1052 return Qup - Qdown;
1053 }
1054
1055
1056 /**
1057 * Read atmospheric muon analyser from input.
1058 *
1059 * \param in input stream
1060 * \param object atmospheric muon analyser
1061 * \return input stream
1062 */
1063 friend inline std::istream& operator>>(std::istream& in, JAtmosphericMuon& object)
1064 {
1065 double theta1, theta2;
1066
1067 in >> theta1 >> theta2;
1068
1069 object.dot1 = cos(theta1 * JMATH::PI/180.0);
1070 object.dot2 = cos(theta2 * JMATH::PI/180.0);
1071
1072 return in;
1073 }
1074
1075
1076 /**
1077 * Write atmospheric muon analyser to output.
1078 *
1079 * \param out output stream
1080 * \param object atmospheric muon analyser
1081 * \return output stream
1082 */
1083 friend inline std::ostream& operator<<(std::ostream& out, const JAtmosphericMuon& object)
1084 {
1085 out << acos(object.dot1) * 180.0 / JMATH::PI << ' '
1086 << acos(object.dot2) * 180.0 / JMATH::PI;
1087
1088 return out;
1089 }
1090
1091
1092 double dot1;
1093 double dot2;
1094 };
1095}
1096
1097#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.
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-4-g8b3df20 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.
bool operator()(const std::string &key) const
Has weight.
double operator()(const JFit &fit, const std::string &key, const double value) const
Get weight.