Jpp  15.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
11 
15 #include "JSupport/JSupport.hh"
16 #include "JSupport/JMeta.hh"
17 
18 #include "JPhysics/JGeane.hh"
19 #include "JPhysics/JGeanz.hh"
20 #include "JPhysics/JConstants.hh"
21 
22 #include "Jeep/JPrint.hh"
23 #include "Jeep/JParser.hh"
24 #include "Jeep/JMessage.hh"
25 
26 
27 /**
28  * \file
29  *
30  * Auxiliary program to manipulate MUPAGE data.
31  * \author mdejong
32  */
33 int main(int argc, char **argv)
34 {
35  using namespace std;
36  using namespace JPP;
37 
38  JMultipleFileScanner<Evt> inputFile;
40  JLimit_t& numberOfEvents = inputFile.getLimit();
41  double P;
42  double u;
43  double E;
44  UInt_t seed;
45  int debug;
46 
47  try {
48 
49  JParser<> zap("Auxiliary program to manipulate MUPAGE data.");
50 
51  zap['f'] = make_field(inputFile);
52  zap['o'] = make_field(outputFile) = "mupage.root";
53  zap['n'] = make_field(numberOfEvents) = JLimit::max();
54  zap['P'] = make_field(P, "Keep muons in event with given probability (<= 1, 1 == all)") = 1.0;
55  zap['u'] = make_field(u, "Reject events as a function of multiplicity (>= 0, 0 == none)") = 0.0;
56  zap['E'] = make_field(E, "Energy scaling factor") = 1.0;
57  zap['S'] = make_field(seed) = 0;
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  gRandom->SetSeed(seed);
67 
68 
69  outputFile.open();
70 
71  if (!outputFile.is_open()) {
72  FATAL("Error opening file " << outputFile << endl);
73  }
74 
75  outputFile.put(JMeta(argc, argv));
76  outputFile.put(*gRandom);
77 
78  JMultipleFileScanner<Head> io(inputFile);
79 
80  io >> outputFile;
81 
82  while (inputFile.hasNext()) {
83 
84  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
85 
86  Evt* event = inputFile.next();
87 
88  // randomly reject muons in event
89 
90  for (vector<Trk>::iterator i = event->mc_trks.begin(); i != event->mc_trks.end(); ) {
91 
92  if (gRandom->Rndm() < P)
93  ++i;
94  else
95  i = event->mc_trks.erase(i);
96  }
97 
98  // apply energy loss
99 
100  for (vector<Trk>::iterator i = event->mc_trks.begin(); i != event->mc_trks.end(); ) {
101 
102  i->E = gWater(i->E, i->t * getSpeedOfLight());
103  i->E *= E;
104 
105  if (i->E > MASS_MUON)
106  ++i;
107  else
108  i = event->mc_trks.erase(i);
109  }
110 
111  // randonly reject events as a function of muon multiplicity
112 
113  if (gRandom->Rndm() < pow(event->mc_trks.size(),-u)) {
114  outputFile.put(*event);
115  }
116  }
117  STATUS(endl);
118 
119  outputFile.put(*gRandom);
120  outputFile.close();
121 }
Auxiliary class for ROOT I/O of application specific meta data.
Definition: JMeta.hh:70
Object writing to file.
Utility class to parse command line options.
Definition: JParser.hh:1500
int main(int argc, char *argv[])
Definition: Main.cc:15
ROOT TTree parameter settings of various packages.
Energy loss of muon.
#define STATUS(A)
Definition: JMessage.hh:63
Recording of objects on file according a format that follows from the file name extension.
static const double MASS_MUON
muon mass [GeV]
static const JGeaneWater gWater
Function object for energy loss of muon in sea water.
Definition: JGeane.hh:323
string outputFile
then usage E
Definition: JMuonPostfit.sh:35
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
I/O formatting auxiliaries.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
ROOT I/O of application specific meta data.
T pow(const T &x, const double y)
Power .
Definition: JMath.hh:98
Physics constants.
int debug
debug level
Definition: JSirene.cc:63
General purpose messaging.
Template specialisation of JMultipleFileScanner for Monte Carlo header.
#define FATAL(A)
Definition: JMessage.hh:67
Scanning of objects from multiple files according a format that follows from the extension of each fi...
const double getSpeedOfLight()
Get speed of light.
General purpose class for object reading from a list of file names.
Utility class to parse command line options.
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:73
Longitudinal emission profile EM-shower.
double u[N+1]
Definition: JPolint.hh:739
std::vector< Trk > mc_trks
MC: list of MC truth tracks.
Definition: Evt.hh:46
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition: Evt.hh:19
then $DIR JPlotNPE PDG P
Definition: JPlotNPE-PDG.sh:62