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 
25 #include <string>
26 
27 using namespace edm;
28 using namespace std;
29 using namespace reco;
30 
31 static const std::string category("Muon|RecoMuon|L3MuonCandidateProducerFromMuons");
32 
35  m_L3CollectionLabel( parameterSet.getParameter<InputTag>("InputObjects") ) // standAlone Collection Label
36 {
37  muonToken_ = consumes<reco::MuonCollection>(m_L3CollectionLabel);
38  LogTrace(category)<<" constructor called";
39  produces<RecoChargedCandidateCollection>();
40 }
41 
44  LogTrace(category)<<" L3MuonCandidateProducerFromMuons destructor called";
45 }
46 
47 
50  // Create a RecoChargedCandidate collection
51  LogTrace(category)<<" Creating the RecoChargedCandidate collection";
52  auto candidates = std::make_unique<RecoChargedCandidateCollection>();
53 
54  // Take the L3 container
55  LogTrace(category)<<" Taking the L3/GLB muons: "<<m_L3CollectionLabel.label();
57  event.getByToken(muonToken_,muons);
58 
59  if (not muons.isValid()) {
60  LogError(category) << muons.whyFailed()->what();
61  } else {
62  for (unsigned int i=0; i<muons->size(); i++) {
63  TrackRef tkref = (*muons)[i].innerTrack();
64 
65  Particle::Charge q = tkref->charge();
66  Particle::LorentzVector p4(tkref->px(), tkref->py(), tkref->pz(), tkref->p());
67  Particle::Point vtx(tkref->vx(),tkref->vy(), tkref->vz());
68 
69  int pid = 13;
70  if (abs(q)==1)
71  pid = q < 0 ? 13 : -13;
72  else
73  LogWarning(category) << "L3MuonCandidate has charge = " << q;
74  RecoChargedCandidate cand(q, p4, vtx, pid);
75 
76  cand.setTrack(tkref);
77  candidates->push_back(cand);
78  }
79  }
80  event.put(std::move(candidates));
81 }
edm::EDGetTokenT< reco::MuonCollection > muonToken_
std::pair< double, double > Point
Definition: CaloEllipse.h:18
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
produce candidates
double p4[4]
Definition: TauolaWrapper.h:92
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool isValid() const
Definition: HandleBase.h:74
#define LogTrace(id)
L3MuonCandidateProducerFromMuons(const edm::ParameterSet &)
constructor with config
std::string const & label() const
Definition: InputTag.h:36
fixed size matrix
HLT enums.
static const std::string category("Muon|RecoMuon|L3MuonCandidateProducerFromMuons")
std::shared_ptr< cms::Exception > whyFailed() const
Definition: HandleBase.h:106
void setTrack(const reco::TrackRef &r)
set reference to track
ParameterSet const & parameterSet(Provenance const &provenance)
Definition: Provenance.cc:11
def move(src, dest)
Definition: eostools.py:510
Definition: event.py:1
math::PtEtaPhiELorentzVectorF LorentzVector