9 #include "CLHEP/Units/defs.h"
10 #include "CLHEP/Units/PhysicalConstants.h"
16 : wmanager_(iPSet, consumesCollector()),
17 hepmcCollection_(iPSet.getParameter<
edm::
InputTag>(
"hepmcCollection")),
18 genparticleCollection_(iPSet.getParameter<
edm::
InputTag>(
"genparticleCollection")),
19 genjetCollection_(iPSet.getParameter<
edm::
InputTag>(
"genjetsCollection")),
20 matchPr_(iPSet.getParameter<double>(
"matchingPrecision")),
21 verbosity_(iPSet.getUntrackedParameter<unsigned
int>(
"verbosity", 0)) {
32 i.setCurrentFolder(
"Generator/GenParticles");
36 nEvt =
dqm.book1dHisto(
"nEvt",
"n analyzed Events", 1, 0., 1.,
"",
"Number of Events");
40 "Log(No. all GenParticles)",
44 "log_{10}(N_{All GenParticles})",
48 "genMatched",
"Difference reco - matched", 50, -25, 25,
"N_{All GenParticles}-N_{Matched}",
"Number of Events");
51 "multiple reco HepMC matching",
55 "N_{multiple reco HepMC matching}",
59 "log10(momentum difference of matched particles)",
63 "log_{10}(#DeltaP_{matched Particles})",
67 genJetMult =
dqm.book1dHisto(
"genJetMult",
"GenJet multiplicity", 50, 0, 50,
"N_{gen-jets}",
"Number of Events");
69 "genJetEnergy",
"Log10(GenJet energy)", 60, -1, 5,
"log_{10}(E^{gen-jets}) (log_{10}(GeV))",
"Number of Events");
71 "genJetPt",
"Log10(GenJet pt)", 60, -1, 5,
"log_{10}(P_{t}^{gen-jets}) (log_{10}(GeV))",
"Number of Events");
72 genJetEta =
dqm.book1dHisto(
"genJetEta",
"GenJet eta", 220, -11, 11,
"#eta^{gen-jets}",
"Number of Events");
73 genJetPhi =
dqm.book1dHisto(
"genJetPhi",
"GenJet phi", 360, -180, 180,
"#phi^{gen-jets} (rad)",
"Number of Events");
75 "genJetDeltaEtaMin",
"GenJet minimum rapidity gap", 30, 0, 30,
"#delta#eta_{min}^{gen-jets}",
"Number of Events");
78 "genJetPto1",
"GenJet multiplicity above 1 GeV", 50, 0, 50,
"N_{gen-jets P_{t}>1GeV}",
"Number of Events");
80 "genJetPto10",
"GenJet multiplicity above 10 GeV", 50, 0, 50,
"N_{gen-jets P_{t}>10GeV}",
"Number of Events");
82 "genJetPto100",
"GenJet multiplicity above 100 GeV", 50, 0, 50,
"N_{gen-jets P_{t}>100GeV}",
"Number of Events");
84 "genJetCentral",
"GenJet multiplicity |eta|.lt.2.5", 50, 0, 50,
"N_{gen-jets |#eta|#leq2.5}",
"Number of Events");
87 "Log10(GenJet total pt)",
91 "log_{10}(#SigmaP_{t}^{gen-jets}) (log_{10}(GeV))",
98 unsigned int initSize = 1000;
111 std::vector<const HepMC::GenParticle*> hepmcGPCollection;
112 std::vector<int> barcodeList;
113 hepmcGPCollection.reserve(initSize);
114 barcodeList.reserve(initSize);
117 for (HepMC::GenEvent::particle_const_iterator iter = myGenEvent->particles_begin();
118 iter != myGenEvent->particles_end();
120 if ((*iter)->status() == 1) {
121 hepmcGPCollection.push_back(*iter);
122 barcodeList.push_back((*iter)->barcode());
125 << (*iter)->momentum().px() << std::setw(14) <<
std::fixed << (*iter)->momentum().py()
126 << std::setw(14) <<
std::fixed << (*iter)->momentum().pz() << std::endl;
135 std::vector<const reco::GenParticle*>
particles;
137 for (reco::GenParticleCollection::const_iterator iter =
genParticles->begin(); iter !=
genParticles->end(); ++iter) {
138 if ((*iter).status() == 1) {
143 << (*iter).pz() << std::endl;
149 unsigned int nHepMC = hepmcGPCollection.size();
154 std::vector<int> hepmcMatchIndex;
155 hepmcMatchIndex.reserve(initSize);
161 if (nReco != nHepMC) {
163 <<
"Collection size inconsistency: HepMC::GenParticle = " << nHepMC <<
" reco::GenParticle = " << nReco;
168 for (
unsigned int i = 0;
i < nReco; ++
i) {
169 for (
unsigned int j = 0;
j < nHepMC; ++
j) {
171 hepmcMatchIndex.push_back((
int)
j);
172 if (hepmcGPCollection[
j]->momentum().
rho() != 0.) {
173 double reso = 1. -
particles[
i]->p() / hepmcGPCollection[
j]->momentum().rho();
176 <<
" HepMC = " << hepmcGPCollection[
j]->momentum().rho() <<
" resoultion = " << reso << std::endl;
187 unsigned int nMatched = hepmcMatchIndex.size();
189 if (nMatched != nReco) {
190 edm::LogWarning(
"IncorrectMatching") <<
"Incorrect number of matched indexes: GenParticle = " << nReco
191 <<
" matched indexes = " << nMatched;
195 unsigned int nWrMatch = 0;
197 for (
unsigned int i = 0;
i < nMatched; ++
i) {
198 for (
unsigned int j =
i + 1;
j < nMatched; ++
j) {
199 if (hepmcMatchIndex[
i] == hepmcMatchIndex[
j]) {
200 int theIndex = hepmcMatchIndex[
i];
202 <<
"Multiple matching occurencies for GenParticle barcode = " << barcodeList[theIndex];
217 int nJetsCentral = 0;
220 std::vector<double>
jetEta;
223 for (reco::GenJetCollection::const_iterator iter =
genJets->begin(); iter !=
genJets->end(); ++iter) {
225 double pt = (*iter).pt();
233 double eta = (*iter).eta();
234 if (std::fabs(
eta) < 2.5)
254 for (
unsigned int i = 0;
i <
jetEta.size();
i++) {
255 for (
unsigned int j =
i + 1;
j <
jetEta.size();
j++) {
269 if (hepmcP->pdg_id() != recoP->
pdgId())
271 if (std::fabs(hepmcP->momentum().px() - recoP->
px()) < std::fabs(
matchPr_ * hepmcP->momentum().px()) &&
272 std::fabs(hepmcP->momentum().py() - recoP->
py()) < std::fabs(
matchPr_ * hepmcP->momentum().py()) &&
273 std::fabs(hepmcP->momentum().pz() - recoP->
pz()) < std::fabs(
matchPr_ * hepmcP->momentum().pz())) {