ECCE @ EIC 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"
3 #include "PHG4CylinderGeom.h"
4 
6 #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 
19 using namespace std;
20 
22  SubsysReco(name),
23  phi(NAN),
24  theta(NAN),
25  eloss(NAN),
26  layer(-9999)
27 {}
28 
29 int
31 {
32  string hitnodename = "G4HIT_" + detector;
33  string geonodename = "CYLINDERGEOM_" + detector;
34  PHG4CylinderGeomContainer *geo = findNode::getClass<PHG4CylinderGeomContainer>(topNode , geonodename.c_str());
35  if (! geo)
36  {
37  cout << "cannot find geo node " << geonodename << endl;
39  }
40  PHG4HitContainer *hits_ = findNode::getClass<PHG4HitContainer>( topNode , hitnodename.c_str());
41  if (! hits_)
42  {
43  cout << "cannot find hit node " << hitnodename << endl;
45  }
46  PHG4CylinderGeom *mygeom = geo->GetLayerGeom(layer);
47  double inner_radius = mygeom->get_radius();
48  double outer_radius = inner_radius + mygeom->get_thickness();
49  PHG4Hit *hit = new PHG4Hitv1();
50  hit->set_layer((unsigned int)layer);
51  double x0 = inner_radius * cos(phi * M_PI / 180.);
52  double y0 = inner_radius * sin(phi * M_PI / 180.);
53  double z0 = inner_radius * cos(theta * M_PI / 180.);
54  double x1 = outer_radius * cos(phi * M_PI / 180.);
55  double y1 = outer_radius * sin(phi * M_PI / 180.);
56  double z1 = outer_radius * cos(theta * M_PI / 180.);
57  hit->set_x(0, x0);
58  hit->set_y(0, y0);
59  hit->set_z(0, z0);
60  hit->set_x(1, x1);
61  hit->set_y(1, y1);
62  hit->set_z(1, z1);
63  hit->set_edep(eloss);
64  hit->set_trkid(-1);
65  hits_->AddHit(layer, hit);
66  if (Verbosity() > 0)
67  {
68  cout << "phi " << phi << " inner rad: " << inner_radius
69  << ", outer rad: " << outer_radius
70  << " x0/y0/z0: " << x0 << "/" << y0 << "/" << z0
71  << " x1/y1/z1: " << x1 << "/" << y1 << "/" << z1
72  << " edep: " << eloss
73  << endl;
74  }
76 }