-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Backporting to 71X: adding Pythia8 Filter for genparticles HT #12800
Merged
cmsbuild
merged 2 commits into
cms-sw:CMSSW_7_1_X
from
alefisico:CMSSW_7_1_X_PythiaHTFilterv2
Feb 1, 2016
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#ifndef PYTHIAFILTERHT_h | ||
#define PYTHIAFILTERHT_h | ||
// -*- C++ -*- | ||
// | ||
// Package: PythiaFilterHT | ||
// Class: PythiaFilterHT | ||
// | ||
/**\class PythiaFilterHT PythiaFilterHT.cc IOMC/PythiaFilterHT/src/PythiaFilterHT.cc | ||
|
||
Description: <one line class summary> | ||
|
||
Implementation: | ||
<Notes on implementation> | ||
*/ | ||
// | ||
// Original Author: Alejandro Gomez Espinosa | ||
// | ||
// | ||
|
||
|
||
// system include files | ||
#include <memory> | ||
|
||
// user include files | ||
#include "FWCore/Framework/interface/Frameworkfwd.h" | ||
#include "FWCore/Framework/interface/EDFilter.h" | ||
|
||
#include "FWCore/Framework/interface/Event.h" | ||
#include "FWCore/Framework/interface/MakerMacros.h" | ||
|
||
#include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
|
||
|
||
// | ||
// class decleration | ||
// | ||
|
||
class PythiaFilterHT : public edm::EDFilter { | ||
public: | ||
explicit PythiaFilterHT(const edm::ParameterSet&); | ||
~PythiaFilterHT(); | ||
|
||
|
||
virtual bool filter(edm::Event&, const edm::EventSetup&); | ||
private: | ||
// ----------member data --------------------------- | ||
|
||
std::string label_; | ||
int particleID; | ||
double minpcut; | ||
double maxpcut; | ||
double minptcut; | ||
double minhtcut; | ||
double maxptcut; | ||
double minetacut; | ||
double maxetacut; | ||
double minrapcut; | ||
double maxrapcut; | ||
double maxphicut; | ||
double minphicut; | ||
|
||
double rapidity; | ||
|
||
int status; | ||
int motherID; | ||
int processID; | ||
int theNumberOfTestedEvt; | ||
int theNumberOfSelected; | ||
int maxnumberofeventsinrun; | ||
}; | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
#include "GeneratorInterface/GenFilters/interface/PythiaFilterHT.h" | ||
#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" | ||
#include <iostream> | ||
|
||
using namespace edm; | ||
using namespace std; | ||
|
||
|
||
PythiaFilterHT::PythiaFilterHT(const edm::ParameterSet& iConfig) : | ||
label_(iConfig.getUntrackedParameter("moduleLabel",std::string("generator"))), | ||
/*minpcut(iConfig.getUntrackedParameter("MinP", 0.)), | ||
maxpcut(iConfig.getUntrackedParameter("MaxP", 10000.)), | ||
minptcut(iConfig.getUntrackedParameter("MinPt", 0.)), | ||
maxptcut(iConfig.getUntrackedParameter("MaxPt", 10000.)), | ||
minetacut(iConfig.getUntrackedParameter("MinEta", -10.)), | ||
maxetacut(iConfig.getUntrackedParameter("MaxEta", 10.)), | ||
minrapcut(iConfig.getUntrackedParameter("MinRapidity", -20.)), | ||
maxrapcut(iConfig.getUntrackedParameter("MaxRapidity", 20.)), | ||
minphicut(iConfig.getUntrackedParameter("MinPhi", -3.5)), | ||
maxphicut(iConfig.getUntrackedParameter("MaxPhi", 3.5)),*/ | ||
minhtcut(iConfig.getUntrackedParameter("MinHT", 0.)), | ||
motherID(iConfig.getUntrackedParameter("MotherID", 0)) { | ||
|
||
theNumberOfTestedEvt = 0; | ||
theNumberOfSelected = 0; | ||
|
||
cout << " Cut Definition: " << endl; | ||
/*cout << " MinP = " << minpcut << endl; | ||
cout << " MaxP = " << maxpcut << endl; | ||
cout << " MinPt = " << minptcut << endl; | ||
cout << " MaxPt = " << maxptcut << endl; | ||
cout << " MinEta = " << minetacut << endl; | ||
cout << " MaxEta = " << maxetacut << endl; | ||
cout << " MinRapidity = " << minrapcut << endl; | ||
cout << " MaxRapidity = " << maxrapcut << endl; | ||
cout << " MinPhi = " << minphicut << endl; | ||
cout << " MaxPhi = " << maxphicut << endl;*/ | ||
cout << " MinHT = " << minhtcut << endl; | ||
cout << " MotherID = " << motherID << endl; | ||
|
||
} | ||
|
||
|
||
PythiaFilterHT::~PythiaFilterHT() { | ||
std::cout << "Total number of tested events = " << theNumberOfTestedEvt << std::endl; | ||
std::cout << "Total number of accepted events = " << theNumberOfSelected << std::endl; | ||
} | ||
|
||
|
||
// | ||
// member functions | ||
// | ||
|
||
// ------------ method called to produce the data ------------ | ||
bool PythiaFilterHT::filter(edm::Event& iEvent, const edm::EventSetup& iSetup) { | ||
|
||
theNumberOfTestedEvt++; | ||
if(theNumberOfTestedEvt%1000 == 0) cout << "Number of tested events = " << theNumberOfTestedEvt << endl; | ||
|
||
bool accepted = false; | ||
Handle<HepMCProduct> evt; | ||
iEvent.getByLabel(label_, evt); | ||
|
||
const HepMC::GenEvent * myGenEvent = evt->GetEvent(); | ||
|
||
double HT = 0; | ||
|
||
for ( HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin(); p != myGenEvent->particles_end(); ++p ) { | ||
|
||
if ( ( (*p)->status() == 23 ) && ( ( abs( (*p)->pdg_id() ) < 6 ) || ( (*p)->pdg_id() == 21 ) ) ) { | ||
|
||
/*rapidity = 0.5*log( ((*p)->momentum().e()+(*p)->momentum().pz()) / ((*p)->momentum().e()-(*p)->momentum().pz()) ); | ||
|
||
if ( (*p)->momentum().rho() > minpcut | ||
&& (*p)->momentum().rho() < maxpcut | ||
&& (*p)->momentum().perp() > minptcut | ||
&& (*p)->momentum().perp() < maxptcut | ||
&& (*p)->momentum().eta() > minetacut | ||
&& (*p)->momentum().eta() < maxetacut | ||
&& rapidity > minrapcut | ||
&& rapidity < maxrapcut | ||
&& (*p)->momentum().phi() > minphicut | ||
&& (*p)->momentum().phi() < maxphicut ) {*/ | ||
|
||
if ( motherID == 0 ) { | ||
HT += (*p)->momentum().perp(); | ||
} else { | ||
HepMC::GenParticle* mother = (*((*p)->production_vertex()->particles_in_const_begin())); | ||
if (abs(mother->pdg_id()) == abs(motherID)) { | ||
HT += (*p)->momentum().perp(); | ||
} | ||
} | ||
//} | ||
} | ||
} | ||
if ( HT > minhtcut ) accepted = true; | ||
|
||
if (accepted){ | ||
theNumberOfSelected++; | ||
cout << "========> Event preselected " << theNumberOfSelected << " HT = " << HT << endl; | ||
return true; | ||
} else { | ||
//cout << "========> Event rejected HT = " << HT << endl; | ||
return false; | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alefisico
Sorry for the slow review
Please remove the couts. Thanks