Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JHistory.cc File Reference

Example program to test application history. More...

#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

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 JFitApplication_t 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 }
Utility class to parse command line options.
Definition: JParser.hh:1410
bool has_muon_prefit(const Trk &track)
Test whether given track has muon prefit in history.
bool has_reconstructed_track(const Evt &evt, JTrackSelector_t selector)
Test whether given event has a track according selection.
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
bool has_reconstructed_muon(const Evt &evt)
Test whether given event has a track with muon reconstruction.
bool has_muon_start(const Trk &track)
Test whether given track has muon start fit in history.
#define ASSERT(A)
Assert macro.
Definition: JMessage.hh:72
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1836
bool has_muon_gandalf(const Trk &track)
Test whether given track has muon gandalf fit in history.
int debug
debug level
Definition: JSirene.cc:59
#define FATAL(A)
Definition: JMessage.hh:65
const Trk & get_best_reconstructed_muon(const Evt &evt)
Get best reconstructed muon.
bool has_muon_simplex(const Trk &track)
Test whether given track has muon simplex fit in history.
bool has_muon_energy(const Trk &track)
Test whether given track has muon energy fit in history.
bool has_reconstructed_shower(const Evt &evt)
Test whether given event has a track with shower reconstruction.
bool qualitySorter(const JFIT::JFit &first, const JFIT::JFit &second)
Comparison of fit results.
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition: JHead.cc:40
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:60