Jpp 20.0.0-rc.2
the software that should make you happy
Loading...
Searching...
No Matches
JSUPPORT::JEvtWeightFileScannerSet< 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< JComparator_t >:
std::vector< JEvtWeightFileScanner >

Public Types

typedef JEvtWeightFileScanner::input_type input_type
 

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 JComparator_t = std::less<JHead>>
struct JSUPPORT::JEvtWeightFileScannerSet< JComparator_t >

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

Definition at line 56 of file JEvtWeightFileScannerSet.hh.

Member Typedef Documentation

◆ input_type

template<class JComparator_t = std::less<JHead>>
JEvtWeightFileScanner::input_type JSUPPORT::JEvtWeightFileScannerSet< JComparator_t >::input_type

Definition at line 59 of file JEvtWeightFileScannerSet.hh.

Constructor & Destructor Documentation

◆ JEvtWeightFileScannerSet() [1/2]

template<class JComparator_t = std::less<JHead>>
JSUPPORT::JEvtWeightFileScannerSet< JComparator_t >::JEvtWeightFileScannerSet ( )
inline

Default constructor.

Definition at line 65 of file JEvtWeightFileScannerSet.hh.

66 {}

◆ JEvtWeightFileScannerSet() [2/2]

template<class JComparator_t = std::less<JHead>>
JSUPPORT::JEvtWeightFileScannerSet< JComparator_t >::JEvtWeightFileScannerSet ( const input_type & input)
inline

Constructor.

Parameters
inputinput files

Definition at line 74 of file JEvtWeightFileScannerSet.hh.

75 {
76 put(input);
77 }
size_t put(const input_type &input)
Put files.

Member Function Documentation

◆ put() [1/2]

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

Put files.

Parameters
inputinput files
Returns
number of added files

Definition at line 86 of file JEvtWeightFileScannerSet.hh.

87 {
88 size_t n = 0;
89
90 for (typename input_type::const_iterator i = input.begin(); i != input.end(); ++i) {
91 n += size_t(this->put(*i));
92 }
93
94 return n;
95 }
const int n
Definition JPolint.hh:791

◆ put() [2/2]

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

Put file.

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

Definition at line 104 of file JEvtWeightFileScannerSet.hh.

105 {
106 using namespace std;
107 using namespace JPP;
108
109 const JHead& head = getHeader(input);
110
111 iterator i = lower_bound(this->begin(), this->end(), head,
113
114 if (i == this->end() || !i->getHeader().match(head)) {
115 i = this->insert(i, value_type(getEventWeighter(head)));
116 }
117
118 return i->put(input);
119 }
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.
JComparator_t compare
Function object for comparison of headers.

◆ find()

template<class JComparator_t = std::less<JHead>>
const_reference JSUPPORT::JEvtWeightFileScannerSet< JComparator_t >::find ( const JHead & head) const
inline

Find file scanner compatible with a given header.

Parameters
headheader
Returns
file scanner

Definition at line 128 of file JEvtWeightFileScannerSet.hh.

129 {
130 using namespace JPP;
131
132 for (const_iterator i = this->begin(); i != this->end(); ++i) {
133 if (i->match(head)) {
134 return *i;
135 }
136 }
137
138 THROW(JValueOutOfRange, "JEvtWeightFileScannerSet::get(): No corresponding scanner found for given header.");
139 }
#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.

◆ setEvtWeightFactor() [1/3]

template<class JComparator_t = std::less<JHead>>
size_t JSUPPORT::JEvtWeightFileScannerSet< 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 149 of file JEvtWeightFileScannerSet.hh.

151 {
152 using namespace std;
153 using namespace JPP;
154
155 size_t n = 0;
156
157 for (iterator i = this->begin(); i != this->end(); ++i) {
158 n += (size_t) i->setEvtWeightFactor(category, factor);
159 }
160
161 return n;
162 }

◆ setEvtWeightFactor() [2/3]

template<class JComparator_t = std::less<JHead>>
size_t JSUPPORT::JEvtWeightFileScannerSet< 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 177 of file JEvtWeightFileScannerSet.hh.

180 {
181 using namespace std;
182 using namespace JPP;
183
184 size_t n = 0;
185
186 if (requireAll) {
187
188 for (iterator i = this->begin(); i != this->end(); ++i) {
189 n += (size_t) i->setEvtWeightFactor(categories, factor);
190 }
191
192 } else {
193
194 for (iterator i = this->begin(); i != this->end(); ++i) {
195
196 bool isSet = false;
197
198 for (JEvtCategorySet::const_iterator j = categories.cbegin(); j != categories.cend() && !isSet; ++j) {
199 isSet = i->setEvtWeightFactor(*j, factor);
200 }
201
202 n += (size_t) isSet;
203 }
204 }
205
206 return n;
207 }
int j
Definition JPolint.hh:801

◆ setEvtWeightFactor() [3/3]

template<class JComparator_t = std::less<JHead>>
template<class JEvtWeightFactorHelper_t >
size_t JSUPPORT::JEvtWeightFileScannerSet< 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 224 of file JEvtWeightFileScannerSet.hh.

226 {
227 using namespace std;
228 using namespace JPP;
229
230 size_t n = 0;
231
232 if (requireAll) {
233
234 for (iterator i = this->begin(); i != this->end(); ++i) {
235 n += (size_t) i->template setEvtWeightFactor<JEvtWeightFactorHelper_t>(object);
236 }
237
238 } else {
239
240 for (iterator i = this->begin(); i != this->end(); ++i) {
241
242 bool isSet = false;
243
244 for (typename JEvtCategoryMap<JEvtWeightFactorHelper_t>::const_iterator j = object.cbegin(); j != object.cend() && !isSet; ++j) {
245 isSet = i->setEvtWeightFactor(j->first, j->second);
246 }
247
248 n += (size_t) isSet;
249 }
250 }
251
252 return n;
253 }
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 JComparator_t = std::less<JHead>>
size_t JSUPPORT::JEvtWeightFileScannerSet< 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 263 of file JEvtWeightFileScannerSet.hh.

265 {
266 return setEvtWeightFactor(category, flux);
267 }
Neutrino flux.
Definition JHead.hh:906

◆ setFlux() [2/3]

template<class JComparator_t = std::less<JHead>>
size_t JSUPPORT::JEvtWeightFileScannerSet< 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 282 of file JEvtWeightFileScannerSet.hh.

285 {
286 return setEvtWeightFactor(categories, flux, requireAll);
287 }

◆ setFlux() [3/3]

template<class JComparator_t = std::less<JHead>>
size_t JSUPPORT::JEvtWeightFileScannerSet< 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 301 of file JEvtWeightFileScannerSet.hh.

303 {
304 return setEvtWeightFactor(object, requireAll);
305 }

Member Data Documentation

◆ compare

template<class JComparator_t = std::less<JHead>>
JComparator_t JSUPPORT::JEvtWeightFileScannerSet< JComparator_t >::compare

Function object for comparison of headers.

Definition at line 311 of file JEvtWeightFileScannerSet.hh.


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