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  // Get RecoChargedCandidate
50  Handle<reco::RecoChargedCandidateCollection> ChargedCandidateCollection;
51  if(!iEvent.getByToken(ChargedCandidateCollection_, ChargedCandidateCollection)){
52  edm::LogError ("HLTScoutingMuonProducer")
53  << "invalid collection: ChargedCandidateCollection" << "\n";
54  return;
55  }
56 
57  // Get Track
60  edm::LogError ("HLTScoutingMuonProducer")
61  << "invalid collection: TrackCollection" << "\n";
62  return;
63  }
64 
65  // Get EcalPFClusterIsoMap
66  Handle<RecoChargedCandMap> EcalPFClusterIsoMap;
67  if(!iEvent.getByToken(EcalPFClusterIsoMap_, EcalPFClusterIsoMap)){
68  edm::LogError ("HLTScoutingMuonProducer")
69  << "invalid collection: hltMuonEcalPFClusterIsoForMuons" << "\n";
70  return;
71  }
72 
73  // Get HcalPFClusterIsoMap
74  Handle<RecoChargedCandMap> HcalPFClusterIsoMap;
75  if(!iEvent.getByToken(HcalPFClusterIsoMap_, HcalPFClusterIsoMap)){
76  edm::LogError ("HLTScoutingMuonProducer")
77  << "invalid collection: hltMuonHcalPFClusterIsoForMuons" << "\n";
78  return;
79  }
80 
81  // Get TrackIsoMap
82  Handle<ValueMap<double>> TrackIsoMap;
83  if(!iEvent.getByToken(TrackIsoMap_, TrackIsoMap)){
84  edm::LogError ("HLTScoutingMuonProducer")
85  << "invalid collection: TrackIsoMap" << "\n";
86  return;
87  }
88 
89  // Produce muons
90  std::auto_ptr<ScoutingMuonCollection> outMuons(new ScoutingMuonCollection());
91  int index = 0;
92  for (auto &muon : *ChargedCandidateCollection) {
93  reco::RecoChargedCandidateRef muonRef = getRef(ChargedCandidateCollection, index);
94  ++index;
95  if (muonRef.isNull() || !muonRef.isAvailable())
96  continue;
97 
98  reco::TrackRef track = muon.track();
99  if (track.isNull() || !track.isAvailable())
100  continue;
101 
102  if (muon.pt() < muonPtCut)
103  continue;
104  if (fabs(muon.eta()) > muonEtaCut)
105  continue;
106 
107  outMuons->emplace_back(muon.pt(), muon.eta(), muon.phi(), muon.mass(),
108  (*EcalPFClusterIsoMap)[muonRef], (*HcalPFClusterIsoMap)[muonRef],
109  (*TrackIsoMap)[muonRef], track->chi2(), track->ndof(),
110  track->charge(), track->dxy(), track->dz(),
111  track->hitPattern().numberOfValidMuonHits(),
112  track->hitPattern().numberOfValidPixelHits(),
113  0, // nMatchedStations
114  track->hitPattern().trackerLayersWithMeasurement(),
115  2); // Global muon
116  }
117 
118  // Put output
119  iEvent.put(outMuons);
120 }
121 
122 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
125  desc.add<edm::InputTag>("ChargedCandidates", edm::InputTag("hltL3MuonCandidates"));
126  desc.add<edm::InputTag>("Tracks", edm::InputTag("hltL3Muons"));
127  desc.add<edm::InputTag>("EcalPFClusterIsoMap", edm::InputTag("hltMuonEcalPFClusterIsoForMuons"));
128  desc.add<edm::InputTag>("HcalPFClusterIsoMap", edm::InputTag("hltMuonHcalPFClusterIsoForMuons"));
129  desc.add<edm::InputTag>("TrackIsoMap", edm::InputTag(
130  "hltMuonTkRelIsolationCut0p09Map:combinedRelativeIsoDeposits"));
131  desc.add<double>("muonPtCut", 4.0);
132  desc.add<double>("muonEtaCut", 2.4);
133  descriptions.add("scoutingMuonProducer", desc);
134 }
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
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="")