Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
art::Principal Class Reference

#include <Principal.h>

Inheritance diagram for art::Principal:
art::PrincipalBase art::EventPrincipal art::ResultsPrincipal art::RunPrincipal art::SubRunPrincipal

Public Types

enum  allowed_processes { allowed_processes::current_process, allowed_processes::input_source, allowed_processes::all }
 
using GroupCollection = std::map< ProductID, std::unique_ptr< Group >>
 
using const_iterator = GroupCollection::const_iterator
 

Public Member Functions

virtual ~Principal () noexcept
 
 Principal (BranchType, ProcessConfiguration const &, cet::exempt_ptr< ProductTable const > presentProducts, ProcessHistoryID const &, std::unique_ptr< DelayedReader > &&)
 
 Principal (RunAuxiliary const &, ProcessConfiguration const &, cet::exempt_ptr< ProductTable const > presentProducts, std::unique_ptr< DelayedReader > &&reader=std::make_unique< NoDelayedReader >())
 
 Principal (SubRunAuxiliary const &, ProcessConfiguration const &, cet::exempt_ptr< ProductTable const > presentProducts, std::unique_ptr< DelayedReader > &&reader=std::make_unique< NoDelayedReader >())
 
 Principal (EventAuxiliary const &, ProcessConfiguration const &, cet::exempt_ptr< ProductTable const > presentProducts, std::unique_ptr< History > &&history=std::make_unique< History >(), std::unique_ptr< DelayedReader > &&reader=std::make_unique< NoDelayedReader >(), bool lastInSubRun=false)
 
 Principal (ResultsAuxiliary const &, ProcessConfiguration const &, cet::exempt_ptr< ProductTable const > presentProducts, std::unique_ptr< DelayedReader > &&reader=std::make_unique< NoDelayedReader >())
 
 Principal (Principal const &)=delete
 
Principaloperator= (Principal const &)=delete
 
GroupQueryResult getByProductID (ProductID const pid) const
 
GroupQueryResult getBySelector (ModuleContext const &mc, WrappedTypeID const &wrapped, SelectorBase const &, ProcessTag const &) const
 
GroupQueryResult getByLabel (ModuleContext const &mc, WrappedTypeID const &wrapped, std::string const &label, std::string const &productInstanceName, ProcessTag const &processTag) const
 
std::vector< GroupQueryResultgetMany (ModuleContext const &mc, WrappedTypeID const &wrapped, SelectorBase const &, ProcessTag const &) const
 
std::vector< InputTaggetInputTags (ModuleContext const &mc, WrappedTypeID const &wrapped, SelectorBase const &, ProcessTag const &) const
 
std::vector< cet::exempt_ptr< Group > > getMatchingSequence (ModuleContext const &, SelectorBase const &, ProcessTag const &) const
 
EDProductGetter const * productGetter (ProductID const &pid) const
 
ProcessHistory const & processHistory () const
 
void removeCachedProduct (ProductID) const
 
OutputHandle getForOutput (ProductID const &, bool resolveProd) const
 
cet::exempt_ptr< BranchDescription const > getProductDescription (ProductID const pid, bool const alwaysEnableLookupOfProducedProducts=false) const
 
void createGroupsForProducedProducts (ProductTables const &producedProducts)
 
void enableLookupOfProducedProducts (ProductTables const &producedProducts)
 
void markProcessHistoryAsModified ()
 
void readImmediate () const
 
ProcessConfiguration const & processConfiguration () const
 
cet::exempt_ptr< ProductProvenance const > branchToProductProvenance (ProductID const &) const
 
size_t size () const
 
const_iterator begin () const
 
const_iterator cbegin () const
 
const_iterator end () const
 
const_iterator cend () const
 
void addToProcessHistory ()
 
BranchType branchType () const
 
RangeSet seenRanges () const
 
void put (BranchDescription const &, std::unique_ptr< ProductProvenance const > &&, std::unique_ptr< EDProduct > &&, std::unique_ptr< RangeSet > &&)
 
RunAuxiliary const & runAux () const
 
SubRunAuxiliary const & subRunAux () const
 
EventAuxiliary const & eventAux () const
 
ResultsAuxiliary const & resultsAux () const
 
RunID const & runID () const
 
SubRunID subRunID () const
 
EventID const & eventID () const
 
RunNumber_t run () const
 
SubRunNumber_t subRun () const
 
EventNumber_t event () const
 
Timestamp const & beginTime () const
 
Timestamp const & endTime () const
 
void endTime (Timestamp const &time)
 
Timestamp const & time () const
 
void updateSeenRanges (RangeSet const &rs)
 
RunPrincipal const & runPrincipal () const
 
SubRunPrincipal const & subRunPrincipal () const
 
cet::exempt_ptr< RunPrincipal const > runPrincipalExemptPtr () const
 
SubRunPrincipal const * subRunPrincipalPtr () const
 
void setRunPrincipal (cet::exempt_ptr< RunPrincipal const > rp)
 
void setSubRunPrincipal (cet::exempt_ptr< SubRunPrincipal const > srp)
 
EventAuxiliary::ExperimentType ExperimentType () const
 
bool isReal () const
 
EventSelectionIDVector const & eventSelectionIDs () const
 
History const & history () const
 
bool isLastInSubRun () const
 
- Public Member Functions inherited from art::PrincipalBase
virtual ~PrincipalBase ()=0
 
 PrincipalBase ()
 
EDProductGetter const * getEDProductGetter (ProductID const &pid) const
 

Protected Member Functions

void fillGroup (BranchDescription const &)
 
void setProcessHistoryIDcombined (ProcessHistoryID const &)
 

Private Member Functions

void ctor_create_groups (cet::exempt_ptr< ProductTable const >)
 
void ctor_read_provenance ()
 
void ctor_fetch_process_history (ProcessHistoryID const &)
 
cet::exempt_ptr< GroupgetGroupLocal (ProductID const) const
 
std::vector< cet::exempt_ptr< Group > > matchingSequenceFromInputFile (ModuleContext const &, SelectorBase const &) const
 
size_t findGroupsFromInputFile (ModuleContext const &, WrappedTypeID const &wrapped, SelectorBase const &, std::vector< cet::exempt_ptr< Group >> &results) const
 
size_t findGroups (ProcessLookup const &, ModuleContext const &, SelectorBase const &, std::vector< cet::exempt_ptr< Group >> &groups) const
 
size_t findGroupsForProcess (std::vector< ProductID > const &vpid, ModuleContext const &mc, SelectorBase const &selector, std::vector< cet::exempt_ptr< Group >> &groups) const
 
bool producedInProcess (ProductID) const
 
bool presentFromSource (ProductID) const
 
auto tryNextSecondaryFile () const
 
std::vector< cet::exempt_ptr< Group > > findGroupsForProduct (ModuleContext const &mc, WrappedTypeID const &wrapped, SelectorBase const &, ProcessTag const &) const
 
EDProductGetter const * getEDProductGetter_ (ProductID const &) const override
 
cet::exempt_ptr< Group const > getGroupTryAllFiles (ProductID const) const
 

Private Attributes

BranchType branchType_ {}
 
ProcessHistory processHistory_ {}
 
std::atomic< boolprocessHistoryModified_
 
ProcessConfiguration const & processConfiguration_
 
std::atomic< ProductTable const * > presentProducts_
 
std::atomic< ProductTable const * > producedProducts_
 
std::atomic< boolenableLookupOfProducedProducts_
 
std::recursive_mutex groupMutex_ {}
 
GroupCollection groups_ {}
 
std::unique_ptr< DelayedReaderdelayedReader_ {nullptr}
 
std::vector< std::unique_ptr< Principal > > secondaryPrincipals_ {}
 
int nextSecondaryFileIdx_ {}
 
RangeSet rangeSet_ {RangeSet::invalid()}
 
RunAuxiliary runAux_ {}
 
SubRunAuxiliary subRunAux_ {}
 
std::atomic< EventAuxiliary * > eventAux_
 
ResultsAuxiliary resultsAux_ {}
 
cet::exempt_ptr< RunPrincipal const > runPrincipal_ {nullptr}
 
std::atomic< SubRunPrincipal const * > subRunPrincipal_
 
std::unique_ptr< Historyhistory_ {nullptr}
 
bool lastInSubRun_ {false}
 

Detailed Description

Definition at line 54 of file Principal.h.

Member Typedef Documentation

using art::Principal::const_iterator = GroupCollection::const_iterator

Definition at line 57 of file Principal.h.

using art::Principal::GroupCollection = std::map<ProductID, std::unique_ptr<Group>>

Definition at line 56 of file Principal.h.

Member Enumeration Documentation

Enumerator
current_process 
input_source 
all 

Definition at line 58 of file Principal.h.

58 { current_process, input_source, all };
static QInternalList< QTextCodec > * all
Definition: qtextcodec.cpp:63

Constructor & Destructor Documentation

virtual art::Principal::~Principal ( )
inlinevirtualnoexcept

Definition at line 64 of file Principal.h.

65  {
66  presentProducts_ = nullptr;
67  producedProducts_ = nullptr;
68  delete eventAux_.load();
69  }
std::atomic< ProductTable const * > producedProducts_
Definition: Principal.h:303
std::atomic< ProductTable const * > presentProducts_
Definition: Principal.h:302
std::atomic< EventAuxiliary * > eventAux_
Definition: Principal.h:337
art::Principal::Principal ( BranchType  branchType,
ProcessConfiguration const &  pc,
cet::exempt_ptr< ProductTable const >  presentProducts,
ProcessHistoryID const &  hist,
std::unique_ptr< DelayedReader > &&  reader 
)

Definition at line 124 of file Principal.cc.

131  , delayedReader_{std::move(reader)}
132  {
133  processHistoryModified_ = false;
134  presentProducts_ = presentProducts.get();
135  producedProducts_ = nullptr;
137  delayedReader_->setPrincipal(this);
138  eventAux_ = nullptr;
139  subRunPrincipal_ = nullptr;
140  ctor_create_groups(presentProducts);
143  }
std::atomic< bool > processHistoryModified_
Definition: Principal.h:298
std::atomic< bool > enableLookupOfProducedProducts_
Definition: Principal.h:304
constexpr pointer get() const noexcept
Definition: exempt_ptr.h:148
std::atomic< SubRunPrincipal const * > subRunPrincipal_
Definition: Principal.h:341
BranchType branchType_
Definition: Principal.h:296
std::atomic< ProductTable const * > producedProducts_
Definition: Principal.h:303
def move(depos, offset)
Definition: depos.py:107
std::atomic< ProductTable const * > presentProducts_
Definition: Principal.h:302
void ctor_fetch_process_history(ProcessHistoryID const &)
Definition: Principal.cc:114
void ctor_create_groups(cet::exempt_ptr< ProductTable const >)
Definition: Principal.cc:72
ProcessConfiguration const & processConfiguration_
Definition: Principal.h:299
std::atomic< EventAuxiliary * > eventAux_
Definition: Principal.h:337
void ctor_read_provenance()
Definition: Principal.cc:93
std::unique_ptr< DelayedReader > delayedReader_
Definition: Principal.h:316
BranchType branchType() const
Definition: Principal.cc:1022
art::Principal::Principal ( RunAuxiliary const &  aux,
ProcessConfiguration const &  pc,
cet::exempt_ptr< ProductTable const >  presentProducts,
std::unique_ptr< DelayedReader > &&  reader = std::make_unique<NoDelayedReader>() 
)

Definition at line 146 of file Principal.cc.

151  : branchType_{InRun}
153  , delayedReader_{std::move(reader)}
154  , runAux_{aux}
155  {
156  processHistoryModified_ = false;
157  presentProducts_ = presentProducts.get();
158  producedProducts_ = nullptr;
160  delayedReader_->setPrincipal(this);
161  eventAux_ = nullptr;
162  subRunPrincipal_ = nullptr;
163  ctor_create_groups(presentProducts);
166  }
std::atomic< bool > processHistoryModified_
Definition: Principal.h:298
std::atomic< bool > enableLookupOfProducedProducts_
Definition: Principal.h:304
constexpr pointer get() const noexcept
Definition: exempt_ptr.h:148
std::atomic< SubRunPrincipal const * > subRunPrincipal_
Definition: Principal.h:341
BranchType branchType_
Definition: Principal.h:296
std::atomic< ProductTable const * > producedProducts_
Definition: Principal.h:303
def move(depos, offset)
Definition: depos.py:107
std::atomic< ProductTable const * > presentProducts_
Definition: Principal.h:302
void ctor_fetch_process_history(ProcessHistoryID const &)
Definition: Principal.cc:114
void ctor_create_groups(cet::exempt_ptr< ProductTable const >)
Definition: Principal.cc:72
ProcessConfiguration const & processConfiguration_
Definition: Principal.h:299
std::atomic< EventAuxiliary * > eventAux_
Definition: Principal.h:337
void ctor_read_provenance()
Definition: Principal.cc:93
ProcessHistoryID & processHistoryID() const noexcept
Definition: RunAuxiliary.cc:67
RunAuxiliary runAux_
Definition: Principal.h:333
std::unique_ptr< DelayedReader > delayedReader_
Definition: Principal.h:316
art::Principal::Principal ( SubRunAuxiliary const &  aux,
ProcessConfiguration const &  pc,
cet::exempt_ptr< ProductTable const >  presentProducts,
std::unique_ptr< DelayedReader > &&  reader = std::make_unique<NoDelayedReader>() 
)

Definition at line 169 of file Principal.cc.

176  , delayedReader_{std::move(reader)}
177  , subRunAux_{aux}
178  {
179  processHistoryModified_ = false;
180  presentProducts_ = presentProducts.get();
181  producedProducts_ = nullptr;
183  delayedReader_->setPrincipal(this);
184  eventAux_ = nullptr;
185  subRunPrincipal_ = nullptr;
186  ctor_create_groups(presentProducts);
189  }
std::atomic< bool > processHistoryModified_
Definition: Principal.h:298
std::atomic< bool > enableLookupOfProducedProducts_
Definition: Principal.h:304
constexpr pointer get() const noexcept
Definition: exempt_ptr.h:148
std::atomic< SubRunPrincipal const * > subRunPrincipal_
Definition: Principal.h:341
BranchType branchType_
Definition: Principal.h:296
std::atomic< ProductTable const * > producedProducts_
Definition: Principal.h:303
def move(depos, offset)
Definition: depos.py:107
std::atomic< ProductTable const * > presentProducts_
Definition: Principal.h:302
void ctor_fetch_process_history(ProcessHistoryID const &)
Definition: Principal.cc:114
void ctor_create_groups(cet::exempt_ptr< ProductTable const >)
Definition: Principal.cc:72
ProcessConfiguration const & processConfiguration_
Definition: Principal.h:299
std::atomic< EventAuxiliary * > eventAux_
Definition: Principal.h:337
void ctor_read_provenance()
Definition: Principal.cc:93
ProcessHistoryID const & processHistoryID() const noexcept
std::unique_ptr< DelayedReader > delayedReader_
Definition: Principal.h:316
SubRunAuxiliary subRunAux_
Definition: Principal.h:334
art::Principal::Principal ( EventAuxiliary const &  aux,
ProcessConfiguration const &  pc,
cet::exempt_ptr< ProductTable const >  presentProducts,
std::unique_ptr< History > &&  history = std::make_unique<History>(),
std::unique_ptr< DelayedReader > &&  reader = std::make_unique<NoDelayedReader>(),
bool  lastInSubRun = false 
)

Definition at line 192 of file Principal.cc.

202  , delayedReader_{std::move(reader)}
203  , history_{move(history)}
204  , lastInSubRun_{lastInSubRun}
205  {
206  processHistoryModified_ = false;
207  presentProducts_ = presentProducts.get();
208  producedProducts_ = nullptr;
210  delayedReader_->setPrincipal(this);
211  eventAux_ = new EventAuxiliary(aux);
212  subRunPrincipal_ = nullptr;
213  ctor_create_groups(presentProducts);
215  ctor_fetch_process_history(history_->processHistoryID());
216  }
std::atomic< bool > processHistoryModified_
Definition: Principal.h:298
std::atomic< bool > enableLookupOfProducedProducts_
Definition: Principal.h:304
constexpr pointer get() const noexcept
Definition: exempt_ptr.h:148
std::atomic< SubRunPrincipal const * > subRunPrincipal_
Definition: Principal.h:341
BranchType branchType_
Definition: Principal.h:296
std::atomic< ProductTable const * > producedProducts_
Definition: Principal.h:303
std::unique_ptr< History > history_
Definition: Principal.h:342
def move(depos, offset)
Definition: depos.py:107
bool lastInSubRun_
Definition: Principal.h:343
std::atomic< ProductTable const * > presentProducts_
Definition: Principal.h:302
void ctor_fetch_process_history(ProcessHistoryID const &)
Definition: Principal.cc:114
void ctor_create_groups(cet::exempt_ptr< ProductTable const >)
Definition: Principal.cc:72
ProcessConfiguration const & processConfiguration_
Definition: Principal.h:299
std::atomic< EventAuxiliary * > eventAux_
Definition: Principal.h:337
void ctor_read_provenance()
Definition: Principal.cc:93
std::unique_ptr< DelayedReader > delayedReader_
Definition: Principal.h:316
art::Principal::Principal ( ResultsAuxiliary const &  aux,
ProcessConfiguration const &  pc,
cet::exempt_ptr< ProductTable const >  presentProducts,
std::unique_ptr< DelayedReader > &&  reader = std::make_unique<NoDelayedReader>() 
)

Definition at line 219 of file Principal.cc.

226  , delayedReader_{std::move(reader)}
227  , resultsAux_{aux}
228  {
229  processHistoryModified_ = false;
230  presentProducts_ = presentProducts.get();
231  producedProducts_ = nullptr;
233  delayedReader_->setPrincipal(this);
234  eventAux_ = nullptr;
235  subRunPrincipal_ = nullptr;
236  ctor_create_groups(presentProducts);
239  }
std::atomic< bool > processHistoryModified_
Definition: Principal.h:298
std::atomic< bool > enableLookupOfProducedProducts_
Definition: Principal.h:304
constexpr pointer get() const noexcept
Definition: exempt_ptr.h:148
ProcessHistoryID & processHistoryID() const
std::atomic< SubRunPrincipal const * > subRunPrincipal_
Definition: Principal.h:341
BranchType branchType_
Definition: Principal.h:296
std::atomic< ProductTable const * > producedProducts_
Definition: Principal.h:303
def move(depos, offset)
Definition: depos.py:107
std::atomic< ProductTable const * > presentProducts_
Definition: Principal.h:302
void ctor_fetch_process_history(ProcessHistoryID const &)
Definition: Principal.cc:114
void ctor_create_groups(cet::exempt_ptr< ProductTable const >)
Definition: Principal.cc:72
ProcessConfiguration const & processConfiguration_
Definition: Principal.h:299
std::atomic< EventAuxiliary * > eventAux_
Definition: Principal.h:337
void ctor_read_provenance()
Definition: Principal.cc:93
std::unique_ptr< DelayedReader > delayedReader_
Definition: Principal.h:316
ResultsAuxiliary resultsAux_
Definition: Principal.h:339
art::Principal::Principal ( Principal const &  )
delete

Member Function Documentation

void art::Principal::addToProcessHistory ( )

Definition at line 563 of file Principal.cc.

564  {
565  bool expected = false;
566  if (processHistoryModified_.compare_exchange_strong(expected, true)) {
567  // MT note: We have now locked out any other task trying to
568  // modify the process history. Now we have to block
569  // tasks that already have a pointer to the process
570  // history from accessing its internals while we update
571  // it. We do not protect the iteration interface, the
572  // begin(), end(), and size() are all separate calls
573  // and we cannot lock in each one because there is no
574  // way to automatically unlock.
575  std::lock_guard sentry{processHistory_.get_mutex()};
576  string const& processName = processConfiguration_.processName();
577  for (auto const& val : processHistory_) {
578  if (processName == val.processName()) {
580  << "The process name " << processName
581  << " was previously used on these products.\n"
582  << "Please modify the configuration file to use a "
583  << "distinct process name.\n";
584  }
585  }
586  processHistory_.push_back(processConfiguration_);
587  // Optimization note: As of 0_9_0_pre3 For very simple Sources
588  // (e.g. EmptyEvent) this routine takes up nearly 50% of the
589  // time per event, and 96% of the time for this routine is spent
590  // in computing the ProcessHistory id which happens because we
591  // are reconstructing the ProcessHistory for each event. It
592  // would probably be better to move the ProcessHistory
593  // construction out to somewhere which persists for longer than
594  // one Event.
595  auto const phid = processHistory_.id();
596  ProcessHistoryRegistry::emplace(phid, processHistory_);
597  // MT note: We must protect processHistory_! The id() call can
598  // modify it! Note: threading: We are modifying Run,
599  // SubRun, Event, and Results principals here, and
600  // their *Auxiliary Note: threading: and the event
601  // principal art::History.
602  setProcessHistoryIDcombined(processHistory_.id());
603  }
604  }
std::atomic< bool > processHistoryModified_
Definition: Principal.h:298
const char expected[]
Definition: Exception_t.cc:22
ProcessHistory processHistory_
Definition: Principal.h:297
std::recursive_mutex & get_mutex() const
success_t id() const
void setProcessHistoryIDcombined(ProcessHistoryID const &)
Definition: Principal.cc:272
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
ProcessConfiguration const & processConfiguration_
Definition: Principal.h:299
std::string const & processName() const noexcept
static auto emplace(value_type const &value)
Principal::const_iterator art::Principal::begin ( ) const

Definition at line 386 of file Principal.cc.

387  {
388  std::lock_guard sentry{groupMutex_};
389  return groups_.begin();
390  }
GroupCollection groups_
Definition: Principal.h:312
std::recursive_mutex groupMutex_
Definition: Principal.h:307
Timestamp const & art::Principal::beginTime ( ) const

Definition at line 1097 of file Principal.cc.

1098  {
1099  if (branchType_ == InRun) {
1100  return runAux_.beginTime();
1101  }
1102  return subRunAux_.beginTime();
1103  }
Timestamp const & beginTime() const noexcept
Definition: RunAuxiliary.cc:85
BranchType branchType_
Definition: Principal.h:296
RunAuxiliary runAux_
Definition: Principal.h:333
SubRunAuxiliary subRunAux_
Definition: Principal.h:334
Timestamp const & beginTime() const noexcept
cet::exempt_ptr< ProductProvenance const > art::Principal::branchToProductProvenance ( ProductID const &  pid) const

Definition at line 438 of file Principal.cc.

439  {
440  // Note: The input source lock will be held when this routine is called.
441  //
442  // MT-TODO: For right now ignore the delay reading option for
443  // product provenance. If we do the delay reading then we
444  // must use a lock to interlock all fetches of provenance
445  // because the delay read fills the pp_by_pid_ one entry
446  // at a time, and we do not want other threads to find
447  // the info only partly there.
449  auto g = getGroupLocal(pid);
450  if (g.get() != nullptr) {
451  ret = g->productProvenance();
452  }
453  return ret;
454  }
static constexpr double g
Definition: Units.h:144
cet::exempt_ptr< Group > getGroupLocal(ProductID const) const
Definition: Principal.cc:1164
BranchType art::Principal::branchType ( ) const

Definition at line 1022 of file Principal.cc.

1023  {
1024  return branchType_;
1025  }
BranchType branchType_
Definition: Principal.h:296
Principal::const_iterator art::Principal::cbegin ( ) const

Definition at line 393 of file Principal.cc.

394  {
395  std::lock_guard sentry{groupMutex_};
396  return groups_.cbegin();
397  }
GroupCollection groups_
Definition: Principal.h:312
std::recursive_mutex groupMutex_
Definition: Principal.h:307
Principal::const_iterator art::Principal::cend ( ) const

Definition at line 407 of file Principal.cc.

408  {
409  std::lock_guard sentry{groupMutex_};
410  return groups_.cend();
411  }
GroupCollection groups_
Definition: Principal.h:312
std::recursive_mutex groupMutex_
Definition: Principal.h:307
void art::Principal::createGroupsForProducedProducts ( ProductTables const &  producedProducts)

Definition at line 314 of file Principal.cc.

316  {
317  auto const& produced = producedProducts.get(branchType_);
318  producedProducts_ = &produced;
319  if (produced.descriptions.empty()) {
320  return;
321  }
322  // The process history is expanded if there is a product that is
323  // produced in this process.
325  for (auto const& pr : produced.descriptions) {
326  auto const& pd = pr.second;
327  assert(pd.branchType() == branchType_);
328  // Create a group for the produced product.
329  fillGroup(pd);
330  }
331  }
void addToProcessHistory()
Definition: Principal.cc:563
BranchType branchType_
Definition: Principal.h:296
std::atomic< ProductTable const * > producedProducts_
Definition: Principal.h:303
void fillGroup(BranchDescription const &)
Definition: Principal.cc:242
void art::Principal::ctor_create_groups ( cet::exempt_ptr< ProductTable const >  presentProducts)
private

Definition at line 72 of file Principal.cc.

74  {
75  if (!presentProducts) {
76  return;
77  }
78  // Note: Dropped products are a problem. We should not create
79  // groups for them now because later we may open a secondary
80  // file which actually contains them and we want the
81  // secondary principal to have those groups. However some
82  // code expects to be able to find a group for dropped
83  // products, so getGroupTryAllFiles ignores groups for
84  // dropped products instead.
85  for (auto const& pr : presentProducts->descriptions) {
86  auto const& pd = pr.second;
87  assert(pd.branchType() == branchType_);
88  fillGroup(pd);
89  }
90  }
BranchType branchType_
Definition: Principal.h:296
void fillGroup(BranchDescription const &)
Definition: Principal.cc:242
void art::Principal::ctor_fetch_process_history ( ProcessHistoryID const &  phid)
private

Definition at line 114 of file Principal.cc.

115  {
116  if (!phid.isValid()) {
117  return;
118  }
119  ProcessHistory processHistory;
120  ProcessHistoryRegistry::get(phid, processHistory);
121  std::swap(processHistory_, processHistory);
122  }
ProcessHistory processHistory_
Definition: Principal.h:297
static collection_type const & get()
void swap(Handle< T > &a, Handle< T > &b)
ProcessHistory const & processHistory() const
Definition: Principal.cc:363
void art::Principal::ctor_read_provenance ( )
private

Definition at line 93 of file Principal.cc.

94  {
95  auto ppv = delayedReader_->readProvenance();
96  for (auto iter = ppv.begin(), end = ppv.end(); iter != end; ++iter) {
97  auto g = getGroupLocal(iter->productID());
98  if (g.get() == nullptr) {
99  continue;
100  }
101  if (iter->productStatus() != productstatus::unknown()) {
102  g->setProductProvenance(make_unique<ProductProvenance>(*iter));
103  } else {
104  // We have an old format file, convert.
105  g->setProductProvenance(make_unique<ProductProvenance>(
106  iter->productID(),
108  iter->parentage().parents()));
109  }
110  }
111  }
static constexpr double g
Definition: Units.h:144
const_iterator end() const
Definition: Principal.cc:400
constexpr ProductStatus dummyToPreventDoubleCount() noexcept
Definition: ProductStatus.h:25
constexpr ProductStatus unknown() noexcept
Definition: ProductStatus.h:31
cet::exempt_ptr< Group > getGroupLocal(ProductID const) const
Definition: Principal.cc:1164
std::unique_ptr< DelayedReader > delayedReader_
Definition: Principal.h:316
void art::Principal::enableLookupOfProducedProducts ( ProductTables const &  producedProducts)

Definition at line 334 of file Principal.cc.

336  {
338  }
std::atomic< bool > enableLookupOfProducedProducts_
Definition: Principal.h:304
Principal::const_iterator art::Principal::end ( ) const

Definition at line 400 of file Principal.cc.

401  {
402  std::lock_guard sentry{groupMutex_};
403  return groups_.end();
404  }
GroupCollection groups_
Definition: Principal.h:312
std::recursive_mutex groupMutex_
Definition: Principal.h:307
Timestamp const & art::Principal::endTime ( ) const

Definition at line 1106 of file Principal.cc.

1107  {
1108  if (branchType_ == InRun) {
1109  return runAux_.endTime();
1110  }
1111  return subRunAux_.endTime();
1112  }
BranchType branchType_
Definition: Principal.h:296
Timestamp const & endTime() const noexcept
Timestamp const & endTime() const noexcept
Definition: RunAuxiliary.cc:91
RunAuxiliary runAux_
Definition: Principal.h:333
SubRunAuxiliary subRunAux_
Definition: Principal.h:334
void art::Principal::endTime ( Timestamp const &  time)

Definition at line 1115 of file Principal.cc.

1116  {
1117  if (branchType_ == InRun) {
1118  runAux_.endTime(time);
1119  return;
1120  }
1122  }
BranchType branchType_
Definition: Principal.h:296
Timestamp const & endTime() const noexcept
Definition: RunAuxiliary.cc:91
RunAuxiliary runAux_
Definition: Principal.h:333
void setEndTime(Timestamp const &time)
SubRunAuxiliary subRunAux_
Definition: Principal.h:334
EventNumber_t art::Principal::event ( ) const

Definition at line 1091 of file Principal.cc.

1092  {
1093  return eventAux_.load()->id().event();
1094  }
std::atomic< EventAuxiliary * > eventAux_
Definition: Principal.h:337
EventAuxiliary const & art::Principal::eventAux ( ) const

Definition at line 1040 of file Principal.cc.

1041  {
1042  return *eventAux_.load();
1043  }
std::atomic< EventAuxiliary * > eventAux_
Definition: Principal.h:337
EventID const & art::Principal::eventID ( ) const

Definition at line 1064 of file Principal.cc.

1065  {
1066  return eventAux_.load()->id();
1067  }
std::atomic< EventAuxiliary * > eventAux_
Definition: Principal.h:337
EventSelectionIDVector const & art::Principal::eventSelectionIDs ( ) const

Definition at line 908 of file Principal.cc.

909  {
910  return history_->eventSelectionIDs();
911  }
std::unique_ptr< History > history_
Definition: Principal.h:342
EventAuxiliary::ExperimentType art::Principal::ExperimentType ( ) const

Definition at line 896 of file Principal.cc.

897  {
898  return eventAux_.load()->experimentType();
899  }
std::atomic< EventAuxiliary * > eventAux_
Definition: Principal.h:337
void art::Principal::fillGroup ( BranchDescription const &  pd)
protected

Definition at line 242 of file Principal.cc.

243  {
244  std::lock_guard sentry{groupMutex_};
245  auto it = groups_.find(pd.productID());
246  if (it != std::cend(groups_)) {
247  // The 'combinable' call does not require that the processing
248  // history be the same, which is not what we are checking for here.
249  auto const& found_pd = it->second->productDescription();
250  if (combinable(found_pd, pd)) {
252  << "The process name " << pd.processName()
253  << " was previously used on these products.\n"
254  << "Please modify the configuration file to use a "
255  << "distinct process name.\n";
256  }
258  << "The product ID " << pd.productID() << " of the new product:\n"
259  << pd
260  << " collides with the product ID of the already-existing product:\n"
261  << found_pd
262  << "Please modify the instance name of the new product so as to avoid "
263  "the product ID collision.\n"
264  << "In addition, please notify artists@fnal.gov of this error.\n";
265  }
266 
267  unique_ptr<Group> group = create_group(delayedReader_.get(), pd);
268  groups_[pd.productID()] = move(group);
269  }
decltype(auto) constexpr cend(T &&obj)
ADL-aware version of std::cend.
Definition: StdUtils.h:87
GroupCollection groups_
Definition: Principal.h:312
std::recursive_mutex groupMutex_
Definition: Principal.h:307
def move(depos, offset)
Definition: depos.py:107
bool combinable(BranchDescription const &a, BranchDescription const &b)
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::unique_ptr< DelayedReader > delayedReader_
Definition: Principal.h:316
std::size_t art::Principal::findGroups ( ProcessLookup const &  pl,
ModuleContext const &  mc,
SelectorBase const &  sel,
std::vector< cet::exempt_ptr< Group >> &  groups 
) const
private

Definition at line 607 of file Principal.cc.

611  {
612  // Loop over processes in reverse time order. Sometimes we want
613  // to stop after we find a process with matches so check for that
614  // at each step.
615  std::size_t found{};
616  // MT note: We must protect the process history iterators here
617  // against possible invalidation by output modules
618  // inserting a process history entry while we are
619  // iterating.
620  std::lock_guard sentry{processHistory_.get_mutex()};
621  // We must skip over duplicate entries of the same process
622  // configuration in the process history. This unfortunately
623  // happened with the SamplingInput source.
624  for (auto const& h :
625  ranges::views::reverse(processHistory_) | ranges::views::unique) {
626  if (auto it = pl.find(h.processName()); it != pl.end()) {
627  found += findGroupsForProcess(it->second, mc, sel, groups);
628  }
629  }
630  return found;
631  }
ProcessHistory processHistory_
Definition: Principal.h:297
std::recursive_mutex & get_mutex() const
static unsigned int reverse(QString &chars, unsigned char *level, unsigned int a, unsigned int b)
Definition: qstring.cpp:11649
size_t findGroupsForProcess(std::vector< ProductID > const &vpid, ModuleContext const &mc, SelectorBase const &selector, std::vector< cet::exempt_ptr< Group >> &groups) const
Definition: Principal.cc:813
std::size_t art::Principal::findGroupsForProcess ( std::vector< ProductID > const &  vpid,
ModuleContext const &  mc,
SelectorBase const &  selector,
std::vector< cet::exempt_ptr< Group >> &  groups 
) const
private

Definition at line 813 of file Principal.cc.

818  {
819  std::size_t found{}; // Horrible hack that should go away
820  for (auto const pid : vpid) {
821  auto group = getGroupLocal(pid);
822  if (!group) {
823  continue;
824  }
825  auto const& pd = group->productDescription();
826  // If we are processing a trigger path, the only visible
827  // produced products are those that originate from modules on
828  // the same path we're currently processing.
829  if (mc.onTriggerPath() && pd.produced() &&
830  !mc.onSamePathAs(pd.moduleLabel())) {
831  continue;
832  }
833  if (!sel.match(pd)) {
834  continue;
835  }
836  // Found a good match, save it.
837  res.emplace_back(group);
838  ++found;
839  }
840  return found;
841  }
cet::exempt_ptr< Group > getGroupLocal(ProductID const) const
Definition: Principal.cc:1164
std::vector< cet::exempt_ptr< Group > > art::Principal::findGroupsForProduct ( ModuleContext const &  mc,
WrappedTypeID const &  wrapped,
SelectorBase const &  selector,
ProcessTag const &  processTag 
) const
private

Definition at line 771 of file Principal.cc.

775  {
776  std::vector<cet::exempt_ptr<Group>> results;
777  unsigned ret{};
778  // Find groups from current process
779  if (processTag.current_process_search_allowed() &&
781  auto const& lookup = producedProducts_.load()->productLookup;
782  auto it = lookup.find(wrapped.product_type.friendlyClassName());
783  if (it != lookup.end()) {
784  ret += findGroups(it->second, mc, selector, results);
785  }
786  }
787 
788  if (!processTag.input_source_search_allowed()) {
789  return results;
790  }
791 
792  // Look through currently opened input files
793  ret += findGroupsFromInputFile(mc, wrapped, selector, results);
794  if (ret) {
795  return results;
796  }
797  for (auto const& sp : secondaryPrincipals_) {
798  if (sp->findGroupsFromInputFile(mc, wrapped, selector, results)) {
799  return results;
800  }
801  }
802  // Open more secondary files if necessary
803  while (auto sp = tryNextSecondaryFile()) {
804  auto& new_sp = secondaryPrincipals_.emplace_back(move(sp));
805  if (new_sp->findGroupsFromInputFile(mc, wrapped, selector, results)) {
806  return results;
807  }
808  }
809  return results;
810  }
size_t findGroups(ProcessLookup const &, ModuleContext const &, SelectorBase const &, std::vector< cet::exempt_ptr< Group >> &groups) const
Definition: Principal.cc:607
std::atomic< bool > enableLookupOfProducedProducts_
Definition: Principal.h:304
auto tryNextSecondaryFile() const
Definition: Principal.cc:690
size_t findGroupsFromInputFile(ModuleContext const &, WrappedTypeID const &wrapped, SelectorBase const &, std::vector< cet::exempt_ptr< Group >> &results) const
Definition: Principal.cc:753
std::atomic< ProductTable const * > producedProducts_
Definition: Principal.h:303
def move(depos, offset)
Definition: depos.py:107
std::vector< std::unique_ptr< Principal > > secondaryPrincipals_
Definition: Principal.h:326
std::size_t art::Principal::findGroupsFromInputFile ( ModuleContext const &  mc,
WrappedTypeID const &  wrapped,
SelectorBase const &  selector,
std::vector< cet::exempt_ptr< Group >> &  results 
) const
private

Definition at line 753 of file Principal.cc.

758  {
759  if (!presentProducts_.load()) {
760  return 0;
761  }
762  auto const& lookup = presentProducts_.load()->productLookup;
763  auto it = lookup.find(wrapped.product_type.friendlyClassName());
764  if (it == lookup.end()) {
765  return 0;
766  }
767  return findGroups(it->second, mc, selector, groups);
768  }
size_t findGroups(ProcessLookup const &, ModuleContext const &, SelectorBase const &, std::vector< cet::exempt_ptr< Group >> &groups) const
Definition: Principal.cc:607
std::atomic< ProductTable const * > presentProducts_
Definition: Principal.h:302
GroupQueryResult art::Principal::getByLabel ( ModuleContext const &  mc,
WrappedTypeID const &  wrapped,
std::string const &  label,
std::string const &  productInstanceName,
ProcessTag const &  processTag 
) const

Definition at line 652 of file Principal.cc.

657  {
658  auto const& processName = processTag.name();
659  Selector const sel{ModuleLabelSelector{label} &&
660  ProductInstanceNameSelector{productInstanceName} &&
661  ProcessNameSelector{processName}};
662  return getBySelector(mc, wrapped, sel, processTag);
663  }
GroupQueryResult getBySelector(ModuleContext const &mc, WrappedTypeID const &wrapped, SelectorBase const &, ProcessTag const &) const
Definition: Principal.cc:634
GroupQueryResult art::Principal::getByProductID ( ProductID const  pid) const

Definition at line 1151 of file Principal.cc.

1152  {
1153  if (auto const g = getGroupTryAllFiles(pid)) {
1154  return GroupQueryResult{g};
1155  }
1156  auto whyFailed =
1157  make_shared<Exception>(errors::ProductNotFound, "InvalidID");
1158  *whyFailed << "Principal::getByProductID: no product with branch type: "
1159  << branchType_ << " product id: " << pid << '\n';
1160  return GroupQueryResult{whyFailed};
1161  }
static constexpr double g
Definition: Units.h:144
BranchType branchType_
Definition: Principal.h:296
cet::exempt_ptr< Group const > getGroupTryAllFiles(ProductID const) const
Definition: Principal.cc:1172
GroupQueryResult art::Principal::getBySelector ( ModuleContext const &  mc,
WrappedTypeID const &  wrapped,
SelectorBase const &  sel,
ProcessTag const &  processTag 
) const

Definition at line 634 of file Principal.cc.

638  {
639  auto const groups = findGroupsForProduct(mc, wrapped, sel, processTag);
640  auto const result = resolve_unique_product(groups, wrapped);
641  if (!result.has_value()) {
642  auto whyFailed = std::make_shared<Exception>(errors::ProductNotFound);
643  *whyFailed << "Found zero products matching all selection criteria\n"
644  << indent << "C++ type: " << wrapped.product_type << "\n"
645  << sel.print(indent);
646  return GroupQueryResult{whyFailed};
647  }
648  return *result;
649  }
static QCString result
std::optional< GroupQueryResult > resolve_unique_product(std::vector< cet::exempt_ptr< art::Group >> const &product_groups, art::WrappedTypeID const &wrapped)
Definition: Group.cc:387
std::vector< cet::exempt_ptr< Group > > findGroupsForProduct(ModuleContext const &mc, WrappedTypeID const &wrapped, SelectorBase const &, ProcessTag const &) const
Definition: Principal.cc:771
EDProductGetter const * art::Principal::getEDProductGetter_ ( ProductID const &  pid) const
overrideprivatevirtual

Implements art::PrincipalBase.

Definition at line 308 of file Principal.cc.

309  {
310  return productGetter(pid);
311  }
EDProductGetter const * productGetter(ProductID const &pid) const
Definition: Principal.cc:297
OutputHandle art::Principal::getForOutput ( ProductID const &  pid,
bool  resolveProd 
) const

Definition at line 965 of file Principal.cc.

966  {
967  // MT-FIXME: Uses of group!
968  auto g = getGroupTryAllFiles(pid);
969  if (g.get() == nullptr) {
970  return OutputHandle::invalid();
971  }
972  if (resolveProd) {
973  if (!g->resolveProductIfAvailable()) {
974  // Behavior is the same as if the group wasn't there.
975  return OutputHandle::invalid();
976  }
977  if (g->anyProduct() == nullptr) {
978  return OutputHandle::invalid();
979  }
980  if (!g->anyProduct()->isPresent()) {
981  return OutputHandle::invalid();
982  }
983  }
984  if (!g->anyProduct() && !g->productProvenance()) {
985  return OutputHandle{g->rangeOfValidity()};
986  }
987  return OutputHandle{g->anyProduct(),
988  &g->productDescription(),
989  g->productProvenance(),
990  g->rangeOfValidity()};
991  }
static constexpr double g
Definition: Units.h:144
static OutputHandle invalid()
Definition: OutputHandle.h:44
cet::exempt_ptr< Group const > getGroupTryAllFiles(ProductID const) const
Definition: Principal.cc:1172
cet::exempt_ptr< Group > art::Principal::getGroupLocal ( ProductID const  pid) const
private

Definition at line 1164 of file Principal.cc.

1165  {
1166  std::lock_guard sentry{groupMutex_};
1167  auto it = groups_.find(pid);
1168  return it != groups_.cend() ? it->second.get() : nullptr;
1169  }
GroupCollection groups_
Definition: Principal.h:312
std::recursive_mutex groupMutex_
Definition: Principal.h:307
cet::exempt_ptr< Group const > art::Principal::getGroupTryAllFiles ( ProductID const  pid) const
private

Definition at line 1172 of file Principal.cc.

1173  {
1174  // Look through current process and currently opened primary input file.
1176  return getGroupLocal(pid);
1177  }
1178  // Look through secondary files
1179  for (auto const& sp : secondaryPrincipals_) {
1180  if (sp->presentFromSource(pid)) {
1181  return sp->getGroupLocal(pid);
1182  }
1183  }
1184  // Try new secondary files
1185  while (auto sp = tryNextSecondaryFile()) {
1186  auto& new_sp = secondaryPrincipals_.emplace_back(move(sp));
1187  if (new_sp->presentFromSource(pid)) {
1188  return new_sp->getGroupLocal(pid);
1189  }
1190  }
1191  return nullptr;
1192  }
auto tryNextSecondaryFile() const
Definition: Principal.cc:690
bool presentFromSource(ProductID) const
Definition: Principal.cc:1141
def move(depos, offset)
Definition: depos.py:107
cet::exempt_ptr< Group > getGroupLocal(ProductID const) const
Definition: Principal.cc:1164
std::vector< std::unique_ptr< Principal > > secondaryPrincipals_
Definition: Principal.h:326
bool producedInProcess(ProductID) const
Definition: Principal.cc:1131
std::vector< InputTag > art::Principal::getInputTags ( ModuleContext const &  mc,
WrappedTypeID const &  wrapped,
SelectorBase const &  sel,
ProcessTag const &  processTag 
) const

Definition at line 666 of file Principal.cc.

670  {
671  std::vector<InputTag> tags;
672  auto const groups = findGroupsForProduct(mc, wrapped, sel, processTag);
673  cet::transform_all(groups, back_inserter(tags), [](auto const g) {
674  return g->productDescription().inputTag();
675  });
676  return tags;
677  }
static constexpr double g
Definition: Units.h:144
auto transform_all(Container &, OutputIt, UnaryOp)
std::vector< cet::exempt_ptr< Group > > findGroupsForProduct(ModuleContext const &mc, WrappedTypeID const &wrapped, SelectorBase const &, ProcessTag const &) const
Definition: Principal.cc:771
std::vector< GroupQueryResult > art::Principal::getMany ( ModuleContext const &  mc,
WrappedTypeID const &  wrapped,
SelectorBase const &  sel,
ProcessTag const &  processTag 
) const

Definition at line 680 of file Principal.cc.

684  {
685  auto const groups = findGroupsForProduct(mc, wrapped, sel, processTag);
686  return resolve_products(groups, wrapped.wrapped_product_type);
687  }
std::vector< cet::exempt_ptr< Group > > findGroupsForProduct(ModuleContext const &mc, WrappedTypeID const &wrapped, SelectorBase const &, ProcessTag const &) const
Definition: Principal.cc:771
std::vector< GroupQueryResult > resolve_products(std::vector< cet::exempt_ptr< art::Group >> const &groups, art::TypeID const &wrapped_type)
Definition: Group.cc:428
std::vector< cet::exempt_ptr< Group > > art::Principal::getMatchingSequence ( ModuleContext const &  mc,
SelectorBase const &  selector,
ProcessTag const &  processTag 
) const

Definition at line 696 of file Principal.cc.

699  {
700  std::vector<cet::exempt_ptr<Group>> groups;
701  // Find groups from current process
702  if (processTag.current_process_search_allowed() &&
704  if (findGroups(
705  producedProducts_.load()->viewLookup, mc, selector, groups) != 0) {
706  return groups;
707  }
708  }
709 
710  if (!processTag.input_source_search_allowed()) {
711  return groups;
712  }
713 
714  // Look through currently opened input files
715  if (groups.empty()) {
716  groups = matchingSequenceFromInputFile(mc, selector);
717  if (!groups.empty()) {
718  return groups;
719  }
720  for (auto const& sp : secondaryPrincipals_) {
721  groups = sp->matchingSequenceFromInputFile(mc, selector);
722  if (!groups.empty()) {
723  return groups;
724  }
725  }
726  }
727  // Open more secondary files if necessary
728  if (groups.empty()) {
729  while (auto sp = tryNextSecondaryFile()) {
730  auto& new_sp = secondaryPrincipals_.emplace_back(move(sp));
731  groups = new_sp->matchingSequenceFromInputFile(mc, selector);
732  if (!groups.empty()) {
733  return groups;
734  }
735  }
736  }
737  return groups;
738  }
size_t findGroups(ProcessLookup const &, ModuleContext const &, SelectorBase const &, std::vector< cet::exempt_ptr< Group >> &groups) const
Definition: Principal.cc:607
std::atomic< bool > enableLookupOfProducedProducts_
Definition: Principal.h:304
auto tryNextSecondaryFile() const
Definition: Principal.cc:690
std::vector< cet::exempt_ptr< Group > > matchingSequenceFromInputFile(ModuleContext const &, SelectorBase const &) const
Definition: Principal.cc:741
std::atomic< ProductTable const * > producedProducts_
Definition: Principal.h:303
def move(depos, offset)
Definition: depos.py:107
std::vector< std::unique_ptr< Principal > > secondaryPrincipals_
Definition: Principal.h:326
cet::exempt_ptr< BranchDescription const > art::Principal::getProductDescription ( ProductID const  pid,
bool const  alwaysEnableLookupOfProducedProducts = false 
) const

Definition at line 994 of file Principal.cc.

997  {
998  // Find groups from current process
999  if (alwaysEnableLookupOfProducedProducts ||
1001  if (producedProducts_.load() != nullptr) {
1002  if (auto result = producedProducts_.load()->description(pid)) {
1003  return result;
1004  }
1005  }
1006  }
1007  if (presentProducts_.load()) {
1008  // Look through currently opened input files
1009  if (auto result = presentProducts_.load()->description(pid)) {
1010  return result;
1011  }
1012  }
1013  for (auto const& sp : secondaryPrincipals_) {
1014  if (auto result = sp->getProductDescription(pid)) {
1015  return result;
1016  }
1017  }
1018  return nullptr;
1019  }
std::atomic< bool > enableLookupOfProducedProducts_
Definition: Principal.h:304
static QCString result
std::atomic< ProductTable const * > producedProducts_
Definition: Principal.h:303
std::atomic< ProductTable const * > presentProducts_
Definition: Principal.h:302
std::vector< std::unique_ptr< Principal > > secondaryPrincipals_
Definition: Principal.h:326
History const & art::Principal::history ( ) const

Definition at line 902 of file Principal.cc.

903  {
904  return *history_;
905  }
std::unique_ptr< History > history_
Definition: Principal.h:342
bool art::Principal::isLastInSubRun ( ) const

Definition at line 924 of file Principal.cc.

925  {
926  return lastInSubRun_;
927  }
bool lastInSubRun_
Definition: Principal.h:343
bool art::Principal::isReal ( ) const

Definition at line 890 of file Principal.cc.

891  {
892  return eventAux_.load()->isRealData();
893  }
std::atomic< EventAuxiliary * > eventAux_
Definition: Principal.h:337
void art::Principal::markProcessHistoryAsModified ( )

Definition at line 290 of file Principal.cc.

291  {
293  }
std::atomic< bool > processHistoryModified_
Definition: Principal.h:298
std::vector< cet::exempt_ptr< Group > > art::Principal::matchingSequenceFromInputFile ( ModuleContext const &  mc,
SelectorBase const &  selector 
) const
private

Definition at line 741 of file Principal.cc.

743  {
744  std::vector<cet::exempt_ptr<Group>> groups;
745  if (!presentProducts_.load()) {
746  return groups;
747  }
748  findGroups(presentProducts_.load()->viewLookup, mc, selector, groups);
749  return groups;
750  }
size_t findGroups(ProcessLookup const &, ModuleContext const &, SelectorBase const &, std::vector< cet::exempt_ptr< Group >> &groups) const
Definition: Principal.cc:607
std::atomic< ProductTable const * > presentProducts_
Definition: Principal.h:302
Principal& art::Principal::operator= ( Principal const &  )
delete
bool art::Principal::presentFromSource ( ProductID  pid) const
private

Definition at line 1141 of file Principal.cc.

1142  {
1143  if (!presentProducts_.load()) {
1144  return false;
1145  }
1146  auto pd = presentProducts_.load()->description(pid);
1147  return pd == nullptr ? false : pd->present();
1148  }
std::atomic< ProductTable const * > presentProducts_
Definition: Principal.h:302
ProcessConfiguration const & art::Principal::processConfiguration ( ) const

Definition at line 373 of file Principal.cc.

374  {
375  return processConfiguration_;
376  }
ProcessConfiguration const & processConfiguration_
Definition: Principal.h:299
ProcessHistory const & art::Principal::processHistory ( ) const

Definition at line 363 of file Principal.cc.

364  {
365  // MT note: We make no attempt to protect callers who use this
366  // call to get access to the iteration interface of the
367  // process history. See the threading notes there and
368  // here for the reasons why.
369  return processHistory_;
370  }
ProcessHistory processHistory_
Definition: Principal.h:297
bool art::Principal::producedInProcess ( ProductID  pid) const
private

Definition at line 1131 of file Principal.cc.

1132  {
1133  if (!enableLookupOfProducedProducts_.load()) {
1134  return false;
1135  }
1136  auto pd = producedProducts_.load()->description(pid);
1137  return pd == nullptr ? false : pd->produced();
1138  }
std::atomic< bool > enableLookupOfProducedProducts_
Definition: Principal.h:304
std::atomic< ProductTable const * > producedProducts_
Definition: Principal.h:303
EDProductGetter const * art::Principal::productGetter ( ProductID const &  pid) const

Definition at line 297 of file Principal.cc.

298  {
299  auto g = getGroupTryAllFiles(pid);
300  if (g.get() != nullptr) {
301  // Note: All produced products should be found.
302  return g.get();
303  }
304  return nullptr;
305  }
static constexpr double g
Definition: Units.h:144
cet::exempt_ptr< Group const > getGroupTryAllFiles(ProductID const) const
Definition: Principal.cc:1172
void art::Principal::put ( BranchDescription const &  bd,
std::unique_ptr< ProductProvenance const > &&  pp,
std::unique_ptr< EDProduct > &&  edp,
std::unique_ptr< RangeSet > &&  rs 
)

Definition at line 930 of file Principal.cc.

934  {
935  assert(edp);
937  // Note: We intentionally allow group and provenance replacement
938  // for run and subrun products.
939  auto group = getGroupLocal(bd.productID());
940  assert(group);
941  group->setProductAndProvenance(move(pp), move(edp), move(rs));
942  } else {
943  auto group = getGroupLocal(bd.productID());
944  assert(group);
945  if (group->anyProduct() != nullptr) {
947  "Principal::put:")
948  << "Problem found during put of " << branchType_
949  << " product: product already put for " << bd.branchName() << '\n';
950  }
951  group->setProductAndProvenance(
952  move(pp), move(edp), make_unique<RangeSet>());
953  }
954  }
BranchType branchType_
Definition: Principal.h:296
def move(depos, offset)
Definition: depos.py:107
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
cet::exempt_ptr< Group > getGroupLocal(ProductID const) const
Definition: Principal.cc:1164
constexpr bool range_sets_supported(BranchType const bt)
void art::Principal::readImmediate ( ) const

Definition at line 341 of file Principal.cc.

342  {
343  // Read all data products and provenance immediately, if
344  // available. Used only by RootInputFile to implement the
345  // delayedRead*Products config options.
346  //
347  // Note: The input source lock will be held when this routine is called.
348  //
349  // MT-TODO: For right now ignore the delay reading option for
350  // product provenance. If we do the delay reading then we
351  // must use a lock to interlock all fetches of provenance
352  // because the delay read fills the pp_by_pid_ one entry
353  // at a time, and we do not want other threads to find
354  // the info only partly there.
355  std::lock_guard sentry{groupMutex_};
356  for (auto const& pid_and_group : groups_) {
357  auto group = pid_and_group.second.get();
358  group->resolveProductIfAvailable();
359  }
360  }
GroupCollection groups_
Definition: Principal.h:312
std::recursive_mutex groupMutex_
Definition: Principal.h:307
void art::Principal::removeCachedProduct ( ProductID  pid) const

Definition at line 417 of file Principal.cc.

418  {
419  // MT-FIXME: May be called by a module task, need to protect the
420  // group with a lock.
421  if (auto g = getGroupLocal(pid)) {
422  g->removeCachedProduct();
423  return;
424  }
425  for (auto const& sp : secondaryPrincipals_) {
426  if (auto g = sp->getGroupLocal(pid)) {
427  g->removeCachedProduct();
428  return;
429  }
430  }
431  throw Exception(errors::ProductNotFound, "removeCachedProduct")
432  << "Attempt to remove unknown product corresponding to ProductID: " << pid
433  << '\n'
434  << "Please contact artists@fnal.gov\n";
435  }
static constexpr double g
Definition: Units.h:144
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
cet::exempt_ptr< Group > getGroupLocal(ProductID const) const
Definition: Principal.cc:1164
std::vector< std::unique_ptr< Principal > > secondaryPrincipals_
Definition: Principal.h:326
ResultsAuxiliary const & art::Principal::resultsAux ( ) const

Definition at line 1046 of file Principal.cc.

1047  {
1048  return resultsAux_;
1049  }
ResultsAuxiliary resultsAux_
Definition: Principal.h:339
RunNumber_t art::Principal::run ( ) const

Definition at line 1070 of file Principal.cc.

1071  {
1072  if (branchType_ == InRun) {
1073  return runAux_.run();
1074  }
1075  if (branchType_ == InSubRun) {
1076  return subRunAux_.run();
1077  }
1078  return eventAux_.load()->id().run();
1079  }
BranchType branchType_
Definition: Principal.h:296
RunNumber_t run() const noexcept
RunNumber_t run() const noexcept
std::atomic< EventAuxiliary * > eventAux_
Definition: Principal.h:337
RunAuxiliary runAux_
Definition: Principal.h:333
SubRunAuxiliary subRunAux_
Definition: Principal.h:334
RunAuxiliary const & art::Principal::runAux ( ) const

Definition at line 1028 of file Principal.cc.

1029  {
1030  return runAux_;
1031  }
RunAuxiliary runAux_
Definition: Principal.h:333
RunID const & art::Principal::runID ( ) const

Definition at line 1052 of file Principal.cc.

1053  {
1054  return runAux_.id();
1055  }
RunAuxiliary runAux_
Definition: Principal.h:333
RunID const & id() const noexcept
Definition: RunAuxiliary.cc:79
RunPrincipal const & art::Principal::runPrincipal ( ) const

Definition at line 914 of file Principal.cc.

915  {
916  if (!runPrincipal_) {
918  << "Tried to obtain a NULL runPrincipal.\n";
919  }
920  return *runPrincipal_;
921  }
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
cet::exempt_ptr< RunPrincipal const > runPrincipal_
Definition: Principal.h:340
cet::exempt_ptr< RunPrincipal const > art::Principal::runPrincipalExemptPtr ( ) const

Definition at line 854 of file Principal.cc.

855  {
856  return runPrincipal_;
857  }
cet::exempt_ptr< RunPrincipal const > runPrincipal_
Definition: Principal.h:340
RangeSet art::Principal::seenRanges ( ) const

Definition at line 878 of file Principal.cc.

879  {
880  return rangeSet_;
881  }
RangeSet rangeSet_
Definition: Principal.h:332
void art::Principal::setProcessHistoryIDcombined ( ProcessHistoryID const &  phid)
protected

Definition at line 272 of file Principal.cc.

273  {
274  if (branchType_ == InRun) {
276  } else if (branchType_ == InSubRun) {
278  } else if (branchType_ == InEvent) {
279  history_->setProcessHistoryID(phid);
280  } else {
282  }
283  }
void setProcessHistoryID(ProcessHistoryID const &phid) const
void setProcessHistoryID(ProcessHistoryID const &phid) const
BranchType branchType_
Definition: Principal.h:296
std::unique_ptr< History > history_
Definition: Principal.h:342
void setProcessHistoryID(ProcessHistoryID const &) const
Definition: RunAuxiliary.cc:97
RunAuxiliary runAux_
Definition: Principal.h:333
ResultsAuxiliary resultsAux_
Definition: Principal.h:339
SubRunAuxiliary subRunAux_
Definition: Principal.h:334
void art::Principal::setRunPrincipal ( cet::exempt_ptr< RunPrincipal const >  rp)

Definition at line 866 of file Principal.cc.

867  {
868  runPrincipal_ = rp;
869  }
cet::exempt_ptr< RunPrincipal const > runPrincipal_
Definition: Principal.h:340
void art::Principal::setSubRunPrincipal ( cet::exempt_ptr< SubRunPrincipal const >  srp)

Definition at line 872 of file Principal.cc.

873  {
874  subRunPrincipal_ = srp.get();
875  }
constexpr pointer get() const noexcept
Definition: exempt_ptr.h:148
std::atomic< SubRunPrincipal const * > subRunPrincipal_
Definition: Principal.h:341
size_t art::Principal::size ( ) const

Definition at line 379 of file Principal.cc.

380  {
381  std::lock_guard sentry{groupMutex_};
382  return groups_.size();
383  }
GroupCollection groups_
Definition: Principal.h:312
std::recursive_mutex groupMutex_
Definition: Principal.h:307
SubRunNumber_t art::Principal::subRun ( ) const

Definition at line 1082 of file Principal.cc.

1083  {
1084  if (branchType_ == InSubRun) {
1085  return subRunAux_.subRun();
1086  }
1087  return eventAux_.load()->id().subRun();
1088  }
BranchType branchType_
Definition: Principal.h:296
SubRunNumber_t subRun() const noexcept
std::atomic< EventAuxiliary * > eventAux_
Definition: Principal.h:337
SubRunAuxiliary subRunAux_
Definition: Principal.h:334
SubRunAuxiliary const & art::Principal::subRunAux ( ) const

Definition at line 1034 of file Principal.cc.

1035  {
1036  return subRunAux_;
1037  }
SubRunAuxiliary subRunAux_
Definition: Principal.h:334
SubRunID art::Principal::subRunID ( ) const

Definition at line 1058 of file Principal.cc.

1059  {
1060  return subRunAux_.id();
1061  }
SubRunID const & id() const noexcept
SubRunAuxiliary subRunAux_
Definition: Principal.h:334
SubRunPrincipal const & art::Principal::subRunPrincipal ( ) const

Definition at line 844 of file Principal.cc.

845  {
846  if (subRunPrincipal_.load() == nullptr) {
848  << "Tried to obtain a NULL subRunPrincipal.\n";
849  }
850  return *subRunPrincipal_.load();
851  }
std::atomic< SubRunPrincipal const * > subRunPrincipal_
Definition: Principal.h:341
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
SubRunPrincipal const * art::Principal::subRunPrincipalPtr ( ) const

Definition at line 860 of file Principal.cc.

861  {
862  return subRunPrincipal_.load();
863  }
std::atomic< SubRunPrincipal const * > subRunPrincipal_
Definition: Principal.h:341
Timestamp const & art::Principal::time ( ) const

Definition at line 1125 of file Principal.cc.

1126  {
1127  return eventAux_.load()->time();
1128  }
std::atomic< EventAuxiliary * > eventAux_
Definition: Principal.h:337
auto art::Principal::tryNextSecondaryFile ( ) const
private

Definition at line 690 of file Principal.cc.

691  {
692  return delayedReader_->readFromSecondaryFile(nextSecondaryFileIdx_);
693  }
int nextSecondaryFileIdx_
Definition: Principal.h:330
std::unique_ptr< DelayedReader > delayedReader_
Definition: Principal.h:316
void art::Principal::updateSeenRanges ( RangeSet const &  rs)

Definition at line 884 of file Principal.cc.

885  {
886  rangeSet_ = rs;
887  }
RangeSet rangeSet_
Definition: Principal.h:332

Member Data Documentation

BranchType art::Principal::branchType_ {}
private

Definition at line 296 of file Principal.h.

std::unique_ptr<DelayedReader> art::Principal::delayedReader_ {nullptr}
private

Definition at line 316 of file Principal.h.

std::atomic<bool> art::Principal::enableLookupOfProducedProducts_
private

Definition at line 304 of file Principal.h.

std::atomic<EventAuxiliary*> art::Principal::eventAux_
private

Definition at line 337 of file Principal.h.

std::recursive_mutex art::Principal::groupMutex_ {}
mutableprivate

Definition at line 307 of file Principal.h.

GroupCollection art::Principal::groups_ {}
private

Definition at line 312 of file Principal.h.

std::unique_ptr<History> art::Principal::history_ {nullptr}
private

Definition at line 342 of file Principal.h.

bool art::Principal::lastInSubRun_ {false}
private

Definition at line 343 of file Principal.h.

int art::Principal::nextSecondaryFileIdx_ {}
mutableprivate

Definition at line 330 of file Principal.h.

std::atomic<ProductTable const*> art::Principal::presentProducts_
private

Definition at line 302 of file Principal.h.

ProcessConfiguration const& art::Principal::processConfiguration_
private

Definition at line 299 of file Principal.h.

ProcessHistory art::Principal::processHistory_ {}
private

Definition at line 297 of file Principal.h.

std::atomic<bool> art::Principal::processHistoryModified_
private

Definition at line 298 of file Principal.h.

std::atomic<ProductTable const*> art::Principal::producedProducts_
private

Definition at line 303 of file Principal.h.

RangeSet art::Principal::rangeSet_ {RangeSet::invalid()}
private

Definition at line 332 of file Principal.h.

ResultsAuxiliary art::Principal::resultsAux_ {}
private

Definition at line 339 of file Principal.h.

RunAuxiliary art::Principal::runAux_ {}
private

Definition at line 333 of file Principal.h.

cet::exempt_ptr<RunPrincipal const> art::Principal::runPrincipal_ {nullptr}
private

Definition at line 340 of file Principal.h.

std::vector<std::unique_ptr<Principal> > art::Principal::secondaryPrincipals_ {}
mutableprivate

Definition at line 326 of file Principal.h.

SubRunAuxiliary art::Principal::subRunAux_ {}
private

Definition at line 334 of file Principal.h.

std::atomic<SubRunPrincipal const*> art::Principal::subRunPrincipal_
private

Definition at line 341 of file Principal.h.


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