Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JStingray.cc
Go to the documentation of this file.
1
2#include <string>
3#include <iostream>
4#include <iomanip>
5#include <map>
6
7#include "TRandom3.h"
8
12
16#include "JSupport/JSupport.hh"
17#include "JSupport/JMeta.hh"
18
19#include "JPhysics/JGeane.hh"
20#include "JPhysics/JGeanz.hh"
22
23#include "JROOT/JRandom.hh"
24
25#include "Jeep/JPrint.hh"
26#include "Jeep/JParser.hh"
27#include "Jeep/JMessage.hh"
28
29
30/**
31 * \file
32 *
33 * Auxiliary program to manipulate MUPAGE data.
34 * \author mdejong
35 */
36int main(int argc, char **argv)
37{
38 using namespace std;
39 using namespace JPP;
40
43 JLimit_t& numberOfEvents = inputFile.getLimit();
44 double P;
45 double u;
46 double E;
47 JRandom seed;
48 int debug;
49
50 try {
51
52 JParser<> zap("Auxiliary program to manipulate MUPAGE data.");
53
54 zap['f'] = make_field(inputFile);
55 zap['o'] = make_field(outputFile) = "mupage.root";
56 zap['n'] = make_field(numberOfEvents) = JLimit::max();
57 zap['P'] = make_field(P, "Keep muons in event with given probability (<= 1, 1 == all)") = 1.0;
58 zap['u'] = make_field(u, "Reject events as a function of multiplicity (>= 0, 0 == none)") = 0.0;
59 zap['E'] = make_field(E, "Energy scaling factor") = 1.0;
60 zap['S'] = make_field(seed) = 0;
61 zap['d'] = make_field(debug) = 2;
62
63 zap(argc, argv);
64 }
65 catch(const exception &error) {
66 FATAL(error.what() << endl);
67 }
68
69 seed.set(gRandom);
70
71 outputFile.open();
72
73 if (!outputFile.is_open()) {
74 FATAL("Error opening file " << outputFile << endl);
75 }
76
77 outputFile.put(JMeta(argc, argv));
78 outputFile.put(*gRandom);
79
80 JMultipleFileScanner<Head> io(inputFile);
81
82 io >> outputFile;
83
84 while (inputFile.hasNext()) {
85
86 STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
87
88 Evt* event = inputFile.next();
89
90 // randomly reject muons in event
91
92 for (vector<Trk>::iterator i = event->mc_trks.begin(); i != event->mc_trks.end(); ) {
93
94 if (gRandom->Rndm() < P)
95 ++i;
96 else
97 i = event->mc_trks.erase(i);
98 }
99
100 // apply energy loss
101
102 for (vector<Trk>::iterator i = event->mc_trks.begin(); i != event->mc_trks.end(); ) {
103
104 i->E = gWater(i->E, i->t * getSpeedOfLight());
105 i->E *= E;
106
107 if (i->E > MASS_MUON)
108 ++i;
109 else
110 i = event->mc_trks.erase(i);
111 }
112
113 // randonly reject events as a function of muon multiplicity
114
115 if (gRandom->Rndm() < pow(event->mc_trks.size(),-u)) {
116 outputFile.put(*event);
117 }
118 }
119 STATUS(endl);
120
121 outputFile.put(*gRandom);
122 outputFile.close();
123}
string outputFile
Recording of objects on file according a format that follows from the file name extension.
Energy loss of muon.
Longitudinal emission profile EM-shower.
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
ROOT I/O of application specific meta data.
Scanning of objects from multiple files according a format that follows from the extension of each fi...
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
Physics constants.
I/O formatting auxiliaries.
int main(int argc, char **argv)
Definition JStingray.cc:36
ROOT TTree parameter settings of various packages.
Utility class to parse command line options.
Definition JParser.hh:1698
Object writing to file.
General purpose class for object reading from a list of file names.
virtual bool hasNext() override
Check availability of next element.
counter_type getCounter() const
Get counter.
virtual const pointer_type & next() override
Get next element.
T pow(const T &x, const double y)
Power .
Definition JMath.hh:97
static const JGeaneWater gWater
Function object for energy loss of muon in sea water.
Definition JGeane.hh:381
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
Template definition of random value generator.
Auxiliary class for defining the range of iterations of objects.
Definition JLimit.hh:45
static counter_type max()
Get maximum counter value.
Definition JLimit.hh:128
Auxiliary class for ROOT I/O of application specific meta data.
Definition JMeta.hh:72