Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JHistory.cc File Reference

Example program to test application history. More...

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <iterator>
#include "JReconstruction/JEvt.hh"
#include "JReconstruction/JEvtToolkit.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Example program to test application history.

Author
mdejong

Definition in file examples/JReconstruction/JHistory.cc.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 20 of file examples/JReconstruction/JHistory.cc.

21{
22 using namespace std;
23 using namespace JPP;
24
25 int debug;
26
27 try {
28
29 JParser<> zap("Example program to test application history.");
30
31 zap['d'] = make_field(debug) = 3;
32
33 zap(argc, argv);
34 }
35 catch(const exception &error) {
36 FATAL(error.what() << endl);
37 }
38
39
40 const int numberOfFits = 3;
41
42 JEvt evt;
43
44 // JPrefit
45
46 for (int i = 0; i != numberOfFits; ++i) {
47 evt.push_back(getFit(JHistory(JMUONPREFIT), JTrack3D(), 0.0, 0));
48 }
49
50 // subsequent fits
51
52 const int application[] = { JMUONSIMPLEX,
54 //JMUONENERGY,
55 JMUONSTART };
56
57 for (int i = 0; i != sizeof(application)/sizeof(int); ++i) {
58
59 JEvt out;
60
61 // save previous results
62
63 copy(evt.begin(), evt.end(), back_inserter(out));
64
65 // sort quality
66
67 partial_sort(evt.begin(), evt.end(), evt.end(), qualitySorter);
68
69 // partition according history of best fit
70
71 JEvt::const_iterator __end = partition(evt.begin(), evt.end(), JHistory::is_event(evt.begin()->getHistory()));
72
73 for (JEvt::const_iterator fit = evt.begin(); fit != __end; ++fit) {
74 out.push_back(getFit(JHistory(fit->getHistory()).add(application[i]), JTrack3D(), 0, 0.0));
75 }
76
77 // apply default sorter
78
79 sort(out.begin(), out.end(), qualitySorter);
80
81 // mimic process chain
82
83 evt = out;
84 }
85
86 for (size_t i = 0; i != evt.size(); ++i) {
87 DEBUG("fit[" << i << "]" << endl << static_cast<const JHistory&>(evt[i]) << endl);
88 }
89
90 ASSERT((int) evt.size() == numberOfFits * (sizeof(application)/sizeof(int) + 1));
91
92 for (int i = 0; i != numberOfFits; ++i) {
93 ASSERT(has_muon_prefit (evt[i]) &&
94 has_muon_simplex(evt[i]) &&
95 has_muon_gandalf(evt[i]) &&
96 !has_muon_energy(evt[i]) && // disabled as test
97 has_muon_start (evt[i]));
98 }
99
100 ASSERT( has_reconstructed_track(evt, has_muon_prefit));
101 ASSERT( has_reconstructed_track(evt, has_muon_simplex));
102 ASSERT( has_reconstructed_track(evt, has_muon_gandalf));
103 ASSERT(!has_reconstructed_track(evt, has_muon_energy));
104 ASSERT( has_reconstructed_track(evt, has_muon_start));
105 ASSERT( has_reconstructed_muon (evt));
107
108 const JFit& fit = get_best_reconstructed_muon(evt);
109
110 ASSERT(has_muon_prefit (fit) &&
111 has_muon_simplex(fit) &&
112 has_muon_gandalf(fit) &&
113 !has_muon_energy(fit) && // disabled as test
114 has_muon_start (fit));
115
116 return 0;
117}
#define DEBUG(A)
Message macros.
Definition JMessage.hh:62
#define ASSERT(A,...)
Assert macro.
Definition JMessage.hh:90
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
Utility class to parse command line options.
Definition JParser.hh:1698
static const int JMUONGANDALF
static const int JMUONPREFIT
static const int JMUONSIMPLEX
static const int JMUONSTART
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition JHead.cc:163
JFit getFit(const int id, const JMODEL::JString &string)
Get fit parameters of string.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
bool has_muon_gandalf(const JFit &fit)
Test whether given fit has muon gandalf in history.
const JFit & get_best_reconstructed_muon(const JEvt &evt)
Get best reconstructed muon.
bool has_muon_energy(const JFit &fit)
Test whether given fit has muon energy in history.
bool has_reconstructed_shower(const JEvt &evt)
Test whether given event has a track with shower reconstruction.
bool has_muon_simplex(const JFit &fit)
Test whether given fit has muon simplex in history.
Acoustic event fit.
Auxiliary class to test history.
Definition JHistory.hh:136
Container for historical events.
Definition JHistory.hh:130
JHistory & add(const int type)
Add event to history.
Definition JHistory.hh:346
bool has_reconstructed_track(const Evt &evt, JTrackSelector_t selector)
Test whether given event has a track according selection.