GeneratorInterface
HiGenCommon
plugins
GenHIEventProducer.cc
Go to the documentation of this file.
1
// -*- C++ -*-
2
//
3
// Package: GenHIEventProducer
4
// Class: GenHIEventProducer
5
//
13
//
14
// Original Author: Yetkin Yilmaz
15
// Created: Thu Aug 13 08:39:51 EDT 2009
16
//
17
//
18
19
// system include files
20
#include <memory>
21
#include <string>
22
#include <iostream>
23
24
// user include files
25
#include "
FWCore/Framework/interface/Frameworkfwd.h
"
26
#include "
FWCore/Framework/interface/EDProducer.h
"
27
#include "
FWCore/Framework/interface/EventSetup.h
"
28
29
#include "
FWCore/Framework/interface/Event.h
"
30
#include "
FWCore/Framework/interface/MakerMacros.h
"
31
32
#include "
FWCore/ParameterSet/interface/ParameterSet.h
"
33
#include "
FWCore/Utilities/interface/InputTag.h
"
34
35
#include "
SimDataFormats/GeneratorProducts/interface/HepMCProduct.h
"
36
#include "
SimDataFormats/HiGenData/interface/GenHIEvent.h
"
37
#include "
SimDataFormats/CrossingFrame/interface/MixCollection.h
"
38
39
#include "HepMC/HeavyIon.h"
40
#include "
FWCore/Framework/interface/ESHandle.h
"
41
#include "
SimGeneral/HepPDTRecord/interface/ParticleDataTable.h
"
42
using namespace
std
;
43
44
//
45
// class decleration
46
//
47
48
class
GenHIEventProducer
:
public
edm::EDProducer
{
49
public
:
50
explicit
GenHIEventProducer
(
const
edm::ParameterSet
&);
51
~
GenHIEventProducer
()
override
;
52
53
private
:
54
void
produce(
edm::Event
&,
const
edm::EventSetup
&)
override
;
55
edm::EDGetTokenT<CrossingFrame<edm::HepMCProduct>
>
hepmcSrc_
;
56
edm::ESHandle<ParticleDataTable>
pdt
;
57
58
double
ptCut_
;
59
bool
doParticleInfo_
;
60
};
61
62
//
63
// constants, enums and typedefs
64
//
65
66
//
67
// static data member definitions
68
//
69
70
//
71
// constructors and destructor
72
//
73
GenHIEventProducer::GenHIEventProducer
(
const
edm::ParameterSet
& iConfig) {
74
produces<edm::GenHIEvent>();
75
hepmcSrc_ = consumes<CrossingFrame<edm::HepMCProduct> >(iConfig.
getParameter
<
edm::InputTag
>(
"src"
));
76
doParticleInfo_ = iConfig.
getUntrackedParameter
<
bool
>(
"doParticleInfo"
,
false
);
77
if
(doParticleInfo_) {
78
ptCut_ = iConfig.
getParameter
<
double
>(
"ptCut"
);
79
}
80
}
81
82
GenHIEventProducer::~GenHIEventProducer
() {
83
// do anything here that needs to be done at desctruction time
84
// (e.g. close files, deallocate resources etc.)
85
}
86
87
//
88
// member functions
89
//
90
91
// ------------ method called to produce the data ------------
92
void
GenHIEventProducer::produce
(
edm::Event
&
iEvent
,
const
edm::EventSetup
& iSetup) {
93
using namespace
edm
;
94
95
if
(!(pdt.isValid()))
96
iSetup.
getData
(pdt);
97
98
double
b
= -1;
99
int
npart
= -1;
100
int
ncoll = 0;
101
int
nhard = 0;
102
double
phi = 0;
103
double
ecc = -1;
104
105
int
nCharged
= 0;
106
int
nChargedMR = 0;
107
int
nChargedPtCut = 0;
// NchargedPtCut bym
108
int
nChargedPtCutMR = 0;
// NchargedPtCutMR bym
109
110
double
meanPt = 0;
111
double
meanPtMR = 0;
112
double
EtMR = 0;
// Normalized of total energy bym
113
double
TotEnergy = 0;
// Total energy bym
114
115
Handle<CrossingFrame<edm::HepMCProduct>
> hepmc;
116
iEvent
.getByToken(hepmcSrc_, hepmc);
117
MixCollection<HepMCProduct>
mix
(hepmc.
product
());
118
119
if
(
mix
.size() < 1) {
120
throw
cms::Exception
(
"MatchVtx"
) <<
"Mixing has "
<<
mix
.size() <<
" sub-events, should have been at least 1"
121
<< endl;
122
}
123
124
const
HepMCProduct
& hievt =
mix
.getObject(
mix
.size() - 1);
125
const
HepMC::GenEvent
* evt = hievt.
GetEvent
();
126
if
(doParticleInfo_) {
127
HepMC::GenEvent::particle_const_iterator
begin
= evt->particles_begin();
128
HepMC::GenEvent::particle_const_iterator
end
= evt->particles_end();
129
for
(HepMC::GenEvent::particle_const_iterator it =
begin
; it !=
end
; ++it) {
130
if
((*it)->status() != 1)
131
continue
;
132
int
pdg_id
= (*it)->pdg_id();
133
const
ParticleData
*
part
= pdt->particle(
pdg_id
);
134
int
charge
= static_cast<int>(
part
->charge());
135
136
if
(
charge
== 0)
137
continue
;
138
float
pt
= (*it)->momentum().perp();
139
float
eta
= (*it)->momentum().eta();
140
float
energy
= (*it)->momentum().e();
// energy bym
141
//float energy = (*it)->momentum().energy(); // energy bym
142
nCharged
++;
143
meanPt +=
pt
;
144
// Get the total energy bym
145
if
(fabs(
eta
) < 1.0) {
146
TotEnergy +=
energy
;
147
}
148
if
(
pt
> ptCut_) {
149
nChargedPtCut++;
150
if
(fabs(
eta
) < 0.5) {
151
nChargedPtCutMR++;
152
}
153
}
154
// end bym
155
156
if
(fabs(
eta
) > 0.5)
157
continue
;
158
nChargedMR++;
159
meanPtMR +=
pt
;
160
}
161
}
162
const
HepMC::HeavyIon*
hi
= evt->heavy_ion();
163
164
if
(
hi
) {
165
ncoll = ncoll +
hi
->Ncoll();
166
nhard = nhard +
hi
->Ncoll_hard();
167
int
np
=
hi
->Npart_proj() +
hi
->Npart_targ();
168
if
(
np
>= 0) {
169
npart
=
np
;
170
b
=
hi
->impact_parameter();
171
phi =
hi
->event_plane_angle();
172
ecc =
hi
->eccentricity();
173
}
174
}
175
176
// Get the normalized total energy bym
177
if
(TotEnergy != 0) {
178
EtMR = TotEnergy / 2;
179
}
180
181
if
(nChargedMR != 0) {
182
meanPtMR /= nChargedMR;
183
}
184
if
(
nCharged
!= 0) {
185
meanPt /=
nCharged
;
186
}
187
188
std::unique_ptr<edm::GenHIEvent> pGenHI(
new
edm::GenHIEvent
(
189
b
,
npart
, ncoll, nhard, phi, ecc,
nCharged
, nChargedMR, meanPt, meanPtMR, EtMR, nChargedPtCut, nChargedPtCutMR));
190
191
iEvent
.put(
std::move
(pGenHI));
192
}
193
194
//define this as a plug-in
195
DEFINE_FWK_MODULE
(
GenHIEventProducer
);
HiggsValidation_cfi.pdg_id
pdg_id
Definition:
HiggsValidation_cfi.py:6
edm::Handle::product
T const * product() const
Definition:
Handle.h:70
EDProducer.h
ESHandle.h
GenHIEventProducer::ptCut_
double ptCut_
Definition:
GenHIEventProducer.cc:58
DiDispStaMuonMonitor_cfi.pt
pt
Definition:
DiDispStaMuonMonitor_cfi.py:39
edm::EDGetTokenT
Definition:
EDGetToken.h:33
edm
HLT enums.
Definition:
AlignableModifier.h:19
HLT_2018_cff.nCharged
nCharged
Definition:
HLT_2018_cff.py:31800
np
int np
Definition:
AMPTWrapper.h:43
GenHIEventProducer::pdt
edm::ESHandle< ParticleDataTable > pdt
Definition:
GenHIEventProducer.cc:56
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::Handle
Definition:
AssociativeIterator.h:50
GenHIEventProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition:
GenHIEventProducer.cc:92
npart
double npart
Definition:
HydjetWrapper.h:46
end
#define end
Definition:
vmac.h:39
HepMC::GenEvent
Definition:
hepmc_rootio.cc:9
ParticleData
HepPDT::ParticleData ParticleData
Definition:
ParticleDataTable.h:9
edm::GenHIEvent
Definition:
GenHIEvent.h:8
GenHIEventProducer
Definition:
GenHIEventProducer.cc:48
GenHIEventProducer::~GenHIEventProducer
~GenHIEventProducer() override
Definition:
GenHIEventProducer.cc:82
MakerMacros.h
part
part
Definition:
HCALResponse.h:20
GenHIEventProducer::doParticleInfo_
bool doParticleInfo_
Definition:
GenHIEventProducer.cc:59
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition:
MakerMacros.h:16
MixCollection.h
MixCollection
Definition:
MixCollection.h:11
PVValHelper::eta
Definition:
PVValidationHelpers.h:69
edm::ESHandle< ParticleDataTable >
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition:
HCALHighEnergyHPDFilter_cfi.py:5
GenHIEventProducer::GenHIEventProducer
GenHIEventProducer(const edm::ParameterSet &)
Definition:
GenHIEventProducer.cc:73
b
double b
Definition:
hdecay.h:118
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition:
ALCARECOTkAlJpsiMuMu_cff.py:47
edm::ParameterSet
Definition:
ParameterSet.h:36
Event.h
ParticleDataTable.h
iEvent
int iEvent
Definition:
GenABIO.cc:224
edm::EventSetup
Definition:
EventSetup.h:57
edm::HepMCProduct::GetEvent
const HepMC::GenEvent * GetEvent() const
Definition:
HepMCProduct.h:34
InputTag.h
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition:
EventSetup.h:113
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
hi
Definition:
HiEvtPlaneList.h:38
eostools.move
def move(src, dest)
Definition:
eostools.py:511
std
Definition:
JetResolutionObject.h:76
Frameworkfwd.h
GenHIEvent.h
Exception
Definition:
hltDiff.cc:246
EventSetup.h
edm::EDProducer
Definition:
EDProducer.h:36
edm::HepMCProduct
Definition:
HepMCProduct.h:18
ParameterSet.h
HepMCProduct.h
edm::Event
Definition:
Event.h:73
GeneratorMix_cff.mix
mix
Definition:
GeneratorMix_cff.py:6
edm::InputTag
Definition:
InputTag.h:15
begin
#define begin
Definition:
vmac.h:32
GenHIEventProducer::hepmcSrc_
edm::EDGetTokenT< CrossingFrame< edm::HepMCProduct > > hepmcSrc_
Definition:
GenHIEventProducer.cc:55
Generated for CMSSW Reference Manual by
1.8.16