CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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_ptr<RecoChargedCandidateCollection> candidates( new 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(candidates);
81 }
int i
Definition: DBlmapReader.cc:9
edm::EDGetTokenT< reco::MuonCollection > muonToken_
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
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
bool isValid() const
Definition: HandleBase.h:75
#define LogTrace(id)
L3MuonCandidateProducerFromMuons(const edm::ParameterSet &)
constructor with config
std::vector< RecoChargedCandidate > RecoChargedCandidateCollection
collectin of RecoChargedCandidate objects
tuple pid
Definition: sysUtil.py:22
std::string const & label() const
Definition: InputTag.h:43
tuple muons
Definition: patZpeak.py:38
static const std::string category("Muon|RecoMuon|L3MuonCandidateProducerFromMuons")
std::shared_ptr< cms::Exception > whyFailed() const
Definition: HandleBase.h:110
virtual void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
produce candidates
void setTrack(const reco::TrackRef &r)
set reference to track
ParameterSet const & parameterSet(Provenance const &provenance)
Definition: Provenance.cc:11
math::PtEtaPhiELorentzVectorF LorentzVector