GENIEGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | Friends | List of all members
genie::Algorithm Class Reference

Algorithm abstract base class. More...

#include <Algorithm.h>

Inheritance diagram for genie::Algorithm:
Inheritance graph
[legend]
Collaboration diagram for genie::Algorithm:
Collaboration graph
[legend]

Public Member Functions

virtual ~Algorithm ()
 
virtual void Configure (const Registry &config)
 
virtual void Configure (string config)
 
virtual void FindConfig (void)
 
virtual const RegistryGetConfig (void) const
 
RegistryGetOwnedConfig (void)
 
virtual const AlgIdId (void) const
 Get algorithm ID. More...
 
virtual AlgStatus_t GetStatus (void) const
 Get algorithm status. More...
 
virtual bool AllowReconfig (void) const
 
virtual AlgCmp_t Compare (const Algorithm *alg) const
 Compare with input algorithm. More...
 
virtual void SetId (const AlgId &id)
 Set algorithm ID. More...
 
virtual void SetId (string name, string config)
 
const AlgorithmSubAlg (const RgKey &registry_key) const
 
void AdoptConfig (void)
 
void AdoptSubstructure (void)
 
virtual void Print (ostream &stream) const
 Print algorithm info. More...
 

Static Public Member Functions

static string BuildParamVectKey (const std::string &comm_name, unsigned int i)
 
static string BuildParamVectSizeKey (const std::string &comm_name)
 
static string BuildParamMatKey (const std::string &comm_name, unsigned int i, unsigned int j)
 
static string BuildParamMatRowSizeKey (const std::string &comm_name)
 
static string BuildParamMatColSizeKey (const std::string &comm_name)
 

Protected Member Functions

 Algorithm ()
 
 Algorithm (string name)
 
 Algorithm (string name, string config)
 
void Initialize (void)
 
void DeleteConfig (void)
 
void DeleteSubstructure (void)
 
RegistryExtractLocalConfig (const Registry &in) const
 
RegistryExtractLowerConfig (const Registry &in, const string &alg_key) const
 Split an incoming configuration Registry into a block valid for the sub-algo identified by alg_key. More...
 
template<class T >
bool GetParam (const RgKey &name, T &p, bool is_top_call=true) const
 
template<class T >
bool GetParamDef (const RgKey &name, T &p, const T &def) const
 
template<class T >
int GetParamVect (const std::string &comm_name, std::vector< T > &v, bool is_top_call=true) const
 Handle to load vectors of parameters. More...
 
int GetParamVectKeys (const std::string &comm_name, std::vector< RgKey > &k, bool is_top_call=true) const
 
template<class T >
int GetParamMat (const std::string &comm_name, TMatrixT< T > &mat, bool is_top_call=true) const
 Handle to load matrix of parameters. More...
 
template<class T >
int GetParamMatSym (const std::string &comm_name, TMatrixTSym< T > &mat, bool is_top_call=true) const
 
int GetParamMatKeys (const std::string &comm_name, std::vector< RgKey > &k, bool is_top_call=true) const
 
int AddTopRegistry (Registry *rp, bool owns=true)
 add registry with top priority, also update ownership More...
 
int AddLowRegistry (Registry *rp, bool owns=true)
 add registry with lowest priority, also update ownership More...
 
int MergeTopRegistry (const Registry &r)
 
int AddTopRegisties (const vector< Registry * > &rs, bool owns=false)
 Add registries with top priority, also udated Ownerships. More...
 

Protected Attributes

bool fAllowReconfig
 
bool fOwnsSubstruc
 true if it owns its substructure (sub-algs,...) More...
 
AlgId fID
 algorithm name and configuration set More...
 
vector< Registry * > fConfVect
 
vector< bool > fOwnerships
 ownership for every registry in fConfVect More...
 
AlgStatus_t fStatus
 algorithm execution status More...
 
AlgMapfOwnedSubAlgMp
 local pool for owned sub-algs (taken out of the factory pool) More...
 

Private Attributes

RegistryfConfig
 Summary configuration derived from fConvVect, not necessarily allocated. More...
 

Friends

ostream & operator<< (ostream &stream, const Algorithm &alg)
 

Detailed Description

Algorithm abstract base class.

Author
Costas Andreopoulos <c.andreopoulos cern.ch> University of Liverpool

Marco Roda <mroda liverpool.ac.uk> University of Liverpool

Created:
May 02, 2004
License:
Copyright (c) 2003-2024, The GENIE Collaboration For the full text of the license visit http://copyright.genie-mc.org

Definition at line 54 of file Algorithm.h.

Constructor & Destructor Documentation

Algorithm::~Algorithm ( )
virtual

Definition at line 56 of file Algorithm.cxx.

57 {
58  this->DeleteConfig();
59  this->DeleteSubstructure();
60 }
void DeleteSubstructure(void)
Definition: Algorithm.cxx:488
void DeleteConfig(void)
Definition: Algorithm.cxx:463
Algorithm::Algorithm ( )
protected

Definition at line 38 of file Algorithm.cxx.

References Initialize().

39 {
40  this->Initialize();
41 }
void Initialize(void)
Definition: Algorithm.cxx:335
Algorithm::Algorithm ( string  name)
protected

Definition at line 43 of file Algorithm.cxx.

References Initialize().

44 {
45  this->Initialize();
46  fID.SetId(name);
47 }
AlgId fID
algorithm name and configuration set
Definition: Algorithm.h:165
void SetId(string name, string config="")
Definition: AlgId.cxx:64
void Initialize(void)
Definition: Algorithm.cxx:335
const char * name
Algorithm::Algorithm ( string  name,
string  config 
)
protected

Definition at line 49 of file Algorithm.cxx.

References Initialize().

50 {
51  this->Initialize();
52  fID.SetId(name,config);
53  this->FindConfig();
54 }
AlgId fID
algorithm name and configuration set
Definition: Algorithm.h:165
virtual void FindConfig(void)
Definition: Algorithm.cxx:127
void SetId(string name, string config="")
Definition: AlgId.cxx:64
void Initialize(void)
Definition: Algorithm.cxx:335
const char * name

Member Function Documentation

int Algorithm::AddLowRegistry ( Registry rp,
bool  owns = true 
)
protected

add registry with lowest priority, also update ownership

Definition at line 702 of file Algorithm.cxx.

Referenced by genie::EventGenerator::Configure().

702  {
703 
704  fConfVect.push_back( rp ) ;
705  fOwnerships.push_back( own ) ;
706 
707  if ( fConfig ) {
708  delete fConfig ;
709  fConfig = 0 ;
710  }
711 
712  return fConfVect.size() ;
713 
714 }
vector< Registry * > fConfVect
Definition: Algorithm.h:170
vector< bool > fOwnerships
ownership for every registry in fConfVect
Definition: Algorithm.h:173
Registry * fConfig
Summary configuration derived from fConvVect, not necessarily allocated.
Definition: Algorithm.h:217
int Algorithm::AddTopRegisties ( const vector< Registry * > &  rs,
bool  owns = false 
)
protected

Add registries with top priority, also udated Ownerships.

Definition at line 754 of file Algorithm.cxx.

754  {
755 
756  fConfVect.insert( fConfVect.begin(), rs.begin(), rs.end() ) ;
757 
758  fOwnerships.insert( fOwnerships.begin(), rs.size(), own ) ;
759 
760  if ( fConfig ) {
761  delete fConfig ;
762  fConfig = 0 ;
763  }
764 
765  return fConfVect.size() ;
766 
767 }
vector< Registry * > fConfVect
Definition: Algorithm.h:170
vector< bool > fOwnerships
ownership for every registry in fConfVect
Definition: Algorithm.h:173
Registry * fConfig
Summary configuration derived from fConvVect, not necessarily allocated.
Definition: Algorithm.h:217
int Algorithm::AddTopRegistry ( Registry rp,
bool  owns = true 
)
protected

add registry with top priority, also update ownership

Definition at line 686 of file Algorithm.cxx.

Referenced by genie::EventGeneratorListAssembler::AssembleGeneratorList().

686  {
687 
688  fConfVect.insert( fConfVect.begin(), rp ) ;
689  fOwnerships.insert( fOwnerships.begin(), own ) ;
690 
691  if ( fConfig ) {
692  delete fConfig ;
693  fConfig = 0 ;
694  }
695 
696  return fConfVect.size() ;
697 
698 }
vector< Registry * > fConfVect
Definition: Algorithm.h:170
vector< bool > fOwnerships
ownership for every registry in fConfVect
Definition: Algorithm.h:173
Registry * fConfig
Summary configuration derived from fConvVect, not necessarily allocated.
Definition: Algorithm.h:217
void Algorithm::AdoptConfig ( void  )

Clone the configuration registry looked up from the configuration pool and take its ownership

Definition at line 386 of file Algorithm.cxx.

References Configure(), LOG, and pNOTICE.

386  {
387 
388  LOG("Algorithm", pNOTICE)
389  << this->Id().Key() << " is taking ownership of its configuration";
390 
391  // if(fOwnsConfig) {
392  // LOG("Algorithm", pWARN)
393  // << this->Id().Key() << " already owns its configuration!";
394  // return;
395  // }
396 
397  this->Configure( GetConfig() );
398 }
virtual const Registry & GetConfig(void) const
Definition: Algorithm.cxx:246
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
virtual void Configure(const Registry &config)
Definition: Algorithm.cxx:62
virtual const AlgId & Id(void) const
Get algorithm ID.
Definition: Algorithm.h:98
#define pNOTICE
Definition: Messenger.h:61
string Key(void) const
Definition: AlgId.h:46
void Algorithm::AdoptSubstructure ( void  )

Take ownership of the algorithms subtructure (sub-algorithms,...) by copying them from the AlgFactory pool to the local pool Also bring all the configuration variables to the top level config Registry. This can be used to group together a series of algorithms & their configurations and extract (a clone of) this group from the shared pools. Having a series of algorithms/configurations behaving as a monolithic block, with a single point of configuration (the top level) is to be used when bits & pieces of GENIE are used in isolation for data fitting or reweighting

Definition at line 400 of file Algorithm.cxx.

References genie::AlgFactory::AdoptAlgorithm(), AdoptSubstructure(), genie::AlgFactory::Instance(), genie::kRgAlg, LOG, pDEBUG, pNOTICE, and genie::RegistryItemI::TypeInfo().

Referenced by AdoptSubstructure(), main(), and testReconfigInOwnedModules().

401 {
402 // Take ownership of the algorithms subtructure (sub-algorithms,..) by copying
403 // them from the AlgFactory pool to the local pool. Also bring all the
404 // configuration variables to the top level. See the header for more details.
405 // A secial naming convention is required for configuration parameter keys
406 // for parameters belonging to sub-algorithms (or sub-algorithms of these
407 // sub-algorithms and so on...).
408 // The convention is: "sub-alg-key/sub-sub-alg-key/.../original name"
409 // This is a recursive method: The AdoptSubtructure()of all sub-algorithms is
410 // invoked.
411 //
412  LOG("Algorithm", pNOTICE)
413  << "Algorithm: " << this->Id().Key() << " is adopting its substructure";
414 
415 // Registry deep_config;
416 // deep_config.UnLock();
417 // deep_config.SetName(this->Id().Key());
418 
419  // deep_config.SetName(this->Id().Config() + ";D");
420  // fID.SetConfig(this->Id().Config() + ";D");
421 
422  if(fOwnsSubstruc) this->DeleteSubstructure();
423 
424  fOwnedSubAlgMp = new AlgMap;
425  fOwnsSubstruc = true;
426 
427  AlgFactory * algf = AlgFactory::Instance();
428 
429  const RgIMap & rgmap = GetConfig().GetItemMap();
430 
431  RgIMapConstIter iter = rgmap.begin();
432  for( ; iter != rgmap.end(); ++iter) {
433 
434  RgKey reg_key = iter->first;
435  RegistryItemI * ri = iter->second;
436 
437  if(ri->TypeInfo() == kRgAlg) {
438  LOG("Algorithm", pDEBUG)
439  << "Found sub-algorithm pointed to by " << reg_key;
440  RgAlg reg_alg = fConfig->GetAlg(reg_key);
441  AlgId id(reg_alg);
442 
443  LOG("Algorithm", pDEBUG) << "Adopting sub-algorithm = " << id.Key();
444  Algorithm * subalg = algf->AdoptAlgorithm(id.Name(),id.Config());
445  subalg->AdoptSubstructure();
446 
447  LOG("Algorithm", pDEBUG) << "Adding sub-algorithm to local pool";
448  AlgMapPair key_alg_pair(reg_key, subalg);
449  fOwnedSubAlgMp->insert(key_alg_pair);
450 
451  }
452 
453  }
454 
455 
456  if ( fConfig ) {
457  delete fConfig ;
458  fConfig = 0 ;
459  }
460 
461 }
void DeleteSubstructure(void)
Definition: Algorithm.cxx:488
AlgMap * fOwnedSubAlgMp
local pool for owned sub-algs (taken out of the factory pool)
Definition: Algorithm.h:176
bool fOwnsSubstruc
true if it owns its substructure (sub-algs,...)
Definition: Algorithm.h:164
Algorithm abstract base class.
Definition: Algorithm.h:54
map< string, Algorithm * > AlgMap
Definition: Algorithm.h:49
Registry item pABC.
Definition: RegistryItemI.h:29
virtual const Registry & GetConfig(void) const
Definition: Algorithm.cxx:246
map< RgKey, RegistryItemI * >::const_iterator RgIMapConstIter
Definition: Registry.h:49
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
const RgIMap & GetItemMap(void) const
Definition: Registry.h:161
void AdoptSubstructure(void)
Definition: Algorithm.cxx:400
pair< string, Algorithm * > AlgMapPair
Definition: Algorithm.h:52
Algorithm * AdoptAlgorithm(const AlgId &algid) const
Definition: AlgFactory.cxx:116
Algorithm ID (algorithm name + configuration set name)
Definition: AlgId.h:34
virtual const AlgId & Id(void) const
Get algorithm ID.
Definition: Algorithm.h:98
static AlgFactory * Instance()
Definition: AlgFactory.cxx:64
string RgKey
Registry * fConfig
Summary configuration derived from fConvVect, not necessarily allocated.
Definition: Algorithm.h:217
virtual RgType_t TypeInfo(void) const =0
#define pNOTICE
Definition: Messenger.h:61
The GENIE Algorithm Factory.
Definition: AlgFactory.h:39
string Key(void) const
Definition: AlgId.h:46
RgAlg GetAlg(RgKey key) const
Definition: Registry.cxx:488
#define pDEBUG
Definition: Messenger.h:63
map< RgKey, RegistryItemI * > RgIMap
Definition: Registry.h:45
virtual bool genie::Algorithm::AllowReconfig ( void  ) const
inlinevirtual

Allow reconfigration after initializaton? Algorithms may opt-out, if reconfiguration is not necessary, to improve event reweighting speed.

Definition at line 106 of file Algorithm.h.

References fAllowReconfig.

Referenced by genie::AlgFactory::ForceReconfiguration().

106 { return fAllowReconfig; }
string Algorithm::BuildParamMatColSizeKey ( const std::string &  comm_name)
static

Definition at line 545 of file Algorithm.cxx.

Referenced by genie::AlgConfigPool::AddParameterMatrix(), and GetParamMatKeys().

545  {
546 
547  return "Ncol" + comm_name + 's' ;
548 
549 }
string Algorithm::BuildParamMatKey ( const std::string &  comm_name,
unsigned int  i,
unsigned int  j 
)
static

Definition at line 527 of file Algorithm.cxx.

Referenced by genie::AlgConfigPool::AddParameterMatrix(), and GetParamMatKeys().

527  {
528 
529  std::stringstream name;
530  name << comm_name << '-' << i << "-" << j ;
531  return name.str() ;
532 
533 }
const char * name
string Algorithm::BuildParamMatRowSizeKey ( const std::string &  comm_name)
static

Definition at line 537 of file Algorithm.cxx.

Referenced by genie::AlgConfigPool::AddParameterMatrix(), and GetParamMatKeys().

537  {
538 
539  return "Nrow" + comm_name + 's' ;
540 
541 }
string Algorithm::BuildParamVectKey ( const std::string &  comm_name,
unsigned int  i 
)
static

Definition at line 510 of file Algorithm.cxx.

Referenced by genie::AlgConfigPool::AddParameterVector(), and GetParamVectKeys().

510  {
511 
512  std::stringstream name;
513  name << comm_name << '-' << i ;
514  return name.str() ;
515 
516 }
const char * name
string Algorithm::BuildParamVectSizeKey ( const std::string &  comm_name)
static

Definition at line 520 of file Algorithm.cxx.

Referenced by genie::AlgConfigPool::AddParameterVector(), and GetParamVectKeys().

520  {
521 
522  return 'N' + comm_name + 's' ;
523 
524 }
AlgCmp_t Algorithm::Compare ( const Algorithm alg) const
virtual

Compare with input algorithm.

Definition at line 286 of file Algorithm.cxx.

References genie::AlgId::Config(), Id(), genie::kAlgCmpDiffAlg, genie::kAlgCmpDiffConfig, genie::kAlgCmpIdentical, genie::kAlgCmpUnknown, and genie::AlgId::Name().

287 {
288 // Compares itself with the input algorithm
289 
290  string alg1 = this->Id().Name();
291  string config1 = this->Id().Config();
292  string alg2 = algo->Id().Name();
293  string config2 = algo->Id().Config();
294 
295  if(alg1 == alg2)
296  {
297  if(config1 == config2) return kAlgCmpIdentical;
298  else return kAlgCmpDiffConfig;
299  }
300  else return kAlgCmpDiffAlg;
301 
302  return kAlgCmpUnknown;
303 }
string Name(void) const
Definition: AlgId.h:44
virtual const AlgId & Id(void) const
Get algorithm ID.
Definition: Algorithm.h:98
string Config(void) const
Definition: AlgId.h:45
void Algorithm::Configure ( const Registry config)
virtual

Configure the algorithm with an external registry The registry is merged with the top level registry if it is owned, Otherwise a copy of it is added with the highest priority

Reimplemented in genie::MKSPPPXSec2020, genie::hnl::FluxCreator, genie::NewQELXSec, genie::SmithMonizUtils, genie::AGKYLowW2019, genie::Intranuke, genie::Intranuke2018, genie::ReinSehgalSPPPXSec, genie::BSKLNBaseRESPXSec2014, genie::BBA07ELFormFactorsModel, genie::hnl::BRCalculator, genie::SmithMonizQELCCPXSec, genie::LocalFGM, genie::hnl::VertexGenerator, genie::KovalenkoQELCharmPXSec, genie::NuclearModelMap, genie::NievesQELCCPXSec, genie::SPPEventGenerator, genie::GRV98LO, genie::QELEventGeneratorSM, genie::ReinSehgalRESXSecFast, genie::AGCharm2019, genie::LHAPDF6, genie::FGMBodekRitchie, genie::ReinSehgalRESPXSec, genie::ReinSehgalSPPXSec, genie::SmithMonizQELCCXSec, genie::BostedChristyEMPXSec, genie::EventGenerator, genie::MartiniEricsonChanfrayMarteauMECPXSec2016, genie::NievesSimoVacasMECPXSec2016, genie::SuSAv2MECPXSec, genie::SpectralFunc1d, genie::SuSAv2QELPXSec, genie::evtlib::EventLibraryInterface, genie::DMElectronPXSec, genie::QPMDMDISStrucFuncBase, genie::ReinSehgalCOHPiPXSec, genie::EffectiveSF, genie::PaisQELLambdaPXSec, genie::hnl::Decayer, genie::QPMDISStrucFuncBase, genie::BardinIMDRadCorPXSec, genie::NuElectronPXSec, genie::LHAPDF5, genie::ReinSehgalRESXSec, genie::QPMDMDISPXSec, genie::SpectralFunc, genie::LwlynSmithQELCCPXSec, genie::HybridXSecAlgorithm, genie::BertuzzoDNuCOHPXSec, genie::LeptoHadronization, genie::LwlynSmithFF, genie::AhrensDMELPXSec, genie::DMElectronXSec, genie::BergerSehgalCOHPiPXSec2015, genie::OutgoingDarkGenerator, genie::BYPDF, genie::Pythia8Hadro2019, genie::HEDISInteractionListGenerator, genie::SpectralFunction2p2h, genie::BBA03ELFormFactorsModel, genie::BBA05ELFormFactorsModel, genie::P33PaschosLalakulichPXSec, genie::SPPXSec, genie::DMDISInteractionListGenerator, genie::DFRXSec, genie::Pythia6Hadro2019, genie::KLVOxygenIBDPXSec, genie::MECGenerator, genie::PauliBlocker, genie::IMDAnnihilationPXSec, genie::NuElectronXSec, genie::MArunAxialFormFactorModel, genie::DMDISKinematicsGenerator, genie::AivazisCharmPXSecLO, genie::AlvarezRusoCOHPiPXSec, genie::BergerSehgalFMCOHPiPXSec2015, genie::DarkSectorDecayer, genie::QPMDISPXSec, genie::StrumiaVissaniIBDPXSec, genie::NNBarOscPrimaryVtxGenerator, genie::FermiMover, genie::RESHadronicSystemGenerator, genie::DMELEventGenerator, genie::NormXSec, genie::PrimaryLeptonGenerator, genie::EngelFormFactor, genie::KNOTunedQPMDISPXSec, genie::ReinDFRPXSec, genie::AhrensNCELPXSec, genie::MKFFEM, genie::RosenbluthPXSec, genie::TransverseEnhancementFFModel, genie::ZExpAxialFormFactorModel, genie::hnl::ChannelCalculatorI, genie::NormGenerator, genie::UnstableParticleDecayer, genie::DISInteractionListGenerator, genie::NucBindEnergyAggregator, genie::HEDISKinematicsGenerator, genie::GLRESGenerator, genie::GLRESPXSec, genie::HENuElPXSec, genie::PhotonCOHPXSec, genie::PhotonRESPXSec, genie::MECXSec, genie::AlamSimoAtharVacasSKPXSec2014, genie::AlamSimoAtharVacasSKXSec, genie::SlowRsclCharmDISPXSecLO, genie::PattonCEvNSPXSec, genie::DISKinematicsGenerator, genie::PetersonFragm, genie::HEDISPXSec, genie::EmpiricalMECPXSec2015, genie::QELEventGeneratorSuSA, genie::GalsterELFormFactorsModel, genie::H3AMNuGammaPXSec, genie::DMELKinematicsGenerator, genie::DMELXSec, genie::COHDNuEventGenerator, genie::CollinsSpillerFragm, genie::TabulatedHadronTensorModelI, genie::HELeptonXSec, genie::IBDKinematicsGenerator, genie::SRCNuclearRecoil, genie::RSPPResonanceSelector, genie::DMELInteractionListGenerator, genie::DMDISXSec, genie::COHKinematicsGenerator, genie::COHDNuInteractionListGenerator, genie::AGKY2019, genie::HEDISGenerator, genie::PhotonCOHGenerator, genie::PhotonRESGenerator, genie::NucleonDecayPrimaryVtxGenerator, genie::QELEventGenerator, genie::CEvNSEventGenerator, genie::NormInteractionListGenerator, genie::XSecLinearCombinations, genie::COHDNuXSec, genie::Decayer, genie::HEDISXSec, genie::HENuElGenerator, genie::IBDInteractionListGenerator, genie::DipoleAxialFormFactorModel, genie::RESKinematicsGenerator, genie::RSPPInteractionListGenerator, genie::PhysInteractionSelector, genie::DMEInteractionListGenerator, genie::DMEKinematicsGenerator, genie::COHInteractionListGenerator, genie::HadronTransporter, genie::IBDXSecMap, genie::QELKinematicsGenerator, genie::DipoleELFormFactorsModel, genie::QELXSec, genie::RESInteractionListGenerator, genie::RSHelicityAmplModelNCn, genie::RSHelicityAmplModelNCp, genie::SKInteractionListGenerator, genie::SKKinematicsGenerator, genie::QvalueShifter, genie::VertexGenerator, genie::DFRInteractionListGenerator, genie::DFRKinematicsGenerator, genie::INukeDeltaPropg, genie::MECInteractionListGenerator, genie::NuEInteractionListGenerator, genie::NuEKinematicsGenerator, genie::QELInteractionListGenerator, genie::CEvNSXSec, genie::COHXSec, genie::DISHadronicSystemGenerator, genie::BYStrucFunc, genie::DISXSec, genie::CascadeReweight, genie::HELeptonInteractionListGenerator, genie::HELeptonKinematicsGenerator, genie::NucDeExcitationSim, genie::RESXSec, genie::COHXSecAR, genie::IMDXSec, genie::DMBYStrucFunc, genie::XSecScaleI, genie::evtlib::EvtLibPXSec, and genie::evtlib::EvtLibInteractionListGenerator.

Definition at line 62 of file Algorithm.cxx.

References Configure(), Id(), genie::AlgId::Key(), LOG, genie::Registry::Name(), genie::Registry::NEntries(), pERROR, and pNOTICE.

Referenced by genie::evtlib::EvtLibInteractionListGenerator::Configure(), genie::evtlib::EvtLibPXSec::Configure(), genie::XSecScaleI::Configure(), genie::IMDXSec::Configure(), genie::COHXSecAR::Configure(), genie::HELeptonInteractionListGenerator::Configure(), genie::HELeptonKinematicsGenerator::Configure(), genie::RESXSec::Configure(), genie::DISHadronicSystemGenerator::Configure(), genie::DISXSec::Configure(), genie::NucDeExcitationSim::Configure(), genie::CascadeReweight::Configure(), genie::CEvNSXSec::Configure(), genie::COHXSec::Configure(), genie::QELInteractionListGenerator::Configure(), genie::QvalueShifter::Configure(), genie::DFRKinematicsGenerator::Configure(), genie::DFRInteractionListGenerator::Configure(), genie::INukeDeltaPropg::Configure(), genie::VertexGenerator::Configure(), genie::MECInteractionListGenerator::Configure(), genie::NuEInteractionListGenerator::Configure(), genie::NuEKinematicsGenerator::Configure(), genie::HadronTransporter::Configure(), genie::PhysInteractionSelector::Configure(), genie::QELXSec::Configure(), genie::QELKinematicsGenerator::Configure(), genie::DipoleELFormFactorsModel::Configure(), genie::RESInteractionListGenerator::Configure(), genie::RSHelicityAmplModelNCn::Configure(), genie::RSHelicityAmplModelNCp::Configure(), genie::SKInteractionListGenerator::Configure(), genie::SKKinematicsGenerator::Configure(), genie::DMEInteractionListGenerator::Configure(), genie::IBDXSecMap::Configure(), genie::DMEKinematicsGenerator::Configure(), genie::COHInteractionListGenerator::Configure(), genie::Decayer::Configure(), genie::CEvNSEventGenerator::Configure(), genie::HEDISXSec::Configure(), genie::DipoleAxialFormFactorModel::Configure(), genie::XSecLinearCombinations::Configure(), genie::RESKinematicsGenerator::Configure(), genie::HENuElGenerator::Configure(), genie::RSPPInteractionListGenerator::Configure(), genie::IBDInteractionListGenerator::Configure(), genie::COHDNuXSec::Configure(), genie::NormInteractionListGenerator::Configure(), genie::PhotonCOHGenerator::Configure(), genie::PhotonRESGenerator::Configure(), genie::QELEventGenerator::Configure(), genie::HEDISGenerator::Configure(), genie::AGKY2019::Configure(), genie::DMDISXSec::Configure(), genie::COHDNuInteractionListGenerator::Configure(), genie::DMELInteractionListGenerator::Configure(), genie::COHKinematicsGenerator::Configure(), genie::NucleonDecayPrimaryVtxGenerator::Configure(), genie::H3AMNuGammaPXSec::Configure(), genie::CollinsSpillerFragm::Configure(), genie::HELeptonXSec::Configure(), genie::RSPPResonanceSelector::Configure(), genie::IBDKinematicsGenerator::Configure(), genie::SRCNuclearRecoil::Configure(), genie::TabulatedHadronTensorModelI::Configure(), genie::DMELKinematicsGenerator::Configure(), genie::COHDNuEventGenerator::Configure(), genie::DMELXSec::Configure(), genie::PattonCEvNSPXSec::Configure(), genie::PetersonFragm::Configure(), genie::GalsterELFormFactorsModel::Configure(), genie::QELEventGeneratorSuSA::Configure(), genie::HEDISPXSec::Configure(), genie::SlowRsclCharmDISPXSecLO::Configure(), genie::DISKinematicsGenerator::Configure(), genie::EmpiricalMECPXSec2015::Configure(), genie::GLRESGenerator::Configure(), genie::GLRESPXSec::Configure(), genie::PhotonRESPXSec::Configure(), genie::HEDISKinematicsGenerator::Configure(), genie::HENuElPXSec::Configure(), genie::DISInteractionListGenerator::Configure(), genie::UnstableParticleDecayer::Configure(), genie::AlamSimoAtharVacasSKXSec::Configure(), genie::AlamSimoAtharVacasSKPXSec2014::Configure(), genie::MECXSec::Configure(), genie::PhotonCOHPXSec::Configure(), genie::NormGenerator::Configure(), genie::NucBindEnergyAggregator::Configure(), genie::PrimaryLeptonGenerator::Configure(), genie::AhrensNCELPXSec::Configure(), genie::ReinDFRPXSec::Configure(), genie::TransverseEnhancementFFModel::Configure(), genie::KNOTunedQPMDISPXSec::Configure(), genie::DMELEventGenerator::Configure(), genie::RosenbluthPXSec::Configure(), genie::MKFFEM::Configure(), genie::EngelFormFactor::Configure(), genie::NormXSec::Configure(), genie::ZExpAxialFormFactorModel::Configure(), genie::BergerSehgalFMCOHPiPXSec2015::Configure(), genie::QPMDISPXSec::Configure(), genie::AivazisCharmPXSecLO::Configure(), genie::RESHadronicSystemGenerator::Configure(), genie::DarkSectorDecayer::Configure(), genie::NNBarOscPrimaryVtxGenerator::Configure(), genie::DMDISKinematicsGenerator::Configure(), genie::AlvarezRusoCOHPiPXSec::Configure(), genie::StrumiaVissaniIBDPXSec::Configure(), genie::FermiMover::Configure(), genie::PauliBlocker::Configure(), genie::Pythia6Hadro2019::Configure(), genie::DFRXSec::Configure(), genie::IMDAnnihilationPXSec::Configure(), genie::DMDISInteractionListGenerator::Configure(), genie::KLVOxygenIBDPXSec::Configure(), genie::MArunAxialFormFactorModel::Configure(), genie::MECGenerator::Configure(), genie::NuElectronXSec::Configure(), genie::BergerSehgalCOHPiPXSec2015::Configure(), genie::Pythia8Hadro2019::Configure(), genie::HEDISInteractionListGenerator::Configure(), genie::SpectralFunction2p2h::Configure(), genie::BYPDF::Configure(), genie::AhrensDMELPXSec::Configure(), genie::DMElectronXSec::Configure(), genie::BBA03ELFormFactorsModel::Configure(), genie::P33PaschosLalakulichPXSec::Configure(), genie::BBA05ELFormFactorsModel::Configure(), genie::SPPXSec::Configure(), genie::OutgoingDarkGenerator::Configure(), genie::BertuzzoDNuCOHPXSec::Configure(), genie::HybridXSecAlgorithm::Configure(), genie::LeptoHadronization::Configure(), genie::LwlynSmithFF::Configure(), genie::QPMDMDISPXSec::Configure(), genie::SpectralFunc::Configure(), genie::LwlynSmithQELCCPXSec::Configure(), genie::ReinSehgalRESXSec::Configure(), genie::LHAPDF5::Configure(), genie::hnl::Decayer::Configure(), genie::QPMDISStrucFuncBase::Configure(), genie::NuElectronPXSec::Configure(), genie::BardinIMDRadCorPXSec::Configure(), genie::PaisQELLambdaPXSec::Configure(), genie::ReinSehgalCOHPiPXSec::Configure(), genie::DMElectronPXSec::Configure(), genie::EffectiveSF::Configure(), genie::QPMDMDISStrucFuncBase::Configure(), genie::evtlib::EventLibraryInterface::Configure(), genie::SpectralFunc1d::Configure(), genie::NievesSimoVacasMECPXSec2016::Configure(), genie::SuSAv2MECPXSec::Configure(), genie::EventGenerator::Configure(), genie::SuSAv2QELPXSec::Configure(), genie::MartiniEricsonChanfrayMarteauMECPXSec2016::Configure(), genie::BostedChristyEMPXSec::Configure(), genie::SmithMonizQELCCXSec::Configure(), genie::ReinSehgalRESPXSec::Configure(), genie::ReinSehgalSPPXSec::Configure(), genie::FGMBodekRitchie::Configure(), genie::AGCharm2019::Configure(), genie::LHAPDF6::Configure(), genie::ReinSehgalRESXSecFast::Configure(), genie::QELEventGeneratorSM::Configure(), genie::GRV98LO::Configure(), genie::SPPEventGenerator::Configure(), genie::NuclearModelMap::Configure(), genie::HAIntranuke::Configure(), genie::NievesQELCCPXSec::Configure(), genie::KovalenkoQELCharmPXSec::Configure(), genie::hnl::VertexGenerator::Configure(), genie::LocalFGM::Configure(), genie::hnl::BRCalculator::Configure(), genie::SmithMonizQELCCPXSec::Configure(), genie::BBA07ELFormFactorsModel::Configure(), genie::BSKLNBaseRESPXSec2014::Configure(), genie::ReinSehgalSPPPXSec::Configure(), genie::Intranuke::Configure(), genie::Intranuke2018::Configure(), genie::AGKYLowW2019::Configure(), genie::SmithMonizUtils::Configure(), genie::NewQELXSec::Configure(), genie::hnl::FluxCreator::Configure(), genie::MKSPPPXSec2020::Configure(), genie::AlgFactory::ForceReconfiguration(), genie::AlgFactory::InstantiateAlgorithm(), and testReconfigInOwnedModules().

63 {
64 // Configure the Algorithm using the input configuration Registry
65 
66  LOG("Algorithm", pNOTICE) << "Input configuration: " << config;
67 
68  if ( config.NEntries() <= 0 ) {
69 
70  LOG("Algorithm", pNOTICE) "Registry " << config.Name() << " is empty. Not added to " << fID.Name();
71  return;
72  }
73 
74  Registry* rp = ExtractLocalConfig( config ) ;
75  if ( rp ) {
76 
77  MergeTopRegistry( *rp ) ;
78  LOG("Algorithm", pNOTICE) << fID.Name() << " merged with external configuration: " << *rp;
79 
80  // The memory handled by this pointer has been copied and needs to be cleared
81  delete rp ;
82  }
83 
84  if(!fOwnsSubstruc) return; // doesn't own substructure
85  if(fOwnedSubAlgMp->size()==0) return; // no sub-algorithms
86 
87  LOG("Algorithm", pNOTICE) << "Configuring algorithms stored at local pool";
88 
89  // loop over local pool algorithms
90 
91  for( AlgMapIter alg_iter = fOwnedSubAlgMp->begin();
92  alg_iter != fOwnedSubAlgMp->end(); ++alg_iter) {
93 
94  string alg_key = alg_iter->first;
95  Algorithm * alg = alg_iter->second;
96 
97  if(!alg) {
98  LOG("Algorithm", pERROR)
99  << "Key: " << alg_key << " points to a null algorithm at local pool";
100  continue;
101  }
102 
103  LOG("Algorithm", pNOTICE) << "Configuring sub-alg: " << alg->Id().Key();
104 
105  rp = ExtractLowerConfig( config, alg_key ) ;
106  if ( rp ) {
107 
108  alg -> Configure( *rp ) ;
109 
110  delete rp ;
111 
112  }
113 
114  }
115 
116 }
#define pERROR
Definition: Messenger.h:59
Registry * ExtractLowerConfig(const Registry &in, const string &alg_key) const
Split an incoming configuration Registry into a block valid for the sub-algo identified by alg_key...
Definition: Algorithm.cxx:650
AlgMap * fOwnedSubAlgMp
local pool for owned sub-algs (taken out of the factory pool)
Definition: Algorithm.h:176
bool fOwnsSubstruc
true if it owns its substructure (sub-algs,...)
Definition: Algorithm.h:164
int MergeTopRegistry(const Registry &r)
Definition: Algorithm.cxx:719
Algorithm abstract base class.
Definition: Algorithm.h:54
AlgId fID
algorithm name and configuration set
Definition: Algorithm.h:165
string Name(void) const
get the registry name
Definition: Registry.cxx:597
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
string Name(void) const
Definition: AlgId.h:44
virtual void Configure(const Registry &config)
Definition: Algorithm.cxx:62
virtual const AlgId & Id(void) const
Get algorithm ID.
Definition: Algorithm.h:98
A registry. Provides the container for algorithm configuration parameters.
Definition: Registry.h:65
Registry * ExtractLocalConfig(const Registry &in) const
Definition: Algorithm.cxx:619
#define pNOTICE
Definition: Messenger.h:61
map< string, Algorithm * >::iterator AlgMapIter
Definition: Algorithm.h:50
string Key(void) const
Definition: AlgId.h:46
int NEntries(void) const
get number of items
Definition: Registry.cxx:582
void Algorithm::Configure ( string  config)
virtual

Configure the algorithm from the AlgoConfigPool based on param_set string given in input An algorithm contains a vector of registries coming from different xml configuration files, which are loaded according a very precise prioriy This methods will load a number registries in order of priority: 1) "Tunable" parameter set from CommonParametes. This is loaded with the highest prioriry and it is designed to be used for tuning procedure Usage not expected from the user. 2) For every string defined in "CommonParame" the corresponding parameter set will be loaded from CommonParameter.xml 3) parameter set specified by the config string and defined in the xml file of the algorithm 4) if config is not "Default" also the Default parameter set from the same xml file will be loaded Effectively this avoids the repetion of a parameter when it is not changed in the requested configuration

Reimplemented in genie::MKSPPPXSec2020, genie::hnl::FluxCreator, genie::SmithMonizUtils, genie::AGKYLowW2019, genie::Intranuke, genie::Intranuke2018, genie::ReinSehgalSPPPXSec, genie::BSKLNBaseRESPXSec2014, genie::BBA07ELFormFactorsModel, genie::hnl::BRCalculator, genie::SmithMonizQELCCPXSec, genie::LocalFGM, genie::hnl::VertexGenerator, genie::KovalenkoQELCharmPXSec, genie::NuclearModelMap, genie::NievesQELCCPXSec, genie::SPPEventGenerator, genie::HAIntranuke, genie::GRV98LO, genie::QELEventGeneratorSM, genie::ReinSehgalRESXSecFast, genie::AGCharm2019, genie::LHAPDF6, genie::FGMBodekRitchie, genie::ReinSehgalRESPXSec, genie::ReinSehgalSPPXSec, genie::SmithMonizQELCCXSec, genie::BostedChristyEMPXSec, genie::EventGenerator, genie::MartiniEricsonChanfrayMarteauMECPXSec2016, genie::NievesSimoVacasMECPXSec2016, genie::SuSAv2MECPXSec, genie::SpectralFunc1d, genie::SuSAv2QELPXSec, genie::evtlib::EventLibraryInterface, genie::DMElectronPXSec, genie::QPMDMDISStrucFuncBase, genie::ReinSehgalCOHPiPXSec, genie::EffectiveSF, genie::PaisQELLambdaPXSec, genie::hnl::Decayer, genie::QPMDISStrucFuncBase, genie::BardinIMDRadCorPXSec, genie::NuElectronPXSec, genie::LHAPDF5, genie::ReinSehgalRESXSec, genie::QPMDMDISPXSec, genie::SpectralFunc, genie::LwlynSmithQELCCPXSec, genie::HybridXSecAlgorithm, genie::BertuzzoDNuCOHPXSec, genie::LeptoHadronization, genie::LwlynSmithFF, genie::AhrensDMELPXSec, genie::DMElectronXSec, genie::BergerSehgalCOHPiPXSec2015, genie::OutgoingDarkGenerator, genie::BYPDF, genie::Pythia8Hadro2019, genie::HEDISInteractionListGenerator, genie::SpectralFunction2p2h, genie::BBA03ELFormFactorsModel, genie::BBA05ELFormFactorsModel, genie::P33PaschosLalakulichPXSec, genie::SPPXSec, genie::DMDISInteractionListGenerator, genie::Pythia6Hadro2019, genie::KLVOxygenIBDPXSec, genie::MECGenerator, genie::PauliBlocker, genie::IMDAnnihilationPXSec, genie::NuElectronXSec, genie::MArunAxialFormFactorModel, genie::DMDISKinematicsGenerator, genie::AivazisCharmPXSecLO, genie::AlvarezRusoCOHPiPXSec, genie::BergerSehgalFMCOHPiPXSec2015, genie::DarkSectorDecayer, genie::QPMDISPXSec, genie::StrumiaVissaniIBDPXSec, genie::NNBarOscPrimaryVtxGenerator, genie::FermiMover, genie::RESHadronicSystemGenerator, genie::DMELEventGenerator, genie::NormXSec, genie::PrimaryLeptonGenerator, genie::EngelFormFactor, genie::KNOTunedQPMDISPXSec, genie::ReinDFRPXSec, genie::AhrensNCELPXSec, genie::MKFFEM, genie::RosenbluthPXSec, genie::TransverseEnhancementFFModel, genie::ZExpAxialFormFactorModel, genie::hnl::ChannelCalculatorI, genie::NormGenerator, genie::UnstableParticleDecayer, genie::DISInteractionListGenerator, genie::NucBindEnergyAggregator, genie::HEDISKinematicsGenerator, genie::GLRESGenerator, genie::GLRESPXSec, genie::HENuElPXSec, genie::PhotonCOHPXSec, genie::PhotonRESPXSec, genie::MECXSec, genie::AlamSimoAtharVacasSKPXSec2014, genie::AlamSimoAtharVacasSKXSec, genie::SlowRsclCharmDISPXSecLO, genie::PattonCEvNSPXSec, genie::DISKinematicsGenerator, genie::PetersonFragm, genie::HEDISPXSec, genie::EmpiricalMECPXSec2015, genie::QELEventGeneratorSuSA, genie::GalsterELFormFactorsModel, genie::H3AMNuGammaPXSec, genie::DMELKinematicsGenerator, genie::DMELXSec, genie::COHDNuEventGenerator, genie::CollinsSpillerFragm, genie::PhotonCOHGenerator, genie::PhotonRESGenerator, genie::HELeptonXSec, genie::IBDKinematicsGenerator, genie::SRCNuclearRecoil, genie::RSPPResonanceSelector, genie::DMELInteractionListGenerator, genie::DMDISXSec, genie::COHKinematicsGenerator, genie::COHDNuInteractionListGenerator, genie::AGKY2019, genie::HEDISGenerator, genie::NucleonDecayPrimaryVtxGenerator, genie::QELEventGenerator, genie::CEvNSEventGenerator, genie::NormInteractionListGenerator, genie::XSecLinearCombinations, genie::COHDNuXSec, genie::Decayer, genie::HEDISXSec, genie::HENuElGenerator, genie::IBDInteractionListGenerator, genie::DipoleAxialFormFactorModel, genie::RESKinematicsGenerator, genie::RSPPInteractionListGenerator, genie::PhysInteractionSelector, genie::DMEInteractionListGenerator, genie::DMEKinematicsGenerator, genie::COHInteractionListGenerator, genie::HadronTransporter, genie::IBDXSecMap, genie::QELKinematicsGenerator, genie::DipoleELFormFactorsModel, genie::QELXSec, genie::RESInteractionListGenerator, genie::RSHelicityAmplModelNCn, genie::RSHelicityAmplModelNCp, genie::SKInteractionListGenerator, genie::SKKinematicsGenerator, genie::QvalueShifter, genie::VertexGenerator, genie::DFRInteractionListGenerator, genie::DFRKinematicsGenerator, genie::INukeDeltaPropg, genie::MECInteractionListGenerator, genie::NuEInteractionListGenerator, genie::NuEKinematicsGenerator, genie::QELInteractionListGenerator, genie::CEvNSXSec, genie::COHXSec, genie::DISHadronicSystemGenerator, genie::BYStrucFunc, genie::DISXSec, genie::CascadeReweight, genie::HELeptonInteractionListGenerator, genie::HELeptonKinematicsGenerator, genie::RESXSec, genie::COHXSecAR, genie::IMDXSec, genie::DMBYStrucFunc, genie::XSecScaleI, genie::evtlib::EvtLibPXSec, and genie::evtlib::EvtLibInteractionListGenerator.

Definition at line 118 of file Algorithm.cxx.

119 {
120 // Configure the Algorithm looking up at the ConfigPool singleton for a
121 // configuration Registry corresponding to the input named parameter set.
122 
123  fID.SetConfig(config);
124  this->FindConfig();
125 }
AlgId fID
algorithm name and configuration set
Definition: Algorithm.h:165
virtual void FindConfig(void)
Definition: Algorithm.cxx:127
void SetConfig(string config)
Definition: AlgId.cxx:59
void Algorithm::DeleteConfig ( void  )
protected

Definition at line 463 of file Algorithm.cxx.

464 {
465  // there is nothing to delete if the configuration is not owned but is
466  // rather looked up from the configuration pool
467  //
468 
469  for ( unsigned int i = 0 ; i < fConfVect.size() ; ++i ) {
470  if ( fOwnerships[i] ) {
471  delete fConfVect[i] ;
472  }
473  }
474 
475  fConfVect.clear() ;
476  fOwnerships.clear() ;
477 
478  // delete owned configuration registry
479 
480  if(fConfig) {
481  delete fConfig;
482  fConfig=0;
483  }
484 
485 }
vector< Registry * > fConfVect
Definition: Algorithm.h:170
vector< bool > fOwnerships
ownership for every registry in fConfVect
Definition: Algorithm.h:173
Registry * fConfig
Summary configuration derived from fConvVect, not necessarily allocated.
Definition: Algorithm.h:217
void Algorithm::DeleteSubstructure ( void  )
protected

Definition at line 488 of file Algorithm.cxx.

489 {
490  // there is nothing to delete if the sub-algorithms are not owned but rather
491  // taken from the AlgFactory's pool
492  //
493  if(!fOwnsSubstruc) return;
494 
495  // delete local algorithm pool
496  //
497  AlgMapIter iter = fOwnedSubAlgMp->begin();
498  for( ; iter != fOwnedSubAlgMp->end(); ++iter) {
499  Algorithm * alg = iter->second;
500  if(alg) {
501  delete alg;
502  alg=0;
503  }
504  }
505  delete fOwnedSubAlgMp;
506  fOwnedSubAlgMp = 0;
507 }
AlgMap * fOwnedSubAlgMp
local pool for owned sub-algs (taken out of the factory pool)
Definition: Algorithm.h:176
bool fOwnsSubstruc
true if it owns its substructure (sub-algs,...)
Definition: Algorithm.h:164
Algorithm abstract base class.
Definition: Algorithm.h:54
map< string, Algorithm * >::iterator AlgMapIter
Definition: Algorithm.h:50
Registry * Algorithm::ExtractLocalConfig ( const Registry in) const
protected

Split an incoming configuration Registry into a block valid for this algorithm Ownership of the returned registry belongs to the algo

Definition at line 619 of file Algorithm.cxx.

References genie::RegistryItemI::Clone(), genie::Registry::GetItemMap(), and genie::Registry::Name().

619  {
620 
621  const RgIMap & rgmap = in.GetItemMap();
622  Registry * out = new Registry( in.Name(), false );
623 
624  for( RgIMapConstIter reg_iter = rgmap.begin();
625  reg_iter != rgmap.end(); ++reg_iter ) {
626 
627  RgKey reg_key = reg_iter->first;
628  if( reg_key.find( '/' ) != string::npos) continue;
629 
630  // at this point
631  // this key is referred to the local algorithm
632  // it has to be copied in out;
633 
634  RegistryItemI * ri = reg_iter->second;
635  RgIMapPair key_item_pair( reg_key, ri->Clone() );
636  out -> Set(key_item_pair);
637 
638  }
639 
640  if ( out -> NEntries() <= 0 ) {
641  delete out ;
642  out = 0 ;
643  }
644 
645  return out ;
646 }
virtual RegistryItemI * Clone(void) const =0
Registry item pABC.
Definition: RegistryItemI.h:29
string Name(void) const
get the registry name
Definition: Registry.cxx:597
map< RgKey, RegistryItemI * >::const_iterator RgIMapConstIter
Definition: Registry.h:49
const RgIMap & GetItemMap(void) const
Definition: Registry.h:161
pair< RgKey, RegistryItemI * > RgIMapPair
Definition: Registry.h:46
string RgKey
A registry. Provides the container for algorithm configuration parameters.
Definition: Registry.h:65
map< RgKey, RegistryItemI * > RgIMap
Definition: Registry.h:45
Registry * Algorithm::ExtractLowerConfig ( const Registry in,
const string &  alg_key 
) const
protected

Split an incoming configuration Registry into a block valid for the sub-algo identified by alg_key.

Definition at line 650 of file Algorithm.cxx.

References genie::RegistryItemI::Clone(), genie::Registry::GetItemMap(), and genie::Registry::Name().

650  {
651 
652  const RgIMap & rgmap = in.GetItemMap();
653  Registry * out = new Registry( in.Name(), false );
654 
655  for( RgIMapConstIter reg_iter = rgmap.begin();
656  reg_iter != rgmap.end(); ++reg_iter ) {
657 
658  RgKey reg_key = reg_iter->first;
659  if( reg_key.find(alg_key+"/") == string::npos) continue;
660 
661  // at this point
662  // this key is referred to the sub-algorithm
663  // indicated by alg_key: it has to be copied in out;
664 
665  int new_key_start = reg_key.find_first_of('/')+1;
666  RgKey new_reg_key = reg_key.substr( new_key_start, reg_key.length() );
667 
668  RegistryItemI * ri = reg_iter->second;
669  RgIMapPair key_item_pair(new_reg_key, ri->Clone());
670  out -> Set(key_item_pair);
671 
672  }
673 
674  if ( out -> NEntries() <= 0 ) {
675  delete out ;
676  out = 0 ;
677  }
678 
679  return out ;
680 
681 }
virtual RegistryItemI * Clone(void) const =0
Registry item pABC.
Definition: RegistryItemI.h:29
string Name(void) const
get the registry name
Definition: Registry.cxx:597
map< RgKey, RegistryItemI * >::const_iterator RgIMapConstIter
Definition: Registry.h:49
const RgIMap & GetItemMap(void) const
Definition: Registry.h:161
pair< RgKey, RegistryItemI * > RgIMapPair
Definition: Registry.h:46
string RgKey
A registry. Provides the container for algorithm configuration parameters.
Definition: Registry.h:65
map< RgKey, RegistryItemI * > RgIMap
Definition: Registry.h:45
void Algorithm::FindConfig ( void  )
virtual

Lookup configuration from the config pool Similar logic from void Configure(string)

Definition at line 127 of file Algorithm.cxx.

References genie::AlgConfigPool::FindRegistry(), genie::Registry::GetItemMap(), genie::Registry::GetString(), genie::AlgConfigPool::Instance(), genie::Registry::ItemIsLocal(), LOG, pDEBUG, pFATAL, pWARN, genie::units::second, and genie::utils::str::Split().

128 {
129 // Finds its configration Registry from the ConfigPool and gets a pointer to
130 // it. If the Registry comes from the ConfigPool then the Algorithm does not
131 // own its configuration (the ConfigPool singleton keeps the ownership and the
132 // responsibility to -eventually- delete all the Registries it instantiates
133 // by parsing the XML config files).
134 
135  DeleteConfig() ;
136 
138 
139  Registry * config = 0 ;
140 
141  // load the Default config if config is not the default
142  if ( fID.Config() != "Default" ) {
143  config = pool -> FindRegistry( fID.Name(), "Default" );
144  if ( config ) {
145  if ( config -> NEntries() > 0 ) {
146  AddTopRegistry( config, false ) ;
147  LOG("Algorithm", pDEBUG) << "\n" << *config;
148  }
149  }
150  }
151 
152  // Load the right config
153  config = pool->FindRegistry(this);
154 
155  if(!config)
156  // notify & keep whatever config Registry was used before.
157  LOG("Algorithm", pWARN)
158  << "No Configuration available for "
159  << this->Id().Key() << " at the ConfigPool";
160  else {
161  if ( config -> NEntries() > 0 ) {
162  AddTopRegistry( config, false ) ;
163  LOG("Algorithm", pDEBUG) << "\n" << config;
164  }
165  }
166 
167  const string common_key_root = "Common" ;
168  std::map<string, string> common_lists;
169 
170  // Load Common Parameters if key that start with "Common" is found
171  for ( unsigned int i = 0 ; i < fConfVect.size() ; ++i ) {
172  const Registry & temp = * fConfVect[i] ;
173  for ( RgIMapConstIter it = temp.GetItemMap().begin() ; it != temp.GetItemMap().end() ; ++it ) {
174 
175  // check if it is a "Common" entry
176  if ( it -> first.find( common_key_root ) == 0 ) {
177  // retrieve the type of the common entry
178  std::string type = it -> first.substr(common_key_root.size() ) ;
179 
180  if ( temp.ItemIsLocal( it -> first ) ) {
181 
182  string temp_list = temp.GetString( it -> first ) ;
183  if ( temp_list.length() > 0 ) {
184  common_lists[type] = temp_list ;
185  }
186  }
187  }
188 
189  }
190 
191  } // loop over the local registries
192 
193 
194  for ( std::map<string, string>::const_iterator it = common_lists.begin() ;
195  it != common_lists.end() ; ++it ) {
196 
197  vector<string> list = str::Split( it -> second , "," ) ;
198 
199  for ( unsigned int i = 0; i < list.size(); ++i ) {
200 
201  config = pool -> CommonList( it -> first, list[i] ) ;
202 
203  if ( ! config ) {
204  LOG("Algorithm", pFATAL)
205  << "No Common parameters available for " << it -> first << " list "
206  << list[i] << " at the ConfigPool";
207 
208  exit( 78 ) ;
209  }
210  else {
211  AddLowRegistry( config, false ) ;
212  LOG("Algorithm", pDEBUG) << "Loading "
213  << it -> first << " registry "
214  << list[i] << " \n" << config;
215  }
216 
217  }
218 
219  }
220 
221 
222  // Load Tunable from CommonParameters
223  // only if the option is specified in RunOpt
224  config = pool -> CommonList( "Param", "Tunable" ) ;
225  if ( config ) {
226  if ( config -> NEntries() > 0 ) {
227  AddTopRegistry( config, false ) ;
228  LOG("Algorithm", pDEBUG) << "Loading Tunable registry \n" << config;
229  }
230  }
231  else {
232  // notify & keep whatever config Registry was used before.
233  LOG("Algorithm", pWARN)
234  << "No Tunable parameter set available at the ConfigPool";
235  }
236 
237  if ( fConfig ) {
238  delete fConfig ;
239  fConfig = 0 ;
240  }
241 
242 }
A singleton class holding all configuration registries built while parsing all loaded XML configurati...
Definition: AlgConfigPool.h:40
#define pFATAL
Definition: Messenger.h:56
AlgId fID
algorithm name and configuration set
Definition: Algorithm.h:165
static constexpr double second
Definition: Units.h:37
map< RgKey, RegistryItemI * >::const_iterator RgIMapConstIter
Definition: Registry.h:49
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
const RgIMap & GetItemMap(void) const
Definition: Registry.h:161
string Name(void) const
Definition: AlgId.h:44
bool ItemIsLocal(RgKey key) const
local or global?
Definition: Registry.cxx:178
int AddTopRegistry(Registry *rp, bool owns=true)
add registry with top priority, also update ownership
Definition: Algorithm.cxx:686
#define pWARN
Definition: Messenger.h:60
void DeleteConfig(void)
Definition: Algorithm.cxx:463
virtual const AlgId & Id(void) const
Get algorithm ID.
Definition: Algorithm.h:98
RgStr GetString(RgKey key) const
Definition: Registry.cxx:481
vector< Registry * > fConfVect
Definition: Algorithm.h:170
vector< string > Split(string input, string delim)
Definition: StringUtils.cxx:36
A registry. Provides the container for algorithm configuration parameters.
Definition: Registry.h:65
Registry * fConfig
Summary configuration derived from fConvVect, not necessarily allocated.
Definition: Algorithm.h:217
Registry * FindRegistry(string key) const
int AddLowRegistry(Registry *rp, bool owns=true)
add registry with lowest priority, also update ownership
Definition: Algorithm.cxx:702
string Key(void) const
Definition: AlgId.h:46
static AlgConfigPool * Instance()
#define pDEBUG
Definition: Messenger.h:63
string Config(void) const
Definition: AlgId.h:45
const Registry & Algorithm::GetConfig ( void  ) const
virtual

Get configuration registry Evaluate the summary of the configuration and returns it The summary of a configuration is a merge of all the registries known to the algorithm (see Configure() methods) but every parameter is appearing only once and in case of repetitions, only the parameter from the registry with the highest prioriry is considered.

Definition at line 246 of file Algorithm.cxx.

References GetConfig(), LOG, pDEBUG, and genie::units::second.

Referenced by genie::EventGeneratorListAssembler::AssembleGeneratorList(), genie::HybridXSecAlgorithm::ChooseXSecAlg(), GetAlgorithms(), GetConfig(), genie::GRV98LO::GRV98LO(), genie::NewQELXSec::Integrate(), genie::LHAPDF5::LHAPDF5(), genie::XSecScaleMap::LoadConfig(), genie::MECScaleVsW::LoadConfig(), genie::CascadeReweight::LoadConfig(), genie::HadronTransporter::LoadConfig(), genie::QvalueShifter::LoadConfig(), genie::IBDXSecMap::LoadConfig(), genie::Decayer::LoadConfig(), genie::HybridXSecAlgorithm::LoadConfig(), genie::Pythia6Hadro2019::LoadConfig(), genie::Pythia8Hadro2019::LoadConfig(), genie::BostedChristyEMPXSec::LoadConfig(), genie::SuSAv2QELPXSec::LoadConfig(), genie::NievesSimoVacasMECPXSec2016::LoadConfig(), genie::FGMBodekRitchie::LoadConfig(), genie::SuSAv2MECPXSec::LoadConfig(), genie::NuclearModelMap::LoadConfig(), genie::NievesQELCCPXSec::LoadConfig(), genie::SmithMonizUtils::LoadConfig(), main(), genie::AlgFactory::Print(), TestPythiaTauDecays(), testReconfigInOwnedModules(), and genie::P33PaschosLalakulichPXSec::XSec().

246  {
247 
248  if ( fConfig ) return * fConfig ;
249 
250  const_cast<Algorithm*>( this ) -> fConfig = new Registry( fID.Key() + "_summary", false ) ;
251 
252  // loop and append
253  // understand the append mechanism
254  for ( unsigned int i = 0 ; i < fConfVect.size(); ++i ) {
255  fConfig -> Append( * fConfVect[i] ) ;
256  }
257 
258  if ( fOwnsSubstruc ) {
259 
260  for ( AlgMapConstIter iter = fOwnedSubAlgMp -> begin() ;
261  iter != fOwnedSubAlgMp -> end() ; ++iter ) {
262 
263  Algorithm * subalg = iter -> second ;
264 
265  LOG("Algorithm", pDEBUG) << "Appending config from " << iter -> first << " -> " << subalg -> Id() ;
266  const Registry & r = subalg->GetConfig();
267  RgKey prefix = iter -> first + "/";
268  fConfig -> Append(r,prefix);
269 
270  }
271 
272  } //if owned substructure
273 
274  return * fConfig ;
275 }
AlgMap * fOwnedSubAlgMp
local pool for owned sub-algs (taken out of the factory pool)
Definition: Algorithm.h:176
bool fOwnsSubstruc
true if it owns its substructure (sub-algs,...)
Definition: Algorithm.h:164
Algorithm abstract base class.
Definition: Algorithm.h:54
AlgId fID
algorithm name and configuration set
Definition: Algorithm.h:165
virtual const Registry & GetConfig(void) const
Definition: Algorithm.cxx:246
static constexpr double second
Definition: Units.h:37
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
map< string, Algorithm * >::const_iterator AlgMapConstIter
Definition: Algorithm.h:51
virtual const AlgId & Id(void) const
Get algorithm ID.
Definition: Algorithm.h:98
vector< Registry * > fConfVect
Definition: Algorithm.h:170
string RgKey
A registry. Provides the container for algorithm configuration parameters.
Definition: Registry.h:65
Registry * fConfig
Summary configuration derived from fConvVect, not necessarily allocated.
Definition: Algorithm.h:217
string Key(void) const
Definition: AlgId.h:46
#define pDEBUG
Definition: Messenger.h:63
Registry * Algorithm::GetOwnedConfig ( void  )

Returns the pointer of the summary registry, see previous method Gives access to the summary so it could be changed. The usage of this method is deprecated as it is mantained only for back compatibility. If you need to add or chage a parter (or more), use the AddTopRegistry() instead

Definition at line 279 of file Algorithm.cxx.

Referenced by genie::TransverseEnhancementFFModel::LoadConfig(), and genie::EffectiveSF::LoadConfig().

280 {
281 
282  GetConfig() ;
283  return fConfig;
284 }
virtual const Registry & GetConfig(void) const
Definition: Algorithm.cxx:246
Registry * fConfig
Summary configuration derived from fConvVect, not necessarily allocated.
Definition: Algorithm.h:217
template<class T >
bool genie::Algorithm::GetParam ( const RgKey name,
T &  p,
bool  is_top_call = true 
) const
protected

Ideal access to a parameter value from the vector of registries Returns true if the value is found and the parameters is set

Referenced by genie::CollinsSpillerFragm::BuildFunction(), genie::PetersonFragm::BuildFunction(), genie::PythiaBaseHadro2019::LoadConfig(), genie::DISXSec::LoadConfig(), genie::COHXSec::LoadConfig(), genie::MECScaleVsW::LoadConfig(), genie::DFRKinematicsGenerator::LoadConfig(), genie::INukeDeltaPropg::LoadConfig(), genie::CascadeReweight::LoadConfig(), genie::HadronTransporter::LoadConfig(), genie::RSHelicityAmplModelNCn::LoadConfig(), genie::RSHelicityAmplModelNCp::LoadConfig(), genie::QvalueShifter::LoadConfig(), genie::HEDISXSec::LoadConfig(), genie::RESKinematicsGenerator::LoadConfig(), genie::DipoleELFormFactorsModel::LoadConfig(), genie::DISHadronicSystemGenerator::LoadConfig(), genie::DMDISXSec::LoadConfig(), genie::BaryonResonanceDecayer::LoadConfig(), genie::COHDNuXSec::LoadConfig(), genie::COHKinematicsGenerator::LoadConfig(), genie::DipoleAxialFormFactorModel::LoadConfig(), genie::AGKY2019::LoadConfig(), genie::H3AMNuGammaPXSec::LoadConfig(), genie::RSPPResonanceSelector::LoadConfig(), genie::IBDXSecMap::LoadConfig(), genie::VertexGenerator::LoadConfig(), genie::XSecLinearCombinations::LoadConfig(), genie::PhotonCOHGenerator::LoadConfig(), genie::PhotonRESGenerator::LoadConfig(), genie::HEDISPXSec::LoadConfig(), genie::EmpiricalMECPXSec2015::LoadConfig(), genie::PattonCEvNSPXSec::LoadConfig(), genie::COHDNuEventGenerator::LoadConfig(), genie::PhotonRESPXSec::LoadConfig(), genie::QELEventGeneratorSuSA::LoadConfig(), genie::GLRESPXSec::LoadConfig(), genie::Decayer::LoadConfig(), genie::SlowRsclCharmDISPXSecLO::LoadConfig(), genie::GalsterELFormFactorsModel::LoadConfig(), genie::UnstableParticleDecayer::LoadConfig(), genie::AhrensNCELPXSec::LoadConfig(), genie::GLRESGenerator::LoadConfig(), genie::AlamSimoAtharVacasSKPXSec2014::LoadConfig(), genie::KNOTunedQPMDISPXSec::LoadConfig(), genie::QPMDISPXSec::LoadConfig(), genie::ReinDFRPXSec::LoadConfig(), genie::RosenbluthPXSec::LoadConfig(), genie::BergerSehgalFMCOHPiPXSec2015::LoadConfig(), genie::StrumiaVissaniIBDPXSec::LoadConfig(), genie::MECXSec::LoadConfig(), genie::DFRXSec::LoadConfig(), genie::HEDISKinematicsGenerator::LoadConfig(), genie::AivazisCharmPXSecLO::LoadConfig(), genie::MArunAxialFormFactorModel::LoadConfig(), genie::MECGenerator::LoadConfig(), genie::P33PaschosLalakulichPXSec::LoadConfig(), genie::AhrensDMELPXSec::LoadConfig(), genie::SPPXSec::LoadConfig(), genie::BergerSehgalCOHPiPXSec2015::LoadConfig(), genie::BYPDF::LoadConfig(), genie::DarkSectorDecayer::LoadConfig(), genie::BBA03ELFormFactorsModel::LoadConfig(), genie::BBA05ELFormFactorsModel::LoadConfig(), genie::QPMDMDISPXSec::LoadConfig(), genie::BertuzzoDNuCOHPXSec::LoadConfig(), genie::ZExpAxialFormFactorModel::LoadConfig(), genie::ReinSehgalRESXSec::LoadConfig(), genie::LwlynSmithQELCCPXSec::LoadConfig(), genie::NuElectronPXSec::LoadConfig(), genie::PrimaryLeptonGenerator::LoadConfig(), genie::DMElectronPXSec::LoadConfig(), genie::PaisQELLambdaPXSec::LoadConfig(), genie::ReinSehgalCOHPiPXSec::LoadConfig(), genie::LeptoHadronization::LoadConfig(), genie::SpectralFunc1d::LoadConfig(), genie::LwlynSmithFF::LoadConfig(), genie::OutgoingDarkGenerator::LoadConfig(), genie::SuSAv2QELPXSec::LoadConfig(), genie::NievesSimoVacasMECPXSec2016::LoadConfig(), genie::FGMBodekRitchie::LoadConfig(), genie::EventGenerator::LoadConfig(), genie::ReinSehgalSPPXSec::LoadConfig(), genie::BostedChristyEMPXSec::LoadConfig(), genie::ReinSehgalRESPXSec::LoadConfig(), genie::LHAPDF6::LoadConfig(), genie::QPMDISStrucFuncBase::LoadConfig(), genie::ReinSehgalRESXSecFast::LoadConfig(), genie::AGCharm2019::LoadConfig(), genie::QPMDMDISStrucFuncBase::LoadConfig(), genie::SuSAv2MECPXSec::LoadConfig(), genie::NievesQELCCPXSec::LoadConfig(), genie::NuclearModelMap::LoadConfig(), genie::HAIntranuke::LoadConfig(), genie::HAIntranuke2018::LoadConfig(), genie::HNIntranuke2018::LoadConfig(), genie::LocalFGM::LoadConfig(), genie::EffectiveSF::LoadConfig(), genie::SmithMonizQELCCPXSec::LoadConfig(), genie::BBA07ELFormFactorsModel::LoadConfig(), genie::hnl::Decayer::LoadConfig(), genie::ReinSehgalSPPPXSec::LoadConfig(), genie::BSKLNBaseRESPXSec2014::LoadConfig(), genie::hnl::BRCalculator::LoadConfig(), genie::AGKYLowW2019::LoadConfig(), genie::SmithMonizUtils::LoadConfig(), genie::hnl::FluxCreator::LoadConfig(), genie::MKSPPPXSec2020::LoadConfig(), genie::PhysInteractionSelector::LoadConfigData(), genie::MECInteractionListGenerator::LoadConfigData(), genie::RESInteractionListGenerator::LoadConfigData(), genie::PauliBlocker::LoadModelType(), genie::evtlib::EventLibraryInterface::LoadRecords(), genie::evtlib::EvtLibPXSec::LoadXSecs(), genie::DMBYStrucFunc::ReadBYParams(), genie::BYStrucFunc::ReadBYParams(), and genie::LHAPDF5::SetPDFSetFromConfig().

template<class T >
bool genie::Algorithm::GetParamDef ( const RgKey name,
T &  p,
const T &  def 
) const
protected

Ideal access to a parameter value from the vector of registries, With default value. Returns true if the value is set from the registries, false if the value is the default

Referenced by genie::IMDXSec::LoadConfig(), genie::DISXSec::LoadConfig(), genie::RESXSec::LoadConfig(), genie::COHXSec::LoadConfig(), genie::DFRKinematicsGenerator::LoadConfig(), genie::CEvNSXSec::LoadConfig(), genie::MECScaleVsW::LoadConfig(), genie::HELeptonKinematicsGenerator::LoadConfig(), genie::COHXSecAR::LoadConfig(), genie::DISHadronicSystemGenerator::LoadConfig(), genie::NuEKinematicsGenerator::LoadConfig(), genie::QELXSec::LoadConfig(), genie::HEDISXSec::LoadConfig(), genie::RESKinematicsGenerator::LoadConfig(), genie::SKKinematicsGenerator::LoadConfig(), genie::BaryonResonanceDecayer::LoadConfig(), genie::COHDNuXSec::LoadConfig(), genie::DMDISXSec::LoadConfig(), genie::DMEKinematicsGenerator::LoadConfig(), genie::COHKinematicsGenerator::LoadConfig(), genie::CEvNSEventGenerator::LoadConfig(), genie::QELKinematicsGenerator::LoadConfig(), genie::HELeptonXSec::LoadConfig(), genie::IBDKinematicsGenerator::LoadConfig(), genie::NuEInteractionListGenerator::LoadConfig(), genie::DMELXSec::LoadConfig(), genie::DISKinematicsGenerator::LoadConfig(), genie::SRCNuclearRecoil::LoadConfig(), genie::PattonCEvNSPXSec::LoadConfig(), genie::EmpiricalMECPXSec2015::LoadConfig(), genie::QELEventGenerator::LoadConfig(), genie::QELEventGeneratorSuSA::LoadConfig(), genie::COHDNuEventGenerator::LoadConfig(), genie::NucBindEnergyAggregator::LoadConfig(), genie::GalsterELFormFactorsModel::LoadConfig(), genie::KNOTunedQPMDISPXSec::LoadConfig(), genie::NormXSec::LoadConfig(), genie::DMELKinematicsGenerator::LoadConfig(), genie::DMDISKinematicsGenerator::LoadConfig(), genie::NuElectronXSec::LoadConfig(), genie::DFRXSec::LoadConfig(), genie::AlamSimoAtharVacasSKXSec::LoadConfig(), genie::HEDISKinematicsGenerator::LoadConfig(), genie::MECXSec::LoadConfig(), genie::NucDeExcitationSim::LoadConfig(), genie::P33PaschosLalakulichPXSec::LoadConfig(), genie::AhrensDMELPXSec::LoadConfig(), genie::MECGenerator::LoadConfig(), genie::SPPXSec::LoadConfig(), genie::DMElectronXSec::LoadConfig(), genie::DMELEventGenerator::LoadConfig(), genie::QPMDMDISPXSec::LoadConfig(), genie::FermiMover::LoadConfig(), genie::ReinSehgalRESXSec::LoadConfig(), genie::LwlynSmithQELCCPXSec::LoadConfig(), genie::DMElectronPXSec::LoadConfig(), genie::FGMBodekRitchie::LoadConfig(), genie::ReinSehgalSPPXSec::LoadConfig(), genie::BostedChristyEMPXSec::LoadConfig(), genie::ReinSehgalRESPXSec::LoadConfig(), genie::ReinSehgalRESXSecFast::LoadConfig(), genie::QPMDISStrucFuncBase::LoadConfig(), genie::QPMDMDISStrucFuncBase::LoadConfig(), genie::AGCharm2019::LoadConfig(), genie::SuSAv2MECPXSec::LoadConfig(), genie::NievesQELCCPXSec::LoadConfig(), genie::SPPEventGenerator::LoadConfig(), genie::QELEventGeneratorSM::LoadConfig(), genie::HAIntranuke::LoadConfig(), genie::SmithMonizQELCCXSec::LoadConfig(), genie::HNIntranuke2018::LoadConfig(), genie::KovalenkoQELCharmPXSec::LoadConfig(), genie::HAIntranuke2018::LoadConfig(), genie::LocalFGM::LoadConfig(), genie::EffectiveSF::LoadConfig(), genie::SmithMonizQELCCPXSec::LoadConfig(), genie::BSKLNBaseRESPXSec2014::LoadConfig(), genie::AGKYLowW2019::LoadConfig(), genie::NewQELXSec::LoadConfig(), genie::MKSPPPXSec2020::LoadConfig(), genie::MECInteractionListGenerator::LoadConfigData(), genie::DFRInteractionListGenerator::LoadConfigData(), genie::QELInteractionListGenerator::LoadConfigData(), genie::RESInteractionListGenerator::LoadConfigData(), genie::COHInteractionListGenerator::LoadConfigData(), genie::SKInteractionListGenerator::LoadConfigData(), genie::DMELInteractionListGenerator::LoadConfigData(), genie::RSPPInteractionListGenerator::LoadConfigData(), genie::HELeptonInteractionListGenerator::LoadConfigData(), genie::DISInteractionListGenerator::LoadConfigData(), genie::DMDISInteractionListGenerator::LoadConfigData(), and genie::HEDISInteractionListGenerator::LoadConfigData().

template<class T >
int genie::Algorithm::GetParamMat ( const std::string &  comm_name,
TMatrixT< T > &  mat,
bool  is_top_call = true 
) const
protected

Handle to load matrix of parameters.

int Algorithm::GetParamMatKeys ( const std::string &  comm_name,
std::vector< RgKey > &  k,
bool  is_top_call = true 
) const
protected

Definition at line 585 of file Algorithm.cxx.

References BuildParamMatColSizeKey(), BuildParamMatKey(), and BuildParamMatRowSizeKey().

586  {
587 
588  k.clear() ;
589 
590  int n_row = 0, n_col = 0 ;
591  std::string row_name = Algorithm::BuildParamMatRowSizeKey( comm_name ) ;
592  std::string col_name = Algorithm::BuildParamMatColSizeKey( comm_name ) ;
593 
594  bool found = GetParam( row_name, n_row, is_top_call ) && GetParam( col_name, n_col, is_top_call ) ;
595 
596  if ( ! found ) {
597  return 0 ;
598  }
599 
600  for ( int i = 0; i < n_row; ++i ) {
601  for ( int j = 0; j < n_col; ++j ) {
602 
603  RgKey temp_key = Algorithm::BuildParamMatKey( comm_name, i, j ) ;
604 
605  // potentially, if it is a top call,
606  // we might want to check if the key actually exist in the global Registry
607  // Not a priority irght now
608 
609  k.push_back( temp_key ) ;
610  }
611  }
612 
613  return k.size() ;
614 }
static string BuildParamMatKey(const std::string &comm_name, unsigned int i, unsigned int j)
Definition: Algorithm.cxx:527
static string BuildParamMatColSizeKey(const std::string &comm_name)
Definition: Algorithm.cxx:545
static string BuildParamMatRowSizeKey(const std::string &comm_name)
Definition: Algorithm.cxx:537
string RgKey
bool GetParam(const RgKey &name, T &p, bool is_top_call=true) const
template<class T >
int genie::Algorithm::GetParamMatSym ( const std::string &  comm_name,
TMatrixTSym< T > &  mat,
bool  is_top_call = true 
) const
protected
template<class T >
int genie::Algorithm::GetParamVect ( const std::string &  comm_name,
std::vector< T > &  v,
bool  is_top_call = true 
) const
protected
int Algorithm::GetParamVectKeys ( const std::string &  comm_name,
std::vector< RgKey > &  k,
bool  is_top_call = true 
) const
protected

Definition at line 555 of file Algorithm.cxx.

References BuildParamVectKey(), and BuildParamVectSizeKey().

Referenced by genie::XSecLinearCombinations::LoadConfig().

556  {
557 
558  k.clear() ;
559 
560  int n ;
561  std::string n_name = Algorithm::BuildParamVectSizeKey( comm_name ) ;
562 
563  bool found = GetParam( n_name, n, is_top_call ) ;
564 
565  if ( ! found ) {
566  return 0 ;
567  }
568 
569  for ( int i = 0; i < n; ++i ) {
570 
571  RgKey temp_key = Algorithm::BuildParamVectKey( comm_name, i ) ;
572 
573  // potentially, if it is a top call,
574  // we might want to check if the key actually exist in the global Registry
575  // Not a priority irght now
576 
577  k.push_back( temp_key ) ;
578  }
579 
580  return k.size() ;
581 }
static string BuildParamVectSizeKey(const std::string &comm_name)
Definition: Algorithm.cxx:520
string RgKey
bool GetParam(const RgKey &name, T &p, bool is_top_call=true) const
static string BuildParamVectKey(const std::string &comm_name, unsigned int i)
Definition: Algorithm.cxx:510
virtual AlgStatus_t genie::Algorithm::GetStatus ( void  ) const
inlinevirtual

Get algorithm status.

Definition at line 101 of file Algorithm.h.

References fStatus.

101 { return fStatus; }
AlgStatus_t fStatus
algorithm execution status
Definition: Algorithm.h:175
virtual const AlgId& genie::Algorithm::Id ( void  ) const
inlinevirtual

Get algorithm ID.

Definition at line 98 of file Algorithm.h.

References fID.

Referenced by genie::KineGeneratorWithCache::AccessCacheBranch(), genie::InteractionListAssembler::AssembleInteractionList(), genie::XSecAlgorithmMap::BuildMap(), genie::InteractionGeneratorMap::BuildMap(), genie::XSecSplineList::BuildSplineKey(), genie::ReinSehgalRESXSecWithCache::CacheBranchName(), genie::DISXSec::CacheBranchName(), genie::DMDISXSec::CacheBranchName(), genie::ReinSehgalRESXSecWithCacheFast::CacheBranchName(), genie::SPPXSecWithCache::CacheBranchName(), Compare(), genie::SKKinematicsGenerator::ComputeMaxXSec(), genie::COHKinematicsGenerator::ComputeMaxXSec(), Configure(), genie::GEVGDriver::CreateSplines(), genie::KNOTunedQPMDISPXSec::DISRESJoinSuppressionFactor(), genie::AlgConfigPool::FindRegistry(), genie::AlgFactory::ForceReconfiguration(), genie::GEVGDriver::GenerateEvent(), GetAlgorithms(), genie::LwlynSmithQELCCPXSec::Integral(), genie::NievesQELCCPXSec::Integral(), genie::COHXSec::Integrate(), genie::HadronTransporter::LoadConfig(), genie::QPMDISPXSec::LoadConfig(), genie::QPMDMDISPXSec::LoadConfig(), genie::EventGenerator::LoadConfig(), genie::NievesSimoVacasMECPXSec2016::LoadConfig(), genie::SuSAv2QELPXSec::LoadConfig(), genie::SuSAv2MECPXSec::LoadConfig(), genie::NievesQELCCPXSec::LoadConfig(), genie::EventGeneratorListAssembler::LoadGenerator(), main(), genie::COHKinematicsGenerator::MaxXSec_AlvarezRuso(), genie::XSecAlgorithmMap::Print(), genie::InteractionGeneratorMap::Print(), genie::AlgFactory::Print(), genie::COHHadronicSystemGenerator::ProcessEventRecord(), genie::COHPrimaryLeptonGenerator::ProcessEventRecord(), genie::COHKinematicsGenerator::ProcessEventRecord(), genie::MECGenerator::ProcessEventRecord(), genie::EventGenerator::ProcessEventRecord(), genie::AGKY2019::SelectHadronizer(), TestPythiaTauDecays(), and genie::GEVGDriver::UseSplines().

98 { return fID; }
AlgId fID
algorithm name and configuration set
Definition: Algorithm.h:165
void Algorithm::Initialize ( void  )
protected

Definition at line 335 of file Algorithm.cxx.

336 {
337 // Algorithm initialization
338 //
339  fAllowReconfig = true;
340  fOwnsSubstruc = false;
341  fConfig = 0;
342  fOwnedSubAlgMp = 0;
343 }
AlgMap * fOwnedSubAlgMp
local pool for owned sub-algs (taken out of the factory pool)
Definition: Algorithm.h:176
bool fOwnsSubstruc
true if it owns its substructure (sub-algs,...)
Definition: Algorithm.h:164
Registry * fConfig
Summary configuration derived from fConvVect, not necessarily allocated.
Definition: Algorithm.h:217
int Algorithm::MergeTopRegistry ( const Registry r)
protected

Merge with top level registry if first reg of the vector is owned Otherwise an owned copy is added as a top registry

Definition at line 719 of file Algorithm.cxx.

719  {
720 
721  if ( fOwnerships.empty() ) {
722 
723  // this algorithm is not configured right now, the incoming registry is the only configuration
724  Registry * p = new Registry( r ) ;
725  AddTopRegistry( p ) ;
726 
727  return 1 ;
728  }
729 
730  if ( fOwnerships[0] ) {
731  //the top registry is owned: it can be changed with no consequences for other algorithms
732  fConfVect[0] -> Merge( r ) ;
733  }
734  else {
735  // The top registry is not owned so it cannot be changed
736  // The registry will be added with top priority
737 
738  Registry * p = new Registry( r ) ;
739  AddTopRegistry( p ) ;
740  }
741 
742  // The configuration has changed so the summary is not updated anymore and must be deleted
743  if ( fConfig ) {
744  delete fConfig ;
745  fConfig = 0 ;
746  }
747 
748  return fConfVect.size() ;
749 }
int AddTopRegistry(Registry *rp, bool owns=true)
add registry with top priority, also update ownership
Definition: Algorithm.cxx:686
vector< Registry * > fConfVect
Definition: Algorithm.h:170
A registry. Provides the container for algorithm configuration parameters.
Definition: Registry.h:65
vector< bool > fOwnerships
ownership for every registry in fConfVect
Definition: Algorithm.h:173
Registry * fConfig
Summary configuration derived from fConvVect, not necessarily allocated.
Definition: Algorithm.h:217
void Algorithm::Print ( ostream &  stream) const
virtual

Print algorithm info.

Definition at line 315 of file Algorithm.cxx.

Referenced by genie::operator<<().

316 {
317  // print algorithm name & parameter-set
318  stream << "\nAlgorithm Key: " << this->fID.Key();
319  stream << " - Owns Substruc: " << ((fOwnsSubstruc) ? "[true]" : "[false]");
320 
321  // print algorithm configuration
322  const Registry & r = this->GetConfig();
323  stream << r;
324 
325  if(fOwnsSubstruc) {
326  AlgMapConstIter iter = fOwnedSubAlgMp->begin();
327  for(; iter!=fOwnedSubAlgMp->end(); ++iter) {
328  Algorithm * alg = iter->second;
329  stream << "<Next algorithm is owned by : " << this->fID.Key() << ">";
330  stream << *alg;
331  }
332  }
333 }
AlgMap * fOwnedSubAlgMp
local pool for owned sub-algs (taken out of the factory pool)
Definition: Algorithm.h:176
bool fOwnsSubstruc
true if it owns its substructure (sub-algs,...)
Definition: Algorithm.h:164
Algorithm abstract base class.
Definition: Algorithm.h:54
AlgId fID
algorithm name and configuration set
Definition: Algorithm.h:165
virtual const Registry & GetConfig(void) const
Definition: Algorithm.cxx:246
map< string, Algorithm * >::const_iterator AlgMapConstIter
Definition: Algorithm.h:51
A registry. Provides the container for algorithm configuration parameters.
Definition: Registry.h:65
string Key(void) const
Definition: AlgId.h:46
void Algorithm::SetId ( const AlgId id)
virtual

Set algorithm ID.

Definition at line 305 of file Algorithm.cxx.

306 {
307  fID.Copy(id);
308 }
AlgId fID
algorithm name and configuration set
Definition: Algorithm.h:165
void Copy(const AlgId &id)
Definition: AlgId.cxx:72
void Algorithm::SetId ( string  name,
string  config 
)
virtual

Definition at line 310 of file Algorithm.cxx.

311 {
312  fID.SetId(name, config);
313 }
AlgId fID
algorithm name and configuration set
Definition: Algorithm.h:165
void SetId(string name, string config="")
Definition: AlgId.cxx:64
const char * name
const Algorithm * Algorithm::SubAlg ( const RgKey registry_key) const

Access the sub-algorithm pointed to by the input key, either from the local pool or from AlgFactory's pool

Definition at line 345 of file Algorithm.cxx.

References genie::AlgFactory::GetAlgorithm(), genie::AlgFactory::Instance(), LOG, pERROR, and pINFO.

Referenced by genie::HybridXSecAlgorithm::ChooseXSecAlg(), genie::utils::gsl::FullQELdXSec::FullQELdXSec(), genie::NewQELXSec::Integrate(), genie::XSecScaleMap::LoadConfig(), genie::HadronTransporter::LoadConfig(), genie::DISHadronicSystemGenerator::LoadConfig(), genie::XSecLinearCombinations::LoadConfig(), genie::NucleonDecayPrimaryVtxGenerator::LoadConfig(), genie::AGKY2019::LoadConfig(), genie::IBDXSecMap::LoadConfig(), genie::SecondNucleonEmissionI::LoadConfig(), genie::HEDISPXSec::LoadConfig(), genie::SlowRsclCharmDISPXSecLO::LoadConfig(), genie::EmpiricalMECPXSec2015::LoadConfig(), genie::GLRESPXSec::LoadConfig(), genie::PattonCEvNSPXSec::LoadConfig(), genie::HEDISGenerator::LoadConfig(), genie::PhotonCOHPXSec::LoadConfig(), genie::PhotonRESPXSec::LoadConfig(), genie::HENuElPXSec::LoadConfig(), genie::QELEventGenerator::LoadConfig(), genie::QELEventGeneratorSuSA::LoadConfig(), genie::KNOTunedQPMDISPXSec::LoadConfig(), genie::AhrensNCELPXSec::LoadConfig(), genie::UnstableParticleDecayer::LoadConfig(), genie::AlamSimoAtharVacasSKPXSec2014::LoadConfig(), genie::RosenbluthPXSec::LoadConfig(), genie::StrumiaVissaniIBDPXSec::LoadConfig(), genie::MKFFEM::LoadConfig(), genie::BergerSehgalFMCOHPiPXSec2015::LoadConfig(), genie::QPMDISPXSec::LoadConfig(), genie::AlvarezRusoCOHPiPXSec::LoadConfig(), genie::ReinDFRPXSec::LoadConfig(), genie::RESHadronicSystemGenerator::LoadConfig(), genie::IMDAnnihilationPXSec::LoadConfig(), genie::AivazisCharmPXSecLO::LoadConfig(), genie::NNBarOscPrimaryVtxGenerator::LoadConfig(), genie::DMELEventGenerator::LoadConfig(), genie::MECGenerator::LoadConfig(), genie::P33PaschosLalakulichPXSec::LoadConfig(), genie::AhrensDMELPXSec::LoadConfig(), genie::BergerSehgalCOHPiPXSec2015::LoadConfig(), genie::BYPDF::LoadConfig(), genie::BertuzzoDNuCOHPXSec::LoadConfig(), genie::QPMDMDISPXSec::LoadConfig(), genie::FermiMover::LoadConfig(), genie::HybridXSecAlgorithm::LoadConfig(), genie::LwlynSmithQELCCPXSec::LoadConfig(), genie::NuElectronPXSec::LoadConfig(), genie::ReinSehgalCOHPiPXSec::LoadConfig(), genie::PaisQELLambdaPXSec::LoadConfig(), genie::DMElectronPXSec::LoadConfig(), genie::BardinIMDRadCorPXSec::LoadConfig(), genie::LwlynSmithFF::LoadConfig(), genie::NievesSimoVacasMECPXSec2016::LoadConfig(), genie::EventGenerator::LoadConfig(), genie::MartiniEricsonChanfrayMarteauMECPXSec2016::LoadConfig(), genie::SuSAv2QELPXSec::LoadConfig(), genie::ReinSehgalRESPXSec::LoadConfig(), genie::QPMDISStrucFuncBase::LoadConfig(), genie::QPMDMDISStrucFuncBase::LoadConfig(), genie::AGCharm2019::LoadConfig(), genie::SuSAv2MECPXSec::LoadConfig(), genie::NievesQELCCPXSec::LoadConfig(), genie::QELEventGeneratorSM::LoadConfig(), genie::SmithMonizQELCCXSec::LoadConfig(), genie::HAIntranuke::LoadConfig(), genie::NuclearModelMap::LoadConfig(), genie::HAIntranuke2018::LoadConfig(), genie::KovalenkoQELCharmPXSec::LoadConfig(), genie::HNIntranuke2018::LoadConfig(), genie::SmithMonizQELCCPXSec::LoadConfig(), genie::ReinSehgalSPPPXSec::LoadConfig(), genie::BSKLNBaseRESPXSec2014::LoadConfig(), genie::MKSPPPXSec2020::LoadConfig(), and genie::EventGeneratorListAssembler::LoadGenerator().

346 {
347 // Returns the sub-algorithm pointed to this algorithm's XML config file using
348 // the the values of the key.
349 // This method asserts the existence of these keys in the XML config.
350 // Note: Since only 1 parameter is used, the key value should contain both the
351 // algorithm name and its configuration set according to the usual scheme:
352 // namespace::algorithm_name/configuration_set
353 //
354  LOG("Algorithm", pINFO)
355  << "Fetching sub-alg within alg: " << this->Id().Key()
356  << " pointed to by key: " << registry_key;
357 
358  //-- if the algorithm owns its substructure:
359  // return the sub-algorithm from the local pool
360  //
361  if(fOwnsSubstruc) {
362  AlgMapConstIter iter = fOwnedSubAlgMp->find(registry_key);
363  if(iter!=fOwnedSubAlgMp->end()) return iter->second;
364  LOG("Algorithm", pERROR)
365  << "Owned sub-alg pointed to by key: " << registry_key
366  << " was not found within alg: " << this->Id().Key();
367  return 0;
368  }
369 
370  //-- if the algorithm does not own its substructure:
371  // return the sub-algorithm from the AlgFactory's pool
372  RgAlg alg ;
373  GetParam( registry_key, alg ) ;
374 
375  LOG("Algorithm", pINFO)
376  << "Registry key: " << registry_key << " points to algorithm: " << alg;
377 
378  // retrieve the Algorithm object from the the Algorithm factory
379  AlgFactory * algf = AlgFactory::Instance();
380  const Algorithm * algbase = algf->GetAlgorithm(alg.name, alg.config);
381  assert(algbase);
382 
383  return algbase;
384 }
#define pERROR
Definition: Messenger.h:59
AlgMap * fOwnedSubAlgMp
local pool for owned sub-algs (taken out of the factory pool)
Definition: Algorithm.h:176
bool fOwnsSubstruc
true if it owns its substructure (sub-algs,...)
Definition: Algorithm.h:164
Algorithm abstract base class.
Definition: Algorithm.h:54
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
const Algorithm * GetAlgorithm(const AlgId &algid)
Definition: AlgFactory.cxx:75
#define pINFO
Definition: Messenger.h:62
map< string, Algorithm * >::const_iterator AlgMapConstIter
Definition: Algorithm.h:51
virtual const AlgId & Id(void) const
Get algorithm ID.
Definition: Algorithm.h:98
static AlgFactory * Instance()
Definition: AlgFactory.cxx:64
bool GetParam(const RgKey &name, T &p, bool is_top_call=true) const
The GENIE Algorithm Factory.
Definition: AlgFactory.h:39
string Key(void) const
Definition: AlgId.h:46

Friends And Related Function Documentation

ostream& operator<< ( ostream &  stream,
const Algorithm alg 
)
friend

Definition at line 31 of file Algorithm.cxx.

32  {
33  alg.Print(stream);
34  return stream;
35  }
virtual void Print(ostream &stream) const
Print algorithm info.
Definition: Algorithm.cxx:315

Member Data Documentation

bool genie::Algorithm::fAllowReconfig
protected
Registry* genie::Algorithm::fConfig
private

Summary configuration derived from fConvVect, not necessarily allocated.

Definition at line 217 of file Algorithm.h.

vector<Registry*> genie::Algorithm::fConfVect
protected

ideally these members should go private Registry will be access only through the GetParam method configurations registries from various sources the order of the vector is the precedence in case of repeated parameters position 0 -> Highest precedence

Definition at line 170 of file Algorithm.h.

AlgId genie::Algorithm::fID
protected

algorithm name and configuration set

Definition at line 165 of file Algorithm.h.

Referenced by Id().

AlgMap* genie::Algorithm::fOwnedSubAlgMp
protected

local pool for owned sub-algs (taken out of the factory pool)

Definition at line 176 of file Algorithm.h.

vector<bool> genie::Algorithm::fOwnerships
protected

ownership for every registry in fConfVect

Definition at line 173 of file Algorithm.h.

bool genie::Algorithm::fOwnsSubstruc
protected

true if it owns its substructure (sub-algs,...)

Definition at line 164 of file Algorithm.h.

AlgStatus_t genie::Algorithm::fStatus
protected

algorithm execution status

Definition at line 175 of file Algorithm.h.

Referenced by GetStatus().


The documentation for this class was generated from the following files: