src
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/global/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
#include "
FWCore/Utilities/interface/ESGetToken.h
"
32
33
#include "
FWCore/ParameterSet/interface/ParameterSet.h
"
34
#include "
FWCore/Utilities/interface/InputTag.h
"
35
36
#include "
SimDataFormats/GeneratorProducts/interface/HepMCProduct.h
"
37
#include "
SimDataFormats/HiGenData/interface/GenHIEvent.h
"
38
#include "
SimDataFormats/CrossingFrame/interface/MixCollection.h
"
39
40
#include "HepMC/HeavyIon.h"
41
#include "
FWCore/Framework/interface/ESHandle.h
"
42
#include "
SimGeneral/HepPDTRecord/interface/ParticleDataTable.h
"
43
using namespace
std
;
44
45
//
46
// class decleration
47
//
48
49
class
GenHIEventProducer
:
public
edm::global::EDProducer
<> {
50
public
:
51
explicit
GenHIEventProducer
(
const
edm::ParameterSet
&);
52
~
GenHIEventProducer
()
override
=
default
;
53
54
private
:
55
void
produce(
edm::StreamID
,
edm::Event
&,
const
edm::EventSetup
&)
const override
;
56
const
edm::EDGetTokenT<CrossingFrame<edm::HepMCProduct>
>
hepmcSrc_
;
57
const
edm::ESGetToken<ParticleDataTable, edm::DefaultRecord>
pdtToken_
;
58
const
edm::EDPutTokenT<edm::GenHIEvent>
putToken_
;
59
60
double
ptCut_
;
61
const
bool
doParticleInfo_
;
62
};
63
64
//
65
// constructors and destructor
66
//
67
GenHIEventProducer::GenHIEventProducer
(
const
edm::ParameterSet
& iConfig)
68
: hepmcSrc_(consumes<
CrossingFrame
<
edm
::
HepMCProduct
> >(iConfig.getParameter<
edm
::
InputTag
>(
"src"
))),
69
pdtToken_(
esConsumes
<
ParticleDataTable
,
edm
::DefaultRecord>()),
70
putToken_(produces<
edm
::GenHIEvent>()),
71
doParticleInfo_(iConfig.getUntrackedParameter<
bool
>(
"doParticleInfo"
,
false
)) {
72
if
(
doParticleInfo_
) {
73
ptCut_
= iConfig.
getParameter
<
double
>(
"ptCut"
);
74
}
75
}
76
77
//
78
// member functions
79
//
80
81
// ------------ method called to produce the data ------------
82
void
GenHIEventProducer::produce
(
edm::StreamID
,
edm::Event
&
iEvent
,
const
edm::EventSetup
& iSetup)
const
{
83
using namespace
edm
;
84
85
const
auto
& pdt = iSetup.
getData
(
pdtToken_
);
86
87
double
b
= -1;
88
int
npart
= -1;
89
int
ncoll = 0;
90
int
nhard = 0;
91
double
phi
= 0;
92
double
ecc = -1;
93
94
int
nCharged
= 0;
95
int
nChargedMR = 0;
96
int
nChargedPtCut = 0;
// NchargedPtCut bym
97
int
nChargedPtCutMR = 0;
// NchargedPtCutMR bym
98
99
double
meanPt = 0;
100
double
meanPtMR = 0;
101
double
EtMR = 0;
// Normalized of total energy bym
102
double
TotEnergy = 0;
// Total energy bym
103
104
const
auto
& hepmc =
iEvent
.get(
hepmcSrc_
);
105
MixCollection<HepMCProduct>
mix
(&hepmc);
106
107
if
(
mix
.size() < 1) {
108
throw
cms::Exception
(
"MatchVtx"
) <<
"Mixing has "
<<
mix
.size() <<
" sub-events, should have been at least 1"
109
<< endl;
110
}
111
112
const
HepMCProduct
& hievt =
mix
.getObject(
mix
.size() - 1);
113
const
HepMC::GenEvent
* evt = hievt.GetEvent();
114
if
(
doParticleInfo_
) {
115
HepMC::GenEvent::particle_const_iterator begin = evt->particles_begin();
116
HepMC::GenEvent::particle_const_iterator
end
= evt->particles_end();
117
for
(HepMC::GenEvent::particle_const_iterator it = begin; it !=
end
; ++it) {
118
if
((*it)->status() != 1)
119
continue
;
120
int
pdg_id
= (*it)->pdg_id();
121
const
ParticleData
*
part
= pdt.particle(
pdg_id
);
122
int
charge
=
static_cast<
int
>
(
part
->charge());
123
124
if
(
charge
== 0)
125
continue
;
126
float
pt
= (*it)->momentum().perp();
127
float
eta
= (*it)->momentum().eta();
128
float
energy
= (*it)->momentum().e();
// energy bym
129
//float energy = (*it)->momentum().energy(); // energy bym
130
nCharged
++;
131
meanPt +=
pt
;
132
// Get the total energy bym
133
if
(fabs(
eta
) < 1.0) {
134
TotEnergy +=
energy
;
135
}
136
if
(
pt
>
ptCut_
) {
137
nChargedPtCut++;
138
if
(fabs(
eta
) < 0.5) {
139
nChargedPtCutMR++;
140
}
141
}
142
// end bym
143
144
if
(fabs(
eta
) > 0.5)
145
continue
;
146
nChargedMR++;
147
meanPtMR +=
pt
;
148
}
149
}
150
const
HepMC::HeavyIon*
hi
= evt->heavy_ion();
151
152
if
(
hi
) {
153
ncoll = ncoll +
hi
->Ncoll();
154
nhard = nhard +
hi
->Ncoll_hard();
155
int
np
=
hi
->Npart_proj() +
hi
->Npart_targ();
156
if
(
np
>= 0) {
157
npart
=
np
;
158
b
=
hi
->impact_parameter();
159
phi
=
hi
->event_plane_angle();
160
ecc =
hi
->eccentricity();
161
}
162
}
163
164
// Get the normalized total energy bym
165
if
(TotEnergy != 0) {
166
EtMR = TotEnergy / 2;
167
}
168
169
if
(nChargedMR != 0) {
170
meanPtMR /= nChargedMR;
171
}
172
if
(
nCharged
!= 0) {
173
meanPt /=
nCharged
;
174
}
175
176
iEvent
.emplace(
putToken_
,
177
b
,
178
npart
,
179
ncoll,
180
nhard,
181
phi
,
182
ecc,
183
nCharged
,
184
nChargedMR,
185
meanPt,
186
meanPtMR,
187
EtMR,
188
nChargedPtCut,
189
nChargedPtCutMR);
190
}
191
192
//define this as a plug-in
193
DEFINE_FWK_MODULE
(
GenHIEventProducer
);
ProducerED_cfi.InputTag
InputTag
Definition:
ProducerED_cfi.py:5
deDxTools::esConsumes
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition:
DeDxTools.cc:283
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition:
ParameterSet.h:303
GenHIEventProducer::produce
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
Definition:
GenHIEventProducer.cc:82
edm::EventSetup::getData
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition:
EventSetup.h:119
Exception
Definition:
hltDiff.cc:245
ParticleDataTable
HepPDT::ParticleDataTable ParticleDataTable
Definition:
ParticleDataTable.h:8
funct::false
false
Definition:
Factorize.h:29
edm::StreamID
Definition:
StreamID.h:30
Event.h
HLT_2023v12_cff.nCharged
nCharged
Definition:
HLT_2023v12_cff.py:30007
EventSetup.h
MixCollection
Definition:
MixCollection.h:10
npart
double npart
Definition:
HydjetWrapper.h:46
PVValHelper::eta
Definition:
PVValidationHelpers.h:70
std
Definition:
JetResolutionObject.h:76
GenHIEvent.h
GenHIEventProducer::pdtToken_
const edm::ESGetToken< ParticleDataTable, edm::DefaultRecord > pdtToken_
Definition:
GenHIEventProducer.cc:57
edm::EDGetTokenT
Definition:
EDGetToken.h:37
Frameworkfwd.h
GenHIEventProducer::putToken_
const edm::EDPutTokenT< edm::GenHIEvent > putToken_
Definition:
GenHIEventProducer.cc:58
GenHIEventProducer::hepmcSrc_
const edm::EDGetTokenT< CrossingFrame< edm::HepMCProduct > > hepmcSrc_
Definition:
GenHIEventProducer.cc:56
edm::EDPutTokenT< edm::GenHIEvent >
DDAxes::phi
DiDispStaMuonMonitor_cfi.pt
pt
Definition:
DiDispStaMuonMonitor_cfi.py:39
MixCollection.h
ParameterSet.h
GeneratorMix_cff.mix
mix
Definition:
GeneratorMix_cff.py:6
ParticleDataTable.h
HiggsValidation_cfi.pdg_id
pdg_id
Definition:
HiggsValidation_cfi.py:6
edm::ESGetToken< ParticleDataTable, edm::DefaultRecord >
iEvent
int iEvent
Definition:
GenABIO.cc:224
np
int np
Definition:
AMPTWrapper.h:43
GenHIEventProducer
Definition:
GenHIEventProducer.cc:49
HepMC::GenEvent
Definition:
hepmc_rootio.cc:9
hi
Definition:
EPCuts.h:4
CrossingFrame
Definition:
CrossingFrame.h:37
HepMCProduct
ESHandle.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition:
MakerMacros.h:16
edm::EventSetup
Definition:
EventSetup.h:56
edm::global::EDProducer
Definition:
EDProducer.h:32
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition:
ALCARECOTkAlJpsiMuMu_cff.py:47
ParticleData
HepPDT::ParticleData ParticleData
Definition:
ParticleDataTable.h:9
HepMCProduct.h
GenHIEventProducer::ptCut_
double ptCut_
Definition:
GenHIEventProducer.cc:60
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition:
HCALHighEnergyHPDFilter_cfi.py:5
electrons_cff.bool
bool
Definition:
electrons_cff.py:315
mps_fire.end
end
Definition:
mps_fire.py:242
part
part
Definition:
HCALResponse.h:20
GenHIEventProducer::doParticleInfo_
const bool doParticleInfo_
Definition:
GenHIEventProducer.cc:61
b
double b
Definition:
hdecay.h:118
EDProducer.h
edm
HLT enums.
Definition:
AlignableModifier.h:19
InputTag.h
edm::ParameterSet
Definition:
ParameterSet.h:47
edm::Event
Definition:
Event.h:73
MakerMacros.h
ESGetToken.h
GenHIEventProducer::GenHIEventProducer
GenHIEventProducer(const edm::ParameterSet &)
Definition:
GenHIEventProducer.cc:67
Generated for CMSSW Reference Manual by
1.8.14