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))
40 nEvt = dqm.
book1dHisto(
"nEvt",
"n analyzed Events", 1, 0., 1.,
"",
"Number of Events");
43 genPMultiplicity = dqm.
book1dHisto(
"genPMultiplicty",
"Log(No. all GenParticles)", 50, -1, 5,
"log_{10}(N_{All GenParticles})",
"Number of Events");
45 genMatched = dqm.
book1dHisto(
"genMatched",
"Difference reco - matched", 50, -25, 25,
"N_{All GenParticles}-N_{Matched}",
"Number of Events");
47 multipleMatching = dqm.
book1dHisto(
"multipleMatching",
"multiple reco HepMC matching", 50, 0, 50,
"N_{multiple reco HepMC matching}",
"Number of Events");
49 matchedResolution = dqm.
book1dHisto(
"matchedResolution",
"log10(momentum difference of matched particles)", 70, -10., -3.,
"log_{10}(#DeltaP_{matched Particles})",
"Number of Events");
52 genJetMult = dqm.
book1dHisto(
"genJetMult",
"GenJet multiplicity", 50, 0, 50,
"N_{gen-jets}",
"Number of Events");
53 genJetEnergy = dqm.
book1dHisto(
"genJetEnergy",
"Log10(GenJet energy)", 60, -1, 5,
"log_{10}(E^{gen-jets}) (log_{10}(GeV))",
"Number of Events");
54 genJetPt = dqm.
book1dHisto(
"genJetPt",
"Log10(GenJet pt)", 60, -1, 5,
"log_{10}(P_{t}^{gen-jets}) (log_{10}(GeV))",
"Number of Events");
55 genJetEta = dqm.
book1dHisto(
"genJetEta",
"GenJet eta", 220, -11, 11,
"#eta^{gen-jets}",
"Number of Events");
56 genJetPhi = dqm.
book1dHisto(
"genJetPhi",
"GenJet phi", 360, -180, 180,
"#phi^{gen-jets} (rad)",
"Number of Events");
57 genJetDeltaEtaMin = dqm.
book1dHisto(
"genJetDeltaEtaMin",
"GenJet minimum rapidity gap", 30, 0, 30,
"#delta#eta_{min}^{gen-jets}",
"Number of Events");
59 genJetPto1 = dqm.
book1dHisto(
"genJetPto1",
"GenJet multiplicity above 1 GeV", 50, 0, 50,
"N_{gen-jets P_{t}>1GeV}",
"Number of Events");
60 genJetPto10 = dqm.
book1dHisto(
"genJetPto10",
"GenJet multiplicity above 10 GeV", 50, 0, 50,
"N_{gen-jets P_{t}>10GeV}",
"Number of Events");
61 genJetPto100 = dqm.
book1dHisto(
"genJetPto100",
"GenJet multiplicity above 100 GeV", 50, 0, 50,
"N_{gen-jets P_{t}>100GeV}",
"Number of Events");
62 genJetCentral = dqm.
book1dHisto(
"genJetCentral",
"GenJet multiplicity |eta|.lt.2.5", 50, 0, 50,
"N_{gen-jets |#eta|#leq2.5}",
"Number of Events");
64 genJetTotPt = dqm.
book1dHisto(
"genJetTotPt",
"Log10(GenJet total pt)", 100, -5, 5,
"log_{10}(#SigmaP_{t}^{gen-jets}) (log_{10}(GeV))",
"Number of Events");
72 unsigned int initSize = 1000;
79 HepMC::GenEvent *myGenEvent =
new HepMC::GenEvent(*(evt->
GetEvent()));
85 std::vector<const HepMC::GenParticle*> hepmcGPCollection;
86 std::vector<int> barcodeList;
87 hepmcGPCollection.reserve(initSize);
88 barcodeList.reserve(initSize);
91 for (HepMC::GenEvent::particle_const_iterator iter = myGenEvent->particles_begin(); iter != myGenEvent->particles_end(); ++iter){
92 if ( (*iter)->status() == 1) {
93 hepmcGPCollection.push_back(*iter);
94 barcodeList.push_back((*iter)->barcode());
97 << (*iter)->momentum().py() << std::setw(14) <<
std::fixed << (*iter)->momentum().pz() << std::endl;
107 std::vector<const reco::GenParticle*>
particles;
108 particles.reserve(initSize);
109 for (reco::GenParticleCollection::const_iterator iter=genParticles->begin();iter!=genParticles->end();++iter){
110 if ( (*iter).status() == 1) {
111 particles.push_back(&*iter);
114 << std::setw(14) <<
std::fixed << (*iter).py() << std::setw(14) <<
std::fixed << (*iter).pz() << std::endl;
119 unsigned int nReco = particles.size();
120 unsigned int nHepMC = hepmcGPCollection.size();
125 std::vector<int> hepmcMatchIndex;
126 hepmcMatchIndex.reserve(initSize);
132 if ( nReco != nHepMC ) {
133 edm::LogWarning(
"CollectionSizeInconsistency") <<
"Collection size inconsistency: HepMC::GenParticle = " << nHepMC <<
" reco::GenParticle = " << nReco;
138 for (
unsigned int i = 0;
i < nReco; ++
i ){
139 for (
unsigned int j = 0; j < nHepMC; ++j ){
141 hepmcMatchIndex.push_back((
int)j);
142 if ( hepmcGPCollection[j]->momentum().
rho() != 0. ) {
143 double reso = 1.-particles[
i]->p()/hepmcGPCollection[j]->momentum().rho();
145 std::cout <<
"Matching momentum: reco = " << particles[
i]->p() <<
" HepMC = " 146 << hepmcGPCollection[j]->momentum().rho() <<
" resoultion = " << reso << std::endl;
156 unsigned int nMatched = hepmcMatchIndex.size();
158 if ( nMatched != nReco ) {
159 edm::LogWarning(
"IncorrectMatching") <<
"Incorrect number of matched indexes: GenParticle = " << nReco <<
" matched indexes = " << nMatched;
163 unsigned int nWrMatch = 0;
165 for (
unsigned int i = 0;
i < nMatched; ++
i ){
166 for (
unsigned int j =
i+1; j < nMatched; ++j ){
167 if ( hepmcMatchIndex[
i] == hepmcMatchIndex[j] ) {
168 int theIndex = hepmcMatchIndex[
i];
169 edm::LogWarning(
"DuplicatedMatching") <<
"Multiple matching occurencies for GenParticle barcode = " << barcodeList[theIndex];
184 int nJetsCentral = 0;
187 std::vector<double>
jetEta;
188 jetEta.reserve(initSize);
190 for (reco::GenJetCollection::const_iterator iter=genJets->begin();iter!=genJets->end();++iter){
192 double pt = (*iter).pt();
194 if (pt > 1.) nJetso1++;
195 if (pt > 10.) nJetso10++;
196 if (pt > 100.) nJetso100++;
197 double eta = (*iter).eta();
198 if ( std::fabs(eta) < 2.5 ) nJetsCentral++;
199 jetEta.push_back(eta);
216 if ( jetEta.size() > 1 ) {
217 for (
unsigned int i = 0;
i < jetEta.size();
i++){
218 for (
unsigned int j =
i+1; j < jetEta.size(); j++){
219 deltaEta =
std::min(deltaEta,std::fabs(jetEta[
i]-jetEta[j]));
233 if ( hepmcP->pdg_id() != recoP->
pdgId() )
return state;
234 if ( std::fabs(hepmcP->momentum().px()-recoP->
px()) < std::fabs(
matchPr_*hepmcP->momentum().px()) &&
235 std::fabs(hepmcP->momentum().py()-recoP->
py()) < std::fabs(
matchPr_*hepmcP->momentum().py()) &&
236 std::fabs(hepmcP->momentum().pz()-recoP->
pz()) < std::fabs(
matchPr_*hepmcP->momentum().pz())) {
int pdgId() const final
PDG identifier.
MonitorElement * genJetCentral
MonitorElement * genMatched
MonitorElement * multipleMatching
bool getByToken(EDGetToken token, Handle< PROD > &result) const
double px() const final
x coordinate of momentum vector
MonitorElement * genJetEta
MonitorElement * genJetEnergy
MonitorElement * genJetTotPt
edm::InputTag genparticleCollection_
bool matchParticles(const HepMC::GenParticle *&, const reco::GenParticle *&)
MonitorElement * book1dHisto(std::string name, std::string title, int n, double xmin, double xmax, std::string xaxis, std::string yaxis)
static const double deltaEta
MonitorElement * genJetMult
edm::InputTag hepmcCollection_
MonitorElement * genJetDeltaEtaMin
double pz() const final
z coordinate of momentum vector
edm::EDGetTokenT< reco::GenJetCollection > genjetCollectionToken_
MonitorElement * genJetPto1
MonitorElement * genJetPt
edm::EDGetTokenT< edm::HepMCProduct > hepmcCollectionToken_
edm::InputTag genjetCollection_
void setCurrentFolder(const std::string &fullpath)
const HepMC::GenEvent * GetEvent() const
MonitorElement * matchedResolution
double py() const final
y coordinate of momentum vector
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 &)
~BasicGenParticleValidation() override
double weight(const edm::Event &)
edm::EDGetTokenT< reco::GenParticleCollection > genparticleCollectionToken_