1 #ifndef __JSUPPORT__JEVTWEIGHTFILESCANNER__
2 #define __JSUPPORT__JEVTWEIGHTFILESCANNER__
31 namespace JPP {
using namespace JSUPPORT; }
47 template<
class JFileScanner_t = JMultipleFileScanner<Evt> >
106 static const char SEPARATOR =
'.';
110 if (header.simul.size() > 0) {
112 string name = header.simul.cbegin()->program;
122 THROW(
JNoValue,
"JEvtWeightFileScanner::getProgramName(): Missing simul header-field!");
135 JFileScanner_t ::clear();
149 for (
typename input_type::const_iterator
i = input.begin();
i != input.end(); ++
i) {
150 n += size_t(this->
put(*
i));
163 bool put(
const std::string& input)
169 if (this->
check(head)) {
172 JFileScanner_t ::push_back(input);
193 template<
class JEvtWeightFactor_t = JEvtWeightFactor>
195 const JEvtWeightFactor_t& factor)
204 if ((header.primary.type == type) ||
206 (find_if(header.flux.cbegin(), header.flux.cend(),
209 JEvtWeightFactorHelper_t* helper =
dynamic_cast<JEvtWeightFactorHelper_t*
>(this->
get());
211 if (helper != NULL) {
213 helper->configure(factor);
236 template<
class JEvtWeightFactor_t = JEvtWeightFactor>
238 const JEvtWeightFactor_t& factor)
245 bool matching = (!types.empty());
255 matching = (flux != header.flux.cend());
260 JEvtWeightFactorHelper_t* helper =
dynamic_cast<JEvtWeightFactorHelper_t*
>(this->
get());
262 if (helper != NULL) {
264 helper->configure(factor);
286 template<
class JEvtWeightFactor_t = JEvtWeightFactor>
294 typedef typename JEvtWeightFactorMultiParticle_t::const_iterator const_iterator;
296 bool matching = (!multiParticleFactor.empty());
300 for (const_iterator
i = multiParticleFactor.cbegin();
i != multiParticleFactor.cend() && matching; ++
i) {
306 matching = (flux != header.flux.cend());
311 JEvtWeightFactorHelper_t* helper =
dynamic_cast<JEvtWeightFactorHelper_t*
>(this->
get());
313 if (helper != NULL) {
315 helper->configure(multiParticleFactor);
333 const JFlux&
function)
335 return setEvtWeightFactor<JFlux>(
type,
function);
350 const JFlux&
function)
352 return setEvtWeightFactor<JFlux>(types,
function);
367 return setEvtWeightFactor<JFlux>(multiParticleFlux);
bool is_mupage(const JHead &header)
Check for generator.
JEvtWeighter getEventWeighter
Function object for mapping header to event weighter.
void configure(const JEvtWeight &weighter)
Configuration.
void reset(const JEvtWeight &weighter)
Reset file scanner and event weighter.
JPredicate< JResult_t T::*, JComparison::eq > make_predicate(JResult_t T::*member, const JResult_t value)
Helper method to create predicate for data member.
bool setFlux(const std::set< int > &types, const JFlux &function)
Set flux function corresponding to a given set of PDG codes.
bool setEvtWeightFactor(const int type, const JEvtWeightFactor_t &factor)
Set event-weight factor corresponding to a given PDG code.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
bool check(const JHead &header) const
Check if a given header is consistent with this event weighter.
JEvtWeightFileScanner(const input_type &input)
Constructor.
#define MAKE_STRING(A)
Make string.
Head getHeader(const JMultipleFileScanner_t &file_list)
Get Monte Carlo header.
Exception for missing value.
Abstract base class for event weighing.
bool setEvtWeightFactor(const JEvtWeightFactorMultiParticle< JEvtWeightFactor_t > &multiParticleFactor)
Set event-weight factor corresponding to a given multi-particle weighting factor interface.
Implementation of event-weight factor for multiple particle types.
Helper class for event-weight factor.
bool setFlux(const int type, const JFlux &function)
Set flux function corresponding to a given PDG code.
Low-level interface for retrieving the flux corresponding to a given event.
then fatal The output file must have the wildcard in the name
Scanning of objects from multiple files according a format that follows from the extension of each fi...
JLANG::JSTDObjectReader< const event_type > input_type
JFileScanner_t::input_type input_type
JEvtWeightFileScanner()
Default constructor.
bool put(const std::string &input)
Put file.
size_t put(const input_type &input)
Put files.
then set_variable DETECTOR set_variable OUTPUT_FILE set_variable DAQ_FILE set_variable PMT_FILE else fatal Wrong number of arguments fi JPrintTree f $DAQ_FILE type
const JHead & getHeader() const
Get header.
Template event-weighter-associated file scanner.
Low-level interface for retrieving a specifiable multiplication factor corresponding to a given event...
bool setFlux(const JEvtWeightFactorMultiParticle< JFlux > &multiParticleFlux)
Set flux function corresponding to a given multi-particle flux interface.
bool setEvtWeightFactor(const std::set< int > &types, const JEvtWeightFactor_t &factor)
Set event-weight factor corresponding to a given set of PDG codes.
Helper class for event weighing.
void add(const JHead &header)
Add header.
JEvtWeightFileScanner(const JEvtWeight &weighter)
Constructor.
std::string getProgramName() const
Get name of simulation program.