11 #include "CLHEP/Units/defs.h"
12 #include "CLHEP/Units/PhysicalConstants.h"
18 hepmcCollection_(iPSet.getParameter<edm::
InputTag>(
"hepmcCollection")),
19 genparticleCollection_(iPSet.getParameter<edm::
InputTag>(
"genparticleCollection")),
20 genjetCollection_(iPSet.getParameter<edm::
InputTag>(
"genjetsCollection")),
21 matchPr_(iPSet.getParameter<double>(
"matchingPrecision")),
22 verbosity_(iPSet.getUntrackedParameter<unsigned int>(
"verbosity",0))
80 unsigned int initSize = 1000;
87 HepMC::GenEvent *myGenEvent =
new HepMC::GenEvent(*(evt->GetEvent()));
93 std::vector<const HepMC::GenParticle*> hepmcGPCollection;
94 std::vector<int> barcodeList;
95 hepmcGPCollection.reserve(initSize);
96 barcodeList.reserve(initSize);
99 for (HepMC::GenEvent::particle_const_iterator iter = myGenEvent->particles_begin(); iter != myGenEvent->particles_end(); ++iter){
100 if ( (*iter)->status() == 1) {
101 hepmcGPCollection.push_back(*iter);
102 barcodeList.push_back((*iter)->barcode());
104 std::cout <<
"HepMC " << std::setw(14) << std::fixed << (*iter)->pdg_id() << std::setw(14) << std::fixed << (*iter)->momentum().px() << std::setw(14) << std::fixed
105 << (*iter)->momentum().py() << std::setw(14) << std::fixed << (*iter)->momentum().pz() << std::endl;
115 std::vector<const reco::GenParticle*> particles;
116 particles.reserve(initSize);
117 for (reco::GenParticleCollection::const_iterator iter=genParticles->begin();iter!=genParticles->end();++iter){
118 if ( (*iter).status() == 1) {
119 particles.push_back(&*iter);
121 std::cout <<
"reco " << std::setw(14) << std::fixed << (*iter).pdgId() << std::setw(14) << std::fixed << (*iter).px()
122 << std::setw(14) << std::fixed << (*iter).py() << std::setw(14) << std::fixed << (*iter).pz() << std::endl;
127 unsigned int nReco = particles.size();
128 unsigned int nHepMC = hepmcGPCollection.size();
133 std::vector<int> hepmcMatchIndex;
134 hepmcMatchIndex.reserve(initSize);
140 if ( nReco != nHepMC ) {
141 edm::LogWarning(
"CollectionSizeInconsistency") <<
"Collection size inconsistency: HepMC::GenParticle = " << nHepMC <<
" reco::GenParticle = " << nReco;
146 for (
unsigned int i = 0;
i < nReco; ++
i ){
147 for (
unsigned int j = 0;
j < nHepMC; ++
j ){
149 hepmcMatchIndex.push_back((
int)j);
150 if ( hepmcGPCollection[j]->momentum().
rho() != 0. ) {
151 double reso = 1.-particles[
i]->p()/hepmcGPCollection[
j]->momentum().rho();
153 std::cout <<
"Matching momentum: reco = " << particles[
i]->p() <<
" HepMC = "
154 << hepmcGPCollection[
j]->momentum().rho() <<
" resoultion = " << reso << std::endl;
164 unsigned int nMatched = hepmcMatchIndex.size();
166 if ( nMatched != nReco ) {
167 edm::LogWarning(
"IncorrectMatching") <<
"Incorrect number of matched indexes: GenParticle = " << nReco <<
" matched indexes = " << nMatched;
171 unsigned int nWrMatch = 0;
173 for (
unsigned int i = 0;
i < nMatched; ++
i ){
174 for (
unsigned int j =
i+1;
j < nMatched; ++
j ){
175 if ( hepmcMatchIndex[
i] == hepmcMatchIndex[
j] ) {
176 int theIndex = hepmcMatchIndex[
i];
177 edm::LogWarning(
"DuplicatedMatching") <<
"Multiple matching occurencies for GenParticle barcode = " << barcodeList[theIndex];
192 int nJetsCentral = 0;
195 std::vector<double>
jetEta;
196 jetEta.reserve(initSize);
198 for (reco::GenJetCollection::const_iterator iter=genJets->begin();iter!=genJets->end();++iter){
200 double pt = (*iter).pt();
202 if (pt > 1.) nJetso1++;
203 if (pt > 10.) nJetso10++;
204 if (pt > 100.) nJetso100++;
205 double eta = (*iter).eta();
206 if ( std::fabs(eta) < 2.5 ) nJetsCentral++;
207 jetEta.push_back(eta);
224 if ( jetEta.size() > 1 ) {
225 for (
unsigned int i = 0;
i < jetEta.size();
i++){
226 for (
unsigned int j =
i+1;
j < jetEta.size();
j++){
227 deltaEta =
std::min(deltaEta,std::fabs(jetEta[
i]-jetEta[
j]));
241 if ( hepmcP->pdg_id() != recoP->
pdgId() )
return state;
242 if ( std::fabs(hepmcP->momentum().px()-recoP->
px()) < std::fabs(
matchPr_*hepmcP->momentum().px()) &&
243 std::fabs(hepmcP->momentum().py()-recoP->
py()) < std::fabs(
matchPr_*hepmcP->momentum().py()) &&
244 std::fabs(hepmcP->momentum().pz()-recoP->
pz()) < std::fabs(
matchPr_*hepmcP->momentum().pz())) {
virtual void beginRun(const edm::Run &, const edm::EventSetup &)
MonitorElement * genJetCentral
edm::ESHandle< HepPDT::ParticleDataTable > fPDGTable
PDT table.
MonitorElement * genMatched
DQMStore * dbe
ME's "container".
MonitorElement * multipleMatching
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
virtual int pdgId() const GCC11_FINAL
PDG identifier.
virtual void analyze(const edm::Event &, const edm::EventSetup &)
MonitorElement * genJetEta
MonitorElement * genJetEnergy
MonitorElement * genJetTotPt
edm::InputTag genparticleCollection_
bool matchParticles(const HepMC::GenParticle *&, const reco::GenParticle *&)
virtual ~BasicGenParticleValidation()
virtual double pz() const GCC11_FINAL
z coordinate of momentum vector
virtual double py() const GCC11_FINAL
y coordinate of momentum vector
void getData(T &iHolder) const
MonitorElement * genJetMult
edm::InputTag hepmcCollection_
MonitorElement * genJetDeltaEtaMin
MonitorElement * genJetPto1
virtual double px() const GCC11_FINAL
x coordinate of momentum vector
MonitorElement * genJetPt
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
edm::InputTag genjetCollection_
MonitorElement * matchedResolution
MonitorElement * genJetPto10
MonitorElement * genPMultiplicity
MonitorElement * genJetPhi
MonitorElement * genJetPto100
BasicGenParticleValidation(const edm::ParameterSet &)
double weight(const edm::Event &)
virtual void endRun(const edm::Run &, const edm::EventSetup &)
void setCurrentFolder(const std::string &fullpath)