Jpp  19.1.0
the software that should make you happy
Public Types | Public Member Functions | Public Attributes | List of all members
JSUPPORT::JEvtWeightFileScannerSet< JFileScanner_t, JComparator_t > Struct Template Reference

Auxiliary class for organising Monte Carlo file scanners associated with event weighters. More...

#include <JEvtWeightFileScannerSet.hh>

Inheritance diagram for JSUPPORT::JEvtWeightFileScannerSet< JFileScanner_t, JComparator_t >:
std::vector< JEvtWeightFileScanner< JMultipleFileScanner< Evt > > >

Public Types

typedef JEvtWeightFileScannerSet< JFileScanner_t, JComparator_t > filescannerset_type
 
typedef JEvtWeightFileScanner< JFileScanner_t > filescanner_type
 
typedef filescanner_type::input_type input_type
 
typedef std::vector< filescanner_type >::value_type value_type
 
typedef std::vector< filescanner_type >::reference reference
 
typedef std::vector< filescanner_type >::const_reference const_reference
 
typedef std::vector< filescanner_type >::const_iterator const_iterator
 
typedef std::vector< filescanner_type >::iterator iterator
 
typedef std::vector< filescanner_type >::const_reverse_iterator const_reverse_iterator
 
typedef std::vector< filescanner_type >::reverse_iterator reverse_iterator
 

Public Member Functions

 JEvtWeightFileScannerSet ()
 Default constructor. More...
 
 JEvtWeightFileScannerSet (const input_type &input)
 Constructor. More...
 
size_t put (const input_type &input)
 Put files. More...
 
bool put (const std::string &input)
 Put file. More...
 
std::string getUniqueIdentifier (const_iterator p) const
 Get unique identifier for a file-scanner contained within this set of event-weighter-associated file-scanners. More...
 
const_reference find (const JHead &head) const
 Find file scanner compatible with a given header. More...
 
size_t setEvtWeightFactor (const JEvtCategoryHelper &category, const JEvtWeightFactorHelper &factor)
 Set event-weighting factor for all MC-files corresponding to a given PDG code. More...
 
size_t setEvtWeightFactor (const JEvtCategorySet &categories, const JEvtWeightFactorHelper &factor, const bool requireAll=false)
 Set event-weight factor of all MC-files corresponding to a given set of event categories. More...
 
template<class JEvtWeightFactorHelper_t >
size_t setEvtWeightFactor (const JEvtCategoryMap< JEvtWeightFactorHelper_t > &object, const bool requireAll=false)
 Set event-weight factor of all MC-files according to a given map between event categories and event-weight factors. More...
 
size_t setFlux (const JEvtCategoryHelper &category, const JFluxHelper &flux)
 Set flux function for all MC-files corresponding to a given event category. More...
 
size_t setFlux (const JEvtCategorySet &categories, const JFluxHelper &flux, const bool requireAll=false)
 Set flux function of all MC-files corresponding to a given set of event categories. More...
 
size_t setFlux (const JEvtCategoryMap< JFluxHelper > &object, const bool requireAll=false)
 Set event-weight factor of all MC-files according to a given map between event categories and event-weight factors. More...
 

Public Attributes

JComparator_t compare
 Function object for comparison of headers. More...
 

Detailed Description

template<class JFileScanner_t = JMultipleFileScanner<Evt>, class JComparator_t = std::less<JHead>>
struct JSUPPORT::JEvtWeightFileScannerSet< JFileScanner_t, JComparator_t >

Auxiliary class for organising Monte Carlo file scanners associated with event weighters.

Note: The template class JFileScanner_t must be derived from JMultipleFileScanner<Evt>.

Definition at line 59 of file JEvtWeightFileScannerSet.hh.

Member Typedef Documentation

◆ filescannerset_type

template<class JFileScanner_t = JMultipleFileScanner<Evt>, class JComparator_t = std::less<JHead>>
typedef JEvtWeightFileScannerSet<JFileScanner_t, JComparator_t> JSUPPORT::JEvtWeightFileScannerSet< JFileScanner_t, JComparator_t >::filescannerset_type

Definition at line 62 of file JEvtWeightFileScannerSet.hh.

◆ filescanner_type

template<class JFileScanner_t = JMultipleFileScanner<Evt>, class JComparator_t = std::less<JHead>>
typedef JEvtWeightFileScanner<JFileScanner_t> JSUPPORT::JEvtWeightFileScannerSet< JFileScanner_t, JComparator_t >::filescanner_type

Definition at line 63 of file JEvtWeightFileScannerSet.hh.

◆ input_type

template<class JFileScanner_t = JMultipleFileScanner<Evt>, class JComparator_t = std::less<JHead>>
typedef filescanner_type::input_type JSUPPORT::JEvtWeightFileScannerSet< JFileScanner_t, JComparator_t >::input_type

Definition at line 65 of file JEvtWeightFileScannerSet.hh.

◆ value_type

template<class JFileScanner_t = JMultipleFileScanner<Evt>, class JComparator_t = std::less<JHead>>
typedef std::vector<filescanner_type>::value_type JSUPPORT::JEvtWeightFileScannerSet< JFileScanner_t, JComparator_t >::value_type

Definition at line 67 of file JEvtWeightFileScannerSet.hh.

◆ reference

template<class JFileScanner_t = JMultipleFileScanner<Evt>, class JComparator_t = std::less<JHead>>
typedef std::vector<filescanner_type>::reference JSUPPORT::JEvtWeightFileScannerSet< JFileScanner_t, JComparator_t >::reference

Definition at line 68 of file JEvtWeightFileScannerSet.hh.

◆ const_reference

template<class JFileScanner_t = JMultipleFileScanner<Evt>, class JComparator_t = std::less<JHead>>
typedef std::vector<filescanner_type>::const_reference JSUPPORT::JEvtWeightFileScannerSet< JFileScanner_t, JComparator_t >::const_reference

Definition at line 69 of file JEvtWeightFileScannerSet.hh.

◆ const_iterator

template<class JFileScanner_t = JMultipleFileScanner<Evt>, class JComparator_t = std::less<JHead>>
typedef std::vector<filescanner_type>::const_iterator JSUPPORT::JEvtWeightFileScannerSet< JFileScanner_t, JComparator_t >::const_iterator

Definition at line 71 of file JEvtWeightFileScannerSet.hh.

◆ iterator

template<class JFileScanner_t = JMultipleFileScanner<Evt>, class JComparator_t = std::less<JHead>>
typedef std::vector<filescanner_type>::iterator JSUPPORT::JEvtWeightFileScannerSet< JFileScanner_t, JComparator_t >::iterator

Definition at line 72 of file JEvtWeightFileScannerSet.hh.

◆ const_reverse_iterator

template<class JFileScanner_t = JMultipleFileScanner<Evt>, class JComparator_t = std::less<JHead>>
typedef std::vector<filescanner_type>::const_reverse_iterator JSUPPORT::JEvtWeightFileScannerSet< JFileScanner_t, JComparator_t >::const_reverse_iterator

Definition at line 73 of file JEvtWeightFileScannerSet.hh.

◆ reverse_iterator

template<class JFileScanner_t = JMultipleFileScanner<Evt>, class JComparator_t = std::less<JHead>>
typedef std::vector<filescanner_type>::reverse_iterator JSUPPORT::JEvtWeightFileScannerSet< JFileScanner_t, JComparator_t >::reverse_iterator

Definition at line 74 of file JEvtWeightFileScannerSet.hh.

Constructor & Destructor Documentation

◆ JEvtWeightFileScannerSet() [1/2]

template<class JFileScanner_t = JMultipleFileScanner<Evt>, class JComparator_t = std::less<JHead>>
JSUPPORT::JEvtWeightFileScannerSet< JFileScanner_t, JComparator_t >::JEvtWeightFileScannerSet ( )
inline

Default constructor.

Definition at line 81 of file JEvtWeightFileScannerSet.hh.

82  {}

◆ JEvtWeightFileScannerSet() [2/2]

template<class JFileScanner_t = JMultipleFileScanner<Evt>, class JComparator_t = std::less<JHead>>
JSUPPORT::JEvtWeightFileScannerSet< JFileScanner_t, JComparator_t >::JEvtWeightFileScannerSet ( const input_type input)
inline

Constructor.

Parameters
inputinput files

Definition at line 90 of file JEvtWeightFileScannerSet.hh.

91  {
92  put(input);
93  }
size_t put(const input_type &input)
Put files.

Member Function Documentation

◆ put() [1/2]

template<class JFileScanner_t = JMultipleFileScanner<Evt>, class JComparator_t = std::less<JHead>>
size_t JSUPPORT::JEvtWeightFileScannerSet< JFileScanner_t, JComparator_t >::put ( const input_type input)
inline

Put files.

Parameters
inputinput files
Returns
number of added files

Definition at line 102 of file JEvtWeightFileScannerSet.hh.

103  {
104  size_t n = 0;
105 
106  for (typename input_type::const_iterator i = input.begin(); i != input.end(); ++i) {
107  n += size_t(this->put(*i));
108  }
109 
110  return n;
111  }
const int n
Definition: JPolint.hh:786

◆ put() [2/2]

template<class JFileScanner_t = JMultipleFileScanner<Evt>, class JComparator_t = std::less<JHead>>
bool JSUPPORT::JEvtWeightFileScannerSet< JFileScanner_t, JComparator_t >::put ( const std::string &  input)
inline

Put file.

Parameters
inputinput file
Returns
true if successfully added; else false.

Definition at line 120 of file JEvtWeightFileScannerSet.hh.

121  {
122  using namespace std;
123  using namespace JPP;
124 
125  const JHead& head = getHeader(input);
126 
127  iterator i = lower_bound(this->begin(), this->end(), head,
129 
130  if (i == this->end() || !i->getHeader().match(head)) {
131  i = this->insert(i, value_type(getEventWeighter(head)));
132  }
133 
134  return i->put(input);
135  }
Monte Carlo run header.
Definition: JHead.hh:1236
const JHead & getHeader() const
Get header.
Definition: JHead.hh:1270
JEvtWeighter getEventWeighter
Function object for mapping header to event weighter.
JComparator< JResult_t T::*, JComparison::lt > make_comparator(JResult_t T::*member)
Helper method to create comparator between values of data member.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Head getHeader(const JMultipleFileScanner_t &file_list)
Get Monte Carlo header.
Definition: JSTDTypes.hh:14
std::vector< filescanner_type >::value_type value_type
JComparator_t compare
Function object for comparison of headers.

◆ getUniqueIdentifier()

template<class JFileScanner_t = JMultipleFileScanner<Evt>, class JComparator_t = std::less<JHead>>
std::string JSUPPORT::JEvtWeightFileScannerSet< JFileScanner_t, JComparator_t >::getUniqueIdentifier ( const_iterator  p) const
inline

Get unique identifier for a file-scanner contained within this set of event-weighter-associated file-scanners.

Parameters
piterator to contained file-scanner
Returns
unique identifier of contained file-scanner

Definition at line 144 of file JEvtWeightFileScannerSet.hh.

145  {
146  using namespace std;
147  using namespace JPP;
148 
149  static const char SEPARATOR = '.';
150 
151  string name = p->getProgramName();
152  int index = 0;
153 
154  for (const_iterator i = this->cbegin(); i != this->cend() && i != p; ++i) {
155  if (i->getProgramName() == name) {
156  ++index;
157  }
158  }
159 
160  return MAKE_STRING(name << SEPARATOR << index);
161  }
#define MAKE_STRING(A)
Make string.
Definition: JPrint.hh:63
std::vector< filescanner_type >::const_iterator const_iterator

◆ find()

template<class JFileScanner_t = JMultipleFileScanner<Evt>, class JComparator_t = std::less<JHead>>
const_reference JSUPPORT::JEvtWeightFileScannerSet< JFileScanner_t, JComparator_t >::find ( const JHead head) const
inline

Find file scanner compatible with a given header.

Parameters
headheader
Returns
file scanner

Definition at line 170 of file JEvtWeightFileScannerSet.hh.

171  {
172  using namespace JPP;
173 
174  for (const_iterator i = this->begin(); i != this->end(); ++i) {
175  if (i->match(head)) {
176  return *i;
177  }
178  }
179 
180  THROW(JValueOutOfRange, "JEvtWeightFileScannerSet::get(): No corresponding scanner found for given header.");
181  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
Exception for accessing a value in a collection that is outside of its range.
Definition: JException.hh:180

◆ setEvtWeightFactor() [1/3]

template<class JFileScanner_t = JMultipleFileScanner<Evt>, class JComparator_t = std::less<JHead>>
size_t JSUPPORT::JEvtWeightFileScannerSet< JFileScanner_t, JComparator_t >::setEvtWeightFactor ( const JEvtCategoryHelper category,
const JEvtWeightFactorHelper factor 
)
inline

Set event-weighting factor for all MC-files corresponding to a given PDG code.

Parameters
categoryevent category
factorevent-weight factor
Returns
number of modified event weighters

Definition at line 191 of file JEvtWeightFileScannerSet.hh.

193  {
194  using namespace std;
195  using namespace JPP;
196 
197  size_t n = 0;
198 
199  for (iterator i = this->begin(); i != this->end(); ++i) {
200  n += (size_t) i->setEvtWeightFactor(category, factor);
201  }
202 
203  return n;
204  }

◆ setEvtWeightFactor() [2/3]

template<class JFileScanner_t = JMultipleFileScanner<Evt>, class JComparator_t = std::less<JHead>>
size_t JSUPPORT::JEvtWeightFileScannerSet< JFileScanner_t, JComparator_t >::setEvtWeightFactor ( const JEvtCategorySet categories,
const JEvtWeightFactorHelper factor,
const bool  requireAll = false 
)
inline

Set event-weight factor of all MC-files corresponding to a given set of event categories.

If the boolean requireAll argument is set to true,
the given event-weighting factor will only be assigned to those files
whose header matches < b>all< /b> of the specified event categories.

Parameters
categoriesset of event categories
factorevent-weight factor
requireAlltoggle requirement that the file headers match all given event categories
Returns
number of modified event weighters

Definition at line 219 of file JEvtWeightFileScannerSet.hh.

222  {
223  using namespace std;
224  using namespace JPP;
225 
226  size_t n = 0;
227 
228  if (requireAll) {
229 
230  for (iterator i = this->begin(); i != this->end(); ++i) {
231  n += (size_t) i->setEvtWeightFactor(categories, factor);
232  }
233 
234  } else {
235 
236  for (iterator i = this->begin(); i != this->end(); ++i) {
237 
238  bool isSet = false;
239 
240  for (JEvtCategorySet::const_iterator j = categories.cbegin(); j != categories.cend() && !isSet; ++j) {
241  isSet = i->setEvtWeightFactor(*j, factor);
242  }
243 
244  n += (size_t) isSet;
245  }
246  }
247 
248  return n;
249  }
int j
Definition: JPolint.hh:792

◆ setEvtWeightFactor() [3/3]

template<class JFileScanner_t = JMultipleFileScanner<Evt>, class JComparator_t = std::less<JHead>>
template<class JEvtWeightFactorHelper_t >
size_t JSUPPORT::JEvtWeightFileScannerSet< JFileScanner_t, JComparator_t >::setEvtWeightFactor ( const JEvtCategoryMap< JEvtWeightFactorHelper_t > &  object,
const bool  requireAll = false 
)
inline

Set event-weight factor of all MC-files according to a given map between event categories and event-weight factors.

The template argument refers either to the class JAANET::JEvtWeightFactorHelper or JAANET::JFluxHelper.

If the boolean requireAll argument is set to true,
the given event-weighting factor will only be assigned to those files
whose header matches < b>all< /b> of the specified event categories.

Parameters
objectmap between event categories and event-weight factors
requireAlltoggle requirement that the file headers match all given event categories
Returns
number of modified event weighters

Definition at line 266 of file JEvtWeightFileScannerSet.hh.

268  {
269  using namespace std;
270  using namespace JPP;
271 
272  size_t n = 0;
273 
274  if (requireAll) {
275 
276  for (iterator i = this->begin(); i != this->end(); ++i) {
277  n += (size_t) i->template setEvtWeightFactor<JEvtWeightFactorHelper_t>(object);
278  }
279 
280  } else {
281 
282  for (iterator i = this->begin(); i != this->end(); ++i) {
283 
284  bool isSet = false;
285 
286  for (typename JEvtCategoryMap<JEvtWeightFactorHelper_t>::const_iterator j = object.cbegin(); j != object.cend() && !isSet; ++j) {
287  isSet = i->setEvtWeightFactor(j->first, j->second);
288  }
289 
290  n += (size_t) isSet;
291  }
292  }
293 
294  return n;
295  }
map_type::const_iterator const_iterator

◆ setFlux() [1/3]

template<class JFileScanner_t = JMultipleFileScanner<Evt>, class JComparator_t = std::less<JHead>>
size_t JSUPPORT::JEvtWeightFileScannerSet< JFileScanner_t, JComparator_t >::setFlux ( const JEvtCategoryHelper category,
const JFluxHelper flux 
)
inline

Set flux function for all MC-files corresponding to a given event category.

Parameters
categoryevent category
fluxflux function
Returns
number of modified event weighters

Definition at line 305 of file JEvtWeightFileScannerSet.hh.

307  {
308  return setEvtWeightFactor(category, flux);
309  }
Neutrino flux.
Definition: JHead.hh:906
size_t setEvtWeightFactor(const JEvtCategoryHelper &category, const JEvtWeightFactorHelper &factor)
Set event-weighting factor for all MC-files corresponding to a given PDG code.

◆ setFlux() [2/3]

template<class JFileScanner_t = JMultipleFileScanner<Evt>, class JComparator_t = std::less<JHead>>
size_t JSUPPORT::JEvtWeightFileScannerSet< JFileScanner_t, JComparator_t >::setFlux ( const JEvtCategorySet categories,
const JFluxHelper flux,
const bool  requireAll = false 
)
inline

Set flux function of all MC-files corresponding to a given set of event categories.

If the boolean requireAll argument is set to true, the given flux function will only be assigned to those files
whose header lists < b>all< /b> of the specified PDG codes as primaries.

Parameters
categoriesset of event categories
fluxflux function
requireAlltoggle requirement that each file header must contain every given PDG code.
Returns
number of modified event weighters

Definition at line 324 of file JEvtWeightFileScannerSet.hh.

327  {
328  return setEvtWeightFactor(categories, flux, requireAll);
329  }

◆ setFlux() [3/3]

template<class JFileScanner_t = JMultipleFileScanner<Evt>, class JComparator_t = std::less<JHead>>
size_t JSUPPORT::JEvtWeightFileScannerSet< JFileScanner_t, JComparator_t >::setFlux ( const JEvtCategoryMap< JFluxHelper > &  object,
const bool  requireAll = false 
)
inline

Set event-weight factor of all MC-files according to a given map between event categories and event-weight factors.

If the boolean requireAll argument is set to true, the given flux function will only be assigned to those files
whose header matches < b>all< /b> of the specified event categories.

Parameters
objectmap between event categories and flux functions
requireAlltoggle requirement that the file headers match all given event categories
Returns
number of modified event weighters

Definition at line 343 of file JEvtWeightFileScannerSet.hh.

345  {
346  return setEvtWeightFactor(object, requireAll);
347  }

Member Data Documentation

◆ compare

template<class JFileScanner_t = JMultipleFileScanner<Evt>, class JComparator_t = std::less<JHead>>
JComparator_t JSUPPORT::JEvtWeightFileScannerSet< JFileScanner_t, JComparator_t >::compare

Function object for comparison of headers.

Definition at line 353 of file JEvtWeightFileScannerSet.hh.


The documentation for this struct was generated from the following file: