Jpp
Functions
JStingray.cc File Reference
#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/JPDFToolkit.hh"
#include "JTools/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

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 32 of file JStingray.cc.

33 {
34  using namespace std;
35  using namespace JPP;
36 
37  JMultipleFileScanner<Evt> inputFile;
39  JLimit_t& numberOfEvents = inputFile.getLimit();
40  double P;
41  double u;
42  double E;
43  UInt_t seed;
44  int debug;
45 
46  try {
47 
48  JParser<> zap("Auxiliary program to manipulate MUPAGE data.");
49 
50  zap['f'] = make_field(inputFile);
51  zap['o'] = make_field(outputFile) = "mupage.root";
52  zap['n'] = make_field(numberOfEvents) = JLimit::max();
53  zap['P'] = make_field(P, "Keep muons in event with given probability (<= 1, 1 == all)") = 1.0;
54  zap['u'] = make_field(u, "Reject events as a function of multiplicity (>= 0, 0 == none)") = 0.0;
55  zap['E'] = make_field(E, "Energy scaling factor") = 1.0;
56  zap['S'] = make_field(seed) = 0;
57  zap['d'] = make_field(debug) = 2;
58 
59  zap(argc, argv);
60  }
61  catch(const exception &error) {
62  FATAL(error.what() << endl);
63  }
64 
65  gRandom->SetSeed(seed);
66 
67 
68  outputFile.open();
69 
70  if (!outputFile.is_open()) {
71  FATAL("Error opening file " << outputFile << endl);
72  }
73 
74  outputFile.put(JMeta(argc, argv));
75  outputFile.put(*gRandom);
76 
77  JMultipleFileScanner<Head> io(inputFile);
78 
79  io >> outputFile;
80 
81  while (inputFile.hasNext()) {
82 
83  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
84 
85  Evt* event = inputFile.next();
86 
87  // randomly reject muons in event
88 
89  for (vector<Trk>::iterator i = event->mc_trks.begin(); i != event->mc_trks.end(); ) {
90 
91  if (gRandom->Rndm() < P)
92  ++i;
93  else
94  i = event->mc_trks.erase(i);
95  }
96 
97  // apply energy loss
98 
99  for (vector<Trk>::iterator i = event->mc_trks.begin(); i != event->mc_trks.end(); ) {
100 
101  i->E = gWater(i->E, i->t * getSpeedOfLight());
102  i->E *= E;
103 
104  if (i->E > MASS_MUON)
105  ++i;
106  else
107  i = event->mc_trks.erase(i);
108  }
109 
110  // randonly reject events as a function of muon multiplicity
111 
112  if (gRandom->Rndm() < pow(event->mc_trks.size(),-u)) {
113  outputFile.put(*event);
114  }
115  }
116  STATUS(endl);
117 
118  outputFile.put(*gRandom);
119  outputFile.close();
120 }
JSUPPORT::JLimit
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
JTOOLS::getSpeedOfLight
const double getSpeedOfLight()
Number of bytes in a gigabyte.
Definition: JConstants.hh:89
JTOOLS::MASS_MUON
static const double MASS_MUON
muon mass [GeV]
Definition: JConstants.hh:59
JPHYSICS::gWater
static const JGeaneWater gWater
Function object for energy loss of muon in sea water.
Definition: JGeane.hh:328
JTOOLS::u
double u[N+1]
Definition: JPolint.hh:706
std::vector
Definition: JSTDTypes.hh:12
Evt
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition: Evt.hh:19
JPARSER::JParser
Utility class to parse command line options.
Definition: JParser.hh:1493
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
JSUPPORT::JMultipleFileScanner::getCounter
counter_type getCounter() const
Get counter.
Definition: JMultipleFileScanner.hh:323
debug
int debug
debug level
Definition: JSirene.cc:59
JSUPPORT::JMultipleFileScanner::next
virtual const pointer_type & next()
Get next element.
Definition: JMultipleFileScanner.hh:398
JSUPPORT::JMultipleFileScanner< Head >
Template specialisation of JMultipleFileScanner for Monte Carlo header.
Definition: JMonteCarloFileSupportkit.hh:324
STATUS
#define STATUS(A)
Definition: JMessage.hh:63
JSUPPORT::JMultipleFileScanner::hasNext
virtual bool hasNext()
Check availability of next element.
Definition: JMultipleFileScanner.hh:350
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1954
JSUPPORT::JMultipleFileScanner
General purpose class for object reading from a list of file names.
Definition: JMultipleFileScanner.hh:167
JSUPPORT::JMeta
Auxiliary class for ROOT I/O of application specific meta data.
Definition: JMeta.hh:71
DEBUG
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
std
Definition: jaanetDictionary.h:36
FATAL
#define FATAL(A)
Definition: JMessage.hh:67
outputFile
string outputFile
Definition: JDAQTimesliceSelector.cc:37
JSUPPORT::JFileRecorder
Object writing to file.
Definition: JFileRecorder.hh:41