Jpp
JMCEvt.cc
Go to the documentation of this file.
1 #include <string>
2 #include <iostream>
3 #include <iomanip>
4 
5 #include "evt/Head.hh"
6 #include "evt/Evt.hh"
7 #include "JAAnet/JHead.hh"
8 #include "JAAnet/JHeadToolkit.hh"
9 #include "JDAQ/JDAQEvent.hh"
10 #include "JDAQ/JDAQTimeslice.hh"
11 #include "JDAQ/JDAQSummaryslice.hh"
17 #include "JSupport/JSupport.hh"
18 #include "JSupport/JMeta.hh"
19 
20 #include "JFit/JEvt.hh"
21 #include "JFit/JEvtToolkit.hh"
22 
23 #include "Jeep/JParser.hh"
24 #include "Jeep/JMessage.hh"
25 
26 
27 /**
28  * \file
29  *
30  * Auxiliary program to store Monte Carlo true muon in JFIT::JEvt format.
31  * \author mdejong
32  */
33 int main(int argc, char **argv)
34 {
35  using namespace std;
36  using namespace JPP;
37  using namespace KM3NETDAQ;
38 
40 
41  JTriggeredFileScanner<> inputFile;
42  JFileRecorder<typelist> outputFile;
43  JLimit_t& numberOfEvents = inputFile.getLimit();
44  int debug;
45 
46  try {
47 
48  JParser<> zap("Auxiliary program to store Monte Carlo true muon in format for subsequent fits.");
49 
50  zap['f'] = make_field(inputFile);
51  zap['o'] = make_field(outputFile) = "mcevt.root";
52  zap['n'] = make_field(numberOfEvents) = JLimit::max();
53  zap['d'] = make_field(debug) = 2;
54 
55  zap(argc, argv);
56  }
57  catch(const exception& error) {
58  FATAL(error.what() << endl);
59  }
60 
61 
62 
63  const JVector3D center = get<JPosition3D>(getHeader(inputFile));
64 
65  outputFile.open();
66 
67  outputFile.put(JMeta(argc, argv));
68 
69  while (inputFile.hasNext()) {
70 
71  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
72 
73  JTriggeredFileScanner<>::multi_pointer_type ps = inputFile.next();
74 
75  const JDAQEvent* tev = ps;
76  const Evt* event = ps;
77  JEvt out;
78 
79  const JTimeConverter converter(*event, *tev);
80 
81  vector<Trk>::const_iterator muon = find_if(event->mc_trks.begin(), event->mc_trks.end(), is_muon);
82 
83  if (muon != event->mc_trks.end()) {
84 
85  JTrack3E ta = getTrack(*muon);
86 
87  ta.add(center);
88  ta.add(converter.putTime());
89 
90  out.push_back(getFit(JMCEVT, ta, 0, 0.0, ta.getE()));
91 
92  if (has_neutrino(*event)) {
93  out.rbegin()->setW(0, (get_neutrino(*event).pos - muon->pos).len());
94  }
95  }
96 
97  outputFile.put(out);
98  }
99  STATUS(endl);
100 
101  JMultipleFileScanner<JRemove<typelist, JEvt>::typelist> io(inputFile);
102 
103  io >> outputFile;
104 
105  outputFile.close();
106 }
JMeta.hh
KM3NETDAQ::JDAQEvent
DAQ Event.
Definition: JDAQEvent.hh:34
JTriggerParameters.hh
JFileRecorder.hh
JMessage.hh
JHead.hh
std::vector
Definition: JSTDTypes.hh:12
JEvtToolkit.hh
JSUPPORT::JLimit_t
JLimit JLimit_t
Type definition of limit.
Definition: JLimit.hh:215
JAANET::getTrack
JTrack3E getTrack(const Trk &track)
Get track.
Definition: JAAnetToolkit.hh:256
JTimeConverter.hh
JPARSER::JParser
Utility class to parse command line options.
Definition: JParser.hh:1493
JTriggeredFileScanner.hh
JDAQTimeslice.hh
JAANET::is_muon
bool is_muon(const Trk &track)
Test whether given track is a (anti-)muon.
Definition: JAAnetToolkit.hh:367
JDAQSummaryslice.hh
JHeadToolkit.hh
JSupport.hh
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
JEvt.hh
JSUPPORT::getHeader
Head getHeader(const JMultipleFileScanner_t &file_list)
Get Monte Carlo header.
Definition: JMonteCarloFileSupportkit.hh:425
JFIT::JMCEVT
JMCEvt.cc.
Definition: JFitApplications.hh:42
debug
int debug
debug level
Definition: JSirene.cc:59
JAANET::get_neutrino
const Trk & get_neutrino(const Evt &evt)
Get incoming neutrino.
Definition: JAAnetToolkit.hh:438
JSUPPORT::JLimit::getLimit
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:73
JAANET::has_neutrino
bool has_neutrino(const Evt &evt)
Test whether given event has an incoming neutrino.
Definition: JAAnetToolkit.hh:427
JLANG::JTypeList
Type list.
Definition: JTypeList.hh:22
STATUS
#define STATUS(A)
Definition: JMessage.hh:63
JParser.hh
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1954
JSUPPORT::JMeta
Auxiliary class for ROOT I/O of application specific meta data.
Definition: JMeta.hh:71
DEBUG
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
std
Definition: jaanetDictionary.h:36
KM3NETDAQ
KM3NeT DAQ data structures and auxiliaries.
Definition: DataQueue.cc:39
JDAQEvent.hh
JMonteCarloFileSupportkit.hh
JFIT::getFit
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
main
int main(int argc, char **argv)
Definition: JMCEvt.cc:33
FATAL
#define FATAL(A)
Definition: JMessage.hh:67
outputFile
string outputFile
Definition: JDAQTimesliceSelector.cc:37