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:
genie::AxialFormFactorModelI genie::DISStructureFuncModelI genie::ELFormFactorsModelI genie::EngelFormFactor genie::EventGeneratorListAssembler genie::EventRecordVisitorI genie::FragmentationFunctionI genie::HadronTensorModelI genie::InteractionListAssembler genie::InteractionListGeneratorI genie::InteractionSelectorI genie::mueloss::MuELossI genie::NuclearModelI genie::PDFModelI genie::QELFormFactorsModelI genie::QvalueShifter genie::RSHelicityAmplModelI genie::SmithMonizUtils genie::XSecAlgorithmI genie::XSecIntegratorI genie::XSecScaleI

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)
 

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
 
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< boolfOwnerships
 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 <constantinos.andreopoulos cern.ch> University of Liverpool & STFC Rutherford Appleton Laboratory

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

May 02, 2004

Copyright (c) 2003-2020, The GENIE Collaboration For the full text of the license visit http://copyright.genie-mc.org

Definition at line 53 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.

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.

44 {
45  this->Initialize();
46  fID.SetId(name);
47 }
static QCString name
Definition: declinfo.cpp:673
AlgId fID
algorithm name and configuration set
Definition: Algorithm.h:159
void SetId(string name, string config="")
Definition: AlgId.cxx:64
void Initialize(void)
Definition: Algorithm.cxx:335
Algorithm::Algorithm ( string  name,
string  config 
)
protected

Definition at line 49 of file Algorithm.cxx.

50 {
51  this->Initialize();
53  this->FindConfig();
54 }
static QCString name
Definition: declinfo.cpp:673
AlgId fID
algorithm name and configuration set
Definition: Algorithm.h:159
virtual void FindConfig(void)
Definition: Algorithm.cxx:127
static Config * config
Definition: config.cpp:1054
void SetId(string name, string config="")
Definition: AlgId.cxx:64
void Initialize(void)
Definition: Algorithm.cxx:335

Member Function Documentation

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

add registry with lowest priority, also update ownership

Definition at line 641 of file Algorithm.cxx.

641  {
642 
643  fConfVect.push_back( rp ) ;
644  fOwnerships.push_back( own ) ;
645 
646  if ( fConfig ) {
647  delete fConfig ;
648  fConfig = 0 ;
649  }
650 
651  return fConfVect.size() ;
652 
653 }
vector< Registry * > fConfVect
Definition: Algorithm.h:164
vector< bool > fOwnerships
ownership for every registry in fConfVect
Definition: Algorithm.h:167
Registry * fConfig
Summary configuration derived from fConvVect, not necessarily allocated.
Definition: Algorithm.h:199
int Algorithm::AddTopRegisties ( const vector< Registry * > &  rs,
bool  owns = false 
)
protected

Add registries with top priority, also udated Ownerships.

Definition at line 693 of file Algorithm.cxx.

693  {
694 
695  fConfVect.insert( fConfVect.begin(), rs.begin(), rs.end() ) ;
696 
697  fOwnerships.insert( fOwnerships.begin(), rs.size(), own ) ;
698 
699  if ( fConfig ) {
700  delete fConfig ;
701  fConfig = 0 ;
702  }
703 
704  return fConfVect.size() ;
705 
706 }
vector< Registry * > fConfVect
Definition: Algorithm.h:164
vector< bool > fOwnerships
ownership for every registry in fConfVect
Definition: Algorithm.h:167
Registry * fConfig
Summary configuration derived from fConvVect, not necessarily allocated.
Definition: Algorithm.h:199
int Algorithm::AddTopRegistry ( Registry rp,
bool  owns = true 
)
protected

add registry with top priority, also update ownership

Definition at line 625 of file Algorithm.cxx.

625  {
626 
627  fConfVect.insert( fConfVect.begin(), rp ) ;
628  fOwnerships.insert( fOwnerships.begin(), own ) ;
629 
630  if ( fConfig ) {
631  delete fConfig ;
632  fConfig = 0 ;
633  }
634 
635  return fConfVect.size() ;
636 
637 }
vector< Registry * > fConfVect
Definition: Algorithm.h:164
vector< bool > fOwnerships
ownership for every registry in fConfVect
Definition: Algorithm.h:167
Registry * fConfig
Summary configuration derived from fConvVect, not necessarily allocated.
Definition: Algorithm.h:199
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.

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:97
#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.

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:170
bool fOwnsSubstruc
true if it owns its substructure (sub-algs,...)
Definition: Algorithm.h:158
ChannelGroupService::Name Name
Algorithm abstract base class.
Definition: Algorithm.h:53
map< string, Algorithm * > AlgMap
Definition: Algorithm.h:48
Registry item pABC.
Definition: RegistryItemI.h:29
virtual const Registry & GetConfig(void) const
Definition: Algorithm.cxx:246
virtual RgType_t TypeInfo(void) const =0
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
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:51
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:97
static AlgFactory * Instance()
Definition: AlgFactory.cxx:64
string RgKey
Registry * fConfig
Summary configuration derived from fConvVect, not necessarily allocated.
Definition: Algorithm.h:199
#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 105 of file Algorithm.h.

105 { return fAllowReconfig; }
string Algorithm::BuildParamVectKey ( const std::string comm_name,
unsigned int  i 
)
static

Definition at line 510 of file Algorithm.cxx.

510  {
511 
512  std::stringstream name;
513  name << comm_name << '-' << i ;
514  return name.str() ;
515 
516 }
static QCString name
Definition: declinfo.cpp:673
string Algorithm::BuildParamVectSizeKey ( const std::string comm_name)
static

Definition at line 520 of file Algorithm.cxx.

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.

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:97
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::NewQELXSec, genie::AGKYLowW2019, genie::SmithMonizUtils, genie::Intranuke, genie::Intranuke2018, genie::ReinSehgalSPPPXSec, genie::BBA07ELFormFactorsModel, genie::SmithMonizQELCCPXSec, genie::LocalFGM, genie::KovalenkoQELCharmPXSec, genie::NuclearModelMap, genie::NievesQELCCPXSec, genie::GRV98LO, genie::QELEventGeneratorSM, genie::BSKLNBaseRESPXSec2014, genie::SmithMonizQELCCXSec, genie::ReinSehgalRESXSecFast, genie::AGCharm2019, genie::LHAPDF6, genie::FGMBodekRitchie, genie::ReinSehgalRESPXSec, genie::ReinSehgalSPPXSec, genie::BostedChristyEMPXSec, genie::EventGenerator, genie::MartiniEricsonChanfrayMarteauMECPXSec2016, genie::NievesSimoVacasMECPXSec2016, genie::SuSAv2MECPXSec, genie::SpectralFunc1d, genie::SuSAv2QELPXSec, genie::DMElectronPXSec, genie::QPMDMDISStrucFuncBase, genie::ReinSehgalCOHPiPXSec, genie::EffectiveSF, genie::PaisQELLambdaPXSec, 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::evtlib::EventLibraryInterface, genie::AhrensDMELPXSec, genie::DMElectronXSec, genie::BergerSehgalCOHPiPXSec2015, genie::OutgoingDarkGenerator, genie::BYPDF, genie::GLRESXSec, genie::Pythia8Hadro2019, genie::HEDISInteractionListGenerator, genie::SpectralFunction2p2h, genie::BBA03ELFormFactorsModel, genie::BBA05ELFormFactorsModel, genie::P33PaschosLalakulichPXSec, genie::DMDISInteractionListGenerator, genie::DFRXSec, genie::Pythia6Hadro2019, genie::KLVOxygenIBDPXSec, genie::MECGenerator, genie::PauliBlocker, genie::IMDAnnihilationPXSec, genie::NuElectronXSec, genie::DMDISKinematicsGenerator, genie::AivazisCharmPXSecLO, genie::AlvarezRusoCOHPiPXSec, genie::BergerSehgalFMCOHPiPXSec2015, genie::DarkSectorDecayer, genie::QPMDISPXSec, genie::StrumiaVissaniIBDPXSec, genie::NNBarOscPrimaryVtxGenerator, genie::FermiMover, genie::RESHadronicSystemGenerator, genie::DMELEventGenerator, genie::PrimaryLeptonGenerator, genie::EngelFormFactor, genie::KNOTunedQPMDISPXSec, genie::ReinDFRPXSec, genie::AhrensNCELPXSec, genie::RosenbluthPXSec, genie::TransverseEnhancementFFModel, genie::ZExpAxialFormFactorModel, genie::UnstableParticleDecayer, genie::DISInteractionListGenerator, genie::NucBindEnergyAggregator, genie::HEDISKinematicsGenerator, genie::MECXSec, genie::AlamSimoAtharVacasSKPXSec2014, genie::AlamSimoAtharVacasSKXSec, genie::SlowRsclCharmDISPXSecLO, genie::PattonCEvNSPXSec, genie::DISKinematicsGenerator, genie::GLRESPXSec, genie::PetersonFragm, genie::HEDISPXSec, genie::EmpiricalMECPXSec2015, genie::QELEventGeneratorSuSA, genie::H3AMNuGammaPXSec, genie::DMELKinematicsGenerator, genie::DMELXSec, genie::COHDNuEventGenerator, genie::GLRESGenerator, genie::CollinsSpillerFragm, genie::IBDKinematicsGenerator, genie::SRCNuclearRecoil, genie::KuzminNaumov2016AxialFormFactorModel, genie::RSPPResonanceSelector, genie::DMELInteractionListGenerator, genie::DMDISXSec, genie::COHKinematicsGenerator, genie::COHDNuInteractionListGenerator, genie::AGKY2019, genie::HEDISGenerator, genie::NucleonDecayPrimaryVtxGenerator, genie::QELEventGenerator, genie::CEvNSEventGenerator, genie::XSecLinearCombinations, genie::COHDNuXSec, genie::Decayer, genie::GLRESKinematicsGenerator, genie::TabulatedHadronTensorModelI, genie::HEDISXSec, genie::IBDInteractionListGenerator, genie::DipoleAxialFormFactorModel, genie::RESKinematicsGenerator, genie::RSPPInteractionListGenerator, genie::PhysInteractionSelector, genie::DMEInteractionListGenerator, genie::DMEKinematicsGenerator, genie::COHInteractionListGenerator, genie::HadronTransporter, genie::IBDXSecMap, genie::NHLPrimaryVtxGenerator, 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::GLRESInteractionListGenerator, genie::CascadeReweight, 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.

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:589
AlgMap * fOwnedSubAlgMp
local pool for owned sub-algs (taken out of the factory pool)
Definition: Algorithm.h:170
bool fOwnsSubstruc
true if it owns its substructure (sub-algs,...)
Definition: Algorithm.h:158
int MergeTopRegistry(const Registry &r)
Definition: Algorithm.cxx:658
Algorithm abstract base class.
Definition: Algorithm.h:53
AlgId fID
algorithm name and configuration set
Definition: Algorithm.h:159
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
static Config * config
Definition: config.cpp:1054
virtual void Configure(const Registry &config)
Definition: Algorithm.cxx:62
virtual const AlgId & Id(void) const
Get algorithm ID.
Definition: Algorithm.h:97
A registry. Provides the container for algorithm configuration parameters.
Definition: Registry.h:65
Registry * ExtractLocalConfig(const Registry &in) const
Definition: Algorithm.cxx:558
#define pNOTICE
Definition: Messenger.h:61
map< string, Algorithm * >::iterator AlgMapIter
Definition: Algorithm.h:49
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::NewQELXSec, genie::AGKYLowW2019, genie::SmithMonizUtils, genie::Intranuke, genie::Intranuke2018, genie::ReinSehgalSPPPXSec, genie::BBA07ELFormFactorsModel, genie::SmithMonizQELCCPXSec, genie::LocalFGM, genie::KovalenkoQELCharmPXSec, genie::NuclearModelMap, genie::NievesQELCCPXSec, genie::HAIntranuke, genie::GRV98LO, genie::QELEventGeneratorSM, genie::BSKLNBaseRESPXSec2014, genie::SmithMonizQELCCXSec, genie::ReinSehgalRESXSecFast, genie::AGCharm2019, genie::LHAPDF6, genie::FGMBodekRitchie, genie::ReinSehgalRESPXSec, genie::ReinSehgalSPPXSec, genie::BostedChristyEMPXSec, genie::EventGenerator, genie::MartiniEricsonChanfrayMarteauMECPXSec2016, genie::NievesSimoVacasMECPXSec2016, genie::SuSAv2MECPXSec, genie::SpectralFunc1d, genie::SuSAv2QELPXSec, genie::DMElectronPXSec, genie::QPMDMDISStrucFuncBase, genie::ReinSehgalCOHPiPXSec, genie::EffectiveSF, genie::PaisQELLambdaPXSec, 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::evtlib::EventLibraryInterface, genie::AhrensDMELPXSec, genie::DMElectronXSec, genie::BergerSehgalCOHPiPXSec2015, genie::OutgoingDarkGenerator, genie::BYPDF, genie::GLRESXSec, genie::Pythia8Hadro2019, genie::HEDISInteractionListGenerator, genie::SpectralFunction2p2h, genie::BBA03ELFormFactorsModel, genie::BBA05ELFormFactorsModel, genie::P33PaschosLalakulichPXSec, genie::DMDISInteractionListGenerator, genie::DFRXSec, genie::Pythia6Hadro2019, genie::KLVOxygenIBDPXSec, genie::MECGenerator, genie::PauliBlocker, genie::IMDAnnihilationPXSec, genie::NuElectronXSec, genie::DMDISKinematicsGenerator, genie::AivazisCharmPXSecLO, genie::AlvarezRusoCOHPiPXSec, genie::BergerSehgalFMCOHPiPXSec2015, genie::DarkSectorDecayer, genie::QPMDISPXSec, genie::StrumiaVissaniIBDPXSec, genie::NNBarOscPrimaryVtxGenerator, genie::FermiMover, genie::RESHadronicSystemGenerator, genie::DMELEventGenerator, genie::PrimaryLeptonGenerator, genie::EngelFormFactor, genie::KNOTunedQPMDISPXSec, genie::ReinDFRPXSec, genie::AhrensNCELPXSec, genie::RosenbluthPXSec, genie::TransverseEnhancementFFModel, genie::ZExpAxialFormFactorModel, genie::UnstableParticleDecayer, genie::DISInteractionListGenerator, genie::NucBindEnergyAggregator, genie::HEDISKinematicsGenerator, genie::MECXSec, genie::AlamSimoAtharVacasSKPXSec2014, genie::AlamSimoAtharVacasSKXSec, genie::SlowRsclCharmDISPXSecLO, genie::PattonCEvNSPXSec, genie::DISKinematicsGenerator, genie::GLRESPXSec, genie::PetersonFragm, genie::HEDISPXSec, genie::EmpiricalMECPXSec2015, genie::QELEventGeneratorSuSA, genie::H3AMNuGammaPXSec, genie::DMELKinematicsGenerator, genie::DMELXSec, genie::COHDNuEventGenerator, genie::GLRESGenerator, genie::CollinsSpillerFragm, genie::IBDKinematicsGenerator, genie::SRCNuclearRecoil, genie::KuzminNaumov2016AxialFormFactorModel, genie::RSPPResonanceSelector, genie::DMELInteractionListGenerator, genie::DMDISXSec, genie::COHKinematicsGenerator, genie::COHDNuInteractionListGenerator, genie::AGKY2019, genie::HEDISGenerator, genie::NucleonDecayPrimaryVtxGenerator, genie::QELEventGenerator, genie::CEvNSEventGenerator, genie::XSecLinearCombinations, genie::COHDNuXSec, genie::Decayer, genie::GLRESKinematicsGenerator, genie::TabulatedHadronTensorModelI, genie::HEDISXSec, genie::IBDInteractionListGenerator, genie::DipoleAxialFormFactorModel, genie::RESKinematicsGenerator, genie::RSPPInteractionListGenerator, genie::PhysInteractionSelector, genie::DMEInteractionListGenerator, genie::DMEKinematicsGenerator, genie::COHInteractionListGenerator, genie::HadronTransporter, genie::IBDXSecMap, genie::NHLPrimaryVtxGenerator, 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::GLRESInteractionListGenerator, genie::CascadeReweight, 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 
124  this->FindConfig();
125 }
AlgId fID
algorithm name and configuration set
Definition: Algorithm.h:159
virtual void FindConfig(void)
Definition: Algorithm.cxx:127
static Config * config
Definition: config.cpp:1054
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:164
vector< bool > fOwnerships
ownership for every registry in fConfVect
Definition: Algorithm.h:167
Registry * fConfig
Summary configuration derived from fConvVect, not necessarily allocated.
Definition: Algorithm.h:199
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:170
bool fOwnsSubstruc
true if it owns its substructure (sub-algs,...)
Definition: Algorithm.h:158
Algorithm abstract base class.
Definition: Algorithm.h:53
map< string, Algorithm * >::iterator AlgMapIter
Definition: Algorithm.h:49
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 558 of file Algorithm.cxx.

558  {
559 
560  const RgIMap & rgmap = in.GetItemMap();
561  Registry * out = new Registry( in.Name(), false );
562 
563  for( RgIMapConstIter reg_iter = rgmap.begin();
564  reg_iter != rgmap.end(); ++reg_iter ) {
565 
566  RgKey reg_key = reg_iter->first;
567  if( reg_key.find( '/' ) != string::npos) continue;
568 
569  // at this point
570  // this key is referred to the local algorithm
571  // it has to be copied in out;
572 
573  RegistryItemI * ri = reg_iter->second;
574  RgIMapPair key_item_pair( reg_key, ri->Clone() );
575  out -> Set(key_item_pair);
576 
577  }
578 
579  if ( out -> NEntries() <= 0 ) {
580  delete out ;
581  out = 0 ;
582  }
583 
584  return out ;
585 }
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
constexpr BitMask< Storage > Set(Flag_t< Storage > flag)
Returns a bit mask which sets the specified flag.
pair< RgKey, RegistryItemI * > RgIMapPair
Definition: Registry.h:46
string RgKey
A registry. Provides the container for algorithm configuration parameters.
Definition: Registry.h:65
virtual RegistryItemI * Clone(void) const =0
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 589 of file Algorithm.cxx.

589  {
590 
591  const RgIMap & rgmap = in.GetItemMap();
592  Registry * out = new Registry( in.Name(), false );
593 
594  for( RgIMapConstIter reg_iter = rgmap.begin();
595  reg_iter != rgmap.end(); ++reg_iter ) {
596 
597  RgKey reg_key = reg_iter->first;
598  if( reg_key.find(alg_key+"/") == string::npos) continue;
599 
600  // at this point
601  // this key is referred to the sub-algorithm
602  // indicated by alg_key: it has to be copied in out;
603 
604  int new_key_start = reg_key.find_first_of('/')+1;
605  RgKey new_reg_key = reg_key.substr( new_key_start, reg_key.length() );
606 
607  RegistryItemI * ri = reg_iter->second;
608  RgIMapPair key_item_pair(new_reg_key, ri->Clone());
609  out -> Set(key_item_pair);
610 
611  }
612 
613  if ( out -> NEntries() <= 0 ) {
614  delete out ;
615  out = 0 ;
616  }
617 
618  return out ;
619 
620 }
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
constexpr BitMask< Storage > Set(Flag_t< Storage > flag)
Returns a bit mask which sets the specified flag.
pair< RgKey, RegistryItemI * > RgIMapPair
Definition: Registry.h:46
string RgKey
A registry. Provides the container for algorithm configuration parameters.
Definition: Registry.h:65
virtual RegistryItemI * Clone(void) const =0
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.

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 }
std::string string
Definition: nybbler.cc:12
A singleton class holding all configuration registries built while parsing all loaded XML configurati...
Definition: AlgConfigPool.h:40
#define pFATAL
Definition: Messenger.h:56
intermediate_table::const_iterator const_iterator
AlgId fID
algorithm name and configuration set
Definition: Algorithm.h:159
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
static Config * config
Definition: config.cpp:1054
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:625
#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:97
RgStr GetString(RgKey key) const
Definition: Registry.cxx:481
vector< Registry * > fConfVect
Definition: Algorithm.h:164
vector< string > Split(string input, string delim)
Definition: StringUtils.cxx:36
A registry. Provides the container for algorithm configuration parameters.
Definition: Registry.h:65
static QCString type
Definition: declinfo.cpp:672
Registry * fConfig
Summary configuration derived from fConvVect, not necessarily allocated.
Definition: Algorithm.h:199
Registry * FindRegistry(string key) const
int AddLowRegistry(Registry *rp, bool owns=true)
add registry with lowest priority, also update ownership
Definition: Algorithm.cxx:641
second_as<> second
Type of time stored in seconds, in double precision.
Definition: spacetime.h:85
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.

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 }
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
AlgMap * fOwnedSubAlgMp
local pool for owned sub-algs (taken out of the factory pool)
Definition: Algorithm.h:170
bool fOwnsSubstruc
true if it owns its substructure (sub-algs,...)
Definition: Algorithm.h:158
Algorithm abstract base class.
Definition: Algorithm.h:53
AlgId fID
algorithm name and configuration set
Definition: Algorithm.h:159
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
map< string, Algorithm * >::const_iterator AlgMapConstIter
Definition: Algorithm.h:50
virtual const AlgId & Id(void) const
Get algorithm ID.
Definition: Algorithm.h:97
vector< Registry * > fConfVect
Definition: Algorithm.h:164
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:199
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:72
second_as<> second
Type of time stored in seconds, in double precision.
Definition: spacetime.h:85
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.

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

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

template<class T >
int genie::Algorithm::GetParamVect ( const std::string comm_name,
std::vector< T > &  v,
bool  is_top_call = true 
) const
protected

Handle to load vectors of parameters.

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

Definition at line 528 of file Algorithm.cxx.

529  {
530 
531  k.clear() ;
532 
533  int n ;
534  std::string n_name = Algorithm::BuildParamVectSizeKey( comm_name ) ;
535 
536  bool found = GetParam( n_name, n, is_top_call ) ;
537 
538  if ( ! found ) {
539  return 0 ;
540  }
541 
542  for ( int i = 0; i < n; ++i ) {
543 
544  RgKey temp_key = Algorithm::BuildParamVectKey( comm_name, i ) ;
545 
546  // potentially, if it is a top call,
547  // we might want to check if the key actually exist in the global Registry
548  // Not a priority irght now
549 
550  k.push_back( temp_key ) ;
551  }
552 
553  return k.size() ;
554 }
std::string string
Definition: nybbler.cc:12
std::void_t< T > n
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 100 of file Algorithm.h.

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

Get algorithm ID.

Definition at line 97 of file Algorithm.h.

97 { return fID; }
AlgId fID
algorithm name and configuration set
Definition: Algorithm.h:159
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:170
bool fOwnsSubstruc
true if it owns its substructure (sub-algs,...)
Definition: Algorithm.h:158
Registry * fConfig
Summary configuration derived from fConvVect, not necessarily allocated.
Definition: Algorithm.h:199
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 658 of file Algorithm.cxx.

658  {
659 
660  if ( fOwnerships.empty() ) {
661 
662  // this algorithm is not configured right now, the incoming registry is the only configuration
663  Registry * p = new Registry( r ) ;
664  AddTopRegistry( p ) ;
665 
666  return 1 ;
667  }
668 
669  if ( fOwnerships[0] ) {
670  //the top registry is owned: it can be changed with no consequences for other algorithms
671  fConfVect[0] -> Merge( r ) ;
672  }
673  else {
674  // The top registry is not owned so it cannot be changed
675  // The registry will be added with top priority
676 
677  Registry * p = new Registry( r ) ;
678  AddTopRegistry( p ) ;
679  }
680 
681  // The configuration has changed so the summary is not updated anymore and must be deleted
682  if ( fConfig ) {
683  delete fConfig ;
684  fConfig = 0 ;
685  }
686 
687  return fConfVect.size() ;
688 }
p
Definition: test.py:223
int AddTopRegistry(Registry *rp, bool owns=true)
add registry with top priority, also update ownership
Definition: Algorithm.cxx:625
vector< Registry * > fConfVect
Definition: Algorithm.h:164
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:167
Registry * fConfig
Summary configuration derived from fConvVect, not necessarily allocated.
Definition: Algorithm.h:199
void Algorithm::Print ( ostream &  stream) const
virtual

Print algorithm info.

Definition at line 315 of file Algorithm.cxx.

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:170
bool fOwnsSubstruc
true if it owns its substructure (sub-algs,...)
Definition: Algorithm.h:158
Algorithm abstract base class.
Definition: Algorithm.h:53
AlgId fID
algorithm name and configuration set
Definition: Algorithm.h:159
virtual const Registry & GetConfig(void) const
Definition: Algorithm.cxx:246
map< string, Algorithm * >::const_iterator AlgMapConstIter
Definition: Algorithm.h:50
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:159
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 }
static QCString name
Definition: declinfo.cpp:673
AlgId fID
algorithm name and configuration set
Definition: Algorithm.h:159
static Config * config
Definition: config.cpp:1054
void SetId(string name, string config="")
Definition: AlgId.cxx:64
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.

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:170
bool fOwnsSubstruc
true if it owns its substructure (sub-algs,...)
Definition: Algorithm.h:158
Algorithm abstract base class.
Definition: Algorithm.h:53
#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:50
virtual const AlgId & Id(void) const
Get algorithm ID.
Definition: Algorithm.h:97
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

Definition at line 156 of file Algorithm.h.

Registry* genie::Algorithm::fConfig
private

Summary configuration derived from fConvVect, not necessarily allocated.

Definition at line 199 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 164 of file Algorithm.h.

AlgId genie::Algorithm::fID
protected

algorithm name and configuration set

Definition at line 159 of file Algorithm.h.

AlgMap* genie::Algorithm::fOwnedSubAlgMp
protected

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

Definition at line 170 of file Algorithm.h.

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

ownership for every registry in fConfVect

Definition at line 167 of file Algorithm.h.

bool genie::Algorithm::fOwnsSubstruc
protected

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

Definition at line 158 of file Algorithm.h.

AlgStatus_t genie::Algorithm::fStatus
protected

algorithm execution status

Definition at line 169 of file Algorithm.h.


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