CMS 3D CMS Logo

ZMuMuTrackUserData.cc
Go to the documentation of this file.
8 
14 
18 
19 #include <vector>
20 
21 using namespace edm;
22 using namespace std;
23 using namespace reco;
24 using namespace isodeposit;
25 //using namespace pat;
26 
28 public:
30 
31 private:
32  void produce(edm::Event &, const edm::EventSetup &) override;
33 
37  double ptThreshold_, etEcalThreshold_, etHcalThreshold_, dRVetoTrk_, dRTrk_, dREcal_, dRHcal_;
38  double alpha_, beta_;
39  template <typename T>
40  vector<double> isolation(const T &t,
41  double ptThreshold,
42  double etEcalThreshold,
43  double etHcalThreshold,
44  double dRVetoTrk,
45  double dRTrk,
46  double dREcal,
47  double dRHcal,
48  double alpha,
49  double beta);
50 };
51 
52 template <typename T>
53 vector<double> ZMuMuTrackUserData::isolation(const T &t,
54  double ptThreshold,
55  double etEcalThreshold,
56  double etHcalThreshold,
57  double dRVetoTrk,
58  double dRTrk,
59  double dREcal,
60  double dRHcal,
61  double alpha,
62  double beta) {
63  vector<double> iso;
64  const pat::IsoDeposit *trkIso = t.isoDeposit(pat::TrackIso);
65  const pat::IsoDeposit *ecalIso = t.isoDeposit(pat::EcalIso);
66  const pat::IsoDeposit *hcalIso = t.isoDeposit(pat::HcalIso);
67 
68  Direction dir = Direction(t.eta(), t.phi());
69 
71  vetosTrk.push_back(new ConeVeto(dir, dRVetoTrk));
72  vetosTrk.push_back(new ThresholdVeto(ptThreshold));
73 
74  pat::IsoDeposit::AbsVetos vetosEcal;
75  vetosEcal.push_back(new ConeVeto(dir, 0.));
76  vetosEcal.push_back(new ThresholdVeto(etEcalThreshold));
77 
78  pat::IsoDeposit::AbsVetos vetosHcal;
79  vetosHcal.push_back(new ConeVeto(dir, 0.));
80  vetosHcal.push_back(new ThresholdVeto(etHcalThreshold));
81 
82  double isovalueTrk = (trkIso->sumWithin(dRTrk, vetosTrk));
83  double isovalueEcal = (ecalIso->sumWithin(dREcal, vetosEcal));
84  double isovalueHcal = (hcalIso->sumWithin(dRHcal, vetosHcal));
85 
86  iso.push_back(isovalueTrk);
87  iso.push_back(isovalueEcal);
88  iso.push_back(isovalueHcal);
89 
90  //double iso = isovalueTrk + isovalueEcal + isovalueHcal;
91  double combIso =
92  alpha * (((1 + beta) / 2 * isovalueEcal) + ((1 - beta) / 2 * isovalueHcal)) + ((1 - alpha) * isovalueTrk);
93 
94  iso.push_back(combIso);
95  double relIso = combIso /= t.pt();
96  iso.push_back(relIso);
97  return iso;
98 }
99 
101  : srcToken_(consumes<vector<pat::GenericParticle> >(cfg.getParameter<InputTag>("src"))),
102  beamSpotToken_(consumes<BeamSpot>(cfg.getParameter<InputTag>("beamSpot"))),
103  primaryVerticesToken_(consumes<VertexCollection>(cfg.getParameter<InputTag>("primaryVertices"))),
104  ptThreshold_(cfg.getParameter<double>("ptThreshold")),
105  etEcalThreshold_(cfg.getParameter<double>("etEcalThreshold")),
106  etHcalThreshold_(cfg.getParameter<double>("etHcalThreshold")),
107  dRVetoTrk_(cfg.getParameter<double>("dRVetoTrk")),
108  dRTrk_(cfg.getParameter<double>("dRTrk")),
109  dREcal_(cfg.getParameter<double>("dREcal")),
110  dRHcal_(cfg.getParameter<double>("dRHcal")),
111  alpha_(cfg.getParameter<double>("alpha")),
112  beta_(cfg.getParameter<double>("beta")) {
113  produces<std::vector<pat::GenericParticle> >();
114 }
115 
119 
120  Handle<BeamSpot> beamSpotHandle;
121  evt.getByToken(beamSpotToken_, beamSpotHandle);
122 
123  Handle<VertexCollection> primaryVertices; // Collection of primary Vertices
125 
126  unique_ptr<vector<pat::GenericParticle> > tkColl(new vector<pat::GenericParticle>(*tracks));
127  for (unsigned int i = 0; i < tkColl->size(); ++i) {
128  pat::GenericParticle &tk = (*tkColl)[i];
129  vector<double> iso = isolation(
131  tk.setIsolation(pat::User1Iso, iso[0]);
132  // cout << "track User1Iso " << iso[0] << endl;
133  tk.setIsolation(pat::User2Iso, iso[1]);
134  //cout << "track User2Iso " << iso[1] << endl;
135  tk.setIsolation(pat::User3Iso, iso[2]);
136  //cout << "track User3Iso " << iso[2] << endl;
137  tk.setIsolation(pat::User4Iso, iso[3]);
138  //cout << "track User4Iso " << iso[3] << endl;
139  tk.setIsolation(pat::User5Iso, iso[4]);
140  //cout << "track User5Iso " << iso[4] << endl;
141 
142  float zDaudxyFromBS = -1;
143  float zDaudzFromBS = -1;
144  float zDaudxyFromPV = -1;
145  float zDaudzFromPV = -1;
146  float zDauNofMuChambers = -1;
147  float zDauNofMuMatches = -1;
148  float zDauChi2 = -1;
149  float zDauTrkChi2 = -1;
150  float zDauSaChi2 = -1;
151  float zDauNofMuonHits = -1;
152  float zDauNofStripHits = -1;
153  float zDauNofPixelHits = -1;
154  float zDauMuEnergyEm = -1;
155  float zDauMuEnergyHad = -1;
156 
157  TrackRef muTrkRef = tk.track();
158  if (muTrkRef.isNonnull()) {
159  zDaudxyFromBS = muTrkRef->dxy(beamSpotHandle->position());
160  zDaudzFromBS = muTrkRef->dz(beamSpotHandle->position());
161  zDaudxyFromPV = muTrkRef->dxy(primaryVertices->begin()->position());
162  zDaudzFromPV = muTrkRef->dz(primaryVertices->begin()->position());
163  zDauChi2 = muTrkRef->normalizedChi2();
164  zDauTrkChi2 = muTrkRef->normalizedChi2();
165  zDauNofStripHits = muTrkRef->hitPattern().numberOfValidStripHits();
166  zDauNofPixelHits = muTrkRef->hitPattern().numberOfValidPixelHits();
167  }
168  tk.addUserFloat("zDau_dxyFromBS", zDaudxyFromBS);
169  tk.addUserFloat("zDau_dzFromBS", zDaudzFromBS);
170  tk.addUserFloat("zDau_dxyFromPV", zDaudxyFromPV);
171  tk.addUserFloat("zDau_dzFromPV", zDaudzFromPV);
172  tk.addUserFloat("zDau_NofMuonHits", zDauNofMuonHits);
173  tk.addUserFloat("zDau_TrkNofStripHits", zDauNofStripHits);
174  tk.addUserFloat("zDau_TrkNofPixelHits", zDauNofPixelHits);
175  tk.addUserFloat("zDau_NofMuChambers", zDauNofMuChambers);
176  tk.addUserFloat("zDau_NofMuMatches", zDauNofMuMatches);
177  tk.addUserFloat("zDau_Chi2", zDauChi2);
178  tk.addUserFloat("zDau_TrkChi2", zDauTrkChi2);
179  tk.addUserFloat("zDau_SaChi2", zDauSaChi2);
180  tk.addUserFloat("zDau_MuEnergyEm", zDauMuEnergyEm);
181  tk.addUserFloat("zDau_MuEnergyHad", zDauMuEnergyHad);
182  }
183 
184  evt.put(std::move(tkColl));
185 }
186 
188 
ewkMuLumiMonitorDQM_cfi.ptThreshold
ptThreshold
Definition: ewkMuLumiMonitorDQM_cfi.py:13
ZMuMuTrackUserData::dRVetoTrk_
double dRVetoTrk_
Definition: ZMuMuTrackUserData.cc:37
pat::User3Iso
Definition: Isolation.h:19
Handle.h
PDWG_EXOHSCP_cff.tracks
tracks
Definition: PDWG_EXOHSCP_cff.py:28
zMuMuMuonUserData.dRHcal
dRHcal
Definition: zMuMuMuonUserData.py:19
mps_fire.i
i
Definition: mps_fire.py:355
pat::EcalIso
Definition: Isolation.h:11
ZMuMuTrackUserData::dREcal_
double dREcal_
Definition: ZMuMuTrackUserData.cc:37
IsoDepositVetos.h
ZMuMuTrackUserData::etEcalThreshold_
double etEcalThreshold_
Definition: ZMuMuTrackUserData.cc:37
EDProducer.h
ZMuMuTrackUserData::ptThreshold_
double ptThreshold_
Definition: ZMuMuTrackUserData.cc:37
ZMuMuTrackUserData::beamSpotToken_
EDGetTokenT< BeamSpot > beamSpotToken_
Definition: ZMuMuTrackUserData.cc:35
ZMuMuTrackUserData::beta_
double beta_
Definition: ZMuMuTrackUserData.cc:38
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
ZMuMuTrackUserData
Definition: ZMuMuTrackUserData.cc:27
reco::VertexCollection
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
GenericParticle.h
ZMuMuTrackUserData::alpha_
double alpha_
Definition: ZMuMuTrackUserData.cc:38
pat::User5Iso
Definition: Isolation.h:21
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
edm::Handle
Definition: AssociativeIterator.h:50
IsoDepositDirection.h
edm::Ref< TrackCollection >
EDMException.h
pat::User4Iso
Definition: Isolation.h:20
reco::isodeposit::ConeVeto
Definition: IsoDepositVetos.h:9
MakerMacros.h
pat::User1Iso
Definition: Isolation.h:17
pat::GenericParticle::setIsolation
void setIsolation(IsolationKeys key, float value)
Definition: GenericParticle.h:201
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
BeamSpot.h
zMuMuMuonUserData.dREcal
dREcal
Definition: zMuMuMuonUserData.py:18
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
ZMuMuTrackUserData::srcToken_
EDGetTokenT< vector< pat::GenericParticle > > srcToken_
Definition: ZMuMuTrackUserData.cc:34
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:528
Isolation.h
reco::BeamSpot::position
const Point & position() const
position
Definition: BeamSpot.h:59
OrderedSet.t
t
Definition: OrderedSet.py:90
ZMuMuTrackUserData::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: ZMuMuTrackUserData.cc:116
IsoDeposit.h
Vertex.h
ZMuMuTrackUserData::etHcalThreshold_
double etHcalThreshold_
Definition: ZMuMuTrackUserData.cc:37
pat::User2Iso
Definition: Isolation.h:18
pat::GenericParticle
Analysis-level Generic Particle class (e.g. for hadron or muon not fully reconstructed)
Definition: GenericParticle.h:38
edm::ParameterSet
Definition: ParameterSet.h:36
zMuMuMuonUserData.primaryVertices
primaryVertices
Definition: zMuMuMuonUserData.py:12
Event.h
zMuMuMuonUserData.dRVetoTrk
dRVetoTrk
Definition: zMuMuMuonUserData.py:16
ZMuMuTrackUserData::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: ZMuMuTrackUserData.cc:53
ZMuMuTrackUserData::ZMuMuTrackUserData
ZMuMuTrackUserData(const edm::ParameterSet &)
Definition: ZMuMuTrackUserData.cc:100
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
pat::PATObject::addUserFloat
void addUserFloat(const std::string &label, float data, const bool overwrite=false)
Set user-defined float.
Definition: PATObject.h:897
pat::HcalIso
Definition: Isolation.h:12
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:132
zMuMuMuonUserData.etEcalThreshold
etEcalThreshold
Definition: zMuMuMuonUserData.py:14
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
reco::isodeposit::Direction
Definition: IsoDepositDirection.h:19
reco::IsoDeposit
Definition: IsoDeposit.h:49
pat::GenericParticle::track
reco::TrackRef track() const override
Definition: GenericParticle.h:62
edm::EDProducer
Definition: EDProducer.h:36
IsoDepositFwd.h
ParameterSet.h
ZMuMuTrackUserData::primaryVerticesToken_
EDGetTokenT< VertexCollection > primaryVerticesToken_
Definition: ZMuMuTrackUserData.cc:36
edm::Event
Definition: Event.h:73
ZMuMuTrackUserData::dRHcal_
double dRHcal_
Definition: ZMuMuTrackUserData.cc:37
edm::InputTag
Definition: InputTag.h:15
ZMuMuTrackUserData::dRTrk_
double dRTrk_
Definition: ZMuMuTrackUserData.cc:37
zMuMuMuonUserData.etHcalThreshold
etHcalThreshold
Definition: zMuMuMuonUserData.py:15
isolation
double isolation
Definition: AssociatedVariableMaxCutCandRefSelector.cc:25
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23