Jpp  18.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JShowerMCEvt.cc
Go to the documentation of this file.
1 #include <string>
2 #include <iostream>
3 #include <iomanip>
4 
9 
10 #include "JAAnet/JHead.hh"
11 #include "JAAnet/JHeadToolkit.hh"
12 #include "JAAnet/JAAnetToolkit.hh"
13 #include "JDAQ/JDAQEventIO.hh"
14 #include "JDAQ/JDAQTimesliceIO.hh"
20 #include "JSupport/JSupport.hh"
21 #include "JSupport/JMeta.hh"
22 #include "JPhysics/JGeanz.hh"
23 
24 #include "JReconstruction/JEvt.hh"
26 
27 #include "Jeep/JParser.hh"
28 #include "Jeep/JMessage.hh"
29 
30 
31 /**
32  * \file
33  *
34  * Auxiliary program to store Monte Carlo information from a neutrino or the primary electron in JFIT::JEvt format.
35  * By default the neutrino is considered, a bool variable allows to select the primary electron instead.
36  *
37  * \author mdejong, adomi
38  */
39 int main(int argc, char **argv)
40 {
41  using namespace std;
42  using namespace JPP;
43  using namespace KM3NETDAQ;
44 
46 
47  JTriggeredFileScanner<> inputFile;
49  JLimit_t& numberOfEvents = inputFile.getLimit();
50  int debug;
51  bool take_electron;
52 
53  try {
54 
55  JParser<> zap("Auxiliary program to store Monte Carlo true muon in format for subsequent fits.");
56 
57  zap['f'] = make_field(inputFile, "output of JTriggerEfficiency[.sh]");
58  zap['o'] = make_field(outputFile) = "mcevt.root";
59  zap['n'] = make_field(numberOfEvents) = JLimit::max();
60  zap['d'] = make_field(debug) = 2;
61  zap['e'] = make_field(take_electron);
62 
63  zap(argc, argv);
64  }
65  catch(const exception& error) {
66  FATAL(error.what() << endl);
67  }
68 
69 
70  const JVector3D center = get<JPosition3D>(getHeader(inputFile));
71 
72  outputFile.open();
73 
74  outputFile.put(JMeta(argc, argv));
75 
76  while (inputFile.hasNext()) {
77 
78  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
79 
80  JTriggeredFileScanner<>::multi_pointer_type ps = inputFile.next();
81 
82  const JDAQEvent* tev = ps;
83  const Evt* event = ps;
84  JEvt out;
85 
86  const time_converter converter(*event, *tev);
87 
89 
90  if(!take_electron) fermion = find_if(event->mc_trks.begin(), event->mc_trks.end(), is_neutrino);
91  else fermion = find_if(event->mc_trks.begin(), event->mc_trks.end(), is_electron);
92 
93  if (fermion != event->mc_trks.end()) {
94 
95  // if fermion = neutrino => fermion position = neutrino interaction vertex
96  double time = converter.putTime();
97  JVector3D position = getPosition(*fermion);
98 
99  // if fermion = electron => fermion position and time = EM shower brightest point
100  if(take_electron){
101  JVector3D electron_dir = getDirection(*fermion);
102  double shower_elongation = geanz.getMaximum(fermion->E);
103  electron_dir *= shower_elongation;
104  position.add(electron_dir);
105  time += (shower_elongation * getInverseSpeedOfLight());
106  }
107 
108  JTrack3D td(position, getDirection(*fermion), time);
109  JTrack3E ta(td, fermion->E);
110 
111  ta.add(center);
112 
113  out.push_back(getFit(JMCEVT, ta, 0, 0.0, ta.getE()));
114 
115  }
116 
117  outputFile.put(out);
118  }
119  STATUS(endl);
120 
122 
123  io >> outputFile;
124 
125  outputFile.close();
126 }
Auxiliary class for ROOT I/O of application specific meta data.
Definition: JMeta.hh:70
bool is_electron(const Trk &track)
Test whether given track is a (anti-)electron.
Object writing to file.
Utility class to parse command line options.
Definition: JParser.hh:1514
int main(int argc, char *argv[])
Definition: Main.cc:15
ROOT TTree parameter settings of various packages.
Synchronously read DAQ events and Monte Carlo events (and optionally other events).
#define STATUS(A)
Definition: JMessage.hh:63
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.
bool is_neutrino(const Trk &track)
Test whether given track is a neutrino.
Type list.
Definition: JTypeList.hh:22
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
JDirection3D getDirection(const Vec &dir)
Get direction.
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:1989
static const JGeanz geanz(1.85, 0.62, 0.54)
Function object for longitudinal EM-shower profile.
ROOT I/O of application specific meta data.
JPosition3D getPosition(const Vec &pos)
Get position.
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.
General purpose messaging.
Auxiliary include file for time conversion between DAQ/trigger hit and Monte Carlo hit...
#define FATAL(A)
Definition: JMessage.hh:67
static const int JMCEVT
JFit getFit(const int id, const JMODEL::JString &string)
Get fit parameters of string.
double getMaximum(const double E) const
Get depth of shower maximum.
Definition: JGeanz.hh:162
General purpose class for object reading from a list of file names.
Utility class to parse command line options.
const double getInverseSpeedOfLight()
Get inverse speed of light.
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:84
Longitudinal emission profile EM-shower.
General purpose class for multiple pointers.
JVector3D & add(const JVector3D &vector)
Add vector.
Definition: JVector3D.hh:142
int debug
debug level
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition: Evt.hh:20
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62