HiggsAnalysis-KITHiggsToTauTau
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
DiLeptonVetoFilters.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include <boost/algorithm/string.hpp>
5 #include <boost/algorithm/string/trim.hpp>
6 
7 #include "Kappa/DataFormats/interface/Kappa.h"
8 
9 #include "Artus/Core/interface/FilterBase.h"
10 
11 #include "HiggsAnalysis/KITHiggsToTauTau/interface/HttTypes.h"
12 #include "HiggsAnalysis/KITHiggsToTauTau/interface/HttEnumTypes.h"
13 
14 
17 template<class TLepton>
18 class DiLeptonVetoFilterBase: public FilterBase<HttTypes> {
19 public:
20 
21  enum class VetoMode : int
22  {
23  NONE = -1,
24  VETO_OS_KEEP_SS = 0,
25  VETO_SS_KEEP_OS = 1,
26  VETO_OS_VETO_SS = 2,
27  KEEP_OS_KEEP_SS = 2,
28  };
29  static VetoMode ToVetoMode(std::string const& vetoMode)
30  {
31  if (vetoMode == "veto_os_keep_ss") return VetoMode::VETO_OS_KEEP_SS;
32  else if (vetoMode == "veto_ss_keep_os") return VetoMode::VETO_SS_KEEP_OS;
33  else if (vetoMode == "veto_os_veto_ss") return VetoMode::VETO_OS_VETO_SS;
34  else if (vetoMode == "keep_os_keep_ss") return VetoMode::KEEP_OS_KEEP_SS;
35  else return VetoMode::NONE;
36  }
37 
38  DiLeptonVetoFilterBase(std::vector<TLepton*> product_type::*leptons,
39  std::string (setting_type::*GetDiLeptonVetoMode)(void) const) :
40  m_leptons(leptons),
41  GetDiLeptonVetoMode(GetDiLeptonVetoMode)
42  {
43  }
44 
45  virtual void Init(setting_type const& settings, metadata_type& metadata) override
46  {
47  FilterBase<HttTypes>::Init(settings, metadata);
48 
49  vetoMode = ToVetoMode(boost::algorithm::to_lower_copy(boost::algorithm::trim_copy((settings.*GetDiLeptonVetoMode)())));
50  }
51 
52  virtual bool DoesEventPass(event_type const& event, product_type const& product,
53  setting_type const& settings, metadata_type const& metadata) const override
54  {
55  // TODO: This producer should be adapted to use the outputs of the new DiLeptonVetoProducers.
56 
57  if ((vetoMode == VetoMode::KEEP_OS_KEEP_SS) ||
58  (vetoMode == VetoMode::NONE) ||
59  ((product.*m_leptons).size() < 2))
60  {
61  return true;
62  }
63  else
64  {
65  int nPosLeptons = 0;
66  int nNegLeptons = 0;
67 
68  for (typename std::vector<TLepton*>::const_iterator lepton = (product.*m_leptons).begin();
69  lepton != (product.*m_leptons).end(); ++lepton)
70  {
71  if ((int)((*lepton)->charge()) > 0)
72  {
73  ++nPosLeptons;
74  }
75  else
76  {
77  ++nNegLeptons;
78  }
79 
80  if ((
81  ((nPosLeptons > 0) && (nNegLeptons > 0))
82  &&
83  ((vetoMode == VetoMode::VETO_OS_KEEP_SS) || (vetoMode == VetoMode::VETO_OS_VETO_SS))
84  )
85  ||
86  (
87  ((nPosLeptons > 1) || (nNegLeptons > 1))
88  &&
89  ((vetoMode == VetoMode::VETO_SS_KEEP_OS) || (vetoMode == VetoMode::VETO_OS_VETO_SS))
90  )
91  )
92  {
93  return false;
94  }
95  }
96 
97  return true;
98  }
99  }
100 
101 
102 private:
103  std::vector<TLepton*> product_type::*m_leptons;
104  std::string (setting_type::*GetDiLeptonVetoMode)(void) const;
105 
106  VetoMode vetoMode;
107 
108 };
109 
110 
116 public:
117 
118  virtual std::string GetFilterId() const override {
119  return "DiVetoElectronVetoFilter";
120  }
121 
123 };
124 
125 
131 public:
132 
133  virtual std::string GetFilterId() const override {
134  return "DiVetoMuonVetoFilter";
135  }
136 
138 };
139 
virtual bool DoesEventPass(event_type const &event, product_type const &product, setting_type const &settings, metadata_type const &metadata) const override
Definition: DiLeptonVetoFilters.h:52
DiVetoElectronVetoFilter()
Definition: DiLeptonVetoFilters.cc:5
virtual void Init(setting_type const &settings, metadata_type &metadata) override
Definition: DiLeptonVetoFilters.h:45
Definition: DiLeptonVetoFilters.h:115
VetoMode
Definition: DiLeptonVetoFilters.h:21
virtual std::string GetFilterId() const override
Definition: DiLeptonVetoFilters.h:133
virtual std::string GetFilterId() const override
Definition: DiLeptonVetoFilters.h:118
Definition: DiLeptonVetoFilters.h:130
DiVetoMuonVetoFilter()
Definition: DiLeptonVetoFilters.cc:11
Definition: DiLeptonVetoFilters.h:18
static VetoMode ToVetoMode(std::string const &vetoMode)
Definition: DiLeptonVetoFilters.h:29
DiLeptonVetoFilterBase(std::vector< TLepton * > product_type::*leptons, std::string(setting_type::*GetDiLeptonVetoMode)(void) const)
Definition: DiLeptonVetoFilters.h:38