Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ReactionPlaneAfterburner.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ReactionPlaneAfterburner.cc
1 
3 
5 
6 #include <phool/getClass.h>
8 #include <phool/PHRandomSeed.h>
9 //phhepmc
12 
13 //hepmc
14 #pragma GCC diagnostic push
15 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
16 #include <HepMC/GenEvent.h>
17 #include <HepMC/GenParticle.h> // for GenParticle
18 #include <HepMC/GenVertex.h> // for GenVertex, GenVertex::part...
19 #include <HepMC/SimpleVector.h>
20 #include <HepMC/HeavyIon.h> // for HeavyIon
21 #pragma GCC diagnostic pop
22 
23 #include <cassert>
24 
25 //____________________________________________________________________________..
27  SubsysReco(name)
28 {
29  RandomGenerator = gsl_rng_alloc(gsl_rng_mt19937);
30 }
31 
32 //____________________________________________________________________________..
34 {
35  gsl_rng_free(RandomGenerator);
36 }
37 
38 //____________________________________________________________________________..
40 {
41  unsigned int seed = PHRandomSeed();
42  gsl_rng_set(RandomGenerator, seed);
44 }
45 
46 //____________________________________________________________________________..
48 {
49  //get event
50  PHHepMCGenEventMap *genevtmap = findNode::getClass<PHHepMCGenEventMap>(topNode, "PHHepMCGenEventMap");
51  for (auto & iter : *genevtmap)
52  {
53  PHHepMCGenEvent *genevt = iter.second;
54  HepMC::GenEvent *evt = genevt->getEvent();
55  assert(evt);
56  HepMC::HeavyIon *hi = evt->heavy_ion();
57  if (hi)
58  {
59  double psi = hi->event_plane_angle();
60  if(psi != 0){
61  std::cout << "ReactionPlaneAfterburner::process_event(PHCompositeNode *topNode) psi = " << psi << std::endl;
62  std::cout<<"non-zero psi found, skipping"<<std::endl;
64  }
65  psi = gsl_rng_uniform_pos(RandomGenerator) * 2 * M_PI;
66  hi->set_event_plane_angle(psi);
67  //rotate all particles and vertices
68  for (HepMC::GenEvent::particle_iterator p = evt->particles_begin(); p != evt->particles_end(); ++p)
69  {
70  HepMC::FourVector v = (*p)->momentum();
71  double px = v.px();
72  double py = v.py();
73  v.setPx(px * cos(psi) - py * sin(psi));
74  v.setPy(px * sin(psi) + py * cos(psi));
75  (*p)->set_momentum(v);
76  }
77  for (HepMC::GenEvent::vertex_iterator v = evt->vertices_begin(); v != evt->vertices_end(); ++v)
78  {
79  HepMC::FourVector pos = (*v)->position();
80  double x = pos.x();
81  double y = pos.y();
82  pos.setX(x * cos(psi) - y * sin(psi));
83  pos.setY(x * sin(psi) + y * cos(psi));
84  (*v)->set_position(pos);
85  }
86  }
87  else{
88  std::cout<<"ReactionPlaneAfterburner::process_event: no heavy ion info found, exiting"<<std::endl;
90  }
91  }
93 }
94 
95 
96 
97