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 
24 
25 #include "HLTJetTag.h"
26 
27 #include<vector>
28 #include<string>
29 #include<typeinfo>
30 
31 //
32 // constructors and destructor
33 //
34 
35 template<typename T>
37  m_Jets (config.getParameter<edm::InputTag> ("Jets") ),
38  m_JetTags(config.getParameter<edm::InputTag> ("JetTags") ),
39  m_MinTag (config.getParameter<double> ("MinTag") ),
40  m_MaxTag (config.getParameter<double> ("MaxTag") ),
41  m_MinJets(config.getParameter<int> ("MinJets") ),
42  m_TriggerType(config.getParameter<int> ("TriggerType") )
43 {
44 
45  edm::LogInfo("") << " (HLTJetTag) trigger cuts: " << std::endl
46  << "\ttype of jets used: " << m_Jets.encode() << std::endl
47  << "\ttype of tagged jets used: " << m_JetTags.encode() << std::endl
48  << "\tmin/max tag value: [" << m_MinTag << ".." << m_MaxTag << "]" << std::endl
49  << "\tmin no. tagged jets: " << m_MinJets
50  << "\tTriggerType: " << m_TriggerType << std::endl;
51 }
52 
53 template<typename T>
55 {
56 }
57 
58 template<typename T>
59 void
62  makeHLTFilterDescription(desc);
63  desc.add<edm::InputTag>("Jets",edm::InputTag("hltJetCollection"));
64  desc.add<edm::InputTag>("JetTags",edm::InputTag("hltJetTagCollection"));
65  desc.add<double>("MinTag",2.0);
66  desc.add<double>("MaxTag",999999.0);
67  desc.add<int>("MinJets",1);
68  desc.add<int>("TriggerType",0);
69  descriptions.add(std::string("hlt")+std::string(typeid(HLTJetTag<T>).name()),desc);
70 }
71 
72 //
73 // member functions
74 //
75 
76 
77 // ------------ method called to produce the data ------------
78 template<typename T>
79 bool
81 {
82  using namespace std;
83  using namespace edm;
84  using namespace reco;
85 
86  typedef vector<T> TCollection;
87  typedef Ref<TCollection> TRef;
88 
90  event.getByLabel(m_Jets, h_Jets);
91  if (saveTags()) filterproduct.addCollectionTag(m_Jets);
92 
94  event.getByLabel(m_JetTags, h_JetTags);
95 
96  // check if the product this one depends on is available
97  auto const & handle = h_JetTags;
98  auto const & dependent = handle->keyProduct();
99  if (not dependent.isNull() and not dependent.hasCache()) {
100  // only an empty AssociationVector can have a invalid dependent collection
101  edm::Provenance const & dependent_provenance = event.getProvenance(dependent.id());
102  if (dependent_provenance.constBranchDescription().dropped())
103  // FIXME the error message should be made prettier
104  throw edm::Exception(edm::errors::ProductNotFound) << "Product " << handle.provenance()->branchName() << " requires product " << dependent_provenance.branchName() << ", which has been dropped";
105  }
106 
107  TRef jetRef;
108 
109  // Look at all jets in decreasing order of Et.
110  int nJet = 0;
111  int nTag = 0;
112  for (JetTagCollection::const_iterator jet = h_JetTags->begin(); jet != h_JetTags->end(); ++jet) {
113  jetRef = TRef(h_Jets,jet->first.key());
114  LogTrace("") << "Jet " << nJet
115  << " : Et = " << jet->first->et()
116  << " , tag value = " << jet->second;
117  ++nJet;
118  // Check if jet is tagged.
119  if ( (m_MinTag <= jet->second) and (jet->second <= m_MaxTag) ) {
120  ++nTag;
121 
122  // Store a reference to the jets which passed tagging cuts
123  filterproduct.addObject(m_TriggerType,jetRef);
124  }
125  }
126 
127  // filter decision
128  bool accept = (nTag >= m_MinJets);
129 
130  edm::LogInfo("") << " trigger accept ? = " << accept
131  << " nTag/nJet = " << nTag << "/" << nJet << std::endl;
132 
133  return accept;
134 }
transient_vector_type::const_iterator const_iterator
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:22
std::string encode() const
Definition: InputTag.cc:72
edm::InputTag m_Jets
Definition: HLTJetTag.h:42
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)
virtual bool hltFilter(edm::Event &event, const edm::EventSetup &setup, trigger::TriggerFilterObjectWithRefs &filterproduct)
Definition: HLTJetTag.cc:80
HLTJetTag(const edm::ParameterSet &config)
Definition: HLTJetTag.cc:36
int m_TriggerType
Definition: HLTJetTag.h:46
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:44
ConstBranchDescription const & constBranchDescription() const
Definition: Provenance.h:47
edm::InputTag m_JetTags
Definition: HLTJetTag.h:43
int m_MinJets
Definition: HLTJetTag.h:45
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:60
double m_MinTag
Definition: HLTJetTag.h:44
std::string const & branchName() const
Definition: Provenance.h:60
~HLTJetTag()
Definition: HLTJetTag.cc:54
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")