CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

SoftPFElectronProducer Class Reference

#include <SoftPFElectronProducer.h>

Inheritance diagram for SoftPFElectronProducer:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

 SoftPFElectronProducer (const edm::ParameterSet &conf)
 ~SoftPFElectronProducer ()

Private Member Functions

bool isClean (const reco::GsfElectron &gsfcandidate)
virtual void produce (edm::Event &iEvent, const edm::EventSetup &iSetup)

Private Attributes

std::vector< double > barreldRGsfTrackElectronCuts_
std::vector< double > barrelEemPinRatioCuts_
std::vector< double > barrelInversedRFirstLastHitCuts_
std::vector< double > barrelMVACuts_
std::vector< double > barrelPtCuts_
std::vector< double > barrelRadiusFirstHitCuts_
std::vector< double > barrelZFirstHitCuts_
std::vector< double > forwarddRGsfTrackElectronCuts_
std::vector< double > forwardInverseFBremCuts_
std::vector< double > forwardMVACuts_
std::vector< double > forwardPtCuts_
std::vector< double > forwardRadiusFirstHitCuts_
std::vector< double > forwardZFirstHitCuts_
edm::InputTag gsfElectronTag_

Detailed Description

Definition at line 17 of file SoftPFElectronProducer.h.


Constructor & Destructor Documentation

SoftPFElectronProducer::SoftPFElectronProducer ( const edm::ParameterSet conf)

Definition at line 14 of file SoftPFElectronProducer.cc.

References barreldRGsfTrackElectronCuts_, barrelEemPinRatioCuts_, barrelInversedRFirstLastHitCuts_, barrelMVACuts_, barrelPtCuts_, barrelRadiusFirstHitCuts_, barrelZFirstHitCuts_, forwarddRGsfTrackElectronCuts_, forwardInverseFBremCuts_, forwardMVACuts_, forwardPtCuts_, forwardRadiusFirstHitCuts_, forwardZFirstHitCuts_, edm::ParameterSet::getParameter(), and gsfElectronTag_.

{
    gsfElectronTag_ = conf.getParameter<edm::InputTag>("Electrons");

    barrelPtCuts_                    = conf.getParameter<std::vector<double> >("BarrelPtCuts");
    barreldRGsfTrackElectronCuts_    = conf.getParameter<std::vector<double> >("BarreldRGsfTrackElectronCuts");
    barrelEemPinRatioCuts_           = conf.getParameter<std::vector<double> >("BarrelEemPinRatioCuts");
    barrelMVACuts_                   = conf.getParameter<std::vector<double> >("BarrelMVACuts");
    barrelInversedRFirstLastHitCuts_ = conf.getParameter<std::vector<double> >("BarrelInversedRFirstLastHitCuts");
    barrelRadiusFirstHitCuts_        = conf.getParameter<std::vector<double> >("BarrelRadiusFirstHitCuts");
    barrelZFirstHitCuts_             = conf.getParameter<std::vector<double> >("BarrelZFirstHitCuts");

    forwardPtCuts_                   = conf.getParameter<std::vector<double> >("ForwardPtCuts");
    forwardInverseFBremCuts_         = conf.getParameter<std::vector<double> >("ForwardInverseFBremCuts");
    forwarddRGsfTrackElectronCuts_   = conf.getParameter<std::vector<double> >("ForwarddRGsfTrackElectronCuts");
    forwardRadiusFirstHitCuts_       = conf.getParameter<std::vector<double> >("ForwardRadiusFirstHitCuts");
    forwardZFirstHitCuts_            = conf.getParameter<std::vector<double> >("ForwardZFirstHitCuts");
    forwardMVACuts_                  = conf.getParameter<std::vector<double> >("ForwardMVACuts");

    produces<reco::GsfElectronCollection>();
}
SoftPFElectronProducer::~SoftPFElectronProducer ( )

Definition at line 36 of file SoftPFElectronProducer.cc.

{

}

Member Function Documentation

bool SoftPFElectronProducer::isClean ( const reco::GsfElectron gsfcandidate) [private]

Definition at line 62 of file SoftPFElectronProducer.cc.

References barreldRGsfTrackElectronCuts_, barrelEemPinRatioCuts_, barrelInversedRFirstLastHitCuts_, barrelMVACuts_, barrelPtCuts_, barrelRadiusFirstHitCuts_, barrelZFirstHitCuts_, deltaR(), reco::LeafCandidate::eta(), forwarddRGsfTrackElectronCuts_, forwardInverseFBremCuts_, forwardMVACuts_, forwardPtCuts_, forwardRadiusFirstHitCuts_, forwardZFirstHitCuts_, reco::GsfElectron::gsfTrack(), reco::GsfElectron::mva(), reco::LeafCandidate::phi(), reco::LeafCandidate::pt(), and reco::GsfElectron::superCluster().

Referenced by produce().

{
  const double ecalEnergy            = gsfcandidate.superCluster()->energy();
  const double pIn                   = gsfcandidate.gsfTrack()->innerMomentum().R();
  const double pOut                  = gsfcandidate.gsfTrack()->outerMomentum().R();
  const double EemPinRatio           = (ecalEnergy - pIn)/(ecalEnergy + pIn);
  //const double EemPoutRatio          = (ecalEnergy - pOut)/(ecalEnergy + pOut);
  const double pt                    = gsfcandidate.pt();
  const double fbrem                 = (pIn - pOut)/pIn;
  const double dRGsfTrackElectron    = deltaR(gsfcandidate.gsfTrack()->eta(), gsfcandidate.gsfTrack()->phi(), gsfcandidate.eta(), gsfcandidate.phi());
  const double mva                   = gsfcandidate.mva();
  const math::XYZPoint firstHit      = gsfcandidate.gsfTrack()->innerPosition();
  const math::XYZPoint lastHit       = gsfcandidate.gsfTrack()->outerPosition();
  const double inversedRFirstLastHit = 1.0/deltaR(firstHit.eta(), firstHit.phi(), lastHit.eta(), lastHit.phi());
  const double radiusFirstHit        = firstHit.Rho();
  const double zFirstHit             = firstHit.Z();
  /*std::cout << "This particle has " << pt << " "
                                    << 1.0/fbrem << " "
                                    << dRGsfTrackElectron << " "
                                    << EemPoutRatio << " "
                                    << mva << std::endl;*/
  if(fabs(gsfcandidate.eta()) < 1.5)
  {
    // use barrel cuts
    if( barrelPtCuts_.front()                    > pt                    || barrelPtCuts_.back()                    < pt)                    return false;
    if( barreldRGsfTrackElectronCuts_.front()    > dRGsfTrackElectron    || barreldRGsfTrackElectronCuts_.back()    < dRGsfTrackElectron)    return false;
    if( barrelEemPinRatioCuts_.front()           > EemPinRatio           || barrelEemPinRatioCuts_.back()           < EemPinRatio)           return false;
    if( barrelMVACuts_.front()                   > mva                   || barrelMVACuts_.back()                   < mva)                   return false;
    if( barrelInversedRFirstLastHitCuts_.front() > inversedRFirstLastHit || barrelInversedRFirstLastHitCuts_.back() < inversedRFirstLastHit) return false;
    if( barrelRadiusFirstHitCuts_.front()        > radiusFirstHit        || barrelRadiusFirstHitCuts_.back()        < radiusFirstHit)        return false;
    if( barrelZFirstHitCuts_.front()             > zFirstHit             || barrelZFirstHitCuts_.back()             < zFirstHit)             return false;
  }
  else
  {
    // use endcap cuts
    if( forwardPtCuts_.front()                 > pt                 || forwardPtCuts_.back()                 < pt)                 return false;
    if( forwardInverseFBremCuts_.front()       > 1.0/fbrem          || forwardInverseFBremCuts_.back()       < 1.0/fbrem)          return false;
    if( forwarddRGsfTrackElectronCuts_.front() > dRGsfTrackElectron || forwarddRGsfTrackElectronCuts_.back() < dRGsfTrackElectron) return false;
    if( forwardRadiusFirstHitCuts_.front()     > radiusFirstHit     || forwardRadiusFirstHitCuts_.back()     < radiusFirstHit)     return false;
    if( forwardZFirstHitCuts_.front()          > zFirstHit          || forwardZFirstHitCuts_.back()          < zFirstHit)          return false;
    if( forwardMVACuts_.front()                > mva                || forwardMVACuts_.back()                < mva)                return false;
  }

  return true;
}
void SoftPFElectronProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [private, virtual]

Implements edm::EDProducer.

Definition at line 41 of file SoftPFElectronProducer.cc.

References edm::Event::getByLabel(), gsfElectronTag_, i, isClean(), convertSQLitetoXML_cfg::output, edm::Handle< T >::product(), and edm::Event::put().

{
  std::auto_ptr<reco::GsfElectronCollection> output(new reco::GsfElectronCollection);

  edm::Handle<reco::GsfElectronCollection> gsfCandidates;
  iEvent.getByLabel(gsfElectronTag_, gsfCandidates);

  // this will throw if the input collection is not present
  const reco::GsfElectronCollection & gsfCollection = *(gsfCandidates.product());

  for (unsigned int i = 0 ; i != gsfCollection.size(); ++i)
  {
    if (not isClean(gsfCollection[i]))
      continue;

    output->push_back(gsfCollection[i]);
  }

  iEvent.put(output);
}

Member Data Documentation

Definition at line 33 of file SoftPFElectronProducer.h.

Referenced by isClean(), and SoftPFElectronProducer().

std::vector<double> SoftPFElectronProducer::barrelEemPinRatioCuts_ [private]

Definition at line 34 of file SoftPFElectronProducer.h.

Referenced by isClean(), and SoftPFElectronProducer().

Definition at line 36 of file SoftPFElectronProducer.h.

Referenced by isClean(), and SoftPFElectronProducer().

std::vector<double> SoftPFElectronProducer::barrelMVACuts_ [private]

Definition at line 35 of file SoftPFElectronProducer.h.

Referenced by isClean(), and SoftPFElectronProducer().

std::vector<double> SoftPFElectronProducer::barrelPtCuts_ [private]

Definition at line 32 of file SoftPFElectronProducer.h.

Referenced by isClean(), and SoftPFElectronProducer().

Definition at line 37 of file SoftPFElectronProducer.h.

Referenced by isClean(), and SoftPFElectronProducer().

std::vector<double> SoftPFElectronProducer::barrelZFirstHitCuts_ [private]

Definition at line 38 of file SoftPFElectronProducer.h.

Referenced by isClean(), and SoftPFElectronProducer().

Definition at line 42 of file SoftPFElectronProducer.h.

Referenced by isClean(), and SoftPFElectronProducer().

std::vector<double> SoftPFElectronProducer::forwardInverseFBremCuts_ [private]

Definition at line 41 of file SoftPFElectronProducer.h.

Referenced by isClean(), and SoftPFElectronProducer().

std::vector<double> SoftPFElectronProducer::forwardMVACuts_ [private]

Definition at line 45 of file SoftPFElectronProducer.h.

Referenced by isClean(), and SoftPFElectronProducer().

std::vector<double> SoftPFElectronProducer::forwardPtCuts_ [private]

Definition at line 40 of file SoftPFElectronProducer.h.

Referenced by isClean(), and SoftPFElectronProducer().

Definition at line 43 of file SoftPFElectronProducer.h.

Referenced by isClean(), and SoftPFElectronProducer().

std::vector<double> SoftPFElectronProducer::forwardZFirstHitCuts_ [private]

Definition at line 44 of file SoftPFElectronProducer.h.

Referenced by isClean(), and SoftPFElectronProducer().

Definition at line 30 of file SoftPFElectronProducer.h.

Referenced by produce(), and SoftPFElectronProducer().