CMS 3D CMS Logo

Public Member Functions | Private Attributes

PFRecoTauDiscriminationByMVAIsolation Class Reference

Inheritance diagram for PFRecoTauDiscriminationByMVAIsolation:
TauDiscriminationProducerBase< TauType, TauDiscriminator > edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

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 ()

Private Attributes

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

Detailed Description

Definition at line 49 of file PFRecoTauDiscriminationByMVAIsolation.cc.


Constructor & Destructor Documentation

PFRecoTauDiscriminationByMVAIsolation::PFRecoTauDiscriminationByMVAIsolation ( const edm::ParameterSet iConfig) [inline, explicit]

Definition at line 52 of file PFRecoTauDiscriminationByMVAIsolation.cc.

                                                                                 : 
    PFTauDiscriminationProducerBase(iConfig),
    rhoProducer_(iConfig.getParameter<edm::InputTag>("rhoProducer")),
    gbrfFilePath_(iConfig.getParameter<edm::FileInPath>("gbrfFilePath")),
    returnMVA_(iConfig.getParameter<bool>("returnMVA")),
    mvaMin_(iConfig.getParameter<double>("mvaMin")),
    rho_(0)
  {
    // Prediscriminant fail value
    if(returnMVA_)
      prediscriminantFailValue_ = -1;
    else
      prediscriminantFailValue_ = 0;

    // Read GBRForest
    TFile *gbrfFile = new TFile(gbrfFilePath_.fullPath().data());
    gbrfTauIso_ = (GBRForest *)(gbrfFile->Get("gbrfTauIso"));
  }
PFRecoTauDiscriminationByMVAIsolation::~PFRecoTauDiscriminationByMVAIsolation ( ) [inline]

Definition at line 71 of file PFRecoTauDiscriminationByMVAIsolation.cc.

{} 

Member Function Documentation

void PFRecoTauDiscriminationByMVAIsolation::beginEvent ( const edm::Event evt,
const edm::EventSetup evtSetup 
) [virtual]

Reimplemented from TauDiscriminationProducerBase< TauType, TauDiscriminator >.

Definition at line 86 of file PFRecoTauDiscriminationByMVAIsolation.cc.

{
  // Get rho of event
  edm::Handle<double> hRho;
  event.getByLabel(rhoProducer_, hRho);
  rho_ = *hRho;
}
reco::tau::cone::IsoRings PFRecoTauDiscriminationByMVAIsolation::computeIsoRings ( const PFTauRef pfTau)

Definition at line 105 of file PFRecoTauDiscriminationByMVAIsolation.cc.

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

{
  vector<int>            niso(3);
  vector<vector<float> > rings(3, vector<float>(5));
  vector<vector<float> > shapes(3, vector<float>(5));
  vector<float>          isoptsum(3);

  for(unsigned int i = 0; i < pfTau->isolationPFCands().size(); i++)
  {
    const PFCandidateRef pf = pfTau->isolationPFCands().at(i);

    // Angular distance between PF candidate and tau
    float deta = pfTau->eta() - pf->eta();
    float dphi = reco::deltaPhi(pfTau->phi(), pf->phi());
    float dr = reco::deltaR(pfTau->eta(), pfTau->phi(), pf->eta(), pf->phi());
    int pftype = 0;

    // Determine PF candidate type
    if(pf->charge() != 0)                           pftype = 0;
    else if(pf->particleId() == PFCandidate::gamma) pftype = 1;
    else                                            pftype = 2;

    // Number of isolation candidates by type
    niso[pftype]++;

    // Isolation Rings
    if(dr < 0.1)      rings[pftype][0] += pf->pt();
    else if(dr < 0.2) rings[pftype][1] += pf->pt();
    else if(dr < 0.3) rings[pftype][2] += pf->pt();
    else if(dr < 0.4) rings[pftype][3] += pf->pt();
    else if(dr < 0.5) rings[pftype][4] += pf->pt();

    // Angle Shape Variables
    shapes[pftype][0] += pf->pt() * deta;
    shapes[pftype][1] += pf->pt() * dphi;
    shapes[pftype][2] += pf->pt() * deta*deta;
    shapes[pftype][3] += pf->pt() * dphi*dphi;
    shapes[pftype][4] += pf->pt() * deta*dphi;
    isoptsum[pftype]  += pf->pt();
  }

  // Mean and variance of angle variables are weighted by pT
  for(unsigned int i = 0; i < shapes.size(); i++)
  {
    for(unsigned int j = 0; j < shapes[i].size(); j++)
    {
      shapes[i][j] = isoptsum[i] > 0 ? fabs(shapes[i][j]/isoptsum[i]) : 0;
    }
  }

  // Fill IsoRing object
  reco::tau::cone::IsoRings isoRings;
  isoRings.niso = niso;
  isoRings.rings = rings;
  isoRings.shapes = shapes;

  return isoRings;
}
double PFRecoTauDiscriminationByMVAIsolation::discriminate ( const PFTauRef pfTau)

Definition at line 95 of file PFRecoTauDiscriminationByMVAIsolation.cc.

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

{
  reco::tau::cone::IsoRings isoRings = computeIsoRings(thePFTauRef);
  vector<float> mvainput = isoRings.getVector();
  mvainput.push_back(rho_);
  double mvaValue = gbrfTauIso_->GetClassifier(&mvainput[0]);

  return returnMVA_ ? mvaValue : mvaValue > mvaMin_;
}

Member Data Documentation

Definition at line 79 of file PFRecoTauDiscriminationByMVAIsolation.cc.

Definition at line 80 of file PFRecoTauDiscriminationByMVAIsolation.cc.

Definition at line 82 of file PFRecoTauDiscriminationByMVAIsolation.cc.

Definition at line 81 of file PFRecoTauDiscriminationByMVAIsolation.cc.

Definition at line 83 of file PFRecoTauDiscriminationByMVAIsolation.cc.

Definition at line 78 of file PFRecoTauDiscriminationByMVAIsolation.cc.