Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:27:58

0001 
0002 #include "FWCore/Framework/interface/MergeableRunProductProcesses.h"
0003 
0004 #include "DataFormats/Common/interface/WrapperBase.h"
0005 #include "DataFormats/Provenance/interface/BranchDescription.h"
0006 #include "DataFormats/Provenance/interface/ProductRegistry.h"
0007 #include "FWCore/Utilities/interface/getAnyPtr.h"
0008 
0009 #include "TClass.h"
0010 
0011 #include <memory>
0012 #include <set>
0013 
0014 namespace edm {
0015 
0016   MergeableRunProductProcesses::MergeableRunProductProcesses() {}
0017 
0018   void MergeableRunProductProcesses::setProcessesWithMergeableRunProducts(ProductRegistry const& productRegistry) {
0019     TClass* wrapperBaseTClass = TypeWithDict::byName("edm::WrapperBase").getClass();
0020     std::set<std::string> processSet;
0021     for (auto const& prod : productRegistry.productList()) {
0022       BranchDescription const& desc = prod.second;
0023       if (desc.branchType() == InRun && !desc.produced() && desc.present()) {
0024         TClass* cp = desc.wrappedType().getClass();
0025         void* p = cp->New();
0026         int offset = cp->GetBaseClassOffset(wrapperBaseTClass);
0027         std::unique_ptr<WrapperBase> edp = getAnyPtr<WrapperBase>(p, offset);
0028         if (edp->isMergeable()) {
0029           processSet.insert(desc.processName());
0030         }
0031       }
0032     }
0033     processesWithMergeableRunProducts_.assign(processSet.begin(), processSet.end());
0034   }
0035 }  // namespace edm