CMS 3D CMS Logo

ZToMuMuSelector.cc
Go to the documentation of this file.
1 /* \class ZToMuMuSelector
2  *
3  * \author Juan Alcaraz, CIEMAT
4  *
5  */
11 
13 public:
15  bool filter(edm::Event &, const edm::EventSetup &) override;
16 
17 private:
20  double ptCut_;
21  double etaCut_;
22  double massZMin_;
23  double massZMax_;
24 
29 };
30 
35 
36 using namespace edm;
37 using namespace std;
38 using namespace reco;
39 
41  : muonToken_(consumes<TrackCollection>(cfg.getParameter<edm::InputTag>("MuonTag"))),
42  isoToken_(consumes<edm::ValueMap<bool> >(cfg.getParameter<edm::InputTag>("IsolationTag"))),
43  ptCut_(cfg.getParameter<double>("PtCut")),
44  etaCut_(cfg.getParameter<double>("EtaCut")),
45  massZMin_(cfg.getParameter<double>("MassZMin")),
46  massZMax_(cfg.getParameter<double>("MassZMax")),
47 
48  onlyGlobalMuons_(cfg.getParameter<bool>("OnlyGlobalMuons")),
49  trackerToken_(mayConsume<TrackCollection>(
50  cfg.getUntrackedParameter<edm::InputTag>("TrackerTag", edm::InputTag("ctfWithMaterialTracks")))),
51  isoTrackerToken_(mayConsume<edm::ValueMap<bool> >(
52  cfg.getUntrackedParameter<edm::InputTag>("TrackerIsolationTag", edm::InputTag("zMuMuTrackerIsolations")))),
53  minTrackerHits_(cfg.getUntrackedParameter<int>("MinTrackerHits", 7)) {}
54 
57  ev.getByToken(muonToken_, muonCollection);
58  if (!muonCollection.isValid()) {
59  LogTrace("") << ">>> Muon collection does not exist !!!";
60  return false;
61  }
62 
64  ev.getByToken(isoToken_, isoMap);
65  if (!isoMap.isValid()) {
66  LogTrace("") << ">>> ISO Muon collection does not exist !!!";
67  return false;
68  }
69 
70  Handle<TrackCollection> trackerCollection;
71  Handle<edm::ValueMap<bool> > isoTrackerMap;
72  if (!onlyGlobalMuons_) {
73  ev.getByToken(trackerToken_, trackerCollection);
74  if (!trackerCollection.isValid()) {
75  LogTrace("") << ">>> Tracker collection does not exist !!!";
76  return false;
77  }
78 
79  ev.getByToken(isoTrackerToken_, isoTrackerMap);
80  if (!isoTrackerMap.isValid()) {
81  LogTrace("") << ">>> ISO Tracker collection does not exist !!!";
82  return false;
83  }
84  }
85 
86  unsigned int npairs = 0;
87  bool globalCombinationFound = false;
88  for (unsigned int i = 0; i < muonCollection->size(); i++) {
90  LogTrace("") << "> Processing muon number " << i << "...";
91  double pt = mu->pt();
92  LogTrace("") << "\t... pt= " << pt << " GeV";
93  if (pt < ptCut_)
94  continue;
95  double eta = mu->eta();
96  LogTrace("") << "\t... eta= " << eta;
97  if (fabs(eta) > etaCut_)
98  continue;
99  bool iso = (*isoMap)[mu];
100  LogTrace("") << "\t... isolated? " << iso;
101  if (!iso)
102  continue;
103 
104  for (unsigned int j = i + 1; j < muonCollection->size(); j++) {
105  TrackRef mu2(muonCollection, j);
106  LogTrace("") << "> Processing second muon number " << j << "...";
107  double pt2 = mu2->pt();
108  LogTrace("") << "\t... pt2= " << pt2 << " GeV";
109  if (pt2 < ptCut_)
110  continue;
111  double eta2 = mu2->eta();
112  LogTrace("") << "\t... eta2= " << eta2;
113  if (fabs(eta2) > etaCut_)
114  continue;
115  bool iso2 = (*isoMap)[mu2];
116  LogTrace("") << "\t... isolated2? " << iso2;
117  if (!iso2)
118  continue;
119 
120  double z_en = mu->p() + mu2->p();
121  double z_px = mu->px() + mu2->px();
122  double z_py = mu->py() + mu2->py();
123  double z_pz = mu->pz() + mu2->pz();
124  double massZ = z_en * z_en - z_px * z_px - z_py * z_py - z_pz * z_pz;
125  massZ = (massZ > 0) ? sqrt(massZ) : 0;
126  LogTrace("") << "\t... Z_en, Z_px, Z_py, Z_pz= " << z_en << ", " << z_px << ", " << z_py << ", " << z_pz
127  << " GeV";
128  LogTrace("") << "\t... (GM-GM) Invariant reconstructed mass= " << massZ << " GeV";
129  if (massZ < massZMin_)
130  continue;
131  if (massZ > massZMax_)
132  continue;
133  globalCombinationFound = true;
134  npairs++;
135  }
136 
137  if (onlyGlobalMuons_ || globalCombinationFound)
138  continue;
139 
140  for (unsigned int j = 0; j < trackerCollection->size(); j++) {
141  TrackRef mu2(trackerCollection, j);
142  LogTrace("") << "> Processing track number " << j << "...";
143  double pt2 = mu2->pt();
144  LogTrace("") << "\t... pt3= " << pt2 << " GeV";
145  if (pt2 < ptCut_)
146  continue;
147  double eta2 = mu2->eta();
148  LogTrace("") << "\t... eta3= " << eta2;
149  if (fabs(eta2) > etaCut_)
150  continue;
151  int nhits2 = mu2->numberOfValidHits();
152  LogTrace("") << "\t... nhits3= " << nhits2;
153  if (nhits2 < minTrackerHits_)
154  continue;
155  bool iso2 = (*isoTrackerMap)[mu2];
156  LogTrace("") << "\t... isolated3? " << iso2;
157  if (!iso2)
158  continue;
159 
160  double z_en = mu->p() + mu2->p();
161  double z_px = mu->px() + mu2->px();
162  double z_py = mu->py() + mu2->py();
163  double z_pz = mu->pz() + mu2->pz();
164  double massZ = z_en * z_en - z_px * z_px - z_py * z_py - z_pz * z_pz;
165  massZ = (massZ > 0) ? sqrt(massZ) : 0;
166  LogTrace("") << "\t... Z_en, Z_px, Z_py, Z_pz= " << z_en << ", " << z_px << ", " << z_py << ", " << z_pz
167  << " GeV";
168  LogTrace("") << "\t... (GM-TK) Invariant reconstructed mass= " << massZ << " GeV";
169  if (massZ < massZMin_)
170  continue;
171  if (massZ > massZMax_)
172  continue;
173  npairs++;
174  }
175  }
176 
177  LogTrace("") << "> Number of Z pairs found= " << npairs;
178  if (npairs < 1) {
179  LogTrace("") << ">>>> Event REJECTED";
180  return false;
181  }
182  LogTrace("") << ">>>> Event SELECTED!!!";
183 
184  return true;
185 }
186 
188 
ZToMuMuSelector::ZToMuMuSelector
ZToMuMuSelector(const edm::ParameterSet &)
Definition: ZToMuMuSelector.cc:40
Handle.h
electrons_cff.bool
bool
Definition: electrons_cff.py:393
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
ZToMuMuSelector::isoTrackerToken_
edm::EDGetTokenT< edm::ValueMap< bool > > isoTrackerToken_
Definition: ZToMuMuSelector.cc:27
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
amptDefaultParameters_cff.mu
mu
Definition: amptDefaultParameters_cff.py:16
edm::EDGetTokenT< reco::TrackCollection >
edm
HLT enums.
Definition: AlignableModifier.h:19
ZToMuMuSelector::ptCut_
double ptCut_
Definition: ZToMuMuSelector.cc:20
EDFilter.h
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
edm::Handle
Definition: AssociativeIterator.h:50
edm::Ref< TrackCollection >
ZToMuMuSelector::isoToken_
edm::EDGetTokenT< edm::ValueMap< bool > > isoToken_
Definition: ZToMuMuSelector.cc:19
MakerMacros.h
Track.h
TrackFwd.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
PVValHelper::eta
Definition: PVValidationHelpers.h:69
ZToMuMuSelector::minTrackerHits_
int minTrackerHits_
Definition: ZToMuMuSelector.cc:28
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
ZToMuMuSelector::filter
bool filter(edm::Event &, const edm::EventSetup &) override
Definition: ZToMuMuSelector.cc:55
HLT_FULL_cff.eta2
eta2
Definition: HLT_FULL_cff.py:9542
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
createfilelist.int
int
Definition: createfilelist.py:10
edm::EDFilter
Definition: EDFilter.h:38
edm::EventSetup
Definition: EventSetup.h:57
HLT_FULL_cff.pt2
pt2
Definition: HLT_FULL_cff.py:9872
pdwgLeptonRecoSkim_cfi.muonCollection
muonCollection
Definition: pdwgLeptonRecoSkim_cfi.py:7
InputTag.h
looper.cfg
cfg
Definition: looper.py:297
ValueMap.h
ZToMuMuSelector::massZMin_
double massZMin_
Definition: ZToMuMuSelector.cc:22
ZToMuMuSelector::onlyGlobalMuons_
bool onlyGlobalMuons_
Definition: ZToMuMuSelector.cc:25
std
Definition: JetResolutionObject.h:76
edm::ValueMap
Definition: ValueMap.h:107
ev
bool ev
Definition: Hydjet2Hadronizer.cc:95
ZToMuMuSelector::trackerToken_
edm::EDGetTokenT< reco::TrackCollection > trackerToken_
Definition: ZToMuMuSelector.cc:26
ZToMuMuSelector::etaCut_
double etaCut_
Definition: ZToMuMuSelector.cc:21
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:224
ParameterSet.h
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
ZToMuMuSelector::muonToken_
edm::EDGetTokenT< reco::TrackCollection > muonToken_
Definition: ZToMuMuSelector.cc:18
ZToMuMuSelector::massZMax_
double massZMax_
Definition: ZToMuMuSelector.cc:23
reco::TrackCollection
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
ZToMuMuSelector
Definition: ZToMuMuSelector.cc:12