CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TauDiscriminationAgainstMuon.cc
Go to the documentation of this file.
1 
2 /*
3  * class TauDiscriminationAgainstMuon
4  * created : July 09 2010
5  * revised :
6  * Authors : Sho Maruyama, Christian Veelken (UC Davis)
7  */
8 
10 
13 
16 
18 
19 #include <string>
20 
21 using namespace reco;
22 
23 template<class TauType, class TauDiscriminator>
24 class TauDiscriminationAgainstMuon : public TauDiscriminationProducerBase<TauType, TauDiscriminator>
25 {
26  public:
27  // setup framework types for this tautype
28  typedef std::vector<TauType> TauCollection;
30 
33 
34  // called at the beginning of every event
35  void beginEvent(const edm::Event&, const edm::EventSetup&);
36 
37  double discriminate(const TauRef&);
38 
39  private:
40  bool evaluateMuonVeto(const reco::Muon&);
41 
44  double dRmatch_;
45 
46  enum { kNoSegMatch, kTwoDCut, kMerePresence, kCombined };
48 
51  double muonCompCut_;
52 };
53 
54 template<class TauType, class TauDiscriminator>
56  : TauDiscriminationProducerBase<TauType, TauDiscriminator>(cfg)
57 {
58  //if ( cfg.exists("muonSource") ) muonSource_ = cfg.getParameter<edm::InputTag>("muonSource");
59  muonSource_ = cfg.getParameter<edm::InputTag>("muonSource");
60  dRmatch_ = ( cfg.exists("dRmatch") ) ? cfg.getParameter<double>("dRmatch") : 0.5;
61 
62  std::string discriminatorOption_string = cfg.getParameter<std::string>("discriminatorOption");
63  if ( discriminatorOption_string == "noSegMatch" ) discriminatorOption_ = kNoSegMatch;
64  else if ( discriminatorOption_string == "twoDCut" ) discriminatorOption_ = kTwoDCut;
65  else if ( discriminatorOption_string == "merePresence" ) discriminatorOption_ = kMerePresence;
66  else if ( discriminatorOption_string == "combined" ) discriminatorOption_ = kCombined;
67  else {
68  throw edm::Exception(edm::errors::UnimplementedFeature) << " Invalid Discriminator Option! Please check cfi file \n";
69  }
70 
71  coeffCaloComp_ = cfg.getParameter<double>("caloCompCoefficient");
72  coeffSegmComp_ = cfg.getParameter<double>("segmCompCoefficient");
73  muonCompCut_ = cfg.getParameter<double>("muonCompCut");
74 }
75 
76 template<class TauType, class TauDiscriminator>
78 {
79  evt.getByLabel(muonSource_, muons_);
80 }
81 
82 template<class TauType, class TauDiscriminator>
84 {
85  bool decision = true;
86 
87  if ( discriminatorOption_ == kNoSegMatch ) {
88  if ( muon.numberOfMatches() > 0 ) decision = false;
89  } else if ( discriminatorOption_ == kTwoDCut ) {
90  double segmComp = muon::segmentCompatibility(muon);
91  double caloComp = muon.caloCompatibility();
92  if ( (coeffCaloComp_*segmComp + coeffSegmComp_*caloComp) > muonCompCut_ ) decision = false;
93  } else if ( discriminatorOption_ == kMerePresence ) {
94  decision = false;
95  } else if ( discriminatorOption_ == kCombined ) { // testing purpose only
96  unsigned int muonType = 0;
97  if ( muon.isGlobalMuon() ) muonType = 1;
98  else if ( muon.isCaloMuon() ) muonType = 2;
99  else if ( muon.isTrackerMuon() ) muonType = 3;
100 
101  bool eta_veto = ( fabs(muon.eta()) > 2.3 || (fabs(muon.eta()) > 1.4 && fabs(muon.eta()) < 1.6) ) ? true : false;
102  bool phi_veto = ( muon.phi() < 0.1 && muon.phi() > -0.1 ) ? true : false;
103 
104  if ( muonType != 1 || muon.numberOfMatches() > 0 || eta_veto || phi_veto ) decision = false;
105  }
106 
107  return decision;
108 }
109 
110 template<class TauType, class TauDiscriminator>
112 {
113  bool decision = true;
114 
115  for ( reco::MuonCollection::const_iterator muon = muons_->begin();
116  muon != muons_->end(); ++muon ) {
117  if ( reco::deltaR(muon->p4(), tau->p4()) < dRmatch_ ) decision &= evaluateMuonVeto(*muon);
118  }
119 
120  return (decision ? 1. : 0.);
121 }
122 
124 
125 //typedef TauDiscriminationAgainstMuon<PFTau, PFTauDiscriminator> PFRecoTauDiscriminationAgainstMuon;
127 
128 //DEFINE_FWK_MODULE(PFRecoTauDiscriminationAgainstMuon);
T getParameter(std::string const &) const
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
bool isTrackerMuon() const
Definition: Muon.h:220
bool exists(std::string const &parameterName) const
checks if a parameter exists
bool isGlobalMuon() const
Definition: Muon.h:219
edm::Ref< TauCollection > TauRef
Definition: Tau.h:38
TauDiscriminationAgainstMuon< CaloTau, CaloTauDiscriminator > CaloRecoTauDiscriminationAgainstMuon
TauDiscriminationAgainstMuon(const edm::ParameterSet &)
bool isCaloMuon() const
Definition: Muon.h:222
virtual float phi() const GCC11_FINAL
momentum azimuthal angle
auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30
float segmentCompatibility(const reco::Muon &muon, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
edm::Handle< reco::MuonCollection > muons_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
int numberOfMatches(ArbitrationType type=SegmentAndTrackArbitration) const
get number of chambers with matched segments
Definition: Muon.cc:60
virtual float eta() const GCC11_FINAL
momentum pseudorapidity
void beginEvent(const edm::Event &, const edm::EventSetup &)
float caloCompatibility() const
Definition: Muon.h:151