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
pat::PATConversionProducer Class Reference

#include <PATConversionProducer.h>

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

Public Member Functions

 PATConversionProducer (const edm::ParameterSet &iConfig)
 
virtual void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
 ~PATConversionProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
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 ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

edm::EDGetTokenT< reco::BeamSpotbsToken_
 
edm::EDGetTokenT
< reco::ConversionCollection
conversionsToken_
 
edm::EDGetTokenT< edm::View
< reco::GsfElectron > > 
electronToken_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- 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::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)
 

Detailed Description

Definition at line 37 of file PATConversionProducer.h.

Constructor & Destructor Documentation

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

Definition at line 46 of file PATConversionProducer.cc.

References edm::ParameterSet::getParameter().

46  {
47 
48  // general configurables
49  electronToken_ = consumes<edm::View<reco::GsfElectron> >(iConfig.getParameter<edm::InputTag>( "electronSource" ));
50  bsToken_ = consumes<reco::BeamSpot>(edm::InputTag("offlineBeamSpot"));
51  conversionsToken_ = consumes<reco::ConversionCollection>(edm::InputTag("allConversions"));
52 
53  // produces vector of muons
54  produces<std::vector<Conversion> >();
55 
56 }
T getParameter(std::string const &) const
edm::EDGetTokenT< edm::View< reco::GsfElectron > > electronToken_
edm::EDGetTokenT< reco::BeamSpot > bsToken_
edm::EDGetTokenT< reco::ConversionCollection > conversionsToken_
PATConversionProducer::~PATConversionProducer ( )

Definition at line 59 of file PATConversionProducer.cc.

59  {
60 }

Member Function Documentation

void PATConversionProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overridevirtual

Implements edm::EDProducer.

Definition at line 63 of file PATConversionProducer.cc.

References reco::Vertex::chi2(), conv, HI_PhotonSkim_cff::electrons, edm::Event::getByToken(), cmsHarvester::index, lxy(), ConversionTools::matchesConversion(), reco::Vertex::ndof(), 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().

63  {
64 
65  // Get the collection of electrons from the event
67  iEvent.getByToken(electronToken_, electrons);
68 
70  iEvent.getByToken(bsToken_, bsHandle);
71  const reco::BeamSpot &beamspot = *bsHandle.product();
72 
73  // for conversion veto selection
75  iEvent.getByToken(conversionsToken_, hConversions);
76 
77  std::vector<Conversion> * patConversions = new std::vector<Conversion>();
78 
79  for (reco::ConversionCollection::const_iterator conv = hConversions->begin(); conv!= hConversions->end(); ++conv) {
80 
81  reco::Vertex vtx = conv->conversionVertex();
82 
83  int index = 0;
84  for (edm::View<reco::GsfElectron>::const_iterator itElectron = electrons->begin(); itElectron != electrons->end(); ++itElectron) {
85 
86  //find matched conversions with electron and save those conversions with matched electron index
87  if (ConversionTools::matchesConversion(*itElectron, *conv)) {
88 
89  double vtxProb = TMath::Prob( vtx.chi2(), vtx.ndof());
90  math::XYZVector mom(conv->refittedPairMomentum());
91  double dbsx = vtx.x() - beamspot.position().x();
92  double dbsy = vtx.y() - beamspot.position().y();
93  double lxy = (mom.x()*dbsx + mom.y()*dbsy)/mom.rho();
94  int nHitsMax = 0;
95 
96  for (std::vector<uint8_t>::const_iterator it = conv->nHitsBeforeVtx().begin(); it!=conv->nHitsBeforeVtx().end(); ++it) {
97  if ((*it) > nHitsMax) nHitsMax = (*it);
98  }
99 
100  pat::Conversion anConversion( index );
101  anConversion.setVtxProb( vtxProb );
102  anConversion.setLxy( lxy );
103  anConversion.setNHitsMax( nHitsMax );
104 
105  patConversions->push_back(anConversion);
106  break;
107  }
108  index++;
109  }
110 
111  }
112 
113  // add the electrons to the event output
114  std::auto_ptr<std::vector<Conversion> > ptr(patConversions);
115  iEvent.put(ptr);
116 
117 }
double lxy(const math::XYZPoint &myBeamSpot, const Conversion &conv)
static bool matchesConversion(const reco::GsfElectron &ele, const reco::Conversion &conv, bool allowCkfMatch=true, bool allowAmbiguousGsfMatch=false)
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
edm::EDGetTokenT< edm::View< reco::GsfElectron > > electronToken_
static HepMC::IO_HEPEVT conv
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
double y() const
y coordinate
Definition: Vertex.h:110
edm::EDGetTokenT< reco::BeamSpot > bsToken_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
double chi2() const
chi-squares
Definition: Vertex.h:95
double ndof() const
Definition: Vertex.h:102
double x() const
x coordinate
Definition: Vertex.h:108
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
T const * product() const
Definition: Handle.h:81
const Point & position() const
position
Definition: BeamSpot.h:62
edm::EDGetTokenT< reco::ConversionCollection > conversionsToken_

Member Data Documentation

edm::EDGetTokenT<reco::BeamSpot> pat::PATConversionProducer::bsToken_
private

Definition at line 50 of file PATConversionProducer.h.

edm::EDGetTokenT<reco::ConversionCollection> pat::PATConversionProducer::conversionsToken_
private

Definition at line 51 of file PATConversionProducer.h.

edm::EDGetTokenT<edm::View<reco::GsfElectron> > pat::PATConversionProducer::electronToken_
private

Definition at line 49 of file PATConversionProducer.h.