Jpp  test_elongated_shower_pde
the software that should make you happy
 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 "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 JHistory.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 20 of file 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,
53  JMUONGANDALF,
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 
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 }
static const int JMUONSTART
bool has_muon_gandalf(const JFit &fit)
Test whether given fit has muon gandalf in history.
bool has_reconstructed_shower(const JEvt &evt)
Test whether given event has a track with shower reconstruction.
Utility class to parse command line options.
Definition: JParser.hh:1500
bool has_muon_start(const JFit &fit)
Test whether given fit has muon start in history.
bool qualitySorter(const JFit &first, const JFit &second)
Comparison of fit results.
const JFit & get_best_reconstructed_muon(const JEvt &evt)
Get best reconstructed muon.
static const int JMUONPREFIT
#define ASSERT(A,...)
Assert macro.
Definition: JMessage.hh:90
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
Auxiliary class to test history.
Definition: JHistory.hh:104
static const int JMUONGANDALF
bool has_muon_simplex(const JFit &fit)
Test whether given fit has muon simplex in history.
int debug
debug level
Definition: JSirene.cc:68
#define FATAL(A)
Definition: JMessage.hh:67
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.
JFIT::JHistory JHistory
Definition: JHistory.hh:301
bool has_reconstructed_muon(const JEvt &evt)
Test whether given event has a track with muon reconstruction.
static const int JMUONSIMPLEX
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition: JHead.cc:139
bool has_muon_prefit(const JFit &fit)
Test whether given fit has muon prefit in history.
bool has_reconstructed_track(const JEvt &evt, JTrackSelector_t selector)
Test whether given event has a track according selection.
bool has_muon_energy(const JFit &fit)
Test whether given fit has muon energy in history.