CMS 3D CMS Logo

HLTTriMuonIsolation.h
Go to the documentation of this file.
1 #ifndef HLTrigger_Muon_HLTTriMuonIsolation_h
2 #define HLTrigger_Muon_HLTTriMuonIsolation_h
3 
4 #include <iostream>
5 #include <string>
6 
13 
22 
24 public:
25  explicit HLTTriMuonIsolation(const edm::ParameterSet& iConfig);
26  ~HLTTriMuonIsolation() override;
27  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
28  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
29 
30 private:
35 
41 
42  template <typename T>
43  static bool ptComparer(const T& cand_1, const T& cand_2) {
44  return cand_1.pt() > cand_2.pt();
45  }
46 
47  const double TwiceMuonMass_ = 2. * 0.1056583715; // in GeV
48 
49  const double Muon1PtCut_;
50  const double Muon2PtCut_;
51  const double Muon3PtCut_;
52  const double TriMuonPtCut_;
53  const double TriMuonEtaCut_;
54  const double ChargedRelIsoCut_;
55  const double ChargedAbsIsoCut_;
56  const double IsoConeSize_;
57  const double MatchingConeSize_;
58  const double MinTriMuonMass_;
59  const double MaxTriMuonMass_;
60  const double MaxTriMuonRadius_;
61  const int TriMuonAbsCharge_;
62  const double MaxDZ_;
63  const bool EnableRelIso_;
64  const bool EnableAbsIso_;
65 };
66 
68  : L3MuonsToken_(consumes<reco::RecoChargedCandidateCollection>(iConfig.getParameter<edm::InputTag>("L3MuonsSrc"))),
69  AllMuonsToken_(
70  consumes<reco::RecoChargedCandidateCollection>(iConfig.getParameter<edm::InputTag>("AllMuonsSrc"))),
71  L3DiMuonsFilterToken_(
72  consumes<trigger::TriggerFilterObjectWithRefs>(iConfig.getParameter<edm::InputTag>("L3DiMuonsFilterSrc"))),
73  IsoTracksToken_(consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("IsoTracksSrc"))),
74  Muon1PtCut_(iConfig.getParameter<double>("Muon1PtCut")),
75  Muon2PtCut_(iConfig.getParameter<double>("Muon2PtCut")),
76  Muon3PtCut_(iConfig.getParameter<double>("Muon3PtCut")),
77  TriMuonPtCut_(iConfig.getParameter<double>("TriMuonPtCut")),
78  TriMuonEtaCut_(iConfig.getParameter<double>("TriMuonEtaCut")),
79  ChargedRelIsoCut_(iConfig.getParameter<double>("ChargedRelIsoCut")),
80  ChargedAbsIsoCut_(iConfig.getParameter<double>("ChargedAbsIsoCut")),
81  IsoConeSize_(iConfig.getParameter<double>("IsoConeSize")),
82  MatchingConeSize_(iConfig.getParameter<double>("MatchingConeSize")),
83  MinTriMuonMass_(iConfig.getParameter<double>("MinTriMuonMass")),
84  MaxTriMuonMass_(iConfig.getParameter<double>("MaxTriMuonMass")),
85  MaxTriMuonRadius_(iConfig.getParameter<double>("MaxTriMuonRadius")),
86  TriMuonAbsCharge_(iConfig.getParameter<int>("TriMuonAbsCharge")),
87  MaxDZ_(iConfig.getParameter<double>("MaxDZ")),
88  EnableRelIso_(iConfig.getParameter<bool>("EnableRelIso")),
89  EnableAbsIso_(iConfig.getParameter<bool>("EnableAbsIso")) {
90  //register products
91  produces<reco::CompositeCandidateCollection>("Taus");
92  produces<reco::CompositeCandidateCollection>("SelectedTaus");
93 }
94 
96 
98  std::unique_ptr<reco::CompositeCandidateCollection> Taus(new reco::CompositeCandidateCollection);
99  std::unique_ptr<reco::CompositeCandidateCollection> SelectedTaus(new reco::CompositeCandidateCollection);
100 
101  // Get the L3 muon candidates
103  iEvent.getByToken(L3MuonsToken_, L3MuCands);
104 
105  // Get the L3 muon candidates that passed the filter
108 
109  std::vector<reco::RecoChargedCandidateRef> PassedL3Muons;
111 
112  // Get the Trk + L3 muon candidates (after merging)
114  iEvent.getByToken(AllMuonsToken_, AllMuCands);
115 
116  // Get iso tracks
118  iEvent.getByToken(IsoTracksToken_, IsoTracks);
119 
120  if (AllMuCands->size() >= 3 && L3MuCands->size() >= 2) {
121  // Create the 3-muon candidates
122  // loop over L3/Trk muons and create all combinations
123  auto AllMuCands_end = AllMuCands->end();
124  for (auto i = AllMuCands->begin(); i != AllMuCands_end - 2; ++i) {
125  // check that muon_i passes the previous filter
126  bool passingPreviousFilter_1 = false;
127  for (const auto& imu : PassedL3Muons) {
128  if (reco::deltaR2(i->momentum(), imu->momentum()) < (MatchingConeSize_ * MatchingConeSize_))
129  passingPreviousFilter_1 = true;
130  }
131  for (auto j = i + 1; j != AllMuCands_end - 1; ++j) {
132  // check that muon_j passes the previous filter
133  bool passingPreviousFilter_2 = false;
134  for (const auto& jmu : PassedL3Muons) {
135  if (reco::deltaR2(j->momentum(), jmu->momentum()) < (MatchingConeSize_ * MatchingConeSize_))
136  passingPreviousFilter_2 = true;
137  }
138  // if, at this point, no muons passed the previous filter just skip to the next iteration
139  if (!(passingPreviousFilter_1 || passingPreviousFilter_2))
140  continue;
141  for (auto k = j + 1; k != AllMuCands_end; ++k) {
142  // check that muon_k passes the previous filter
143  bool passingPreviousFilter_3 = false;
144  for (const auto& kmu : PassedL3Muons) {
145  if (reco::deltaR2(k->momentum(), kmu->momentum()) < (MatchingConeSize_ * MatchingConeSize_))
146  passingPreviousFilter_3 = true;
147  }
148  // at least two muons must have passed the previous di-muon filter
149  if (!((passingPreviousFilter_1 & passingPreviousFilter_2) ||
150  (passingPreviousFilter_1 & passingPreviousFilter_3) ||
151  (passingPreviousFilter_2 & passingPreviousFilter_3)))
152  continue;
153 
154  // Create a composite candidate to be a tau
156 
157  // sort the muons by pt and add them to the tau
159  daughters.reserve(3);
160 
161  daughters.push_back(*i);
162  daughters.push_back(*j);
163  daughters.push_back(*k);
164 
165  std::sort(daughters.begin(), daughters.end(), ptComparer<reco::RecoChargedCandidate>);
166 
167  // Muon kinematic selections
168  if (daughters[0].pt() < Muon1PtCut_)
169  continue;
170  if (daughters[1].pt() < Muon2PtCut_)
171  continue;
172  if (daughters[2].pt() < Muon3PtCut_)
173  continue;
174 
175  // assign the tau its daughters
176  tau.addDaughter((daughters)[0], "Muon_1");
177  tau.addDaughter((daughters)[1], "Muon_2");
178  tau.addDaughter((daughters)[2], "Muon_3");
179 
180  // start building the tau
181  int charge = daughters[0].charge() + daughters[1].charge() + daughters[2].charge();
182  math::XYZTLorentzVectorD taup4 = daughters[0].p4() + daughters[1].p4() + daughters[2].p4();
183  int tauPdgId = charge > 0 ? 15 : -15;
184 
185  tau.setP4(taup4);
186  tau.setCharge(charge);
187  tau.setPdgId(tauPdgId);
188  tau.setVertex((daughters)[0].vertex()); // assign the leading muon vertex as tau vertex
189 
190  // the three muons must be close to each other in Z
191  if (std::abs(tau.daughter(0)->vz() - tau.vz()) > MaxDZ_)
192  continue;
193  if (std::abs(tau.daughter(1)->vz() - tau.vz()) > MaxDZ_)
194  continue;
195  if (std::abs(tau.daughter(2)->vz() - tau.vz()) > MaxDZ_)
196  continue;
197 
198  // require muons to be collimated
199  bool collimated = true;
200  for (auto const& idau : daughters) {
201  if (reco::deltaR2(tau.p4(), idau.p4()) > MaxTriMuonRadius_ * MaxTriMuonRadius_) {
202  collimated = false;
203  break;
204  }
205  }
206 
207  if (!collimated)
208  continue;
209 
210  // Tau kinematic selections
211  if (tau.pt() < TriMuonPtCut_)
212  continue;
213  if (tau.mass() < MinTriMuonMass_)
214  continue;
215  if (tau.mass() > MaxTriMuonMass_)
216  continue;
217  if (std::abs(tau.eta()) > TriMuonEtaCut_)
218  continue;
219 
220  // Tau charge selection
221  if ((std::abs(tau.charge()) != TriMuonAbsCharge_) & (TriMuonAbsCharge_ >= 0))
222  continue;
223 
224  // Sanity check against duplicates, di-muon masses must be > 2 * mass_mu
225  if ((tau.daughter(0)->p4() + tau.daughter(1)->p4()).mass() < TwiceMuonMass_)
226  continue;
227  if ((tau.daughter(0)->p4() + tau.daughter(2)->p4()).mass() < TwiceMuonMass_)
228  continue;
229  if ((tau.daughter(1)->p4() + tau.daughter(2)->p4()).mass() < TwiceMuonMass_)
230  continue;
231 
232  // a good tau, at last
233  Taus->push_back(tau);
234  }
235  }
236  }
237 
238  // Sort taus by pt
239  std::sort(Taus->begin(), Taus->end(), ptComparer<reco::CompositeCandidate>);
240 
241  // Loop over taus and further select by isolation
242  for (const auto& itau : *Taus) {
243  // remove the candidate pt from the iso sum
244  double sumPt = -itau.pt();
245 
246  // compute iso sum pT
247  for (const auto& itrk : *IsoTracks) {
248  if (reco::deltaR2(itrk.momentum(), itau.p4()) > IsoConeSize_ * IsoConeSize_)
249  continue;
250  if (std::abs(itrk.vz() - itau.vz()) > MaxDZ_)
251  continue;
252  sumPt += itrk.pt();
253  }
254 
255  // apply the isolation cut
257  double chRelIsoCut = EnableRelIso_ ? ChargedRelIsoCut_ * itau.pt() : std::numeric_limits<double>::infinity();
258 
259  if (!((sumPt < chAbsIsoCut) || (sumPt < chRelIsoCut)))
260  continue;
261 
262  SelectedTaus->push_back(itau);
263  }
264  }
265 
266  // finally put the vector of 3-muon candidates in the event
267  iEvent.put(std::move(Taus), "Taus");
268  iEvent.put(std::move(SelectedTaus), "SelectedTaus");
269 }
270 
273  desc.add<edm::InputTag>("L3MuonsSrc", edm::InputTag("hltIterL3FromL2MuonCandidates"));
274  desc.add<edm::InputTag>("AllMuonsSrc", edm::InputTag("hltGlbTrkMuonCands"));
275  desc.add<edm::InputTag>("L3DiMuonsFilterSrc", edm::InputTag("hltDiMuonForTau3MuDzFiltered0p3"));
276  desc.add<edm::InputTag>("IsoTracksSrc", edm::InputTag("hltIter2L3FromL2MuonMerged"));
277  desc.add<double>("Muon1PtCut", 5.);
278  desc.add<double>("Muon2PtCut", 3.);
279  desc.add<double>("Muon3PtCut", 0.);
280  desc.add<double>("TriMuonPtCut", 8.);
281  desc.add<double>("TriMuonEtaCut", 2.5);
282  desc.add<double>("ChargedAbsIsoCut", 3.0);
283  desc.add<double>("ChargedRelIsoCut", 0.1);
284  desc.add<double>("IsoConeSize", 0.5);
285  desc.add<double>("MatchingConeSize", 0.03);
286  desc.add<double>("MinTriMuonMass", 0.5);
287  desc.add<double>("MaxTriMuonMass", 2.8);
288  desc.add<double>("MaxTriMuonRadius", 0.6);
289  desc.add<int>("TriMuonAbsCharge", -1);
290  desc.add<double>("MaxDZ", 0.3);
291  desc.add<bool>("EnableRelIso", false);
292  desc.add<bool>("EnableAbsIso", true);
293  descriptions.add("hltTriMuonIsolationProducer", desc);
294 }
295 
296 #endif
edm::StreamID
Definition: StreamID.h:30
electrons_cff.bool
bool
Definition: electrons_cff.py:372
mps_fire.i
i
Definition: mps_fire.py:355
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
Muon.h
MessageLogger.h
HLTTriMuonIsolation::HLTTriMuonIsolation
HLTTriMuonIsolation(const edm::ParameterSet &iConfig)
Definition: HLTTriMuonIsolation.h:67
CompositeCandidate.h
IsoTracks
Definition: IsoTracks.cc:16
metsig::tau
Definition: SignAlgoResolutions.h:49
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
edm::EDGetTokenT< reco::RecoChargedCandidateCollection >
edm
HLT enums.
Definition: AlignableModifier.h:19
math::XYZTLorentzVectorD
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:14
HLTTriMuonIsolation::EnableRelIso_
const bool EnableRelIso_
Definition: HLTTriMuonIsolation.h:63
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
HLTTriMuonIsolation::ptComparer
static bool ptComparer(const T &cand_1, const T &cand_2)
Definition: HLTTriMuonIsolation.h:43
HLTTriMuonIsolation
Definition: HLTTriMuonIsolation.h:23
HLTTriMuonIsolation::MaxTriMuonRadius_
const double MaxTriMuonRadius_
Definition: HLTTriMuonIsolation.h:60
HLTTriMuonIsolation::produce
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
Definition: HLTTriMuonIsolation.h:97
HLTTriMuonIsolation::EnableAbsIso_
const bool EnableAbsIso_
Definition: HLTTriMuonIsolation.h:64
HLTTriMuonIsolation::IsoTracks
edm::Handle< reco::TrackCollection > IsoTracks
Definition: HLTTriMuonIsolation.h:40
TriggerFilterObjectWithRefs.h
HLTTriMuonIsolation::TwiceMuonMass_
const double TwiceMuonMass_
Definition: HLTTriMuonIsolation.h:47
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
infinity
const double infinity
Definition: CSCChamberFitter.cc:10
HLTTriMuonIsolation::ChargedRelIsoCut_
const double ChargedRelIsoCut_
Definition: HLTTriMuonIsolation.h:54
edm::Handle< reco::RecoChargedCandidateCollection >
trigger::TriggerRefsCollections::getObjects
void getObjects(Vids &ids, VRphoton &refs) const
various physics-level getters:
Definition: TriggerRefsCollections.h:452
reco::RecoChargedCandidateCollection
std::vector< RecoChargedCandidate > RecoChargedCandidateCollection
collectin of RecoChargedCandidate objects
Definition: RecoChargedCandidateFwd.h:9
TtFullHadEvtBuilder_cfi.sumPt
sumPt
Definition: TtFullHadEvtBuilder_cfi.py:38
deltaR.h
HLTTriMuonIsolation::~HLTTriMuonIsolation
~HLTTriMuonIsolation() override
Definition: HLTTriMuonIsolation.h:95
HLTTriMuonIsolation::TriMuonEtaCut_
const double TriMuonEtaCut_
Definition: HLTTriMuonIsolation.h:53
MakerMacros.h
reco::CompositeCandidateCollection
std::vector< CompositeCandidate > CompositeCandidateCollection
collection of Candidate objects
Definition: CompositeCandidateFwd.h:19
HLTTriMuonIsolation::AllMuonsToken_
const edm::EDGetTokenT< reco::RecoChargedCandidateCollection > AllMuonsToken_
Definition: HLTTriMuonIsolation.h:32
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
BPhysicsValidation_cfi.daughters
daughters
Definition: BPhysicsValidation_cfi.py:11
MuonFwd.h
HLTTriMuonIsolation::Muon1PtCut_
const double Muon1PtCut_
Definition: HLTTriMuonIsolation.h:49
trigger::TriggerMuon
Definition: TriggerTypeDefs.h:68
HLTTriMuonIsolation::MaxDZ_
const double MaxDZ_
Definition: HLTTriMuonIsolation.h:62
HLTTriMuonIsolation::L3MuonsToken_
const edm::EDGetTokenT< reco::RecoChargedCandidateCollection > L3MuonsToken_
Definition: HLTTriMuonIsolation.h:31
dqmdumpme.k
k
Definition: dqmdumpme.py:60
HLTTriMuonIsolation::L3DiMuonsFilterToken_
const edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefs > L3DiMuonsFilterToken_
Definition: HLTTriMuonIsolation.h:33
edm::global::EDProducer
Definition: EDProducer.h:32
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition: ALCARECOTkAlJpsiMuMu_cff.py:47
HLTTriMuonIsolation::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: HLTTriMuonIsolation.h:271
HLTTriMuonIsolation::Muon3PtCut_
const double Muon3PtCut_
Definition: HLTTriMuonIsolation.h:51
bphysicsOniaDQM_cfi.vertex
vertex
Definition: bphysicsOniaDQM_cfi.py:7
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
HLTTriMuonIsolation::IsoConeSize_
const double IsoConeSize_
Definition: HLTTriMuonIsolation.h:56
HLTTriMuonIsolation::MatchingConeSize_
const double MatchingConeSize_
Definition: HLTTriMuonIsolation.h:57
reco::deltaR2
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
LorentzVector.h
createfilelist.int
int
Definition: createfilelist.py:10
HLTTriMuonIsolation::L3DiMuonsFilterCands
edm::Handle< trigger::TriggerFilterObjectWithRefs > L3DiMuonsFilterCands
Definition: HLTTriMuonIsolation.h:37
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:57
HLTTriMuonIsolation::TriMuonAbsCharge_
const int TriMuonAbsCharge_
Definition: HLTTriMuonIsolation.h:61
eostools.move
def move(src, dest)
Definition: eostools.py:511
RecoChargedCandidate.h
HLTTriMuonIsolation::TriMuonPtCut_
const double TriMuonPtCut_
Definition: HLTTriMuonIsolation.h:52
Frameworkfwd.h
T
long double T
Definition: Basic3DVectorLD.h:48
HLTTriMuonIsolation::MaxTriMuonMass_
const double MaxTriMuonMass_
Definition: HLTTriMuonIsolation.h:59
EgHLTOffHistBins_cfi.mass
mass
Definition: EgHLTOffHistBins_cfi.py:34
HLTTriMuonIsolation::Muon2PtCut_
const double Muon2PtCut_
Definition: HLTTriMuonIsolation.h:50
HLTTriMuonIsolation::MinTriMuonMass_
const double MinTriMuonMass_
Definition: HLTTriMuonIsolation.h:58
HLTTriMuonIsolation::IsoTracksToken_
const edm::EDGetTokenT< reco::TrackCollection > IsoTracksToken_
Definition: HLTTriMuonIsolation.h:34
trigger
Definition: HLTPrescaleTableCond.h:8
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ParameterSet.h
EDProducer.h
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
HLTTriMuonIsolation::ChargedAbsIsoCut_
const double ChargedAbsIsoCut_
Definition: HLTTriMuonIsolation.h:55
edm::Event
Definition: Event.h:73
RecoChargedCandidateFwd.h
HLTTriMuonIsolation::L3MuCands
edm::Handle< reco::RecoChargedCandidateCollection > L3MuCands
Definition: HLTTriMuonIsolation.h:36
HLTTriMuonIsolation::PassedL3Muons
edm::Handle< reco::RecoChargedCandidateRef > PassedL3Muons
Definition: HLTTriMuonIsolation.h:38
edm::InputTag
Definition: InputTag.h:15
reco::TrackCollection
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
reco::CompositeCandidate
Definition: CompositeCandidate.h:21
HLTTriMuonIsolation::AllMuCands
edm::Handle< reco::RecoChargedCandidateCollection > AllMuCands
Definition: HLTTriMuonIsolation.h:39