#include <EDConsumerBase.h>
Classes | |
struct | LabelPlacement |
struct | Labels |
struct | TokenLookupInfo |
Public Member Functions | |
EDConsumerBase () | |
ProductHolderIndex | indexFrom (EDGetToken, BranchType, TypeID const &) const |
void | itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const |
void | itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const |
void | labelsForToken (EDGetToken iToken, Labels &oLabels) const |
void | updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &) |
virtual | ~EDConsumerBase () |
Protected Member Functions | |
template<typename ProductType , BranchType B = InEvent> | |
EDGetTokenT< ProductType > | consumes (edm::InputTag const &tag) |
template<BranchType B> | |
EDGetToken | consumes (TypeToGet const &id, edm::InputTag const &tag) |
EDGetToken | consumes (const TypeToGet &id, edm::InputTag const &tag) |
ConsumesCollector | consumesCollector () |
Use a ConsumesCollector to gather consumes information from helper functions. | |
template<typename ProductType , BranchType B = InEvent> | |
void | consumesMany () |
template<BranchType B> | |
void | consumesMany (const TypeToGet &id) |
void | consumesMany (const TypeToGet &id) |
template<typename ProductType , BranchType B = InEvent> | |
EDGetTokenT< ProductType > | mayConsume (edm::InputTag const &tag) |
template<BranchType B> | |
EDGetToken | mayConsume (const TypeToGet &id, edm::InputTag const &tag) |
EDGetToken | mayConsume (const TypeToGet &id, edm::InputTag const &tag) |
Private Types | |
enum | { kLookupInfo, kAlwaysGets, kLabels, kKind } |
Private Member Functions | |
EDConsumerBase (const EDConsumerBase &) | |
const EDConsumerBase & | operator= (const EDConsumerBase &) |
unsigned int | recordConsumes (BranchType iBranch, TypeToGet const &iType, edm::InputTag const &iTag, bool iAlwaysGets) |
void | throwBadToken (edm::TypeID const &iType, EDGetToken iToken) const |
void | throwBranchMismatch (BranchType, EDGetToken) const |
void | throwTypeMismatch (edm::TypeID const &, EDGetToken) const |
Private Attributes | |
edm::SoATuple< TokenLookupInfo, bool, LabelPlacement, edm::KindOfType > | m_tokenInfo |
std::vector< char > | m_tokenLabels |
Friends | |
class | ConsumesCollector |
Definition at line 42 of file EDConsumerBase.h.
anonymous enum [private] |
Definition at line 155 of file EDConsumerBase.h.
edm::EDConsumerBase::EDConsumerBase | ( | ) | [inline] |
Definition at line 46 of file EDConsumerBase.h.
{}
EDConsumerBase::~EDConsumerBase | ( | ) | [virtual] |
Definition at line 47 of file EDConsumerBase.cc.
{ }
edm::EDConsumerBase::EDConsumerBase | ( | const EDConsumerBase & | ) | [private] |
EDGetTokenT<ProductType> edm::EDConsumerBase::consumes | ( | edm::InputTag const & | tag | ) | [inline, protected] |
Definition at line 74 of file EDConsumerBase.h.
References recordConsumes(), and edm::InputTag::willSkipCurrentProcess().
Referenced by edm::ConsumesCollector::consumes(), and edm::OutputModule::selectProducts().
{ TypeToGet tid=TypeToGet::make<ProductType>(); return EDGetTokenT<ProductType>{recordConsumes(B,tid, tag,true), tag.willSkipCurrentProcess()}; }
EDGetToken edm::EDConsumerBase::consumes | ( | const TypeToGet & | id, |
edm::InputTag const & | tag | ||
) | [inline, protected] |
Definition at line 79 of file EDConsumerBase.h.
References edm::InEvent, recordConsumes(), and edm::InputTag::willSkipCurrentProcess().
{ return EDGetToken{recordConsumes(InEvent,id,tag,true), tag.willSkipCurrentProcess()}; }
EDGetToken edm::EDConsumerBase::consumes | ( | TypeToGet const & | id, |
edm::InputTag const & | tag | ||
) | [inline, protected] |
Definition at line 84 of file EDConsumerBase.h.
References recordConsumes(), and edm::InputTag::willSkipCurrentProcess().
{ return EDGetToken{recordConsumes(B,id,tag,true), tag.willSkipCurrentProcess()}; }
ConsumesCollector EDConsumerBase::consumesCollector | ( | ) | [protected] |
Use a ConsumesCollector to gather consumes information from helper functions.
Definition at line 67 of file EDConsumerBase.cc.
References trackerHits::c.
{ ConsumesCollector c{this}; return std::move(c); }
void edm::EDConsumerBase::consumesMany | ( | ) | [inline, protected] |
Definition at line 105 of file EDConsumerBase.h.
Referenced by edm::ConsumesCollector::consumesMany().
{ TypeToGet tid=TypeToGet::make<ProductType>(); consumesMany<B>(tid); }
void edm::EDConsumerBase::consumesMany | ( | const TypeToGet & | id | ) | [inline, protected] |
Definition at line 111 of file EDConsumerBase.h.
{ consumesMany<InEvent>(id); }
void edm::EDConsumerBase::consumesMany | ( | const TypeToGet & | id | ) | [inline, protected] |
Definition at line 116 of file EDConsumerBase.h.
References recordConsumes().
{ recordConsumes(B,id,edm::InputTag{},true); }
ProductHolderIndex EDConsumerBase::indexFrom | ( | EDGetToken | iToken, |
BranchType | iBranch, | ||
TypeID const & | iType | ||
) | const |
Definition at line 172 of file EDConsumerBase.cc.
References edm::SoATuple< Args >::get(), info, kLookupInfo, likely, m_tokenInfo, edm::ProductHolderIndexInvalid, edm::SoATuple< Args >::size(), throwBadToken(), throwBranchMismatch(), throwTypeMismatch(), and unlikely.
{ if(unlikely(iToken.index()>=m_tokenInfo.size())) { throwBadToken(iType,iToken); } const auto& info = m_tokenInfo.get<kLookupInfo>(iToken.index()); if (likely(iBranch == info.m_branchType)) { if (likely(iType == info.m_type)) { return info.m_index; } else { throwTypeMismatch(iType, iToken); } } else { throwBranchMismatch(iBranch,iToken); } return edm::ProductHolderIndexInvalid; }
void EDConsumerBase::itemsMayGet | ( | BranchType | iBranch, |
std::vector< ProductHolderIndex > & | oIndices | ||
) | const |
Definition at line 227 of file EDConsumerBase.cc.
References edm::SoATuple< Args >::begin(), prof2calltree::count, edm::SoATuple< Args >::end(), kAlwaysGets, kLookupInfo, m_tokenInfo, and edm::ProductHolderIndexInvalid.
{ //how many are we adding? unsigned int count=0; { auto itAlwaysGet = m_tokenInfo.begin<kAlwaysGets>(); for(auto it = m_tokenInfo.begin<kLookupInfo>(), itEnd = m_tokenInfo.end<kLookupInfo>(); it != itEnd; ++it,++itAlwaysGet) { if(iBranch==it->m_branchType) { if (it->m_index != ProductHolderIndexInvalid) { if(not *itAlwaysGet) { ++count; } } } } } oIndices.reserve(oIndices.size()+count); { auto itAlwaysGet = m_tokenInfo.begin<kAlwaysGets>(); for(auto it = m_tokenInfo.begin<kLookupInfo>(), itEnd = m_tokenInfo.end<kLookupInfo>(); it != itEnd; ++it,++itAlwaysGet) { if(iBranch==it->m_branchType) { if (it->m_index != ProductHolderIndexInvalid) { if(not *itAlwaysGet) { oIndices.push_back(it->m_index); } } } } } }
void EDConsumerBase::itemsToGet | ( | BranchType | iBranch, |
std::vector< ProductHolderIndex > & | oIndices | ||
) | const |
Definition at line 191 of file EDConsumerBase.cc.
References edm::SoATuple< Args >::begin(), prof2calltree::count, edm::SoATuple< Args >::end(), kAlwaysGets, kLookupInfo, m_tokenInfo, and edm::ProductHolderIndexInvalid.
{ //how many are we adding? unsigned int count=0; { auto itAlwaysGet = m_tokenInfo.begin<kAlwaysGets>(); for(auto it = m_tokenInfo.begin<kLookupInfo>(), itEnd = m_tokenInfo.end<kLookupInfo>(); it != itEnd; ++it,++itAlwaysGet) { if(iBranch==it->m_branchType) { if (it->m_index != ProductHolderIndexInvalid) { if(*itAlwaysGet) { ++count; } } } } } oIndices.reserve(oIndices.size()+count); { auto itAlwaysGet = m_tokenInfo.begin<kAlwaysGets>(); for(auto it = m_tokenInfo.begin<kLookupInfo>(), itEnd = m_tokenInfo.end<kLookupInfo>(); it != itEnd; ++it,++itAlwaysGet) { if(iBranch==it->m_branchType) { if (it->m_index != ProductHolderIndexInvalid) { if(*itAlwaysGet) { oIndices.push_back(it->m_index); } } } } } }
void EDConsumerBase::labelsForToken | ( | EDGetToken | iToken, |
Labels & | oLabels | ||
) | const |
Definition at line 263 of file EDConsumerBase.cc.
References edm::SoATuple< Args >::get(), getHLTprescales::index, kLabels, reco_calib_source_client_cfg::labels, m_tokenInfo, m_tokenLabels, edm::EDConsumerBase::Labels::module, edm::EDConsumerBase::Labels::process, edm::EDConsumerBase::Labels::productInstance, and dqm_diff::start.
{ unsigned int index = iToken.index(); auto labels = m_tokenInfo.get<kLabels>(index); unsigned int start = labels.m_startOfModuleLabel; oLabels.module = &(m_tokenLabels[start]); oLabels.productInstance = oLabels.module+labels.m_deltaToProductInstance; oLabels.process = oLabels.module+labels.m_deltaToProcessName; }
EDGetToken edm::EDConsumerBase::mayConsume | ( | const TypeToGet & | id, |
edm::InputTag const & | tag | ||
) | [inline, protected] |
Definition at line 95 of file EDConsumerBase.h.
References GlobalPosition_Frontier_DevDB_cff::tag.
{ return mayConsume<InEvent>(id,tag); }
EDGetTokenT<ProductType> edm::EDConsumerBase::mayConsume | ( | edm::InputTag const & | tag | ) | [inline, protected] |
Definition at line 89 of file EDConsumerBase.h.
References recordConsumes(), and edm::InputTag::willSkipCurrentProcess().
Referenced by edm::ConsumesCollector::mayConsume().
{ TypeToGet tid=TypeToGet::make<ProductType>(); return EDGetTokenT<ProductType>{recordConsumes(B,tid, tag,false), tag.willSkipCurrentProcess()}; }
EDGetToken edm::EDConsumerBase::mayConsume | ( | const TypeToGet & | id, |
edm::InputTag const & | tag | ||
) | [inline, protected] |
Definition at line 100 of file EDConsumerBase.h.
References recordConsumes(), and edm::InputTag::willSkipCurrentProcess().
{ return EDGetToken{recordConsumes(B,id,tag,false), tag.willSkipCurrentProcess()}; }
const EDConsumerBase& edm::EDConsumerBase::operator= | ( | const EDConsumerBase & | ) | [private] |
unsigned int EDConsumerBase::recordConsumes | ( | BranchType | iBranch, |
TypeToGet const & | iType, | ||
edm::InputTag const & | iTag, | ||
bool | iAlwaysGets | ||
) | [private] |
Definition at line 74 of file EDConsumerBase.cc.
References edm::SoATuple< Args >::emplace_back(), getHLTprescales::index, edm::InputTag::instance(), edm::TypeToGet::kind(), edm::InputTag::label(), m, m_tokenInfo, m_tokenLabels, edm::InputTag::process(), edm::ProductHolderIndexInvalid, edm::SoATuple< Args >::size(), AlCaHLTBitMon_QueryRunRegistry::string, edm::TypeToGet::type(), and edm::InputTag::willSkipCurrentProcess().
Referenced by consumes(), consumesMany(), and mayConsume().
{ unsigned int index =m_tokenInfo.size(); const size_t labelSize = iTag.label().size(); const size_t productInstanceSize = iTag.instance().size(); unsigned int labelStart = m_tokenLabels.size(); unsigned short delta1 = labelSize+1; unsigned short delta2 = labelSize+2+productInstanceSize; m_tokenInfo.emplace_back(TokenLookupInfo{iType.type(),ProductHolderIndexInvalid,iBranch}, iAlwaysGets, LabelPlacement{labelStart,delta1,delta2}, iType.kind()); bool skipCurrentProcess = iTag.willSkipCurrentProcess(); const size_t additionalSize = skipCurrentProcess ? labelSize+productInstanceSize+3 : labelSize+productInstanceSize+iTag.process().size()+3; m_tokenLabels.reserve(m_tokenLabels.size()+additionalSize); { const std::string& m =iTag.label(); m_tokenLabels.insert(m_tokenLabels.end(),m.begin(),m.end()); m_tokenLabels.push_back('\0'); } { const std::string& m =iTag.instance(); m_tokenLabels.insert(m_tokenLabels.end(),m.begin(),m.end()); m_tokenLabels.push_back('\0'); } { if (!skipCurrentProcess) { const std::string& m =iTag.process(); m_tokenLabels.insert(m_tokenLabels.end(),m.begin(),m.end()); m_tokenLabels.push_back('\0'); } else { m_tokenLabels.push_back('\0'); } } return index; }
void EDConsumerBase::throwBadToken | ( | edm::TypeID const & | iType, |
EDGetToken | iToken | ||
) | const [private] |
Definition at line 285 of file EDConsumerBase.cc.
References edm::TypeID::className(), and Exception.
Referenced by indexFrom().
{ if(iToken.isUnitialized()) { throw cms::Exception("BadToken")<<"A get using a EDGetToken with the C++ type '"<<iType.className()<<"' was made using an uninitialized token.\n Please check that the variable is being initialized from a 'consumes' call."; } throw cms::Exception("BadToken")<<"A get using a EDGetToken with the C++ type '"<<iType.className()<<"' was made using a token with a value "<<iToken.index()<<" which is beyond the range used by this module.\n Please check that the variable is being initialized from a 'consumes' call from this module.\n You can not share EDGetToken values between modules."; }
void EDConsumerBase::throwBranchMismatch | ( | BranchType | iBranch, |
EDGetToken | iToken | ||
) | const [private] |
Definition at line 280 of file EDConsumerBase.cc.
References edm::BranchTypeToString(), Exception, edm::SoATuple< Args >::get(), kLookupInfo, and m_tokenInfo.
Referenced by indexFrom().
{ throw cms::Exception("BranchTypeMismatch")<<"A get using a EDGetToken was done in "<<BranchTypeToString(iBranch)<<" but the consumes call was for "<<BranchTypeToString(m_tokenInfo.get<kLookupInfo>(iToken.index()).m_branchType)<<".\n Please modify the consumes call to use the correct branch type."; }
void EDConsumerBase::throwTypeMismatch | ( | edm::TypeID const & | iType, |
EDGetToken | iToken | ||
) | const [private] |
Definition at line 275 of file EDConsumerBase.cc.
References edm::TypeID::className(), Exception, edm::SoATuple< Args >::get(), kLookupInfo, and m_tokenInfo.
Referenced by indexFrom().
{ throw cms::Exception("TypeMismatch")<<"A get using a EDGetToken used the C++ type '"<<iType.className()<<"' but the consumes call was for type '"<<m_tokenInfo.get<kLookupInfo>(iToken.index()).m_type.className()<<"'.\n Please modify either the consumes or get call so the types match."; }
void EDConsumerBase::updateLookup | ( | BranchType | iBranchType, |
ProductHolderIndexHelper const & | iHelper | ||
) |
Definition at line 118 of file EDConsumerBase.cc.
References edm::SoATuple< Args >::begin(), edm::SoATuple< Args >::emplace_back(), edm::SoATuple< Args >::end(), edm::SoATuple< Args >::get(), i, getHLTprescales::index, edm::ProductHolderIndexHelper::index(), info, j, kAlwaysGets, kKind, kLabels, kLookupInfo, reco_calib_source_client_cfg::labels, m_tokenInfo, m_tokenLabels, edm::ProductHolderIndexInvalid, edm::ProductHolderIndexHelper::relatedIndexes(), edm::SoATuple< Args >::shrink_to_fit(), and edm::SoATuple< Args >::size().
{ { auto itKind = m_tokenInfo.begin<kKind>(); auto itLabels = m_tokenInfo.begin<kLabels>(); for(auto itInfo = m_tokenInfo.begin<kLookupInfo>(),itEnd = m_tokenInfo.end<kLookupInfo>(); itInfo != itEnd; ++itInfo,++itKind,++itLabels) { const unsigned int labelStart = itLabels->m_startOfModuleLabel; const char* moduleLabel = &(m_tokenLabels[labelStart]); itInfo->m_index = iHelper.index(*itKind, itInfo->m_type, moduleLabel, moduleLabel+itLabels->m_deltaToProductInstance, moduleLabel+itLabels->m_deltaToProcessName); } } //now add resolved requests to get many to the end of our list // a get many will have an empty module label for(size_t i=0, iEnd = m_tokenInfo.size(); i!=iEnd;++i) { //need to copy since pointer could be invalidated by emplace_back auto const info = m_tokenInfo.get<kLookupInfo>(i); if(info.m_branchType == iBranchType && info.m_index == ProductHolderIndexInvalid && m_tokenLabels[m_tokenInfo.get<kLabels>(i).m_startOfModuleLabel]=='\0') { //find all matching types const auto kind=m_tokenInfo.get<kKind>(i); auto matches = iHelper.relatedIndexes(kind,info.m_type); //NOTE: This could be changed to contain the true labels for what is being // requested but for now I want to remember these are part of a get many const LabelPlacement labels= m_tokenInfo.get<kLabels>(i); bool alwaysGet = m_tokenInfo.get<kAlwaysGets>(i); for(unsigned int j=0;j!=matches.numberOfMatches();++j) { //only keep the ones that are for a specific data item and not a collection if(matches.isFullyResolved(j)) { auto index =matches.index(j); m_tokenInfo.emplace_back(TokenLookupInfo{info.m_type,index,info.m_branchType}, alwaysGet, labels, kind); } } } } m_tokenInfo.shrink_to_fit(); }
friend class ConsumesCollector [friend] |
Definition at line 69 of file EDConsumerBase.h.
edm::SoATuple<TokenLookupInfo,bool,LabelPlacement,edm::KindOfType> edm::EDConsumerBase::m_tokenInfo [private] |
Definition at line 156 of file EDConsumerBase.h.
Referenced by indexFrom(), itemsMayGet(), itemsToGet(), labelsForToken(), recordConsumes(), throwBranchMismatch(), throwTypeMismatch(), and updateLookup().
std::vector<char> edm::EDConsumerBase::m_tokenLabels [private] |
Definition at line 160 of file EDConsumerBase.h.
Referenced by labelsForToken(), recordConsumes(), and updateLookup().