ATLAS Offline Software
Loading...
Searching...
No Matches
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::Result * execute (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 25 of file CompositeAlgorithm.cxx.

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

◆ CompositeAlgorithm() [2/2]

dqi::CompositeAlgorithm::CompositeAlgorithm ( HanConfigCompAlg & compAlg)

Definition at line 40 of file CompositeAlgorithm.cxx.

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

◆ ~CompositeAlgorithm()

dqi::CompositeAlgorithm::~CompositeAlgorithm ( )
virtual

Definition at line 74 of file CompositeAlgorithm.cxx.

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

Member Function Documentation

◆ clone()

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

Definition at line 88 of file CompositeAlgorithm.cxx.

90{
91 dqi::CompositeAlgorithm* result = new CompositeAlgorithm(*this);
92 return result;
93}
CompositeAlgorithm(const CompositeAlgorithm &other)

◆ ConfigureSubAlg()

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

Definition at line 145 of file CompositeAlgorithm.cxx.

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

◆ execute()

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

Definition at line 111 of file CompositeAlgorithm.cxx.

113{
114 dqm_core::Result::Status status(dqm_core::Result::Undefined);
115 std::map<std::string,double> tags;
116
117 AlgVec_t::const_iterator subAlgsEnd = m_subAlgs.end();
118 AlgVec_t::const_iterator subAlgsIter = m_subAlgs.begin();
119 for( ; subAlgsIter != subAlgsEnd; ++subAlgsIter ) {
120 std::unique_ptr<HanAlgorithmConfig> subConfig(ConfigureSubAlg(config, subAlgsIter->second));
121
122 dqm_core::Algorithm* alg = subAlgsIter->first;
123 dqm_core::Result* subResult = alg->execute( name, data, *subConfig );
124 if( subResult->status_ != dqm_core::Result::Undefined ) {
125 status = ( status == dqm_core::Result::Undefined ) ? dqm_core::Result::Green : status;
126 status = ( subResult->status_ < status ) ? subResult->status_ : status;
127 }
128
129 std::map<std::string,double>::const_iterator tagsEnd = subResult->tags_.end();
130 std::map<std::string,double>::const_iterator tagsIter = subResult->tags_.begin();
131 for( ; tagsIter != tagsEnd; ++tagsIter ) {
132 std::map<std::string,double>::value_type tagVal( subAlgsIter->second + std::string("|") + tagsIter->first, tagsIter->second );
133 tags.insert( std::move(tagVal) );
134 }
135 delete subResult;
136 }
137
138 dqm_core::Result* result = new dqm_core::Result( status );
139 result->tags_ = std::move(tags);
140
141 return result;
142}
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
HanAlgorithmConfig * ConfigureSubAlg(const dqm_core::AlgorithmConfig &config, const std::string &subalg)
std::vector< std::string > tags
Definition hcg.cxx:105
status
Definition merge.py:16

◆ printDescription()

void dqi::CompositeAlgorithm::printDescription ( )
virtual

Definition at line 97 of file CompositeAlgorithm.cxx.

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

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: