Jpp  17.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JStingray.cc File Reference

Auxiliary program to manipulate MUPAGE data. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include "TRandom3.h"
#include "km3net-dataformat/offline/Head.hh"
#include "km3net-dataformat/offline/Evt.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JSupport/JMonteCarloFileSupportkit.hh"
#include "JSupport/JFileRecorder.hh"
#include "JSupport/JSupport.hh"
#include "JSupport/JMeta.hh"
#include "JPhysics/JGeane.hh"
#include "JPhysics/JGeanz.hh"
#include "JPhysics/JConstants.hh"
#include "Jeep/JPrint.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Auxiliary program to manipulate MUPAGE data.

Author
mdejong

Definition in file JStingray.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 33 of file JStingray.cc.

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
then usage E
Definition: JMuonPostfit.sh:35
#define STATUS(A)
Definition: JMessage.hh:63
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:381
string outputFile
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
T pow(const T &x, const double y)
Power .
Definition: JMath.hh:98
int debug
debug level
Definition: JSirene.cc:66
Template specialisation of JMultipleFileScanner for Monte Carlo header.
#define FATAL(A)
Definition: JMessage.hh:67
const double getSpeedOfLight()
Get speed of light.
General purpose class for object reading from a list of file names.
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:73
double u[N+1]
Definition: JPolint.hh:755
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
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62