LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
art::detail::CachedProducts Class Reference

#include "CachedProducts.h"

Public Member Functions

void setupDefault (std::vector< std::string > const &trigger_names)
 
void setup (std::vector< std::pair< std::string, std::string >> const &path_specs, std::vector< std::string > const &trigger_names, std::string const &process_name)
 
bool wantEvent (Event const &)
 
art::Handle< art::TriggerResultsgetOneTriggerResults (Event const &) const
 

Private Member Functions

void clearTriggerResults ()
 
void loadTriggerResults (Event const &)
 

Private Attributes

std::vector< ProcessAndEventSelectorp_and_e_selectors_ {}
 
bool loadDone_ {false}
 
unsigned long numberFound_ {}
 

Friends

class PVSentry
 

Detailed Description

Definition at line 71 of file CachedProducts.h.

Member Function Documentation

void art::detail::CachedProducts::clearTriggerResults ( )
private

Definition at line 85 of file CachedProducts.cc.

86 {
87  for_all(p_and_e_selectors_, [](auto& p) { p.clearTriggerResults(); });
88  loadDone_ = false;
89  numberFound_ = 0;
90 }
std::vector< ProcessAndEventSelector > p_and_e_selectors_
art::Handle< art::TriggerResults > art::detail::CachedProducts::getOneTriggerResults ( Event const &  ev) const

Definition at line 68 of file CachedProducts.cc.

References art::errors::ProductNotFound.

Referenced by art::EventObserverBase::getTriggerResults().

69 {
70  const_cast<CachedProducts*>(this)->loadTriggerResults(ev);
71  if (numberFound_ == 1) {
72  return p_and_e_selectors_[0].triggerResults();
73  }
74  if (numberFound_ == 0) {
75  throw art::Exception(art::errors::ProductNotFound, "TooFewProducts")
76  << "CachedProducts::getOneTriggerResults: "
77  << "too few products found, exepcted one, got zero\n";
78  }
79  throw art::Exception(art::errors::ProductNotFound, "TooManyMatches")
80  << "CachedProducts::getOneTriggerResults: "
81  << "too many products found, expected one, got " << numberFound_ << '\n';
82 }
std::vector< ProcessAndEventSelector > p_and_e_selectors_
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
void loadTriggerResults(Event const &)
void art::detail::CachedProducts::loadTriggerResults ( Event const &  ev)
private

Definition at line 93 of file CachedProducts.cc.

References s.

94 {
95  // Get all the TriggerResults objects for the process names we are
96  // interested in.
97  if (loadDone_) {
98  return;
99  }
100  loadDone_ = true;
101  // Note: The loadTriggerResults call might throw, so numberFound_
102  // may be less than expected.
103  for_all(p_and_e_selectors_, [&, this](auto& s) {
104  s.loadTriggerResults(ev);
105  ++numberFound_;
106  });
107 }
Float_t s
Definition: plot.C:23
std::vector< ProcessAndEventSelector > p_and_e_selectors_
void art::detail::CachedProducts::setup ( std::vector< std::pair< std::string, std::string >> const &  path_specs,
std::vector< std::string > const &  trigger_names,
std::string const &  process_name 
)

Definition at line 22 of file CachedProducts.cc.

Referenced by art::EventObserverBase::init_().

26 {
27  // Turn the passed path specs into a map of process name to
28  // a vector of trigger names.
29  map<string, vector<string>> paths_for_process;
30  for (auto const& pr : path_specs) {
31  auto const& pname = pr.first.empty() ? process_name : pr.first;
32  paths_for_process[pname].push_back(pr.second);
33  }
34 
35  // Now go through all the process names found, and create an event
36  // selector for each one.
37  for (auto const& pr : paths_for_process) {
38  auto const& pname = pr.first;
39  auto const& paths = pr.second;
40  if (pname == process_name) {
41  // For the passed process name we have been given the trigger names.
42  p_and_e_selectors_.emplace_back(pname,
43  EventSelector{paths, triggernames});
44  continue;
45  }
46  // For other process names we do not know the trigger names.
47  p_and_e_selectors_.emplace_back(pname, EventSelector{paths});
48  }
49 }
std::vector< ProcessAndEventSelector > p_and_e_selectors_
void art::detail::CachedProducts::setupDefault ( std::vector< std::string > const &  trigger_names)

Definition at line 13 of file CachedProducts.cc.

Referenced by art::EventObserverBase::init_().

14 {
15  // Setup to accept everything.
16  vector<string> paths;
17  EventSelector ES(paths, triggernames);
18  p_and_e_selectors_.emplace_back("", ES);
19 }
std::vector< ProcessAndEventSelector > p_and_e_selectors_
bool art::detail::CachedProducts::wantEvent ( Event const &  ev)

Definition at line 52 of file CachedProducts.cc.

References evd::details::begin(), evd::details::end(), and s.

Referenced by art::EventObserverBase::wantEvent().

53 {
54  // Get all the TriggerResults objects before we test any for a
55  // match, because we have to deal with the possibility there may be
56  // more than one. Note that the existence of more than one object
57  // in the event is intended to lead to an exception throw *unless*
58  // either the configuration has been set to match all events, or the
59  // configuration is set to use specific process names.
61 
62  return any_of(begin(p_and_e_selectors_),
64  [](auto& s) { return s.match(); });
65 }
Float_t s
Definition: plot.C:23
std::vector< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
std::vector< ProcessAndEventSelector > p_and_e_selectors_
void loadTriggerResults(Event const &)
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)

Friends And Related Function Documentation

friend class PVSentry
friend

Definition at line 85 of file CachedProducts.h.

Member Data Documentation

bool art::detail::CachedProducts::loadDone_ {false}
private

Definition at line 87 of file CachedProducts.h.

unsigned long art::detail::CachedProducts::numberFound_ {}
private

Definition at line 88 of file CachedProducts.h.

std::vector<ProcessAndEventSelector> art::detail::CachedProducts::p_and_e_selectors_ {}
private

Definition at line 86 of file CachedProducts.h.


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