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