Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
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< JElement_t, JAllocator_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.
 
 JEvtWeightFileScannerSet (const input_type &input)
 Constructor.
 
size_t put (const input_type &input)
 Put files.
 
bool put (const std::string &input)
 Put file.
 
const_reference find (const JHead &head) const
 Find file scanner compatible with a given header.
 
size_t setEvtWeightFactor (const JEvtCategoryHelper &category, const JEvtWeightFactorHelper &factor)
 Set event-weighting factor for all MC-files corresponding to a given PDG code.
 
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.
 
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.
 
size_t setFlux (const JEvtCategoryHelper &category, const JFluxHelper &flux)
 Set flux function for all MC-files corresponding to a given event category.
 
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.
 
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.
 

Public Attributes

JComparator_t compare
 Function object for comparison of headers.
 

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>>
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>>
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>>
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>>
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>>
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>>
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>>
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>>
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>>
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>>
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:791

◆ 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.
std::vector< filescanner_type >::value_type value_type
JComparator_t compare
Function object for comparison of headers.

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

145 {
146 using namespace JPP;
147
148 for (const_iterator i = this->begin(); i != this->end(); ++i) {
149 if (i->match(head)) {
150 return *i;
151 }
152 }
153
154 THROW(JValueOutOfRange, "JEvtWeightFileScannerSet::get(): No corresponding scanner found for given header.");
155 }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Exception for accessing a value in a collection that is outside of its range.
std::vector< filescanner_type >::const_iterator const_iterator

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

167 {
168 using namespace std;
169 using namespace JPP;
170
171 size_t n = 0;
172
173 for (iterator i = this->begin(); i != this->end(); ++i) {
174 n += (size_t) i->setEvtWeightFactor(category, factor);
175 }
176
177 return n;
178 }

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

196 {
197 using namespace std;
198 using namespace JPP;
199
200 size_t n = 0;
201
202 if (requireAll) {
203
204 for (iterator i = this->begin(); i != this->end(); ++i) {
205 n += (size_t) i->setEvtWeightFactor(categories, factor);
206 }
207
208 } else {
209
210 for (iterator i = this->begin(); i != this->end(); ++i) {
211
212 bool isSet = false;
213
214 for (JEvtCategorySet::const_iterator j = categories.cbegin(); j != categories.cend() && !isSet; ++j) {
215 isSet = i->setEvtWeightFactor(*j, factor);
216 }
217
218 n += (size_t) isSet;
219 }
220 }
221
222 return n;
223 }
int j
Definition JPolint.hh:801

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

242 {
243 using namespace std;
244 using namespace JPP;
245
246 size_t n = 0;
247
248 if (requireAll) {
249
250 for (iterator i = this->begin(); i != this->end(); ++i) {
251 n += (size_t) i->template setEvtWeightFactor<JEvtWeightFactorHelper_t>(object);
252 }
253
254 } else {
255
256 for (iterator i = this->begin(); i != this->end(); ++i) {
257
258 bool isSet = false;
259
260 for (typename JEvtCategoryMap<JEvtWeightFactorHelper_t>::const_iterator j = object.cbegin(); j != object.cend() && !isSet; ++j) {
261 isSet = i->setEvtWeightFactor(j->first, j->second);
262 }
263
264 n += (size_t) isSet;
265 }
266 }
267
268 return n;
269 }
map_type::const_iterator const_iterator
size_t setEvtWeightFactor(const JEvtCategoryHelper &category, const JEvtWeightFactorHelper &factor)
Set event-weighting factor for all MC-files corresponding to a given PDG code.

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

281 {
282 return setEvtWeightFactor(category, flux);
283 }
Neutrino flux.
Definition JHead.hh:906

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

301 {
302 return setEvtWeightFactor(categories, flux, requireAll);
303 }

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

319 {
320 return setEvtWeightFactor(object, requireAll);
321 }

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


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