Skip to content

Commit 0c511fd

Browse files
author
Michele Mormile
committed
code checks patch applied
1 parent 26439f3 commit 0c511fd

File tree

2 files changed

+81
-91
lines changed

2 files changed

+81
-91
lines changed

GeneratorInterface/GenFilters/plugins/PhotonGenFilter.cc

Lines changed: 74 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -9,105 +9,96 @@ using namespace std;
99
PhotonGenFilter::PhotonGenFilter(const edm::ParameterSet &iConfig)
1010
: token_(consumes<edm::HepMCProduct>(
1111
edm::InputTag(iConfig.getUntrackedParameter("moduleLabel", std::string("generator")), "unsmeared"))),
12-
betaBoost(iConfig.getUntrackedParameter("BetaBoost", 0.))
13-
{
14-
// Constructor implementation
15-
vector<int> defpid;
16-
defpid.push_back(0);
17-
particleID = iConfig.getUntrackedParameter<vector<int>>("ParticleID", defpid);
18-
vector<double> defptmin;
19-
defptmin.push_back(0.);
20-
ptMin = iConfig.getUntrackedParameter<vector<double>>("MinPt", defptmin);
12+
betaBoost(iConfig.getUntrackedParameter("BetaBoost", 0.)) {
13+
// Constructor implementation
14+
vector<int> defpid;
15+
defpid.push_back(0);
16+
particleID = iConfig.getUntrackedParameter<vector<int>>("ParticleID", defpid);
17+
vector<double> defptmin;
18+
defptmin.push_back(0.);
19+
ptMin = iConfig.getUntrackedParameter<vector<double>>("MinPt", defptmin);
2120

22-
vector<double> defetamin;
23-
defetamin.push_back(-10.);
24-
etaMin = iConfig.getUntrackedParameter<vector<double>>("MinEta", defetamin);
25-
vector<double> defetamax;
26-
defetamax.push_back(10.);
27-
etaMax = iConfig.getUntrackedParameter<vector<double>>("MaxEta", defetamax);
28-
vector<int> defstat;
29-
defstat.push_back(0);
30-
status = iConfig.getUntrackedParameter<vector<int>>("Status", defstat);
31-
vector<double> defdrmin;
32-
defdrmin.push_back(0.);
33-
drMin = iConfig.getUntrackedParameter<vector<double>>("drMin", defdrmin);
21+
vector<double> defetamin;
22+
defetamin.push_back(-10.);
23+
etaMin = iConfig.getUntrackedParameter<vector<double>>("MinEta", defetamin);
24+
vector<double> defetamax;
25+
defetamax.push_back(10.);
26+
etaMax = iConfig.getUntrackedParameter<vector<double>>("MaxEta", defetamax);
27+
vector<int> defstat;
28+
defstat.push_back(0);
29+
status = iConfig.getUntrackedParameter<vector<int>>("Status", defstat);
30+
vector<double> defdrmin;
31+
defdrmin.push_back(0.);
32+
drMin = iConfig.getUntrackedParameter<vector<double>>("drMin", defdrmin);
3433

35-
// check if beta is smaller than 1
36-
if (std::abs(betaBoost) >= 1)
37-
{
38-
edm::LogError("PhotonGenFilter") << "Input beta boost is >= 1 !";
39-
}
34+
// check if beta is smaller than 1
35+
if (std::abs(betaBoost) >= 1) {
36+
edm::LogError("PhotonGenFilter") << "Input beta boost is >= 1 !";
37+
}
4038
}
4139

42-
PhotonGenFilter::~PhotonGenFilter()
43-
{
44-
// Destructor implementation
40+
PhotonGenFilter::~PhotonGenFilter() {
41+
// Destructor implementation
4542
}
4643

47-
bool PhotonGenFilter::filter(edm::StreamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const
48-
{
49-
using namespace edm;
50-
Handle<HepMCProduct> evt;
51-
iEvent.getByToken(token_, evt);
52-
const HepMC::GenEvent * myGenEvent = evt->GetEvent();
44+
bool PhotonGenFilter::filter(edm::StreamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const {
45+
using namespace edm;
46+
Handle<HepMCProduct> evt;
47+
iEvent.getByToken(token_, evt);
48+
const HepMC::GenEvent *myGenEvent = evt->GetEvent();
5349

54-
for (HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin(); p != myGenEvent->particles_end();
55-
++p)
56-
{
57-
for (unsigned int i = 0; i < particleID.size(); i++)
58-
{
59-
if (particleID[i] == (*p)->pdg_id() || particleID[i] == 0)
60-
{
61-
if ((*p)->momentum().perp() > ptMin[i] && ((*p)->status() == status[i] || status[i] == 0))
50+
for (HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin(); p != myGenEvent->particles_end();
51+
++p) {
52+
for (unsigned int i = 0; i < particleID.size(); i++) {
53+
if (particleID[i] == (*p)->pdg_id() || particleID[i] == 0) {
54+
if ((*p)->momentum().perp() > ptMin[i] && ((*p)->status() == status[i] || status[i] == 0)) {
55+
HepMC::FourVector mom = MCFilterZboostHelper::zboost((*p)->momentum(), betaBoost);
56+
if (mom.eta() > etaMin[i] && mom.eta() < etaMax[i]) {
57+
bool accepted_photon = true;
58+
double phi = (*p)->momentum().phi();
59+
double eta = mom.eta();
60+
for (HepMC::GenEvent::particle_const_iterator q = myGenEvent->particles_begin();
61+
q != myGenEvent->particles_end();
62+
++q) {
63+
if (&p != &q) {
64+
if ((*q)->momentum().perp() > 2 && (*q)->pdg_id() != 22 &&
65+
(*q)->status() == 1) // && abs((*q)->charge()) > 0)
6266
{
63-
HepMC::FourVector mom = MCFilterZboostHelper::zboost((*p)->momentum(), betaBoost);
64-
if (mom.eta() > etaMin[i] && mom.eta() < etaMax[i])
65-
{
66-
bool accepted_photon = true;
67-
double phi = (*p)->momentum().phi();
68-
double eta = mom.eta();
69-
for (HepMC::GenEvent::particle_const_iterator q = myGenEvent->particles_begin(); q != myGenEvent->particles_end();
70-
++q)
71-
{
72-
if (&p != &q)
73-
{
74-
if ((*q)->momentum().perp() > 2 && (*q)->pdg_id() != 22 && (*q)->status() == 1)// && abs((*q)->charge()) > 0)
75-
{
76-
double phi2 = (*p)->momentum().phi();
77-
double deltaphi = fabs(phi - phi2);
78-
if (deltaphi > M_PI)
79-
deltaphi = 2. * M_PI - deltaphi;
80-
HepMC::FourVector mom2 = MCFilterZboostHelper::zboost((*q)->momentum(), betaBoost);
81-
double eta2 = mom2.eta();
82-
double deltaeta = fabs(eta - eta2);
83-
double deltaR = sqrt(deltaeta * deltaeta + deltaphi * deltaphi);
84-
if (deltaR < 0.1)
85-
accepted_photon = false;
86-
}
87-
}
88-
}
89-
if (accepted_photon) return true;
90-
}
67+
double phi2 = (*p)->momentum().phi();
68+
double deltaphi = fabs(phi - phi2);
69+
if (deltaphi > M_PI)
70+
deltaphi = 2. * M_PI - deltaphi;
71+
HepMC::FourVector mom2 = MCFilterZboostHelper::zboost((*q)->momentum(), betaBoost);
72+
double eta2 = mom2.eta();
73+
double deltaeta = fabs(eta - eta2);
74+
double deltaR = sqrt(deltaeta * deltaeta + deltaphi * deltaphi);
75+
if (deltaR < 0.1)
76+
accepted_photon = false;
9177
}
78+
}
9279
}
80+
if (accepted_photon)
81+
return true;
82+
}
9383
}
84+
}
9485
}
86+
}
9587

96-
// Implementation for event filtering
97-
return false; // Return true if event passes the filter, false otherwise
88+
// Implementation for event filtering
89+
return false; // Return true if event passes the filter, false otherwise
9890
}
9991

100-
void PhotonGenFilter::fillDescriptions(edm::ConfigurationDescriptions &descriptions)
101-
{
102-
edm::ParameterSetDescription desc;
103-
desc.addUntracked<double>("MaxEta", 2.4);
104-
desc.addUntracked<double>("MinEta", -2.4);
105-
desc.addUntracked<double>("MinPt", 20.);
106-
desc.addUntracked<int>("Status", 1);
107-
desc.addUntracked<int>("ParticleID", 22);
108-
desc.addUntracked<double>("drMin", 0.1);
92+
void PhotonGenFilter::fillDescriptions(edm::ConfigurationDescriptions &descriptions) {
93+
edm::ParameterSetDescription desc;
94+
desc.addUntracked<double>("MaxEta", 2.4);
95+
desc.addUntracked<double>("MinEta", -2.4);
96+
desc.addUntracked<double>("MinPt", 20.);
97+
desc.addUntracked<int>("Status", 1);
98+
desc.addUntracked<int>("ParticleID", 22);
99+
desc.addUntracked<double>("drMin", 0.1);
109100

110-
descriptions.add("PhotonGenFilter", desc);
101+
descriptions.add("PhotonGenFilter", desc);
111102
}
112103

113104
DEFINE_FWK_MODULE(PhotonGenFilter);

GeneratorInterface/GenFilters/plugins/PhotonGenFilter.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@
1212

1313
#include "FWCore/ParameterSet/interface/ParameterSet.h"
1414

15-
1615
namespace edm {
1716
class HepMCProduct;
1817
}
1918

2019
class PhotonGenFilter : public edm::global::EDFilter<> {
2120
public:
22-
explicit PhotonGenFilter(const edm::ParameterSet&);
23-
~PhotonGenFilter() override;
24-
25-
bool filter(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
26-
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
21+
explicit PhotonGenFilter(const edm::ParameterSet&);
22+
~PhotonGenFilter() override;
23+
24+
bool filter(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
25+
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
26+
2727
private:
28-
// Private member variables and functions
28+
// Private member variables and functions
2929

3030
const edm::EDGetTokenT<edm::HepMCProduct> token_;
3131
std::vector<int> particleID;
@@ -35,7 +35,6 @@ class PhotonGenFilter : public edm::global::EDFilter<> {
3535
std::vector<double> drMin;
3636
std::vector<int> status;
3737
const double betaBoost;
38-
3938
};
4039

4140
#endif

0 commit comments

Comments
 (0)