CMS 3D CMS Logo

L3MuonCandidateProducerFromMuons.cc
Go to the documentation of this file.
1 
8 // Framework
14 
16 
17 // Input and output collections
20 
23 
24 #include <string>
25 
26 using namespace edm;
27 using namespace std;
28 using namespace reco;
29 
30 static const std::string category("Muon|RecoMuon|L3MuonCandidateProducerFromMuons");
31 
34  : m_L3CollectionLabel(parameterSet.getParameter<InputTag>("InputObjects")) // standAlone Collection Label
35 {
36  muonToken_ = consumes<reco::MuonCollection>(m_L3CollectionLabel);
37  LogTrace(category) << " constructor called";
38  produces<RecoChargedCandidateCollection>();
39 }
40 
43  LogTrace(category) << " L3MuonCandidateProducerFromMuons destructor called";
44 }
45 
48  // Create a RecoChargedCandidate collection
49  LogTrace(category) << " Creating the RecoChargedCandidate collection";
50  auto candidates = std::make_unique<RecoChargedCandidateCollection>();
51 
52  // Take the L3 container
53  LogTrace(category) << " Taking the L3/GLB muons: " << m_L3CollectionLabel.label();
55  event.getByToken(muonToken_, muons);
56 
57  if (not muons.isValid()) {
58  LogError(category) << muons.whyFailed()->what();
59  } else {
60  for (unsigned int i = 0; i < muons->size(); i++) {
61  // avoids crashing in case the muon is SA only.
62  TrackRef tkref = ((*muons)[i].innerTrack().isNonnull()) ? (*muons)[i].innerTrack() : (*muons)[i].muonBestTrack();
63 
64  Particle::Charge q = tkref->charge();
65  Particle::LorentzVector p4(tkref->px(), tkref->py(), tkref->pz(), tkref->p());
66  Particle::Point vtx(tkref->vx(), tkref->vy(), tkref->vz());
67 
68  int pid = 13;
69  if (abs(q) == 1)
70  pid = q < 0 ? 13 : -13;
71  else
72  LogWarning(category) << "L3MuonCandidate has charge = " << q;
74 
75  cand.setTrack(tkref);
76  candidates->push_back(cand);
77  }
78  }
79  event.put(std::move(candidates));
80 }
L3MuonCandidateProducerFromMuons::~L3MuonCandidateProducerFromMuons
~L3MuonCandidateProducerFromMuons() override
destructor
Definition: L3MuonCandidateProducerFromMuons.cc:42
edm::StreamID
Definition: StreamID.h:30
PDWG_BPHSkim_cff.muons
muons
Definition: PDWG_BPHSkim_cff.py:47
Handle.h
mps_fire.i
i
Definition: mps_fire.py:355
MessageLogger.h
edm
HLT enums.
Definition: AlignableModifier.h:19
data-class-funcs.q
q
Definition: data-class-funcs.py:169
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
edm::Handle< reco::MuonCollection >
edm::Ref< TrackCollection >
L3MuonCandidateProducerFromMuons.h
edm::InputTag::label
std::string const & label() const
Definition: InputTag.h:36
Point
math::XYZPoint Point
Definition: TrackerDpgAnalysis.cc:107
category
static const std::string category("Muon|RecoMuon|L3MuonCandidateProducerFromMuons")
Track.h
TrackFwd.h
badGlobalMuonTaggersAOD_cff.vtx
vtx
Definition: badGlobalMuonTaggersAOD_cff.py:5
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::LogWarning
Definition: MessageLogger.h:141
L3MuonCandidateProducerFromMuons::L3MuonCandidateProducerFromMuons
L3MuonCandidateProducerFromMuons(const edm::ParameterSet &)
constructor with config
Definition: L3MuonCandidateProducerFromMuons.cc:33
edm::ParameterSet
Definition: ParameterSet.h:36
edm::LogError
Definition: MessageLogger.h:183
Event.h
cand
Definition: decayParser.h:34
p4
double p4[4]
Definition: TauolaWrapper.h:92
reco::RecoChargedCandidate
Definition: RecoChargedCandidate.h:15
edm::EventSetup
Definition: EventSetup.h:57
reco::JetExtendedAssociation::LorentzVector
math::PtEtaPhiELorentzVectorF LorentzVector
Definition: JetExtendedAssociation.h:25
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
RecoChargedCandidate.h
L3MuonCandidateProducerFromMuons::produce
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
produce candidates
Definition: L3MuonCandidateProducerFromMuons.cc:47
HLT_2018_cff.candidates
candidates
Definition: HLT_2018_cff.py:53513
edm::parameterSet
ParameterSet const & parameterSet(Provenance const &provenance, ProcessHistory const &history)
Definition: Provenance.cc:11
PixelTestBeamValidation_cfi.Charge
Charge
Definition: PixelTestBeamValidation_cfi.py:78
L3MuonCandidateProducerFromMuons::muonToken_
edm::EDGetTokenT< reco::MuonCollection > muonToken_
Definition: L3MuonCandidateProducerFromMuons.h:38
EventSetup.h
L3MuonCandidateProducerFromMuons::m_L3CollectionLabel
edm::InputTag m_L3CollectionLabel
Definition: L3MuonCandidateProducerFromMuons.h:37
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
ParameterSet.h
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
RecoChargedCandidateFwd.h
edm::InputTag
Definition: InputTag.h:15