CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
PFRecoTauDiscriminationByMVAIsolation Class Reference
Inheritance diagram for PFRecoTauDiscriminationByMVAIsolation:
TauDiscriminationProducerBase< TauType, TauDiscriminator > edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

void beginEvent (const edm::Event &evt, const edm::EventSetup &evtSetup)
 
reco::tau::cone::IsoRings computeIsoRings (const PFTauRef &pfTau)
 
double discriminate (const PFTauRef &pfTau)
 
 PFRecoTauDiscriminationByMVAIsolation (const edm::ParameterSet &iConfig)
 
 ~PFRecoTauDiscriminationByMVAIsolation ()
 
- Public Member Functions inherited from TauDiscriminationProducerBase< TauType, TauDiscriminator >
virtual double discriminate (const TauRef &tau)=0
 
virtual void endEvent (edm::Event &evt)
 
void produce (edm::Event &, const edm::EventSetup &)
 
 TauDiscriminationProducerBase (const edm::ParameterSet &iConfig)
 
 TauDiscriminationProducerBase ()
 
virtual ~TauDiscriminationProducerBase ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

edm::FileInPath gbrfFilePath_
 
GBRForestgbrfTauIso_
 
double mvaMin_
 
bool returnMVA_
 
double rho_
 
edm::InputTag rhoProducer_
 

Additional Inherited Members

- Public Types inherited from TauDiscriminationProducerBase< TauType, TauDiscriminator >
typedef std::vector< TauType > TauCollection
 
typedef edm::Ref< TauCollectionTauRef
 
typedef edm::RefProd
< TauCollection
TauRefProd
 
- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
- Protected Attributes inherited from TauDiscriminationProducerBase< TauType, TauDiscriminator >
std::string moduleLabel_
 
double prediscriminantFailValue_
 
edm::InputTag TauProducer_
 

Detailed Description

Definition at line 49 of file PFRecoTauDiscriminationByMVAIsolation.cc.

Constructor & Destructor Documentation

PFRecoTauDiscriminationByMVAIsolation::PFRecoTauDiscriminationByMVAIsolation ( const edm::ParameterSet iConfig)
inlineexplicit

Definition at line 52 of file PFRecoTauDiscriminationByMVAIsolation.cc.

52  :
54  rhoProducer_(iConfig.getParameter<edm::InputTag>("rhoProducer")),
55  gbrfFilePath_(iConfig.getParameter<edm::FileInPath>("gbrfFilePath")),
56  returnMVA_(iConfig.getParameter<bool>("returnMVA")),
57  mvaMin_(iConfig.getParameter<double>("mvaMin")),
58  rho_(0)
59  {
60  // Prediscriminant fail value
61  if(returnMVA_)
63  else
65 
66  // Read GBRForest
67  TFile *gbrfFile = new TFile(gbrfFilePath_.fullPath().data());
68  gbrfTauIso_ = (GBRForest *)(gbrfFile->Get("gbrfTauIso"));
69  }
T getParameter(std::string const &) const
TauDiscriminationProducerBase< reco::PFTau, reco::PFTauDiscriminator > PFTauDiscriminationProducerBase
std::string fullPath() const
Definition: FileInPath.cc:171
PFRecoTauDiscriminationByMVAIsolation::~PFRecoTauDiscriminationByMVAIsolation ( )
inline

Definition at line 71 of file PFRecoTauDiscriminationByMVAIsolation.cc.

71 {}

Member Function Documentation

void PFRecoTauDiscriminationByMVAIsolation::beginEvent ( const edm::Event evt,
const edm::EventSetup evtSetup 
)
virtual
reco::tau::cone::IsoRings PFRecoTauDiscriminationByMVAIsolation::computeIsoRings ( const PFTauRef pfTau)

Definition at line 105 of file PFRecoTauDiscriminationByMVAIsolation.cc.

References reco::deltaPhi(), reco::deltaR(), i, j, reco::tau::cone::IsoRings::niso, reco::tau::cone::IsoRings::rings, and reco::tau::cone::IsoRings::shapes.

106 {
107  vector<int> niso(3);
108  vector<vector<float> > rings(3, vector<float>(5));
109  vector<vector<float> > shapes(3, vector<float>(5));
110  vector<float> isoptsum(3);
111 
112  for(unsigned int i = 0; i < pfTau->isolationPFCands().size(); i++)
113  {
114  const PFCandidateRef pf = pfTau->isolationPFCands().at(i);
115 
116  // Angular distance between PF candidate and tau
117  float deta = pfTau->eta() - pf->eta();
118  float dphi = reco::deltaPhi(pfTau->phi(), pf->phi());
119  float dr = reco::deltaR(pfTau->eta(), pfTau->phi(), pf->eta(), pf->phi());
120  int pftype = 0;
121 
122  // Determine PF candidate type
123  if(pf->charge() != 0) pftype = 0;
124  else if(pf->particleId() == PFCandidate::gamma) pftype = 1;
125  else pftype = 2;
126 
127  // Number of isolation candidates by type
128  niso[pftype]++;
129 
130  // Isolation Rings
131  if(dr < 0.1) rings[pftype][0] += pf->pt();
132  else if(dr < 0.2) rings[pftype][1] += pf->pt();
133  else if(dr < 0.3) rings[pftype][2] += pf->pt();
134  else if(dr < 0.4) rings[pftype][3] += pf->pt();
135  else if(dr < 0.5) rings[pftype][4] += pf->pt();
136 
137  // Angle Shape Variables
138  shapes[pftype][0] += pf->pt() * deta;
139  shapes[pftype][1] += pf->pt() * dphi;
140  shapes[pftype][2] += pf->pt() * deta*deta;
141  shapes[pftype][3] += pf->pt() * dphi*dphi;
142  shapes[pftype][4] += pf->pt() * deta*dphi;
143  isoptsum[pftype] += pf->pt();
144  }
145 
146  // Mean and variance of angle variables are weighted by pT
147  for(unsigned int i = 0; i < shapes.size(); i++)
148  {
149  for(unsigned int j = 0; j < shapes[i].size(); j++)
150  {
151  shapes[i][j] = isoptsum[i] > 0 ? fabs(shapes[i][j]/isoptsum[i]) : 0;
152  }
153  }
154 
155  // Fill IsoRing object
156  reco::tau::cone::IsoRings isoRings;
157  isoRings.niso = niso;
158  isoRings.rings = rings;
159  isoRings.shapes = shapes;
160 
161  return isoRings;
162 }
int i
Definition: DBlmapReader.cc:9
int j
Definition: DBlmapReader.cc:9
auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30
double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:12
double PFRecoTauDiscriminationByMVAIsolation::discriminate ( const PFTauRef pfTau)

Definition at line 95 of file PFRecoTauDiscriminationByMVAIsolation.cc.

References reco::tau::cone::IsoRings::getVector().

96 {
97  reco::tau::cone::IsoRings isoRings = computeIsoRings(thePFTauRef);
98  vector<float> mvainput = isoRings.getVector();
99  mvainput.push_back(rho_);
100  double mvaValue = gbrfTauIso_->GetClassifier(&mvainput[0]);
101 
102  return returnMVA_ ? mvaValue : mvaValue > mvaMin_;
103 }
reco::tau::cone::IsoRings computeIsoRings(const PFTauRef &pfTau)
double GetClassifier(const float *vector) const
Definition: GBRForest.h:60

Member Data Documentation

edm::FileInPath PFRecoTauDiscriminationByMVAIsolation::gbrfFilePath_
private

Definition at line 79 of file PFRecoTauDiscriminationByMVAIsolation.cc.

GBRForest* PFRecoTauDiscriminationByMVAIsolation::gbrfTauIso_
private

Definition at line 80 of file PFRecoTauDiscriminationByMVAIsolation.cc.

double PFRecoTauDiscriminationByMVAIsolation::mvaMin_
private

Definition at line 82 of file PFRecoTauDiscriminationByMVAIsolation.cc.

bool PFRecoTauDiscriminationByMVAIsolation::returnMVA_
private

Definition at line 81 of file PFRecoTauDiscriminationByMVAIsolation.cc.

double PFRecoTauDiscriminationByMVAIsolation::rho_
private

Definition at line 83 of file PFRecoTauDiscriminationByMVAIsolation.cc.

edm::InputTag PFRecoTauDiscriminationByMVAIsolation::rhoProducer_
private

Definition at line 78 of file PFRecoTauDiscriminationByMVAIsolation.cc.