Jpp
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/JPDFToolkit.hh"
19 #include "JTools/JConstants.hh"
20 
21 #include "Jeep/JPrint.hh"
22 #include "Jeep/JParser.hh"
23 #include "Jeep/JMessage.hh"
24 
25 
26 /**
27  * \file
28  *
29  * Auxiliary program to manipulate MUPAGE data.
30  * \author mdejong
31  */
32 int main(int argc, char **argv)
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 }
JMeta.hh
Head.hh
JFileRecorder.hh
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
JMessage.hh
JPHYSICS::gWater
static const JGeaneWater gWater
Function object for energy loss of muon in sea water.
Definition: JGeane.hh:328
JPrint.hh
JTOOLS::u
double u[N+1]
Definition: JPolint.hh:706
JPDFToolkit.hh
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
Evt.hh
JPARSER::JParser
Utility class to parse command line options.
Definition: JParser.hh:1493
JSupport.hh
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
main
int main(int argc, char **argv)
Definition: JStingray.cc:32
JConstants.hh
JSUPPORT::JMultipleFileScanner< Head >
Template specialisation of JMultipleFileScanner for Monte Carlo header.
Definition: JMonteCarloFileSupportkit.hh:324
JMultipleFileScanner.hh
STATUS
#define STATUS(A)
Definition: JMessage.hh:63
JSUPPORT::JMultipleFileScanner::hasNext
virtual bool hasNext()
Check availability of next element.
Definition: JMultipleFileScanner.hh:350
JParser.hh
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
JMonteCarloFileSupportkit.hh
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