Jpp  pmt_effective_area_update
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JMuonPrefit.cc File Reference

Program to perform linear fits JFIT::JEstimator<JFIT::JLine1Z> covering the solid angle producing JFIT::JEvt data. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <memory>
#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 "JDAQ/JDAQEvaluator.hh"
#include "JTrigger/JTriggerParameters.hh"
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JDetector/JModuleRouter.hh"
#include "JDynamics/JDynamics.hh"
#include "JSupport/JSupport.hh"
#include "JSupport/JSingleFileScanner.hh"
#include "JSupport/JTreeScanner.hh"
#include "JSupport/JFileRecorder.hh"
#include "JSupport/JMeta.hh"
#include "JReconstruction/JEvt.hh"
#include "JReconstruction/JMuonPrefit.hh"
#include "JReconstruction/JMuonPrefitParameters_t.hh"
#include "JLang/JPredicate.hh"
#include "JLang/JComparison.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 linear fits JFIT::JEstimator<JFIT::JLine1Z> covering the solid angle producing JFIT::JEvt data.

Author
mdejong, gmaggi

Definition in file JMuonPrefit.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 46 of file JMuonPrefit.cc.

47 {
48  using namespace std;
49  using namespace JPP;
50  using namespace KM3NETDAQ;
51 
55  JACOUSTICS::JEvt>::typelist calibration_types;
56  typedef JMultipleFileScanner<calibration_types> JCalibration_t;
57 
58  JSingleFileScanner_t inputFile;
60  JLimit_t& numberOfEvents = inputFile.getLimit();
61  string detectorFile;
62  JCalibration_t calibrationFile;
63  double Tmax_s;
65  int debug;
66 
67  try {
68 
69  JParser<> zap("Program to perform pre-fit of muon trajectory to data.");
70 
71  zap['f'] = make_field(inputFile);
72  zap['o'] = make_field(outputFile) = "prefit.root";
73  zap['a'] = make_field(detectorFile);
74  zap['+'] = make_field(calibrationFile) = JPARSER::initialised();
75  zap['T'] = make_field(Tmax_s) = 100.0;
76  zap['n'] = make_field(numberOfEvents) = JLimit::max();
78  zap['d'] = make_field(debug) = 1;
79 
80  zap(argc, argv);
81  }
82  catch(const exception& error) {
83  FATAL(error.what() << endl);
84  }
85 
86  cout.tie(&cerr);
87 
89 
90  try {
91  load(detectorFile, detector);
92  }
93  catch(const JException& error) {
94  FATAL(error);
95  }
96 
97  getMechanics.load(detector.getID());
98 
99  unique_ptr<JDynamics> dynamics;
100 
101  try {
102 
103  dynamics.reset(new JDynamics(detector, Tmax_s));
104 
105  dynamics->load(calibrationFile);
106  }
107  catch(const exception& error) {
108  if (!calibrationFile.empty()) {
109  FATAL(error.what());
110  }
111  }
112 
113  const JModuleRouter router(dynamics ? dynamics->getDetector() : detector);
114 
115  JMuonPrefit fit(parameters, router, debug);
116 
117 
118  outputFile.open();
119  outputFile.put(JMeta(argc, argv));
120 
121  JTreeScanner<JDAQEvent, JDAQEvaluator> in (inputFile, inputFile.getLimit());
122 
123  while (in.hasNext()) {
124 
125  STATUS("event: " << setw(10) << in.getCounter() << '\r'); DEBUG(endl);
126 
127  const JDAQEvent* tev = in.next();
128 
129  if (dynamics) {
130  dynamics->update(*tev);
131  }
132 
133  JFIT::JEvt out = fit(*tev);
134 
135  if (dynamics) {
136 
137  const JDynamics::coverage_type coverage = dynamics->getCoverage();
138 
139  for (JFIT::JEvt::iterator i = out.begin(); i != out.end(); ++i) {
140  i->setW(JPP_COVERAGE_ORIENTATION, coverage.orientation);
141  i->setW(JPP_COVERAGE_POSITION, coverage.position);
142  }
143  }
144 
145  if (parameters.numberOfPrefits > 0) {
146 
147 
148  // apply default sorter
149 
150  JFIT::JEvt::iterator __end = out.end();
151 
152  if (parameters.numberOfPrefits < out.size()) {
153 
154  advance(__end = out.begin(), parameters.numberOfPrefits);
155 
156  partial_sort(out.begin(), __end, out.end(), qualitySorter);
157 
158  } else {
159 
160  sort(out.begin(), __end, qualitySorter);
161  }
162 
163  // add downward pointing solutions if available but not yet sufficient
164 
165  int nz = parameters.numberOfDZMax - count_if(out.begin(), __end, make_predicate(&JFIT::JFit::getDZ, parameters.DZMax, JComparison::le()));
166 
167  if (nz > 0) {
168 
169  JFIT::JEvt::iterator __p = __end;
170  JFIT::JEvt::iterator __q = __end = partition(__p, out.end(), make_predicate(&JFIT::JFit::getDZ, parameters.DZMax, JComparison::le()));
171 
172  if (nz < distance(__p, __q)) {
173 
174  advance(__end = __p, nz);
175 
176  partial_sort(__p, __end, __q, qualitySorter);
177 
178  } else {
179 
180  sort(__p, __end, qualitySorter);
181  }
182  }
183 
184  out.erase(__end, out.end());
185 
186  } else {
187 
188  sort(out.begin(), out.end(), qualitySorter);
189  }
190 
191  outputFile.put(*tev);
192  outputFile.put(out);
193  }
194  STATUS(endl);
195 
197 
198  io >> outputFile;
199 
200  outputFile.close();
201 }
Auxiliary class for ROOT I/O of application specific meta data.
Definition: JMeta.hh:70
Object writing to file.
Utility class to parse command line options.
Definition: JParser.hh:1500
General exception.
Definition: JException.hh:23
Wrapper class to make pre-fit of muon trajectory.
Definition: JMuonPrefit.hh:73
JPredicate< JResult_t T::*, JComparison::eq > make_predicate(JResult_t T::*member, const JResult_t value)
Helper method to create predicate for data member.
Definition: JPredicate.hh:128
double position
coverage of detector by available position calibration [0,1]
Definition: JDynamics.hh:536
static JDetectorMechanics getMechanics
Function object to get string mechanics.
Definition: JMechanics.hh:243
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
#define STATUS(A)
Definition: JMessage.hh:63
Detector data structure.
Definition: JDetector.hh:81
Router for direct addressing of module data in detector data structure.
Data structure for fit parameters.
*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
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:66
string outputFile
Template definition for direct access of elements in ROOT TChain.
Definition: JTreeScanner.hh:91
Auxiliary base class for file name.
double orientation
coverage of detector by available orientation calibration [0,1]
Definition: JDynamics.hh:535
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
Detector file.
Definition: JHead.hh:196
Acoustic event fit.
Auxiliary class for recursive type list generation.
Definition: JTypeList.hh:351
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
void load(const std::string &file_name)
Load mechanical model parameters from file.
Definition: JMechanics.hh:142
int debug
debug level
Definition: JSirene.cc:63
Data structure for coverage of dynamic calibrations.
Definition: JDynamics.hh:534
counter_type advance(counter_type &counter, const counter_type value, const counter_type limit=std::numeric_limits< counter_type >::max())
Advance counter.
#define FATAL(A)
Definition: JMessage.hh:67
double getDZ() const
Get Z-slope.
static const int JPP_COVERAGE_ORIENTATION
coverage of dynamic orientation calibration from any Jpp application
Dynamic detector calibration.
Definition: JDynamics.hh:61
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
Data structure for set of track fit results.
General purpose class for object reading from a list of file names.
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
Orientation of module.
Object reading from a list of files.
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:73
do set_variable DETECTOR_TXT $WORKDIR detector
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:40
bool qualitySorter(const JRECONSTRUCTION::JFit &first, const JRECONSTRUCTION::JFit &second)
Comparison of fit results.
static const int JPP_COVERAGE_POSITION
coverage of dynamic position calibration from any Jpp application