CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/CommonTools/UtilAlgos/interface/EventSetupInitTrait.h

Go to the documentation of this file.
00001 #ifndef UtilAlgos_EventSetupInitTrait_h
00002 #define UtilAlgos_EventSetupInitTrait_h
00003 #include "CommonTools/UtilAlgos/interface/AndSelector.h"
00004 #include "CommonTools/UtilAlgos/interface/OrSelector.h"
00005 
00006 namespace edm {
00007   class EventSetup;
00008   class Event;
00009 }
00010 
00011 namespace helpers {
00012   struct NullAndOperand;
00013 }
00014 
00015 namespace reco {
00016   namespace modules {
00018     template<typename T>
00019     struct NoEventSetupInit {
00020       static void init(T &, const edm::Event&, const edm::EventSetup&) { }
00021     };
00022 
00025     struct CommonSelectorEventSetupInit {
00026       template<typename Selector>
00027       static void init( Selector & selector,
00028                         const edm::Event & evt,
00029                         const edm::EventSetup& es ) { 
00030         selector.newEvent(evt, es);
00031       }
00032     };
00033 
00034     template<typename T>
00035     struct EventSetupInit {
00036       typedef NoEventSetupInit<T> type;
00037     };
00038 
00039     template<typename T1, typename T2, typename T3 = helpers::NullAndOperand, 
00040       typename T4 = helpers::NullAndOperand, typename T5 = helpers::NullAndOperand>
00041     struct CombinedEventSetupInit {
00042       template<template<typename, typename, typename, typename, typename> class SelectorT>
00043       static void init(SelectorT<T1, T2, T3, T4, T5>& selector,
00044                        const edm::Event & evt,
00045                        const edm::EventSetup& es) {
00046         EventSetupInit<T1>::type::init(selector.s1_, evt, es);
00047         EventSetupInit<T2>::type::init(selector.s2_, evt, es);
00048         EventSetupInit<T3>::type::init(selector.s3_, evt, es);
00049         EventSetupInit<T4>::type::init(selector.s4_, evt, es);
00050         EventSetupInit<T5>::type::init(selector.s5_, evt, es);
00051       }
00052     };
00053     
00054     template<typename T1, typename T2, typename T3, typename T4>
00055     struct CombinedEventSetupInit<T1, T2, T3, T4, helpers::NullAndOperand> {
00056       template<template<typename, typename, typename, typename, typename> class SelectorT>
00057       static void init(SelectorT<T1, T2, T3, T4, helpers::NullAndOperand>& selector,
00058                        const edm::Event & evt,
00059                        const edm::EventSetup& es) {
00060         EventSetupInit<T1>::type::init(selector.s1_, evt, es);
00061         EventSetupInit<T2>::type::init(selector.s2_, evt, es);
00062         EventSetupInit<T3>::type::init(selector.s3_, evt, es);
00063         EventSetupInit<T4>::type::init(selector.s4_, evt, es);
00064       }
00065     };
00066     
00067     template<typename T1, typename T2, typename T3>
00068     struct CombinedEventSetupInit<T1, T2, T3, helpers::NullAndOperand, helpers::NullAndOperand> {
00069       template<template<typename, typename, typename, typename, typename> class SelectorT>
00070       static void init(SelectorT<T1, T2, T3, helpers::NullAndOperand, helpers::NullAndOperand>& selector,
00071                        const edm::Event & evt,
00072                        const edm::EventSetup& es) {
00073         EventSetupInit<T1>::type::init(selector.s1_, evt, es);
00074         EventSetupInit<T2>::type::init(selector.s2_, evt, es);
00075         EventSetupInit<T3>::type::init(selector.s3_, evt, es);
00076       }
00077     };
00078     
00079     template<typename T1, typename T2>
00080     struct CombinedEventSetupInit<T1, T2, helpers::NullAndOperand, helpers::NullAndOperand, helpers::NullAndOperand> {
00081       template<template<typename, typename, typename, typename, typename> class SelectorT>
00082       static void init(SelectorT<T1, T2, helpers::NullAndOperand, helpers::NullAndOperand, helpers::NullAndOperand>& selector,
00083                        const edm::Event & evt,
00084                        const edm::EventSetup& es) {
00085         EventSetupInit<T1>::type::init(selector.s1_, evt, es);
00086         EventSetupInit<T2>::type::init(selector.s2_, evt, es);
00087       }
00088     };
00089     
00090     template<typename T1, typename T2, typename T3, typename T4, typename T5>
00091     struct EventSetupInit<AndSelector<T1, T2, T3, T4, T5> > {
00092       typedef CombinedEventSetupInit<T1, T2, T3, T4, T5> type;
00093     };
00094 
00095     template<typename T1, typename T2, typename T3, typename T4, typename T5>
00096     struct EventSetupInit<OrSelector<T1, T2, T3, T4, T5> > {
00097       typedef CombinedEventSetupInit<T1, T2, T3, T4, T5> type;
00098     };
00099 
00100   }
00101 }
00102 
00103 #define EVENTSETUP_STD_INIT(SELECTOR) \
00104 namespace reco { \
00105   namespace modules { \
00106     template<> \
00107     struct EventSetupInit<SELECTOR> { \
00108       typedef CommonSelectorEventSetupInit type; \
00109     }; \
00110   } \
00111 } \
00112 struct __useless_ignoreme
00113 
00114 #define EVENTSETUP_STD_INIT_T1(SELECTOR) \
00115 namespace reco { \
00116   namespace modules { \
00117     template<typename T1> \
00118     struct EventSetupInit<SELECTOR<T1> > {       \
00119       typedef CommonSelectorEventSetupInit type; \
00120     }; \
00121   } \
00122 } \
00123 struct __useless_ignoreme
00124 
00125 #define EVENTSETUP_STD_INIT_T2(SELECTOR) \
00126 namespace reco { \
00127   namespace modules { \
00128     template<typename T1, typename T2>                   \
00129     struct EventSetupInit<SELECTOR<T1, T2> > {           \
00130       typedef CommonSelectorEventSetupInit type; \
00131     }; \
00132   } \
00133 } \
00134 struct __useless_ignoreme
00135 
00136 #define EVENTSETUP_STD_INIT_T3(SELECTOR) \
00137 namespace reco { \
00138   namespace modules { \
00139     template<typename T1, typename T2, typename T3>              \
00140     struct EventSetupInit<SELECTOR<T1, T2, T3> > {               \
00141       typedef CommonSelectorEventSetupInit type; \
00142     }; \
00143   } \
00144 } \
00145 struct __useless_ignoreme
00146 
00147 
00148 #endif