Jpp master_rocky-44-g75b7c4f75
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 "Jeep/JPrint.hh"
24#include "Jeep/JParser.hh"
25#include "Jeep/JMessage.hh"
26
27
28/**
29 * \file
30 *
31 * Auxiliary program to manipulate MUPAGE data.
32 * \author mdejong
33 */
34int main(int argc, char **argv)
35{
36 using namespace std;
37 using namespace JPP;
38
41 JLimit_t& numberOfEvents = inputFile.getLimit();
42 double P;
43 double u;
44 double E;
45 UInt_t seed;
46 int debug;
47
48 try {
49
50 JParser<> zap("Auxiliary program to manipulate MUPAGE data.");
51
52 zap['f'] = make_field(inputFile);
53 zap['o'] = make_field(outputFile) = "mupage.root";
54 zap['n'] = make_field(numberOfEvents) = JLimit::max();
55 zap['P'] = make_field(P, "Keep muons in event with given probability (<= 1, 1 == all)") = 1.0;
56 zap['u'] = make_field(u, "Reject events as a function of multiplicity (>= 0, 0 == none)") = 0.0;
57 zap['E'] = make_field(E, "Energy scaling factor") = 1.0;
58 zap['S'] = make_field(seed) = 0;
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 gRandom->SetSeed(seed);
68
69
70 outputFile.open();
71
72 if (!outputFile.is_open()) {
73 FATAL("Error opening file " << outputFile << endl);
74 }
75
76 outputFile.put(JMeta(argc, argv));
77 outputFile.put(*gRandom);
78
79 JMultipleFileScanner<Head> io(inputFile);
80
81 io >> outputFile;
82
83 while (inputFile.hasNext()) {
84
85 STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
86
87 Evt* event = inputFile.next();
88
89 // randomly reject muons in event
90
91 for (vector<Trk>::iterator i = event->mc_trks.begin(); i != event->mc_trks.end(); ) {
92
93 if (gRandom->Rndm() < P)
94 ++i;
95 else
96 i = event->mc_trks.erase(i);
97 }
98
99 // apply energy loss
100
101 for (vector<Trk>::iterator i = event->mc_trks.begin(); i != event->mc_trks.end(); ) {
102
103 i->E = gWater(i->E, i->t * getSpeedOfLight());
104 i->E *= E;
105
106 if (i->E > MASS_MUON)
107 ++i;
108 else
109 i = event->mc_trks.erase(i);
110 }
111
112 // randonly reject events as a function of muon multiplicity
113
114 if (gRandom->Rndm() < pow(event->mc_trks.size(),-u)) {
115 outputFile.put(*event);
116 }
117 }
118 STATUS(endl);
119
120 outputFile.put(*gRandom);
121 outputFile.close();
122}
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:69
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:34
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).
double u[N+1]
Definition JPolint.hh:865
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition Evt.hh:21
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