Create extra data dependencies arising eventually from the given variables.
250 {
251 (void) new_output_handles;
253 for (const std::string &var_name : var_names) {
255 std::string container_name;
256 std::string method_name;
259 std::cout <<
"DEBUG SGxAODProxyLoader::updateDataDependencies var " <<
var_name <<
" -> " << container_name <<
" . " << method_name
260 << " i:" << input_data_in.size() << " o:" << output_data_in.size()
261 << std::endl;
262 }
263 const DataObjID *container_data_id=nullptr;
264 const DataObjID *method_data_id=nullptr;
266
267
268
269
270
271
272
273 auto set_ids = [&method_data_id,&container_data_id,&
var_name,&container_name,
verbose](
const DataObjID *obj_data_id) ->
bool {
274 std::string_view handle_key(obj_data_id->key());
275 std::string::size_type
pos=obj_data_id->key().find(
'+');
276 pos = (
pos==std::string::npos ? 0 :
pos+1);
277 handle_key=handle_key.substr(pos,handle_key.size()-pos);
278 if (
verbose && (handle_key == container_name || handle_key == var_name)) {
280 std::cout <<
"DEBUG SGxAODProxyLoader::updateDataDependencies " << handle_key <<
" matches " <<
var_name <<
" ? "
281 << (handle_key ==
var_name ?
" method " :
"")
282 << (handle_key == container_name ? " container " : "")
283 <<
"-> " << (base_info ? base_info->
typeinfo().
name() :
"")
284 << std::endl;
285 }
286 if (handle_key == var_name) {
287 method_data_id = obj_data_id;
288 if (container_data_id) return true;
289 }
290 else if (handle_key == container_name ) {
291 container_data_id = obj_data_id;
292 if (method_data_id) return true;
293 }
294 return false;
295 };
296
297 for( std::vector<const DataObjID *>::const_iterator elm_iter = output_data_in.begin(); elm_iter != output_data_in.end() && !set_ids(*elm_iter); ++elm_iter) {}
298 if (!method_data_id) {
299 for( std::vector<const DataObjID *>::const_iterator elm_iter = input_data_in.begin(); elm_iter != input_data_in.end() && !set_ids(*elm_iter); ++elm_iter) {}
300 }
301 if (method_data_id) {
302 if (!container_data_id) {
303 container_data_id=method_data_id;
304 }
305 }
306
307 if (
m_verbose && method_data_id && method_data_id != container_data_id) {
308 std::cout << "DEBUG SGxAODProxyLoader method_clid " << method_data_id->clid() << std::endl;
309 }
311 std::cout << "DEBUG SGxAODProxyLoader container_clid " << container_data_id->clid() << std::endl;
312 }
313
314
315 if (container_data_id) {
316 m_accessor.insert( std::make_pair(var_name, CxxUtils::CachedUniquePtrT<IAccessor>()));
318 if (have_container_read_key && !method_data_id) continue;
319
320 auto clid = container_data_id->clid();
321 (void) clid;
322 const SG::BaseInfoBase* base_info = (container_data_id ?
SG::BaseInfoBase::find (container_data_id->clid()) : nullptr);
323 if (!base_info) {
324 std::stringstream
msg;
325 msg <<
"Missing type information about container " << container_name <<
".";
326 if (container_data_id) {
327 msg <<
" It seems that inheritance information is missing for " << container_data_id->className() <<
"."
328 << " Only container which inherit from SG::AuxVectorBase or data inheriting from SG::AuxElement "
329 << " are supported by the SGxAODProxyLoader loader.";
330 }
331 else {
332 msg <<
" This problem may occur if the container is read from the input"
333 << " file and not accessed anywhere in the job via read handles. ";
334 }
335 throw std::runtime_error(
msg.str());
336 }
337
339 std::cout <<
"DEBUG SGxAODProxyLoader " << container_name <<
" -> " << base_info->
typeinfo().name() << std::endl;
342 std::cout <<
"DEBUG SGxAODProxyLoader " << container_name <<
" base: " << a_base_info->
typeinfo().name() << std::endl;
343 }
344 }
345
346
347
348 std::any read_key;
349 std::any decor_key;
351 if (!have_container_read_key) {
352 read_key = std::make_any<SG::ReadHandleKey<SG::AuxVectorBase> >(container_name);
353 }
354 if (method_data_id) {
355 decor_key = std::make_any<SG::ReadDecorHandleKey<SG::AuxVectorBase> >(
var_name);
356 }
357 }
359 if (!have_container_read_key) {
360 read_key = std::make_any<SG::ReadHandleKey<SG::AuxElement> >(container_name);
361 }
362 if (method_data_id) {
363 decor_key = std::make_any<SG::ReadDecorHandleKey<SG::AuxElement> >(
var_name);
364 }
365 }
366 else {
367 if (method_data_id && method_data_id != container_data_id && method_data_id->clid() != container_data_id->clid()) {
368 std::stringstream
msg;
369 msg <<
"Did not expect a \"method\" handle for the plain type " <<
var_name;
370 throw std::logic_error(
msg.str());
371 }
373 if (registered_key) {
374 popRenounced(renounce, new_input_handles);
375 continue;
376 }
377 }
378
379 if (!have_container_read_key) {
380 if (!read_key.has_value()) {
381 std::stringstream
msg;
382 msg <<
"Container " << container_name <<
" is of unsupported type " << base_info->
typeinfo().name()
383 << " expected a type derived from SG::AuxVectorBase or SG::AuxElement";
384 throw std::runtime_error(
msg.str());
385 }
386 std::pair<ReadHandleMap::iterator, bool> ret =
m_readKeys.insert(std::make_pair(container_name, std::move(read_key)));
387 if (ret.second) {
390 std::stringstream
msg;
391 msg <<
"Failed to add read handle key for " << container_name;
392 throw std::runtime_error(
msg.str());
393 }
397 }
400 popRenounced(renounce, new_input_handles);
401
402 }
403 }
404 if (method_data_id) {
405 if (!decor_key.has_value()) {
406 std::stringstream
msg;
407 msg <<
"Container " << container_name <<
" is of unsupported type " << base_info->
typeinfo().name()
408 << " expected a type derived from SG::AuxVectorBase or SG::AuxElement";
409 throw std::runtime_error(
msg.str());
410 }
411 std::pair<ReadDecorHandleMap::iterator, bool> ret =
m_decorKeys.insert(std::make_pair(var_name,std::move(decor_key)));
412 if (ret.second) {
415 std::stringstream
msg;
416 msg <<
"Failed to add read decor handle key for " <<
var_name;
417 throw std::runtime_error(
msg.str());
418 }
422 }
425 popRenounced(renounce, new_input_handles);
426 }
427 }
428 }
429 }
431 }
uint32_t CLID
The Class ID type.
static bool registerReadKey(std::unordered_map< std::string, std::any > &read_keys, SGxAODProxyLoader::IParentHelper &parent, const std::string &var_name, std::vector< Gaudi::DataHandle * > &new_input_handles, bool verbose)
static const BaseInfoBase * find(CLID clid)
Find the BaseInfoBase instance for clid.
const std::type_info & typeinfo() const
Return the std::type_info for this class.
const std::vector< CLID > & get_bases() const
Return the class IDs of all known bases of T (that have class IDs).
bool is_base(CLID clid) const
Return true if clid is the ID of a class that is known to be a base of T.
void initializeHandle(T_Key *key, std::vector< Gaudi::DataHandle * > &new_input_handles)
Auxiliary function to initialize newly create data handles.
void dumpDeclare(const T *key)
Function for debugging which dumps information about newly declared data handles.