Public Member Functions | Private Member Functions | Private Attributes | List of all members
gallery::DataGetterHelper Class Reference

#include <DataGetterHelper.h>

Inheritance diagram for gallery::DataGetterHelper:
art::PrincipalBase

Public Member Functions

 DataGetterHelper (EventNavigator const *eventNavigator, std::shared_ptr< EventHistoryGetter > historyGetter)
 
 DataGetterHelper (DataGetterHelper const &)=delete
 
 DataGetterHelper (DataGetterHelper &&)=delete
 
DataGetterHelperoperator= (DataGetterHelper const &)=delete
 
DataGetterHelperoperator= (DataGetterHelper &&)=delete
 
ProductWithID getByLabel (std::type_info const &typeInfoOfWrapper, art::InputTag const &inputTag) const
 
std::vector< art::InputTaggetInputTags (std::type_info const &typeInfoOfWrapper) const
 
std::vector< ProductWithIDgetManyByType (std::type_info const &typeInfoOfWrapper) const
 
art::BranchDescription const & getProductDescription (art::ProductID) const
 
void updateFile (TFile *iFile, TTree *iTree, bool initializeTheCache)
 
void initializeTTreeCache ()
 
void updateEvent ()
 
- Public Member Functions inherited from art::PrincipalBase
virtual ~PrincipalBase ()=0
 
 PrincipalBase ()
 
EDProductGetter const * getEDProductGetter (ProductID const &pid) const
 

Private Member Functions

void initializeForProcessHistory () const
 
void addProcess (std::string const &processName) const
 
void addBranchData (std::string branchName, unsigned int processIndex, InfoForTypeLabelInstance const &info, bool initializeTheCache=false) const
 
TClass * getTClass (InfoForTypeLabelInstance const &info, std::string const &processName) const
 
InfoForTypeLabelInstancegetInfoForTypeLabelInstance (art::TypeID const &type, std::string const &label, std::string const &instance) const
 
void addTypeLabelInstance (art::TypeID const &type, std::string const &label, std::string const &instance) const
 
void insertIntoInfoMap (art::TypeID const &type, std::string const &label, std::string const &instance, unsigned int infoIndex) const
 
art::EDProduct const * readProduct (art::ProductID const productID, art::TypeID const &type) const
 
art::ProductID getMaybeValidProductID (std::vector< IndexProductIDPair > const &processIndexToProductID, unsigned int processIndex) const
 
void updateBranchDataIndexOrderedByHistory (InfoForTypeLabelInstance const &info) const
 
std::vector< art::BranchDescription const * > getProductDescriptions (art::TypeID const &typeIDOfWrapper) const
 
BranchData const * getBranchData (InfoForTypeLabelInstance const &info, unsigned int processIndex) const
 
BranchData const * getBranchData (art::BranchDescription const &) const
 
art::EDProductGetter const * getEDProductGetter_ (art::ProductID const &) const override
 

Private Attributes

EventNavigator const * eventNavigator_
 
TTree * tree_ {nullptr}
 
std::shared_ptr< EventHistoryGetterhistoryGetter_
 
bool initializedForProcessHistory_ {false}
 
art::ProcessHistoryID previousProcessHistoryID_ {}
 
std::vector< std::stringpreviousProcessHistoryNames_ {}
 
std::vector< std::stringprocessNames_ {}
 
std::map< std::string, unsigned int > processNameToProcessIndex_ {}
 
std::vector< unsigned int > orderedProcessIndexes_ {}
 
std::vector< InfoForTypeLabelInstanceinfoVector_ {}
 
std::map< TypeLabelInstanceKey, unsigned int > infoMap_ {}
 
std::map< art::ProductID, std::unique_ptr< BranchData > > branchDataMap_ {}
 
BranchData invalidBranchData_ {}
 
std::set< art::ProductIDbranchDataMissingSet_ {}
 
BranchMapReader branchMapReader_ {}
 
art::root::DictionaryChecker dictChecker_ {}
 

Detailed Description

Definition at line 72 of file DataGetterHelper.h.

Constructor & Destructor Documentation

gallery::DataGetterHelper::DataGetterHelper ( EventNavigator const *  eventNavigator,
std::shared_ptr< EventHistoryGetter historyGetter 
)
explicit

Definition at line 69 of file DataGetterHelper.cc.

72  : eventNavigator_{eventNavigator}, historyGetter_{historyGetter}
73  {
74  initializeStreamers();
75  }
EventNavigator const * eventNavigator_
std::shared_ptr< EventHistoryGetter > historyGetter_
gallery::DataGetterHelper::DataGetterHelper ( DataGetterHelper const &  )
delete
gallery::DataGetterHelper::DataGetterHelper ( DataGetterHelper &&  )
delete

Member Function Documentation

void gallery::DataGetterHelper::addBranchData ( std::string  branchName,
unsigned int  processIndex,
InfoForTypeLabelInstance const &  info,
bool  initializeTheCache = false 
) const
private

Definition at line 340 of file DataGetterHelper.cc.

344  {
345  auto branch = tree_->GetBranch(branchName.c_str());
346  if (branch == nullptr) {
347  return;
348  }
349  auto pd =
351  assert(pd);
352  auto const productID = pd->productID();
353  if (info.isAssns()) {
354  auto const& processName = processNames_[processIndex];
355  auto tClass = getTClass(info, processName);
356 
357  art::TypeID const typeIDInDescription{tClass->GetTypeInfo()};
358  branchDataMap_[productID] =
359  std::make_unique<AssnsBranchData>(typeIDInDescription,
360  tClass,
361  branch,
363  this,
364  move(branchName),
365  info.type(),
366  info.partnerType());
367  } else {
368  branchDataMap_[productID] =
369  std::make_unique<BranchData>(info.type(),
370  info.tClass(),
371  branch,
373  this,
374  move(branchName));
375  }
376  info.processIndexToProductID().emplace_back(processIndex, productID);
377  if (initializeTheCache && branch) {
378  tree_->AddBranchToCache(branch, kTRUE);
379  }
380  }
std::map< art::ProductID, std::unique_ptr< BranchData > > branchDataMap_
art::BranchDescription const * productDescription(InfoForTypeLabelInstance const &info, std::string const &process) const
def move(depos, offset)
Definition: depos.py:107
EventNavigator const * eventNavigator_
BranchMapReader branchMapReader_
TClass * getTClass(InfoForTypeLabelInstance const &info, std::string const &processName) const
std::vector< std::string > processNames_
void gallery::DataGetterHelper::addProcess ( std::string const &  processName) const
private

Definition at line 324 of file DataGetterHelper.cc.

325  {
326  unsigned int const processIndex = processNames_.size();
327  processNames_.push_back(processName);
328  processNameToProcessIndex_[processName] = processIndex;
329  for (auto& info : infoVector_) {
330  auto pd = branchMapReader_.productDescription(info, processName);
331  if (pd == nullptr) {
332  continue;
333  }
334  assert(branchMapReader_.branchInRegistryOfAnyOpenedFile(pd->productID()));
335  addBranchData(pd->branchName(), processIndex, info);
336  }
337  }
art::BranchDescription const * productDescription(InfoForTypeLabelInstance const &info, std::string const &process) const
void addBranchData(std::string branchName, unsigned int processIndex, InfoForTypeLabelInstance const &info, bool initializeTheCache=false) const
std::map< std::string, unsigned int > processNameToProcessIndex_
bool branchInRegistryOfAnyOpenedFile(art::ProductID const &) const
BranchMapReader branchMapReader_
std::vector< InfoForTypeLabelInstance > infoVector_
std::vector< std::string > processNames_
void gallery::DataGetterHelper::addTypeLabelInstance ( art::TypeID const &  type,
std::string const &  label,
std::string const &  instance 
) const
private

Definition at line 426 of file DataGetterHelper.cc.

429  {
430  dictChecker_.checkDictionaries(art::uniform_type_name(type.typeInfo()),
431  true);
432  dictChecker_.reportMissingDictionaries();
433  unsigned int infoIndex = infoVector_.size();
434  infoVector_.emplace_back(type, label, instance);
435  insertIntoInfoMap(type, label, instance, infoIndex);
436  InfoForTypeLabelInstance const& info = infoVector_[infoIndex];
437  if (info.isAssns()) {
438  insertIntoInfoMap(info.partnerType(), label, instance, infoIndex);
439  }
440  unsigned int processIndex{};
441  for (auto const& processName : processNames_) {
442  std::string branchName{buildBranchName(info, processName)};
443  art::ProductID const productID{branchName};
445  addBranchData(move(branchName), processIndex, info);
446  }
447  ++processIndex;
448  }
450  }
std::string string
Definition: nybbler.cc:12
void addBranchData(std::string branchName, unsigned int processIndex, InfoForTypeLabelInstance const &info, bool initializeTheCache=false) const
const std::string instance
void insertIntoInfoMap(art::TypeID const &type, std::string const &label, std::string const &instance, unsigned int infoIndex) const
std::string uniform_type_name(std::type_info const &tid)
def move(depos, offset)
Definition: depos.py:107
void updateBranchDataIndexOrderedByHistory(InfoForTypeLabelInstance const &info) const
bool branchInRegistryOfAnyOpenedFile(art::ProductID const &) const
BranchMapReader branchMapReader_
std::vector< InfoForTypeLabelInstance > infoVector_
std::vector< std::string > processNames_
art::root::DictionaryChecker dictChecker_
BranchData const * gallery::DataGetterHelper::getBranchData ( InfoForTypeLabelInstance const &  info,
unsigned int  processIndex 
) const
private

Definition at line 488 of file DataGetterHelper.cc.

490  {
491  auto const pid =
492  getMaybeValidProductID(info.processIndexToProductID(), processIndex);
493  return pid.isValid() ? branchDataMap_.at(pid).get() : nullptr;
494  }
std::map< art::ProductID, std::unique_ptr< BranchData > > branchDataMap_
art::ProductID getMaybeValidProductID(std::vector< IndexProductIDPair > const &processIndexToProductID, unsigned int processIndex) const
BranchData const * gallery::DataGetterHelper::getBranchData ( art::BranchDescription const &  desc) const
private

Definition at line 519 of file DataGetterHelper.cc.

520  {
523  }
524  TClass* tClass = TClass::GetClass(desc.wrappedName().c_str());
525  if (tClass == nullptr) {
527  "DataGetterHelper::getBranchData: ")
528  << "Missing dictionary for wrapped class.\n"
529  << desc.wrappedName() << "\n";
530  }
531 
532  auto const& typeInfoOfWrapper = *tClass->GetTypeInfo();
533  art::TypeID const type{typeInfoOfWrapper};
534  auto const& info = getInfoForTypeLabelInstance(
535  type, desc.moduleLabel(), desc.productInstanceName());
536  auto itProcess = processNameToProcessIndex_.find(desc.processName());
537  if (itProcess != cend(processNameToProcessIndex_)) {
538  unsigned int const processIndex = itProcess->second;
539  auto branchData = getBranchData(info, processIndex);
540  if (branchData && branchData->branch() != nullptr) {
541  return branchData;
542  }
543  }
544  return nullptr;
545  }
decltype(auto) constexpr cend(T &&obj)
ADL-aware version of std::cend.
Definition: StdUtils.h:87
void initializeForProcessHistory() const
InfoForTypeLabelInstance & getInfoForTypeLabelInstance(art::TypeID const &type, std::string const &label, std::string const &instance) const
BranchData const * getBranchData(InfoForTypeLabelInstance const &info, unsigned int processIndex) const
std::map< std::string, unsigned int > processNameToProcessIndex_
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
ProductWithID gallery::DataGetterHelper::getByLabel ( std::type_info const &  typeInfoOfWrapper,
art::InputTag const &  inputTag 
) const

Definition at line 78 of file DataGetterHelper.cc.

80  {
83  }
84  art::TypeID const type{typeInfoOfWrapper};
85  auto const& info =
86  getInfoForTypeLabelInstance(type, inputTag.label(), inputTag.instance());
87 
88  if (inputTag.process().empty()) {
89  // search in reverse order of the ProcessHistory
90  for (auto reverseIter = crbegin(info.productIDsOrderedByHistory()),
91  iEnd = crend(info.productIDsOrderedByHistory());
92  reverseIter != iEnd;
93  ++reverseIter) {
94  if (auto edProduct = readProduct(*reverseIter, type)) {
95  // If the product was present in the input file and we
96  // successfully read it then we are done
97  return std::make_pair(edProduct, *reverseIter);
98  }
99  }
100  } else { // process is not empty
101  auto itProcess = processNameToProcessIndex_.find(inputTag.process());
102  if (itProcess != cend(processNameToProcessIndex_)) {
103  unsigned int const processIndex = itProcess->second;
104  auto branchData = getBranchData(info, processIndex);
105  if (branchData) {
106  auto pd = branchMapReader_.productDescription(info, itProcess->first);
107  assert(pd);
108  auto product = branchData->uniqueProduct_(type);
109  return std::make_pair(product, pd->productID());
110  }
111  }
112  }
113  return std::make_pair(nullptr, art::ProductID::invalid());
114  }
decltype(auto) constexpr cend(T &&obj)
ADL-aware version of std::cend.
Definition: StdUtils.h:87
art::BranchDescription const * productDescription(InfoForTypeLabelInstance const &info, std::string const &process) const
void initializeForProcessHistory() const
InfoForTypeLabelInstance & getInfoForTypeLabelInstance(art::TypeID const &type, std::string const &label, std::string const &instance) const
BranchData const * getBranchData(InfoForTypeLabelInstance const &info, unsigned int processIndex) const
std::map< std::string, unsigned int > processNameToProcessIndex_
BranchMapReader branchMapReader_
static constexpr ProductID invalid() noexcept
Definition: ProductID.h:26
art::EDProduct const * readProduct(art::ProductID const productID, art::TypeID const &type) const
art::EDProductGetter const * gallery::DataGetterHelper::getEDProductGetter_ ( art::ProductID const &  productID) const
overrideprivatevirtual

Implements art::PrincipalBase.

Definition at line 561 of file DataGetterHelper.cc.

562  {
563  auto itFind = branchDataMap_.find(productID);
564  if (itFind != cend(branchDataMap_)) {
565  return itFind->second.get();
566  }
567 
568  if (branchDataMissingSet_.find(productID) != cend(branchDataMissingSet_)) {
569  return &invalidBranchData_;
570  }
571 
572  auto const pd = branchMapReader_.productDescription(productID);
573  if (pd == nullptr) {
574  return &invalidBranchData_;
575  }
576 
577  auto branchData = getBranchData(*pd);
578  if (branchData == nullptr) {
579  branchDataMissingSet_.insert(productID);
580  return &invalidBranchData_;
581  }
582  return branchData;
583  }
std::map< art::ProductID, std::unique_ptr< BranchData > > branchDataMap_
std::set< art::ProductID > branchDataMissingSet_
decltype(auto) constexpr cend(T &&obj)
ADL-aware version of std::cend.
Definition: StdUtils.h:87
art::BranchDescription const * productDescription(InfoForTypeLabelInstance const &info, std::string const &process) const
BranchData const * getBranchData(InfoForTypeLabelInstance const &info, unsigned int processIndex) const
BranchMapReader branchMapReader_
InfoForTypeLabelInstance & gallery::DataGetterHelper::getInfoForTypeLabelInstance ( art::TypeID const &  type,
std::string const &  label,
std::string const &  instance 
) const
private

Definition at line 407 of file DataGetterHelper.cc.

411  {
412  if (label.empty()) {
414  << "getValidHandle was passed an empty module label. Not allowed.\n";
415  }
416  TypeLabelInstanceKey const key{type, label, instance};
417  auto itFind = infoMap_.find(key);
418  if (itFind == cend(infoMap_)) {
419  addTypeLabelInstance(type, label, instance);
420  itFind = infoMap_.find(key);
421  }
422  return infoVector_[itFind->second];
423  }
decltype(auto) constexpr cend(T &&obj)
ADL-aware version of std::cend.
Definition: StdUtils.h:87
void addTypeLabelInstance(art::TypeID const &type, std::string const &label, std::string const &instance) const
const std::string instance
def key(type, name=None)
Definition: graph.py:13
std::map< TypeLabelInstanceKey, unsigned int > infoMap_
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::vector< InfoForTypeLabelInstance > infoVector_
static QCString type
Definition: declinfo.cpp:672
std::vector< art::InputTag > gallery::DataGetterHelper::getInputTags ( std::type_info const &  typeInfoOfWrapper) const

Definition at line 137 of file DataGetterHelper.cc.

138  {
139  std::vector<art::InputTag> result;
140  art::TypeID const type{typeInfoOfWrapper};
141  for (auto const* pd : getProductDescriptions(type)) {
142  result.push_back(pd->inputTag());
143  }
144  return result;
145  }
static QCString result
std::vector< art::BranchDescription const * > getProductDescriptions(art::TypeID const &typeIDOfWrapper) const
std::vector< ProductWithID > gallery::DataGetterHelper::getManyByType ( std::type_info const &  typeInfoOfWrapper) const

Definition at line 148 of file DataGetterHelper.cc.

149  {
150  std::vector<ProductWithID> result;
151  art::TypeID const type{typeInfoOfWrapper};
152  for (auto const* pd : getProductDescriptions(type)) {
153  auto itProcess = processNameToProcessIndex_.find(pd->processName());
154  if (itProcess == cend(processNameToProcessIndex_)) {
155  continue;
156  }
157 
158  auto const& info = getInfoForTypeLabelInstance(
159  type, pd->moduleLabel(), pd->productInstanceName());
160 
161  unsigned int const processIndex = itProcess->second;
162  auto branchData = getBranchData(info, processIndex);
163  if (!branchData) {
164  continue;
165  }
166 
167  if (auto product = branchData->uniqueProduct_(type)) {
168  result.emplace_back(product, pd->productID());
169  }
170  }
171  return result;
172  }
decltype(auto) constexpr cend(T &&obj)
ADL-aware version of std::cend.
Definition: StdUtils.h:87
static QCString result
std::vector< art::BranchDescription const * > getProductDescriptions(art::TypeID const &typeIDOfWrapper) const
InfoForTypeLabelInstance & getInfoForTypeLabelInstance(art::TypeID const &type, std::string const &label, std::string const &instance) const
BranchData const * getBranchData(InfoForTypeLabelInstance const &info, unsigned int processIndex) const
std::map< std::string, unsigned int > processNameToProcessIndex_
art::ProductID gallery::DataGetterHelper::getMaybeValidProductID ( std::vector< IndexProductIDPair > const &  processIndexToProductID,
unsigned int  processIndex 
) const
private

Definition at line 471 of file DataGetterHelper.cc.

474  {
475  auto itBranchDataIndex = lower_bound(
476  processIndexToProductID.cbegin(),
477  processIndexToProductID.cend(),
478  std::make_pair(processIndex, art::ProductID::invalid()),
479  [](auto const& l, auto const& r) { return l.first < r.first; });
480  if (itBranchDataIndex != processIndexToProductID.cend() &&
481  itBranchDataIndex->first == processIndex) {
482  return itBranchDataIndex->second;
483  }
484  return art::ProductID::invalid();
485  }
type * first()
Definition: qinternallist.h:87
static QStrList * l
Definition: config.cpp:1044
static constexpr ProductID invalid() noexcept
Definition: ProductID.h:26
art::BranchDescription const & gallery::DataGetterHelper::getProductDescription ( art::ProductID  productID) const

Definition at line 548 of file DataGetterHelper.cc.

549  {
550  auto pd = branchMapReader_.productDescription(productID);
551  if (pd == nullptr) {
553  "DataGetterHelper::getProductDescription: "}
554  << "No product description could be found for ProductID " << productID
555  << ".\n";
556  }
557  return *pd;
558  }
art::BranchDescription const * productDescription(InfoForTypeLabelInstance const &info, std::string const &process) const
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
BranchMapReader branchMapReader_
std::vector< art::BranchDescription const * > gallery::DataGetterHelper::getProductDescriptions ( art::TypeID const &  typeIDOfWrapper) const
private

Definition at line 117 of file DataGetterHelper.cc.

119  {
120  std::vector<art::BranchDescription const*> result;
123  }
124  auto const fcn = typeIDOfWrapper.friendlyClassName();
125  for (auto const& pr : branchMapReader_.productDescriptions()) {
126  auto const& pd = pr.second;
127  if (pd.friendlyClassName() != fcn) {
128  continue;
129  }
130 
131  result.push_back(&pd);
132  }
133  return result;
134  }
static QCString result
void initializeForProcessHistory() const
std::map< art::ProductID, art::BranchDescription > const & productDescriptions() const
BranchMapReader branchMapReader_
TClass * gallery::DataGetterHelper::getTClass ( InfoForTypeLabelInstance const &  info,
std::string const &  processName 
) const
private

Definition at line 383 of file DataGetterHelper.cc.

385  {
386  auto bd = branchMapReader_.productDescription(info, processName);
387  if (bd == nullptr) {
389  "DataGetterHelper::getTClass: "}
390  << "TBranch exists but no BranchDescription in ProductRegistry.\n"
391  << "This shouldn't be possible. For type " << info.type().className()
392  << "\n";
393  }
394 
395  art::detail::AssnsStreamer::init_streamer(bd->producedClassName());
396  auto tClass = TClass::GetClass(bd->wrappedName().c_str());
397  if (tClass == nullptr) {
399  "DataGetterHelper::getTClass: "}
400  << "Missing dictionary for wrapped Assns class.\n"
401  << bd->wrappedName() << "\n";
402  }
403  return tClass;
404  }
art::BranchDescription const * productDescription(InfoForTypeLabelInstance const &info, std::string const &process) const
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
BranchMapReader branchMapReader_
void gallery::DataGetterHelper::initializeForProcessHistory ( ) const
private

Definition at line 279 of file DataGetterHelper.cc.

280  {
282  // Do nothing if the process names in the process history are the same
283  auto const processHistoryID = historyGetter_->processHistoryID();
284  if (processHistoryID == previousProcessHistoryID_) {
285  return;
286  }
287  previousProcessHistoryID_ = processHistoryID;
288  art::ProcessHistory const& processHistory =
289  historyGetter_->processHistory();
290  if (previousProcessHistoryNames_.size() == processHistory.size()) {
291  bool same = true;
292  auto iPrevious = previousProcessHistoryNames_.begin();
293  for (auto i = processHistory.begin(), iEnd = processHistory.end();
294  i != iEnd;
295  ++i, ++iPrevious) {
296  if (i->processName() != *iPrevious) {
297  same = false;
298  break;
299  }
300  }
301  if (same) {
302  return;
303  }
304  }
306  // update for the new process history
307  orderedProcessIndexes_.clear();
308  for (auto const& processConfig : processHistory) {
309  std::string const& processName = processConfig.processName();
310  previousProcessHistoryNames_.push_back(processName);
311  auto itFind = processNameToProcessIndex_.find(processName);
312  if (itFind == processNameToProcessIndex_.end()) {
313  addProcess(processName);
314  itFind = processNameToProcessIndex_.find(processName);
315  }
316  orderedProcessIndexes_.push_back(itFind->second);
317  }
318  for (auto const& info : infoVector_) {
320  }
321  }
const_iterator end() const
std::string string
Definition: nybbler.cc:12
const_iterator begin() const
void addProcess(std::string const &processName) const
std::vector< std::string > previousProcessHistoryNames_
art::ProcessHistoryID previousProcessHistoryID_
void updateBranchDataIndexOrderedByHistory(InfoForTypeLabelInstance const &info) const
std::map< std::string, unsigned int > processNameToProcessIndex_
size_type size() const
std::shared_ptr< EventHistoryGetter > historyGetter_
std::vector< InfoForTypeLabelInstance > infoVector_
std::vector< unsigned int > orderedProcessIndexes_
void gallery::DataGetterHelper::initializeTTreeCache ( )

Definition at line 256 of file DataGetterHelper.cc.

257  {
258  tree_->SetCacheSize();
259  tree_->AddBranchToCache(eventNavigator_->eventAuxiliaryBranch(), kTRUE);
260  for (auto const& info : infoVector_) {
261  for (auto const& i : info.processIndexToProductID()) {
262  auto const productID = i.second;
263  auto& branchData = *branchDataMap_.at(productID);
264  if (auto branch = branchData.branch()) {
265  tree_->AddBranchToCache(branch, kTRUE);
266  }
267  }
268  }
269  tree_->StopCacheLearningPhase();
270  }
std::map< art::ProductID, std::unique_ptr< BranchData > > branchDataMap_
TBranch * eventAuxiliaryBranch() const
EventNavigator const * eventNavigator_
std::vector< InfoForTypeLabelInstance > infoVector_
void gallery::DataGetterHelper::insertIntoInfoMap ( art::TypeID const &  type,
std::string const &  label,
std::string const &  instance,
unsigned int  infoIndex 
) const
private

Definition at line 453 of file DataGetterHelper.cc.

457  {
458  TypeLabelInstanceKey const newKey{type, label, instance};
459  infoMap_[newKey] = infoIndex;
460  }
const std::string instance
std::map< TypeLabelInstanceKey, unsigned int > infoMap_
static QCString type
Definition: declinfo.cpp:672
DataGetterHelper& gallery::DataGetterHelper::operator= ( DataGetterHelper const &  )
delete
DataGetterHelper& gallery::DataGetterHelper::operator= ( DataGetterHelper &&  )
delete
art::EDProduct const * gallery::DataGetterHelper::readProduct ( art::ProductID const  productID,
art::TypeID const &  type 
) const
private

Definition at line 463 of file DataGetterHelper.cc.

465  {
466  auto const& branchData = branchDataMap_.at(productID);
467  return branchData->uniqueProduct_(type);
468  }
std::map< art::ProductID, std::unique_ptr< BranchData > > branchDataMap_
void gallery::DataGetterHelper::updateBranchDataIndexOrderedByHistory ( InfoForTypeLabelInstance const &  info) const
private

Definition at line 497 of file DataGetterHelper.cc.

499  {
500  info.productIDsOrderedByHistory().clear();
501  if (info.productIDsOrderedByHistory().capacity() <
502  orderedProcessIndexes_.size()) {
503  info.productIDsOrderedByHistory().reserve(orderedProcessIndexes_.size());
504  }
505  for (auto processIndex : orderedProcessIndexes_) {
506  auto const& orderedProcessName = processNames_[processIndex];
507  auto pd = branchMapReader_.productDescription(info, orderedProcessName);
508  if (pd == nullptr) {
509  continue;
510  }
511  auto branchData = getBranchData(info, processIndex);
512  if (branchData && branchData->branch() != nullptr) {
513  info.productIDsOrderedByHistory().emplace_back(pd->productID());
514  }
515  }
516  }
art::BranchDescription const * productDescription(InfoForTypeLabelInstance const &info, std::string const &process) const
BranchData const * getBranchData(InfoForTypeLabelInstance const &info, unsigned int processIndex) const
BranchMapReader branchMapReader_
std::vector< unsigned int > orderedProcessIndexes_
std::vector< std::string > processNames_
void gallery::DataGetterHelper::updateEvent ( )

Definition at line 273 of file DataGetterHelper.cc.

274  {
276  }
void gallery::DataGetterHelper::updateFile ( TFile *  iFile,
TTree *  iTree,
bool  initializeTheCache 
)

Definition at line 175 of file DataGetterHelper.cc.

178  {
179  tree_ = iTree;
180  art::configureProductIDStreamer(); // Null out the ProductID streamer
182  art::configureProductIDStreamer(branchMapReader_.branchIDLists());
183  if (initializeTheCache) {
184  tree_->SetCacheSize();
185  tree_->AddBranchToCache(eventNavigator_->eventAuxiliaryBranch(), kTRUE);
186  }
187  for (auto& info : infoVector_) {
188  std::vector<IndexProductIDPair> old;
189  old.swap(info.processIndexToProductID());
190  info.processIndexToProductID().reserve(processNames_.size());
191  for (unsigned int processIndex{}; processIndex < processNames_.size();
192  ++processIndex) {
193  auto const& processName = processNames_[processIndex];
194  auto bd = branchMapReader_.productDescription(info, processName);
195  if (bd == nullptr) {
196  // Product not available.
197  continue;
198  }
199 
200  auto const productID = getMaybeValidProductID(old, processIndex);
201  if (productID.isValid()) {
202  auto& branchData = *branchDataMap_.at(productID);
203  auto branch = tree_->GetBranch(branchData.branchName().c_str());
204  // This will update the pointer to the TBranch in
205  // BranchData. This loop is sufficient to update all
206  // BranchData objects in the vector.
207  branchData.updateFile(branch);
208 
209  // A little paranoia here. What if in one input file
210  // Assns<A,B,C> is written into the file and Assns<B,A,C> is
211  // written into another? The following deals properly with
212  // that case by constructing a new AssnsBranchData object,
213  // although I imagine it might never happen in practice.
214  if (info.isAssns() && branch != nullptr) {
215  TClass* tClass = getTClass(info, processName);
216 
217  art::TypeID const typeIDInDescription{tClass->GetTypeInfo()};
218  art::TypeID const typeIDInBranchData{
219  branchData.tClass()->GetTypeInfo()};
220  if (typeIDInDescription != typeIDInBranchData) {
221  std::string branchName = branchData.branchName();
222  branchDataMap_[productID] =
223  std::make_unique<AssnsBranchData>(typeIDInDescription,
224  tClass,
225  branch,
227  this,
228  move(branchName),
229  info.type(),
230  info.partnerType());
231  }
232  }
233  info.processIndexToProductID().emplace_back(processIndex,
234  bd->productID());
235  if (initializeTheCache && branch) {
236  tree_->AddBranchToCache(branch, kTRUE);
237  }
239  productID)) {
241  bd->branchName(), processIndex, info, initializeTheCache);
242  }
243  }
245  }
246  if (initializeTheCache) {
247  tree_->StopCacheLearningPhase();
248  }
249  // This must be cleared because the BranchIDLists may be different
250  // in different input files.
251  branchDataMissingSet_.clear();
252  updateEvent();
253  }
std::map< art::ProductID, std::unique_ptr< BranchData > > branchDataMap_
std::set< art::ProductID > branchDataMissingSet_
art::BranchDescription const * productDescription(InfoForTypeLabelInstance const &info, std::string const &process) const
std::string string
Definition: nybbler.cc:12
void addBranchData(std::string branchName, unsigned int processIndex, InfoForTypeLabelInstance const &info, bool initializeTheCache=false) const
art::ProductID getMaybeValidProductID(std::vector< IndexProductIDPair > const &processIndexToProductID, unsigned int processIndex) const
TBranch * eventAuxiliaryBranch() const
void updateFile(TFile *tFile)
def move(depos, offset)
Definition: depos.py:107
void updateBranchDataIndexOrderedByHistory(InfoForTypeLabelInstance const &info) const
bool branchInRegistryOfAnyOpenedFile(art::ProductID const &) const
EventNavigator const * eventNavigator_
BranchMapReader branchMapReader_
std::vector< InfoForTypeLabelInstance > infoVector_
TClass * getTClass(InfoForTypeLabelInstance const &info, std::string const &processName) const
cet::exempt_ptr< art::BranchIDLists const > branchIDLists() const
std::vector< std::string > processNames_

Member Data Documentation

std::map<art::ProductID, std::unique_ptr<BranchData> > gallery::DataGetterHelper::branchDataMap_ {}
mutableprivate

Definition at line 200 of file DataGetterHelper.h.

std::set<art::ProductID> gallery::DataGetterHelper::branchDataMissingSet_ {}
mutableprivate

Definition at line 207 of file DataGetterHelper.h.

BranchMapReader gallery::DataGetterHelper::branchMapReader_ {}
private

Definition at line 210 of file DataGetterHelper.h.

art::root::DictionaryChecker gallery::DataGetterHelper::dictChecker_ {}
mutableprivate

Definition at line 212 of file DataGetterHelper.h.

EventNavigator const* gallery::DataGetterHelper::eventNavigator_
private

Definition at line 149 of file DataGetterHelper.h.

std::shared_ptr<EventHistoryGetter> gallery::DataGetterHelper::historyGetter_
private

Definition at line 153 of file DataGetterHelper.h.

std::map<TypeLabelInstanceKey, unsigned int> gallery::DataGetterHelper::infoMap_ {}
mutableprivate

Definition at line 182 of file DataGetterHelper.h.

std::vector<InfoForTypeLabelInstance> gallery::DataGetterHelper::infoVector_ {}
mutableprivate

Definition at line 178 of file DataGetterHelper.h.

bool gallery::DataGetterHelper::initializedForProcessHistory_ {false}
mutableprivate

Definition at line 155 of file DataGetterHelper.h.

BranchData gallery::DataGetterHelper::invalidBranchData_ {}
private

Definition at line 202 of file DataGetterHelper.h.

std::vector<unsigned int> gallery::DataGetterHelper::orderedProcessIndexes_ {}
mutableprivate

Definition at line 171 of file DataGetterHelper.h.

art::ProcessHistoryID gallery::DataGetterHelper::previousProcessHistoryID_ {}
mutableprivate

Definition at line 157 of file DataGetterHelper.h.

std::vector<std::string> gallery::DataGetterHelper::previousProcessHistoryNames_ {}
mutableprivate

Definition at line 159 of file DataGetterHelper.h.

std::vector<std::string> gallery::DataGetterHelper::processNames_ {}
mutableprivate

Definition at line 164 of file DataGetterHelper.h.

std::map<std::string, unsigned int> gallery::DataGetterHelper::processNameToProcessIndex_ {}
mutableprivate

Definition at line 168 of file DataGetterHelper.h.

TTree* gallery::DataGetterHelper::tree_ {nullptr}
private

Definition at line 151 of file DataGetterHelper.h.


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