LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
art::DataViewImpl Class Reference

#include "DataViewImpl.h"

Inheritance diagram for art::DataViewImpl:
art::Event art::Results art::Run art::SubRun

Classes

struct  PMValue
 

Public Types

using RetrievedProductIDs = std::vector< ProductID >
 
using RetrievedProductSet = std::set< ProductID >
 
using TypeLabelMap = std::map< TypeLabel, PMValue >
 

Public Member Functions

 DataViewImpl (DataViewImpl const &)=delete
 
DataViewImploperator= (DataViewImpl const &)=delete
 
 DataViewImpl (Principal const &p, ModuleDescription const &md, BranchType bt, bool recordParents, cet::exempt_ptr< Consumer > consumer)
 
size_t size () const
 
template<typename PROD >
bool get (SelectorBase const &, Handle< PROD > &result) const
 
template<typename PROD >
bool get (ProductID const pid, Handle< PROD > &result) const
 
template<typename PROD >
bool getByLabel (std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
 
template<typename PROD >
bool getByLabel (std::string const &label, std::string const &productInstanceName, std::string const &processName, Handle< PROD > &result) const
 
template<typename PROD >
PROD const & getByLabel (InputTag const &tag) const
 same as above, but using the InputTag class More...
 
template<typename PROD >
bool getByLabel (InputTag const &tag, Handle< PROD > &result) const
 
template<typename PROD >
PROD const * getPointerByLabel (InputTag const &tag) const
 
template<typename PROD >
bool getByToken (ProductToken< PROD > const &token, Handle< PROD > &result) const
 
template<typename PROD >
ValidHandle< PROD > getValidHandle (InputTag const &tag) const
 
template<typename PROD >
ValidHandle< PROD > getValidHandle (ProductToken< PROD > const &token) const
 
template<typename PROD >
void getMany (SelectorBase const &, std::vector< Handle< PROD >> &results) const
 
template<typename PROD >
void getManyByType (std::vector< Handle< PROD >> &results) const
 
template<typename ELEMENT >
std::size_t getView (std::string const &moduleLabel, std::string const &productInstanceName, std::vector< ELEMENT const * > &result) const
 
template<typename ELEMENT >
std::size_t getView (InputTag const &tag, std::vector< ELEMENT const * > &result) const
 
template<typename ELEMENT >
std::size_t getView (ViewToken< ELEMENT > const &token, std::vector< ELEMENT const * > &result) const
 
template<typename ELEMENT >
bool getView (std::string const &moduleLabel, std::string const &instanceName, View< ELEMENT > &result) const
 
template<typename ELEMENT >
bool getView (InputTag const &tag, View< ELEMENT > &result) const
 
template<typename ELEMENT >
bool getView (ViewToken< ELEMENT > const &tag, View< ELEMENT > &result) const
 
template<typename PROD >
bool removeCachedProduct (Handle< PROD > &h) const
 
ProcessHistory const & processHistory () const
 
template<typename PROD >
art::ValidHandle< PROD > getValidHandle (InputTag const &tag) const
 
template<typename PROD >
art::ValidHandle< PROD > getValidHandle (ProductToken< PROD > const &token) const
 
template<typename ELEMENT >
art::DataViewImpl::GroupQueryResultVec getView_ (std::string const &moduleLabel, std::string const &productInstanceName, std::string const &processName) const
 

Protected Types

using GroupQueryResultVec = std::vector< GroupQueryResult >
 

Protected Member Functions

void recordAsParent (Provenance const &prov) const
 
TypeLabelMapputProducts ()
 
TypeLabelMap const & putProducts () const
 
RetrievedProductSet const & retrievedProducts () const
 
RetrievedProductIDs retrievedProductIDs () const
 
void checkPutProducts (bool checkProducts, std::set< TypeLabel > const &expectedProducts, TypeLabelMap const &putProducts)
 
BranchDescription const & getProductDescription (TypeID const &type, std::string const &productInstanceName) const
 

Private Member Functions

void removeNonViewableMatches_ (TypeID const &requestedElementType, GroupQueryResultVec &results) const
 
void ensureUniqueProduct_ (std::size_t nFound, TypeID const &typeID, std::string const &moduleLabel, std::string const &productInstanceName, std::string const &processName) const
 
GroupQueryResult get_ (WrappedTypeID const &wrapped, SelectorBase const &) const
 
GroupQueryResult getByProductID_ (ProductID const pid) const
 
GroupQueryResult getByLabel_ (WrappedTypeID const &wrapped, std::string const &label, std::string const &productInstanceName, std::string const &processName) const
 
GroupQueryResultVec getMany_ (WrappedTypeID const &wrapped, SelectorBase const &sel) const
 
GroupQueryResultVec getMatchingSequenceByLabel_ (std::string const &label, std::string const &productInstanceName, std::string const &processName) const
 
template<typename ELEMENT >
GroupQueryResultVec getView_ (std::string const &moduleLabel, std::string const &productInstanceName, std::string const &processName) const
 
template<typename ELEMENT >
void fillView_ (GroupQueryResult &bh, std::vector< ELEMENT const * > &result) const
 
void removeCachedProduct_ (ProductID const pid) const
 

Private Attributes

TypeLabelMap putProducts_ {}
 
RetrievedProductSet retrievedProducts_ {}
 
Principal const & principal_
 
ModuleDescription const & md_
 
BranchType const branchType_
 
bool const recordParents_
 
cet::exempt_ptr< Consumerconsumer_
 

Detailed Description

Definition at line 76 of file DataViewImpl.h.

Member Typedef Documentation

Definition at line 214 of file DataViewImpl.h.

Definition at line 175 of file DataViewImpl.h.

Definition at line 176 of file DataViewImpl.h.

Definition at line 177 of file DataViewImpl.h.

Constructor & Destructor Documentation

art::DataViewImpl::DataViewImpl ( DataViewImpl const &  )
delete
art::DataViewImpl::DataViewImpl ( Principal const &  p,
ModuleDescription const &  md,
BranchType  bt,
bool  recordParents,
cet::exempt_ptr< Consumer consumer 
)
explicit

Definition at line 21 of file DataViewImpl.cc.

References branchType_, consumer_, md_, and recordParents_.

26  : principal_{pcpl}
27  , md_{md}
28  , branchType_{branchType}
29  , recordParents_{recordParents}
30  , consumer_{consumer}
31  {}
Principal const & principal_
Definition: DataViewImpl.h:276
BranchType const branchType_
Definition: DataViewImpl.h:283
cet::exempt_ptr< Consumer > consumer_
Definition: DataViewImpl.h:291
ModuleDescription const & md_
Definition: DataViewImpl.h:280
bool const recordParents_
Definition: DataViewImpl.h:286

Member Function Documentation

void art::DataViewImpl::checkPutProducts ( bool  checkProducts,
std::set< TypeLabel > const &  expectedProducts,
TypeLabelMap const &  putProducts 
)
protected

Definition at line 109 of file DataViewImpl.cc.

References getProductDescription(), and art::errors::LogicError.

Referenced by art::Run::commit(), art::SubRun::commit(), art::Event::commit(), art::Event::put(), and retrievedProducts().

112  {
113  if (!checkProducts)
114  return;
115 
116  std::vector<std::string> missing;
117  for (auto const& typeLabel : expectedProducts) {
118  if (putProducts.find(typeLabel) != putProducts.cend())
119  continue;
120 
121  std::ostringstream desc;
122  desc << getProductDescription(typeLabel.typeID(),
123  typeLabel.productInstanceName());
124  missing.emplace_back(desc.str());
125  }
126 
127  if (!missing.empty()) {
128  std::ostringstream errmsg;
129  HorizontalRule rule{25};
130  errmsg << "The following products have been declared with 'produces',\n"
131  << "but they have not been placed onto the event:\n"
132  << rule('=') << '\n';
133  for (auto const& desc : missing) {
134  errmsg << desc << rule('=') << '\n';
135  }
136  throw Exception{errors::LogicError, "DataViewImpl::checkPutProducts"}
137  << errmsg.str();
138  }
139  }
BranchDescription const & getProductDescription(TypeID const &type, std::string const &productInstanceName) const
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
TypeLabelMap & putProducts()
Definition: DataViewImpl.h:183
void art::DataViewImpl::ensureUniqueProduct_ ( std::size_t  nFound,
TypeID const &  typeID,
std::string const &  moduleLabel,
std::string const &  productInstanceName,
std::string const &  processName 
) const
private

Definition at line 174 of file DataViewImpl.cc.

References e, and art::errors::ProductNotFound.

Referenced by getView_().

179  {
180  if (nFound == 1)
181  return;
182 
184  e << "getView: Found "
185  << (nFound == 0 ? "no products" : "more than one product")
186  << " matching all criteria\n"
187  << "Looking for sequence of type: " << typeID << "\n"
188  << "Looking for module label: " << moduleLabel << "\n"
189  << "Looking for productInstanceName: " << productInstanceName << "\n";
190  if (!processName.empty())
191  e << "Looking for processName: " << processName << "\n";
192  throw e;
193  }
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
Float_t e
Definition: plot.C:34
template<typename ELEMENT >
void art::DataViewImpl::fillView_ ( GroupQueryResult bh,
std::vector< ELEMENT const * > &  result 
) const
private

Definition at line 531 of file DataViewImpl.h.

References recordAsParent(), and art::GroupQueryResult::result().

Referenced by getView().

533 {
534  std::vector<void const*> erased_ptrs;
535  auto product = bh.result()->uniqueProduct();
536 
537  // The lookups and the checking done in getView_ ensure that the
538  // retrieved product supports the requested view.
539  product->fillView(erased_ptrs);
540  recordAsParent(Provenance{bh.result()});
541 
542  std::vector<ELEMENT const*> vals;
543  cet::transform_all(erased_ptrs, std::back_inserter(vals), [](auto p) {
544  return static_cast<ELEMENT const*>(p);
545  });
546  result.swap(vals);
547 }
void recordAsParent(Provenance const &prov) const
Definition: DataViewImpl.cc:87
template<typename PROD >
bool art::DataViewImpl::get ( SelectorBase const &  sel,
Handle< PROD > &  result 
) const
inline

Definition at line 307 of file DataViewImpl.h.

References art::Handle< T >::clear(), art::convert_handle(), art::Handle< T >::failedToGet(), get_(), art::Handle< T >::provenance(), recordAsParent(), recordParents_, and art::GroupQueryResult::succeeded().

Referenced by art::Run::endTime(), art::SubRun::endTime(), art::detail::ProcessAndEventSelector::loadTriggerResults(), DUNE::NeutrinoTrackingEff::processEff(), DUNE::MuonTrackingEff::processEff(), and art::Event::put().

308 {
309  result.clear(); // Is this the correct thing to do if an exception is thrown?
310  // We do *not* track whether consumes was called for a SelectorBase.
311  GroupQueryResult bh = get_(WrappedTypeID::make<PROD>(), sel);
312  convert_handle(bh, result);
313  bool const ok{bh.succeeded() && !result.failedToGet()};
314  if (recordParents_ && ok) {
315  recordAsParent(*result.provenance());
316  }
317  return ok;
318 }
void recordAsParent(Provenance const &prov) const
Definition: DataViewImpl.cc:87
GroupQueryResult get_(WrappedTypeID const &wrapped, SelectorBase const &) const
Definition: DataViewImpl.cc:40
void convert_handle(GroupQueryResult const &, Handle< T > &)
Definition: Handle.h:249
bool const recordParents_
Definition: DataViewImpl.h:286
template<typename PROD >
bool art::DataViewImpl::get ( ProductID const  pid,
Handle< PROD > &  result 
) const

Definition at line 322 of file DataViewImpl.h.

References art::Handle< T >::clear(), art::convert_handle(), art::Handle< T >::failedToGet(), getByProductID_(), art::Handle< T >::provenance(), recordAsParent(), recordParents_, and art::GroupQueryResult::succeeded().

323 {
324  result.clear(); // Is this the correct thing to do if an exception is thrown?
325  // We do *not* track whether consumes was called for a ProductID.
326  GroupQueryResult bh = getByProductID_(pid);
327  convert_handle(bh, result);
328  bool const ok{bh.succeeded() && !result.failedToGet()};
329  if (recordParents_ && ok) {
330  recordAsParent(*result.provenance());
331  }
332  return ok;
333 }
void recordAsParent(Provenance const &prov) const
Definition: DataViewImpl.cc:87
void convert_handle(GroupQueryResult const &, Handle< T > &)
Definition: Handle.h:249
GroupQueryResult getByProductID_(ProductID const pid) const
Definition: DataViewImpl.cc:47
bool const recordParents_
Definition: DataViewImpl.h:286
GroupQueryResult art::DataViewImpl::get_ ( WrappedTypeID const &  wrapped,
SelectorBase const &  sel 
) const
private

Definition at line 40 of file DataViewImpl.cc.

References art::Principal::getBySelector(), and principal_.

Referenced by get().

42  {
43  return principal_.getBySelector(wrapped, sel);
44  }
Principal const & principal_
Definition: DataViewImpl.h:276
GroupQueryResult getBySelector(WrappedTypeID const &wrapped, SelectorBase const &) const
Definition: Principal.cc:110
template<typename PROD >
bool art::DataViewImpl::getByLabel ( std::string const &  label,
std::string const &  productInstanceName,
Handle< PROD > &  result 
) const
inline

Definition at line 344 of file DataViewImpl.h.

Referenced by lar::util::details::FindAllP< Source, Dest >::Add(), reco3d::PlotSpacePoints::analyze(), hit::MCHitAnaExample::analyze(), pid::PIDAAnalyzer::analyze(), opdet::OpFlashSimpleAna::analyze(), opdet::OpHitAna::analyze(), cheat::CheckBackTracking::analyze(), calo::PrintCalorimetry::analyze(), opdet::OpFlashMCTruthAna::analyze(), MCBTDemo::analyze(), trk::TrackContainmentAnalyzer::analyze(), opdet::FlashHypothesisAna::analyze(), cheat::RecoCheckAna::analyze(), opreco::OpticalRecoAna::analyze(), cluster::ClusterPCA::analyze(), hit::HitAnaModule::analyze(), lar_pandora::ConsolidatedPFParticleAnalysisTemplate::analyze(), vertex::AggregateVertexAna::analyze(), rwgt::ReweightAna::analyze(), caldata::CalWireAna::analyze(), shower::TCShowerTemplateMaker::analyze(), opdet::FIFOHistogramAna::analyze(), opdet::TrackTimeAssocAna::analyze(), shower::TCShowerElectronLikelihood::analyze(), shower::TCShowerAnalysis::analyze(), opdet::OpDigiAna::analyze(), opdet::OpFlashAna::analyze(), microboone::CosmicRemovalAna::analyze(), detsim::SimWireAna::analyze(), opdet::FlashPurityCheckAna::analyze(), opdet::LEDCalibrationAna::analyze(), larg::LArSimChannelAna::analyze(), pfpf::PFPAna::analyze(), trkf::SpacePointAna::analyze(), cluster::ClusterAna::analyze(), hit::MagDriftAna::analyze(), detsim::WienerFilterAna::analyze(), cluster::DBclusterAna::analyze(), hit::GausHitFinderAna::analyze(), hit::HitFinderAna::analyze(), cluster::HoughLineFinderAna::analyze(), NuShowerEff::analyze(), opdet::SimPhotonCounter::analyze(), vertex::FeatureVertexFinderAna::analyze(), ems::MultiEMShowers::analyze(), lar::example::AnalysisExample::analyze(), trkf::SeedAna::analyze(), trkf::TrackAna::analyze(), ClusteringValidation::ClusteringValidation::analyze(), trkf::TrackAna::anaStitch(), lar_pandora::LArPandoraHelper::BuildMCParticleHitMaps(), evd::AnalysisBaseDrawer::CalorShower(), evd::HitSelector::ChangeHit(), lar_cluster3d::StandardHit3DBuilder::CollectArtHits(), lar_pandora::LArPandoraHelper::CollectClusters(), lar_pandora::LArPandoraHelper::CollectCosmicTags(), lar_pandora::LArPandoraHelper::CollectGeneratorMCParticles(), lar_pandora::LArPandoraHelper::CollectHits(), lar_pandora::LArPandoraHelper::CollectMCParticles(), lar_pandora::LArPandoraHelper::CollectPFParticleMetadata(), lar_pandora::LArPandoraExternalEventBuilding::CollectPFParticles(), lar_pandora::LArPandoraHelper::CollectPFParticles(), lar_pandora::LArPandoraHelper::CollectSeeds(), ems::EMShower3D::CollectShower2D(), lar_pandora::LArPandoraHelper::CollectShowers(), ems::MergeEMShower3D::collectshowers(), lar_pandora::LArPandoraHelper::CollectSimChannels(), lar_pandora::LArPandoraHelper::CollectSpacePoints(), lar_pandora::LArPandoraHelper::CollectT0s(), lar_pandora::LArPandoraHelper::CollectTracks(), lar_pandora::LArPandoraHelper::CollectVertices(), lar_pandora::LArPandoraHelper::CollectWires(), ems::MultiEMShowers::convCluster(), t0::IndirectHitParticleAssns::CreateHitParticleAssociations(), t0::DirectHitParticleAssns::CreateHitParticleAssociations(), evd::AnalysisBaseDrawer::DrawDeDx(), evd::AnalysisBaseDrawer::DrawKineticEnergy(), evd::RecoBaseDrawer::DrawTrackVertexAssns2D(), art::Run::endTime(), art::SubRun::endTime(), filt::LArG4ParticleFilter::filter(), simfilter::FilterNoMCParticles::filter(), filt::FinalStateParticleFilter::filter(), filt::FinalStateSelectFilter::filter(), simfilter::FilterSimPhotonTime::filter(), cluster::SmallClusterFilter::filter(), filt::EmptyFilter::filter(), simfilter::FilterNoDirtNeutrinos::filter(), simfilter::FilterStoppingMuon::filter(), filter::MuonFilter::filter(), trkf::StitchAlg::FindHeadsAndTails(), anab::FVectorReader< T, N >::FVectorReader(), trkf::Track3DKalmanHit::getAllHits(), lar_pandora::LArPandoraHelper::GetAssociatedHits(), evd::RecoBaseDrawer::GetBezierTracks(), getByLabel(), getByToken(), trkf::Track3DKalmanHit::getClusteredHits(), evd::RecoBaseDrawer::GetClusters(), lar_pandora::LArPandoraEvent::GetCollection(), ShowerQuality::GetDataOrDie(), evd::RecoBaseDrawer::GetEdges(), evd::RecoBaseDrawer::GetEndPoint2D(), evd::RecoBaseDrawer::GetEvents(), lar_pandora::LArPandoraEvent::GetFilteredParticlesByCRTag(), ems::MergeEMShower3D::getGammaId(), trkf::BezierTrackerModule::GetHitsFromClusters(), trkf::SeedFinderModule::GetHitsFromEvent(), evd::RecoBaseDrawer::GetOpFlashes(), evd::RecoBaseDrawer::GetPFParticles(), trkf::Track3DKalmanHit::getPFParticleStuff(), getPointerByLabel(), evd::RecoBaseDrawer::GetSeeds(), shower::TCShower::getShowersWithoutSlices(), shower::TCShower::getShowersWithSlices(), sim::SimListUtils::GetSimPhotonsCollection(), evd::RecoBaseDrawer::GetSlices(), trkf::SeedFinderModule::GetSortedHitsFromClusters(), evd::RecoBaseDrawer::GetSpacePoints(), getValidHandle(), evd::RecoBaseDrawer::GetVertices(), evwgh::GenieWeightCalc::GetWeight(), evd::RecoBaseDrawer::GetWires(), lar_cluster3d::SpacePointHit3DBuilder::Hit3DBuilder(), lar_pandora::LArPandoraEventDump::PandoraData::LoadCollection(), ems::MergeEMShower3D::mcinfo(), evgb::MCTruthAndFriendsItr::MCTruthAndFriendsItr(), mvapid::MVAAlg::PrepareEvent(), wc::CellTree::processCalib(), DUNE::NeutrinoShowerEff::processEff(), DUNE::NeutrinoTrackingEff::processEff(), DUNE::MuonTrackingEff::processEff(), wc::CellTree::processMC(), wc::CellTree::processOpFlash(), wc::CellTree::processOpHit(), wc::CellTree::processRaw(), wc::CellTree::processTrigger(), event::EventMaker::produce(), MCReco::produce(), opdet::FlashClusterMatch::produce(), hit::DisambigCheater::produce(), hit::MCHitFinder::produce(), hit::TTHitFinder::produce(), trk::TrackContainmentTagger::produce(), vertex::VertexCheater::produce(), cluster::SimpleClusterMerger::produce(), opdet::OpMCDigi::produce(), vertex::CornerFinder::produce(), hit::RFFHitFinder::produce(), event::EventCheater::produce(), shwf::ShowerCheater::produce(), apa::APAHitFinder::produce(), opdet::TrackTimeAssoc::produce(), opdet::BeamFlashCompatabilityCheck::produce(), sppt::TTSpacePointFinder::produce(), trkf::SpacePointCheater::produce(), trkf::SpacePointFinder::produce(), sim::MergeSimSources::produce(), trkf::BezierTrackerModule::produce(), spacecharge::ShiftEdepSCE::produce(), noisefilteralg::WireCellNoiseFilter::produce(), opdet::OpticalRawDigitReformatter::produce(), trkf::TrackCheater::produce(), pid::Chi2ParticleID::produce(), cluster::ClusterCheater::produce(), calo::BezierCalorimetry::produce(), hit::FFTHitFinder::produce(), evwgh::EventWeight::produce(), calo::TrackCalorimetry::produce(), cosmic::BeamFlashTrackMatchTagger::produce(), caldata::CalWire::produce(), trkf::FeatureTracker::produce(), opdet::OpFlashFinder::produce(), vertex::AggregateVertex::produce(), CRHitRemoval::produce(), cluster::TrajCluster::produce(), cosmic::TrackPFParticleMatch::produce(), cluster::DBcluster::produce(), ShowerReco3D::produce(), cluster::FuzzyClusterMerger::produce(), caldata::CalWireT962::produce(), cluster::BlurredClustering::produce(), cluster::LineMerger::produce(), cluster::fuzzyCluster::produce(), trkf::SpacePts::produce(), cosmic::CosmicPFParticleTagger::produce(), event::AggregateEvent::produce(), shower::EMShower::produce(), trkf::TrackKalmanCheater::produce(), cosmic::CosmicTrackTagger::produce(), vertex::VertexMatch::produce(), trkf::Track3Dreco::produce(), shower::TCShower::produce(), shwf::ShowerFinder::produce(), cosmic::CosmicPCAxisTagger::produce(), cosmic::CosmicClusterTagger::produce(), t0::MCParticleTrackMatching::produce(), t0::MCParticleShowerMatching::produce(), opdet::OpHitFinder::produce(), hit::RawHitFinder::produce(), reco3d::SpacePointSolver::produce(), trkf::CCTrackMaker::produce(), vertex::PrimaryVertexFinder::produce(), trkf::MCSFitProducer::produce(), vertex::HarrisVertexFinder::produce(), cluster::SmallClusterFinder::produce(), cluster::EndPointModule::produce(), hit::GausHitFinder::produce(), trkf::TrackStitcher::produce(), ems::EMShower3D::produce(), CRHitRemovalByPCA::produce(), cluster::HoughLineFinder::produce(), hit::DPRawHitFinder::produce(), calo::Calorimetry::produce(), vertex::VertexFinder2D::produce(), shwf::ShowerReco::produce(), trkf::Track3DKalman::produce(), lbne::PhotonCounterT0Matching::produce(), trkf::PMAlgTrajFitter::produce(), trkf::Track3DKalmanSPS::produce(), detsim::SimDriftElectrons::produce(), t0::MCTruthT0Matching::produce(), vertex::FeatureVertexFinder::produce(), trkf::KalmanFilterTrajectoryFitter::produce(), trkf::CosmicTracker::produce(), larg4::LArG4::produce(), ems::MergeEMShower3D::produce(), art::Event::put(), evd::details::RawDigitCacheDataClass::ReadProduct(), evd::InfoTransfer::Rebuild(), cheat::PhotonBackTracker::Rebuild(), evd::HitSelector::SaveHits(), evd::HitSelector::SaveSeedLines(), cluster::ClusterMergeHelper::SetClusters(), nnet::TrainingDataAlg::setDataEventData(), tss::TrackShowerHits::sortHits(), and evd::details::RawDigitCacheDataClass::Update().

347 {
348  return getByLabel<PROD>(label, productInstanceName, {}, result);
349 }
template<typename PROD >
bool art::DataViewImpl::getByLabel ( std::string const &  label,
std::string const &  productInstanceName,
std::string const &  processName,
Handle< PROD > &  result 
) const
inline

Definition at line 353 of file DataViewImpl.h.

References branchType_, art::Handle< T >::clear(), consumer_, art::convert_handle(), art::Handle< T >::failedToGet(), getByLabel_(), art::ProductInfo::Product, art::Handle< T >::provenance(), recordAsParent(), recordParents_, and art::GroupQueryResult::succeeded().

357 {
358  result.clear(); // Is this the correct thing to do if an exception is thrown?
359  auto const wrapped = WrappedTypeID::make<PROD>();
360  ProductInfo const pinfo{ProductInfo::ConsumableType::Product,
361  wrapped.product_type,
362  label,
363  productInstanceName,
364  processName};
365  consumer_->validateConsumedProduct(branchType_, pinfo);
366  GroupQueryResult bh =
367  getByLabel_(wrapped, label, productInstanceName, processName);
368  convert_handle(bh, result);
369  bool const ok{bh.succeeded() && !result.failedToGet()};
370  if (recordParents_ && ok) {
371  recordAsParent(*result.provenance());
372  }
373  return ok;
374 }
void recordAsParent(Provenance const &prov) const
Definition: DataViewImpl.cc:87
BranchType const branchType_
Definition: DataViewImpl.h:283
cet::exempt_ptr< Consumer > consumer_
Definition: DataViewImpl.h:291
void convert_handle(GroupQueryResult const &, Handle< T > &)
Definition: Handle.h:249
GroupQueryResult getByLabel_(WrappedTypeID const &wrapped, std::string const &label, std::string const &productInstanceName, std::string const &processName) const
Definition: DataViewImpl.cc:60
bool const recordParents_
Definition: DataViewImpl.h:286
template<typename PROD >
PROD const & art::DataViewImpl::getByLabel ( InputTag const &  tag) const
inline

same as above, but using the InputTag class

Definition at line 378 of file DataViewImpl.h.

References getByLabel().

379 {
380  Handle<PROD> h;
381  getByLabel(tag, h);
382  return *h;
383 }
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
template<typename PROD >
bool art::DataViewImpl::getByLabel ( InputTag const &  tag,
Handle< PROD > &  result 
) const
inline

Definition at line 337 of file DataViewImpl.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

338 {
339  return getByLabel<PROD>(tag.label(), tag.instance(), tag.process(), result);
340 }
GroupQueryResult art::DataViewImpl::getByLabel_ ( WrappedTypeID const &  wrapped,
std::string const &  label,
std::string const &  productInstanceName,
std::string const &  processName 
) const
private

Definition at line 60 of file DataViewImpl.cc.

References art::Principal::getByLabel(), and principal_.

Referenced by getByLabel().

64  {
65  return principal_.getByLabel(
66  wrapped, label, productInstanceName, processName);
67  }
Principal const & principal_
Definition: DataViewImpl.h:276
GroupQueryResult getByLabel(WrappedTypeID const &wrapped, std::string const &label, std::string const &productInstanceName, std::string const &processName) const
Definition: Principal.cc:143
GroupQueryResult art::DataViewImpl::getByProductID_ ( ProductID const  pid) const
private

Definition at line 47 of file DataViewImpl.cc.

References art::Principal::getByProductID(), and principal_.

Referenced by get().

48  {
50  }
Principal const & principal_
Definition: DataViewImpl.h:276
GroupQueryResult getByProductID(ProductID const pid) const
Definition: Principal.cc:131
template<typename PROD >
bool art::DataViewImpl::getByToken ( ProductToken< PROD > const &  token,
Handle< PROD > &  result 
) const
inline

Definition at line 387 of file DataViewImpl.h.

References getByLabel(), and art::ProductToken< T >::inputTag_.

Referenced by art::Run::endTime(), art::SubRun::endTime(), and art::Event::put().

389 {
390  auto const& tag = token.inputTag_;
391  return getByLabel(tag.label(), tag.instance(), tag.process(), result);
392 }
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
template<typename PROD >
void art::DataViewImpl::getMany ( SelectorBase const &  sel,
std::vector< Handle< PROD >> &  results 
) const
inline

Definition at line 421 of file DataViewImpl.h.

References branchType_, consumer_, art::convert_handle(), getMany_(), art::ProductInfo::Many, recordAsParent(), and recordParents_.

Referenced by art::Run::endTime(), art::SubRun::endTime(), getManyByType(), and art::Event::put().

423 {
424  auto const wrapped = WrappedTypeID::make<PROD>();
425  consumer_->validateConsumedProduct(
426  branchType_,
427  ProductInfo{ProductInfo::ConsumableType::Many, wrapped.product_type});
428 
429  std::vector<Handle<PROD>> products;
430  for (auto const& qr : getMany_(wrapped, sel)) {
431  Handle<PROD> result;
432  convert_handle(qr, result);
433  products.push_back(result);
434  }
435  results.swap(products);
436 
437  if (!recordParents_)
438  return;
439 
440  for (auto const& h : results)
441  recordAsParent(*h.provenance());
442 }
void recordAsParent(Provenance const &prov) const
Definition: DataViewImpl.cc:87
BranchType const branchType_
Definition: DataViewImpl.h:283
cet::exempt_ptr< Consumer > consumer_
Definition: DataViewImpl.h:291
void convert_handle(GroupQueryResult const &, Handle< T > &)
Definition: Handle.h:249
GroupQueryResultVec getMany_(WrappedTypeID const &wrapped, SelectorBase const &sel) const
Definition: DataViewImpl.cc:53
bool const recordParents_
Definition: DataViewImpl.h:286
DataViewImpl::GroupQueryResultVec art::DataViewImpl::getMany_ ( WrappedTypeID const &  wrapped,
SelectorBase const &  sel 
) const
private

Definition at line 53 of file DataViewImpl.cc.

References art::Principal::getMany(), and principal_.

Referenced by getMany().

55  {
56  return principal_.getMany(wrapped, sel);
57  }
Principal const & principal_
Definition: DataViewImpl.h:276
GroupQueryResultVec getMany(WrappedTypeID const &wrapped, SelectorBase const &) const
Definition: Principal.cc:178
DataViewImpl::GroupQueryResultVec art::DataViewImpl::getMatchingSequenceByLabel_ ( std::string const &  label,
std::string const &  productInstanceName,
std::string const &  processName 
) const
private

Definition at line 70 of file DataViewImpl.cc.

References art::Principal::getMatchingSequence(), and principal_.

Referenced by getView_().

73  {
74  Selector const sel{ModuleLabelSelector{label} &&
75  ProductInstanceNameSelector{productInstanceName} &&
76  ProcessNameSelector{processName}};
77  return principal_.getMatchingSequence(sel);
78  }
Principal const & principal_
Definition: DataViewImpl.h:276
GroupQueryResultVec getMatchingSequence(SelectorBase const &) const
Definition: Principal.cc:195
template<typename PROD >
PROD const * art::DataViewImpl::getPointerByLabel ( InputTag const &  tag) const
inline

Definition at line 396 of file DataViewImpl.h.

References getByLabel().

Referenced by art::Run::endTime(), art::SubRun::endTime(), and art::Event::put().

397 {
398  Handle<PROD> h;
399  getByLabel(tag, h);
400  return &(*h);
401 }
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
BranchDescription const & art::DataViewImpl::getProductDescription ( TypeID const &  type,
std::string const &  productInstanceName 
) const
protected

Definition at line 142 of file DataViewImpl.cc.

References branchType_, art::get_ProductDescription(), art::ProductMetaData::instance(), md_, art::ModuleDescription::moduleLabel(), art::ModuleDescription::processName(), and art::ProductMetaData::productList().

Referenced by checkPutProducts(), art::Results::put(), art::Event::put(), art::Run::put_(), art::SubRun::put_(), and retrievedProducts().

144  {
145  return get_ProductDescription(type,
146  md_.processName(),
148  branchType_,
149  md_.moduleLabel(),
150  productInstanceName);
151  }
BranchDescription const & get_ProductDescription(BranchType branch_type, std::string const &module_label, std::string const &instance_name)
BranchType const branchType_
Definition: DataViewImpl.h:283
static ProductMetaData const & instance()
ModuleDescription const & md_
Definition: DataViewImpl.h:280
std::string const & processName() const
std::string const & moduleLabel() const
ProductList const & productList() const
template<typename PROD >
ValidHandle<PROD> art::DataViewImpl::getValidHandle ( ProductToken< PROD > const &  token) const
template<typename PROD >
art::ValidHandle<PROD> art::DataViewImpl::getValidHandle ( InputTag const &  tag) const
inline

Definition at line 405 of file DataViewImpl.h.

References getByLabel(), and art::ValidHandle< T >::provenance().

406 {
407  Handle<PROD> h;
408  getByLabel(tag, h);
409  return ValidHandle<PROD>(&(*h), *h.provenance());
410 }
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
template<typename PROD >
art::ValidHandle<PROD> art::DataViewImpl::getValidHandle ( ProductToken< PROD > const &  token) const
inline

Definition at line 414 of file DataViewImpl.h.

References art::ProductToken< T >::inputTag_.

415 {
416  return getValidHandle<PROD>(token.inputTag_);
417 }
template<typename ELEMENT >
std::size_t art::DataViewImpl::getView ( std::string const &  moduleLabel,
std::string const &  productInstanceName,
std::vector< ELEMENT const * > &  result 
) const
template<typename ELEMENT >
std::size_t art::DataViewImpl::getView ( InputTag const &  tag,
std::vector< ELEMENT const * > &  result 
) const

Definition at line 486 of file DataViewImpl.h.

References fillView_(), art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

488 {
489  auto bhv = getView_<ELEMENT>(tag.label(), tag.instance(), tag.process());
490  std::size_t const orig_size = result.size();
491  fillView_(bhv[0], result);
492  return result.size() - orig_size;
493 } // getView<>()
void fillView_(GroupQueryResult &bh, std::vector< ELEMENT const * > &result) const
Definition: DataViewImpl.h:531
template<typename ELEMENT >
std::size_t art::DataViewImpl::getView ( ViewToken< ELEMENT > const &  token,
std::vector< ELEMENT const * > &  result 
) const
template<typename ELEMENT >
bool art::DataViewImpl::getView ( std::string const &  moduleLabel,
std::string const &  instanceName,
View< ELEMENT > &  result 
) const

Definition at line 497 of file DataViewImpl.h.

References fillView_(), art::View< T >::set_innards(), and art::View< T >::vals().

500 {
501  auto bhv = getView_<ELEMENT>(moduleLabel, productInstanceName, {});
502  fillView_(bhv[0], result.vals());
503  result.set_innards(bhv[0].result()->productID(),
504  bhv[0].result()->uniqueProduct());
505  return true;
506 }
void fillView_(GroupQueryResult &bh, std::vector< ELEMENT const * > &result) const
Definition: DataViewImpl.h:531
template<typename ELEMENT >
bool art::DataViewImpl::getView ( InputTag const &  tag,
View< ELEMENT > &  result 
) const

Definition at line 510 of file DataViewImpl.h.

References fillView_(), art::InputTag::instance(), art::InputTag::label(), art::InputTag::process(), art::View< T >::set_innards(), and art::View< T >::vals().

511 {
512  auto bhv = getView_<ELEMENT>(tag.label(), tag.instance(), tag.process());
513  fillView_(bhv[0], result.vals());
514  result.set_innards(bhv[0].result()->productID(),
515  bhv[0].result()->uniqueProduct());
516  return true;
517 }
void fillView_(GroupQueryResult &bh, std::vector< ELEMENT const * > &result) const
Definition: DataViewImpl.h:531
template<typename ELEMENT >
bool art::DataViewImpl::getView ( ViewToken< ELEMENT > const &  tag,
View< ELEMENT > &  result 
) const

Definition at line 521 of file DataViewImpl.h.

References getView(), and art::ViewToken< Element >::inputTag_.

523 {
524  return getView(token.inputTag_, result);
525 }
std::size_t getView(std::string const &moduleLabel, std::string const &productInstanceName, std::vector< ELEMENT const * > &result) const
Definition: DataViewImpl.h:474
template<typename ELEMENT >
GroupQueryResultVec art::DataViewImpl::getView_ ( std::string const &  moduleLabel,
std::string const &  productInstanceName,
std::string const &  processName 
) const
private
template<typename ELEMENT >
art::DataViewImpl::GroupQueryResultVec art::DataViewImpl::getView_ ( std::string const &  moduleLabel,
std::string const &  productInstanceName,
std::string const &  processName 
) const

Definition at line 453 of file DataViewImpl.h.

References branchType_, consumer_, ensureUniqueProduct_(), getMatchingSequenceByLabel_(), removeNonViewableMatches_(), and art::ProductInfo::ViewElement.

456 {
457  TypeID const typeID{typeid(ELEMENT)};
458  ProductInfo const pinfo{ProductInfo::ConsumableType::ViewElement,
459  typeID,
460  moduleLabel,
461  productInstanceName,
462  processName};
463  consumer_->validateConsumedProduct(branchType_, pinfo);
464  auto bhv =
465  getMatchingSequenceByLabel_(moduleLabel, productInstanceName, processName);
466  removeNonViewableMatches_(typeID, bhv);
468  bhv.size(), typeID, moduleLabel, productInstanceName, processName);
469  return bhv;
470 } // getView_<>()
void ensureUniqueProduct_(std::size_t nFound, TypeID const &typeID, std::string const &moduleLabel, std::string const &productInstanceName, std::string const &processName) const
BranchType const branchType_
Definition: DataViewImpl.h:283
cet::exempt_ptr< Consumer > consumer_
Definition: DataViewImpl.h:291
void removeNonViewableMatches_(TypeID const &requestedElementType, GroupQueryResultVec &results) const
GroupQueryResultVec getMatchingSequenceByLabel_(std::string const &label, std::string const &productInstanceName, std::string const &processName) const
Definition: DataViewImpl.cc:70
DataViewImpl& art::DataViewImpl::operator= ( DataViewImpl const &  )
delete
ProcessHistory const & art::DataViewImpl::processHistory ( ) const

Definition at line 81 of file DataViewImpl.cc.

References principal_, and art::Principal::processHistory().

Referenced by art::Run::endTime(), art::SubRun::endTime(), and art::Event::put().

82  {
83  return principal_.processHistory();
84  }
Principal const & principal_
Definition: DataViewImpl.h:276
ProcessHistory const & processHistory() const
Definition: Principal.h:132
TypeLabelMap& art::DataViewImpl::putProducts ( )
inlineprotected
TypeLabelMap const& art::DataViewImpl::putProducts ( ) const
inlineprotected

Definition at line 188 of file DataViewImpl.h.

References putProducts_.

189  {
190  return putProducts_;
191  }
TypeLabelMap putProducts_
Definition: DataViewImpl.h:266
void art::DataViewImpl::recordAsParent ( Provenance const &  prov) const
protected

Definition at line 87 of file DataViewImpl.cc.

References art::Provenance::parents(), art::Provenance::productDescription(), art::Provenance::productID(), retrievedProducts_, and art::BranchDescription::transient().

Referenced by fillView_(), get(), getByLabel(), and getMany().

88  {
89  if (prov.productDescription().transient()) {
90  // If the product retrieved is transient, don't use its
91  // ProductID; use the ProductID's of its parents.
92  auto const& parents = prov.parents();
93  retrievedProducts_.insert(cbegin(parents), cend(parents));
94  } else {
95  retrievedProducts_.insert(prov.productID());
96  }
97  }
RetrievedProductSet retrievedProducts_
Definition: DataViewImpl.h:272
template<typename PROD >
bool art::DataViewImpl::removeCachedProduct ( Handle< PROD > &  h) const

Definition at line 551 of file DataViewImpl.h.

References art::Handle< T >::clear(), art::Handle< T >::id(), art::Handle< T >::isValid(), art::Handle< T >::provenance(), and removeCachedProduct_().

Referenced by art::Run::endTime(), art::SubRun::endTime(), hit::MCHitFinder::produce(), and art::Event::put().

552 {
553  bool result{false};
554  if (h.isValid() && !h.provenance()->produced()) {
555  removeCachedProduct_(h.id());
556  h.clear();
557  result = true;
558  }
559  return result;
560 }
void removeCachedProduct_(ProductID const pid) const
void art::DataViewImpl::removeCachedProduct_ ( ProductID const  pid) const
private

Definition at line 196 of file DataViewImpl.cc.

References principal_, and art::Principal::removeCachedProduct().

Referenced by removeCachedProduct().

197  {
199  }
Principal const & principal_
Definition: DataViewImpl.h:276
void removeCachedProduct(ProductID const pid) const
Definition: Principal.cc:259
void art::DataViewImpl::removeNonViewableMatches_ ( TypeID const &  requestedElementType,
GroupQueryResultVec results 
) const
private

Definition at line 154 of file DataViewImpl.cc.

References evd::details::begin(), evd::details::end(), art::TypeID::typeInfo(), and art::detail::upcastAllowed().

Referenced by getView_().

156  {
157  // To determine if the requested view is allowed, the matched
158  // 'results' (products) must be read.
159  auto not_convertible = [&requestedElementType](auto const& query_result) {
160  // Assns collections do not support views; we therefore do not
161  // need to worry about an exception throw when calling
162  // uniqueProduct.
163  auto group = query_result.result();
164  assert(group->productDescription().supportsView());
165  auto p = group->uniqueProduct();
166  return !detail::upcastAllowed(*p->typeInfo(),
167  requestedElementType.typeInfo());
168  };
169  results.erase(std::remove_if(begin(results), end(results), not_convertible),
170  end(results));
171  }
std::vector< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
bool upcastAllowed(std::type_info const &tiFrom, std::type_info const &tiTo)
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
DataViewImpl::RetrievedProductIDs art::DataViewImpl::retrievedProductIDs ( ) const
protected

Definition at line 100 of file DataViewImpl.cc.

References retrievedProducts_.

Referenced by art::Event::commit(), and retrievedProducts().

101  {
102  std::vector<ProductID> result;
103  result.reserve(retrievedProducts_.size());
104  result.assign(cbegin(retrievedProducts_), cend(retrievedProducts_));
105  return result;
106  }
RetrievedProductSet retrievedProducts_
Definition: DataViewImpl.h:272
RetrievedProductSet const& art::DataViewImpl::retrievedProducts ( ) const
inlineprotected

Definition at line 197 of file DataViewImpl.h.

References checkPutProducts(), getProductDescription(), putProducts(), retrievedProductIDs(), and retrievedProducts_.

198  {
199  return retrievedProducts_;
200  }
RetrievedProductSet retrievedProducts_
Definition: DataViewImpl.h:272
size_t art::DataViewImpl::size ( void  ) const

Definition at line 34 of file DataViewImpl.cc.

References principal_, putProducts_, and art::Principal::size().

Referenced by art::Event::put().

35  {
36  return putProducts_.size() + principal_.size();
37  }
Principal const & principal_
Definition: DataViewImpl.h:276
size_t size() const
Definition: Principal.h:150
TypeLabelMap putProducts_
Definition: DataViewImpl.h:266

Member Data Documentation

BranchType const art::DataViewImpl::branchType_
private

Definition at line 283 of file DataViewImpl.h.

Referenced by DataViewImpl(), getByLabel(), getMany(), getProductDescription(), and getView_().

cet::exempt_ptr<Consumer> art::DataViewImpl::consumer_
private

Definition at line 291 of file DataViewImpl.h.

Referenced by DataViewImpl(), getByLabel(), getMany(), and getView_().

ModuleDescription const& art::DataViewImpl::md_
private

Definition at line 280 of file DataViewImpl.h.

Referenced by DataViewImpl(), and getProductDescription().

Principal const& art::DataViewImpl::principal_
private
TypeLabelMap art::DataViewImpl::putProducts_ {}
private

Definition at line 266 of file DataViewImpl.h.

Referenced by putProducts(), and size().

bool const art::DataViewImpl::recordParents_
private

Definition at line 286 of file DataViewImpl.h.

Referenced by DataViewImpl(), get(), getByLabel(), and getMany().

RetrievedProductSet art::DataViewImpl::retrievedProducts_ {}
mutableprivate

Definition at line 272 of file DataViewImpl.h.

Referenced by recordAsParent(), retrievedProductIDs(), and retrievedProducts().


The documentation for this class was generated from the following files: