Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:30:03

0001 #ifndef SimGeneral_MixingModule_PileUpEventPrincipal_h
0002 #define SimGeneral_MixingModule_PileUpEventPrincipal_h
0003 
0004 #include <set>
0005 #include <string>
0006 
0007 #include "FWCore/Framework/interface/EventPrincipal.h"
0008 #include "FWCore/Utilities/interface/InputTag.h"
0009 #include "FWCore/Utilities/interface/ProductKindOfType.h"
0010 #include "FWCore/Utilities/interface/TypeID.h"
0011 #include "DataFormats/Common/interface/BasicHandle.h"
0012 #include "DataFormats/Common/interface/ConvertHandle.h"
0013 #include "SimDataFormats/EncodedEventId/interface/EncodedEventId.h"
0014 
0015 namespace edm {
0016   class ModuleCallingContext;
0017 }
0018 
0019 class PileUpEventPrincipal {
0020 public:
0021   PileUpEventPrincipal(edm::EventPrincipal const& ep, edm::ModuleCallingContext const* mcc, int bcr)
0022       : principal_(ep), mcc_(mcc), bunchCrossing_(bcr) {}
0023 
0024   edm::EventPrincipal const& principal() { return principal_; }
0025 
0026   edm::EventPrincipal const& principal() const { return principal_; }
0027 
0028   edm::ModuleCallingContext const* moduleCallingContext() const { return mcc_; }
0029 
0030   int bunchCrossing() const { return bunchCrossing_; }
0031 
0032   template <typename T>
0033   bool getByLabel(edm::InputTag const& tag, edm::Handle<T>& result) const {
0034     edm::BasicHandle bh = principal_.getByLabel(edm::PRODUCT_TYPE, edm::TypeID(typeid(T)), tag, nullptr, nullptr, mcc_);
0035     result = edm::convert_handle<T>(std::move(bh));
0036     return result.isValid();
0037   }
0038 
0039 private:
0040   edm::EventPrincipal const& principal_;
0041   edm::ModuleCallingContext const* mcc_;
0042   int bunchCrossing_;
0043 };
0044 
0045 #endif