Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4GenHit.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4GenHit.cc
1 #include "PHG4GenHit.h"
2 #include "PHG4CylinderGeom.h"
4 
5 #include <g4main/PHG4Hit.h>
7 #include <g4main/PHG4Hitv1.h>
8 
10 #include <fun4all/SubsysReco.h> // for SubsysReco
11 
12 #include <phool/getClass.h>
13 
14 #include <cmath>
15 #include <iostream> // for operator<<, basic_ostream
16 
17 class PHCompositeNode;
18 
20  : SubsysReco(name)
21 {
22 }
23 
25 {
26  std::string hitnodename = "G4HIT_" + detector;
27  std::string geonodename = "CYLINDERGEOM_" + detector;
28  PHG4CylinderGeomContainer *geo = findNode::getClass<PHG4CylinderGeomContainer>(topNode, geonodename);
29  if (!geo)
30  {
31  std::cout << "cannot find geo node " << geonodename << std::endl;
33  }
34  PHG4HitContainer *hits_ = findNode::getClass<PHG4HitContainer>(topNode, hitnodename);
35  if (!hits_)
36  {
37  std::cout << "cannot find hit node " << hitnodename << std::endl;
39  }
40  PHG4CylinderGeom *mygeom = geo->GetLayerGeom(layer);
41  double inner_radius = mygeom->get_radius();
42  double outer_radius = inner_radius + mygeom->get_thickness();
43  PHG4Hit *hit = new PHG4Hitv1();
44  hit->set_layer((unsigned int) layer);
45  double x0 = inner_radius * cos(phi * M_PI / 180.);
46  double y0 = inner_radius * sin(phi * M_PI / 180.);
47  double z0 = inner_radius * cos(theta * M_PI / 180.);
48  double x1 = outer_radius * cos(phi * M_PI / 180.);
49  double y1 = outer_radius * sin(phi * M_PI / 180.);
50  double z1 = outer_radius * cos(theta * M_PI / 180.);
51  hit->set_x(0, x0);
52  hit->set_y(0, y0);
53  hit->set_z(0, z0);
54  hit->set_x(1, x1);
55  hit->set_y(1, y1);
56  hit->set_z(1, z1);
57  hit->set_edep(eloss);
58  hit->set_trkid(-1);
59  hits_->AddHit(layer, hit);
60  if (Verbosity() > 0)
61  {
62  std::cout << "phi " << phi << " inner rad: " << inner_radius
63  << ", outer rad: " << outer_radius
64  << " x0/y0/z0: " << x0 << "/" << y0 << "/" << z0
65  << " x1/y1/z1: " << x1 << "/" << y1 << "/" << z1
66  << " edep: " << eloss
67  << std::endl;
68  }
70 }