ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4EtaParameterization.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4EtaParameterization.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 
14 using namespace std;
15 
17  unsigned int neta, // Binning in eta
18  double minEta, // "
19  double maxEta, // "
20  double startPhi,
21  double deltaPhi,
22  double radiusIn, // Radius of inner face of cylinder
23  double radiusOut, // Radius of outer face of cylinder
24  double centerZ // Z of center of set
25  )
26  : _neta(neta)
27  , _minEta(minEta)
28  , _maxEta(maxEta)
29  , _startPhi(startPhi)
30  , _deltaPhi(deltaPhi)
31  , _radiusIn(radiusIn)
32  , _radiusOut(radiusOut)
33  , _centerZ(centerZ)
34 {
35  if (_maxEta < _minEta)
36  {
37  cout << " invalid eta, max<min"
38  << " etamin: " << _minEta
39  << " etamax: " << _maxEta
40  << endl;
41  exit(1);
42  }
43  // G4Exception("PHG4EtaParameterization::PHG4EtaParameterization", "invalid eta, max<min",G4ExceptionSeverity::FatalException);
44 
45  if ((_radiusIn < 0.0) || (_radiusOut < 0.0) || (_radiusOut < _radiusIn))
46  {
47  cout << " invalid radius parameters:"
48  << " radiusIn: " << radiusIn
49  << " radiusOut: " << radiusOut
50  << endl;
51  exit(1);
52  }
53  // G4Exception("PHG4EtaParameterization::PHG4EtaParameterization: invalid radius parameters");
54 
55  double totalEta = _maxEta - _minEta;
56  double dEta = totalEta / _neta;
57  //double minZ = 1e6;
58  //double maxZ = -1e6;
59  for (unsigned int i = 0; i < neta; i++)
60  {
61  // Compute the edges of this eta bin
62  double etaMin = _minEta + dEta * i;
63  double etaMax = etaMin + dEta;
64  // Compute the corresponding Z positions of the edges
65  double zmin = _centerZ + _radiusIn * std::sinh(etaMin);
66  double zmax = _centerZ + _radiusIn * std::sinh(etaMax);
67  // Z positions is halfway between the edges
68  double zpos = (zmin + zmax) / 2.0;
69  double zhalf = (zmax - zmin) / 2.0;
70  _zpos.push_back(zpos);
71  _zhalf.push_back(zhalf);
72  std::cout << zmin << " " << zmax << " " << zpos << " +/- " << zhalf << std::endl;
73  }
74 
75  // Build lookup vectors for the copyNo->(ieta, iphi) translation
76  //
77  for (unsigned int i = 0; i < _neta; i++)
78  {
79  _ieta.push_back(i);
80  }
81 
82  std::cout << "*********** Constructing PHG4EtaParameterization ***************" << std::endl;
83  std::cout << std::endl;
84 
85  std::cout << "Radii = " << _radiusIn << ", " << _radiusOut << std::endl;
86  std::cout << "Phi,dPhi = " << _startPhi << ", " << _deltaPhi << std::endl;
87  std::cout << "Min/Max Z = " << _zpos.front() - _zhalf.front() << " / " << _zpos.back() + _zhalf.back() << std::endl;
88 
89  std::cout << std::endl;
90  std::cout << "********* End Constructing PHG4EtaParameterization *************" << std::endl;
91 }
92 
94 {
95  std::cout << "PHG4EtaParameterization::~PHG4EtaParameterization: Alas, poor Yorick! I knew him, Horatio"
96  << std::endl;
97 }
98 
99 void PHG4EtaParameterization::Print(std::ostream& os) const
100 {
101  os << "PhiEtaParameterization: NETA = " << _neta << std::endl;
102  os << "Zpos: ";
103  std::copy(_zpos.begin(), _zpos.end(), std::ostream_iterator<double>(os, " "));
104  os << std::endl;
105 }
106 
108 {
109  int iring = copyNo;
110  G4ThreeVector origin(0, 0, _zpos.at(iring));
111  physVol->SetTranslation(origin);
112  physVol->SetRotation(0);
113 }
114 
116  const G4VPhysicalVolume*) const
117 {
118  //int ieta = GetIEta(copyNo);
119  ring.SetZHalfLength(_zhalf.at(copyNo));
124 }