2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
5 #include "Identifier/IdentifierHash.h"
6 template< class IDC, class IDHELPER >
8 typename IDC::IDENTIFIABLE*
9 Muon::IDC_Helper::getCollection ATLAS_NOT_THREAD_SAFE
10 ( const Identifier collId, IDC* idc, const IDHELPER& idHelper, MsgStream& log)
12 IdentifierHash idHash;
13 if (idHelper.get_module_hash( collId, idHash )) {
14 log << MSG::ERROR << "Unable to get CSC hash id from CSC RDO collection "
15 << " the identifier is "
20 typename IDC::IDENTIFIABLE* collection=0;
21 auto collptr = idc->indexFindPtr(idHash);
22 if (collptr == nullptr) {
23 collection = new typename IDC::IDENTIFIABLE(idHash);
24 collection->setIdentifier(collId);
25 StatusCode status = idc->addCollection(collection, idHash );
26 if (status.isFailure())
27 log << MSG::ERROR << "Couldn't add collection to IDC" << endmsg;
29 //Use naughtyRetrieve to protect external caches from modification
30 StatusCode status = idc->naughtyRetrieve(idHash, collection);
31 if (status.isFailure())
32 log << MSG::ERROR << "Attempt to get unsafe access to external cache" << endmsg;
38 template< class IDC, class IDHELPER >
39 typename IDC::IDENTIFIABLE*
40 Muon::IDC_Helper::addCollection( const Identifier collId, IDC* idc, const IDHELPER& idHelper, MsgStream& log){
41 IdentifierHash idHash;
42 if (idHelper.get_module_hash( collId, idHash )) {
43 log << MSG::ERROR << "Unable to get CSC hash id from CSC RDO collection "
44 << " the identifier is "
49 std::unique_ptr<typename IDC::IDENTIFIABLE> collection;
50 auto collptr = idc->indexFindPtr(idHash);
51 if (collptr == nullptr) {
52 collection = std::make_unique<typename IDC::IDENTIFIABLE>(idHash);
53 collection->setIdentifier(collId);
54 StatusCode status = idc->addCollection(collection.get(), idHash );
55 if (status.isFailure()) {
57 if (idc->indexFindPtr(idHash)) {
58 log << MSG::ERROR << "Attempt to get unsafe access to external cache" << endmsg;
61 log << MSG::ERROR << "Couldn't add collection to IDC" << endmsg;
65 log << MSG::ERROR << "Attempt to get unsafe access to external cache" << endmsg;
67 return collection.release();