Jpp  18.1.0
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  JFluxMapParser fluxMaps;
64 
65  int debug;
66 
67  try {
68 
69  fluxMaps.put("zero", zeroFluxes);
70 
71  JParser<> zap;
72 
73  zap['f'] = make_field(inputFiles);
74  zap['@'] = make_field(fluxMaps, "keys:" << endl << get_keys(fluxMaps))
76  zap['d'] = make_field(debug)
77  = 1;
78 
79  zap(argc, argv);
80  }
81  catch(const exception& error) {
82  FATAL(error.what() << endl);
83  }
84 
85 
86  // Set event weighter
87 
88  JEvtWeightFileScannerSet<> scanners(inputFiles);
89 
90  if (scanners.setFlux(fluxMaps) == 0) {
91  WARNING("No file found containing all given primaries; Flux function not set." << endl);
92  }
93 
94 
95  // Scan events
96 
97  for (JEvtWeightFileScannerSet<>::iterator scanner = scanners.begin(); scanner != scanners.end(); ++scanner) {
98 
99  if (scanner->simul.size() > 0) {
100  STATUS("Scanning " << scanner->simul[0].program << " files..." << endl);
101  }
102 
103  STATUS(LEFT(15) << "event" << RIGHT(15) << "weight" << endl);
104 
105  while (scanner->hasNext()) {
106 
107  const Evt* event = scanner->next();
108  const double weight = scanner->getWeight(*event);
109 
110  STATUS(LEFT (15) << scanner->getCounter() <<
111  SCIENTIFIC(15, 3) << weight << '\r'); DEBUG(endl);
112  }
113  }
114 
115  return 0;
116 }
Utility class to parse command line options.
Definition: JParser.hh:1514
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:83
Utility class to parse parameter values.
I/O formatting auxiliaries.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
Definition of hit and track types and auxiliary methods for handling Monte Carlo data.
Auxiliary class for parsing multiparticle fluxes.
Auxiliary methods to convert data members or return values of member methods of a set of objects to a...
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.
then echo WARNING
Definition: JTuneHV.sh:91
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:484
const array_type< JKey_t > & get_keys(const std::map< JKey_t, JValue_t, JComparator_t, JAllocator_t > &data)
Method to create array of keys of map.
Definition: JVectorize.hh:139
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