-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12645 from richard-cms/HIN-MC-PhotonFilters_71X
Add new GenFilter for use by HI photon team (71X)
- Loading branch information
Showing
3 changed files
with
180 additions
and
0 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
GeneratorInterface/GenFilters/interface/PythiaFilterMultiMother.h
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,54 @@ | ||
#ifndef PYTHIAFILTERMULTIMOTHER_h | ||
#define PYTHIAFILTERMULTIMOTHER_h | ||
|
||
|
||
// 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 | ||
// | ||
namespace edm { | ||
class HepMCProduct; | ||
} | ||
|
||
class PythiaFilterMultiMother : public edm::EDFilter { | ||
public: | ||
explicit PythiaFilterMultiMother(const edm::ParameterSet&); | ||
~PythiaFilterMultiMother(); | ||
|
||
|
||
virtual bool filter(edm::Event&, const edm::EventSetup&); | ||
private: | ||
// ----------member data --------------------------- | ||
|
||
edm::EDGetTokenT<edm::HepMCProduct> token_; | ||
int particleID; | ||
double minpcut; | ||
double maxpcut; | ||
double minptcut; | ||
double maxptcut; | ||
double minetacut; | ||
double maxetacut; | ||
double minrapcut; | ||
double maxrapcut; | ||
double minphicut; | ||
double maxphicut; | ||
|
||
double rapidity; | ||
|
||
int status; | ||
std::vector<int> motherIDs; | ||
int processID; | ||
}; | ||
#endif |
124 changes: 124 additions & 0 deletions
124
GeneratorInterface/GenFilters/src/PythiaFilterMultiMother.cc
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,124 @@ | ||
|
||
#include "GeneratorInterface/GenFilters/interface/PythiaFilterMultiMother.h" | ||
|
||
#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" | ||
#include <iostream> | ||
|
||
using namespace edm; | ||
using namespace std; | ||
|
||
|
||
PythiaFilterMultiMother::PythiaFilterMultiMother(const edm::ParameterSet& iConfig) : | ||
token_(consumes<edm::HepMCProduct>(iConfig.getUntrackedParameter("moduleLabel",std::string("generator")))), | ||
particleID(iConfig.getUntrackedParameter("ParticleID", 0)), | ||
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)), | ||
status(iConfig.getUntrackedParameter("Status", 0)), | ||
motherIDs(iConfig.getUntrackedParameter("MotherIDs", std::vector<int>{0})), | ||
processID(iConfig.getUntrackedParameter("ProcessID", 0)) | ||
{ | ||
//now do what ever initialization is needed | ||
|
||
} | ||
|
||
|
||
PythiaFilterMultiMother::~PythiaFilterMultiMother() | ||
{ | ||
|
||
// do anything here that needs to be done at desctruction time | ||
// (e.g. close files, deallocate resources etc.) | ||
|
||
} | ||
|
||
|
||
// | ||
// member functions | ||
// | ||
|
||
// ------------ method called to produce the data ------------ | ||
bool PythiaFilterMultiMother::filter(edm::Event& iEvent, const edm::EventSetup& iSetup) | ||
{ | ||
using namespace edm; | ||
bool accepted = false; | ||
Handle<HepMCProduct> evt; | ||
iEvent.getByToken(token_, evt); | ||
|
||
const HepMC::GenEvent * myGenEvent = evt->GetEvent(); | ||
|
||
if(processID == 0 || processID == myGenEvent->signal_process_id()) { | ||
|
||
for ( HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin(); | ||
p != myGenEvent->particles_end(); ++p ) { | ||
|
||
rapidity = 0.5*log( ((*p)->momentum().e()+(*p)->momentum().pz()) / ((*p)->momentum().e()-(*p)->momentum().pz()) ); | ||
|
||
if ( abs((*p)->pdg_id()) == particleID | ||
&& (*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 ) { | ||
|
||
|
||
for(std::vector<int>::const_iterator motherID = motherIDs.begin(); motherID != motherIDs.end(); ++motherID) { | ||
if (status == 0 && *motherID == 0){ | ||
accepted = true; | ||
} | ||
if (status != 0 && *motherID == 0){ | ||
if ((*p)->status() == status) | ||
accepted = true; | ||
} | ||
|
||
HepMC::GenParticle* mother = (*((*p)->production_vertex()->particles_in_const_begin())); | ||
|
||
if (status == 0 && *motherID != 0){ | ||
if (abs(mother->pdg_id()) == abs(*motherID)) { | ||
accepted = true; | ||
} | ||
} | ||
if (status != 0 && *motherID != 0){ | ||
|
||
if ((*p)->status() == status && abs(mother->pdg_id()) == abs(*motherID)){ | ||
accepted = true; | ||
|
||
} | ||
} | ||
} | ||
|
||
/* | ||
if (status == 0 && motherID != 0){ | ||
if (abs(((*p)->mother())->pdg_id()) == abs(motherID)) { | ||
accepted = true; | ||
} | ||
} | ||
if (status != 0 && motherID != 0){ | ||
if ((*p)->status() == status && abs(((*p)->mother())->pdg_id()) == abs(motherID)){ | ||
accepted = true; | ||
} | ||
} | ||
*/ | ||
|
||
} | ||
} | ||
|
||
} else { accepted = true; } | ||
|
||
if (accepted){ | ||
return true; } else {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