CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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>
56 {
57 }
58 
59 template<typename T>
60 void
63  makeHLTFilterDescription(desc);
64  desc.add<edm::InputTag>("Jets",edm::InputTag("hltJetCollection"));
65  desc.add<edm::InputTag>("JetTags",edm::InputTag("hltJetTagCollection"));
66  desc.add<double>("MinTag",2.0);
67  desc.add<double>("MaxTag",999999.0);
68  desc.add<int>("MinJets",1);
69  desc.add<int>("TriggerType",0);
70  descriptions.add(defaultModuleLabel<HLTJetTag<T>>(), desc);
71 }
72 
73 //
74 // member functions
75 //
76 
77 
78 // ------------ method called to produce the data ------------
79 template<typename T>
80 bool
82 {
83  using namespace std;
84  using namespace edm;
85  using namespace reco;
86 
87  typedef vector<T> TCollection;
88  typedef Ref<TCollection> TRef;
89 
91  event.getByToken(m_JetsToken, h_Jets);
92  if (saveTags()) filterproduct.addCollectionTag(m_Jets);
93 
95  event.getByToken(m_JetTagsToken, h_JetTags);
96 
97  // check if the product this one depends on is available
98  auto const & handle = h_JetTags;
99  auto const & dependent = handle->keyProduct();
100  if (not dependent.isNull() and not dependent.hasCache()) {
101  // only an empty AssociationVector can have a invalid dependent collection
102  edm::Provenance const & dependent_provenance = event.getProvenance(dependent.id());
103  if (dependent_provenance.constBranchDescription().dropped())
104  // FIXME the error message should be made prettier
105  throw edm::Exception(edm::errors::ProductNotFound) << "Product " << handle.provenance()->branchName() << " requires product " << dependent_provenance.branchName() << ", which has been dropped";
106  }
107 
108  TRef jetRef;
109 
110  // Look at all jets in decreasing order of Et.
111  int nJet = 0;
112  int nTag = 0;
113  for (JetTagCollection::const_iterator jet = h_JetTags->begin(); jet != h_JetTags->end(); ++jet) {
114  jetRef = TRef(h_Jets,jet->first.key());
115  LogTrace("") << "Jet " << nJet
116  << " : Et = " << jet->first->et()
117  << " , tag value = " << jet->second;
118  ++nJet;
119  // Check if jet is tagged.
120  if ( (m_MinTag <= jet->second) and (jet->second <= m_MaxTag) ) {
121  ++nTag;
122 
123  // Store a reference to the jets which passed tagging cuts
124  filterproduct.addObject(m_TriggerType,jetRef);
125  }
126  }
127 
128  // filter decision
129  bool accept = (nTag >= m_MinJets);
130 
131  edm::LogInfo("") << " trigger accept ? = " << accept
132  << " nTag/nJet = " << nTag << "/" << nJet << std::endl;
133 
134  return accept;
135 }
std::string defaultModuleLabel()
edm::EDGetTokenT< reco::JetTagCollection > m_JetTagsToken
Definition: HLTJetTag.h:44
transient_vector_type::const_iterator const_iterator
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:24
std::string encode() const
Definition: InputTag.cc:164
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&lt;C&gt;)
U second(std::pair< T, U > const &p)
HLTJetTag(const edm::ParameterSet &config)
Definition: HLTJetTag.cc:35
int m_TriggerType
Definition: HLTJetTag.h:47
tuple handle
Definition: patZpeak.py:22
ParameterDescriptionBase * add(U const &iLabel, T const &value)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
#define LogTrace(id)
double m_MaxTag
Definition: HLTJetTag.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)
virtual bool hltFilter(edm::Event &event, const edm::EventSetup &setup, trigger::TriggerFilterObjectWithRefs &filterproduct) const override
Definition: HLTJetTag.cc:81
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: HLTJetTag.cc:61
double m_MinTag
Definition: HLTJetTag.h:45
BranchDescription const & constBranchDescription() const
Definition: Provenance.h:45
std::string const & branchName() const
Definition: Provenance.h:58
~HLTJetTag()
Definition: HLTJetTag.cc:55
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")