@@ -9,105 +9,96 @@ using namespace std;
99PhotonGenFilter::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
113104DEFINE_FWK_MODULE (PhotonGenFilter);
0 commit comments