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