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 <math>
12 /*Originally from DQM/Physics package, written by Roger Wolf and Jeremy Andrea*/
22 inline bool
23 acceptHLT(const edm::Event& event, const edm::TriggerResults& triggerTable, const std::string& triggerPath)
24 {
25  bool passed=false;
26  const edm::TriggerNames& triggerNames = event.triggerNames(triggerTable);
27  for(unsigned int i=0; i<triggerNames.triggerNames().size(); ++i){
28  if(triggerNames.triggerNames()[i] == triggerPath) {
29  if(triggerTable.accept(i)){
30  passed=true;
31  break;
32  }
33  }
34  }
35  return passed;
36 }
37 
38 inline bool
39 acceptHLT(const edm::Event& event, const edm::TriggerResults& triggerTable, const std::vector<std::string>& triggerPaths)
40 {
41  bool passed=false;
42  for(unsigned int j=0; j<triggerPaths.size(); ++j){
43  if(acceptHLT(event, triggerTable, triggerPaths[j])){
44  passed=true;
45  break;
46  }
47  }
48  return passed;
49 }
50 
51 
54 
67 class CalculateHLT {
68  public:
70  CalculateHLT(int maxNJets, double wMass);
73 
75  double massWBoson(const std::vector<reco::Jet>& jets);
77  double massTopQuark(const std::vector<reco::Jet>& jets);
79 /* double tmassWBoson(const T& mu, const reco::CaloMET& met, const reco::Jet& b);
81  double tmassTopQuark(const T& mu, const reco::CaloMET& met, const reco::Jet& b);
83  double masslb(const T& mu, const reco::CaloMET& met, const reco::Jet& b);*/
84 
86  double tmassWBoson(reco::RecoCandidate* mu, const reco::MET& met, const reco::Jet& b);
88  double tmassTopQuark(reco::RecoCandidate* mu, const reco::MET& met, const reco::Jet& b);
90  double masslb(reco::RecoCandidate* mu, const reco::MET& met, const reco::Jet& b);
91 
92  private:
96  void operator()(const std::vector<reco::Jet>& jets);
97  void operator()(const reco::Jet& bJet, reco::RecoCandidate* lepton, const reco::MET& met);
98  private:
100  bool failed_;
104  double wMass_;
106  double massWBoson_;
110  double tmassWBoson_;
114  double mlb_;
115 
116 
117 };
118 
119 
131 
172 template <typename Object>
174 public:
179 
181  bool select(const edm::Event& event);
183  bool select(const edm::Event& event, const edm::EventSetup& setup);
184  bool selectVertex(const edm::Event& event);
185 private:
189  int min_, max_;
204  std::string jetCorrector_;
211 
213 
218 };
219 
221 template <typename Object>
223  src_( cfg.getParameter<edm::InputTag>( "src" )),
224  select_( cfg.getParameter<std::string>("select")),
225  jetIDSelect_(0)
226 {
227  // construct min/max if the corresponding params
228  // exist otherwise they are initialized with -1
229  cfg.exists("min") ? min_= cfg.getParameter<int>("min") : min_= -1;
230  cfg.exists("max") ? max_= cfg.getParameter<int>("max") : max_= -1;
231  // read electron extras if they exist
232  if(cfg.existsAs<edm::ParameterSet>("electronId")){
233  edm::ParameterSet elecId=cfg.getParameter<edm::ParameterSet>("electronId");
234  electronId_= elecId.getParameter<edm::InputTag>("src");
235  eidPattern_= elecId.getParameter<int>("pattern");
236  }
237  // read jet corrector label if it exists
238  if(cfg.exists("jetCorrector")){ jetCorrector_= cfg.getParameter<std::string>("jetCorrector"); }
239  // read btag information if it exists
240  if(cfg.existsAs<edm::ParameterSet>("jetBTagger")){
241  edm::ParameterSet jetBTagger=cfg.getParameter<edm::ParameterSet>("jetBTagger");
242  btagLabel_=jetBTagger.getParameter<edm::InputTag>("label");
243  btagWorkingPoint_=jetBTagger.getParameter<double>("workingPoint");
244  }
245  // read jetID information if it exists
246  if(cfg.existsAs<edm::ParameterSet>("jetID")){
248  jetIDLabel_ =jetID.getParameter<edm::InputTag>("label");
249  jetIDSelect_= new StringCutObjectSelector<reco::JetID>(jetID.getParameter<std::string>("select"));
250  }
251 }
252 
254 template <typename Object>
256 {
257  // fetch input collection
259  if( !event.getByLabel(src_, src) ) return false;
260 
261  // load electronId value map if configured such
263  if(!electronId_.label().empty()) {
264  if( !event.getByLabel(electronId_, electronId) ) return false;
265  }
266 
267  // determine multiplicity of selected objects
268  int n=0;
269  for(typename edm::View<Object>::const_iterator obj=src->begin(); obj!=src->end(); ++obj){
270  // special treatment for electrons
271  if(dynamic_cast<const reco::GsfElectron*>(&*obj)){
272  unsigned int idx = obj-src->begin();
273  if( electronId_.label().empty() ? true : ((int)(*electronId)[src->refAt(idx)] & eidPattern_) ){
274  if(select_(*obj))++n;
275  }
276  }
277  // normal treatment
278  else{
279  if(select_(*obj))++n;
280  }
281  }
282  bool accept=(min_>=0 ? n>=min_:true) && (max_>=0 ? n<=max_:true);
283  return (min_<0 && max_<0) ? (n>0):accept;
284 }
285 template <typename Object>
287 {
288  // fetch input collection
290  if( !event.getByLabel(src_, src) ) return false;
291 
292  // load electronId value map if configured such
294  if(!electronId_.label().empty()) {
295  if( !event.getByLabel(electronId_, electronId) ) return false;
296  }
297 
298  // determine multiplicity of selected objects
299  int n=0;
300  for(typename edm::View<Object>::const_iterator obj=src->begin(); obj!=src->end(); ++obj){
301 
302  if(select_(*obj))++n;
303  }
304  bool accept=(min_>=0 ? n>=min_:true) && (max_>=0 ? n<=max_:true);
305  return (min_<0 && max_<0) ? (n>0):accept;
306 }
307 
309 template <typename Object>
311 {
312  // fetch input collection
314  if( !event.getByLabel(src_, src) ) return false;
315 
316  // load btag collection if configured such
317  // NOTE that the JetTagCollection needs an
318  // edm::View to reco::Jets; we have to add
319  // another Handle bjets for this purpose
323  if(!btagLabel_.label().empty()){
324  if( !event.getByLabel(src_, bjets) ) return false;
325  if( !event.getByLabel(btagLabel_, btagger) ) return false;
326  if( !event.getByLabel(pvs_, pvertex) ) return false;
327  }
328 
329  // load jetID value map if configured such
331  if(jetIDSelect_){
332  if( !event.getByLabel(jetIDLabel_, jetID) ) return false;
333 
334  }
335 
336  // load jet corrector if configured such
337  const JetCorrector* corrector=0;
338  if(!jetCorrector_.empty()){
339  // check whether a jet correcto is in the event setup or not
340  if(setup.find( edm::eventsetup::EventSetupRecordKey::makeKey<JetCorrectionsRecord>() )){
341  corrector = JetCorrector::getJetCorrector(jetCorrector_, setup);
342  }
343  else{
344  edm::LogVerbatim( "TopDQMHelpers" )
345  << "\n"
346  << "------------------------------------------------------------------------------------- \n"
347  << " No JetCorrectionsRecord available from EventSetup: \n"
348  << " - Jets will not be corrected. \n"
349  << " - If you want to change this add the following lines to your cfg file \n"
350  << " \n"
351  << " ## load jet corrections \n"
352  << " process.load(\"JetMETCorrections.Configuration.JetCorrectionServicesAllAlgos_cff\") \n"
353  << " process.prefer(\"ak5CaloL2L3\") \n"
354  << " \n"
355  << "------------------------------------------------------------------------------------- \n";
356  }
357  }
358  // determine multiplicity of selected objects
359  int n=0;
360  for(typename edm::View<Object>::const_iterator obj=src->begin(); obj!=src->end(); ++obj){
361  // check for chosen btag discriminator to be above the
362  // corresponding working point if configured such
363  unsigned int idx = obj-src->begin();
364  if( btagLabel_.label().empty() ? true : (*btagger)[bjets->refAt(idx)]>btagWorkingPoint_ ){
365  bool passedJetID=true;
366  // check jetID for calo jets
367  if( jetIDSelect_ && dynamic_cast<const reco::CaloJet*>(src->refAt(idx).get())){
368  passedJetID=(*jetIDSelect_)((*jetID)[src->refAt(idx)]);
369  }
370  if(passedJetID){
371  // scale jet energy if configured such
372  Object jet=*obj; jet.scaleEnergy(corrector ? corrector->correction(*obj) : 1.);
373  if(select_(jet))++n;
374  }
375  }
376  }
377  bool accept=(min_>=0 ? n>=min_:true) && (max_>=0 ? n<=max_:true);
378  return (min_<0 && max_<0) ? (n>0):accept;
379 }
380 
381 #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
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:187
bool acceptHLT(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
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)
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:21
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:22
Strings const & triggerNames() const
Definition: TriggerNames.cc:24
const eventsetup::EventSetupRecord * find(const eventsetup::EventSetupRecordKey &) const
Definition: EventSetup.cc:90
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
const int mu
Definition: Constants.h:23
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 getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
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
SelectionStepHLT(const edm::ParameterSet &cfg)
default constructor
StringCutObjectSelector< Object > select_
string cut selector
~SelectionStepHLT()
default destructor
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:51
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
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")