Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JWeightFileScanner.hh
Go to the documentation of this file.
1 #ifndef __JSUPPORT__JWEIGHTFILESCANNER__
2 #define __JSUPPORT__JWEIGHTFILESCANNER__
3 
6 
7 #include "JAAnet/JHead.hh"
10 
13 
14 /**
15  * \author bjung
16  */
17 
18 namespace JSUPPORT {
19 
22 
23 
24  /**
25  * Template file scanner with event weight.
26  */
27  template<class JFileScanner_t = JMultipleFileScanner<Evt> >
29  public JWeightEventHelper,
30  public JFileScanner_t
31  {
32  /**
33  * Default constructor.
34  */
36  {}
37 
38 
39  /**
40  * Constructor.
41  *
42  * \param weighter event weighter
43  */
45  {
46  reset(weighter);
47  }
48 
49 
50  /**
51  * Reset file scanner and event weighter.
52  *
53  * \param weighter event weighter
54  */
55  void reset(const JWeightEvent& weighter)
56  {
58  JFileScanner_t ::clear();
59  }
60 
61 
62  /**
63  * Put list of files.
64  *
65  * \param input file list
66  * \return number of added files
67  */
68  size_t put(const JFileScanner_t& input)
69  {
70  size_t n = 0;
71 
72  for (typename JFileScanner_t::const_iterator i = input.begin(); i != input.end(); ++i) {
73  n += size_t(this->put(*i));
74  }
75 
76  return n;
77  }
78 
79 
80  /**
81  * Put file.
82  *
83  * \param input file name
84  * \return true if successfully added; else false.
85  */
86  bool put(const std::string& input)
87  {
88  using namespace JPP;
89 
90  const JHead head = JSUPPORT::getHeader(input);
91 
92  if (this->check(head)) {
93 
95  JFileScanner_t ::push_back(input);
96 
97  return true;
98 
99  } else {
100 
101  return false;
102  }
103  }
104  };
105 }
106 
107 #endif
bool put(const std::string &input)
Put file.
bool check(const JHead &head) const
Check if a given header is consistent with this event weighter.
Head getHeader(const JMultipleFileScanner_t &file_list)
Get Monte Carlo header.
JWeightFileScanner(const JWeightEvent &weighter)
Constructor.
Template file scanner with event weight.
Helper class for event weighing.
Low-level interface for event weighing.
Definition: JWeightEvent.hh:23
void reset(const JWeightEvent &weighter)
Reset file scanner and event weighter.
Monte Carlo run header.
Definition: JHead.hh:1050
Scanning of objects from multiple files according a format that follows from the extension of each fi...
size_t put(const JFileScanner_t &input)
Put list of files.
void configure(const JWeightEvent &weighter)
Configuration.
JWeightFileScanner()
Default constructor.
alias put_queue eval echo n
Definition: qlib.csh:19
void add(const JHead &head)
Add header.
virtual void reset() override
Reset pointer.