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

Auxiliary program to generate particles. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <cmath>
#include "TROOT.h"
#include "TFile.h"
#include "km3net-dataformat/offline/Head.hh"
#include "km3net-dataformat/offline/MultiHead.hh"
#include "km3net-dataformat/offline/Evt.hh"
#include "km3net-dataformat/definitions/trkmembers.hh"
#include "JSupport/JFileRecorder.hh"
#include "JSupport/JSupport.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JGeometry3D/JCylinder3D.hh"
#include "JAAnet/JHead.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Auxiliary program to generate particles.

Author
mdejong

Definition in file JGedanken.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 34 of file JGedanken.cc.

35 {
36  using namespace std;
37  using namespace JPP;
38 
39  Trk trk;
40 
42  size_t numberOfEvents;
43  int debug;
44 
45  string detectorFile;
46 
47  try {
48 
49  JParser<> zap("Auxiliary program to generate particles.");
50 
51  zap['o'] = make_field(outputFile) = "gedanken.root";
52  zap['n'] = make_field(numberOfEvents) = 1;
53  zap['P'] = make_field(trk.pos, "position");
54  zap['D'] = make_field(trk.dir, "direction") = Vec(0.0, 0.0, 1.0);
55  zap['E'] = make_field(trk.E, "energy [GeV]");
56  zap['T'] = make_field(trk.type, "particle type (PDG)");
57  zap['a'] = make_field(detectorFile);
58  zap['d'] = make_field(debug) = 2;
59 
60  zap(argc, argv);
61  }
62  catch(const exception& error) {
63  FATAL(error.what() << endl);
64  }
65 
66  trk.dir.normalize();
67 
68  trk.status = TRK_ST_FINALSTATE;
69 
71 
72  try {
73  load(detectorFile, detector);
74  }
75  catch(const JException& error) {
76  FATAL(error);
77  }
78 
79  const JCylinder3D cylinder(detector.begin(), detector.end());
80 
81  Head header;
82 
83  JHead buffer(header);
84 
85  buffer.fixedcan.xcenter = cylinder.getX();
86  buffer.fixedcan.ycenter = cylinder.getY();
87  buffer.fixedcan.zmin = cylinder.getZmin();
88  buffer.fixedcan.zmax = cylinder.getZmax();
89  buffer.fixedcan.radius = cylinder.getRadius();
90 
91  buffer.push(&JHead::fixedcan);
92  copy(buffer, header);
93 
94  outputFile.open();
95 
96  outputFile.put(header);
97 
98  Evt evt;
99 
100  evt.mc_trks.push_back(trk);
101 
102  for (size_t counter = 0; counter != numberOfEvents; ++counter) {
103 
104  STATUS("event: " << setw(10) << counter << '\r'); DEBUG(endl);
105 
106  outputFile.put(evt);
107  }
108  STATUS(endl);
109 
110  outputFile.close();
111 }
Object writing to file.
Utility class to parse command line options.
Definition: JParser.hh:1711
General exception.
Definition: JException.hh:24
#define STATUS(A)
Definition: JMessage.hh:63
Detector data structure.
Definition: JDetector.hh:89
string outputFile
The Vec class is a straightforward 3-d vector, which also works in pyroot.
Definition: Vec.hh:12
Cylinder object.
Definition: JCylinder3D.hh:39
Detector file.
Definition: JHead.hh:226
Monte Carlo run header.
Definition: JHead.hh:1234
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2158
The Head class reflects the header of Monte-Carlo event files, which consists of keys (also referred ...
Definition: Head.hh:64
#define FATAL(A)
Definition: JMessage.hh:67
static const int TRK_ST_FINALSTATE
for MC: the particle must be processed by detector simulation (&#39;track_in&#39; tag in evt files)...
Definition: trkmembers.hh:15
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition: JHead.cc:162
do set_variable DETECTOR_TXT $WORKDIR detector
The Trk class represents a Monte Carlo (MC) particle as well as a reconstructed track/shower.
Definition: Trk.hh:14
std::vector< Trk > mc_trks
MC: list of MC truth tracks.
Definition: Evt.hh:49
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