Jpp  16.0.0-rc.2
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 JEvtWeightFileScanner
< JFileScanner_t > 
value_type
 
typedef std::vector
< value_type >::const_iterator 
const_iterator
 
typedef std::vector
< value_type >::iterator 
iterator
 
typedef std::vector
< value_type >
::const_reverse_iterator 
const_reverse_iterator
 
typedef std::vector
< value_type >
::reverse_iterator 
reverse_iterator
 
typedef std::vector
< value_type >::reference 
reference
 
typedef std::vector
< value_type >
::const_reference 
const_reference
 

Public Member Functions

 JEvtWeightFileScannerSet ()
 Default constructor. More...
 
 JEvtWeightFileScannerSet (const JMultipleFileScanner_t &input)
 Constructor. More...
 
size_t put (const JMultipleFileScanner_t &input)
 Put file. 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 JEvtWeightFileScanner
< JFileScanner_t > & 
find (const JHead &head) const
 Find file scanner compatible with a given header. More...
 
size_t setEvtWeightFactor (const int type, const JEvtWeightFactor &factor)
 Set event-weighting factor for all MC-files corresponding to a given PDG code. More...
 
size_t setEvtWeightFactor (const std::set< int > &types, const JEvtWeightFactor &factor)
 Set event-weight factor of all MC-files corresponding to a given set of PDG codes. More...
 
size_t setEvtWeightFactor (const JEvtWeightFactorMultiParticle &multiParticleFactor)
 Set event-weight factor of all MC-files corresponding to a given multi-particle flux. More...
 
size_t setFlux (const int type, const JFlux &function)
 Set flux function for all MC-files corresponding to a given PDG code. More...
 
size_t setFlux (const std::set< int > &types, const JFlux &function)
 Set flux function of all MC-files corresponding to a given set of PDG codes. More...
 
size_t setFlux (const JFluxMultiParticle &multiParticleFlux)
 Set flux function of all MC-files corresponding to a given multi-particle flux. 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.

Definition at line 51 of file JEvtWeightFileScannerSet.hh.

Member Typedef Documentation

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

Definition at line 54 of file JEvtWeightFileScannerSet.hh.

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

Definition at line 56 of file JEvtWeightFileScannerSet.hh.

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

Definition at line 57 of file JEvtWeightFileScannerSet.hh.

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

Definition at line 58 of file JEvtWeightFileScannerSet.hh.

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

Definition at line 59 of file JEvtWeightFileScannerSet.hh.

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

Definition at line 61 of file JEvtWeightFileScannerSet.hh.

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

Definition at line 62 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 68 of file JEvtWeightFileScannerSet.hh.

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

Constructor.

Parameters
inputfile list

Definition at line 77 of file JEvtWeightFileScannerSet.hh.

78  {
79  put(input);
80  }
size_t put(const JMultipleFileScanner_t &input)
Put file.

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 JMultipleFileScanner_t input)
inline

Put file.

Parameters
inputfile list
Returns
number of added files

Definition at line 89 of file JEvtWeightFileScannerSet.hh.

90  {
91  size_t n = 0;
92 
93  for (JMultipleFileScanner_t::const_iterator i = input.begin(); i != input.end(); ++i) {
94  n += size_t(this->put(*i));
95  }
96 
97  return n;
98  }
size_t put(const JMultipleFileScanner_t &input)
Put file.
const int n
Definition: JPolint.hh:676
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
inputfile name
Returns
true if successfully added; else false.

Definition at line 107 of file JEvtWeightFileScannerSet.hh.

108  {
109  using namespace std;
110  using namespace JPP;
111 
112  const JHead& head = getHeader(input);
113 
114  iterator i = lower_bound(this->begin(), this->end(), head,
116 
117  if (i == this->end() || !i->getHeader().match(head)) {
118  i = this->insert(i, value_type(getEventWeighter(head)));
119  }
120 
121  return i->put(input);
122  }
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.
Definition: JComparator.hh:185
const JHead & getHeader() const
Get header.
Definition: JHead.hh:1197
JEvtWeightFileScanner< JFileScanner_t > value_type
Head getHeader(const JMultipleFileScanner_t &file_list)
Get Monte Carlo header.
Monte Carlo run header.
Definition: JHead.hh:1164
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 131 of file JEvtWeightFileScannerSet.hh.

132  {
133  using namespace std;
134  using namespace JPP;
135 
136  static const char SEPARATOR = '.';
137 
138  string name = p->getProgramName();
139  int index = 0;
140 
141  for (typename vector<value_type>::const_iterator i = this->cbegin(); i != this->cend() && i != p; ++i) {
142  if (i->getProgramName() == name) {
143  ++index;
144  }
145  }
146 
147  return MAKE_STRING(name << SEPARATOR << index);
148  }
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:142
template<class JFileScanner_t = JMultipleFileScanner<Evt>, class JComparator_t = std::less<JHead>>
const JEvtWeightFileScanner<JFileScanner_t>& 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 157 of file JEvtWeightFileScannerSet.hh.

158  {
159  for (const_iterator i = this->begin(); i != this->end(); ++i) {
160  if (i->match(head)) {
161  return *i;
162  }
163  }
164 
165  THROW(JValueOutOfRange, "JEvtWeightFileScannerSet::get(): No corresponding scanner found for given header.");
166  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:696
Exception for accessing a value in a collection that is outside of its range.
Definition: JException.hh:162
std::vector< value_type >::const_iterator const_iterator
template<class JFileScanner_t = JMultipleFileScanner<Evt>, class JComparator_t = std::less<JHead>>
size_t JSUPPORT::JEvtWeightFileScannerSet< JFileScanner_t, JComparator_t >::setEvtWeightFactor ( const int  type,
const JEvtWeightFactor factor 
)
inline

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

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

181  {
182  using namespace std;
183  using namespace JPP;
184 
185  size_t n = 0;
186 
187  for (iterator i = this->begin(); i != this->end(); ++i) {
188  n += (size_t) i->setEvtWeightFactor(type, factor);
189  }
190 
191  return n;
192  }
const int n
Definition: JPolint.hh:676
template<class JFileScanner_t = JMultipleFileScanner<Evt>, class JComparator_t = std::less<JHead>>
size_t JSUPPORT::JEvtWeightFileScannerSet< JFileScanner_t, JComparator_t >::setEvtWeightFactor ( const std::set< int > &  types,
const JEvtWeightFactor factor 
)
inline

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

Note that 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
Returns
number of modified event weighters

Definition at line 205 of file JEvtWeightFileScannerSet.hh.

207  {
208  using namespace std;
209  using namespace JPP;
210 
211  size_t n = 0;
212 
213  for (iterator i = this->begin(); i != this->end(); ++i) {
214  n += (size_t) i->setEvtWeightFactor(types, factor);
215  }
216 
217  return n;
218  }
const int n
Definition: JPolint.hh:676
template<class JFileScanner_t = JMultipleFileScanner<Evt>, class JComparator_t = std::less<JHead>>
size_t JSUPPORT::JEvtWeightFileScannerSet< JFileScanner_t, JComparator_t >::setEvtWeightFactor ( const JEvtWeightFactorMultiParticle multiParticleFactor)
inline

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

Note that the given event-weighting factors will only be assigned to those files
whose header lists < b>all< /b> of the PDG codes associated with the multi-particle event-weighting factor object as primaries.

Parameters
multiParticleFactormulti-particle event-weight factor
Returns
number of modified event weighters

Definition at line 230 of file JEvtWeightFileScannerSet.hh.

231  {
232  using namespace std;
233  using namespace JPP;
234 
235  size_t n = 0;
236 
237  for (iterator i = this->begin(); i != this->end(); ++i) {
238  n += (size_t) i->setEvtWeightFactor(multiParticleFactor);
239  }
240 
241  return n;
242  }
const int n
Definition: JPolint.hh:676
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 &  function 
)
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
functionflux function
Returns
number of modified event weighters

Definition at line 255 of file JEvtWeightFileScannerSet.hh.

257  {
258  return setEvtWeightFactor(type, function);
259  }
size_t setEvtWeightFactor(const int type, const JEvtWeightFactor &factor)
Set event-weighting factor for all MC-files corresponding to a given PDG code.
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 &  function 
)
inline

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

Note that 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
functionflux function
Returns
number of modified event weighters

Definition at line 272 of file JEvtWeightFileScannerSet.hh.

274  {
275  return setEvtWeightFactor(types, function);
276  }
size_t setEvtWeightFactor(const int type, const JEvtWeightFactor &factor)
Set event-weighting factor for all MC-files corresponding to a given PDG code.
template<class JFileScanner_t = JMultipleFileScanner<Evt>, class JComparator_t = std::less<JHead>>
size_t JSUPPORT::JEvtWeightFileScannerSet< JFileScanner_t, JComparator_t >::setFlux ( const JFluxMultiParticle &  multiParticleFlux)
inline

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

Note that the given flux functions will only be assigned to those files
whose header lists < b>all< /b> of the PDG codes associated with the multi-particle flux as primaries.

Parameters
multiParticleFluxmulti-particle flux object
Returns
number of modified event weighters

Definition at line 288 of file JEvtWeightFileScannerSet.hh.

289  {
290  return setEvtWeightFactor(multiParticleFlux);
291  }
size_t setEvtWeightFactor(const int type, const JEvtWeightFactor &factor)
Set event-weighting factor for all MC-files corresponding to a given PDG code.

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


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