CMS 3D CMS Logo

AlignmentMuonSelector.cc
Go to the documentation of this file.
2 
5 
6 #include "TLorentzVector.h"
7 
8 // constructor ----------------------------------------------------------------
9 
11  : applyBasicCuts(cfg.getParameter<bool>("applyBasicCuts")),
12  applyNHighestPt(cfg.getParameter<bool>("applyNHighestPt")),
13  applyMultiplicityFilter(cfg.getParameter<bool>("applyMultiplicityFilter")),
14  applyMassPairFilter(cfg.getParameter<bool>("applyMassPairFilter")),
15  nHighestPt(cfg.getParameter<int>("nHighestPt")),
16  minMultiplicity(cfg.getParameter<int>("minMultiplicity")),
17  pMin(cfg.getParameter<double>("pMin")),
18  pMax(cfg.getParameter<double>("pMax")),
19  ptMin(cfg.getParameter<double>("ptMin")),
20  ptMax(cfg.getParameter<double>("ptMax")),
21  etaMin(cfg.getParameter<double>("etaMin")),
22  etaMax(cfg.getParameter<double>("etaMax")),
23  phiMin(cfg.getParameter<double>("phiMin")),
24  phiMax(cfg.getParameter<double>("phiMax")),
25  nHitMinSA(cfg.getParameter<double>("nHitMinSA")),
26  nHitMaxSA(cfg.getParameter<double>("nHitMaxSA")),
27  chi2nMaxSA(cfg.getParameter<double>("chi2nMaxSA")),
28  nHitMinGB(cfg.getParameter<double>("nHitMinGB")),
29  nHitMaxGB(cfg.getParameter<double>("nHitMaxGB")),
30  chi2nMaxGB(cfg.getParameter<double>("chi2nMaxGB")),
31  nHitMinTO(cfg.getParameter<double>("nHitMinTO")),
32  nHitMaxTO(cfg.getParameter<double>("nHitMaxTO")),
33  chi2nMaxTO(cfg.getParameter<double>("chi2nMaxTO")),
34  minMassPair(cfg.getParameter<double>("minMassPair")),
35  maxMassPair(cfg.getParameter<double>("maxMassPair")) {
36  if (applyBasicCuts)
37  edm::LogInfo("AlignmentMuonSelector")
38  << "applying basic muon cuts ..."
39  << "\npmin,pmax: " << pMin << "," << pMax << "\nptmin,ptmax: " << ptMin << "," << ptMax
40  << "\netamin,etamax: " << etaMin << "," << etaMax << "\nphimin,phimax: " << phiMin << "," << phiMax
41  << "\nnhitminSA,nhitmaxSA: " << nHitMinSA << "," << nHitMaxSA << "\nchi2nmaxSA: " << chi2nMaxSA << ","
42  << "\nnhitminGB,nhitmaxGB: " << nHitMinGB << "," << nHitMaxGB << "\nchi2nmaxGB: " << chi2nMaxGB << ","
43  << "\nnhitminTO,nhitmaxTO: " << nHitMinTO << "," << nHitMaxTO << "\nchi2nmaxTO: " << chi2nMaxTO;
44 
45  if (applyNHighestPt)
46  edm::LogInfo("AlignmentMuonSelector") << "filter N muons with highest Pt N=" << nHighestPt;
47 
49  edm::LogInfo("AlignmentMuonSelector") << "apply multiplicity filter N>=" << minMultiplicity;
50 
52  edm::LogInfo("AlignmentMuonSelector")
53  << "apply Mass Pair filter minMassPair=" << minMassPair << " maxMassPair=" << maxMassPair;
54 }
55 
56 // destructor -----------------------------------------------------------------
57 
59 
60 // do selection ---------------------------------------------------------------
61 
63  Muons result = muons;
64 
65  // apply basic muon cuts (if selected)
66  if (applyBasicCuts)
67  result = this->basicCuts(result);
68 
69  // filter N muons with highest Pt (if selected)
70  if (applyNHighestPt)
71  result = this->theNHighestPtMuons(result);
72 
73  // apply minimum multiplicity requirement (if selected)
75  if (result.size() < (unsigned int)minMultiplicity)
76  result.clear();
77  }
78 
79  // apply mass pair requirement (if selected)
80  if (applyMassPairFilter) {
81  if (result.size() < 2)
82  result.clear(); // at least 2 muons are require for a mass pair...
83  else
85  }
86 
87  edm::LogInfo("AlignmentMuonSelector") << "muons all,kept: " << muons.size() << "," << result.size();
88 
89  return result;
90 }
91 
92 // make basic cuts ------------------------------------------------------------
93 
95  Muons result;
96 
97  for (Muons::const_iterator it = muons.begin(); it != muons.end(); ++it) {
98  const reco::Muon* muonp = *it;
99  float p = muonp->p();
100  float pt = muonp->pt();
101  float eta = muonp->eta();
102  float phi = muonp->phi();
103 
104  int nhitSA = 0;
105  float chi2nSA = 9999.;
106  if (muonp->isStandAloneMuon()) {
107  nhitSA = muonp->standAloneMuon()->numberOfValidHits(); // standAlone Muon
108  chi2nSA = muonp->standAloneMuon()->normalizedChi2(); // standAlone Muon
109  }
110  int nhitGB = 0;
111  float chi2nGB = 9999.;
112  if (muonp->isGlobalMuon()) {
113  nhitGB = muonp->combinedMuon()->numberOfValidHits(); // global Muon
114  chi2nGB = muonp->combinedMuon()->normalizedChi2(); // global Muon
115  }
116  int nhitTO = 0;
117  float chi2nTO = 9999.;
118  if (muonp->isTrackerMuon()) {
119  nhitTO = muonp->track()->numberOfValidHits(); // Tracker Only
120  chi2nTO = muonp->track()->normalizedChi2(); // Tracker Only
121  }
122  edm::LogInfo("AlignmentMuonSelector")
123  << " pt,eta,phi,nhitSA,chi2nSA,nhitGB,chi2nGB,nhitTO,chi2nTO: " << pt << "," << eta << "," << phi << ","
124  << nhitSA << "," << chi2nSA << "," << nhitGB << "," << chi2nGB << "," << nhitTO << "," << chi2nTO;
125 
126  if (p > pMin && p < pMax && pt > ptMin && pt < ptMax && eta > etaMin && eta < etaMax && phi > phiMin &&
127  phi < phiMax && nhitSA >= nHitMinSA && nhitSA <= nHitMaxSA && chi2nSA < chi2nMaxSA && nhitGB >= nHitMinGB &&
128  nhitGB <= nHitMaxGB && chi2nGB < chi2nMaxGB && nhitTO >= nHitMinTO && nhitTO <= nHitMaxTO &&
129  chi2nTO < chi2nMaxTO) {
130  result.push_back(muonp);
131  }
132  }
133 
134  return result;
135 }
136 
137 //-----------------------------------------------------------------------------
138 
140  Muons sortedMuons = muons;
141  Muons result;
142 
143  // sort in pt
144  std::sort(sortedMuons.begin(), sortedMuons.end(), ptComparator);
145 
146  // copy theMuonMult highest pt muons to result vector
147  int n = 0;
148  for (Muons::const_iterator it = sortedMuons.begin(); it != sortedMuons.end(); ++it) {
149  if (n < nHighestPt) {
150  result.push_back(*it);
151  n++;
152  }
153  }
154 
155  return result;
156 }
157 
158 //-----------------------------------------------------------------------------
159 
161  Muons sortedMuons = muons;
162  Muons result;
163  TLorentzVector mu1, mu2, pair;
164  double mass = 0, minDiff = 999999.;
165 
166  // sort in pt
167  std::sort(sortedMuons.begin(), sortedMuons.end(), ptComparator);
168 
169  // copy best mass pair combination muons to result vector
170  // Criteria:
171  // a) maxMassPair != minMassPair: the two highest pt muons with mass pair inside the given mass window
172  // b) maxMassPair == minMassPair: the muon pair with massPair closest to given mass value
173  for (Muons::const_iterator it1 = sortedMuons.begin(); it1 != sortedMuons.end(); ++it1) {
174  for (Muons::const_iterator it2 = it1 + 1; it2 != sortedMuons.end(); ++it2) {
175  mu1 = TLorentzVector((*it1)->momentum().x(), (*it1)->momentum().y(), (*it1)->momentum().z(), (*it1)->p());
176  mu2 = TLorentzVector((*it2)->momentum().x(), (*it2)->momentum().y(), (*it2)->momentum().z(), (*it2)->p());
177  pair = mu1 + mu2;
178  mass = pair.M();
179 
180  if (maxMassPair != minMassPair) {
181  if (mass < maxMassPair && mass > minMassPair) {
182  result.push_back(*it1);
183  result.push_back(*it2);
184  break;
185  }
186  } else {
187  if (fabs(mass - maxMassPair) < minDiff) {
188  minDiff = fabs(mass - maxMassPair);
189  result.clear();
190  result.push_back(*it1);
191  result.push_back(*it2);
192  }
193  }
194  }
195  }
196 
197  return result;
198 }
AlignmentMuonSelector.h
PDWG_BPHSkim_cff.muons
muons
Definition: PDWG_BPHSkim_cff.py:47
electrons_cff.bool
bool
Definition: electrons_cff.py:366
ALCARECOTkAlBeamHalo_cff.etaMin
etaMin
GeV.
Definition: ALCARECOTkAlBeamHalo_cff.py:32
MessageLogger.h
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
AlignmentMuonSelector::pMin
double pMin
Definition: AlignmentMuonSelector.h:58
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
AlignmentMuonSelector::pMax
double pMax
Definition: AlignmentMuonSelector.h:58
AlignmentMuonSelector::applyNHighestPt
bool applyNHighestPt
Definition: AlignmentMuonSelector.h:56
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
ptMin
constexpr float ptMin
Definition: PhotonIDValueMapProducer.cc:155
AlignmentMuonSelector::phiMax
double phiMax
Definition: AlignmentMuonSelector.h:58
AlignmentMuonSelector::chi2nMaxTO
double chi2nMaxTO
Definition: AlignmentMuonSelector.h:61
reco::LeafCandidate::pt
double pt() const final
transverse momentum
Definition: LeafCandidate.h:146
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
AlignmentMuonSelector::applyMassPairFilter
bool applyMassPairFilter
Definition: AlignmentMuonSelector.h:56
AlignmentMuonSelector::nHitMaxSA
double nHitMaxSA
Definition: AlignmentMuonSelector.h:59
reco::Muon
Definition: Muon.h:27
AlignmentMuonSelector::minMultiplicity
int minMultiplicity
Definition: AlignmentMuonSelector.h:57
AlignmentMuonSelector_cfi.applyMassPairFilter
applyMassPairFilter
Definition: AlignmentMuonSelector_cfi.py:43
AlignmentMuonSelector::~AlignmentMuonSelector
~AlignmentMuonSelector()
destructor
Definition: AlignmentMuonSelector.cc:58
AlignmentMuonSelector::nHighestPt
int nHighestPt
Definition: AlignmentMuonSelector.h:57
AlignmentMuonSelector_cfi.maxMassPair
maxMassPair
Definition: AlignmentMuonSelector_cfi.py:45
AlignmentMuonSelector::applyBasicCuts
bool applyBasicCuts
private data members
Definition: AlignmentMuonSelector.h:56
ALCARECOTkAlBeamHalo_cff.applyBasicCuts
applyBasicCuts
do not store empty events
Definition: ALCARECOTkAlBeamHalo_cff.py:29
AlignmentTrackSelector_cfi.ptMax
ptMax
Definition: AlignmentTrackSelector_cfi.py:12
AlignmentTrackSelector_cfi.applyMultiplicityFilter
applyMultiplicityFilter
Definition: AlignmentTrackSelector_cfi.py:55
AlignmentTrackSelector_cfi.pMax
pMax
Definition: AlignmentTrackSelector_cfi.py:14
PVValHelper::eta
Definition: PVValidationHelpers.h:70
AlignmentMuonSelector::AlignmentMuonSelector
AlignmentMuonSelector(const edm::ParameterSet &cfg)
constructor
Definition: AlignmentMuonSelector.cc:10
AlignmentMuonSelector::etaMin
double etaMin
Definition: AlignmentMuonSelector.h:58
AlignmentTrackSelector_cfi.phiMin
phiMin
Definition: AlignmentTrackSelector_cfi.py:18
AlignmentTrackSelector_cfi.phiMax
phiMax
Definition: AlignmentTrackSelector_cfi.py:17
AlignmentMuonSelector::ptMax
double ptMax
Definition: AlignmentMuonSelector.h:58
AlignmentMuonSelector::nHitMaxTO
double nHitMaxTO
Definition: AlignmentMuonSelector.h:61
reco::Muon::combinedMuon
TrackRef combinedMuon() const override
reference to a stand-alone muon Track
Definition: Muon.h:52
AlignmentMuonSelector::phiMin
double phiMin
Definition: AlignmentMuonSelector.h:58
reco::Muon::isGlobalMuon
bool isGlobalMuon() const override
Definition: Muon.h:299
AlignmentMuonSelector::applyMultiplicityFilter
bool applyMultiplicityFilter
Definition: AlignmentMuonSelector.h:56
AlignmentTrackSelector_cfi.nHighestPt
nHighestPt
Definition: AlignmentTrackSelector_cfi.py:61
edm::ParameterSet
Definition: ParameterSet.h:47
reco::LeafCandidate::eta
double eta() const final
momentum pseudorapidity
Definition: LeafCandidate.h:152
AlignmentMuonSelector::nHitMinTO
double nHitMinTO
Definition: AlignmentMuonSelector.h:61
AlignmentTrackSelector_cfi.minMultiplicity
minMultiplicity
Definition: AlignmentTrackSelector_cfi.py:56
ALCARECOTkAlMinBias_cff.pMin
pMin
GeV.
Definition: ALCARECOTkAlMinBias_cff.py:35
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
AlignmentMuonSelector::etaMax
double etaMax
Definition: AlignmentMuonSelector.h:58
createfilelist.int
int
Definition: createfilelist.py:10
AlignmentMuonSelector::maxMassPair
double maxMassPair
Definition: AlignmentMuonSelector.h:62
looper.cfg
cfg
Definition: looper.py:297
AlignmentMuonSelector::ptComparator
ComparePt ptComparator
Definition: AlignmentMuonSelector.h:53
reco::Muon::track
TrackRef track() const override
reference to a Track
Definition: Muon.h:46
DDAxes::phi
AlignmentMuonSelector::minMassPair
double minMassPair
Definition: AlignmentMuonSelector.h:62
reco::Muon::isTrackerMuon
bool isTrackerMuon() const override
Definition: Muon.h:300
reco::LeafCandidate::phi
double phi() const final
momentum azimuthal angle
Definition: LeafCandidate.h:148
AlignmentMuonSelector::chi2nMaxSA
double chi2nMaxSA
Definition: AlignmentMuonSelector.h:59
AlignmentMuonSelector::basicCuts
Muons basicCuts(const Muons &muons) const
apply basic cuts on pt,eta,phi,nhit
Definition: AlignmentMuonSelector.cc:94
AlignmentMuonSelector::ptMin
double ptMin
Definition: AlignmentMuonSelector.h:58
reco::LeafCandidate::p
double p() const final
magnitude of momentum vector
Definition: LeafCandidate.h:123
EgHLTOffHistBins_cfi.mass
mass
Definition: EgHLTOffHistBins_cfi.py:34
ALCARECOTkAlBeamHalo_cff.etaMax
etaMax
Definition: ALCARECOTkAlBeamHalo_cff.py:33
AlignmentMuonSelector::Muons
std::vector< const reco::Muon * > Muons
Definition: AlignmentMuonSelector.h:28
AlignmentMuonSelector::theBestMassPairCombinationMuons
Muons theBestMassPairCombinationMuons(const Muons &muons) const
filter only those muons giving best mass pair combination
Definition: AlignmentMuonSelector.cc:160
reco::Muon::isStandAloneMuon
bool isStandAloneMuon() const override
Definition: Muon.h:301
AlignmentMuonSelector::nHitMaxGB
double nHitMaxGB
Definition: AlignmentMuonSelector.h:60
AlignmentMuonSelector_cfi.minMassPair
minMassPair
Definition: AlignmentMuonSelector_cfi.py:44
AlignmentTrackSelector_cfi.applyNHighestPt
applyNHighestPt
Definition: AlignmentTrackSelector_cfi.py:60
mps_fire.result
result
Definition: mps_fire.py:311
AlignmentMuonSelector::theNHighestPtMuons
Muons theNHighestPtMuons(const Muons &muons) const
filter the n highest pt muons
Definition: AlignmentMuonSelector.cc:139
ParameterSet.h
AlignmentMuonSelector::nHitMinGB
double nHitMinGB
Definition: AlignmentMuonSelector.h:60
edm::Event
Definition: Event.h:73
AlignmentMuonSelector::select
Muons select(const Muons &muons, const edm::Event &evt) const
select muons
Definition: AlignmentMuonSelector.cc:62
AlignmentMuonSelector::chi2nMaxGB
double chi2nMaxGB
Definition: AlignmentMuonSelector.h:60
reco::Muon::standAloneMuon
TrackRef standAloneMuon() const override
reference to a stand-alone muon Track
Definition: Muon.h:49
AlignmentMuonSelector::nHitMinSA
double nHitMinSA
Definition: AlignmentMuonSelector.h:59