Jpp
 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 
9 #include "evt/Head.hh"
10 #include "evt/Evt.hh"
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;
38  JFileRecorder<JTYPELIST<JAAnetTypes_t, JMeta, JRootTypes_t>::typelist> outputFile;
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 }
Auxiliary class for ROOT I/O of application specific meta data.
Definition: JMeta.hh:71
Utility class to parse command line options.
Definition: JParser.hh:1410
static const JGeane gWater(2.67e-1 *JTOOLS::DENSITY_SEA_WATER, 3.4e-4 *JTOOLS::DENSITY_SEA_WATER)
Function object for Energy loss of muon in sea water.
Auxiliary methods for PDF calculations.
static const double MASS_MUON
muon mass [GeV]
Definition: JConstants.hh:59
const double getSpeedOfLight()
Number of bytes in a gigabyte.
Definition: JConstants.hh:89
#define STATUS(A)
Definition: JMessage.hh:61
Recording of objects on file according a format that follows from the file name extension.
Structure to store the ToT mean and standard deviation of the hits produced by a nanobeacon in a sour...
string outputFile
JLimit JLimit_t
Type definition of limit.
Definition: JLimit.hh:214
Constants.
I/O formatting auxiliaries.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1836
ROOT I/O of application specific meta data.
int debug
debug level
Definition: JSirene.cc:59
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:65
Scanning of objects from multiple files according a format that follows from the extension of each fi...
Utility class to parse command line options.
ROOT TTree parameter settings.
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:72
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:60
int main(int argc, char *argv[])
Definition: Main.cpp:15