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

Auxiliary program to store Monte Carlo information from a neutrino or the primary electron in JFIT::JEvt format. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "km3net-dataformat/offline/Head.hh"
#include "km3net-dataformat/offline/Evt.hh"
#include "km3net-dataformat/tools/time_converter.hh"
#include "JAAnet/JHead.hh"
#include "JAAnet/JHeadToolkit.hh"
#include "JAAnet/JAAnetToolkit.hh"
#include "JDAQ/JDAQEventIO.hh"
#include "JDAQ/JDAQTimesliceIO.hh"
#include "JDAQ/JDAQSummarysliceIO.hh"
#include "JTrigger/JTriggerParameters.hh"
#include "JSupport/JTriggeredFileScanner.hh"
#include "JSupport/JFileRecorder.hh"
#include "JSupport/JMonteCarloFileSupportkit.hh"
#include "JSupport/JSupport.hh"
#include "JSupport/JMeta.hh"
#include "JPhysics/JGeanz.hh"
#include "JReconstruction/JEvt.hh"
#include "JReconstruction/JEvtToolkit.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

Auxiliary program to store Monte Carlo information from a neutrino or the primary electron in JFIT::JEvt format.

By default the neutrino is considered, a bool variable allows to select the primary electron instead.

Author
mdejong, adomi

Definition in file JShowerMCEvt.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 38 of file JShowerMCEvt.cc.

39 {
40  using namespace std;
41  using namespace JPP;
42  using namespace KM3NETDAQ;
43 
45 
46  JTriggeredFileScanner<> inputFile;
48  JLimit_t& numberOfEvents = inputFile.getLimit();
49  int debug;
50  bool take_electron;
51 
52  try {
53 
54  JParser<> zap("Auxiliary program to store Monte Carlo true muon in format for subsequent fits.");
55 
56  zap['f'] = make_field(inputFile);
57  zap['o'] = make_field(outputFile) = "mcevt.root";
58  zap['n'] = make_field(numberOfEvents) = JLimit::max();
59  zap['d'] = make_field(debug) = 2;
60  zap['e'] = make_field(take_electron);
61 
62  zap(argc, argv);
63  }
64  catch(const exception& error) {
65  FATAL(error.what() << endl);
66  }
67 
68 
69  const JVector3D center = get<JPosition3D>(getHeader(inputFile));
70 
71  outputFile.open();
72 
73  outputFile.put(JMeta(argc, argv));
74 
75  while (inputFile.hasNext()) {
76 
77  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
78 
79  JTriggeredFileScanner<>::multi_pointer_type ps = inputFile.next();
80 
81  const JDAQEvent* tev = ps;
82  const Evt* event = ps;
83  JEvt out;
84 
85  const time_converter converter(*event, *tev);
86 
88 
89  if(!take_electron) fermion = find_if(event->mc_trks.begin(), event->mc_trks.end(), is_neutrino);
90  else fermion = find_if(event->mc_trks.begin(), event->mc_trks.end(), is_electron);
91 
92  if (fermion != event->mc_trks.end()) {
93 
94  // if fermion = neutrino => fermion position = neutrino interaction vertex
95  double time = converter.putTime();
96  JVector3D position = getPosition(*fermion);
97 
98  // if fermion = electron => fermion position and time = EM shower brightest point
99  if(take_electron){
100  JVector3D electron_dir = getDirection(*fermion);
101  double shower_elongation = geanz.getMaximum(fermion->E);
102  electron_dir *= shower_elongation;
103  position.add(electron_dir);
104  time += (shower_elongation * getInverseSpeedOfLight());
105  }
106 
107  JTrack3D td(position, getDirection(*fermion), time);
108  JTrack3E ta(td, fermion->E);
109 
110  ta.add(center);
111 
112  out.push_back(getFit(JMCEVT, ta, 0, 0.0, ta.getE()));
113 
114  }
115 
116  outputFile.put(out);
117  }
118  STATUS(endl);
119 
121 
122  io >> outputFile;
123 
124  outputFile.close();
125 }
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:1500
#define STATUS(A)
Definition: JMessage.hh:63
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
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.
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
static const JGeanz geanz(1.85, 0.62, 0.54)
Function object for longitudinal EM-shower profile.
JPosition3D getPosition(const Vec &pos)
Get position.
int debug
debug level
Definition: JSirene.cc:63
#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.
static const int JMCEVT
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.
const double getInverseSpeedOfLight()
Get inverse speed of light.
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:73
General purpose class for multiple pointers.
JVector3D & add(const JVector3D &vector)
Add vector.
Definition: JVector3D.hh:142
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition: Evt.hh:19
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62