Jpp  18.1.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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< JFileScanner_t > >

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...
 
template<class JEvtWeightFactor_t = JEvtWeightFactor>
size_t setEvtWeightFactor (const int type, const JEvtWeightFactor_t &factor)
 Set event-weighting factor for all MC-files corresponding to a given PDG code. More...
 
template<class JEvtWeightFactor_t = JEvtWeightFactor>
size_t setEvtWeightFactor (const std::set< int > &types, const JEvtWeightFactor_t &factor, const bool requireAll=false)
 Set event-weight factor of all MC-files corresponding to a given set of PDG codes. More...
 
template<class JEvtWeightFactor_t = JEvtWeightFactor>
size_t setEvtWeightFactor (const JEvtWeightFactorMultiParticle< JEvtWeightFactor_t > &multiParticleFactor, const bool requireAll=false)
 Set event-weight factor of all MC-files corresponding to a given multi-particle flux. More...
 
size_t setFlux (const int type, const JFlux &flux)
 Set flux function for all MC-files corresponding to a given PDG code. More...
 
size_t setFlux (const std::set< int > &types, const JFlux &flux, const bool requireAll=false)
 Set flux function of all MC-files corresponding to a given set of PDG codes. More...
 
size_t setFlux (const JEvtWeightFactorMultiParticle< JFlux > &multiParticleFlux, const bool requireAll=false)
 Set flux function of all MC-files corresponding to a given multi-particle flux interface. 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 must be derived from JMultipleFileScanner<Evt>.

Definition at line 51 of file JEvtWeightFileScannerSet.hh.

Member Typedef Documentation

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 54 of file JEvtWeightFileScannerSet.hh.

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 55 of file JEvtWeightFileScannerSet.hh.

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 57 of file JEvtWeightFileScannerSet.hh.

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 59 of file JEvtWeightFileScannerSet.hh.

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 60 of file JEvtWeightFileScannerSet.hh.

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 61 of file JEvtWeightFileScannerSet.hh.

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 63 of file JEvtWeightFileScannerSet.hh.

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 64 of file JEvtWeightFileScannerSet.hh.

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 65 of file JEvtWeightFileScannerSet.hh.

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 66 of file JEvtWeightFileScannerSet.hh.

Constructor & Destructor Documentation

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 73 of file JEvtWeightFileScannerSet.hh.

74  {}
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 82 of file JEvtWeightFileScannerSet.hh.

83  {
84  put(input);
85  }
size_t put(const input_type &input)
Put files.

Member Function Documentation

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 94 of file JEvtWeightFileScannerSet.hh.

95  {
96  size_t n = 0;
97 
98  for (typename input_type::const_iterator i = input.begin(); i != input.end(); ++i) {
99  n += size_t(this->put(*i));
100  }
101 
102  return n;
103  }
size_t put(const input_type &input)
Put files.
const int n
Definition: JPolint.hh:697
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 112 of file JEvtWeightFileScannerSet.hh.

113  {
114  using namespace std;
115  using namespace JPP;
116 
117  const JHead& head = getHeader(input);
118 
119  iterator i = lower_bound(this->begin(), this->end(), head,
121 
122  if (i == this->end() || !i->getHeader().match(head)) {
123  i = this->insert(i, value_type(getEventWeighter(head)));
124  }
125 
126  return i->put(input);
127  }
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.
const JHead & getHeader() const
Get header.
Definition: JHead.hh:1256
Head getHeader(const JMultipleFileScanner_t &file_list)
Get Monte Carlo header.
Monte Carlo run header.
Definition: JHead.hh:1221
std::vector< filescanner_type >::value_type value_type
JComparator_t compare
Function object for comparison of headers.
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 136 of file JEvtWeightFileScannerSet.hh.

137  {
138  using namespace std;
139  using namespace JPP;
140 
141  static const char SEPARATOR = '.';
142 
143  string name = p->getProgramName();
144  int index = 0;
145 
146  for (const_iterator i = this->cbegin(); i != this->cend() && i != p; ++i) {
147  if (i->getProgramName() == name) {
148  ++index;
149  }
150  }
151 
152  return MAKE_STRING(name << SEPARATOR << index);
153  }
then echo Enter input within $TIMEOUT_S seconds echo n User name
Definition: JCookie.sh:42
#define MAKE_STRING(A)
Make string.
Definition: JPrint.hh:127
std::vector< filescanner_type >::const_iterator const_iterator
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 162 of file JEvtWeightFileScannerSet.hh.

163  {
164  for (const_iterator i = this->begin(); i != this->end(); ++i) {
165  if (i->match(head)) {
166  return *i;
167  }
168  }
169 
170  THROW(JValueOutOfRange, "JEvtWeightFileScannerSet::get(): No corresponding scanner found for given header.");
171  }
#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:178
std::vector< filescanner_type >::const_iterator const_iterator
template<class JFileScanner_t = JMultipleFileScanner<Evt>, class JComparator_t = std::less<JHead>>
template<class JEvtWeightFactor_t = JEvtWeightFactor>
size_t JSUPPORT::JEvtWeightFileScannerSet< JFileScanner_t, JComparator_t >::setEvtWeightFactor ( const int  type,
const JEvtWeightFactor_t &  factor 
)
inline

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

The template argument corresponds to the desired class of event-weight factor. This class must contain the method getFactor(const Evt&).

Note that the given event-weighting factor will only be assigned to those files
whose header exclusively lists the given PDG code as primary.

Parameters
typePDG code
factorevent-weight factor
Returns
number of modified event weighters

Definition at line 188 of file JEvtWeightFileScannerSet.hh.

190  {
191  using namespace std;
192  using namespace JPP;
193 
194  size_t n = 0;
195 
196  for (iterator i = this->begin(); i != this->end(); ++i) {
197  n += (size_t) i->template setEvtWeightFactor<JEvtWeightFactor_t>(type, factor);
198  }
199 
200  return n;
201  }
const int n
Definition: JPolint.hh:697
template<class JFileScanner_t = JMultipleFileScanner<Evt>, class JComparator_t = std::less<JHead>>
template<class JEvtWeightFactor_t = JEvtWeightFactor>
size_t JSUPPORT::JEvtWeightFileScannerSet< JFileScanner_t, JComparator_t >::setEvtWeightFactor ( const std::set< int > &  types,
const JEvtWeightFactor_t &  factor,
const bool  requireAll = false 
)
inline

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

The template argument corresponds to the desired class of event-weight factor. This class must contain the method getFactor(const Evt&).

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

Parameters
typesset of PDG codes
factorevent-weight factor
requireAlltoggle requirement that each file header must contain every given PDG code.
Returns
number of modified event weighters

Definition at line 220 of file JEvtWeightFileScannerSet.hh.

223  {
224  using namespace std;
225  using namespace JPP;
226 
227  size_t n = 0;
228 
229  if (requireAll) {
230 
231  for (iterator i = this->begin(); i != this->end(); ++i) {
232  n += (size_t) i->template setEvtWeightFactor<JEvtWeightFactor_t>(types, factor);
233  }
234 
235  } else {
236 
237  for (iterator i = this->begin(); i != this->end(); ++i) {
238 
239  bool isSet = false;
240 
241  for (set<int>::const_iterator j = types.cbegin(); j != types.cend() && !isSet; ++j) {
242  isSet = i->template setEvtWeightFactor<JEvtWeightFactor_t>(*i, factor);
243  }
244 
245  n += (size_t) isSet;
246  }
247  }
248 
249  return n;
250  }
const int n
Definition: JPolint.hh:697
int j
Definition: JPolint.hh:703
template<class JFileScanner_t = JMultipleFileScanner<Evt>, class JComparator_t = std::less<JHead>>
template<class JEvtWeightFactor_t = JEvtWeightFactor>
size_t JSUPPORT::JEvtWeightFileScannerSet< JFileScanner_t, JComparator_t >::setEvtWeightFactor ( const JEvtWeightFactorMultiParticle< JEvtWeightFactor_t > &  multiParticleFactor,
const bool  requireAll = false 
)
inline

Set event-weight factor of all MC-files corresponding to a given multi-particle flux.

The template argument corresponds to the desired class of event-weight factor. This class must contain the method getFactor(const Evt&).

If the boolean requireAll argument is set to true, the given flux factor will only be assigned to those files
whose header lists < b>all< /b> of the PDG codes associated with the multi-particle flux interface as primaries.

Parameters
multiParticleFactormulti-particle event-weight factor
requireAlltoggle requirement that each file header must contain every given PDG code.
Returns
number of modified event weighters

Definition at line 268 of file JEvtWeightFileScannerSet.hh.

270  {
271  using namespace std;
272  using namespace JPP;
273 
274  size_t n = 0;
275 
276  if (requireAll) {
277 
278  for (iterator i = this->begin(); i != this->end(); ++i) {
279  n += (size_t) i->template setEvtWeightFactor<JEvtWeightFactor_t>(multiParticleFactor);
280  }
281 
282  } else {
283 
284  for (iterator i = this->begin(); i != this->end(); ++i) {
285 
286  bool isSet = false;
287 
288  for (typename JEvtWeightFactorMultiParticle<JEvtWeightFactor_t>::const_iterator j = multiParticleFactor.cbegin(); j != multiParticleFactor.cend() && !isSet; ++j) {
289  isSet = i->template setEvtWeightFactor<JEvtWeightFactor_t>(j->first, *(j->second));
290  }
291 
292  n += (size_t) isSet;
293  }
294  }
295 
296  return n;
297  }
const int n
Definition: JPolint.hh:697
Implementation of event-weight factor for multiple particle types.
int j
Definition: JPolint.hh:703
template<class JFileScanner_t = JMultipleFileScanner<Evt>, class JComparator_t = std::less<JHead>>
size_t JSUPPORT::JEvtWeightFileScannerSet< JFileScanner_t, JComparator_t >::setFlux ( const int  type,
const JFlux flux 
)
inline

Set flux function for all MC-files corresponding to a given PDG code.

Note that only the given flux function will only be assigned to those files
whose header exclusively lists the given PDG code as primary.

Parameters
typePDG code
fluxflux function
Returns
number of modified event weighters

Definition at line 310 of file JEvtWeightFileScannerSet.hh.

312  {
313  return setEvtWeightFactor<JFlux>(type, flux);
314  }
template<class JFileScanner_t = JMultipleFileScanner<Evt>, class JComparator_t = std::less<JHead>>
size_t JSUPPORT::JEvtWeightFileScannerSet< JFileScanner_t, JComparator_t >::setFlux ( const std::set< int > &  types,
const JFlux flux,
const bool  requireAll = false 
)
inline

Set flux function of all MC-files corresponding to a given set of PDG codes.

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
typesset of PDG codes
fluxflux function
requireAlltoggle requirement that each file header must contain every given PDG code.
Returns
number of modified event weighters

Definition at line 329 of file JEvtWeightFileScannerSet.hh.

332  {
333  return setEvtWeightFactor<JFlux>(types, flux, requireAll);
334  }
template<class JFileScanner_t = JMultipleFileScanner<Evt>, class JComparator_t = std::less<JHead>>
size_t JSUPPORT::JEvtWeightFileScannerSet< JFileScanner_t, JComparator_t >::setFlux ( const JEvtWeightFactorMultiParticle< JFlux > &  multiParticleFlux,
const bool  requireAll = false 
)
inline

Set flux function of all MC-files corresponding to a given multi-particle flux interface.

If the boolean requireAll argument is set to true, the given flux factor will only be assigned to those files
whose header lists < b>all< /b> of the PDG codes associated with the multi-particle flux interface as primaries.

Parameters
multiParticleFluxmulti-particle flux object
requireAlltoggle requirement that each file header must contain every given PDG code.
Returns
number of modified event weighters

Definition at line 348 of file JEvtWeightFileScannerSet.hh.

350  {
351  return setEvtWeightFactor<JFlux>(multiParticleFlux, requireAll);
352  }

Member Data Documentation

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 358 of file JEvtWeightFileScannerSet.hh.


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