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

Program to perform JFIT::JRegressor<JFIT::JLine3Z,JFIT::JGandalf> fit with I/O of JFIT::JEvt data. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "TROOT.h"
#include "TFile.h"
#include "TProfile.h"
#include "TH2D.h"
#include "km3net-dataformat/offline/Head.hh"
#include "km3net-dataformat/offline/Evt.hh"
#include "JDAQ/JDAQEventIO.hh"
#include "JDAQ/JDAQTimesliceIO.hh"
#include "JDAQ/JDAQSummarysliceIO.hh"
#include "JTrigger/JTriggerParameters.hh"
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JDetector/JModuleRouter.hh"
#include "JSupport/JSupport.hh"
#include "JSupport/JParallelFileScanner.hh"
#include "JSupport/JFileRecorder.hh"
#include "JSupport/JSummaryFileRouter.hh"
#include "JSupport/JMeta.hh"
#include "JReconstruction/JEvt.hh"
#include "JReconstruction/JMuonGandalf.hh"
#include "JReconstruction/JMuonGandalfParameters_t.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

Program to perform JFIT::JRegressor<JFIT::JLine3Z,JFIT::JGandalf> fit with I/O of JFIT::JEvt data.

Author
mdejong, gmaggi

Definition in file JMuonGandalf.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 44 of file JMuonGandalf.cc.

45 {
46  using namespace std;
47  using namespace JPP;
48  using namespace KM3NETDAQ;
49 
51  typedef JParallelFileScanner< JTypeList<JDAQEvent, JEvt> > JParallelFileScanner_t;
52  typedef JParallelFileScanner_t::multi_pointer_type multi_pointer_type;
53 
54  JParallelFileScanner_t inputFile;
56  JLimit_t& numberOfEvents = inputFile.getLimit();
57  string detectorFile;
58  string pdfFile;
60  int debug;
61 
62 
63  try {
64 
65  JParser<> zap("Program to perform PDF fit of muon trajectory to data.");
66 
67  zap['f'] = make_field(inputFile);
68  zap['o'] = make_field(outputFile) = "gandalf.root";
69  zap['a'] = make_field(detectorFile);
70  zap['n'] = make_field(numberOfEvents) = JLimit::max();
71  zap['P'] = make_field(pdfFile);
73  zap['d'] = make_field(debug) = 1;
74 
75  zap(argc, argv);
76  }
77  catch(const exception& error) {
78  FATAL(error.what() << endl);
79  }
80 
81  cout.tie(&cerr);
82 
84 
85  try {
86  load(detectorFile, detector);
87  }
88  catch(const JException& error) {
89  FATAL(error);
90  }
91 
92  const JModuleRouter router(detector);
93 
94  JSummaryFileRouter summary(inputFile, parameters.R_Hz);
95 
96  JMuonGandalf fit(parameters, router, summary, pdfFile, debug);
97 
98 
99  outputFile.open();
100  outputFile.put(JMeta(argc, argv));
101 
102  while (inputFile.hasNext()) {
103 
104  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
105 
106  multi_pointer_type ps = inputFile.next();
107 
108  const JDAQEvent* tev = ps;
109  const JEvt* in = ps;
110 
111  summary.update(*tev);
112 
113 
114  // select start values
115 
116  JEvt cp = *in;
117 
118  if (parameters.reprocess) {
120  }
121 
122  cp.select(parameters.numberOfPrefits, qualitySorter);
123 
124  if (!cp.empty()) {
125  cp.select(JHistory::is_event(cp.begin()->getHistory()));
126  }
127 
128  // fit
129 
130  JEvt out = fit(*tev, cp);
131 
132 
133  // apply default sorter
134 
135  sort(out.begin(), out.end(), qualitySorter);
136 
137  copy(in->begin(), in->end(), back_inserter(out));
138 
139  outputFile.put(out);
140  }
141  STATUS(endl);
142 
144 
145  io >> outputFile;
146 
147  outputFile.close();
148 }
Auxiliary class for ROOT I/O of application specific meta data.
Definition: JMeta.hh:71
Object writing to file.
Utility class to parse command line options.
Definition: JParser.hh:1493
General exception.
Definition: JException.hh:23
#define STATUS(A)
Definition: JMessage.hh:63
Detector data structure.
Definition: JDetector.hh:80
Router for direct addressing of module data in detector data structure.
esac print_variable DETECTOR INPUT_FILE OUTPUT_FILE CDF for TYPE in
Definition: JSirene.sh:45
*fatal Wrong number of arguments esac JCookie sh typeset Z DETECTOR typeset Z SOURCE_RUN typeset Z TARGET_RUN set_variable PARAMETERS_FILE $WORKDIR parameters
Definition: diff-Tuna.sh:38
General purpose class for parallel reading of objects from a single file or multiple files...
Auxiliary class to test history.
Definition: JHistory.hh:152
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:63
string outputFile
Wrapper class to make final fit of muon trajectory.
Definition: JMuonGandalf.hh:72
Type list.
Definition: JTypeList.hh:22
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
Detector file.
Definition: JHead.hh:130
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1954
Auxiliary class to test history.
Definition: JHistory.hh:104
static const int JMUONGANDALF
File router for fast addressing of summary data.
void load(const JString &file_name, JDetector &detector)
Load detector from input file.
int debug
debug level
Definition: JSirene.cc:61
#define FATAL(A)
Definition: JMessage.hh:67
Data structure for set of track fit results.
Definition: JEvt.hh:294
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition: JHead.cc:153
Object reading from a list of files.
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:73
void select(const JSelector_t &selector)
Select fits.
Definition: JEvt.hh:314
bool qualitySorter(const JRECONSTRUCTION::JFit &first, const JRECONSTRUCTION::JFit &second)
Comparison of fit results.
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62