CMS 3D CMS Logo

HLTJetTag.cc
Go to the documentation of this file.
1 
13 #include <vector>
14 #include <string>
15 
26 
27 #include "HLTJetTag.h"
28 
29 
30 //
31 // constructors and destructor
32 //
33 
34 template<typename T>
36  m_Jets (config.getParameter<edm::InputTag>("Jets") ),
37  m_JetTags(config.getParameter<edm::InputTag>("JetTags") ),
38  m_MinTag (config.getParameter<double> ("MinTag") ),
39  m_MaxTag (config.getParameter<double> ("MaxTag") ),
40  m_MinJets(config.getParameter<int> ("MinJets") ),
41  m_TriggerType(config.getParameter<int> ("TriggerType") )
42 {
43  m_JetsToken = consumes<std::vector<T> >(m_Jets),
44  m_JetTagsToken = consumes<reco::JetTagCollection>(m_JetTags),
45 
46  edm::LogInfo("") << " (HLTJetTag) trigger cuts: " << std::endl
47  << "\ttype of jets used: " << m_Jets.encode() << std::endl
48  << "\ttype of tagged jets used: " << m_JetTags.encode() << std::endl
49  << "\tmin/max tag value: [" << m_MinTag << ".." << m_MaxTag << "]" << std::endl
50  << "\tmin no. tagged jets: " << m_MinJets
51  << "\tTriggerType: " << m_TriggerType << std::endl;
52 }
53 
54 template<typename T>
55 HLTJetTag<T>::~HLTJetTag() = default;
56 
57 template<typename T>
58 void
62  desc.add<edm::InputTag>("Jets",edm::InputTag("hltJetCollection"));
63  desc.add<edm::InputTag>("JetTags",edm::InputTag("hltJetTagCollection"));
64  desc.add<double>("MinTag",2.0);
65  desc.add<double>("MaxTag",999999.0);
66  desc.add<int>("MinJets",1);
67  desc.add<int>("TriggerType",0);
68  descriptions.add(defaultModuleLabel<HLTJetTag<T>>(), desc);
69 }
70 
71 //
72 // member functions
73 //
74 
75 
76 // ------------ method called to produce the data ------------
77 template<typename T>
78 bool
80 {
81  using namespace std;
82  using namespace edm;
83  using namespace reco;
84 
85  typedef vector<T> TCollection;
86  typedef Ref<TCollection> TRef;
87 
89  event.getByToken(m_JetsToken, h_Jets);
90  if (saveTags()) filterproduct.addCollectionTag(m_Jets);
91 
93  event.getByToken(m_JetTagsToken, h_JetTags);
94 
95  // check if the product this one depends on is available
96  auto const & handle = h_JetTags;
97  auto const & dependent = handle->keyProduct();
98  if (not dependent.isNull() and not dependent.hasCache()) {
99  // only an empty AssociationVector can have a invalid dependent collection
100  edm::Provenance const & dependent_provenance = event.getProvenance(dependent.id());
101  if (dependent_provenance.branchDescription().dropped())
102  // FIXME the error message should be made prettier
103  throw edm::Exception(edm::errors::ProductNotFound) << "Product " << handle.provenance()->branchName() << " requires product " << dependent_provenance.branchName() << ", which has been dropped";
104  }
105 
106  TRef jetRef;
107 
108  // Look at all jets in decreasing order of Et.
109  int nJet = 0;
110  int nTag = 0;
111  for (auto const & jet : *h_JetTags) {
112  jetRef = TRef(h_Jets,jet.first.key());
113  LogTrace("") << "Jet " << nJet
114  << " : Et = " << jet.first->et()
115  << " , tag value = " << jet.second;
116  ++nJet;
117  // Check if jet is tagged.
118  if ( (m_MinTag <= jet.second) and (jet.second <= m_MaxTag) ) {
119  ++nTag;
120 
121  // Store a reference to the jets which passed tagging cuts
122  filterproduct.addObject(m_TriggerType,jetRef);
123  }
124  }
125 
126  // filter decision
127  bool accept = (nTag >= m_MinJets);
128 
129  edm::LogInfo("") << " trigger accept ? = " << accept
130  << " nTag/nJet = " << nTag << "/" << nJet << std::endl;
131 
132  return accept;
133 }
edm::EDGetTokenT< reco::JetTagCollection > m_JetTagsToken
Definition: HLTJetTag.h:44
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:2
Definition: config.py:1
std::string defaultModuleLabel()
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:30
std::string encode() const
Definition: InputTag.cc:159
edm::InputTag m_Jets
Definition: HLTJetTag.h:41
void addObject(int id, const reco::RecoEcalCandidateRef &ref)
setters for L3 collections: (id=physics type, and Ref<C>)
HLTJetTag(const edm::ParameterSet &config)
Definition: HLTJetTag.cc:35
int m_TriggerType
Definition: HLTJetTag.h:47
ParameterDescriptionBase * add(U const &iLabel, T const &value)
#define LogTrace(id)
double m_MaxTag
Definition: HLTJetTag.h:45
static void makeHLTFilterDescription(edm::ParameterSetDescription &desc)
Definition: HLTFilter.cc:29
BranchDescription const & branchDescription() const
Definition: Provenance.h:45
edm::InputTag m_JetTags
Definition: HLTJetTag.h:43
int m_MinJets
Definition: HLTJetTag.h:46
edm::EDGetTokenT< std::vector< T > > m_JetsToken
Definition: HLTJetTag.h:42
void addCollectionTag(const edm::InputTag &collectionTag)
collectionTags
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: HLTJetTag.cc:59
double m_MinTag
Definition: HLTJetTag.h:45
fixed size matrix
bool saveTags() const
Definition: HLTFilter.h:45
HLT enums.
~HLTJetTag() override
std::string const & branchName() const
Definition: Provenance.h:51
Definition: event.py:1
bool hltFilter(edm::Event &event, const edm::EventSetup &setup, trigger::TriggerFilterObjectWithRefs &filterproduct) const override
Definition: HLTJetTag.cc:79