CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ME0MuonConverter.cc
Go to the documentation of this file.
1 
9 
13 
15 
16 
17 
23 
24 #include "TLorentzVector.h"
25 
28 
30 
31 
34 
48 
49 
52 
53 
56 
58 
59 
60 
63 
64 
65 
67 public:
69  explicit ME0MuonConverter(const edm::ParameterSet&);
73  virtual void produce(edm::Event&, const edm::EventSetup&) override;
74 
75 
76 
77 private:
78 
79  //edm::EDGetTokenT<std::vector<reco::ME0Muon>> OurMuonsToken_;
81 };
82 
83 
85 
86  produces<std::vector<reco::RecoChargedCandidate> >();
87  edm::InputTag OurMuonsTag ("me0SegmentMatching");
88  OurMuonsToken_ = consumes<ME0MuonCollection>(OurMuonsTag);
89 
90 }
91 
93 
95 
96  using namespace edm;
97 
98  using namespace reco;
99 
100  // Handle <std::vector<ME0Muon> > OurMuons;
101  // ev.getByToken <std::vector<ME0Muon> > (OurMuonsToken_, OurMuons);
102 
103 
105  ev.getByToken(OurMuonsToken_, OurMuons);
106 
107  std::auto_ptr<RecoChargedCandidateCollection> oc( new RecoChargedCandidateCollection());
108 
109  for (std::vector<ME0Muon>::const_iterator thisMuon = OurMuons->begin();
110  thisMuon != OurMuons->end(); ++thisMuon){
111  TrackRef tkRef = thisMuon->innerTrack();
112 
113  Particle::Charge q = tkRef->charge();
114  Particle::LorentzVector p4(tkRef->px(), tkRef->py(), tkRef->pz(), tkRef->p());
115  Particle::Point vtx(tkRef->vx(),tkRef->vy(), tkRef->vz());
116 
117  int pid = 0;
118  if(abs(q)==1) pid = q < 0 ? 13 : -13;
119  reco::RecoChargedCandidate cand(q, p4, vtx, pid);
120  cand.setTrack(thisMuon->innerTrack());
121  oc->push_back(cand);
122  }
123 
124  ev.put(oc);
125 }
126 
127 
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
bool ev
~ME0MuonConverter()
Destructor.
std::pair< double, double > Point
Definition: CaloEllipse.h:18
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:120
double p4[4]
Definition: TauolaWrapper.h:92
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
virtual void produce(edm::Event &, const edm::EventSetup &) override
Produce the converted collection.
std::vector< RecoChargedCandidate > RecoChargedCandidateCollection
collectin of RecoChargedCandidate objects
edm::EDGetTokenT< ME0MuonCollection > OurMuonsToken_
tuple pid
Definition: sysUtil.py:22
ME0MuonConverter(const edm::ParameterSet &)
Constructor.
void setTrack(const reco::TrackRef &r)
set reference to track
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
math::PtEtaPhiELorentzVectorF LorentzVector