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