File indexing completed on 2025-08-05 08:18:08
0001 #include "PHG4EtaParameterization.h"
0002
0003 #include <Geant4/G4ThreeVector.hh>
0004 #include <Geant4/G4Tubs.hh>
0005 #include <Geant4/G4Types.hh> // for G4int
0006 #include <Geant4/G4VPhysicalVolume.hh>
0007
0008 #include <algorithm> // for copy
0009 #include <cmath>
0010 #include <cstdlib>
0011 #include <iostream>
0012 #include <iterator>
0013
0014 using namespace std;
0015
0016 PHG4EtaParameterization::PHG4EtaParameterization(
0017 unsigned int neta,
0018 double minEta,
0019 double maxEta,
0020 double startPhi,
0021 double deltaPhi,
0022 double radiusIn,
0023 double radiusOut,
0024 double centerZ
0025 )
0026 : _neta(neta)
0027 , _minEta(minEta)
0028 , _maxEta(maxEta)
0029 , _startPhi(startPhi)
0030 , _deltaPhi(deltaPhi)
0031 , _radiusIn(radiusIn)
0032 , _radiusOut(radiusOut)
0033 , _centerZ(centerZ)
0034 {
0035 if (_maxEta < _minEta)
0036 {
0037 cout << " invalid eta, max<min"
0038 << " etamin: " << _minEta
0039 << " etamax: " << _maxEta
0040 << endl;
0041 exit(1);
0042 }
0043
0044
0045 if ((_radiusIn < 0.0) || (_radiusOut < 0.0) || (_radiusOut < _radiusIn))
0046 {
0047 cout << " invalid radius parameters:"
0048 << " radiusIn: " << radiusIn
0049 << " radiusOut: " << radiusOut
0050 << endl;
0051 exit(1);
0052 }
0053
0054
0055 double totalEta = _maxEta - _minEta;
0056 double dEta = totalEta / _neta;
0057
0058
0059 for (unsigned int i = 0; i < neta; i++)
0060 {
0061
0062 double etaMin = _minEta + dEta * i;
0063 double etaMax = etaMin + dEta;
0064
0065 double zmin = _centerZ + _radiusIn * std::sinh(etaMin);
0066 double zmax = _centerZ + _radiusIn * std::sinh(etaMax);
0067
0068 double zpos = (zmin + zmax) / 2.0;
0069 double zhalf = (zmax - zmin) / 2.0;
0070 _zpos.push_back(zpos);
0071 _zhalf.push_back(zhalf);
0072 std::cout << zmin << " " << zmax << " " << zpos << " +/- " << zhalf << std::endl;
0073 }
0074
0075
0076
0077 for (unsigned int i = 0; i < _neta; i++)
0078 {
0079 _ieta.push_back(i);
0080 }
0081
0082 std::cout << "*********** Constructing PHG4EtaParameterization ***************" << std::endl;
0083 std::cout << std::endl;
0084
0085 std::cout << "Radii = " << _radiusIn << ", " << _radiusOut << std::endl;
0086 std::cout << "Phi,dPhi = " << _startPhi << ", " << _deltaPhi << std::endl;
0087 std::cout << "Min/Max Z = " << _zpos.front() - _zhalf.front() << " / " << _zpos.back() + _zhalf.back() << std::endl;
0088
0089 std::cout << std::endl;
0090 std::cout << "********* End Constructing PHG4EtaParameterization *************" << std::endl;
0091 }
0092
0093 PHG4EtaParameterization::~PHG4EtaParameterization()
0094 {
0095 std::cout << "PHG4EtaParameterization::~PHG4EtaParameterization: Alas, poor Yorick! I knew him, Horatio"
0096 << std::endl;
0097 }
0098
0099 void PHG4EtaParameterization::Print(std::ostream& os) const
0100 {
0101 os << "PhiEtaParameterization: NETA = " << _neta << std::endl;
0102 os << "Zpos: ";
0103 std::copy(_zpos.begin(), _zpos.end(), std::ostream_iterator<double>(os, " "));
0104 os << std::endl;
0105 }
0106
0107 void PHG4EtaParameterization::ComputeTransformation(const G4int copyNo, G4VPhysicalVolume* physVol) const
0108 {
0109 int iring = copyNo;
0110 G4ThreeVector origin(0, 0, _zpos.at(iring));
0111 physVol->SetTranslation(origin);
0112 physVol->SetRotation(nullptr);
0113 }
0114
0115 void PHG4EtaParameterization::ComputeDimensions(G4Tubs& ring, const G4int copyNo,
0116 const G4VPhysicalVolume* ) const
0117 {
0118
0119 ring.SetZHalfLength(_zhalf.at(copyNo));
0120 ring.SetInnerRadius(_radiusIn);
0121 ring.SetOuterRadius(_radiusOut);
0122 ring.SetStartPhiAngle(_startPhi);
0123 ring.SetDeltaPhiAngle(_deltaPhi);
0124 }