00001 #ifndef SimGeneral_MixingModule_PileUpEventPrincipal_h 00002 #define SimGeneral_MixingModule_PileUpEventPrincipal_h 00003 00004 #include <set> 00005 #include <string> 00006 00007 #include "FWCore/Framework/interface/EventPrincipal.h" 00008 #include "FWCore/Utilities/interface/InputTag.h" 00009 #include "FWCore/Utilities/interface/ProductKindOfType.h" 00010 #include "FWCore/Utilities/interface/TypeID.h" 00011 #include "DataFormats/Common/interface/BasicHandle.h" 00012 #include "DataFormats/Common/interface/ConvertHandle.h" 00013 #include "SimDataFormats/EncodedEventId/interface/EncodedEventId.h" 00014 00015 class PileUpEventPrincipal { 00016 public: 00017 00018 PileUpEventPrincipal(edm::EventPrincipal const& ep, int bcr) : 00019 principal_(ep), bunchCrossing_(bcr) {} 00020 00021 edm::EventPrincipal const& principal() { 00022 return principal_; 00023 } 00024 00025 edm::EventPrincipal const& principal() const { 00026 return principal_; 00027 } 00028 00029 int bunchCrossing() const { 00030 return bunchCrossing_; 00031 } 00032 00033 00034 template<typename T> 00035 bool 00036 getByLabel(edm::InputTag const& tag, edm::Handle<T>& result) const { 00037 typedef typename T::value_type ItemType; 00038 typedef typename T::iterator iterator; 00039 edm::BasicHandle bh = principal_.getByLabel(edm::PRODUCT_TYPE, edm::TypeID(typeid(T)), tag); 00040 convert_handle(bh, result); 00041 return result.isValid(); 00042 } 00043 00044 private: 00045 edm::EventPrincipal const& principal_; 00046 int bunchCrossing_; 00047 }; 00048 00049 #endif 00050