CMS 3D CMS Logo

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
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;
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
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const std::string metname
edm::EDGetTokenT< reco::TrackCollection > tracksToken
int Charge
electric charge type
Definition: Particle.h:19
ParameterSet const & parameterSet(StableProvenance const &provenance, ProcessHistory const &history)
Definition: Provenance.cc:11
#define LogTrace(id)
void produce(edm::StreamID sid, edm::Event &event, const edm::EventSetup &) const override
produce candidates
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
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
~L2MuonCandidateProducer() override
destructor
Log< level::Warning, false > LogWarning
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:21
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1