CMS 3D CMS Logo

PATConversionProducer.cc
Go to the documentation of this file.
38 
39 #include <memory>
40 #include <string>
41 #include <vector>
42 
43 namespace pat {
44 
46  public:
47  explicit PATConversionProducer(const edm::ParameterSet &iConfig);
48  ~PATConversionProducer() override;
49 
50  void produce(edm::StreamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const override;
51 
52  private:
53  // configurables
57  };
58 
59 } // namespace pat
60 
61 using namespace pat;
62 using namespace std;
63 
65  : electronToken_(consumes<edm::View<reco::GsfElectron> >(iConfig.getParameter<edm::InputTag>("electronSource"))),
66  bsToken_(consumes<reco::BeamSpot>(edm::InputTag("offlineBeamSpot"))),
67  conversionsToken_(consumes<reco::ConversionCollection>(edm::InputTag("allConversions"))) {
68  // produces vector of muons
69  produces<std::vector<Conversion> >();
70 }
71 
73 
75  // Get the collection of electrons from the event
77  iEvent.getByToken(electronToken_, electrons);
78 
80  iEvent.getByToken(bsToken_, bsHandle);
81  const reco::BeamSpot &beamspot = *bsHandle.product();
82 
83  // for conversion veto selection
85  iEvent.getByToken(conversionsToken_, hConversions);
86 
87  std::vector<Conversion> *patConversions = new std::vector<Conversion>();
88 
89  for (reco::ConversionCollection::const_iterator conv = hConversions->begin(); conv != hConversions->end(); ++conv) {
90  reco::Vertex vtx = conv->conversionVertex();
91 
92  int index = 0;
93  for (edm::View<reco::GsfElectron>::const_iterator itElectron = electrons->begin(); itElectron != electrons->end();
94  ++itElectron) {
95  //find matched conversions with electron and save those conversions with matched electron index
96  if (ConversionTools::matchesConversion(*itElectron, *conv)) {
97  double vtxProb = TMath::Prob(vtx.chi2(), vtx.ndof());
98  math::XYZVector mom(conv->refittedPairMomentum());
99  double dbsx = vtx.x() - beamspot.position().x();
100  double dbsy = vtx.y() - beamspot.position().y();
101  double lxy = (mom.x() * dbsx + mom.y() * dbsy) / mom.rho();
102  int nHitsMax = 0;
103 
104  for (std::vector<uint8_t>::const_iterator it = conv->nHitsBeforeVtx().begin();
105  it != conv->nHitsBeforeVtx().end();
106  ++it) {
107  if ((*it) > nHitsMax)
108  nHitsMax = (*it);
109  }
110 
111  pat::Conversion anConversion(index);
112  anConversion.setVtxProb(vtxProb);
113  anConversion.setLxy(lxy);
114  anConversion.setNHitsMax(nHitsMax);
115 
116  patConversions->push_back(anConversion);
117  break;
118  }
119  index++;
120  }
121  }
122 
123  // add the electrons to the event output
124  std::unique_ptr<std::vector<Conversion> > ptr(patConversions);
125  iEvent.put(std::move(ptr));
126 }
127 
ConfigurationDescriptions.h
edm::StreamID
Definition: StreamID.h:30
MessageLogger.h
pat::PATConversionProducer::conversionsToken_
const edm::EDGetTokenT< reco::ConversionCollection > conversionsToken_
Definition: PATConversionProducer.cc:56
edm::Handle::product
T const * product() const
Definition: Handle.h:70
align::BeamSpot
Definition: StructureType.h:95
sistrip::View
View
Definition: ConstantsForView.h:26
pat::PATConversionProducer
Definition: PATConversionProducer.cc:45
PFCandidate.h
pat::ConversionCollection
std::vector< Conversion > ConversionCollection
Definition: Conversion.h:13
edm::EDGetTokenT
Definition: EDGetToken.h:33
pat::PATConversionProducer::bsToken_
const edm::EDGetTokenT< reco::BeamSpot > bsToken_
Definition: PATConversionProducer.cc:55
edm
HLT enums.
Definition: AlignableModifier.h:19
TrackerIsolationPt.h
pat::Conversion::setLxy
void setLxy(double lxy)
Definition: Conversion.cc:10
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
Conversion.h
PtComparator.h
EcalClusterLazyTools.h
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:46
TransientTrack.h
Association.h
edm::Handle
Definition: AssociativeIterator.h:50
MultiIsolator.h
EfficiencyLoader.h
GenParticle.h
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
BeamSpot.h
GenParticleFwd.h
reco::BeamSpot
Definition: BeamSpot.h:21
KinResolutionsLoader.h
beamspot
Definition: BeamSpotWrite2Txt.h:8
CaloIsolationEnergy.h
pat::Conversion
Definition: Conversion.h:21
pat::PATConversionProducer::produce
void produce(edm::StreamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const override
Definition: PATConversionProducer.cc:74
ParameterSetDescription.h
edm::global::EDProducer
Definition: EDProducer.h:32
FileInPath.h
pat::Conversion::setNHitsMax
void setNHitsMax(int nHitsMax)
Definition: Conversion.cc:12
TransientTrackBuilder.h
edm::ParameterSet
Definition: ParameterSet.h:47
CandAssociation.h
Event.h
UserData.h
ConversionTools::matchesConversion
static bool matchesConversion(const reco::GsfElectron &ele, const reco::Conversion &conv, bool allowCkfMatch=true, bool allowAmbiguousGsfMatch=false)
Definition: ConversionTools.cc:53
math::XYZVector
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
LorentzVector.h
iEvent
int iEvent
Definition: GenABIO.cc:224
GsfTrack.h
edm::EventSetup
Definition: EventSetup.h:58
pat
Definition: HeavyIon.h:7
TransientTrackRecord.h
InputTag.h
pat::PATConversionProducer::PATConversionProducer
PATConversionProducer(const edm::ParameterSet &iConfig)
Definition: PATConversionProducer.cc:64
ValueMap.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
IPTools.h
GsfTrackFwd.h
extraflags_cff.vtx
vtx
Definition: extraflags_cff.py:19
pwdgSkimBPark_cfi.electrons
electrons
Definition: pwdgSkimBPark_cfi.py:6
Vertex.h
PATUserDataHelper.h
Electron.h
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
edm::View::const_iterator
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
View.h
ParameterSet.h
EDProducer.h
edm::Event
Definition: Event.h:73
pat::PATConversionProducer::~PATConversionProducer
~PATConversionProducer() override
Definition: PATConversionProducer.cc:72
pat::PATConversionProducer::electronToken_
const edm::EDGetTokenT< edm::View< reco::GsfElectron > > electronToken_
Definition: PATConversionProducer.cc:54
pat::Conversion::setVtxProb
void setVtxProb(double vtxProb)
Definition: Conversion.cc:8
reco::Vertex
Definition: Vertex.h:35
PFCandidateFwd.h
ConversionTools.h
conv
EPOS::IO_EPOS conv
Definition: ReggeGribovPartonMCHadronizer.cc:42