ElectroWeakAnalysis
Skimming
plugins
ZMuMuOneTrackUserData.cc
Go to the documentation of this file.
1
#include "
FWCore/Framework/interface/EDProducer.h
"
2
#include "
FWCore/Utilities/interface/InputTag.h
"
3
#include "
DataFormats/Common/interface/Handle.h
"
4
#include "
FWCore/Framework/interface/Event.h
"
5
#include "
FWCore/ParameterSet/interface/ParameterSet.h
"
6
#include "
DataFormats/PatCandidates/interface/Muon.h
"
7
#include "
DataFormats/PatCandidates/interface/CompositeCandidate.h
"
8
#include "
FWCore/Utilities/interface/EDMException.h
"
9
#include "
CommonTools/UtilAlgos/interface/TFileService.h
"
10
11
#include "
DataFormats/RecoCandidate/interface/IsoDeposit.h
"
12
#include "
DataFormats/RecoCandidate/interface/IsoDepositFwd.h
"
13
#include "
DataFormats/PatCandidates/interface/Isolation.h
"
14
#include "
DataFormats/RecoCandidate/interface/IsoDepositVetos.h
"
15
#include "
DataFormats/RecoCandidate/interface/IsoDepositDirection.h
"
16
17
#include "
DataFormats/BeamSpot/interface/BeamSpot.h
"
18
#include "
DataFormats/VertexReco/interface/VertexFwd.h
"
19
#include "
DataFormats/VertexReco/interface/Vertex.h
"
20
21
#include <vector>
22
23
using namespace
edm
;
24
using namespace
std
;
25
using namespace
reco
;
26
using namespace
isodeposit;
27
//using namespace pat;
28
29
class
ZMuMuUserDataOneTrack
:
public
edm::EDProducer
{
30
public
:
31
ZMuMuUserDataOneTrack
(
const
edm::ParameterSet
&);
32
typedef
math::XYZVector
Vector
;
33
34
private
:
35
void
produce(
edm::Event
&,
const
edm::EventSetup
&)
override
;
36
37
EDGetTokenT<std::vector<reco::CompositeCandidate>
>
srcToken_
;
38
EDGetTokenT<BeamSpot>
beamSpotToken_
;
39
EDGetTokenT<VertexCollection>
primaryVerticesToken_
;
40
EDGetTokenT<GenParticleMatch>
zGenParticlesMatchToken_
;
41
double
alpha_,
beta_
;
42
string
hltPath_
;
43
int
counter
;
44
};
45
46
ZMuMuUserDataOneTrack::ZMuMuUserDataOneTrack
(
const
ParameterSet
&
cfg
)
47
: srcToken_(consumes<
std
::vector<
reco
::
CompositeCandidate
> >(
cfg
.getParameter<
InputTag
>(
"src"
))),
48
beamSpotToken_(consumes<
BeamSpot
>(
cfg
.getParameter<
InputTag
>(
"beamSpot"
))),
49
primaryVerticesToken_(consumes<
VertexCollection
>(
cfg
.getParameter<
InputTag
>(
"primaryVertices"
))),
50
zGenParticlesMatchToken_(consumes<
GenParticleMatch
>(
cfg
.getParameter<
InputTag
>(
"zGenParticlesMatch"
))),
51
alpha_(
cfg
.getParameter<double>(
"alpha"
)),
52
beta_(
cfg
.getParameter<double>(
"beta"
)),
53
hltPath_(
cfg
.getParameter<
std
::
string
>(
"hltPath"
)) {
54
produces<vector<pat::CompositeCandidate> >();
55
}
56
57
void
ZMuMuUserDataOneTrack::produce
(
Event
&evt,
const
EventSetup
&) {
58
Handle<std::vector<reco::CompositeCandidate>
>
dimuons
;
59
evt.
getByToken
(
srcToken_
,
dimuons
);
60
61
Handle<BeamSpot>
beamSpotHandle;
62
if
(!evt.
getByToken
(
beamSpotToken_
, beamSpotHandle)) {
63
std::cout
<<
">>> No beam spot found !!!"
<< std::endl;
64
}
65
66
Handle<VertexCollection>
primaryVertices
;
// Collection of primary Vertices
67
if
(!evt.
getByToken
(
primaryVerticesToken_
,
primaryVertices
)) {
68
std::cout
<<
">>> No primary vertices found !!!"
<< std::endl;
69
}
70
71
bool
isMCMatchTrue =
false
;
72
73
Handle<GenParticleMatch>
zGenParticlesMatch
;
74
if
(evt.
getByToken
(
zGenParticlesMatchToken_
,
zGenParticlesMatch
)) {
75
isMCMatchTrue =
true
;
76
}
77
78
//cout<<"isMCMatchTrue"<<isMCMatchTrue <<endl;
79
unique_ptr<vector<pat::CompositeCandidate> > dimuonColl(
new
vector<pat::CompositeCandidate>());
80
81
for
(
unsigned
int
i
= 0;
i
<
dimuons
->size(); ++
i
) {
82
const
CompositeCandidate
&
z
= (*dimuons)[
i
];
83
//CandidateBaseRef zRef = dimuons ->refAt(i);
84
edm::Ref<std::vector<reco::CompositeCandidate>
> zRef(
dimuons
,
i
);
85
pat::CompositeCandidate
dimuon(
z
);
86
87
float
trueMass, truePt, trueEta, truePhi, trueY;
88
if
(isMCMatchTrue) {
89
GenParticleRef
trueZRef = (*zGenParticlesMatch)[zRef];
90
//CandidateRef trueZRef = trueZIter->val;
91
if
(trueZRef.
isNonnull
()) {
92
const
Candidate
&
z
= *trueZRef;
93
trueMass =
z
.mass();
94
truePt =
z
.pt();
95
trueEta =
z
.eta();
96
truePhi =
z
.phi();
97
trueY =
z
.rapidity();
98
}
else
{
99
trueMass = -100;
100
truePt = -100;
101
trueEta = -100;
102
truePhi = -100;
103
trueY = -100;
104
}
105
106
dimuon.
addUserFloat
(
"TrueMass"
, trueMass);
107
dimuon.
addUserFloat
(
"TruePt"
, truePt);
108
dimuon.
addUserFloat
(
"TrueEta"
, trueEta);
109
dimuon.
addUserFloat
(
"TruePhi"
, truePhi);
110
dimuon.
addUserFloat
(
"TrueY"
, trueY);
111
}
112
113
dimuonColl->push_back(dimuon);
114
}
115
116
evt.
put
(
std::move
(dimuonColl));
117
}
118
119
#include "
FWCore/Framework/interface/MakerMacros.h
"
120
121
DEFINE_FWK_MODULE
(
ZMuMuUserDataOneTrack
);
ZMuMuUserDataOneTrack
Definition:
ZMuMuOneTrackUserData.cc:29
Handle.h
CompositeCandidate.h
mps_fire.i
i
Definition:
mps_fire.py:355
IsoDepositVetos.h
EDProducer.h
edm::EDGetTokenT
Definition:
EDGetToken.h:33
pat::CompositeCandidate
Analysis-level particle class.
Definition:
CompositeCandidate.h:31
edm
HLT enums.
Definition:
AlignableModifier.h:19
Muon.h
reco::VertexCollection
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition:
VertexFwd.h:9
gather_cfg.cout
cout
Definition:
gather_cfg.py:144
ZMuMuUserDataOneTrack::primaryVerticesToken_
EDGetTokenT< VertexCollection > primaryVerticesToken_
Definition:
ZMuMuOneTrackUserData.cc:39
reco
fixed size matrix
Definition:
AlignmentAlgorithmBase.h:45
edm::Handle
Definition:
AssociativeIterator.h:50
IsoDepositDirection.h
edm::Ref
Definition:
AssociativeIterator.h:58
EDMException.h
WZMuSkim_cff.dimuons
dimuons
Definition:
WZMuSkim_cff.py:26
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition:
MakerMacros.h:16
BeamSpot.h
reco::BeamSpot
Definition:
BeamSpot.h:21
DDAxes::z
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition:
Event.h:528
Isolation.h
IsoDeposit.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:256
Vertex.h
TFileService.h
edm::ParameterSet
Definition:
ParameterSet.h:36
zMuMuMuonUserData.primaryVertices
primaryVertices
Definition:
zMuMuMuonUserData.py:12
Event.h
ZMuMuUserDataOneTrack::Vector
math::XYZVector Vector
Definition:
ZMuMuOneTrackUserData.cc:32
edm::Ref::isNonnull
bool isNonnull() const
Checks for non-null.
Definition:
Ref.h:238
zMuMu_SubskimPathsWithMCTruth_cff.zGenParticlesMatch
zGenParticlesMatch
Definition:
zMuMu_SubskimPathsWithMCTruth_cff.py:23
math::XYZVector
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition:
Vector3D.h:31
ZMuMuUserDataOneTrack::beta_
double beta_
Definition:
ZMuMuOneTrackUserData.cc:41
pat::PATObject::addUserFloat
void addUserFloat(const std::string &label, float data, const bool overwrite=false)
Set user-defined float.
Definition:
PATObject.h:897
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition:
Event.h:132
edm::Association
Definition:
Association.h:18
edm::EventSetup
Definition:
EventSetup.h:57
ZMuMuUserDataOneTrack::beamSpotToken_
EDGetTokenT< BeamSpot > beamSpotToken_
Definition:
ZMuMuOneTrackUserData.cc:38
InputTag.h
looper.cfg
cfg
Definition:
looper.py:297
reco::Candidate
Definition:
Candidate.h:27
VertexFwd.h
eostools.move
def move(src, dest)
Definition:
eostools.py:511
std
Definition:
JetResolutionObject.h:76
ZMuMuUserDataOneTrack::hltPath_
string hltPath_
Definition:
ZMuMuOneTrackUserData.cc:42
edm::EDProducer
Definition:
EDProducer.h:36
ZMuMuUserDataOneTrack::ZMuMuUserDataOneTrack
ZMuMuUserDataOneTrack(const edm::ParameterSet &)
Definition:
ZMuMuOneTrackUserData.cc:46
IsoDepositFwd.h
ParameterSet.h
ZMuMuUserDataOneTrack::counter
int counter
Definition:
ZMuMuOneTrackUserData.cc:43
edm::Event
Definition:
Event.h:73
ZMuMuUserDataOneTrack::zGenParticlesMatchToken_
EDGetTokenT< GenParticleMatch > zGenParticlesMatchToken_
Definition:
ZMuMuOneTrackUserData.cc:40
edm::InputTag
Definition:
InputTag.h:15
reco::CompositeCandidate
Definition:
CompositeCandidate.h:21
ZMuMuUserDataOneTrack::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition:
ZMuMuOneTrackUserData.cc:57
ZMuMuUserDataOneTrack::srcToken_
EDGetTokenT< std::vector< reco::CompositeCandidate > > srcToken_
Definition:
ZMuMuOneTrackUserData.cc:37
Generated for CMSSW Reference Manual by
1.8.16