Jpp  15.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JMuonMCEvt.cc
Go to the documentation of this file.
1 #include <string>
2 #include <iostream>
3 #include <iomanip>
4 
8 
9 #include "JAAnet/JHead.hh"
10 #include "JAAnet/JHeadToolkit.hh"
11 #include "JAAnet/JAAnetToolkit.hh"
12 #include "JDAQ/JDAQEventIO.hh"
13 #include "JDAQ/JDAQTimesliceIO.hh"
19 #include "JSupport/JSupport.hh"
20 #include "JSupport/JMeta.hh"
21 
22 #include "JReconstruction/JEvt.hh"
24 
25 #include "Jeep/JParser.hh"
26 #include "Jeep/JMessage.hh"
27 
28 
29 /**
30  * \file
31  *
32  * Auxiliary program to store Monte Carlo true muon in JFIT::JEvt format.
33  * \author mdejong
34  */
35 int main(int argc, char **argv)
36 {
37  using namespace std;
38  using namespace JPP;
39  using namespace KM3NETDAQ;
40 
42 
43  JTriggeredFileScanner<> inputFile;
45  JLimit_t& numberOfEvents = inputFile.getLimit();
46  int debug;
47 
48  try {
49 
50  JParser<> zap("Auxiliary program to store Monte Carlo true muon in format for subsequent fits.");
51 
52  zap['f'] = make_field(inputFile);
53  zap['o'] = make_field(outputFile) = "mcevt.root";
54  zap['n'] = make_field(numberOfEvents) = JLimit::max();
55  zap['d'] = make_field(debug) = 2;
56 
57  zap(argc, argv);
58  }
59  catch(const exception& error) {
60  FATAL(error.what() << endl);
61  }
62 
63 
64 
65  const JVector3D center = get<JPosition3D>(getHeader(inputFile));
66 
67  outputFile.open();
68 
69  outputFile.put(JMeta(argc, argv));
70 
71  while (inputFile.hasNext()) {
72 
73  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
74 
75  JTriggeredFileScanner<>::multi_pointer_type ps = inputFile.next();
76 
77  const JDAQEvent* tev = ps;
78  const Evt* event = ps;
79  JEvt out;
80 
81  const time_converter converter(*event, *tev);
82 
83  vector<Trk>::const_iterator muon = find_if(event->mc_trks.begin(), event->mc_trks.end(), is_muon);
84 
85  if (muon != event->mc_trks.end()) {
86 
87  JTrack3E ta = getTrack(*muon);
88 
89  ta.add(center);
90  ta.add(converter.putTime());
91 
92  out.push_back(getFit(JMCEVT, ta, 0.0, 0, ta.getE()));
93 
94  if (has_neutrino(*event)) {
95  out.rbegin()->setW(0, (get_neutrino(*event).pos - muon->pos).len());
96  }
97  }
98 
99  outputFile.put(out);
100  }
101  STATUS(endl);
102 
104 
105  io >> outputFile;
106 
107  outputFile.close();
108 }
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
int main(int argc, char *argv[])
Definition: Main.cc:15
ROOT TTree parameter settings of various packages.
JTrack3E getTrack(const Trk &track)
Get track.
Synchronously read DAQ events and Monte Carlo events (and optionally other events).
#define STATUS(A)
Definition: JMessage.hh:63
bool has_neutrino(const Evt &evt)
Test whether given event has an incoming neutrino.
bool is_muon(const Trk &track)
Test whether given track is a (anti-)muon.
Recording of objects on file according a format that follows from the file name extension.
Auxiliary class to synchronously read DAQ events and Monte Carlo events (and optionally other events)...
Auxiliary class to convert DAQ hit time to/from Monte Carlo hit time.
string outputFile
3D track with energy.
Definition: JTrack3E.hh:30
JTime & add(const JTime &value)
Addition operator.
Head getHeader(const JMultipleFileScanner_t &file_list)
Get Monte Carlo header.
Type list.
Definition: JTypeList.hh:22
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
double getE() const
Get energy.
Definition: JTrack3E.hh:93
Data structure for vector in three dimensions.
Definition: JVector3D.hh:34
Acoustic event fit.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
ROOT I/O of application specific meta data.
Definition of hit and track types and auxiliary methods for handling Monte Carlo data.
double putTime() const
Get Monte Carlo time minus DAQ/trigger time.
int debug
debug level
Definition: JSirene.cc:63
General purpose messaging.
Auxiliary include file for time conversion between DAQ/trigger hit and Monte Carlo hit...
#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.
Vec pos
postion of the track at time t [m]
Definition: Trk.hh:17
static const int JMCEVT
General purpose class for object reading from a list of file names.
Utility class to parse command line options.
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:73
const Trk & get_neutrino(const Evt &evt)
Get incoming neutrino.
General purpose class for multiple pointers.
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition: Evt.hh:19