Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4EtaPhiParameterization.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4EtaPhiParameterization.cc
2 
3 #include <Geant4/G4ThreeVector.hh>
4 #include <Geant4/G4Tubs.hh>
5 #include <Geant4/G4Types.hh> // for G4int
6 #include <Geant4/G4VPhysicalVolume.hh>
7 
8 #include <algorithm> // for copy
9 #include <cmath>
10 #include <cstdlib>
11 #include <iostream>
12 #include <iterator>
13 
15  unsigned int neta, // Binning in eta
16  double minEta, // "
17  double maxEta, // "
18  unsigned int nphi, // number of phi bins
19  double startPhi,
20  double deltaPhi,
21  double radiusIn, // Radius of inner face of cylinder
22  double radiusOut, // Radius of outer face of cylinder
23  double centerZ // Z of center of set
24  )
25  : _neta(neta)
26  , _minEta(minEta)
27  , _maxEta(maxEta)
28  , _nphi(nphi)
29  , _startPhi(startPhi)
30  , _deltaPhi(deltaPhi)
31  , _radiusIn(radiusIn)
32  , _radiusOut(radiusOut)
33  , _centerZ(centerZ)
34 {
35  if (_maxEta < _minEta)
36  {
37  std::cout << " invalid eta, max<min"
38  << " etamin: " << _minEta
39  << " etamax: " << _maxEta
40  << std::endl;
41  exit(1);
42  }
43 
44  if ((_radiusIn < 0.0) || (_radiusOut < 0.0) || (_radiusOut < _radiusIn))
45  {
46  std::cout << " invalid radius parameters:"
47  << " radiusIn: " << radiusIn
48  << " radiusOut: " << radiusOut
49  << std::endl;
50  exit(1);
51  }
52 
53  double totalEta = _maxEta - _minEta;
54  double dEta = totalEta / _neta;
55  for (unsigned int i = 0; i < neta; i++)
56  {
57  // Compute the edges of this eta bin
58  double etaMin = _minEta + dEta * i;
59  double etaMax = etaMin + dEta;
60  //double eta = _minEta + dEta * (i + 0.5);
61  // Compute the corresponding Z positions of the edges
62  double zmin = _centerZ + _radiusIn * std::sinh(etaMin);
63  double zmax = _centerZ + _radiusIn * std::sinh(etaMax);
64  // Z positions is halfway between the edges
65  double zpos = (zmin + zmax) / 2.0;
66  double zhalf = (zmax - zmin) / 2.0;
67  _zpos.push_back(zpos);
68  _zhalf.push_back(zhalf);
69  }
70 
71  for (unsigned int i = 0; i < _nphi; i++)
72  {
73  _phi0.push_back(_startPhi + i * _deltaPhi);
74  _phi1.push_back(_startPhi + (i + 1) * _deltaPhi);
75  }
76 
77  // Build lookup vectors for the copyNo->(ieta, iphi) translation
78  //
79  for (unsigned int i = 0; i < _neta * _nphi; i++)
80  {
81  div_t q = div((int)i, (int)_nphi);
82  int ieta = q.quot;
83  int iphi = q.rem;
84  _ieta.push_back(ieta);
85  _iphi.push_back(iphi);
86  }
87 }
88 
90 {
91  std::cout << "PHG4EtaPhiParameterization::~PHG4EtaPhiParameterization: Alas, poor Yorick! I knew him, Horatio"
92  << std::endl;
93 }
94 
95 void PHG4EtaPhiParameterization::Print(std::ostream& os) const
96 {
97  os << "PhiEtaPhiParameterization: NETA x NPHI = " << _neta << " x " << _nphi << std::endl;
98  os << "Zpos: ";
99  std::copy(_zpos.begin(), _zpos.end(), std::ostream_iterator<double>(os, " "));
100  os << std::endl;
101  os << "Phi0: ";
102  std::copy(_phi0.begin(), _phi0.end(), std::ostream_iterator<double>(os, " "));
103  os << std::endl;
104  os << "Phi1: ";
105  std::copy(_phi0.begin(), _phi0.end(), std::ostream_iterator<double>(os, " "));
106  os << std::endl;
107 }
108 
110 {
111  int iring = copyNo / _nphi;
112  G4ThreeVector origin(0, 0, _zpos.at(iring));
113  physVol->SetTranslation(origin);
114  physVol->SetRotation(0);
115 }
116 
117 void PHG4EtaPhiParameterization::ComputeDimensions(G4Tubs& ring, const G4int copyNo,
118  const G4VPhysicalVolume*) const
119 {
120  int ieta = GetIEta(copyNo);
121  int iphi = GetIPhi(copyNo);
122  double phi = _phi0.at(iphi);
123  double dphi = _phi1.at(iphi) - phi;
124  ring.SetZHalfLength(_zhalf.at(ieta));
125  ring.SetInnerRadius(_radiusIn);
126  ring.SetOuterRadius(_radiusOut);
127  ring.SetStartPhiAngle(phi);
128  ring.SetDeltaPhiAngle(dphi);
129 }