HiggsAnalysis-KITHiggsToTauTau
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
TriggerTagAndProbeProducers.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include <algorithm>
5 #include <utility>
6 
7 #include <boost/regex.hpp>
8 
9 #include <Math/VectorUtil.h>
10 
11 #include "Kappa/DataFormats/interface/Kappa.h"
12 
13 #include "Artus/Core/interface/ProducerBase.h"
14 #include "Artus/Utility/interface/SafeMap.h"
15 #include "Artus/Utility/interface/Utility.h"
16 #include "Artus/KappaAnalysis/interface/Producers/TriggerMatchingProducers.h"
17 
18 #include "HiggsAnalysis/KITHiggsToTauTau/interface/HttTypes.h"
19 
20 
21 
22 template<class TTag, class TProbe>
23 class TriggerTagAndProbeProducerBase: public ProducerBase<HttTypes>
24 {
25 public:
26 
28  std::vector<TTag*> product_type::*tagObjectsMember,
29  std::vector<TProbe*> product_type::*probeObjectsMember,
30  std::map<TTag*, std::map<std::string, std::map<std::string, std::vector<KLV*> > > > product_type::*detailedTriggerMatchedTagObjectsMember,
31  std::map<TProbe*, std::map<std::string, std::map<std::string, std::vector<KLV*> > > > product_type::*detailedTriggerMatchedProbeObjectsMember,
32  std::vector<std::string>& (setting_type::*GetTagObjectHltPaths)(void) const,
33  std::vector<std::string>& (setting_type::*GetProbeObjectHltPaths)(void) const,
34  //std::vector<std::string>& (setting_type::*GetTagObjectTriggerFilterNames)(void) const,
35  //std::vector<std::string>& (setting_type::*GetProbeObjectTriggerFilterNames)(void) const,
36  std::vector<std::pair<TTag*, TProbe*> > product_type::*triggerTagProbeObjectPairsMember,
37  std::vector<std::pair<bool, bool> > product_type::*triggerTagProbeObjectMatchedPairsMember
38  ) :
39  ProducerBase<HttTypes>(),
40  m_tagObjectsMember(tagObjectsMember),
41  m_probeObjectsMember(probeObjectsMember),
42  m_detailedTriggerMatchedTagObjectsMember(detailedTriggerMatchedTagObjectsMember),
43  m_detailedTriggerMatchedProbeObjectsMember(detailedTriggerMatchedProbeObjectsMember),
44  GetTagObjectHltPaths(GetTagObjectHltPaths),
45  GetProbeObjectHltPaths(GetProbeObjectHltPaths),
46  //GetTagObjectTriggerFilterNames(GetTagObjectTriggerFilterNames),
47  //GetProbeObjectTriggerFilterNames(GetProbeObjectTriggerFilterNames),
48  m_triggerTagProbeObjectPairsMember(triggerTagProbeObjectPairsMember),
49  m_triggerTagProbeObjectMatchedPairsMember(triggerTagProbeObjectMatchedPairsMember)
50  {
51  }
52 
53  virtual void Init(setting_type const& settings, metadata_type& metadata) override
54  {
55  ProducerBase<HttTypes>::Init(settings, metadata);
56  }
57 
58  virtual void Produce(event_type const& event, product_type & product,
59  setting_type const& settings, metadata_type const& metadata) const override
60  {
61  assert((product.*m_tagObjectsMember).size() > 0);
62  assert((product.*m_probeObjectsMember).size() > 0);
63 
64  for (typename std::vector<TTag*>::iterator tagObject = (product.*m_tagObjectsMember).begin();
65  tagObject != (product.*m_tagObjectsMember).end(); ++tagObject)
66  {
67  std::vector<std::string> tagFiredHltPaths = TriggerMatchingProducerBase<TObject>::GetHltNamesWhereAllFiltersMatched(SafeMap::GetWithDefault(
68  (product.*m_detailedTriggerMatchedTagObjectsMember),
69  (*tagObject),
70  std::map<std::string, std::map<std::string, std::vector<KLV*> > >()
71  ));
72 
73  bool matchedTagObject = false;
74  for (std::vector<std::string>::iterator tagFiredHltPath = tagFiredHltPaths.begin();
75  tagFiredHltPath != tagFiredHltPaths.end(); ++tagFiredHltPath)
76  {
77  for (std::vector<std::string>::iterator tagObjectHltPath = (settings.*GetTagObjectHltPaths)().begin();
78  tagObjectHltPath != (settings.*GetTagObjectHltPaths)().end(); ++tagObjectHltPath)
79  {
80  if (boost::regex_search(*tagFiredHltPath, boost::regex(*tagObjectHltPath, boost::regex::icase | boost::regex::extended)))
81  {
82  matchedTagObject = true;
83  break;
84  }
85  }
86  }
87 
88  for (typename std::vector<TProbe*>::iterator probeObject = (product.*m_probeObjectsMember).begin();
89  probeObject != (product.*m_probeObjectsMember).end(); ++probeObject)
90  {
91  if ((static_cast<void*>(*tagObject) != static_cast<void*>(*probeObject)) &&
92  ROOT::Math::VectorUtil::DeltaR((*tagObject)->p4, (*probeObject)->p4) > settings.GetDiTauPairMinDeltaRCut())
93  {
94  std::vector<std::string> probeFiredHltPaths = TriggerMatchingProducerBase<TObject>::GetHltNamesWhereAllFiltersMatched(SafeMap::GetWithDefault(
95  (product.*m_detailedTriggerMatchedProbeObjectsMember),
96  (*probeObject),
97  std::map<std::string, std::map<std::string, std::vector<KLV*> > >()
98  ));
99 
100  bool matchedProbeObject = false;
101  for (std::vector<std::string>::iterator probeFiredHltPath = probeFiredHltPaths.begin();
102  probeFiredHltPath != probeFiredHltPaths.end(); ++probeFiredHltPath)
103  {
104  for (std::vector<std::string>::iterator probeObjectHltPath = (settings.*GetProbeObjectHltPaths)().begin();
105  probeObjectHltPath != (settings.*GetProbeObjectHltPaths)().end(); ++probeObjectHltPath)
106  {
107  if (boost::regex_search(*probeFiredHltPath, boost::regex(*probeObjectHltPath, boost::regex::icase | boost::regex::extended)))
108  {
109  matchedProbeObject = true;
110  break;
111  }
112  }
113  }
114 
115  (product.*m_triggerTagProbeObjectPairsMember).push_back(std::pair<TTag*, TProbe*>(*tagObject, *probeObject));
116  (product.*m_triggerTagProbeObjectMatchedPairsMember).push_back(std::pair<bool, bool>(matchedTagObject, matchedProbeObject));
117  }
118  }
119  }
120  }
121 
122 
123 private:
124  std::vector<TTag*> product_type::*m_tagObjectsMember;
125  std::vector<TProbe*> product_type::*m_probeObjectsMember;
126  std::map<TTag*, std::map<std::string, std::map<std::string, std::vector<KLV*> > > > product_type::*m_detailedTriggerMatchedTagObjectsMember;
127  std::map<TProbe*, std::map<std::string, std::map<std::string, std::vector<KLV*> > > > product_type::*m_detailedTriggerMatchedProbeObjectsMember;
128  std::vector<std::string>& (setting_type::*GetTagObjectHltPaths)(void) const;
129  std::vector<std::string>& (setting_type::*GetProbeObjectHltPaths)(void) const;
130  //std::vector<std::string>& (setting_type::*GetTagObjectTriggerFilterNames)(void) const;
131  //std::vector<std::string>& (setting_type::*GetProbeObjectTriggerFilterNames)(void) const;
132  std::vector<std::pair<TTag*, TProbe*> > product_type::*m_triggerTagProbeObjectPairsMember;
133  std::vector<std::pair<bool, bool> > product_type::*m_triggerTagProbeObjectMatchedPairsMember;
134 
135 };
136 
137 
138 
140 {
141 public:
143  virtual std::string GetProducerId() const override;
144 };
145 
146 
148 {
149 public:
151  virtual std::string GetProducerId() const override;
152 };
153 
154 
156 {
157 public:
159  virtual std::string GetProducerId() const override;
160 };
161 
162 
164 {
165 public:
167  virtual std::string GetProducerId() const override;
168 };
169 
ETTriggerTagAndProbeProducer()
Definition: TriggerTagAndProbeProducers.cc:71
MTTriggerTagAndProbeProducer()
Definition: TriggerTagAndProbeProducers.cc:49
EETriggerTagAndProbeProducer()
Definition: TriggerTagAndProbeProducers.cc:5
virtual std::string GetProducerId() const override
Definition: TriggerTagAndProbeProducers.cc:43
virtual std::string GetProducerId() const override
Definition: TriggerTagAndProbeProducers.cc:87
TriggerTagAndProbeProducerBase(std::vector< TTag * > product_type::*tagObjectsMember, std::vector< TProbe * > product_type::*probeObjectsMember, std::map< TTag *, std::map< std::string, std::map< std::string, std::vector< KLV * > > > > product_type::*detailedTriggerMatchedTagObjectsMember, std::map< TProbe *, std::map< std::string, std::map< std::string, std::vector< KLV * > > > > product_type::*detailedTriggerMatchedProbeObjectsMember, std::vector< std::string > &(setting_type::*GetTagObjectHltPaths)(void) const, std::vector< std::string > &(setting_type::*GetProbeObjectHltPaths)(void) const, std::vector< std::pair< TTag *, TProbe * > > product_type::*triggerTagProbeObjectPairsMember, std::vector< std::pair< bool, bool > > product_type::*triggerTagProbeObjectMatchedPairsMember)
Definition: TriggerTagAndProbeProducers.h:27
virtual std::string GetProducerId() const override
Definition: TriggerTagAndProbeProducers.cc:21
virtual void Init(setting_type const &settings, metadata_type &metadata) override
Definition: TriggerTagAndProbeProducers.h:53
Definition: TriggerTagAndProbeProducers.h:155
MMTriggerTagAndProbeProducer()
Definition: TriggerTagAndProbeProducers.cc:27
Definition: TriggerTagAndProbeProducers.h:23
Definition: TriggerTagAndProbeProducers.h:163
Definition: TriggerTagAndProbeProducers.h:139
Definition: TriggerTagAndProbeProducers.h:147
virtual void Produce(event_type const &event, product_type &product, setting_type const &settings, metadata_type const &metadata) const override
Definition: TriggerTagAndProbeProducers.h:58
all data types which are used for Htt analyses
Definition: HttTypes.h:27
tuple regex
Definition: plot_overtraining.py:51
begin
Definition: plot_BDTSeparation.py:82
virtual std::string GetProducerId() const override
Definition: TriggerTagAndProbeProducers.cc:65