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
0017
0018
0019
0020
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 }