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)),
22 signalParticlesOnly_(iPSet.getParameter<bool>(
"signalParticlesOnly")) {
37 nEvt = dqm.
book1dHisto(
"nEvt",
"n analyzed Events", 1, 0., 1.,
"",
"Number of Events");
41 "Log(No. all GenParticles)",
45 "log_{10}(N_{All GenParticles})",
49 "genMatched",
"Difference reco - matched", 50, -25, 25,
"N_{All GenParticles}-N_{Matched}",
"Number of Events");
52 "multiple reco HepMC matching",
56 "N_{multiple reco HepMC matching}",
60 "log10(momentum difference of matched particles)",
64 "log_{10}(#DeltaP_{matched Particles})",
68 genJetMult = dqm.
book1dHisto(
"genJetMult",
"GenJet multiplicity", 50, 0, 50,
"N_{gen-jets}",
"Number of Events");
70 "genJetEnergy",
"Log10(GenJet energy)", 60, -1, 5,
"log_{10}(E^{gen-jets}) (log_{10}(GeV))",
"Number of Events");
72 "genJetPt",
"Log10(GenJet pt)", 60, -1, 5,
"log_{10}(P_{t}^{gen-jets}) (log_{10}(GeV))",
"Number of Events");
73 genJetEta = dqm.
book1dHisto(
"genJetEta",
"GenJet eta", 220, -11, 11,
"#eta^{gen-jets}",
"Number of Events");
74 genJetPhi = dqm.
book1dHisto(
"genJetPhi",
"GenJet phi", 360, -180, 180,
"#phi^{gen-jets} (rad)",
"Number of Events");
76 "genJetDeltaEtaMin",
"GenJet minimum rapidity gap", 30, 0, 30,
"#delta#eta_{min}^{gen-jets}",
"Number of Events");
79 "genJetPto1",
"GenJet multiplicity above 1 GeV", 50, 0, 50,
"N_{gen-jets P_{t}>1GeV}",
"Number of Events");
81 "genJetPto10",
"GenJet multiplicity above 10 GeV", 50, 0, 50,
"N_{gen-jets P_{t}>10GeV}",
"Number of Events");
83 "genJetPto100",
"GenJet multiplicity above 100 GeV", 50, 0, 50,
"N_{gen-jets P_{t}>100GeV}",
"Number of Events");
85 "genJetCentral",
"GenJet multiplicity |eta|.lt.2.5", 50, 0, 50,
"N_{gen-jets |#eta|#leq2.5}",
"Number of Events");
88 "Log10(GenJet total pt)",
92 "log_{10}(#SigmaP_{t}^{gen-jets}) (log_{10}(GeV))",
99 unsigned int initSize = 1000;
112 std::vector<const HepMC::GenParticle*> hepmcGPCollection;
113 std::vector<int> barcodeList;
114 hepmcGPCollection.reserve(initSize);
115 barcodeList.reserve(initSize);
118 for (HepMC::GenEvent::particle_const_iterator iter = myGenEvent->particles_begin();
119 iter != myGenEvent->particles_end();
121 if ((*iter)->status() == 1) {
122 hepmcGPCollection.push_back(*iter);
123 barcodeList.push_back((*iter)->barcode());
125 std::cout <<
"HepMC " << std::setw(14) << std::fixed << (*iter)->pdg_id() << std::setw(14) << std::fixed
126 << (*iter)->momentum().px() << std::setw(14) << std::fixed << (*iter)->momentum().py()
127 << std::setw(14) << std::fixed << (*iter)->momentum().pz() << std::endl;
136 std::vector<const reco::GenParticle*>
particles;
137 particles.reserve(initSize);
138 for (reco::GenParticleCollection::const_iterator iter = genParticles->begin(); iter != genParticles->end(); ++iter) {
139 if ((*iter).status() == 1) {
140 particles.push_back(&*iter);
142 std::cout <<
"reco " << std::setw(14) << std::fixed << (*iter).pdgId() << std::setw(14) << std::fixed
143 << (*iter).px() << std::setw(14) << std::fixed << (*iter).py() << std::setw(14) << std::fixed
144 << (*iter).pz() << std::endl;
149 unsigned int nReco = particles.size();
150 unsigned int nHepMC = hepmcGPCollection.size();
153 for (
unsigned int i = 0;
i < particles.size(); ++
i) {
154 if (particles[
i]->collisionId() != 0)
162 std::vector<int> hepmcMatchIndex;
163 hepmcMatchIndex.reserve(initSize);
169 if (nReco != nHepMC) {
171 <<
"Collection size inconsistency: HepMC::GenParticle = " << nHepMC <<
" reco::GenParticle = " << nReco;
176 for (
unsigned int i = 0;
i < nReco; ++
i) {
177 for (
unsigned int j = 0;
j < nHepMC; ++
j) {
179 hepmcMatchIndex.push_back((
int)j);
180 if (hepmcGPCollection[j]->momentum().
rho() != 0.) {
181 double reso = 1. - particles[
i]->p() / hepmcGPCollection[
j]->momentum().rho();
183 std::cout <<
"Matching momentum: reco = " << particles[
i]->p()
184 <<
" HepMC = " << hepmcGPCollection[
j]->momentum().rho() <<
" resoultion = " << reso << std::endl;
195 unsigned int nMatched = hepmcMatchIndex.size();
197 if (nMatched != nReco) {
198 edm::LogWarning(
"IncorrectMatching") <<
"Incorrect number of matched indexes: GenParticle = " << nReco
199 <<
" matched indexes = " << nMatched;
203 unsigned int nWrMatch = 0;
205 for (
unsigned int i = 0;
i < nMatched; ++
i) {
206 for (
unsigned int j =
i + 1;
j < nMatched; ++
j) {
207 if (hepmcMatchIndex[
i] == hepmcMatchIndex[
j]) {
210 <<
"Multiple matching occurencies for GenParticle barcode = " << barcodeList[
theIndex];
225 int nJetsCentral = 0;
228 std::vector<double>
jetEta;
229 jetEta.reserve(initSize);
231 for (reco::GenJetCollection::const_iterator iter = genJets->begin(); iter != genJets->end(); ++iter) {
233 double pt = (*iter).pt();
241 double eta = (*iter).eta();
242 if (std::fabs(eta) < 2.5)
244 jetEta.push_back(eta);
261 if (jetEta.size() > 1) {
262 for (
unsigned int i = 0;
i < jetEta.size();
i++) {
263 for (
unsigned int j =
i + 1;
j < jetEta.size();
j++) {
264 deltaEta =
std::min(deltaEta, std::fabs(jetEta[
i] - jetEta[
j]));
277 if (hepmcP->pdg_id() != recoP->
pdgId())
279 if (std::fabs(hepmcP->momentum().px() - recoP->
px()) < std::fabs(
matchPr_ * hepmcP->momentum().px()) &&
280 std::fabs(hepmcP->momentum().py() - recoP->
py()) < std::fabs(
matchPr_ * hepmcP->momentum().py()) &&
281 std::fabs(hepmcP->momentum().pz() - recoP->
pz()) < std::fabs(
matchPr_ * hepmcP->momentum().pz())) {
MonitorElement * genJetCentral
MonitorElement * genMatched
double pz() const final
z coordinate of momentum vector
MonitorElement * multipleMatching
virtual void setCurrentFolder(std::string const &fullpath)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
MonitorElement * genJetEta
MonitorElement * genJetEnergy
MonitorElement * genJetTotPt
edm::InputTag genparticleCollection_
bool matchParticles(const HepMC::GenParticle *&, const reco::GenParticle *&)
static const double deltaEta
MonitorElement * genJetMult
edm::InputTag hepmcCollection_
int pdgId() const final
PDG identifier.
double px() const final
x coordinate of momentum vector
MonitorElement * genJetDeltaEtaMin
edm::EDGetTokenT< reco::GenJetCollection > genjetCollectionToken_
MonitorElement * genJetPto1
MonitorElement * genJetPt
edm::EDGetTokenT< edm::HepMCProduct > hepmcCollectionToken_
double py() const final
y coordinate of momentum vector
MonitorElement * book1dHisto(const std::string &name, const std::string &title, int n, double xmin, double xmax, const std::string &xaxis, const std::string &yaxis)
edm::InputTag genjetCollection_
bool signalParticlesOnly_
MonitorElement * matchedResolution
MonitorElement * genJetPto10
void analyze(const edm::Event &, const edm::EventSetup &) override
void bookHistograms(DQMStore::IBooker &i, edm::Run const &, edm::EventSetup const &) override
MonitorElement * genPMultiplicity
MonitorElement * genJetPhi
MonitorElement * genJetPto100
BasicGenParticleValidation(const edm::ParameterSet &)
Log< level::Warning, false > LogWarning
~BasicGenParticleValidation() override
double weight(const edm::Event &)
edm::EDGetTokenT< reco::GenParticleCollection > genparticleCollectionToken_