Create extra data dependencies arising eventually from the given variables.
252 {
253 (void) new_output_handles;
255 for (const std::string &var_name : var_names) {
257 std::string container_name;
258 std::string method_name;
261 std::cout <<
"DEBUG SGxAODProxyLoader::updateDataDependencies var " <<
var_name <<
" -> " << container_name <<
" . " << method_name
262 << " i:" << input_data_in.size() << " o:" << output_data_in.size()
263 << std::endl;
264 }
265 const DataObjID *container_data_id=nullptr;
266 const DataObjID *method_data_id=nullptr;
268
269
270
271
272
273
274
275 auto set_ids = [&method_data_id,&container_data_id,&
var_name,&container_name,
verbose](
const DataObjID *obj_data_id) ->
bool {
276 std::string_view handle_key(obj_data_id->key());
277 std::string::size_type
pos=obj_data_id->key().find(
'+');
278 pos = (
pos==std::string::npos ? 0 :
pos+1);
279 handle_key=handle_key.substr(pos,handle_key.size()-pos);
280 if (
verbose && (handle_key == container_name || handle_key == var_name)) {
282 std::cout <<
"DEBUG SGxAODProxyLoader::updateDataDependencies " << handle_key <<
" matches " <<
var_name <<
" ? "
283 << (handle_key ==
var_name ?
" method " :
"")
284 << (handle_key == container_name ? " container " : "")
285 <<
"-> " << (base_info ? base_info->
typeinfo().
name() :
"")
286 << std::endl;
287 }
288 if (handle_key == var_name) {
289 method_data_id = obj_data_id;
290 if (container_data_id) return true;
291 }
292 else if (handle_key == container_name ) {
293 container_data_id = obj_data_id;
294 if (method_data_id) return true;
295 }
296 return false;
297 };
298
299 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) {}
300 if (!method_data_id) {
301 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) {}
302 }
303 if (method_data_id) {
304 if (!container_data_id) {
305 container_data_id=method_data_id;
306 }
307 }
308
309 if (
m_verbose && method_data_id && method_data_id != container_data_id) {
310 std::cout << "DEBUG SGxAODProxyLoader method_clid " << method_data_id->clid() << std::endl;
311 }
313 std::cout << "DEBUG SGxAODProxyLoader container_clid " << container_data_id->clid() << std::endl;
314 }
315
316
317 if (container_data_id) {
318 m_accessor.insert( std::make_pair(var_name, CxxUtils::CachedUniquePtrT<IAccessor>()));
320 if (have_container_read_key && !method_data_id) continue;
321
322 auto clid = container_data_id->clid();
323 (void) clid;
324
326 if (!base_info) {
327 std::stringstream
msg;
328 msg <<
"Missing type information about container " << container_name <<
".";
329 if (container_data_id) {
330 msg <<
" It seems that inheritance information is missing for " << container_data_id->className() <<
"."
331 << " Only container which inherit from SG::AuxVectorBase or data inheriting from SG::AuxElement "
332 << " are supported by the SGxAODProxyLoader loader.";
333 }
334 else {
335 msg <<
" This problem may occur if the container is read from the input"
336 << " file and not accessed anywhere in the job via read handles. ";
337 }
338 throw std::runtime_error(
msg.str());
339 }
340
342 std::cout <<
"DEBUG SGxAODProxyLoader " << container_name <<
" -> " << base_info->
typeinfo().name() << std::endl;
345 std::cout <<
"DEBUG SGxAODProxyLoader " << container_name <<
" base: " << a_base_info->
typeinfo().name() << std::endl;
346 }
347 }
348
349
350
351 std::any read_key;
352 std::any decor_key;
354 if (!have_container_read_key) {
355 read_key = std::make_any<SG::ReadHandleKey<SG::AuxVectorBase> >(container_name);
356 }
357 if (method_data_id) {
358 decor_key = std::make_any<SG::ReadDecorHandleKey<SG::AuxVectorBase> >(
var_name);
359 }
360 }
362 if (!have_container_read_key) {
363 read_key = std::make_any<SG::ReadHandleKey<SG::AuxElement> >(container_name);
364 }
365 if (method_data_id) {
366 decor_key = std::make_any<SG::ReadDecorHandleKey<SG::AuxElement> >(
var_name);
367 }
368 }
369 else {
370 if (method_data_id && method_data_id != container_data_id && method_data_id->clid() != container_data_id->clid()) {
371 std::stringstream
msg;
372 msg <<
"Did not expect a \"method\" handle for the plain type " <<
var_name;
373 throw std::logic_error(
msg.str());
374 }
376 if (registered_key) {
377 popRenounced(renounce, new_input_handles);
378 continue;
379 }
380 }
381
382 if (!have_container_read_key) {
383 if (!read_key.has_value()) {
384 std::stringstream
msg;
385 msg <<
"Container " << container_name <<
" is of unsupported type " << base_info->
typeinfo().name()
386 << " expected a type derived from SG::AuxVectorBase or SG::AuxElement";
387 throw std::runtime_error(
msg.str());
388 }
389 std::pair<ReadHandleMap::iterator, bool> ret =
m_readKeys.insert(std::make_pair(container_name, std::move(read_key)));
390 if (ret.second) {
393 std::stringstream
msg;
394 msg <<
"Failed to add read handle key for " << container_name;
395 throw std::runtime_error(
msg.str());
396 }
400 }
403 popRenounced(renounce, new_input_handles);
404
405 }
406 }
407 if (method_data_id) {
408 if (!decor_key.has_value()) {
409 std::stringstream
msg;
410 msg <<
"Container " << container_name <<
" is of unsupported type " << base_info->
typeinfo().name()
411 << " expected a type derived from SG::AuxVectorBase or SG::AuxElement";
412 throw std::runtime_error(
msg.str());
413 }
414 std::pair<ReadDecorHandleMap::iterator, bool> ret =
m_decorKeys.insert(std::make_pair(var_name,std::move(decor_key)));
415 if (ret.second) {
418 std::stringstream
msg;
419 msg <<
"Failed to add read decor handle key for " <<
var_name;
420 throw std::runtime_error(
msg.str());
421 }
425 }
428 popRenounced(renounce, new_input_handles);
429 }
430 }
431 }
432 }
434 }
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.
static constexpr CLID ID()