Jpp 21.0.0
the software that should make you happy
Loading...
Searching...
No Matches
JGedanken.cc
Go to the documentation of this file.
1#include <string>
2#include <iostream>
3#include <iomanip>
4#include <cmath>
5
6#include "TROOT.h"
7#include "TFile.h"
8
14
16#include "JSupport/JSupport.hh"
17
19
23
24#include "JAAnet/JHead.hh"
25
26#include "Jeep/JParser.hh"
27#include "Jeep/JMessage.hh"
28
29
30/**
31 * \file
32 *
33 * Auxiliary program to generate particles.
34 * \author mdejong
35 */
36int main(int argc, char **argv)
37{
38 using namespace std;
39 using namespace JPP;
40
41 Trk trk;
42
44 size_t numberOfEvents;
45 int debug;
46
47 string detectorFile;
48
49 try {
50
51 JParser<> zap("Auxiliary program to generate particles.");
52
53 zap['o'] = make_field(outputFile) = "gedanken.root";
54 zap['n'] = make_field(numberOfEvents) = 1;
55 zap['P'] = make_field(trk.pos, "position");
56 zap['D'] = make_field(trk.dir, "direction") = Vec(0.0, 0.0, 1.0);
57 zap['E'] = make_field(trk.E, "energy [GeV]");
58 zap['T'] = make_field(trk.type, "particle type (PDG)");
59 zap['a'] = make_field(detectorFile);
60 zap['d'] = make_field(debug) = 2;
61
62 zap(argc, argv);
63 }
64 catch(const exception& error) {
65 FATAL(error.what() << endl);
66 }
67
68 trk.dir.normalize();
69
71
73
74 try {
75 load(detectorFile, detector);
76 }
77 catch(const JException& error) {
78 FATAL(error);
79 }
80
81 const JCylinder3D cylinder(detector.begin(), detector.end());
82
83 Head header;
84
85 JHead buffer(header);
86
87 buffer.simul.push_back(JAANET::simul());
88
89 buffer.simul.rbegin()->program = APPLICATION_JGEDANKEN;
90 buffer.simul.rbegin()->version = getGITVersion();
91 buffer.simul.rbegin()->date = getDate();
92 buffer.simul.rbegin()->time = getTime();
93
94 buffer.push(&JHead::simul);
95
96 buffer.fixedcan.xcenter = cylinder.getX();
97 buffer.fixedcan.ycenter = cylinder.getY();
98 buffer.fixedcan.zmin = cylinder.getZmin();
99 buffer.fixedcan.zmax = cylinder.getZmax();
100 buffer.fixedcan.radius = cylinder.getRadius();
101
102 buffer.push(&JHead::fixedcan);
103
104 copy(buffer, header);
105
106 outputFile.open();
107
108 outputFile.put(header);
109
110 Evt evt;
111
112 evt.mc_trks.push_back(trk);
113
114 for (size_t counter = 0; counter != numberOfEvents; ++counter) {
115
116 STATUS("event: " << setw(10) << counter << '\r'); DEBUG(endl);
117
118 outputFile.put(evt);
119 }
120 STATUS(endl);
121
122 outputFile.close();
123}
string outputFile
Date and time functions.
Data structure for detector geometry and calibration.
Recording of objects on file according a format that follows from the file name extension.
General purpose messaging.
#define DEBUG(A)
Message macros.
Definition JMessage.hh:62
#define STATUS(A)
Definition JMessage.hh:63
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:74
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2107
ROOT TTree parameter settings of various packages.
static const char *const APPLICATION_JGEDANKEN
event generator
Monte Carlo run header.
Definition JHead.hh:1236
std::vector< JAANET::simul > simul
Definition JHead.hh:1609
void push(T JHead::*pd)
Push given data member to Head.
Definition JHead.hh:1374
JAANET::fixedcan fixedcan
Definition JHead.hh:1617
Detector data structure.
Definition JDetector.hh:96
double getRadius() const
Get radius.
Definition JCircle2D.hh:144
double getY() const
Get y position.
Definition JVector2D.hh:74
double getX() const
Get x position.
Definition JVector2D.hh:63
double getZmin() const
Get minimal z position.
double getZmax() const
Get maximal z position.
General exception.
Definition JException.hh:25
Utility class to parse command line options.
Definition JParser.hh:1664
Object writing to file.
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition JHead.cc:157
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
const char * getGITVersion()
Get GIT version.
Definition Jpp.cc:9
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
const char * getTime()
Get current local time conform ISO-8601 standard.
const char * getDate()
Get current local date conform ISO-8601 standard.
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition Evt.hh:21
std::vector< Trk > mc_trks
MC: list of MC truth tracks.
Definition Evt.hh:49
The Head class reflects the header of Monte-Carlo event files, which consists of keys (also referred ...
Definition Head.hh:65
Detector file.
Definition JHead.hh:227
double zmax
Top [m].
Definition JHead.hh:639
double radius
Radius [m].
Definition JHead.hh:640
double zmin
Bottom [m].
Definition JHead.hh:638
double ycenter
y-center [m]
Definition JHead.hh:637
double xcenter
x-center [m]
Definition JHead.hh:636
Generator for simulation.
Definition JHead.hh:528
The Trk class represents a Monte Carlo (MC) particle as well as a reconstructed track/shower.
Definition Trk.hh:15
int status
MC or reconstruction status code, see km3net-dataformat/definitions/trkmembers.csv for values.
Definition Trk.hh:28
int type
MC: particle type in PDG encoding.
Definition Trk.hh:24
Vec dir
track direction
Definition Trk.hh:18
double E
Energy [GeV] (either MC truth or reconstructed)
Definition Trk.hh:20
Vec pos
postion [m] of the track at time t
Definition Trk.hh:17
The Vec class is a straightforward 3-d vector, which also works in pyroot.
Definition Vec.hh:13
static const int TRK_ST_FINALSTATE
for MC: the particle must be processed by detector simulation ('track_in' tag in evt files)....
Definition trkmembers.hh:17