Jpp
Functions
JHistory.cc File Reference
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <iterator>
#include "JFit/JFitApplications.hh"
#include "JFit/JEvt.hh"
#include "JFit/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 JHistory.cc.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 21 of file JHistory.cc.

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