CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
L2MuonCandidateProducer.cc
Go to the documentation of this file.
1 
18 #include <string>
19 
31 
33 public:
36 
38  ~L2MuonCandidateProducer() override;
39 
41  void produce(edm::StreamID sid, edm::Event& event, const edm::EventSetup&) const override;
42 
43 private:
44  // StandAlone Collection Label
47 };
48 
51  LogTrace("Muon|RecoMuon|L2MuonCandidateProducer") << " constructor called";
52 
53  // StandAlone Collection Label
54  theSACollectionLabel = parameterSet.getParameter<edm::InputTag>("InputObjects");
55  tracksToken = consumes<reco::TrackCollection>(theSACollectionLabel);
56  produces<reco::RecoChargedCandidateCollection>();
57 }
58 
61  LogTrace("Muon|RecoMuon|L2MuonCandidateProducer") << " L2MuonCandidateProducer destructor called";
62 }
63 
66  const std::string metname = "Muon|RecoMuon|L2MuonCandidateProducer";
67 
68  // Take the SA container
69  LogTrace(metname) << " Taking the StandAlone muons: " << theSACollectionLabel;
71  event.getByToken(tracksToken, tracks);
72 
73  // Create a RecoChargedCandidate collection
74  LogTrace(metname) << " Creating the RecoChargedCandidate collection";
75  auto candidates = std::make_unique<reco::RecoChargedCandidateCollection>();
76 
77  for (unsigned int i = 0; i < tracks->size(); i++) {
78  reco::TrackRef tkref(tracks, i);
79  reco::Particle::Charge q = tkref->charge();
80  reco::Particle::LorentzVector p4(tkref->px(), tkref->py(), tkref->pz(), tkref->p());
81  reco::Particle::Point vtx(tkref->vx(), tkref->vy(), tkref->vz());
82  int pid = 13;
83  if (abs(q) == 1)
84  pid = q < 0 ? 13 : -13;
85  else
86  edm::LogWarning(metname) << "L2MuonCandidate has charge = " << q;
87  reco::RecoChargedCandidate cand(q, p4, vtx, pid);
88  cand.setTrack(tkref);
89  candidates->push_back(cand);
90  }
91 
92  event.put(std::move(candidates));
93 
94  LogTrace(metname) << " Event loaded"
95  << "================================";
96 }
97 
98 // declare as a framework plugin
const std::string metname
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::EDGetTokenT< reco::TrackCollection > tracksToken
auto const & tracks
cannot be loose
int Charge
electric charge type
Definition: Particle.h:19
#define LogTrace(id)
void produce(edm::StreamID sid, edm::Event &event, const edm::EventSetup &) const override
produce candidates
ParameterSet const & parameterSet(StableProvenance const &provenance, ProcessHistory const &history)
Definition: Provenance.cc:11
def move
Definition: eostools.py:511
math::XYZPoint Point
point in the space
Definition: Particle.h:25
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
L2MuonCandidateProducer(const edm::ParameterSet &)
constructor with config
~L2MuonCandidateProducer() override
destructor
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
Log< level::Warning, false > LogWarning
void setTrack(const reco::TrackRef &r)
set reference to track
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:21