CMS 3D CMS Logo

Public Member Functions | Private Attributes

pat::PATConversionProducer Class Reference

#include <PATConversionProducer.h>

Inheritance diagram for pat::PATConversionProducer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

 PATConversionProducer (const edm::ParameterSet &iConfig)
virtual void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 ~PATConversionProducer ()

Private Attributes

edm::InputTag electronSrc_

Detailed Description

Definition at line 38 of file PATConversionProducer.h.


Constructor & Destructor Documentation

PATConversionProducer::PATConversionProducer ( const edm::ParameterSet iConfig) [explicit]

Definition at line 47 of file PATConversionProducer.cc.

References edm::ParameterSet::getParameter().

                                                                           {

  // general configurables
  electronSrc_      = iConfig.getParameter<edm::InputTag>( "electronSource" );

  // produces vector of muons
  produces<std::vector<Conversion> >();

}
PATConversionProducer::~PATConversionProducer ( )

Definition at line 58 of file PATConversionProducer.cc.

                                              {
}

Member Function Documentation

void PATConversionProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [override, virtual]

Implements edm::EDProducer.

Definition at line 62 of file PATConversionProducer.cc.

References reco::Vertex::chi2(), conv, HI_PhotonSkim_cff::electrons, edm::Event::getByLabel(), getHLTprescales::index, ConversionTools::matchesConversion(), reco::Vertex::ndof(), jptDQMConfig_cff::nHitsMax, reco::BeamSpot::position(), edm::Handle< T >::product(), edm::Event::put(), pat::Conversion::setLxy(), pat::Conversion::setNHitsMax(), pat::Conversion::setVtxProb(), reco::Vertex::x(), and reco::Vertex::y().

                                                                                   {

  // Get the collection of electrons from the event
  edm::Handle<edm::View<reco::GsfElectron> > electrons;
  iEvent.getByLabel(electronSrc_, electrons);

  edm::Handle<reco::BeamSpot> bsHandle;
  iEvent.getByLabel("offlineBeamSpot", bsHandle);
  const reco::BeamSpot &beamspot = *bsHandle.product();

  // for conversion veto selection  
  edm::Handle<reco::ConversionCollection> hConversions;
  iEvent.getByLabel("allConversions", hConversions);

  std::vector<Conversion> * patConversions = new std::vector<Conversion>();

  for (reco::ConversionCollection::const_iterator conv = hConversions->begin(); conv!= hConversions->end(); ++conv) {

    reco::Vertex vtx = conv->conversionVertex();

    int index = 0; 
    for (edm::View<reco::GsfElectron>::const_iterator itElectron = electrons->begin(); itElectron != electrons->end(); ++itElectron) {

      //find matched conversions with electron and save those conversions with matched electron index
      if (ConversionTools::matchesConversion(*itElectron, *conv)) {

        double vtxProb = TMath::Prob( vtx.chi2(), vtx.ndof());
        math::XYZVector mom(conv->refittedPairMomentum());
        double dbsx = vtx.x() - beamspot.position().x();   
        double dbsy = vtx.y() - beamspot.position().y();
        double lxy = (mom.x()*dbsx + mom.y()*dbsy)/mom.rho();
        int nHitsMax = 0;

        for (std::vector<uint8_t>::const_iterator it = conv->nHitsBeforeVtx().begin(); it!=conv->nHitsBeforeVtx().end(); ++it) {
          if ((*it) > nHitsMax) nHitsMax = (*it);
        }

        pat::Conversion anConversion( index ); 
        anConversion.setVtxProb( vtxProb );
        anConversion.setLxy( lxy );
        anConversion.setNHitsMax(  nHitsMax );

        patConversions->push_back(anConversion);
        break;
      }
      index++;
    }
    
  }

  // add the electrons to the event output
  std::auto_ptr<std::vector<Conversion> > ptr(patConversions);
  iEvent.put(ptr);

}

Member Data Documentation

Definition at line 50 of file PATConversionProducer.h.