-
Notifications
You must be signed in to change notification settings - Fork 0
Test2 #13
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
base: master
Are you sure you want to change the base?
Test2 #13
Changes from all commits
5adbf5c
35a6b31
2e9ccc7
ce0d3af
6ddbed5
3394890
67423a3
014600a
2a654bd
3e94777
667a5cc
45a8c5b
1ba5701
815ceef
d0a251d
0f8adaa
49ff81c
0c648ef
9e7cf18
514cbf6
5c1fb73
3f30522
0785178
e06322f
89660ef
ab568eb
7e9afac
2f32421
3fe3cd3
774e982
34e66d1
c6b077c
f5a6ec8
af55b25
8d61916
3a535f0
16716a5
83bb8a6
5ec7de1
15b6eed
66f7822
ed4562e
7e92dc7
a573ec3
fcb6312
c3eb9c5
36cd47a
b4b37c2
c361551
23ef520
498393a
e18445b
ebbee62
3d0a2e4
5628bd2
c7adbfd
62c7a10
5d5a980
fd44486
3505cae
51336ae
b0df38c
ee08eb4
2b02a79
11cb711
f63acd8
47ab938
7eb599f
5d10d3e
f9373cf
90a2f62
7b52f16
ce2f8a3
bcc0827
5b6afda
0f402d4
85e50bb
e3fffce
2cbb506
d7d58e1
63e54e6
04e747f
53eb479
1fe3891
bfcf35d
69de5bb
3d19299
64138d4
2525b3b
bd1ae49
04d5376
7b60428
99b5ed4
bea795c
774ed82
d1152d0
6c11c5d
7030fb8
ec8e8a6
68b618f
c12d8ae
f4e898f
61ecab4
4da13b0
ad7235e
27c0ce0
6242823
c6d1c91
2601ddc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,369 @@ | ||
| #include "HepMCParticleTrigger.h" | ||
|
|
||
| #include <fun4all/SubsysReco.h> | ||
| #include <phhepmc/PHHepMCGenEvent.h> | ||
| #include <phhepmc/PHHepMCGenEventMap.h> | ||
|
|
||
| #include <fun4all/Fun4AllReturnCodes.h> | ||
|
|
||
| #include <phool/PHCompositeNode.h> | ||
| #include <phool/getClass.h> | ||
|
|
||
| #include <fastjet/JetDefinition.hh> | ||
|
|
||
| #include <HepMC/GenEvent.h> | ||
|
|
||
| #include <fastjet/PseudoJet.hh> | ||
| #include <map> | ||
| #include <string> | ||
| #include <vector> | ||
| //____________________________________________________________________________.. | ||
| // NOLINTNEXTLINE(bugprone-easily-swappable-parameters) | ||
| HepMCParticleTrigger::HepMCParticleTrigger(float trigger_thresh, int n_incom, bool up_lim, const std::string& name) | ||
| : SubsysReco(name) | ||
| , threshold(trigger_thresh) | ||
| , goal_event_number(n_incom) | ||
| , set_event_limit(up_lim) | ||
| , _theEtaHigh(1.1) | ||
| , _theEtaLow(-1.1) | ||
| , _thePtHigh(999.9) | ||
| , _thePtLow(0) | ||
| , _thePHigh(999.9) | ||
| , _thePLow(-999.9) | ||
| , _thePzHigh(999.9) | ||
| , _thePzLow(-999.9) | ||
| , | ||
|
|
||
| _doEtaHighCut(true) | ||
| , _doEtaLowCut(true) | ||
| , _doBothEtaCut(true) | ||
| , | ||
|
|
||
| _doAbsEtaHighCut(false) | ||
| , _doAbsEtaLowCut(false) | ||
| , _doBothAbsEtaCut(false) | ||
| , | ||
|
|
||
| _doPtHighCut(false) | ||
| , _doPtLowCut(false) | ||
| , _doBothPtCut(false) | ||
| , | ||
| _doPHighCut(false) | ||
| , _doPLowCut(false) | ||
| , _doBothPCut(false) | ||
| , | ||
|
|
||
| _doPzHighCut(false) | ||
| , _doPzLowCut(false) | ||
| , _doBothPzCut(false) | ||
| { | ||
| if (threshold != 0) | ||
| { | ||
| _doPtLowCut = true; | ||
| _thePtLow = threshold; | ||
| } | ||
| } | ||
|
|
||
| //____________________________________________________________________________.. | ||
| int HepMCParticleTrigger::process_event(PHCompositeNode* topNode) | ||
| { | ||
| // std::cout << "HepMCParticleTrigger::process_event(PHCompositeNode *topNode) Processing Event" << std::endl; | ||
| n_evts++; | ||
| if (this->set_event_limit == true) | ||
| { // needed to keep all HepMC output at the same number of events | ||
| if (n_good >= this->goal_event_number) | ||
| { | ||
| return Fun4AllReturnCodes::ABORTEVENT; | ||
| } | ||
| } | ||
| bool good_event{false}; | ||
| PHHepMCGenEventMap* phg = findNode::getClass<PHHepMCGenEventMap>(topNode, "PHHepMCGenEventMap"); | ||
| if (!phg) | ||
| { | ||
| return Fun4AllReturnCodes::ABORTEVENT; | ||
| } | ||
| for (PHHepMCGenEventMap::ConstIter eventIter = phg->begin(); eventIter != phg->end(); ++eventIter) | ||
| { | ||
| PHHepMCGenEvent* hepev = eventIter->second; | ||
| if (!hepev) | ||
| { | ||
| return Fun4AllReturnCodes::ABORTEVENT; | ||
| } | ||
| HepMC::GenEvent* ev = hepev->getEvent(); | ||
| if (!ev) | ||
| { | ||
| return Fun4AllReturnCodes::ABORTEVENT; | ||
| } | ||
| good_event = isGoodEvent(ev); | ||
| if (!good_event) | ||
| { | ||
| return Fun4AllReturnCodes::ABORTEVENT; | ||
| } | ||
| } | ||
| if (good_event) | ||
| { | ||
| n_good++; | ||
| } | ||
| return Fun4AllReturnCodes::EVENT_OK; | ||
| } | ||
| void HepMCParticleTrigger::AddParticle(int particlePid) | ||
| { | ||
| _theParticles.push_back(particlePid); | ||
| return; | ||
| } | ||
| void HepMCParticleTrigger::AddParticles(const std::vector<int>& particles) | ||
| { | ||
| for (auto p : particles) | ||
| { | ||
| _theParticles.push_back(p); | ||
| } | ||
| return; | ||
| } | ||
|
|
||
| void HepMCParticleTrigger::SetPtHigh(double pt) | ||
| { | ||
| _thePtHigh = pt; | ||
| _doPtHighCut = true; | ||
| if (_doPtLowCut) | ||
| { | ||
| _doBothPtCut = true; | ||
| } | ||
| return; | ||
| } | ||
| void HepMCParticleTrigger::SetPtLow(double pt) | ||
| { | ||
| _thePtLow = pt; | ||
| _doPtLowCut = true; | ||
| if (_doPtHighCut) | ||
| { | ||
| _doBothPtCut = true; | ||
| } | ||
| return; | ||
| } | ||
| void HepMCParticleTrigger::SetPtHighLow(double ptHigh, double ptLow) | ||
| { | ||
| _thePtHigh = ptHigh; | ||
| _doPtHighCut = true; | ||
| _thePtLow = ptLow; | ||
| _doPtLowCut = true; | ||
| _doBothPtCut = true; | ||
| return; | ||
| } | ||
| void HepMCParticleTrigger::SetPHigh(double pt) | ||
| { | ||
| _thePHigh = pt; | ||
| _doPHighCut = true; | ||
| if (_doPLowCut) | ||
| { | ||
| _doBothPCut = true; | ||
| } | ||
| return; | ||
| } | ||
| void HepMCParticleTrigger::SetPLow(double pt) | ||
| { | ||
| _thePLow = pt; | ||
| _doPLowCut = true; | ||
| if (_doPHighCut) | ||
| { | ||
| _doBothPCut = true; | ||
| } | ||
| return; | ||
| } | ||
| void HepMCParticleTrigger::SetPHighLow(double ptHigh, double ptLow) | ||
| { | ||
| _thePHigh = ptHigh; | ||
| _doPHighCut = true; | ||
| _thePLow = ptLow; | ||
| _doPLowCut = true; | ||
| _doBothPCut = true; | ||
| return; | ||
| } | ||
| void HepMCParticleTrigger::SetPzHigh(double pt) | ||
| { | ||
| _thePzHigh = pt; | ||
| _doPzHighCut = true; | ||
| if (_doPzLowCut) | ||
| { | ||
| _doBothPzCut = true; | ||
| } | ||
| return; | ||
| } | ||
| void HepMCParticleTrigger::SetPzLow(double pt) | ||
| { | ||
| _thePzLow = pt; | ||
| _doPzLowCut = true; | ||
| if (_doPzHighCut) | ||
| { | ||
| _doBothPzCut = true; | ||
| } | ||
| return; | ||
| } | ||
| void HepMCParticleTrigger::SetPzHighLow(double ptHigh, double ptLow) | ||
| { | ||
| _thePzHigh = ptHigh; | ||
| _doPzHighCut = true; | ||
| _thePzLow = ptLow; | ||
| _doPzLowCut = true; | ||
| _doBothPzCut = true; | ||
| return; | ||
| } | ||
| void HepMCParticleTrigger::SetEtaHigh(double pt) | ||
| { | ||
| _theEtaHigh = pt; | ||
| _doEtaHighCut = true; | ||
| if (_doEtaLowCut) | ||
| { | ||
| _doBothEtaCut = true; | ||
| } | ||
| return; | ||
| } | ||
| void HepMCParticleTrigger::SetEtaLow(double pt) | ||
| { | ||
| _theEtaLow = pt; | ||
| _doEtaLowCut = true; | ||
| if (_doEtaHighCut) | ||
| { | ||
| _doBothEtaCut = true; | ||
| } | ||
| return; | ||
| } | ||
| void HepMCParticleTrigger::SetEtaHighLow(double ptHigh, double ptLow) | ||
| { | ||
| _theEtaHigh = ptHigh; | ||
| _doEtaHighCut = true; | ||
| _theEtaLow = ptLow; | ||
| _doEtaLowCut = true; | ||
| _doBothEtaCut = true; | ||
| return; | ||
| } | ||
| void HepMCParticleTrigger::SetAbsEtaHigh(double pt) | ||
| { | ||
| _theEtaHigh = pt; | ||
| _doAbsEtaHighCut = true; | ||
| if (_doAbsEtaLowCut) | ||
| { | ||
| _doBothAbsEtaCut = true; | ||
| } | ||
| return; | ||
| } | ||
| void HepMCParticleTrigger::SetAbsEtaLow(double pt) | ||
| { | ||
| _theEtaLow = pt; | ||
| _doAbsEtaLowCut = true; | ||
| if (_doAbsEtaHighCut) | ||
| { | ||
| _doBothAbsEtaCut = true; | ||
| } | ||
| return; | ||
| } | ||
| void HepMCParticleTrigger::SetAbsEtaHighLow(double ptHigh, double ptLow) | ||
| { | ||
| _theEtaHigh = ptHigh; | ||
| _doAbsEtaHighCut = true; | ||
| _theEtaLow = ptLow; | ||
| _doAbsEtaLowCut = true; | ||
| _doBothAbsEtaCut = true; | ||
| return; | ||
|
Comment on lines
+239
to
+266
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AbsEta setters overwrite signed-eta thresholds (risk of asymmetric selection).
🔧 Suggested direction (separate abs-eta thresholds) void HepMCParticleTrigger::SetAbsEtaHigh(double pt)
{
- _theEtaHigh = pt;
+ _theAbsEtaHigh = pt;
_doAbsEtaHighCut = true;
if (_doAbsEtaLowCut)
{
_doBothAbsEtaCut = true;
}
return;
}
void HepMCParticleTrigger::SetAbsEtaLow(double pt)
{
- _theEtaLow = pt;
+ _theAbsEtaLow = pt;
_doAbsEtaLowCut = true;
if (_doAbsEtaHighCut)
{
_doBothAbsEtaCut = true;
}
return;
}
void HepMCParticleTrigger::SetAbsEtaHighLow(double ptHigh, double ptLow)
{
- _theEtaHigh = ptHigh;
+ _theAbsEtaHigh = ptHigh;
_doAbsEtaHighCut = true;
- _theEtaLow = ptLow;
+ _theAbsEtaLow = ptLow;
_doAbsEtaLowCut = true;
_doBothAbsEtaCut = true;
return;
}
- if ((_doAbsEtaHighCut || _doBothAbsEtaCut) && std::abs(eta) > _theEtaHigh)
+ if ((_doAbsEtaHighCut || _doBothAbsEtaCut) && std::abs(eta) > _theAbsEtaHigh)
{
continue;
}
- if ((_doAbsEtaLowCut || _doBothAbsEtaCut) && std::abs(eta) < _theEtaLow)
+ if ((_doAbsEtaLowCut || _doBothAbsEtaCut) && std::abs(eta) < _theAbsEtaLow)
{
continue;
}Note: this requires adding Also applies to: 312-318 🤖 Prompt for AI Agents |
||
| } | ||
| bool HepMCParticleTrigger::isGoodEvent(HepMC::GenEvent* e1) | ||
| { | ||
| // this is really just the call to actually evaluate and return the filter | ||
| /*if (this->threshold == 0) | ||
| { | ||
| return true; | ||
| }*/ | ||
| std::vector<int> n_trigger_particles = getParticles(e1); | ||
| for (auto ntp : n_trigger_particles) | ||
| { | ||
| if (ntp <= 0) | ||
| { | ||
| return false; // make sure all particles have at least 1 | ||
| } | ||
| } | ||
| return true; | ||
| } | ||
|
|
||
| std::vector<int> HepMCParticleTrigger::getParticles(HepMC::GenEvent* e1) | ||
| { | ||
| std::vector<int> n_trigger{}; | ||
| std::map<int, int> particle_types; | ||
| for (HepMC::GenEvent::particle_const_iterator iter = e1->particles_begin(); iter != e1->particles_end(); ++iter) | ||
| { | ||
| if (m_doStableParticleOnly && ((*iter)->end_vertex() || (*iter)->status() != 1)) | ||
| { | ||
| continue; | ||
| } | ||
| auto p = (*iter)->momentum(); | ||
| float px = p.px(); | ||
| float py = p.py(); | ||
| float pz = p.pz(); | ||
| float p_M = std::sqrt(std::pow(px, 2) + std::pow(py, 2) + std::pow(pz, 2)); | ||
| float pt = std::sqrt(std::pow(px, 2) + std::pow(py, 2)); | ||
| int pid = std::abs((*iter)->pdg_id()); | ||
| double eta = p.eta(); | ||
| if ((_doEtaHighCut || _doBothEtaCut) && eta > _theEtaHigh) | ||
| { | ||
| continue; | ||
| } | ||
| if ((_doEtaLowCut || _doBothEtaCut) && eta < _theEtaLow) | ||
| { | ||
| continue; | ||
| } | ||
| if ((_doAbsEtaHighCut || _doBothAbsEtaCut) && std::abs(eta) > _theEtaHigh) | ||
| { | ||
| continue; | ||
| } | ||
| if ((_doAbsEtaLowCut || _doBothAbsEtaCut) && std::abs(eta) < _theEtaLow) | ||
| { | ||
| continue; | ||
| } | ||
| if ((_doPtHighCut || _doBothPtCut) && pt > _thePtHigh) | ||
| { | ||
| continue; | ||
| } | ||
| if ((_doPtLowCut || _doBothPtCut) && pt < _thePtLow) | ||
| { | ||
| continue; | ||
| } | ||
| if ((_doPHighCut || _doBothPCut) && p_M > _thePHigh) | ||
| { | ||
| continue; | ||
| } | ||
| if ((_doPLowCut || _doBothPCut) && p_M < _thePLow) | ||
| { | ||
| continue; | ||
| } | ||
| if ((_doPzHighCut || _doBothPzCut) && pz > _thePzHigh) | ||
| { | ||
| continue; | ||
| } | ||
| if ((_doPzLowCut || _doBothPzCut) && pz < _thePzLow) | ||
| { | ||
| continue; | ||
| } | ||
| if (particle_types.contains(pid)) | ||
| { | ||
| particle_types[pid]++; | ||
| } | ||
| else | ||
| { | ||
| particle_types[pid] = 1; | ||
| } | ||
| } | ||
| n_trigger.reserve(_theParticles.size()); | ||
| for (auto p : _theParticles) | ||
| { | ||
| n_trigger.push_back(particleAboveThreshold(particle_types, p)); // make sure we have at least one of each required particle | ||
| } | ||
| return n_trigger; | ||
| } | ||
| int HepMCParticleTrigger::particleAboveThreshold(const std::map<int, int>& n_particles, int trigger_particle) | ||
| { | ||
| // search through for the number of identified trigger particles passing cuts | ||
| auto it = n_particles.find(std::abs(trigger_particle)); | ||
| if (it != n_particles.end()) | ||
| { | ||
| return it->second; | ||
| } | ||
| return 0; | ||
| } | ||
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.
Fix initializer list syntax (standalone commas).
The empty comma-only lines create empty initializers and will not compile.
🐛 Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents