CMS 3D CMS Logo

ZMuMuMuonUserData.cc
Go to the documentation of this file.
9 
15 
19 
20 #include <vector>
21 
22 using namespace edm;
23 using namespace std;
24 using namespace reco;
25 using namespace isodeposit;
26 //using namespace pat;
27 
29 public:
31 
32 private:
33  void produce(edm::Event &, const edm::EventSetup &) override;
34 
38  double alpha_, beta_;
39  double ptThreshold_, etEcalThreshold_, etHcalThreshold_, dRVetoTrk_, dRTrk_, dREcal_, dRHcal_;
40  string hltPath_;
41  template <typename T>
42  vector<double> isolation(const T &t,
43  double ptThreshold,
44  double etEcalThreshold,
45  double etHcalThreshold,
46  double dRVetoTrk,
47  double dRTrk,
48  double dREcal,
49  double dRHcal,
50  double alpha,
51  double beta);
52 };
53 
54 template <typename T>
55 vector<double> ZMuMuMuonUserData::isolation(const T &t,
56  double ptThreshold,
57  double etEcalThreshold,
58  double etHcalThreshold,
59  double dRVetoTrk,
60  double dRTrk,
61  double dREcal,
62  double dRHcal,
63  double alpha,
64  double beta) {
65  vector<double> iso;
66  const pat::IsoDeposit *trkIso = t.isoDeposit(pat::TrackIso);
67  const pat::IsoDeposit *ecalIso = t.isoDeposit(pat::EcalIso);
68  const pat::IsoDeposit *hcalIso = t.isoDeposit(pat::HcalIso);
69 
70  Direction dir = Direction(t.eta(), t.phi());
71 
73  vetosTrk.push_back(new ConeVeto(dir, dRVetoTrk));
74  vetosTrk.push_back(new ThresholdVeto(ptThreshold));
75 
76  pat::IsoDeposit::AbsVetos vetosEcal;
77  vetosEcal.push_back(new ConeVeto(dir, 0.));
78  vetosEcal.push_back(new ThresholdVeto(etEcalThreshold));
79 
80  pat::IsoDeposit::AbsVetos vetosHcal;
81  vetosHcal.push_back(new ConeVeto(dir, 0.));
82  vetosHcal.push_back(new ThresholdVeto(etHcalThreshold));
83 
84  double isovalueTrk = (trkIso->sumWithin(dRTrk, vetosTrk));
85  double isovalueEcal = (ecalIso->sumWithin(dREcal, vetosEcal));
86  double isovalueHcal = (hcalIso->sumWithin(dRHcal, vetosHcal));
87 
88  iso.push_back(isovalueTrk);
89  //cout<<"isoTrk"<<isovalueTrk<<" "<<t.trackIso()<<endl;
90  iso.push_back(isovalueEcal);
91  //cout<<"isoEcal"<<isovalueEcal<<" "<<t.ecalIso()<<endl;
92  iso.push_back(isovalueHcal);
93  //cout<<"isoHcal"<<isovalueHcal<<" "<<t.hcalIso()<<endl;
94  //double isovalueTrk = t.trackIso();
95  //double isovalueEcal = t.ecalIso();
96  //double isovalueHcal = t.hcalIso();
97 
98  //double iso = isovalueTrk + isovalueEcal + isovalueHcal;
99  double combIso =
100  alpha * (((1 + beta) / 2 * isovalueEcal) + ((1 - beta) / 2 * isovalueHcal)) + ((1 - alpha) * isovalueTrk);
101  iso.push_back(combIso);
102  //cout<<"combIso"<<iso[3]<<endl;
103 
104  double relIso = combIso /= t.pt();
105  iso.push_back(relIso);
106  //cout<<"relIso"<<iso[4]<<endl;
107  return iso;
108 }
109 
111  : srcToken_(consumes<vector<pat::Muon> >(cfg.getParameter<InputTag>("src"))),
112  beamSpotToken_(consumes<BeamSpot>(cfg.getParameter<InputTag>("beamSpot"))),
113  primaryVerticesToken_(consumes<VertexCollection>(cfg.getParameter<InputTag>("primaryVertices"))),
114  alpha_(cfg.getParameter<double>("alpha")),
115  beta_(cfg.getParameter<double>("beta")),
116  ptThreshold_(cfg.getParameter<double>("ptThreshold")),
117  etEcalThreshold_(cfg.getParameter<double>("etEcalThreshold")),
118  etHcalThreshold_(cfg.getParameter<double>("etHcalThreshold")),
119  dRVetoTrk_(cfg.getParameter<double>("dRVetoTrk")),
120  dRTrk_(cfg.getParameter<double>("dRTrk")),
121  dREcal_(cfg.getParameter<double>("dREcal")),
122  dRHcal_(cfg.getParameter<double>("dRHcal")),
123  hltPath_(cfg.getParameter<std::string>("hltPath")) {
124  produces<std::vector<pat::Muon> >();
125 }
126 
129  evt.getByToken(srcToken_, muons);
130 
131  Handle<BeamSpot> beamSpotHandle;
132  evt.getByToken(beamSpotToken_, beamSpotHandle);
133 
134  Handle<VertexCollection> primaryVertices; // Collection of primary Vertices
136 
137  unique_ptr<vector<pat::Muon> > muonColl(new vector<pat::Muon>(*muons));
138  for (unsigned int i = 0; i < muonColl->size(); ++i) {
139  pat::Muon &m = (*muonColl)[i];
140  //pat::Muon *mu = new pat::Muon(m);
141  vector<double> iso = isolation(
143  m.setIsolation(pat::User1Iso, iso[0]);
144  //cout<<"muon User1Iso "<<iso[0]<<endl;
145  m.setIsolation(pat::User2Iso, iso[1]);
146  //cout<<"iso2 "<<iso[1]<<endl;
147  m.setIsolation(pat::User3Iso, iso[2]);
148  //cout<<"iso3 "<<iso[2]<<endl;
149  m.setIsolation(pat::User4Iso, iso[3]);
150  //cout<<"iso4 "<<iso[3]<<endl;
151  m.setIsolation(pat::User5Iso, iso[4]);
152  //cout<<"iso5 "<<iso[4]<<endl;
153  float zDauMuEnergyEm = m.calEnergy().em;
154  float zDauMuEnergyHad = m.calEnergy().had;
155  TrackRef muGlbRef = m.globalTrack();
156  TrackRef muTrkRef = m.innerTrack();
157  TrackRef muSaRef = m.outerTrack();
158  float zDaudxyFromBS = -1;
159  float zDaudzFromBS = -1;
160  float zDaudxyFromPV = -1;
161  float zDaudzFromPV = -1;
162  int zDauNofMuChambers = m.numberOfChambers();
163  int zDauNofMuMatches = m.numberOfMatches();
164  // for the following variables looking at global/trk and sta at the same time
165  float zDauChi2 = -1;
166  float zDauTrkChi2 = -1;
167  float zDauSaChi2 = -1;
168  float zDauNofMuonHits = -1;
169  float zDauSaNofMuonHits = -1;
170  float zDauNofStripHits = -1;
171  float zDauTrkNofStripHits = -1;
172  float zDauNofPixelHits = -1;
173  float zDauTrkNofPixelHits = -1;
174 
175  if (muGlbRef.isNonnull() && m.isGlobalMuon() == true) {
176  zDaudxyFromBS = muGlbRef->dxy(beamSpotHandle->position());
177  zDaudzFromBS = muGlbRef->dz(beamSpotHandle->position());
178  zDaudxyFromPV = muGlbRef->dxy(primaryVertices->begin()->position());
179  zDaudzFromPV = muGlbRef->dz(primaryVertices->begin()->position());
180  zDauChi2 = muGlbRef->normalizedChi2();
181  zDauTrkChi2 = muTrkRef->normalizedChi2();
182  zDauSaChi2 = muSaRef->normalizedChi2();
183  zDauNofMuonHits = muGlbRef->hitPattern().numberOfValidMuonHits();
184  zDauSaNofMuonHits = muSaRef->hitPattern().numberOfValidMuonHits();
185  zDauNofStripHits = muGlbRef->hitPattern().numberOfValidStripHits();
186  zDauTrkNofStripHits = muTrkRef->hitPattern().numberOfValidStripHits();
187  zDauNofPixelHits = muGlbRef->hitPattern().numberOfValidPixelHits();
188  zDauTrkNofPixelHits = muTrkRef->hitPattern().numberOfValidPixelHits();
189  } else if (muSaRef.isNonnull() && m.isStandAloneMuon() == true) {
190  zDaudxyFromBS = muSaRef->dxy(beamSpotHandle->position());
191  zDaudzFromBS = muSaRef->dz(beamSpotHandle->position());
192  zDaudxyFromPV = muSaRef->dxy(primaryVertices->begin()->position());
193  zDaudzFromPV = muSaRef->dz(primaryVertices->begin()->position());
194  zDauSaChi2 = muSaRef->normalizedChi2();
195  zDauSaNofMuonHits = muSaRef->hitPattern().numberOfValidMuonHits();
196 
197  } else if (muTrkRef.isNonnull() && m.isTrackerMuon() == true) {
198  zDaudxyFromBS = muTrkRef->dxy(beamSpotHandle->position());
199  zDaudzFromBS = muTrkRef->dz(beamSpotHandle->position());
200  zDaudxyFromPV = muTrkRef->dxy(primaryVertices->begin()->position());
201  zDaudzFromPV = muTrkRef->dz(primaryVertices->begin()->position());
202  zDauTrkChi2 = muTrkRef->normalizedChi2();
203  zDauTrkNofStripHits = muTrkRef->hitPattern().numberOfValidStripHits();
204  zDauTrkNofPixelHits = muTrkRef->hitPattern().numberOfValidPixelHits();
205  }
206 
207  const pat::TriggerObjectStandAloneCollection muHLTMatches = m.triggerObjectMatchesByPath(hltPath_);
208  float muHLTBit;
209  int dimTrig = muHLTMatches.size();
210  if (dimTrig != 0) {
211  muHLTBit = 1;
212  } else {
213  muHLTBit = 0;
214  }
215  m.addUserFloat("zDau_dxyFromBS", zDaudxyFromBS);
216  m.addUserFloat("zDau_dzFromBS", zDaudzFromBS);
217  m.addUserFloat("zDau_dxyFromPV", zDaudxyFromPV);
218  m.addUserFloat("zDau_dzFromPV", zDaudzFromPV);
219  m.addUserFloat("zDau_HLTBit", muHLTBit);
220  m.addUserFloat("zDau_dzFromPV", zDaudzFromPV);
221  m.addUserFloat("zDau_Chi2", zDauChi2);
222  m.addUserFloat("zDau_TrkChi2", zDauTrkChi2);
223  m.addUserFloat("zDau_SaChi2", zDauSaChi2);
224  m.addUserFloat("zDau_NofMuonHits", zDauNofMuonHits);
225  m.addUserFloat("zDau_SaNofMuonHits", zDauSaNofMuonHits);
226  m.addUserFloat("zDau_NofStripHits", zDauNofStripHits);
227  m.addUserFloat("zDau_TrkNofStripHits", zDauTrkNofStripHits);
228  m.addUserFloat("zDau_NofPixelHits", zDauNofPixelHits);
229  m.addUserFloat("zDau_TrkNofPixelHits", zDauTrkNofPixelHits);
230  m.addUserFloat("zDau_NofMuChambers", zDauNofMuChambers);
231  m.addUserFloat("zDau_NofMuMatches", zDauNofMuMatches);
232  m.addUserFloat("zDau_MuEnergyEm", zDauMuEnergyEm);
233  m.addUserFloat("zDau_MuEnergyHad", zDauMuEnergyHad);
234  }
235 
236  evt.put(std::move(muonColl));
237 }
238 
240 
ewkMuLumiMonitorDQM_cfi.ptThreshold
ptThreshold
Definition: ewkMuLumiMonitorDQM_cfi.py:13
ZMuMuMuonUserData::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: ZMuMuMuonUserData.cc:127
pat::User3Iso
Definition: Isolation.h:19
PDWG_BPHSkim_cff.muons
muons
Definition: PDWG_BPHSkim_cff.py:47
Handle.h
zMuMuMuonUserData.dRHcal
dRHcal
Definition: zMuMuMuonUserData.py:19
mps_fire.i
i
Definition: mps_fire.py:428
pat::EcalIso
Definition: Isolation.h:11
IsoDepositVetos.h
EDProducer.h
zMuMuMuonUserData.alpha
alpha
zGenParticlesMatch = cms.InputTag(""),
Definition: zMuMuMuonUserData.py:9
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
zMuMuMuonUserData.beta
beta
Definition: zMuMuMuonUserData.py:10
ZMuMuCategoriesSequences_cff.trkIso
trkIso
Definition: ZMuMuCategoriesSequences_cff.py:140
Muon.h
reco::VertexCollection
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
pat::User5Iso
Definition: Isolation.h:21
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
pat::Muon
Analysis-level muon class.
Definition: Muon.h:51
ZMuMuMuonUserData::etHcalThreshold_
double etHcalThreshold_
Definition: ZMuMuMuonUserData.cc:39
edm::Handle
Definition: AssociativeIterator.h:50
IsoDepositDirection.h
Muon
Definition: Muon.py:1
edm::Ref< TrackCollection >
EDMException.h
ZMuMuMuonUserData::dREcal_
double dREcal_
Definition: ZMuMuMuonUserData.cc:39
pat::User4Iso
Definition: Isolation.h:20
reco::isodeposit::ConeVeto
Definition: IsoDepositVetos.h:9
MakerMacros.h
pat::User1Iso
Definition: Isolation.h:17
ZMuMuMuonUserData::alpha_
double alpha_
Definition: ZMuMuMuonUserData.cc:38
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
BeamSpot.h
zMuMuMuonUserData.dREcal
dREcal
Definition: zMuMuMuonUserData.py:18
ZMuMuMuonUserData
Definition: ZMuMuMuonUserData.cc:28
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
objects.autophobj.relIso
relIso
Definition: autophobj.py:169
zMuMuMuonUserData.dRTrk
dRTrk
Definition: zMuMuMuonUserData.py:17
reco::BeamSpot
Definition: BeamSpot.h:21
reco::IsoDeposit::AbsVetos
isodeposit::AbsVetos AbsVetos
Definition: IsoDeposit.h:53
ZMuMuMuonUserData::ptThreshold_
double ptThreshold_
Definition: ZMuMuMuonUserData.cc:39
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:531
Isolation.h
reco::BeamSpot::position
const Point & position() const
position
Definition: BeamSpot.h:59
IsoDeposit.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
Vertex.h
TFileService.h
ZMuMuMuonUserData::srcToken_
EDGetTokenT< vector< pat::Muon > > srcToken_
Definition: ZMuMuMuonUserData.cc:35
pat::User2Iso
Definition: Isolation.h:18
ZMuMuMuonUserData::beamSpotToken_
EDGetTokenT< BeamSpot > beamSpotToken_
Definition: ZMuMuMuonUserData.cc:36
edm::ParameterSet
Definition: ParameterSet.h:47
zMuMuMuonUserData.primaryVertices
primaryVertices
Definition: zMuMuMuonUserData.py:12
Event.h
zMuMuMuonUserData.dRVetoTrk
dRVetoTrk
Definition: zMuMuMuonUserData.py:16
edm::Ref::isNonnull
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
pat::TrackIso
Definition: Isolation.h:10
reco::IsoDeposit::sumWithin
double sumWithin(double coneSize, const AbsVetos &vetos=AbsVetos(), bool skipDepositVeto=false) const
Definition: IsoDeposit.cc:137
ZMuMuMuonUserData::dRVetoTrk_
double dRVetoTrk_
Definition: ZMuMuMuonUserData.cc:39
pat::HcalIso
Definition: Isolation.h:12
pat::TriggerObjectStandAloneCollection
std::vector< TriggerObjectStandAlone > TriggerObjectStandAloneCollection
Collection of TriggerObjectStandAlone.
Definition: TriggerObjectStandAlone.h:219
ZMuMuMuonUserData::hltPath_
string hltPath_
Definition: ZMuMuMuonUserData.cc:40
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
ZMuMuMuonUserData::dRHcal_
double dRHcal_
Definition: ZMuMuMuonUserData.cc:39
zMuMuMuonUserData.etEcalThreshold
etEcalThreshold
Definition: zMuMuMuonUserData.py:14
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
edm::EventSetup
Definition: EventSetup.h:57
pat
Definition: HeavyIon.h:7
InputTag.h
reco::isodeposit::ThresholdVeto
Definition: IsoDepositVetos.h:21
looper.cfg
cfg
Definition: looper.py:297
VertexFwd.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
T
long double T
Definition: Basic3DVectorLD.h:48
ZMuMuMuonUserData::beta_
double beta_
Definition: ZMuMuMuonUserData.cc:38
reco::isodeposit::Direction
Definition: IsoDepositDirection.h:19
reco::IsoDeposit
Definition: IsoDeposit.h:49
edm::EDProducer
Definition: EDProducer.h:35
ZMuMuMuonUserData::dRTrk_
double dRTrk_
Definition: ZMuMuMuonUserData.cc:39
IsoDepositFwd.h
ZMuMuMuonUserData::ZMuMuMuonUserData
ZMuMuMuonUserData(const edm::ParameterSet &)
Definition: ZMuMuMuonUserData.cc:110
ParameterSet.h
ZMuMuMuonUserData::etEcalThreshold_
double etEcalThreshold_
Definition: ZMuMuMuonUserData.cc:39
edm::Event
Definition: Event.h:73
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
edm::InputTag
Definition: InputTag.h:15
zMuMuMuonUserData.etHcalThreshold
etHcalThreshold
Definition: zMuMuMuonUserData.py:15
isolation
double isolation
Definition: AssociatedVariableMaxCutCandRefSelector.cc:25
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23
ZMuMuMuonUserData::primaryVerticesToken_
EDGetTokenT< VertexCollection > primaryVerticesToken_
Definition: ZMuMuMuonUserData.cc:37
ZMuMuMuonUserData::isolation
vector< double > isolation(const T &t, double ptThreshold, double etEcalThreshold, double etHcalThreshold, double dRVetoTrk, double dRTrk, double dREcal, double dRHcal, double alpha, double beta)
Definition: ZMuMuMuonUserData.cc:55