Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JWeightFileScanner.cc File Reference

Example program for weighing of Monte Carlo events. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "km3net-dataformat/offline/Head.hh"
#include "km3net-dataformat/offline/Evt.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JSupport/JLimit.hh"
#include "JSupport/JWeightFileScannerSet.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Example program for weighing of Monte Carlo events.

Author
bjung

Definition in file JWeightFileScanner.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 22 of file JWeightFileScanner.cc.

23 {
24  using namespace std;
25  using namespace JPP;
26 
27  JMultipleFileScanner_t inputFiles;
28  JLimit numberOfEvents;
29  int debug;
30 
31  try {
32 
33  JParser<> zap;
34 
35  zap['f'] = make_field(inputFiles);
36  zap['n'] = make_field(numberOfEvents) = JLimit::max();
37  zap['d'] = make_field(debug) = 1;
38 
39  zap(argc, argv);
40  }
41  catch(const exception& error) {
42  FATAL(error.what() << endl);
43  }
44 
45 
46  JWeightFileScannerSet<> scanners(inputFiles, numberOfEvents);
47 
48  for (JWeightFileScannerSet<>::iterator scanner = scanners.begin(); scanner != scanners.end(); ++scanner) {
49 
50  if (scanner->simul.size() > 0) {
51  STATUS("Scanning " << scanner->simul[0].program << " files..." << endl);
52  }
53 
54  STATUS(LEFT(20) << "event" << LEFT(10) << "weight" << endl);
55 
56  while (scanner->hasNext()) {
57 
58  const Evt* event = scanner->next();
59  const double weight = scanner->getWeight(*event);
60 
61  STATUS(LEFT (20) << scanner->getCounter() <<
62  FIXED(15,20) << weight << '\r'); DEBUG(endl);
63  }
64  }
65 
66  return 0;
67 }
Utility class to parse command line options.
Definition: JParser.hh:1500
#define STATUS(A)
Definition: JMessage.hh:63
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:445
Auxiliary class for organising Monte Carlo file scanners.
std::vector< value_type >::iterator iterator
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
int debug
debug level
Definition: JSirene.cc:63
#define FATAL(A)
Definition: JMessage.hh:67
Auxiliary base class for list of file names.
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition: Evt.hh:19
std::vector< double > weight
Definition: JAlgorithm.hh:428
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62