CMS 3D CMS Logo

TrackingParticleRefMuonProducer.cc
Go to the documentation of this file.
10 
12 public:
14 
15  void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override;
16 
17 private:
20  double ptmin_;
21  double pmin_;
22 };
23 
25  : tpToken_(consumes<TrackingParticleCollection>(iConfig.getParameter<edm::InputTag>("src"))),
26  skim_(iConfig.getParameter<std::string>("skim")),
27  ptmin_(iConfig.getParameter<double>("ptmin")),
28  pmin_(iConfig.getParameter<double>("pmin")) {
29  edm::LogVerbatim("TrackingParticleRefMuonProducer")
30  << "\n constructing TrackingParticleRefMuonProducer: skim = " << skim_;
31  if (skim_ == "mu")
32  edm::LogVerbatim("TrackingParticleRefMuonProducer") << "\t ptmin = " << ptmin_ << ", pmin = " << pmin_ << "\n";
33  else if (skim_ == "track")
34  edm::LogVerbatim("TrackingParticleRefMuonProducer") << "\t ptmin = " << ptmin_ << "\n";
35  else if (skim_ == "pf")
36  edm::LogVerbatim("TrackingParticleRefMuonProducer") << "\t ptmin = " << ptmin_ << ", pmin = " << pmin_ << "\n";
37  else
38  edm::LogError("TrackingParticleRefMuonProducer") << "\t undefined skim = " << skim_ << "\n";
39 
40  produces<TrackingParticleRefVector>();
41 }
42 
45  iEvent.getByToken(tpToken_, tpH);
46 
47  auto tpskim = std::make_unique<TrackingParticleRefVector>();
48 
49  if (skim_ == "mu") {
50  for (size_t i = 0, end = tpH->size(); i < end; ++i) {
51  auto tp = TrackingParticleRef(tpH, i);
52 
53  // test if the TP is a muon with pt and p above minimum thresholds
54  bool isMu = (std::abs(tp->pdgId()) == 13);
55  bool ptpOk = (tp->pt() > ptmin_) && (tp->p() > pmin_);
56  if (isMu && ptpOk)
57  tpskim->push_back(tp);
58  else {
59  // test if the TP has muon hits
60  int n_muon_hits = tp->numberOfHits() - tp->numberOfTrackerHits();
61  if (n_muon_hits > 0)
62  tpskim->push_back(tp);
63  }
64  }
65  } else if (skim_ == "track") {
66  for (size_t i = 0, end = tpH->size(); i < end; ++i) {
67  auto tp = TrackingParticleRef(tpH, i);
68 
69  // test if the pt is above a minimum cut
70  if (tp->pt() > ptmin_)
71  tpskim->push_back(tp);
72  }
73  } else if (skim_ == "pf") {
74  for (size_t i = 0, end = tpH->size(); i < end; ++i) {
75  auto tp = TrackingParticleRef(tpH, i);
76 
77  // test if p and pt are above minimum cuts
78  if ((tp->pt() > ptmin_) && (tp->p() > pmin_))
79  tpskim->push_back(tp);
80  }
81  }
82 
83  iEvent.put(std::move(tpskim));
84 }
85 
TrackingParticleRefMuonProducer::ptmin_
double ptmin_
Definition: TrackingParticleRefMuonProducer.cc:20
mps_fire.i
i
Definition: mps_fire.py:428
TrackingParticleRefMuonProducer::tpToken_
edm::EDGetTokenT< TrackingParticleCollection > tpToken_
Definition: TrackingParticleRefMuonProducer.cc:18
MessageLogger.h
TrackingParticleRefMuonProducer
Definition: TrackingParticleRefMuonProducer.cc:11
edm::EDGetTokenT< TrackingParticleCollection >
edm
HLT enums.
Definition: AlignableModifier.h:19
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
EDProducer.h
edm::Handle< TrackingParticleCollection >
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
TrackingParticleRefMuonProducer::produce
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
Definition: TrackingParticleRefMuonProducer.cc:43
mps_fire.end
end
Definition: mps_fire.py:242
cmsswSequenceInfo.tp
tp
Definition: cmsswSequenceInfo.py:17
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
ModuleDef.h
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::stream::EDProducer
Definition: EDProducer.h:36
edm::EventSetup
Definition: EventSetup.h:58
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
TrackingParticleRefMuonProducer::pmin_
double pmin_
Definition: TrackingParticleRefMuonProducer.cc:21
TrackingParticle.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
TrackingParticleFwd.h
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
TrackingParticleCollection
std::vector< TrackingParticle > TrackingParticleCollection
Definition: TrackingParticleFwd.h:9
TrackingParticleRefMuonProducer::skim_
std::string skim_
Definition: TrackingParticleRefMuonProducer.cc:19
TrackingParticleRefMuonProducer::TrackingParticleRefMuonProducer
TrackingParticleRefMuonProducer(const edm::ParameterSet &iConfig)
Definition: TrackingParticleRefMuonProducer.cc:24
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ParameterSet.h
TrackingParticleRef
edm::Ref< TrackingParticleCollection > TrackingParticleRef
Definition: TrackingParticleFwd.h:12
edm::Event
Definition: Event.h:73
jets_cff.isMu
isMu
Definition: jets_cff.py:329
EDProductfwd.h