File indexing completed on 2024-04-06 12:01:15
0001 #ifndef UtilAlgos_EventSetupInitTrait_h
0002 #define UtilAlgos_EventSetupInitTrait_h
0003 #include "CommonTools/UtilAlgos/interface/AndSelector.h"
0004 #include "CommonTools/UtilAlgos/interface/OrSelector.h"
0005 #include "FWCore/Framework/interface/ConsumesCollector.h"
0006
0007 namespace edm {
0008 class EventSetup;
0009 class Event;
0010 }
0011
0012 namespace helpers {
0013 struct NullAndOperand;
0014 }
0015
0016 namespace reco {
0017 namespace modules {
0018
0019 template <typename T>
0020 struct NoEventSetupInit {
0021 explicit NoEventSetupInit(edm::ConsumesCollector) {}
0022 NoEventSetupInit() = delete;
0023 void init(T&, const edm::Event&, const edm::EventSetup&) {}
0024 };
0025
0026
0027
0028 struct CommonSelectorEventSetupInit {
0029 explicit CommonSelectorEventSetupInit(edm::ConsumesCollector) {}
0030 CommonSelectorEventSetupInit() = delete;
0031 template <typename Selector>
0032 void init(Selector& selector, const edm::Event& evt, const edm::EventSetup& es) {
0033 selector.newEvent(evt, es);
0034 }
0035 };
0036
0037 template <typename T>
0038 struct EventSetupInit {
0039 typedef NoEventSetupInit<T> type;
0040 };
0041
0042 template <typename T1,
0043 typename T2,
0044 typename T3 = helpers::NullAndOperand,
0045 typename T4 = helpers::NullAndOperand,
0046 typename T5 = helpers::NullAndOperand>
0047 struct CombinedEventSetupInit {
0048 explicit CombinedEventSetupInit(edm::ConsumesCollector iC) : t1_(iC), t2_(iC), t3_(iC), t4_(iC), t5_(iC) {}
0049 template <template <typename, typename, typename, typename, typename> class SelectorT>
0050 void init(SelectorT<T1, T2, T3, T4, T5>& selector, const edm::Event& evt, const edm::EventSetup& es) {
0051 t1_.init(selector.s1_, evt, es);
0052 t2_.init(selector.s2_, evt, es);
0053 t3_.init(selector.s3_, evt, es);
0054 t4_.init(selector.s4_, evt, es);
0055 t5_.init(selector.s5_, evt, es);
0056 }
0057 typename EventSetupInit<T1>::type t1_;
0058 typename EventSetupInit<T2>::type t2_;
0059 typename EventSetupInit<T3>::type t3_;
0060 typename EventSetupInit<T4>::type t4_;
0061 typename EventSetupInit<T5>::type t5_;
0062 };
0063
0064 template <typename T1, typename T2, typename T3, typename T4>
0065 struct CombinedEventSetupInit<T1, T2, T3, T4, helpers::NullAndOperand> {
0066 explicit CombinedEventSetupInit(edm::ConsumesCollector iC) : t1_(iC), t2_(iC), t3_(iC), t4_(iC) {}
0067 template <template <typename, typename, typename, typename, typename> class SelectorT>
0068 void init(SelectorT<T1, T2, T3, T4, helpers::NullAndOperand>& selector,
0069 const edm::Event& evt,
0070 const edm::EventSetup& es) {
0071 t1_.init(selector.s1_, evt, es);
0072 t2_.init(selector.s2_, evt, es);
0073 t3_.init(selector.s3_, evt, es);
0074 t4_.init(selector.s4_, evt, es);
0075 }
0076 typename EventSetupInit<T1>::type t1_;
0077 typename EventSetupInit<T2>::type t2_;
0078 typename EventSetupInit<T3>::type t3_;
0079 typename EventSetupInit<T4>::type t4_;
0080 };
0081
0082 template <typename T1, typename T2, typename T3>
0083 struct CombinedEventSetupInit<T1, T2, T3, helpers::NullAndOperand, helpers::NullAndOperand> {
0084 explicit CombinedEventSetupInit(edm::ConsumesCollector iC) : t1_(iC), t2_(iC), t3_(iC) {}
0085 template <template <typename, typename, typename, typename, typename> class SelectorT>
0086 void init(SelectorT<T1, T2, T3, helpers::NullAndOperand, helpers::NullAndOperand>& selector,
0087 const edm::Event& evt,
0088 const edm::EventSetup& es) {
0089 t1_.init(selector.s1_, evt, es);
0090 t2_.init(selector.s2_, evt, es);
0091 t3_.init(selector.s3_, evt, es);
0092 }
0093 typename EventSetupInit<T1>::type t1_;
0094 typename EventSetupInit<T2>::type t2_;
0095 typename EventSetupInit<T3>::type t3_;
0096 };
0097
0098 template <typename T1, typename T2>
0099 struct CombinedEventSetupInit<T1, T2, helpers::NullAndOperand, helpers::NullAndOperand, helpers::NullAndOperand> {
0100 explicit CombinedEventSetupInit(edm::ConsumesCollector iC) : t1_(iC), t2_(iC) {}
0101 template <template <typename, typename, typename, typename, typename> class SelectorT>
0102 void init(SelectorT<T1, T2, helpers::NullAndOperand, helpers::NullAndOperand, helpers::NullAndOperand>& selector,
0103 const edm::Event& evt,
0104 const edm::EventSetup& es) {
0105 t1_.init(selector.s1_, evt, es);
0106 t2_.init(selector.s2_, evt, es);
0107 }
0108 typename EventSetupInit<T1>::type t1_;
0109 typename EventSetupInit<T2>::type t2_;
0110 };
0111
0112 template <typename T1, typename T2, typename T3, typename T4, typename T5>
0113 struct EventSetupInit<AndSelector<T1, T2, T3, T4, T5> > {
0114 typedef CombinedEventSetupInit<T1, T2, T3, T4, T5> type;
0115 };
0116
0117 template <typename T1, typename T2, typename T3, typename T4, typename T5>
0118 struct EventSetupInit<OrSelector<T1, T2, T3, T4, T5> > {
0119 typedef CombinedEventSetupInit<T1, T2, T3, T4, T5> type;
0120 };
0121
0122 }
0123 }
0124
0125 #define EVENTSETUP_STD_INIT(SELECTOR) \
0126 namespace reco { \
0127 namespace modules { \
0128 template <> \
0129 struct EventSetupInit<SELECTOR> { \
0130 typedef CommonSelectorEventSetupInit type; \
0131 }; \
0132 } \
0133 } \
0134 struct __useless_ignoreme
0135
0136 #define EVENTSETUP_STD_INIT_T1(SELECTOR) \
0137 namespace reco { \
0138 namespace modules { \
0139 template <typename T1> \
0140 struct EventSetupInit<SELECTOR<T1> > { \
0141 typedef CommonSelectorEventSetupInit type; \
0142 }; \
0143 } \
0144 } \
0145 struct __useless_ignoreme
0146
0147 #define EVENTSETUP_STD_INIT_T2(SELECTOR) \
0148 namespace reco { \
0149 namespace modules { \
0150 template <typename T1, typename T2> \
0151 struct EventSetupInit<SELECTOR<T1, T2> > { \
0152 typedef CommonSelectorEventSetupInit type; \
0153 }; \
0154 } \
0155 } \
0156 struct __useless_ignoreme
0157
0158 #define EVENTSETUP_STD_INIT_T3(SELECTOR) \
0159 namespace reco { \
0160 namespace modules { \
0161 template <typename T1, typename T2, typename T3> \
0162 struct EventSetupInit<SELECTOR<T1, T2, T3> > { \
0163 typedef CommonSelectorEventSetupInit type; \
0164 }; \
0165 } \
0166 } \
0167 struct __useless_ignoreme
0168
0169 #endif