374 {
375 coral::AttributeList attr(*pSpec,true);
376 unsigned int s=attr.size();
377
378 json::const_iterator
it =
j.begin();
379 for (
unsigned int i(0);
i!=
s;++
i){
380
381
382 auto & att =
const_cast<coral::Attribute&
>(attr[
i]);
384 continue;
385 }
386 const auto thisVal =
it.value();
388
389 try{
390 if (thisVal.is_null()){
391 att.setNull();
392 continue;
393 }
394 cool::StorageType::TypeId typespec=cool::StorageType::Bool;
395 for(auto &p : tSpec){
396 if(
p.first.compare(att.specification().name())==0){
399 throw std::runtime_error("CoralCrestManager::createAttributeList: name not found.");
400 }
401 std::string str_spec = pElement ->second;
402 auto pTypespec = typeCorrespondance.find(str_spec);
403 if (pTypespec == typeCorrespondance.end()){
404 throw std::runtime_error("CoralCrestManager::createAttributeList: typespec not found.");
405 }
406 typespec=pTypespec->second;
407 break;
408 }
409 }
411 if(strVal.size()>2&& strVal[0]=='"'&& strVal[strVal.size()-1]=='"')
412 strVal=strVal.substr(1,strVal.size()-2);
413
414 if((strVal.compare("NULL")==0||strVal.compare("null")==0)&&
415 (typespec==cool::StorageType::Bool || typespec==cool::StorageType::Int16 || typespec==cool::StorageType::UInt16
416 || typespec==cool::StorageType::Int32 || typespec==cool::StorageType::UInt32
417 || typespec==cool::StorageType::Int64 || typespec==cool::StorageType::UInt63
418 || typespec==cool::StorageType::Float || typespec==cool::StorageType::Double)){
419 att.setNull();
420 continue;
421 }
422 switch (typespec) {
423 case cool::StorageType::Bool:
424 {
425 const bool newVal=(strVal == "true");
426 att.setValue<bool>(newVal);
427 break;
428 }
429 case cool::StorageType::UChar:
430 {
431 const unsigned char newVal=std::stoul(strVal);
432 att.setValue<unsigned char>(newVal);
433 break;
434 }
435 case cool::StorageType::Int16:
436 {
437 const short newVal=std::stol(strVal);
438 att.setValue<short>(newVal);
439 break;
440 }
441 case cool::StorageType::UInt16:
442 {
443 const unsigned short newVal=std::stoul(strVal);
444 att.setValue<unsigned short>(newVal);
445 break;
446 }
447 case cool::StorageType::Int32:
448 {
449 const int newVal=std::stoi(strVal);
450 att.setValue<int>(newVal);
451 break;
452 }
453 case cool::StorageType::UInt32:
454 {
455 const unsigned int newVal=std::stoull(strVal);
456 att.setValue<unsigned int>(newVal);
457 break;
458 }
459 case cool::StorageType::UInt63:
460 {
461 const unsigned long long newVal=std::stoull(strVal);
462 att.setValue<unsigned long long>(newVal);
463 break;
464 }
465 case cool::StorageType::Int64:
466 {
467 const long long newVal=std::stoll(strVal);
468 att.setValue< long long>(newVal);
469 break;
470 }
471 case cool::StorageType::Float:
472 {
473 const float newVal=std::stof(strVal);
474 att.setValue<float>(newVal);
475 break;
476 }
477 case cool::StorageType::Double:
478 {
479 const double newVal=std::stod(strVal);
480 att.setValue<double>(newVal);
481 break;
482 }
483 case cool::StorageType::String255:
484 case cool::StorageType::String4k:
485 case cool::StorageType::String64k:
486 case cool::StorageType::String16M:
487 case cool::StorageType::String128M:
488 {
489 att.setValue<std::string>(thisVal.get<std::string>());
490 break;
491 }
492 case cool::StorageType::Blob128M:
493 case cool::StorageType::Blob16M:
494 case cool::StorageType::Blob64k:
495 {
497 coral::Blob
blob(charVec.size());
498 memcpy(
blob.startingAddress(), charVec.data(), charVec.size());
499 att.setValue<coral::Blob>(
blob);
500 break;
501 }
502 default:
503 {
504 std::string errorMessage("UNTREATED TYPE! " + std::to_string(typespec));
506 gLog << MSG::ERROR <<
"LoadPayloadForHash:" <<errorMessage<<
endmsg;
507 throw std::runtime_error(errorMessage);
508 }
509 }
510 }
511 catch (json::exception& e){
513 gLog << MSG::ERROR <<
"Error CoralCrestManager::createAttributeList: "<<
e.what()<<
endmsg;
514 throw std::runtime_error(
e.what());
515 }
516 }
517 return attr;
518 }
IMessageSvc * getMessageSvc(bool quiet=false)
static const std::map< TypeId, std::string > s_typeToString
std::vector< unsigned char > base64_decode(const std::string &)
float j(const xAOD::IParticle &, const xAOD::TrackMeasurementValidation &hit, const Eigen::Matrix3d &jab_inv)