CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
MuonSpecialVariables Class Reference
Inheritance diagram for MuonSpecialVariables:
edm::stream::EDProducer<>

Public Member Functions

 MuonSpecialVariables (const edm::ParameterSet &iConfig)
 
void setArbitratedTracker (pat::Muon &mu) const
 
void setInnerTrackDxyz (pat::Muon &mu, const reco::Vertex &vtx) const
 
void setNSegements (pat::Muon &mu) const
 
void setTrkiso04 (pat::Muon &mu, const std::vector< reco::Track > tracks) const
 
 ~MuonSpecialVariables () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Member Functions

void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 

Private Attributes

edm::EDGetToken muonSrc_
 
edm::EDGetToken trkSrc_
 
edm::EDGetToken vertexSrc_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 23 of file MuonSpecialVariables.cc.

Constructor & Destructor Documentation

◆ MuonSpecialVariables()

MuonSpecialVariables::MuonSpecialVariables ( const edm::ParameterSet iConfig)
inlineexplicit

Definition at line 25 of file MuonSpecialVariables.cc.

26  : muonSrc_(consumes<std::vector<pat::Muon>>(iConfig.getParameter<edm::InputTag>("muonSrc"))),
27  vertexSrc_(consumes<std::vector<reco::Vertex>>(iConfig.getParameter<edm::InputTag>("vertexSrc"))),
28  trkSrc_(consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("trkSrc"))) {
29  produces<std::vector<pat::Muon>>();
30  }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307

◆ ~MuonSpecialVariables()

MuonSpecialVariables::~MuonSpecialVariables ( )
inlineoverride

Definition at line 31 of file MuonSpecialVariables.cc.

31 {}

Member Function Documentation

◆ produce()

void MuonSpecialVariables::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 83 of file MuonSpecialVariables.cc.

References mps_fire::i, iEvent, eostools::move(), amptDefaultParameters_cff::mu, pdwgLeptonRecoSkim_cfi::muonCollection, B2GDQM_cfi::muonSrc, muonSrc_, MillePedeFileConverter_cfg::out, setArbitratedTracker(), setInnerTrackDxyz(), setNSegements(), setTrkiso04(), trkSrc_, vertexSrc_, AlignmentTracksFromVertexSelector_cfi::vertices, and L1BJetProducer_cff::vtx.

83  {
85  iEvent.getByToken(muonSrc_, muonSrc);
86 
88  iEvent.getByToken(vertexSrc_, vertices);
89 
91  iEvent.getByToken(trkSrc_, trkCollection);
92 
93  std::unique_ptr<std::vector<pat::Muon>> muonCollection(new std::vector<pat::Muon>(*muonSrc));
94 
95  std::unique_ptr<std::vector<pat::Muon>> out(new std::vector<pat::Muon>());
96 
97  out->reserve(muonCollection->size());
98 
99  for (unsigned int i = 0; i < muonCollection->size(); i++) {
100  pat::Muon &mu = (*muonCollection).at(i);
102  int good_vertex = 0;
103  for (auto &vtx : *vertices) {
104  if (vtx.isFake() || !vtx.isValid())
105  continue;
107  good_vertex = 1;
108  break;
109  }
110  mu.addUserInt("isGoodVertex", good_vertex);
111  setTrkiso04(mu, *trkCollection);
112  setNSegements(mu);
113  out->push_back(mu);
114  }
115 
116  iEvent.put(std::move(out));
117 }
void setInnerTrackDxyz(pat::Muon &mu, const reco::Vertex &vtx) const
int iEvent
Definition: GenABIO.cc:224
void setNSegements(pat::Muon &mu) const
void setArbitratedTracker(pat::Muon &mu) const
Analysis-level muon class.
Definition: Muon.h:51
def move(src, dest)
Definition: eostools.py:511
void setTrkiso04(pat::Muon &mu, const std::vector< reco::Track > tracks) const

◆ setArbitratedTracker()

void MuonSpecialVariables::setArbitratedTracker ( pat::Muon mu) const

Definition at line 46 of file MuonSpecialVariables.cc.

References muon::isGoodMuon(), amptDefaultParameters_cff::mu, and muon::TrackerMuonArbitrated.

Referenced by produce().

46  {
47  mu.addUserInt("isArbitratedTracker", muon::isGoodMuon(mu, muon::TrackerMuonArbitrated));
48 }
bool isGoodMuon(const reco::Muon &muon, SelectionType type, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
main GoodMuon wrapper call

◆ setInnerTrackDxyz()

void MuonSpecialVariables::setInnerTrackDxyz ( pat::Muon mu,
const reco::Vertex vtx 
) const

Definition at line 50 of file MuonSpecialVariables.cc.

References amptDefaultParameters_cff::mu, and L1BJetProducer_cff::vtx.

Referenced by produce().

50  {
51  float innerTrackDxy =
52  mu.innerTrack().isNonnull() ? mu.innerTrack()->dxy(reco::TrackBase::Point(vtx.x(), vtx.y(), vtx.z())) : -999.9;
53  float innerTrackDz =
54  mu.innerTrack().isNonnull() ? mu.innerTrack()->dz(reco::TrackBase::Point(vtx.x(), vtx.y(), vtx.z())) : -999.9;
55  mu.addUserFloat("innerTrackDxy", innerTrackDxy);
56  mu.addUserFloat("innerTrackDz", innerTrackDz);
57 }
math::XYZPoint Point
point in the space
Definition: TrackBase.h:80

◆ setNSegements()

void MuonSpecialVariables::setNSegements ( pat::Muon mu) const

Definition at line 71 of file MuonSpecialVariables.cc.

References relativeConstraints::chamber, MuonSubdetId::CSC, MuonSubdetId::DT, amptDefaultParameters_cff::mu, and DetId::Muon.

Referenced by produce().

71  {
72  int nsegments = 0;
73  for (auto &chamber : mu.matches()) {
74  if (chamber.id.det() != DetId::Muon)
75  continue;
76  if (chamber.id.subdetId() != MuonSubdetId::DT && chamber.id.subdetId() != MuonSubdetId::CSC)
77  continue;
78  nsegments += chamber.segmentMatches.size();
79  }
80  mu.addUserInt("nsegments", nsegments);
81 }
static constexpr int DT
Definition: MuonSubdetId.h:11
static constexpr int CSC
Definition: MuonSubdetId.h:12

◆ setTrkiso04()

void MuonSpecialVariables::setTrkiso04 ( pat::Muon mu,
const std::vector< reco::Track tracks 
) const

Definition at line 59 of file MuonSpecialVariables.cc.

References PbPb_ZMuSkimMuonDPG_cff::deltaR, hcalRecHitTable_cff::energy, amptDefaultParameters_cff::mu, and pwdgSkimBPark_cfi::tracks.

Referenced by produce().

59  {
60  float energy = 0;
61  for (const auto &trk : tracks) {
62  if (deltaR(mu.eta(), mu.phi(), trk.eta(), trk.phi()) > 0.4)
63  continue;
64  energy += trk.pt();
65  }
66  float Trkiso04 = (energy - mu.pt()) / mu.pt();
67  float relTrkiso4 = (Trkiso04 > 0) ? Trkiso04 : 0;
68  mu.addUserFloat("relTrkiso4", relTrkiso4);
69 }

Member Data Documentation

◆ muonSrc_

edm::EDGetToken MuonSpecialVariables::muonSrc_
private

Definition at line 41 of file MuonSpecialVariables.cc.

Referenced by produce().

◆ trkSrc_

edm::EDGetToken MuonSpecialVariables::trkSrc_
private

Definition at line 43 of file MuonSpecialVariables.cc.

Referenced by produce().

◆ vertexSrc_

edm::EDGetToken MuonSpecialVariables::vertexSrc_
private

Definition at line 42 of file MuonSpecialVariables.cc.

Referenced by produce().