Jpp test-rotations-new
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
13
15#include "JSupport/JSupport.hh"
16
17#include "Jeep/JParser.hh"
18#include "Jeep/JMessage.hh"
19
23//#include "JSupport/JSupport.hh"
24
25#include "JAAnet/JHead.hh"
26
27
28/**
29 * \file
30 *
31 * Auxiliary program to generate particles.
32 * \author mdejong
33 */
34int main(int argc, char **argv)
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
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}
string outputFile
Data structure for detector geometry and calibration.
Recording of objects on file according a format that follows from the file name extension.
int main(int argc, char **argv)
Definition JGedanken.cc:34
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:72
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
ROOT TTree parameter settings of various packages.
Monte Carlo run header.
Definition JHead.hh:1236
void push(T JHead::*pd)
Push given data member to Head.
Definition JHead.hh:1374
JAANET::fixedcan fixedcan
Definition JHead.hh:1599
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: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.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
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
The Trk class represents a Monte Carlo (MC) particle as well as a reconstructed track/shower.
Definition Trk.hh:15
int status
MC 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