Jpp  18.6.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JFluxMultiParticle.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <iomanip>
3 #include <string>
4 #include <set>
5 
8 
9 #include "JLang/JException.hh"
10 #include "JLang/JVectorize.hh"
11 
12 #include "JAAnet/JAAnetToolkit.hh"
14 
15 #include "JSupport/JLimit.hh"
18 
19 #include "Jeep/JPrint.hh"
20 #include "Jeep/JParser.hh"
21 #include "Jeep/JMessage.hh"
22 #include "Jeep/JProperties.hh"
23 
24 
25 namespace {
26 
27  /**
28  * Set flux of given event to zero.
29  *
30  * \param evt event
31  * \return zero [GeV * m^-2 * sr^-1 * s^-1]
32  */
33  inline double zeroFlux(const Evt& evt)
34  {
35  return 0.0;
36  }
37 }
38 
39 
40 /**
41  * \file
42  * Example program for scanning event-weights of Monte Carlo files\n
43  * containing a given set of primaries.
44  *
45  * The list of possible options for the flux includes:
46  * <pre>
47  * -@ zero <type>
48  * -@ flat <type> <value>
49  * -@ powerlaw <type> <normalisation> <spectral index>
50  * -@ atmospheric <type>
51  * </pre>
52  *
53  * \author bjung
54  */
55 int main(int argc, char **argv)
56 {
57  using namespace std;
58  using namespace JPP;
59 
60  JMultipleFileScanner_t inputFiles;
61 
62  vector<int> zeroFluxes;
63  JFluxMap fluxMap;
64 
65  int debug;
66 
67  try {
68 
69  JParser<> zap;
70 
71  zap['f'] = make_field(inputFiles);
72  zap['@'] = make_field(fluxMap)
74  zap['d'] = make_field(debug)
75  = 1;
76 
77  zap(argc, argv);
78  }
79  catch(const exception& error) {
80  FATAL(error.what() << endl);
81  }
82 
83 
84  // Set event weighter
85 
86  JEvtWeightFileScannerSet<> scanners(inputFiles);
87 
88  if (scanners.setFlux(fluxMap) == 0) {
89  WARNING("No file found containing all given primaries; Flux function not set." << endl);
90  }
91 
92 
93  // Scan events
94 
95  for (JEvtWeightFileScannerSet<>::iterator scanner = scanners.begin(); scanner != scanners.end(); ++scanner) {
96 
97  if (scanner->simul.size() > 0) {
98  STATUS("Scanning " << scanner->simul[0].program << " files..." << endl);
99  }
100 
101  STATUS(LEFT(15) << "event" << RIGHT(15) << "weight" << endl);
102 
103  while (scanner->hasNext()) {
104 
105  const Evt* event = scanner->next();
106  const double weight = scanner->getWeight(*event);
107 
108  STATUS(LEFT (15) << scanner->getCounter() <<
109  SCIENTIFIC(15, 3) << weight << '\r'); DEBUG(endl);
110  }
111  }
112 
113  return 0;
114 }
Utility class to parse command line options.
Definition: JParser.hh:1711
#define WARNING(A)
Definition: JMessage.hh:65
Exceptions.
int main(int argc, char *argv[])
Definition: Main.cc:15
#define STATUS(A)
Definition: JMessage.hh:63
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:84
Utility class to parse parameter values.
I/O formatting auxiliaries.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2158
Definition of hit and track types and auxiliary methods for handling Monte Carlo data.
Auxiliary methods to convert data members or return values of member methods of a set of objects to a...
Auxiliary class for parsing multiparticle fluxes.
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
Scanning of objects from multiple files according a format that follows from the extension of each fi...
Auxiliary base class for list of file names.
std::vector< filescanner_type >::iterator iterator
Utility class to parse command line options.
size_t setFlux(const int type, const JFlux &flux)
Set flux function for all MC-files corresponding to a given PDG code.
Auxiliary class for organising Monte Carlo file scanners associated with event weighters.
Auxiliaries for defining the range of iterations of objects.
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:486
int debug
debug level
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition: Evt.hh:20
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62