Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JWeightFileScanner.cc
Go to the documentation of this file.
1 #include <string>
2 #include <iostream>
3 #include <iomanip>
4 
7 
9 #include "JSupport/JLimit.hh"
11 
12 #include "Jeep/JParser.hh"
13 #include "Jeep/JMessage.hh"
14 
15 
16 /**
17  * \file
18  * Example program for weighing of Monte Carlo events.
19  *
20  * \author bjung
21  */
22 int main(int argc, char **argv)
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
int main(int argc, char *argv[])
Definition: Main.cc:15
#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
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.
Utility class to parse command line options.
Auxiliaries for defining the range of iterations of objects.
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