CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTScoutingMuonProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: HLTrigger/Muon
4 // Class: HLTScoutingMuonProducer
5 //
11 //
12 // Original Author: David G. Sheffield (Rutgers)
13 // Created: Fri, 31 Jul 2015
14 //
15 //
16 
18 
19 //
20 // constructors and destructor
21 //
23  ChargedCandidateCollection_(consumes<reco::RecoChargedCandidateCollection>
24  (iConfig.getParameter<edm::InputTag>("ChargedCandidates"))),
25  TrackCollection_(consumes<reco::TrackCollection>
26  (iConfig.getParameter<edm::InputTag>("Tracks"))),
27  EcalPFClusterIsoMap_(consumes<RecoChargedCandMap>(iConfig.getParameter<edm::InputTag>(
28  "EcalPFClusterIsoMap"))),
29  HcalPFClusterIsoMap_(consumes<RecoChargedCandMap>(iConfig.getParameter<edm::InputTag>(
30  "HcalPFClusterIsoMap"))),
31  TrackIsoMap_(consumes<edm::ValueMap<double>>(iConfig.getParameter<edm::InputTag>(
32  "TrackIsoMap"))),
33  muonPtCut(iConfig.getParameter<double>("muonPtCut")),
34  muonEtaCut(iConfig.getParameter<double>("muonEtaCut"))
35 {
36  //register products
37  produces<ScoutingMuonCollection>();
38 }
39 
41 { }
42 
43 // ------------ method called to produce the data ------------
45  edm::EventSetup const & setup) const
46 {
47  using namespace edm;
48 
49  std::unique_ptr<ScoutingMuonCollection> outMuons(new ScoutingMuonCollection());
50 
51  // Get RecoChargedCandidate
52  Handle<reco::RecoChargedCandidateCollection> ChargedCandidateCollection;
53  if(!iEvent.getByToken(ChargedCandidateCollection_, ChargedCandidateCollection)){
54  iEvent.put(std::move(outMuons));
55  return;
56  }
57 
58  // Get Track
61  iEvent.put(std::move(outMuons));
62  return;
63  }
64 
65  // Get EcalPFClusterIsoMap
66  Handle<RecoChargedCandMap> EcalPFClusterIsoMap;
67  if(!iEvent.getByToken(EcalPFClusterIsoMap_, EcalPFClusterIsoMap)){
68  iEvent.put(std::move(outMuons));
69  return;
70  }
71 
72  // Get HcalPFClusterIsoMap
73  Handle<RecoChargedCandMap> HcalPFClusterIsoMap;
74  if(!iEvent.getByToken(HcalPFClusterIsoMap_, HcalPFClusterIsoMap)){
75  iEvent.put(std::move(outMuons));
76  return;
77  }
78 
79  // Get TrackIsoMap
80  Handle<ValueMap<double>> TrackIsoMap;
81  if(!iEvent.getByToken(TrackIsoMap_, TrackIsoMap)){
82  iEvent.put(std::move(outMuons));
83  return;
84  }
85 
86  // Produce muons
87  int index = 0;
88  for (auto &muon : *ChargedCandidateCollection) {
89  reco::RecoChargedCandidateRef muonRef = getRef(ChargedCandidateCollection, index);
90  ++index;
91  if (muonRef.isNull() || !muonRef.isAvailable())
92  continue;
93 
94  reco::TrackRef track = muon.track();
95  if (track.isNull() || !track.isAvailable())
96  continue;
97 
98  if (muon.pt() < muonPtCut)
99  continue;
100  if (fabs(muon.eta()) > muonEtaCut)
101  continue;
102 
103  outMuons->emplace_back(muon.pt(), muon.eta(), muon.phi(), muon.mass(),
104  (*EcalPFClusterIsoMap)[muonRef], (*HcalPFClusterIsoMap)[muonRef],
105  (*TrackIsoMap)[muonRef], track->chi2(), track->ndof(),
106  track->charge(), track->dxy(), track->dz(),
107  track->hitPattern().numberOfValidMuonHits(),
108  track->hitPattern().numberOfValidPixelHits(),
109  0, // nMatchedStations
110  track->hitPattern().trackerLayersWithMeasurement(),
111  2); // Global muon
112  }
113 
114  // Put output
115  iEvent.put(std::move(outMuons));
116 }
117 
118 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
121  desc.add<edm::InputTag>("ChargedCandidates", edm::InputTag("hltL3MuonCandidates"));
122  desc.add<edm::InputTag>("Tracks", edm::InputTag("hltL3Muons"));
123  desc.add<edm::InputTag>("EcalPFClusterIsoMap", edm::InputTag("hltMuonEcalPFClusterIsoForMuons"));
124  desc.add<edm::InputTag>("HcalPFClusterIsoMap", edm::InputTag("hltMuonHcalPFClusterIsoForMuons"));
125  desc.add<edm::InputTag>("TrackIsoMap", edm::InputTag(
126  "hltMuonTkRelIsolationCut0p09Map:combinedRelativeIsoDeposits"));
127  desc.add<double>("muonPtCut", 4.0);
128  desc.add<double>("muonEtaCut", 2.4);
129  descriptions.add("hltScoutingMuonProducer", desc);
130 }
helper::MatcherGetRef< C >::ref_type getRef(const Handle< C > &c, size_t k)
Definition: getRef.h:28
bool isAvailable() const
Definition: Ref.h:576
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
const edm::EDGetTokenT< RecoChargedCandMap > EcalPFClusterIsoMap_
const edm::EDGetTokenT< reco::TrackCollection > TrackCollection_
const edm::EDGetTokenT< RecoChargedCandMap > HcalPFClusterIsoMap_
virtual void produce(edm::StreamID sid, edm::Event &iEvent, edm::EventSetup const &setup) const overridefinal
int iEvent
Definition: GenABIO.cc:230
const edm::EDGetTokenT< edm::ValueMap< double > > TrackIsoMap_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
def move
Definition: eostools.py:510
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::vector< ScoutingMuon > ScoutingMuonCollection
Definition: ScoutingMuon.h:69
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isNull() const
Checks for null.
Definition: Ref.h:249
std::vector< RecoChargedCandidate > RecoChargedCandidateCollection
collectin of RecoChargedCandidate objects
const edm::EDGetTokenT< reco::RecoChargedCandidateCollection > ChargedCandidateCollection_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
HLTScoutingMuonProducer(const edm::ParameterSet &)
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")