Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:03:55

0001 
0002 #include "DataFormats/Common/interface/setIsMergeable.h"
0003 
0004 #include "DataFormats/Common/interface/WrapperBase.h"
0005 #include "DataFormats/Provenance/interface/BranchDescription.h"
0006 #include "FWCore/Utilities/interface/BranchType.h"
0007 #include "FWCore/Utilities/interface/getAnyPtr.h"
0008 
0009 #include "TClass.h"
0010 
0011 #include <memory>
0012 
0013 namespace edm {
0014 
0015   void setIsMergeable(BranchDescription& desc) {
0016     // Save some time here with the knowledge that the isMergeable
0017     // data member can only be true for run or lumi products.
0018     // It defaults to false. Also if it is true that means it
0019     // was already set.
0020     // Set it only for branches that are present
0021     if (desc.present() and (desc.branchType() == InRun or desc.branchType() == InLumi)) {
0022       if (!desc.isMergeable()) {
0023         TClass* wrapperBaseTClass = TypeWithDict::byName("edm::WrapperBase").getClass();
0024         TClass* tClass = desc.wrappedType().getClass();
0025         void* p = tClass->New();
0026         int offset = tClass->GetBaseClassOffset(wrapperBaseTClass);
0027         std::unique_ptr<WrapperBase> wrapperBase = getAnyPtr<WrapperBase>(p, offset);
0028         if (wrapperBase->isMergeable()) {
0029           desc.setIsMergeable(true);
0030         }
0031       }
0032     }
0033   }
0034 }  // namespace edm