Jpp test-rotations-old-533-g2bdbdb559
the software that should make you happy
Loading...
Searching...
No Matches
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/applications.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

◆ main()

int main ( int argc,
char ** argv )

Definition at line 35 of file JGedanken.cc.

36{
37 using namespace std;
38 using namespace JPP;
39
40 Trk trk;
41
43 size_t numberOfEvents;
44 int debug;
45
46 string detectorFile;
47
48 try {
49
50 JParser<> zap("Auxiliary program to generate particles.");
51
52 zap['o'] = make_field(outputFile) = "gedanken.root";
53 zap['n'] = make_field(numberOfEvents) = 1;
54 zap['P'] = make_field(trk.pos, "position");
55 zap['D'] = make_field(trk.dir, "direction") = Vec(0.0, 0.0, 1.0);
56 zap['E'] = make_field(trk.E, "energy [GeV]");
57 zap['T'] = make_field(trk.type, "particle type (PDG)");
58 zap['a'] = make_field(detectorFile);
59 zap['d'] = make_field(debug) = 2;
60
61 zap(argc, argv);
62 }
63 catch(const exception& error) {
64 FATAL(error.what() << endl);
65 }
66
67 trk.dir.normalize();
68
70
72
73 try {
74 load(detectorFile, detector);
75 }
76 catch(const JException& error) {
77 FATAL(error);
78 }
79
80 const JCylinder3D cylinder(detector.begin(), detector.end());
81
82 Head header;
83
84 JHead buffer(header);
85
86 buffer.simul.push_back(JAANET::simul());
87
88 buffer.simul.rbegin()->program = APPLICATION_JGEDANKEN;
89 buffer.simul.rbegin()->version = getGITVersion();
90 buffer.simul.rbegin()->date = getDate();
91 buffer.simul.rbegin()->time = getTime();
92
93 buffer.push(&JHead::simul);
94
95 buffer.fixedcan.xcenter = cylinder.getX();
96 buffer.fixedcan.ycenter = cylinder.getY();
97 buffer.fixedcan.zmin = cylinder.getZmin();
98 buffer.fixedcan.zmax = cylinder.getZmax();
99 buffer.fixedcan.radius = cylinder.getRadius();
100
101 buffer.push(&JHead::fixedcan);
102
103 copy(buffer, header);
104
105 outputFile.open();
106
107 outputFile.put(header);
108
109 Evt evt;
110
111 evt.mc_trks.push_back(trk);
112
113 for (size_t counter = 0; counter != numberOfEvents; ++counter) {
114
115 STATUS("event: " << setw(10) << counter << '\r'); DEBUG(endl);
116
117 outputFile.put(evt);
118 }
119 STATUS(endl);
120
121 outputFile.close();
122}
string outputFile
#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:72
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
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
JAANET::fixedcan fixedcan
Definition JHead.hh:1617
Detector data structure.
Definition JDetector.hh:96
General exception.
Definition JException.hh:24
Utility class to parse command line options.
Definition JParser.hh:1698
Object writing to file.
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition JHead.cc:163
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
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
Vec & normalize()
Normalise this vector.
Definition Vec.hh:159
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:15