Jpp  18.3.0-rc.1
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/MultiHead.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 34 of file JStingray.cc.

35 {
36  using namespace std;
37  using namespace JPP;
38 
39  JMultipleFileScanner<Evt> inputFile;
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 }
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:1514
then usage $script< input file >[option[primary[working directory]]] nWhere option can be E
Definition: JMuonPostfit.sh:40
#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:1989
T pow(const T &x, const double y)
Power .
Definition: JMath.hh:97
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:84
double u[N+1]
Definition: JPolint.hh:865
int debug
debug level
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition: Evt.hh:20
then $DIR JPlotNPE PDG P
Definition: JPlotNPE-PDG.sh:62
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62