ATLAS Offline Software
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
dqi::CompositeAlgorithm Class Reference

#include <CompositeAlgorithm.h>

Inheritance diagram for dqi::CompositeAlgorithm:
Collaboration diagram for dqi::CompositeAlgorithm:

Public Member Functions

 CompositeAlgorithm (const CompositeAlgorithm &other)
 
 CompositeAlgorithm (HanConfigCompAlg &compAlg)
 
virtual ~CompositeAlgorithm ()
 
virtual dqm_core::Algorithm * clone ()
 
virtual dqm_core::Resultexecute (const std::string &name, const TObject &data, const dqm_core::AlgorithmConfig &config)
 
virtual void printDescription ()
 

Protected Types

typedef std::vector< std::pair< dqm_core::Algorithm *, std::string > > AlgVec_t
 

Protected Member Functions

HanAlgorithmConfigConfigureSubAlg (const dqm_core::AlgorithmConfig &config, const std::string &subalg)
 

Protected Attributes

std::string m_name
 
AlgVec_t m_subAlgs
 

Detailed Description

Definition at line 18 of file CompositeAlgorithm.h.

Member Typedef Documentation

◆ AlgVec_t

typedef std::vector<std::pair<dqm_core::Algorithm*, std::string> > dqi::CompositeAlgorithm::AlgVec_t
protected

Definition at line 33 of file CompositeAlgorithm.h.

Constructor & Destructor Documentation

◆ CompositeAlgorithm() [1/2]

dqi::CompositeAlgorithm::CompositeAlgorithm ( const CompositeAlgorithm other)

Definition at line 26 of file CompositeAlgorithm.cxx.

28  : Algorithm(other)
29  , m_name(other.m_name)
30 {
31  AlgVec_t::const_iterator subAlgsEnd = other.m_subAlgs.end();
32  AlgVec_t::const_iterator subAlgsIter = other.m_subAlgs.begin();
33  for( ; subAlgsIter != subAlgsEnd; ++subAlgsIter ) {
34  dqm_core::Algorithm* otherSubAlg = subAlgsIter->first;
35  dqm_core::Algorithm* alg = otherSubAlg->clone();
36  m_subAlgs.push_back( AlgVec_t::value_type(alg, subAlgsIter->second) );
37  }
38 }

◆ CompositeAlgorithm() [2/2]

dqi::CompositeAlgorithm::CompositeAlgorithm ( HanConfigCompAlg compAlg)

Definition at line 41 of file CompositeAlgorithm.cxx.

43  : m_name (compAlgConfig.GetName())
44 {
45  TObjString* libStr;
46  TIter libIter( compAlgConfig.GetAllLib() );
47  while( (libStr = dynamic_cast<TObjString*>( libIter() )) != 0 ){
48  try {
49  dqm_core::LibraryManager::instance().loadLibrary( libStr->GetString().Data() );
50  }
51  catch ( dqm_core::Exception& ex ) {
52  std::cout << "Can't load library " << libStr->GetString()
53  << " for composite algorithm " << m_name
54  << ". Continuing regardless ..." << std::endl;
55  }
56  }
57 
58  TObjString* algStr;
59  TIter algIter( compAlgConfig.GetAllAlg() );
60  while( (algStr = dynamic_cast<TObjString*>( algIter() )) != 0 ){
62  std::string algName(algStr->GetString().Data());
63  try {
65  }
66  catch( dqm_core::Exception& ex ) {
67  throw dqm_core::BadConfig( ERS_HERE, m_name, ex.what(), ex );
68  }
69  //std::cout << " --> using component algorithm: \"" << algStr->GetString().Data() << "\"\n";
70  m_subAlgs.push_back( AlgVec_t::value_type(alg, algName) );
71  }
72  dqm_core::AlgorithmManager::instance().registerAlgorithm( m_name, this );
73 }

◆ ~CompositeAlgorithm()

dqi::CompositeAlgorithm::~CompositeAlgorithm ( )
virtual

Definition at line 76 of file CompositeAlgorithm.cxx.

78 {
79  AlgVec_t::const_iterator subAlgsEnd = m_subAlgs.end();
80  AlgVec_t::const_iterator subAlgsIter = m_subAlgs.begin();
81  for( ; subAlgsIter != subAlgsEnd; ++subAlgsIter ) {
82  dqm_core::Algorithm* alg = subAlgsIter->first;
83  delete alg;
84  }
85  m_subAlgs.clear();
86 }

Member Function Documentation

◆ clone()

dqm_core::Algorithm * dqi::CompositeAlgorithm::clone ( )
virtual

Definition at line 90 of file CompositeAlgorithm.cxx.

92 {
94  return result;
95 }

◆ ConfigureSubAlg()

HanAlgorithmConfig * dqi::CompositeAlgorithm::ConfigureSubAlg ( const dqm_core::AlgorithmConfig &  config,
const std::string &  subalg 
)
protected

Definition at line 148 of file CompositeAlgorithm.cxx.

150 {
151 // caller owns the returned object
152 
153 // what we do: copy reference, params, limits to newly created config
154 // copy all those WITHOUT a / (backwards compatibility) and those of the form
155 // subalg/xxx.
156 
157  TObject* ref(0);
158  try {
159  ref = config.getReference();
160  } catch (dqm_core::BadConfig &) { /* ignore */ }
161  std::map< std::string,double > pars;
162  std::map<std::string,std::string> strPars;
163  std::map<std::string,double> grthr;
164  std::map<std::string,double> rdthr;
165 
166  std::map< std::string, double > oldpars(config.getParameters());
167  std::map<std::string,double> oldgrthr(config.getGreenThresholds());
168  std::map<std::string,double> oldrdthr(config.getRedThresholds());
169 
170  for (std::map< std::string, double >::const_iterator parVal = oldpars.begin();
171  parVal != oldpars.end(); ++parVal) {
172  std::string parname(parVal->first);
173  std::string::size_type pos = parname.find('|');
174  if (pos == std::string::npos) {
175  pars.insert(*parVal);
176  } else if (parname.substr(0, pos) == subalg) {
177  pars.insert(std::map< std::string, double >::value_type(parname.substr(pos+1), parVal->second));
178  }
179  }
180  for ( auto& strPar : config.getGenericParameters() ) {
181  std::string parname = strPar.first;
182  auto pipeIndex = parname.find( '|' );
183  if ( pipeIndex == std::string::npos ) {
184  strPars.insert( strPar );
185  } else if ( parname.substr( 0, pipeIndex ) == subalg ) {
186  strPars.emplace( parname.substr( pipeIndex + 1 ), strPar.second );
187  }
188  }
189  for (std::map< std::string, double >::const_iterator thrVal = oldgrthr.begin();
190  thrVal != oldgrthr.end(); ++thrVal) {
191  std::string thrname(thrVal->first);
192  std::string::size_type pos = thrname.find('|');
193  if (pos == std::string::npos) {
194  grthr.insert(*thrVal);
195  } else if (thrname.substr(0, pos) == subalg) {
196  grthr.insert(std::map< std::string, double >::value_type(thrname.substr(pos+1), thrVal->second));
197  }
198  }
199  for (std::map< std::string, double >::const_iterator thrVal = oldrdthr.begin();
200  thrVal != oldrdthr.end(); ++thrVal) {
201  std::string thrname(thrVal->first);
202  std::string::size_type pos = thrname.find('|');
203  if (pos == std::string::npos) {
204  rdthr.insert(*thrVal);
205  } else if (thrname.substr(0, pos) == subalg) {
206  rdthr.insert(std::map< std::string, double >::value_type(thrname.substr(pos+1), thrVal->second));
207  }
208  }
209  return new HanAlgorithmConfig(ref, pars, strPars, grthr, rdthr, 0);
210 }

◆ execute()

dqm_core::Result * dqi::CompositeAlgorithm::execute ( const std::string &  name,
const TObject &  data,
const dqm_core::AlgorithmConfig &  config 
)
virtual

Definition at line 113 of file CompositeAlgorithm.cxx.

115 {
117  std::map<std::string,double> tags;
118 
119  AlgVec_t::const_iterator subAlgsEnd = m_subAlgs.end();
120  AlgVec_t::const_iterator subAlgsIter = m_subAlgs.begin();
121  for( ; subAlgsIter != subAlgsEnd; ++subAlgsIter ) {
122  boost::scoped_ptr<HanAlgorithmConfig> subConfig(ConfigureSubAlg(config, subAlgsIter->second));
123 
124  dqm_core::Algorithm* alg = subAlgsIter->first;
125  dqm_core::Result* subResult = alg->execute( name, data, *subConfig );
126  if( subResult->status_ != dqm_core::Result::Undefined ) {
128  status = ( subResult->status_ < status ) ? subResult->status_ : status;
129  }
130 
131  std::map<std::string,double>::const_iterator tagsEnd = subResult->tags_.end();
132  std::map<std::string,double>::const_iterator tagsIter = subResult->tags_.begin();
133  for( ; tagsIter != tagsEnd; ++tagsIter ) {
134  std::map<std::string,double>::value_type tagVal( subAlgsIter->second + std::string("|") + tagsIter->first, tagsIter->second );
135  tags.insert( tagVal );
136  }
137  //delete subConfig;
138  delete subResult;
139  }
140 
142  result->tags_ = tags;
143 
144  return result;
145 }

◆ printDescription()

void dqi::CompositeAlgorithm::printDescription ( )
virtual

Definition at line 99 of file CompositeAlgorithm.cxx.

101 {
102  std::string message;
103  message += "\n";
104  message += "Algorithm: \"" + m_name + "\"\n";
105  message += "Description: Builds a container for subalgorithms.\n";
106  message += "Parameters: none\n";
107 
108  std::cout << message;
109 }

Member Data Documentation

◆ m_name

std::string dqi::CompositeAlgorithm::m_name
protected

Definition at line 35 of file CompositeAlgorithm.h.

◆ m_subAlgs

AlgVec_t dqi::CompositeAlgorithm::m_subAlgs
protected

Definition at line 36 of file CompositeAlgorithm.h.


The documentation for this class was generated from the following files:
make_hlt_rep.pars
pars
Definition: make_hlt_rep.py:90
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
Undefined
@ Undefined
Definition: MaterialTypes.h:8
SGout2dot.alg
alg
Definition: SGout2dot.py:243
get_generator_info.result
result
Definition: get_generator_info.py:21
dqi::CompositeAlgorithm::ConfigureSubAlg
HanAlgorithmConfig * ConfigureSubAlg(const dqm_core::AlgorithmConfig &config, const std::string &subalg)
Definition: CompositeAlgorithm.cxx:149
dqi::CompositeAlgorithm::CompositeAlgorithm
CompositeAlgorithm(const CompositeAlgorithm &other)
Definition: CompositeAlgorithm.cxx:27
xAOD::JetAlgorithmType::algName
const std::string & algName(ID id)
Converts a JetAlgorithmType::ID into a string.
Definition: JetContainerInfo.cxx:67
python.CreateTierZeroArgdict.parname
parname
Definition: CreateTierZeroArgdict.py:194
python.FakeAthena.Algorithm
def Algorithm(name)
Definition: FakeAthena.py:41
ReweightUtils.message
message
Definition: ReweightUtils.py:15
config
Definition: PhysicsAnalysis/AnalysisCommon/AssociationUtils/python/config.py:1
instance
std::map< std::string, double > instance
Definition: Run_To_Get_Tags.h:8
tags
std::vector< std::string > tags
Definition: hcg.cxx:102
Result
ICscStripFitter::Result Result
Definition: CalibCscStripFitter.cxx:13
python.handimod.Green
int Green
Definition: handimod.py:524
dqi::CompositeAlgorithm::m_subAlgs
AlgVec_t m_subAlgs
Definition: CompositeAlgorithm.h:36
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
Athena::Status
Status
Athena specific StatusCode values.
Definition: AthStatusCode.h:22
ref
const boost::regex ref(r_ef)
dqi::CompositeAlgorithm::m_name
std::string m_name
Definition: CompositeAlgorithm.h:35
dqi::CompositeAlgorithm
Definition: CompositeAlgorithm.h:18
merge.status
status
Definition: merge.py:17