Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-06-12 03:09:34

0001 #ifndef RecoBTau_JetTagComputer_GenericMVAJetTagComputerWrapper_h
0002 #define RecoBTau_JetTagComputer_GenericMVAJetTagComputerWrapper_h
0003 
0004 #include <memory>
0005 
0006 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0007 #include "DataFormats/BTauReco/interface/BaseTagInfo.h"
0008 #include "DataFormats/BTauReco/interface/TaggingVariable.h"
0009 #include "RecoBTau/JetTagComputer/interface/GenericMVAJetTagComputer.h"
0010 
0011 /*
0012  * This header defines a bunch of templated convenience wrappers
0013  *
0014  *      GenericMVAJetTagComputerWrapper<class Provider, ...>
0015  *
0016  * whereas ... dennotes argument pairs, with the
0017  *   first argument being a specific TagInfo class
0018  *   second argument being a constant string dennoting the cfg parameter
0019  *
0020  * If only one TagInfo is passed, the cfg parameter name can be ommited
0021  * (will default to "tagInfo"). 
0022  *
0023  * The wrapper will derive from the template argument class Provider,
0024  * pass the ParameterSet of the JetTagComputer to the (optional) constructor
0025  * and call "TaggingVariableList operator () (...) const" for every jet to
0026  * tag, with ... being the already casted and type-verified specific
0027  * TagInfo references (number of arguments matching the template instance).
0028  *
0029  * The TaggingVariables will be fed into the MVAComputer, which will compute
0030  * the final discriminator from an ES calibration object define in the cfg.
0031  */
0032 
0033 namespace btau_dummy {
0034   struct Null {};
0035   constexpr const char none[] = "";
0036 }  // namespace btau_dummy
0037 
0038 // 4 named TagInfos
0039 
0040 template <class Provider,
0041           class TI1,
0042           const char *ti1 = btau_dummy::none,
0043           class TI2 = btau_dummy::Null,
0044           const char *ti2 = btau_dummy::none,
0045           class TI3 = btau_dummy::Null,
0046           const char *ti3 = btau_dummy::none,
0047           class TI4 = btau_dummy::Null,
0048           const char *ti4 = btau_dummy::none>
0049 class GenericMVAJetTagComputerWrapper : public GenericMVAJetTagComputer, private Provider {
0050 public:
0051   GenericMVAJetTagComputerWrapper(const edm::ParameterSet &params, Tokens tokens)
0052       : GenericMVAJetTagComputer(params, tokens), Provider(params) {
0053     uses(0, ti1);
0054     uses(1, ti2);
0055     uses(2, ti3);
0056     uses(3, ti4);
0057   }
0058 
0059 protected:
0060   reco::TaggingVariableList taggingVariables(const TagInfoHelper &info) const override {
0061     return (
0062         static_cast<const Provider &>(*this))(info.get<TI1>(0), info.get<TI2>(1), info.get<TI3>(2), info.get<TI4>(3));
0063   }
0064 };
0065 
0066 // 3 named TagInfos
0067 
0068 template <class Provider, class TI1, const char *ti1, class TI2, const char *ti2, class TI3, const char *ti3>
0069 class GenericMVAJetTagComputerWrapper<Provider, TI1, ti1, TI2, ti2, TI3, ti3, btau_dummy::Null, btau_dummy::none>
0070     : public GenericMVAJetTagComputer, private Provider {
0071 public:
0072   GenericMVAJetTagComputerWrapper(const edm::ParameterSet &params, Tokens tokens)
0073       : GenericMVAJetTagComputer(params, tokens), Provider(params) {
0074     uses(0, ti1);
0075     uses(1, ti2);
0076     uses(2, ti3);
0077   }
0078 
0079 protected:
0080   reco::TaggingVariableList taggingVariables(const TagInfoHelper &info) const override {
0081     return (static_cast<const Provider &>(*this))(info.get<TI1>(0), info.get<TI2>(1), info.get<TI3>(2));
0082   }
0083 };
0084 
0085 // 2 named TagInfos
0086 
0087 template <class Provider, class TI1, const char *ti1, class TI2, const char *ti2>
0088 class GenericMVAJetTagComputerWrapper<Provider,
0089                                       TI1,
0090                                       ti1,
0091                                       TI2,
0092                                       ti2,
0093                                       btau_dummy::Null,
0094                                       btau_dummy::none,
0095                                       btau_dummy::Null,
0096                                       btau_dummy::none> : public GenericMVAJetTagComputer,
0097                                                           private Provider {
0098 public:
0099   GenericMVAJetTagComputerWrapper(const edm::ParameterSet &params, Tokens tokens)
0100       : GenericMVAJetTagComputer(params, tokens), Provider(params) {
0101     uses(0, ti1);
0102     uses(1, ti2);
0103   }
0104 
0105 protected:
0106   reco::TaggingVariableList taggingVariables(const TagInfoHelper &info) const override {
0107     return (static_cast<const Provider &>(*this))(info.get<TI1>(0), info.get<TI2>(1));
0108   }
0109 };
0110 
0111 // 1 named TagInfo
0112 
0113 template <class Provider, class TI1, const char *ti1>
0114 class GenericMVAJetTagComputerWrapper<Provider,
0115                                       TI1,
0116                                       ti1,
0117                                       btau_dummy::Null,
0118                                       btau_dummy::none,
0119                                       btau_dummy::Null,
0120                                       btau_dummy::none,
0121                                       btau_dummy::Null,
0122                                       btau_dummy::none> : public GenericMVAJetTagComputer,
0123                                                           private Provider {
0124 public:
0125   GenericMVAJetTagComputerWrapper(const edm::ParameterSet &params, Tokens tokens)
0126       : GenericMVAJetTagComputer(params, tokens), Provider(params) {
0127     uses(0, ti1);
0128   }
0129 
0130 protected:
0131   reco::TaggingVariableList taggingVariables(const TagInfoHelper &info) const override {
0132     return (static_cast<const Provider &>(*this))(info.get<TI1>(0));
0133   }
0134 };
0135 
0136 // default TagInfo
0137 
0138 template <class Provider, class TI1>
0139 class GenericMVAJetTagComputerWrapper<Provider,
0140                                       TI1,
0141                                       btau_dummy::none,
0142                                       btau_dummy::Null,
0143                                       btau_dummy::none,
0144                                       btau_dummy::Null,
0145                                       btau_dummy::none,
0146                                       btau_dummy::Null,
0147                                       btau_dummy::none> : public GenericMVAJetTagComputer,
0148                                                           private Provider {
0149 public:
0150   GenericMVAJetTagComputerWrapper(const edm::ParameterSet &params, Tokens tokens)
0151       : GenericMVAJetTagComputer(params, tokens), Provider(params) {}
0152 
0153 protected:
0154   reco::TaggingVariableList taggingVariables(const TagInfoHelper &info) const override {
0155     return (static_cast<const Provider &>(*this))(info.get<TI1>(0));
0156   }
0157 };
0158 
0159 #endif  // RecoBTau_JetTagComputer_GenericMVAJetTagComputerWrapper_h