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