Jpp  18.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JFluxMultiParticle.cc File Reference

Example program for scanning event-weights of Monte Carlo files
containing a given set of primaries. More...

#include <iostream>
#include <iomanip>
#include <string>
#include <set>
#include "km3net-dataformat/offline/Head.hh"
#include "km3net-dataformat/offline/Evt.hh"
#include "JLang/JException.hh"
#include "JLang/JVectorize.hh"
#include "JAAnet/JAAnetToolkit.hh"
#include "JAAnet/JEvtWeightToolkit.hh"
#include "JSupport/JLimit.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JSupport/JEvtWeightFileScannerSet.hh"
#include "Jeep/JPrint.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"
#include "Jeep/JProperties.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Example program for scanning event-weights of Monte Carlo files
containing a given set of primaries.

The list of possible options for the flux includes:

   -@ zero         <type>
   -@ flat         <type>  <value>
   -@ powerlaw     <type>  <normalisation>  <spectral index>
   -@ atmospheric  <type>
Author
bjung

Definition in file JFluxMultiParticle.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 55 of file JFluxMultiParticle.cc.

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
#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
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
Auxiliary class for parsing multiparticle fluxes.
#define FATAL(A)
Definition: JMessage.hh:67
Auxiliary base class for list of file names.
std::vector< filescanner_type >::iterator iterator
Auxiliary class for organising Monte Carlo file scanners associated with event weighters.
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