CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Friends
edm::Ptr< T > Class Template Reference

#include <DataFormats/Common/interface/Ptr.h>

Public Types

typedef unsigned long key_type
 
typedef T value_type
 

Public Member Functions

T const * get () const
 Returns C++ pointer to the item. More...
 
bool hasProductCache () const
 
ProductID id () const
 Accessor for product ID. More...
 
bool isAvailable () const
 
bool isNonnull () const
 Checks for non-null. More...
 
bool isNull () const
 Checks for null. More...
 
bool isTransient () const
 Checks if this Ptr is transient (i.e. not persistable). More...
 
key_type key () const
 
bool operator! () const
 Checks for null. More...
 
T const & operator* () const
 Dereference operator. More...
 
T const * operator-> () const
 Member dereference operator. More...
 
void const * product () const
 
EDProductGetter const * productGetter () const
 Accessor for product getter. More...
 
template<typename C >
 Ptr (Handle< C > const &handle, key_type itemKey, bool=true)
 
template<typename C >
 Ptr (OrphanHandle< C > const &handle, key_type itemKey, bool=true)
 
template<typename C >
 Ptr (C const *iProduct, key_type iItemKey, bool=true)
 
template<typename C >
 Ptr (TestHandle< C > const &handle, key_type itemKey, bool=true)
 
 Ptr (ProductID const &productID, key_type itemKey, EDProductGetter const *prodGetter)
 
 Ptr (ProductID const &productID, T const *item, key_type item_key)
 
 Ptr (ProductID const &iId)
 
 Ptr ()
 
template<typename U >
 Ptr (Ptr< U > const &iOther, typename boost::enable_if_c< boost::is_base_of< T, U >::value >::type *=0)
 
template<typename U >
 Ptr (Ptr< U > const &iOther, typename boost::enable_if_c< boost::is_base_of< U, T >::value >::type *=0)
 
RefCore const & refCore () const
 
 ~Ptr ()
 Destructor. More...
 

Static Public Member Functions

static short Class_Version ()
 

Private Member Functions

void getData_ (bool throwIfNotFound=true) const
 
template<typename C >
T const * getItem_ (C const *product, key_type iKey)
 
 Ptr (T const *item, key_type item_key)
 

Private Attributes

RefCore core_
 
key_type key_
 

Friends

class PtrVectorBase
 

Detailed Description

template<class T>
class edm::Ptr< T >

Description: Persistent 'pointer' to an item in a collection where the collection is in the edm::Event

Usage: <usage>

Definition at line 50 of file AssociativeIterator.h.

Member Typedef Documentation

template<class T>
typedef unsigned long edm::Ptr< T >::key_type

Definition at line 43 of file Ptr.h.

template<class T>
typedef T edm::Ptr< T >::value_type

Definition at line 44 of file Ptr.h.

Constructor & Destructor Documentation

template<class T>
template<typename C >
edm::Ptr< T >::Ptr ( Handle< C > const &  handle,
key_type  itemKey,
bool  = true 
)
inline

Definition at line 48 of file Ptr.h.

48  :
49  core_(handle.id(), getItem_(handle.product(), itemKey), 0, false), key_(itemKey) {}
T const * getItem_(C const *product, key_type iKey)
Definition: Ptr.h:220
key_type key_
Definition: Ptr.h:215
RefCore core_
Definition: Ptr.h:214
template<class T>
template<typename C >
edm::Ptr< T >::Ptr ( OrphanHandle< C > const &  handle,
key_type  itemKey,
bool  = true 
)
inline

Definition at line 53 of file Ptr.h.

53  :
54  core_(handle.id(), getItem_(handle.product(), itemKey), 0, false), key_(itemKey) {}
T const * getItem_(C const *product, key_type iKey)
Definition: Ptr.h:220
key_type key_
Definition: Ptr.h:215
tuple handle
Definition: patZpeak.py:22
RefCore core_
Definition: Ptr.h:214
template<class T>
template<typename C >
edm::Ptr< T >::Ptr ( C const *  iProduct,
key_type  iItemKey,
bool  = true 
)
inline

Definition at line 68 of file Ptr.h.

68  :
69  core_(ProductID(), iProduct != 0 ? getItem_(iProduct,iItemKey) : 0, 0, true),
70  key_(iProduct != 0 ? iItemKey : key_traits<key_type>::value) {}
T const * getItem_(C const *product, key_type iKey)
Definition: Ptr.h:220
key_type key_
Definition: Ptr.h:215
RefCore core_
Definition: Ptr.h:214
template<class T>
template<typename C >
edm::Ptr< T >::Ptr ( TestHandle< C > const &  handle,
key_type  itemKey,
bool  = true 
)
inline

Definition at line 76 of file Ptr.h.

76  :
77  core_(handle.id(), getItem_(handle.product(), itemKey), 0, true), key_(itemKey) {}
T const * getItem_(C const *product, key_type iKey)
Definition: Ptr.h:220
key_type key_
Definition: Ptr.h:215
tuple handle
Definition: patZpeak.py:22
RefCore core_
Definition: Ptr.h:214
template<class T>
edm::Ptr< T >::Ptr ( ProductID const &  productID,
key_type  itemKey,
EDProductGetter const *  prodGetter 
)
inline

Constructor for those users who do not have a product handle, but have a pointer to a product getter (such as the EventPrincipal). prodGetter will ususally be a pointer to the event principal.

Definition at line 82 of file Ptr.h.

82  :
83  core_(productID, 0, mustBeNonZero(prodGetter, "Ptr", productID), false), key_(itemKey) {
84  }
EDProductGetter const * mustBeNonZero(EDProductGetter const *prodGetter, std::string refType, ProductID const &productID)
key_type key_
Definition: Ptr.h:215
RefCore core_
Definition: Ptr.h:214
template<class T>
edm::Ptr< T >::Ptr ( ProductID const &  productID,
T const *  item,
key_type  item_key 
)
inline

Constructor for use in the various X::fillView(...) functions or for extracting a persistent Ptr from a PtrVector. It is an error (not diagnosable at compile- or run-time) to call this constructor with a pointer to a T unless the pointed-to T object is already in a collection of type C stored in the Event. The given ProductID must be the id of the collection in the Event.

Definition at line 93 of file Ptr.h.

93  :
94  core_(productID, item, 0, false),
95  key_(item_key) {
96  }
key_type key_
Definition: Ptr.h:215
RefCore core_
Definition: Ptr.h:214
template<class T>
edm::Ptr< T >::Ptr ( ProductID const &  iId)
inlineexplicit

Constructor that creates an invalid ("null") Ptr that is associated with a given product (denoted by that product's ProductID).

Definition at line 102 of file Ptr.h.

102  :
103  core_(iId, 0, 0, false),
105  { }
key_type key_
Definition: Ptr.h:215
RefCore core_
Definition: Ptr.h:214
template<class T>
edm::Ptr< T >::Ptr ( )
inline

Definition at line 107 of file Ptr.h.

107  :
108  core_(),
110  {}
key_type key_
Definition: Ptr.h:215
RefCore core_
Definition: Ptr.h:214
template<class T>
template<typename U >
edm::Ptr< T >::Ptr ( Ptr< U > const &  iOther,
typename boost::enable_if_c< boost::is_base_of< T, U >::value >::type = 0 
)
inline

Definition at line 113 of file Ptr.h.

113  :
114  core_(iOther.id(),
115  (iOther.hasProductCache() ? static_cast<T const*>(iOther.get()): static_cast<T const*>(0)),
116  iOther.productGetter(),
117  iOther.isTransient()),
118  key_(iOther.key()) {
119  }
key_type key_
Definition: Ptr.h:215
RefCore core_
Definition: Ptr.h:214
string const
Definition: compareJSON.py:14
long double T
template<class T>
template<typename U >
edm::Ptr< T >::Ptr ( Ptr< U > const &  iOther,
typename boost::enable_if_c< boost::is_base_of< U, T >::value >::type = 0 
)
inlineexplicit

Definition at line 123 of file Ptr.h.

123  :
124  core_(iOther.id(),
125  dynamic_cast<T const*>(iOther.get()),
126  0,
127  iOther.isTransient()),
128  key_(iOther.key()) {
129  }
key_type key_
Definition: Ptr.h:215
RefCore core_
Definition: Ptr.h:214
string const
Definition: compareJSON.py:14
long double T
template<class T>
edm::Ptr< T >::~Ptr ( )
inline

Destructor.

Definition at line 132 of file Ptr.h.

132 {}
template<class T>
edm::Ptr< T >::Ptr ( T const *  item,
key_type  item_key 
)
inlineprivate

Constructor for extracting a transient Ptr from a PtrVector.

Definition at line 185 of file Ptr.h.

185  :
186  core_(ProductID(), item, 0, true),
187  key_(item_key) {
188  }
key_type key_
Definition: Ptr.h:215
RefCore core_
Definition: Ptr.h:214

Member Function Documentation

template<class T>
static short edm::Ptr< T >::Class_Version ( )
inlinestatic

Definition at line 179 of file Ptr.h.

181 :
182  //Ptr(Ptr const&); // stop default
template<class T>
T const* edm::Ptr< T >::get ( void  ) const
inline

Returns C++ pointer to the item.

Definition at line 143 of file Ptr.h.

Referenced by Options.Options::__getitem__(), betterConfigParser.BetterConfigParser::__updateDict(), PFEGammaAlgo::buildRefinedSuperCluster(), PFECALSuperClusterAlgo::buildSuperCluster(), rrapi.RRApi::columns(), PileupJetIdAlgo::computeIdVariables(), rrapi.RRApi::count(), rrapi.RRApi::data(), ElectronMVAEstimatorRun2Phys14NonTrig::fillMVAVariables(), ElectronMVAEstimatorRun2Phys14NonTrig::findCategory(), edm::FwdPtr< FFTJPTJet >::get(), pat::EventHypothesis::getAs(), reco::CaloJet::getCaloConstituent(), betterConfigParser.BetterConfigParser::getCompares(), ReflectedIterator::getEt(), MultipleAlgoIterator::getEt(), ParametrizedSubtractor::getEt(), MultipleAlgoIterator::getEta(), ReflectedIterator::getEta(), ParametrizedSubtractor::getEta(), betterConfigParser.BetterConfigParser::getGeneral(), reco::PFJet::getPFConstituent(), betterConfigParser.BetterConfigParser::getResultingSection(), PileUpSubtractor::ieta(), cms::SubEventGenJetProducer::inputTowers(), VirtualJetProducer::inputTowers(), PileUpSubtractor::iphi(), ElectronPFIsolationWithConeVeto::isInIsolationCone(), pat::MET::MET(), reco::PFClusterJet::pfCluster(), EcalDigiSelector::produce(), SoftPFMuonTagInfoProducer::produce(), NoPileUpPFMEtDataProducer::produce(), PFRecoTauChargedHadronProducer::produce(), rrapi.RRApi::report(), rrapi.RRApi::reports(), CandidateBoostedDoubleSecondaryVertexComputer::setTracksPV(), rrapi.RRApi::tables(), rrapi.RRApi::tags(), rrapi.RRApi::templates(), reco::TrackJet::track(), and rrapi.RRApi::workspaces().

143  {
144  return isNull() ? 0 : this->operator->();
145  }
T const * operator->() const
Member dereference operator.
Definition: Ptr.h:241
bool isNull() const
Checks for null.
Definition: Ptr.h:148
template<class T>
void edm::Ptr< T >::getData_ ( bool  throwIfNotFound = true) const
inlineprivate

Definition at line 194 of file Ptr.h.

194  {
195  if(!hasProductCache() && productGetter() != nullptr) {
196  WrapperBase const* prod = productGetter()->getIt(core_.id());
197  unsigned int iKey = key_;
198  if(prod == nullptr) {
199  prod = productGetter()->getThinnedProduct(core_.id(), iKey);
200  if(prod == nullptr) {
201  if(throwIfNotFound) {
203  } else {
204  return;
205  }
206  }
207  }
208  void const* ad = nullptr;
209  prod->setPtr(typeid(T), iKey, ad);
210  core_.setProductPtr(ad);
211  }
212  }
void setProductPtr(void const *prodPtr) const
Definition: RefCore.h:34
EDProductGetter const * productGetter() const
Accessor for product getter.
Definition: Ptr.h:167
key_type key_
Definition: Ptr.h:215
virtual WrapperBase const * getIt(ProductID const &) const =0
void productNotFoundException(std::type_info const &type) const
Definition: RefCore.cc:127
bool hasProductCache() const
Definition: Ptr.h:171
virtual WrapperBase const * getThinnedProduct(ProductID const &, unsigned int &key) const =0
RefCore core_
Definition: Ptr.h:214
ProductID id() const
Definition: RefCore.h:29
long double T
template<typename T >
template<typename C >
T const * edm::Ptr< T >::getItem_ ( C const *  product,
key_type  iKey 
)
private

Definition at line 220 of file Ptr.h.

References edm::detail::GetProduct< COLLECTION >::address(), and assert().

220  {
221  assert (iProduct != 0);
222  typename C::const_iterator it = iProduct->begin();
223  std::advance(it,iKey);
224  T const* address = detail::GetProduct<C>::address(it);
225  return address;
226  }
static const element_type * address(const iter &i)
Definition: GetProduct.h:33
assert(m_qm.get())
long double T
template<class T>
bool edm::Ptr< T >::hasProductCache ( ) const
inline

Definition at line 171 of file Ptr.h.

Referenced by edm::Ptr< PileUpPFCandidate >::getData_(), edm::FwdPtr< FFTJPTJet >::hasProductCache(), and edm::PtrVector< reco::FFTJPTJet >::push_back().

171 { return 0 != core_.productPtr(); }
void const * productPtr() const
Definition: RefCore.h:32
RefCore core_
Definition: Ptr.h:214
template<class T>
ProductID edm::Ptr< T >::id ( void  ) const
inline
template<typename T >
bool edm::Ptr< T >::isAvailable ( ) const
inline
template<class T>
bool edm::Ptr< T >::isNonnull ( ) const
inline

Checks for non-null.

Definition at line 152 of file Ptr.h.

Referenced by reco::tau::RecoTauConstructor::addTauChargedHadron(), heppy::IsolationComputer::addVetos(), B2GHadronicHLTValidation::analyze(), B2GSingleLeptonHLTValidation::analyze(), HPSPFRecoTauAlgorithm::applyElectronRejection(), HPSPFRecoTauAlgorithm::applyMuonRejection(), PFRecoTauAlgorithm::buildPFTau(), HPSPFRecoTauAlgorithm::buildPFTau(), reco::FlavorHistoryEvent::cache(), ConversionProducer::checkTrackPair(), reco::tau::RecoTauConstructor::convertToPtr(), EGEnergyCorrector::CorrectedEnergyWithError(), dEtaInSeed(), PFRecoTauDiscriminationByFlight::discriminate(), PFRecoTauDiscriminationByNProngs::discriminate(), reco::CaloJet::getCaloConstituent(), reco::tau::RecoTauVertexAssociator::getLeadTrack(), reco::PFJet::getPFConstituent(), NjettinessAdder::getTau(), reco::FlavorHistory::hasMatchedJet(), reco::PFTau::hasMuonReference(), reco::FlavorHistory::hasParton(), reco::FlavorHistory::hasProgenitor(), reco::FlavorHistory::hasSister(), reco::FlavorHistory::hasSisterJet(), edm::FwdPtr< FFTJPTJet >::id(), pat::helper::RefHelper< T >::isAncestorOf(), ElectronPFIsolationWithConeVeto::isInIsolationCone(), edm::FwdPtr< FFTJPTJet >::isNonnull(), edm::Ptr< PileUpPFCandidate >::isNull(), heppy::IsolationComputer::isoSumNeutralsWeighted(), heppy::IsolationComputer::isoSumRaw(), edm::FwdPtr< FFTJPTJet >::key(), AntiElectronIDMVA5::MVAValue(), pat::Muon::numberOfSourceCandidatePtrs(), reco::PFCandidateFwdPtrFactory::operator()(), reco::tau::RecoTauElectronRejectionPlugin::operator()(), reco::tau::RecoTauImpactParameterSignificancePlugin::operator()(), reco::tau::PFRecoTauEnergyAlgorithmPlugin::operator()(), TopProjectorFwdPtrOverlap< Top, Bottom >::operator()(), reco::PFCandidate::overlap(), pat::helper::RefHelper< T >::parentOrSelf(), reco::PFClusterJet::pfCluster(), reco::PFRecoTauChargedHadron::print(), PseudoTopProducer::produce(), L1HLTTauMatching::produce(), reco::ParticleFlowForChargedMETProducer::produce(), pat::PATJetProducer::produce(), PFRecoTauChargedHadronProducer::produce(), pat::PATElectronProducer::produce(), CorrectedECALPFClusterProducer::produce(), pat::helper::RefHelper< T >::recursiveLookup(), edm::FwdPtr< FFTJPTJet >::refCore(), reco::tau::setChargedHadronP4(), PFCandidateMaker::SetVars(), and reco::TrackJet::track().

key_type key_
Definition: Ptr.h:215
template<class T>
bool edm::Ptr< T >::isNull ( ) const
inline
template<class T>
bool edm::Ptr< T >::isTransient ( ) const
inline

Checks if this Ptr is transient (i.e. not persistable).

Definition at line 161 of file Ptr.h.

Referenced by edm::FwdPtr< FFTJPTJet >::isTransient().

161 {return core_.isTransient();}
RefCore core_
Definition: Ptr.h:214
bool isTransient() const
Definition: RefCore.h:75
template<class T>
key_type edm::Ptr< T >::key ( ) const
inline

Definition at line 169 of file Ptr.h.

Referenced by reco::tau::RecoTauPiZeroStripPlugin2::addCandsToStrip(), PFEGammaAlgo::attachPSClusters(), ConvertedPhotonProducer::cleanCollections(), reco::tau::RecoTauConstructor::convertToPtr(), reco::tau::disc::EMFraction(), reco::CaloJet::getCaloConstituent(), reco::PFJet::getPFConstituent(), edm::FwdPtr< FFTJPTJet >::key(), EGExtraInfoModifierFromFloatValueMaps::modifyObject(), EGExtraInfoModifierFromIntValueMaps::modifyObject(), EGFull5x5ShowerShapeModifierFromValueMaps::modifyObject(), PhoFull5x5SigmaIEtaIEtaValueMapCut::operator()(), GsfEleMVACut::operator()(), PhoMVACut::operator()(), PhoAnyPFIsoWithEAAndExpoScalingEBCut::operator()(), PhoAnyPFIsoWithEACut::operator()(), GsfEleDeltaBetaIsoCut::operator()(), reco::tau::RecoTauPhotonFilter::operator()(), TopProjectorFwdPtrOverlap< Top, Bottom >::operator()(), reco::FlavorHistory::operator<(), operator<<(), reco::FlavorHistory::operator==(), reco::FlavorHistory::operator>(), ClusterClusterMapping::overlap(), reco::RecoTauPiZero::print(), reco::PFRecoTauChargedHadron::print(), pat::PATTrackAndVertexUnpacker::produce(), NoPileUpPFMEtDataProducer::produce(), CorrectedECALPFClusterProducer::produce(), TriggerMatcherToHLTDebug::produce(), edm::PtrVector< reco::FFTJPTJet >::push_back(), PFCandidateMaker::SetVars(), ConvertedPhotonProducer::solveAmbiguity(), PhoFull5x5SigmaIEtaIEtaValueMapCut::value(), GsfEleMVACut::value(), PhoMVACut::value(), PhoAnyPFIsoWithEAAndExpoScalingEBCut::value(), PhoAnyPFIsoWithEACut::value(), and GsfEleDeltaBetaIsoCut::value().

169 {return key_;}
key_type key_
Definition: Ptr.h:215
template<class T>
bool edm::Ptr< T >::operator! ( ) const
inline

Checks for null.

Definition at line 154 of file Ptr.h.

154 {return isNull();}
bool isNull() const
Checks for null.
Definition: Ptr.h:148
template<typename T >
T const & edm::Ptr< T >::operator* ( ) const
inline

Dereference operator.

Definition at line 232 of file Ptr.h.

References compareJSON::const.

232  {
233  getData_();
234  return *reinterpret_cast<T const*>(core_.productPtr());
235  }
void getData_(bool throwIfNotFound=true) const
Definition: Ptr.h:194
void const * productPtr() const
Definition: RefCore.h:32
RefCore core_
Definition: Ptr.h:214
string const
Definition: compareJSON.py:14
long double T
template<typename T >
T const * edm::Ptr< T >::operator-> ( ) const
inline

Member dereference operator.

Definition at line 241 of file Ptr.h.

References compareJSON::const.

Referenced by edm::Ptr< PileUpPFCandidate >::get().

241  {
242  getData_();
243  return reinterpret_cast<T const*>(core_.productPtr());
244  }
void getData_(bool throwIfNotFound=true) const
Definition: Ptr.h:194
void const * productPtr() const
Definition: RefCore.h:32
RefCore core_
Definition: Ptr.h:214
string const
Definition: compareJSON.py:14
long double T
template<class T>
void const* edm::Ptr< T >::product ( ) const
inline

Definition at line 176 of file Ptr.h.

176 {return 0;}
template<class T>
EDProductGetter const* edm::Ptr< T >::productGetter ( ) const
inline

Accessor for product getter.

Definition at line 167 of file Ptr.h.

Referenced by edm::Ptr< PileUpPFCandidate >::getData_(), and edm::FwdPtr< FFTJPTJet >::productGetter().

167 {return core_.productGetter();}
RefCore core_
Definition: Ptr.h:214
EDProductGetter const * productGetter() const
Definition: RefCore.h:53
template<class T>
RefCore const& edm::Ptr< T >::refCore ( ) const
inline

Friends And Related Function Documentation

template<class T>
friend class PtrVectorBase
friend

Definition at line 40 of file Ptr.h.

Member Data Documentation

template<class T>
RefCore edm::Ptr< T >::core_
private
template<class T>
key_type edm::Ptr< T >::key_
private