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 setTrkiso03 (pat::Muon &mu, const std::vector< reco::Track > tracks) 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 96 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(), setTrkiso03(), setTrkiso04(), trkSrc_, vertexSrc_, AlignmentTracksFromVertexSelector_cfi::vertices, and L1BJetProducer_cff::vtx.

96  {
98  iEvent.getByToken(muonSrc_, muonSrc);
99 
101  iEvent.getByToken(vertexSrc_, vertices);
102 
104  iEvent.getByToken(trkSrc_, trkCollection);
105 
106  std::unique_ptr<std::vector<pat::Muon>> muonCollection(new std::vector<pat::Muon>(*muonSrc));
107 
108  std::unique_ptr<std::vector<pat::Muon>> out(new std::vector<pat::Muon>());
109 
110  out->reserve(muonCollection->size());
111 
112  for (unsigned int i = 0; i < muonCollection->size(); i++) {
113  pat::Muon &mu = (*muonCollection).at(i);
115  int good_vertex = 0;
116  for (auto &vtx : *vertices) {
117  if (vtx.isFake() || !vtx.isValid())
118  continue;
120  good_vertex = 1;
121  break;
122  }
123  mu.addUserInt("isGoodVertex", good_vertex);
124  setTrkiso04(mu, *trkCollection);
125  setTrkiso03(mu, *trkCollection);
126  setNSegements(mu);
127  out->push_back(mu);
128  }
129 
130  iEvent.put(std::move(out));
131 }
void setTrkiso03(pat::Muon &mu, const std::vector< reco::Track > tracks) const
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 47 of file MuonSpecialVariables.cc.

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

Referenced by produce().

47  {
48  mu.addUserInt("isArbitratedTracker", muon::isGoodMuon(mu, muon::TrackerMuonArbitrated));
49 }
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 51 of file MuonSpecialVariables.cc.

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

Referenced by produce().

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

◆ setNSegements()

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

Definition at line 84 of file MuonSpecialVariables.cc.

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

Referenced by produce().

84  {
85  int nsegments = 0;
86  for (auto &chamber : mu.matches()) {
87  if (chamber.id.det() != DetId::Muon)
88  continue;
89  if (chamber.id.subdetId() != MuonSubdetId::DT && chamber.id.subdetId() != MuonSubdetId::CSC)
90  continue;
91  nsegments += chamber.segmentMatches.size();
92  }
93  mu.addUserInt("nsegments", nsegments);
94 }
static constexpr int DT
Definition: MuonSubdetId.h:11
static constexpr int CSC
Definition: MuonSubdetId.h:12

◆ setTrkiso03()

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

Definition at line 72 of file MuonSpecialVariables.cc.

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

Referenced by produce().

72  {
73  float energy = 0;
74  for (const auto &trk : tracks) {
75  if (deltaR(mu.eta(), mu.phi(), trk.eta(), trk.phi()) > 0.3)
76  continue;
77  energy += trk.pt();
78  }
79  float Trkiso03 = (energy - mu.pt());
80  float absTrkiso03 = (Trkiso03 > 0) ? Trkiso03 : 0;
81  mu.addUserFloat("absTrkiso03", absTrkiso03);
82 }

◆ setTrkiso04()

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

Definition at line 60 of file MuonSpecialVariables.cc.

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

Referenced by produce().

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

Member Data Documentation

◆ muonSrc_

edm::EDGetToken MuonSpecialVariables::muonSrc_
private

Definition at line 42 of file MuonSpecialVariables.cc.

Referenced by produce().

◆ trkSrc_

edm::EDGetToken MuonSpecialVariables::trkSrc_
private

Definition at line 44 of file MuonSpecialVariables.cc.

Referenced by produce().

◆ vertexSrc_

edm::EDGetToken MuonSpecialVariables::vertexSrc_
private

Definition at line 43 of file MuonSpecialVariables.cc.

Referenced by produce().