CMS 3D CMS Logo

L2MuonCandidateProducer.cc
Go to the documentation of this file.
1 
18 // Framework
24 
26 
27 // Input and output collections
30 
31 #include <string>
32 
33 using namespace edm;
34 using namespace std;
35 using namespace reco;
36 
39  LogTrace("Muon|RecoMuon|L2MuonCandidateProducer")<<" constructor called";
40 
41  // StandAlone Collection Label
42  theSACollectionLabel = parameterSet.getParameter<InputTag>("InputObjects");
43  tracksToken = consumes<reco::TrackCollection>(theSACollectionLabel);
44  produces<RecoChargedCandidateCollection>();
45 }
46 
49  LogTrace("Muon|RecoMuon|L2MuonCandidateProducer")<<" L2MuonCandidateProducer destructor called";
50 }
51 
52 
55  const string metname = "Muon|RecoMuon|L2MuonCandidateProducer";
56 
57  // Take the SA container
58  LogTrace(metname)<<" Taking the StandAlone muons: "<<theSACollectionLabel;
60  event.getByToken(tracksToken,tracks);
61 
62  // Create a RecoChargedCandidate collection
63  LogTrace(metname)<<" Creating the RecoChargedCandidate collection";
64  auto candidates = std::make_unique<RecoChargedCandidateCollection>();
65 
66  for (unsigned int i=0; i<tracks->size(); i++) {
67  TrackRef tkref(tracks,i);
68  Particle::Charge q = tkref->charge();
69  Particle::LorentzVector p4(tkref->px(), tkref->py(), tkref->pz(), tkref->p());
70  Particle::Point vtx(tkref->vx(),tkref->vy(), tkref->vz());
71  int pid = 13;
72  if(abs(q)==1) pid = q < 0 ? 13 : -13;
73  else LogWarning(metname) << "L2MuonCandidate has charge = "<<q;
74  RecoChargedCandidate cand(q, p4, vtx, pid);
75  cand.setTrack(tkref);
76  candidates->push_back(cand);
77  }
78 
79  event.put(std::move(candidates));
80 
81  LogTrace(metname)<<" Event loaded"
82  <<"================================";
83 }
T getParameter(std::string const &) const
const std::string metname
std::pair< double, double > Point
Definition: CaloEllipse.h:18
double p4[4]
Definition: TauolaWrapper.h:92
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
L2MuonCandidateProducer(const edm::ParameterSet &)
constructor with config
#define LogTrace(id)
virtual void produce(edm::StreamID sid, edm::Event &event, const edm::EventSetup &) const override
produce candidates
virtual ~L2MuonCandidateProducer()
destructor
fixed size matrix
HLT enums.
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