CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TopHLTDQMHelper.h
Go to the documentation of this file.
1 #ifndef TOPHLTDQMHELPERS
2 #define TOPHLTDQMHELPERS
3 
4 #include <string>
5 #include <vector>
6 #include <iostream>
7 //#include <math>
13 
16 /*Originally from DQM/Physics package, written by Roger Wolf and Jeremy Andrea*/
26 inline bool
27 acceptHLT(const edm::Event& event, const edm::TriggerResults& triggerTable, const std::string& triggerPath)
28 {
29  bool passed=false;
30  const edm::TriggerNames& triggerNames = event.triggerNames(triggerTable);
31  for(unsigned int i=0; i<triggerNames.triggerNames().size(); ++i){
32  if(triggerNames.triggerNames()[i] == triggerPath) {
33  if(triggerTable.accept(i)){
34  passed=true;
35  break;
36  }
37  }
38  }
39  return passed;
40 }
41 
42 inline bool
43 acceptHLT(const edm::Event& event, const edm::TriggerResults& triggerTable, const std::vector<std::string>& triggerPaths)
44 {
45  bool passed=false;
46  for(unsigned int j=0; j<triggerPaths.size(); ++j){
47  if(acceptHLT(event, triggerTable, triggerPaths[j])){
48  passed=true;
49  break;
50  }
51  }
52  return passed;
53 }
54 
55 
58 
71 class CalculateHLT {
72  public:
74  CalculateHLT(int maxNJets, double wMass);
77 
79  double massWBoson(const std::vector<reco::Jet>& jets);
81  double massTopQuark(const std::vector<reco::Jet>& jets);
83 /* double tmassWBoson(const T& mu, const reco::CaloMET& met, const reco::Jet& b);
85  double tmassTopQuark(const T& mu, const reco::CaloMET& met, const reco::Jet& b);
87  double masslb(const T& mu, const reco::CaloMET& met, const reco::Jet& b);*/
88 
90  double tmassWBoson(reco::RecoCandidate* mu, const reco::MET& met, const reco::Jet& b);
92  double tmassTopQuark(reco::RecoCandidate* mu, const reco::MET& met, const reco::Jet& b);
94  double masslb(reco::RecoCandidate* mu, const reco::MET& met, const reco::Jet& b);
95 
96  private:
100  void operator()(const std::vector<reco::Jet>& jets);
101  void operator()(const reco::Jet& bJet, reco::RecoCandidate* lepton, const reco::MET& met);
102  private:
104  bool failed_;
108  double wMass_;
110  double massWBoson_;
114  double tmassWBoson_;
118  double mlb_;
119 
120 
121 };
122 
123 
135 
176 template <typename Object>
178 public:
183 
185  bool select(const edm::Event& event);
187  bool select(const edm::Event& event, const edm::EventSetup& setup);
188  bool selectVertex(const edm::Event& event);
189 private:
194  int min_, max_;
219 
222 
227 };
228 
230 template <typename Object>
232  src_( cfg.getParameter<edm::InputTag>( "src" )),
233  select_( cfg.getParameter<std::string>("select")),
234  jetIDSelect_(0)
235 {
236  srcToken_ = iC.consumes< edm::View<Object> >(cfg.getParameter<edm::InputTag>("src"));
237  pvsToken_ = iC.consumes< edm::View<reco::Vertex> >(cfg.getParameter<edm::InputTag>("pvs"));
238  // construct min/max if the corresponding params
239  // exist otherwise they are initialized with -1
240  cfg.exists("min") ? min_= cfg.getParameter<int>("min") : min_= -1;
241  cfg.exists("max") ? max_= cfg.getParameter<int>("max") : max_= -1;
242  // read electron extras if they exist
243  if(cfg.existsAs<edm::ParameterSet>("electronId")){
244  edm::ParameterSet elecId=cfg.getParameter<edm::ParameterSet>("electronId");
245  electronId_= elecId.getParameter<edm::InputTag>("src");
246  electronIdToken_= iC.consumes< edm::ValueMap<float> >(elecId.getParameter<edm::InputTag>("src"));
247  eidPattern_= elecId.getParameter<int>("pattern");
248  }
249  // read jet corrector label if it exists
250  if(cfg.exists("jetCorrector")){ jetCorrector_= cfg.getParameter<std::string>("jetCorrector"); }
251  // read btag information if it exists
252  if(cfg.existsAs<edm::ParameterSet>("jetBTagger")){
253  edm::ParameterSet jetBTagger=cfg.getParameter<edm::ParameterSet>("jetBTagger");
254  btagLabel_=jetBTagger.getParameter<edm::InputTag>("label");
255  btagToken_= iC.consumes<reco::JetTagCollection>(jetBTagger.getParameter<edm::InputTag>("label"));
256  btagWorkingPoint_=jetBTagger.getParameter<double>("workingPoint");
257  }
258  // read jetID information if it exists
259  if(cfg.existsAs<edm::ParameterSet>("jetID")){
261  jetIDLabel_ =jetID.getParameter<edm::InputTag>("label");
262  jetIDToken_= iC.consumes<reco::JetIDValueMap>(jetID.getParameter<edm::InputTag>("label"));
264  }
265 }
266 
268 template <typename Object>
270 {
271  // fetch input collection
273  if( !event.getByToken(srcToken_, src) ) return false;
274 
275  // load electronId value map if configured such
277  if(!electronId_.label().empty()) {
278  if( !event.getByToken(electronIdToken_, electronId) ) return false;
279  }
280 
281  // determine multiplicity of selected objects
282  int n=0;
283  for(typename edm::View<Object>::const_iterator obj=src->begin(); obj!=src->end(); ++obj){
284  // special treatment for electrons
285  if(dynamic_cast<const reco::GsfElectron*>(&*obj)){
286  unsigned int idx = obj-src->begin();
287  if( electronId_.label().empty() ? true : ((int)(*electronId)[src->refAt(idx)] & eidPattern_) ){
288  if(select_(*obj))++n;
289  }
290  }
291  // normal treatment
292  else{
293  if(select_(*obj))++n;
294  }
295  }
296  bool accept=(min_>=0 ? n>=min_:true) && (max_>=0 ? n<=max_:true);
297  return (min_<0 && max_<0) ? (n>0):accept;
298 }
299 template <typename Object>
301 {
302  // fetch input collection
304  if( !event.getByToken(srcToken_, src) ) return false;
305 
306  // load electronId value map if configured such
308  if(!electronId_.label().empty()) {
309  if( !event.getByToken(electronIdToken_, electronId) ) return false;
310  }
311 
312  // determine multiplicity of selected objects
313  int n=0;
314  for(typename edm::View<Object>::const_iterator obj=src->begin(); obj!=src->end(); ++obj){
315 
316  if(select_(*obj))++n;
317  }
318  bool accept=(min_>=0 ? n>=min_:true) && (max_>=0 ? n<=max_:true);
319  return (min_<0 && max_<0) ? (n>0):accept;
320 }
321 
323 template <typename Object>
325 {
326  // fetch input collection
328  if( !event.getByToken(srcToken_, src) ) return false;
329 
330  // load btag collection if configured such
331  // NOTE that the JetTagCollection needs an
332  // edm::View to reco::Jets; we have to add
333  // another Handle bjets for this purpose
337  if(!btagLabel_.label().empty()){
338  if( !event.getByToken(srcToken_, bjets) ) return false;
339  if( !event.getByToken(btagToken_, btagger) ) return false;
340  if( !event.getByToken(pvsToken_, pvertex) ) return false;
341  }
342 
343  // load jetID value map if configured such
345  if(jetIDSelect_){
346  if( !event.getByToken(jetIDToken_, jetID) ) return false;
347 
348  }
349 
350  // load jet corrector if configured such
351  const JetCorrector* corrector=0;
352  if(!jetCorrector_.empty()){
353  // check whether a jet correcto is in the event setup or not
354  if(setup.find( edm::eventsetup::EventSetupRecordKey::makeKey<JetCorrectionsRecord>() )){
355  corrector = JetCorrector::getJetCorrector(jetCorrector_, setup);
356  }
357  else{
358  edm::LogVerbatim( "TopDQMHelpers" )
359  << "\n"
360  << "------------------------------------------------------------------------------------- \n"
361  << " No JetCorrectionsRecord available from EventSetup: \n"
362  << " - Jets will not be corrected. \n"
363  << " - If you want to change this add the following lines to your cfg file \n"
364  << " \n"
365  << " ## load jet corrections \n"
366  << " process.load(\"JetMETCorrections.Configuration.JetCorrectionServicesAllAlgos_cff\") \n"
367  << " process.prefer(\"ak5CaloL2L3\") \n"
368  << " \n"
369  << "------------------------------------------------------------------------------------- \n";
370  }
371  }
372  // determine multiplicity of selected objects
373  int n=0;
374  for(typename edm::View<Object>::const_iterator obj=src->begin(); obj!=src->end(); ++obj){
375  // check for chosen btag discriminator to be above the
376  // corresponding working point if configured such
377  unsigned int idx = obj-src->begin();
378  if( btagLabel_.label().empty() ? true : (*btagger)[bjets->refAt(idx)]>btagWorkingPoint_ ){
379  bool passedJetID=true;
380  // check jetID for calo jets
381  if( jetIDSelect_ && dynamic_cast<const reco::CaloJet*>(src->refAt(idx).get())){
382  passedJetID=(*jetIDSelect_)((*jetID)[src->refAt(idx)]);
383  }
384  if(passedJetID){
385  // scale jet energy if configured such
386  Object jet=*obj; jet.scaleEnergy(corrector ? corrector->correction(*obj) : 1.);
387  if(select_(jet))++n;
388  }
389  }
390  }
391  bool accept=(min_>=0 ? n>=min_:true) && (max_>=0 ? n<=max_:true);
392  return (min_<0 && max_<0) ? (n>0):accept;
393 }
394 
395 #endif
edm::InputTag pvs_
edm::InputTag btagLabel_
choice for b-tag as extra selection type
T getParameter(std::string const &) const
edm::InputTag src_
input collection
int i
Definition: DBlmapReader.cc:9
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
bool failed_
indicate failed associations
tuple met
____________________________________________________________________________||
Definition: CaloMET_cfi.py:7
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:184
bool acceptHLT(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
edm::EDGetTokenT< edm::View< reco::Vertex > > pvsToken_
double masslb(reco::RecoCandidate *mu, const reco::MET &met, const reco::Jet &b)
calculate mlb estimate
edm::InputTag jetIDLabel_
jetID as an extra selection type
double massTopQuark(const std::vector< reco::Jet > &jets)
calculate top quark mass estimate
edm::InputTag electronId_
electronId label as extra selection type
void operator()(const std::vector< reco::Jet > &jets)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
double wMass_
paramater of the w boson mass
virtual double correction(const LorentzVector &fJet) const =0
get correction using Jet information only
Base class for all types of Jets.
Definition: Jet.h:20
int min_
min/max for object multiplicity
bool accept() const
Has at least one path accepted the event?
double tmassTopQuark(reco::RecoCandidate *mu, const reco::MET &met, const reco::Jet &b)
calculate top quark transverse mass estimate
bool exists(std::string const &parameterName) const
checks if a parameter exists
double massWBoson(const std::vector< reco::Jet > &jets)
calculate W boson mass estimate
CalculateHLT(int maxNJets, double wMass)
default constructor
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:26
Strings const & triggerNames() const
Definition: TriggerNames.cc:24
const eventsetup::EventSetupRecord * find(const eventsetup::EventSetupRecordKey &) const
Definition: EventSetup.cc:90
edm::EDGetTokenT< edm::ValueMap< float > > electronIdToken_
SelectionStepHLT(const edm::ParameterSet &cfg, edm::ConsumesCollector &&iC)
default constructor
double massWBoson_
cache of w boson mass estimate
bool selectVertex(const edm::Event &event)
double mlb_
cache of mlb estimate
Definition: MET.h:32
vector< PseudoJet > jets
~CalculateHLT()
default destructor
double massTopQuark_
cache of top quark mass estimate
int j
Definition: DBlmapReader.cc:9
edm::EDGetTokenT< reco::JetIDValueMap > jetIDToken_
const int mu
Definition: Constants.h:22
StringCutObjectSelector< reco::JetID > * jetIDSelect_
selection string on the jetID
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
bool select(const edm::Event &event)
apply selection
double tmassWBoson(reco::RecoCandidate *mu, const reco::MET &met, const reco::Jet &b)
calculate W boson transverse mass estimate
StringCutObjectSelector< Object > select_
string cut selector
~SelectionStepHLT()
default destructor
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
double tmassWBoson_
cache of W boson transverse mass estimate
static const JetCorrector * getJetCorrector(const std::string &fName, const edm::EventSetup &fSetup)
retrieve corrector from the event setup. troughs exception if something is missing ...
Definition: JetCorrector.cc:50
double b
Definition: hdecay.h:120
int maxNJets_
max. number of jets to be considered
double btagWorkingPoint_
choice of b-tag working point as extra selection type
std::string jetCorrector_
jet corrector as extra selection type
double tmassTopQuark_
cache of top quark transverse mass estimate
static std::string const triggerPaths
Definition: EdmProvDump.cc:42
edm::EDGetTokenT< reco::JetTagCollection > btagToken_
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
edm::EDGetTokenT< edm::View< Object > > srcToken_