CMS 3D CMS Logo

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 
19 #include "TMath.h"
20 
21 //
22 // constructors and destructor
23 //
25  : ChargedCandidateCollection_(
26  consumes<reco::RecoChargedCandidateCollection>(iConfig.getParameter<edm::InputTag>("ChargedCandidates"))),
27  TrackCollection_(consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("Tracks"))),
28  EcalPFClusterIsoMap_(consumes<RecoChargedCandMap>(iConfig.getParameter<edm::InputTag>("EcalPFClusterIsoMap"))),
29  HcalPFClusterIsoMap_(consumes<RecoChargedCandMap>(iConfig.getParameter<edm::InputTag>("HcalPFClusterIsoMap"))),
30  TrackIsoMap_(consumes<edm::ValueMap<double>>(iConfig.getParameter<edm::InputTag>("TrackIsoMap"))),
31  displacedvertexCollection_(
32  consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("displacedvertexCollection"))),
33  muonPtCut(iConfig.getParameter<double>("muonPtCut")),
34  muonEtaCut(iConfig.getParameter<double>("muonEtaCut")),
35  minVtxProbCut(iConfig.getParameter<double>("minVtxProbCut")),
36  linkToken_(consumes<reco::MuonTrackLinksCollection>(iConfig.getParameter<edm::InputTag>("InputLinks"))) {
37  //register products
38  produces<ScoutingMuonCollection>();
39  produces<ScoutingVertexCollection>("displacedVtx");
40 }
41 
43 
44 // ------------ method called to produce the data ------------
46  using namespace edm;
47 
48  std::unique_ptr<ScoutingMuonCollection> outMuons(new ScoutingMuonCollection());
49  std::unique_ptr<ScoutingVertexCollection> dispVertices(new ScoutingVertexCollection());
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
60  if (!iEvent.getByToken(TrackCollection_, TrackCollection)) {
61  iEvent.put(std::move(outMuons));
62  return;
63  }
64 
65  // Get EcalPFClusterIsoMap
68 
69  // Get HcalPFClusterIsoMap
72 
73  // Get TrackIsoMap
75  if (!iEvent.getByToken(TrackIsoMap_, TrackIsoMap)) {
76  iEvent.put(std::move(outMuons));
77  return;
78  }
79 
80  std::pair<reco::RecoChargedCandidate, reco::RecoChargedCandidate> ivtxMuPair;
81  std::vector<std::pair<reco::RecoChargedCandidate, reco::RecoChargedCandidate>> vtxMuPair;
82 
83  //get displaced vertices
86  for (auto& dispvtx : *displacedvertexCollection) {
87  if (!dispvtx.isValid())
88  continue;
89  float vtxProb = 0.0;
90  if ((dispvtx.chi2() >= 0.0) && (dispvtx.ndof() > 0))
91  vtxProb = TMath::Prob(dispvtx.chi2(), dispvtx.ndof());
92  if (vtxProb < minVtxProbCut)
93  continue;
94 
95  // Get the 2 tracks associated to displaced vertex
96  auto trackIt = dispvtx.tracks_begin();
97  reco::TrackRef vertextkRef1 = (*trackIt).castTo<reco::TrackRef>();
98  trackIt++;
99  reco::TrackRef vertextkRef2 = (*trackIt).castTo<reco::TrackRef>();
100 
101  // Get the muons associated with the tracks
102  int iFoundRefs = 0;
103  for (auto const& cand : *ChargedCandidateCollection) {
104  reco::TrackRef tkRef = cand.get<reco::TrackRef>();
105  if (tkRef == vertextkRef1) {
106  ivtxMuPair.first = cand;
107  iFoundRefs++;
108  }
109  if (tkRef == vertextkRef2) {
110  ivtxMuPair.second = cand;
111  iFoundRefs++;
112  }
113  }
114  if (iFoundRefs < 2)
115  continue;
116  vtxMuPair.push_back(ivtxMuPair);
117 
118  dispVertices->emplace_back(dispvtx.x(),
119  dispvtx.y(),
120  dispvtx.z(),
121  dispvtx.zError(),
122  dispvtx.xError(),
123  dispvtx.yError(),
124  dispvtx.tracksSize(),
125  dispvtx.chi2(),
126  dispvtx.ndof(),
127  dispvtx.isValid());
128  }
129  }
130 
131  // Produce muons
132  std::vector<int> vtxInd;
133  float minDR2 = 1e-06;
134  int index = 0;
135 
136  // Read Links collection:
138  iEvent.getByToken(linkToken_, links);
139 
140  for (auto& muon : *ChargedCandidateCollection) {
141  reco::RecoChargedCandidateRef muonRef = getRef(ChargedCandidateCollection, index);
142  ++index;
143  if (muonRef.isNull() || !muonRef.isAvailable())
144  continue;
145 
146  reco::TrackRef track = muon.track();
147  if (track.isNull() || !track.isAvailable())
148  continue;
149 
150  int validmuhit = 0;
151  int matchedsta = 0;
152  for (auto const& link : *links) {
153  const reco::Track& trackerTrack = *link.trackerTrack();
154  float dR2 = deltaR2(track->eta(), track->phi(), trackerTrack.eta(), trackerTrack.phi());
155  float dPt = std::abs(track->pt() - trackerTrack.pt());
156  if (track->pt() != 0)
157  dPt = dPt / track->pt();
158 
159  if (dR2 < 0.02 * 0.02 and dPt < 0.001) {
160  const reco::TrackRef staTrack = link.standAloneTrack();
161  validmuhit = staTrack->hitPattern().numberOfValidMuonHits();
162  matchedsta = staTrack->hitPattern().muonStationsWithValidHits();
163  }
164  }
165 
166  if (muon.pt() < muonPtCut)
167  continue;
168  if (fabs(muon.eta()) > muonEtaCut)
169  continue;
170 
171  double ecalisopf = -1.0;
172  if (EcalPFClusterIsoMap.isValid()) {
173  ecalisopf = (*EcalPFClusterIsoMap)[muonRef];
174  }
175 
176  double hcalisopf = -1.0;
177  if (HcalPFClusterIsoMap.isValid()) {
178  hcalisopf = (*HcalPFClusterIsoMap)[muonRef];
179  }
180 
181  vtxInd.reserve(vtxMuPair.size());
182  for (unsigned int i = 0; i < vtxMuPair.size(); i++) {
183  float dr2_1 = reco::deltaR2(((vtxMuPair[i]).first), muon);
184  float dr2_2 = reco::deltaR2(((vtxMuPair[i]).second), muon);
185  if ((dr2_1 < minDR2) || (dr2_2 < minDR2))
186  vtxInd.push_back(i);
187  }
188 
189  outMuons->emplace_back(muon.pt(),
190  muon.eta(),
191  muon.phi(),
192  muon.mass(),
193  ecalisopf,
194  hcalisopf,
195  (*TrackIsoMap)[muonRef],
196  track->chi2(),
197  track->ndof(),
198  track->charge(),
199  track->dxy(),
200  track->dz(),
201  validmuhit,
202  track->hitPattern().numberOfValidPixelHits(),
203  matchedsta,
204  track->hitPattern().trackerLayersWithMeasurement(),
205  2, // Global muon
206  track->hitPattern().numberOfValidStripHits(),
207  track->qoverp(),
208  track->lambda(),
209  track->pt(),
210  track->phi(),
211  track->eta(),
212  track->dxyError(),
213  track->dzError(),
214  track->qoverpError(),
215  track->lambdaError(),
216  track->phiError(),
217  track->dsz(),
218  track->dszError(),
219  vtxInd);
220  vtxInd.clear();
221  }
222 
223  // Put output
224  iEvent.put(std::move(outMuons));
225  iEvent.put(std::move(dispVertices), "displacedVtx");
226 }
227 
228 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
231  desc.add<edm::InputTag>("ChargedCandidates", edm::InputTag("hltIterL3MuonCandidates"));
232  desc.add<edm::InputTag>("Tracks", edm::InputTag("hltPixelTracks"));
233  desc.add<edm::InputTag>("EcalPFClusterIsoMap", edm::InputTag("hltMuonEcalMFPFClusterIsoForMuons"));
234  desc.add<edm::InputTag>("HcalPFClusterIsoMap", edm::InputTag("hltMuonHcalRegPFClusterIsoForMuons"));
235  desc.add<edm::InputTag>("TrackIsoMap", edm::InputTag("hltMuonTkRelIsolationCut0p07Map:combinedRelativeIsoDeposits"));
236  desc.add<edm::InputTag>("displacedvertexCollection", edm::InputTag("hltPixelVertices"));
237  desc.add<double>("muonPtCut", 3.0);
238  desc.add<double>("muonEtaCut", 2.4);
239  desc.add<double>("minVtxProbCut", 0.001);
240  desc.add<edm::InputTag>("InputLinks", edm::InputTag("hltL3MuonsIterL3Links"));
241 
242  descriptions.add("hltScoutingMuonProducer", desc);
243 }
244 
245 // declare this class as a framework plugin
edm::StreamID
Definition: StreamID.h:30
HLT_2018_cff.displacedvertexCollection
displacedvertexCollection
Definition: HLT_2018_cff.py:88465
mps_fire.i
i
Definition: mps_fire.py:355
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
HLTScoutingMuonProducer::minVtxProbCut
const double minVtxProbCut
Definition: HLTScoutingMuonProducer.h:70
HLT_2018_cff.HcalPFClusterIsoMap
HcalPFClusterIsoMap
Definition: HLT_2018_cff.py:88460
MainPageGenerator.link
link
Definition: MainPageGenerator.py:271
muon
Definition: MuonCocktails.h:17
HLT_2018_cff.minVtxProbCut
minVtxProbCut
Definition: HLT_2018_cff.py:88459
edm::Ref::isAvailable
bool isAvailable() const
Definition: Ref.h:537
edm::Ref::isNull
bool isNull() const
Checks for null.
Definition: Ref.h:235
edm
HLT enums.
Definition: AlignableModifier.h:19
reco::VertexCollection
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
HLTScoutingMuonProducer::muonPtCut
const double muonPtCut
Definition: HLTScoutingMuonProducer.h:68
ScoutingMuonCollection
std::vector< ScoutingMuon > ScoutingMuonCollection
Definition: ScoutingMuon.h:176
HLTScoutingMuonProducer::EcalPFClusterIsoMap_
const edm::EDGetTokenT< RecoChargedCandMap > EcalPFClusterIsoMap_
Definition: HLTScoutingMuonProducer.h:63
HLTScoutingMuonProducer::TrackCollection_
const edm::EDGetTokenT< reco::TrackCollection > TrackCollection_
Definition: HLTScoutingMuonProducer.h:62
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:215
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
HLTScoutingMuonProducer.h
edm::Handle< reco::RecoChargedCandidateCollection >
dqmdumpme.first
first
Definition: dqmdumpme.py:55
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
reco::RecoChargedCandidateCollection
std::vector< RecoChargedCandidate > RecoChargedCandidateCollection
collectin of RecoChargedCandidate objects
Definition: RecoChargedCandidateFwd.h:9
edm::Ref< TrackCollection >
deltaR.h
reco::TrackBase::pt
double pt() const
track transverse momentum
Definition: TrackBase.h:608
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
HLTScoutingMuonProducer::HcalPFClusterIsoMap_
const edm::EDGetTokenT< RecoChargedCandMap > HcalPFClusterIsoMap_
Definition: HLTScoutingMuonProducer.h:64
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
reco::MuonTrackLinksCollection
std::vector< MuonTrackLinks > MuonTrackLinksCollection
collection of MuonTrackLinks
Definition: MuonFwd.h:22
HLT_2018_cff.EcalPFClusterIsoMap
EcalPFClusterIsoMap
Definition: HLT_2018_cff.py:88461
reco::Track
Definition: Track.h:27
HLTScoutingMuonProducer::TrackIsoMap_
const edm::EDGetTokenT< edm::ValueMap< double > > TrackIsoMap_
Definition: HLTScoutingMuonProducer.h:65
HLTScoutingMuonProducer::~HLTScoutingMuonProducer
~HLTScoutingMuonProducer() override
HLT_2018_cff.TrackIsoMap
TrackIsoMap
Definition: HLT_2018_cff.py:88468
reco::TrackBase::phi
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:620
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::ParameterSet
Definition: ParameterSet.h:36
HLTScoutingMuonProducer::ChargedCandidateCollection_
const edm::EDGetTokenT< reco::RecoChargedCandidateCollection > ChargedCandidateCollection_
Definition: HLTScoutingMuonProducer.h:61
ScoutingVertexCollection
std::vector< ScoutingVertex > ScoutingVertexCollection
Definition: ScoutingVertex.h:69
edm::getRef
helper::MatcherGetRef< C >::ref_type getRef(const Handle< C > &c, size_t k)
Definition: getRef.h:28
edm::AssociationMap
Definition: AssociationMap.h:48
reco::deltaR2
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
reco::TrackBase::eta
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:623
HLTScoutingMuonProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: HLTScoutingMuonProducer.cc:229
cand
Definition: decayParser.h:34
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:57
HLTScoutingMuonProducer::displacedvertexCollection_
const edm::EDGetTokenT< reco::VertexCollection > displacedvertexCollection_
Definition: HLTScoutingMuonProducer.h:66
eostools.move
def move(src, dest)
Definition: eostools.py:511
HLTScoutingMuonProducer::HLTScoutingMuonProducer
HLTScoutingMuonProducer(const edm::ParameterSet &)
Definition: HLTScoutingMuonProducer.cc:24
HLTMuonOfflineAnalyzer_cfi.deltaR2
deltaR2
Definition: HLTMuonOfflineAnalyzer_cfi.py:105
electronStore.links
links
Definition: electronStore.py:149
HLTScoutingMuonProducer::muonEtaCut
const double muonEtaCut
Definition: HLTScoutingMuonProducer.h:69
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
HLT_2018_cff.track
track
Definition: HLT_2018_cff.py:10352
ewkTauDQM_cfi.muonEtaCut
muonEtaCut
Definition: ewkTauDQM_cfi.py:41
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::Event
Definition: Event.h:73
HLTScoutingMuonProducer::linkToken_
const edm::EDGetTokenT< reco::MuonTrackLinksCollection > linkToken_
Definition: HLTScoutingMuonProducer.h:72
edm::InputTag
Definition: InputTag.h:15
reco::TrackCollection
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
HLTScoutingMuonProducer
Definition: HLTScoutingMuonProducer.h:48
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
HLTScoutingMuonProducer::produce
void produce(edm::StreamID sid, edm::Event &iEvent, edm::EventSetup const &setup) const final
Definition: HLTScoutingMuonProducer.cc:45
L1TObjectsTiming_cfi.muonPtCut
muonPtCut
Definition: L1TObjectsTiming_cfi.py:23