File indexing completed on 2025-08-03 08:16:22
0001
0002 #include "HIJINGFlipAfterburner.h"
0003
0004 #include <fun4all/Fun4AllReturnCodes.h>
0005
0006 #include <phool/PHCompositeNode.h>
0007 #include <phool/getClass.h>
0008
0009 #include <phhepmc/PHHepMCGenEvent.h>
0010 #include <phhepmc/PHHepMCGenEventMap.h>
0011
0012
0013 #pragma GCC diagnostic push
0014 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
0015 #include <HepMC/GenEvent.h>
0016 #include <HepMC/GenParticle.h> // for GenParticle
0017 #include <HepMC/GenVertex.h> // for GenVertex, GenVertex::part...
0018 #include <HepMC/SimpleVector.h>
0019 #pragma GCC diagnostic pop
0020
0021 #include <cassert>
0022
0023
0024 HIJINGFlipAfterburner::HIJINGFlipAfterburner(const std::string &name)
0025 : SubsysReco(name)
0026 {
0027 }
0028
0029
0030 int HIJINGFlipAfterburner::process_event(PHCompositeNode *topNode)
0031 {
0032 if (!doFlip)
0033 {
0034 doFlip = true;
0035 }
0036 else
0037 {
0038 doFlip = false;
0039 PHHepMCGenEventMap *genevtmap = findNode::getClass<PHHepMCGenEventMap>(topNode, "PHHepMCGenEventMap");
0040 for (auto &iter : *genevtmap)
0041 {
0042 PHHepMCGenEvent *genevt = iter.second;
0043 HepMC::GenEvent *evt = genevt->getEvent();
0044 assert(evt);
0045 flipZDirection(evt);
0046 }
0047 }
0048
0049 return Fun4AllReturnCodes::EVENT_OK;
0050 }
0051
0052 void HIJINGFlipAfterburner::flipZDirection(HepMC::GenEvent *event)
0053 {
0054 assert(event);
0055
0056 for (auto v = event->vertices_begin(); v != event->vertices_end(); ++v)
0057 {
0058 HepMC::FourVector position = (*v)->position();
0059
0060 position.setZ(-position.z());
0061 position.setX(-position.x());
0062
0063 (*v)->set_position(position);
0064 }
0065
0066 for (auto p = event->particles_begin(); p != event->particles_end(); ++p)
0067 {
0068 HepMC::FourVector momentum = (*p)->momentum();
0069
0070 momentum.setPz(-momentum.pz());
0071 momentum.setPx(-momentum.px());
0072
0073 (*p)->set_momentum(momentum);
0074 }
0075 }