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
15 
17 
18 // Input and output collections
21 
24 
25 
26 #include <string>
27 
28 using namespace edm;
29 using namespace std;
30 using namespace reco;
31 
32 static const std::string category("Muon|RecoMuon|L3MuonCandidateProducerFromMuons");
33 
36  m_L3CollectionLabel( parameterSet.getParameter<InputTag>("InputObjects") ) // standAlone Collection Label
37 {
38  muonToken_ = consumes<reco::MuonCollection>(m_L3CollectionLabel);
39  LogTrace(category)<<" constructor called";
40  produces<RecoChargedCandidateCollection>();
41 }
42 
45  LogTrace(category)<<" L3MuonCandidateProducerFromMuons destructor called";
46 }
47 
48 
51  // Create a RecoChargedCandidate collection
52  LogTrace(category)<<" Creating the RecoChargedCandidate collection";
53  auto_ptr<RecoChargedCandidateCollection> candidates( new RecoChargedCandidateCollection());
54 
55  // Take the L3 container
56  LogTrace(category)<<" Taking the L3/GLB muons: "<<m_L3CollectionLabel.label();
58  event.getByToken(muonToken_,muons);
59 
60  if (not muons.isValid()) {
61  LogError(category) << muons.whyFailed()->what();
62  } else {
63  for (unsigned int i=0; i<muons->size(); i++) {
64  TrackRef tkref = (*muons)[i].innerTrack();
65 
66  Particle::Charge q = tkref->charge();
67  Particle::LorentzVector p4(tkref->px(), tkref->py(), tkref->pz(), tkref->p());
68  Particle::Point vtx(tkref->vx(),tkref->vy(), tkref->vz());
69 
70  int pid = 13;
71  if (abs(q)==1)
72  pid = q < 0 ? 13 : -13;
73  else
74  LogWarning(category) << "L3MuonCandidate has charge = " << q;
75  RecoChargedCandidate cand(q, p4, vtx, pid);
76 
77  cand.setTrack(tkref);
78  candidates->push_back(cand);
79  }
80  }
81  event.put(candidates);
82 }
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:76
#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:42
virtual void produce(edm::Event &, const edm::EventSetup &)
produce candidates
tuple muons
Definition: patZpeak.py:38
static const std::string category("Muon|RecoMuon|L3MuonCandidateProducerFromMuons")
std::shared_ptr< cms::Exception > whyFailed() const
Definition: HandleBase.h:111
void setTrack(const reco::TrackRef &r)
set reference to track
ParameterSet const & parameterSet(Provenance const &provenance)
Definition: Provenance.cc:11
math::PtEtaPhiELorentzVectorF LorentzVector