Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:21:58

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 PHG4EtaParameterization::PHG4EtaParameterization(
0015     unsigned int neta,  // Binning in eta
0016     double minEta,      // "
0017     double maxEta,      // "
0018     double startPhi,
0019     double deltaPhi,
0020     double radiusIn,   // Radius of inner face of cylinder
0021     double radiusOut,  // Radius of outer face of cylinder
0022     double centerZ     // Z of center of set
0023     )
0024   : _neta(neta)
0025   , _minEta(minEta)
0026   , _maxEta(maxEta)
0027   , _startPhi(startPhi)
0028   , _deltaPhi(deltaPhi)
0029   , _radiusIn(radiusIn)
0030   , _radiusOut(radiusOut)
0031   , _centerZ(centerZ)
0032 {
0033   if (_maxEta < _minEta)
0034   {
0035     std::cout << " invalid eta, max<min"
0036               << " etamin: " << _minEta
0037               << " etamax: " << _maxEta
0038               << std::endl;
0039     exit(1);
0040   }
0041   //    G4Exception("PHG4EtaParameterization::PHG4EtaParameterization", "invalid eta, max<min",G4ExceptionSeverity::FatalException);
0042 
0043   if ((_radiusIn < 0.0) || (_radiusOut < 0.0) || (_radiusOut < _radiusIn))
0044   {
0045     std::cout << " invalid radius parameters:"
0046               << " radiusIn: " << radiusIn
0047               << " radiusOut: " << radiusOut
0048               << std::endl;
0049     exit(1);
0050   }
0051   //    G4Exception("PHG4EtaParameterization::PHG4EtaParameterization: invalid radius parameters");
0052 
0053   double totalEta = _maxEta - _minEta;
0054   double dEta = totalEta / _neta;
0055   // double minZ = 1e6;
0056   // double maxZ = -1e6;
0057   for (unsigned int i = 0; i < neta; i++)
0058   {
0059     // Compute the edges of this eta bin
0060     double etaMin = _minEta + dEta * i;
0061     double etaMax = etaMin + dEta;
0062     // Compute the corresponding Z positions of the edges
0063     double zmin = _centerZ + _radiusIn * std::sinh(etaMin);
0064     double zmax = _centerZ + _radiusIn * std::sinh(etaMax);
0065     // Z positions is halfway between the edges
0066     double zpos = (zmin + zmax) / 2.0;
0067     double zhalf = (zmax - zmin) / 2.0;
0068     _zpos.push_back(zpos);
0069     _zhalf.push_back(zhalf);
0070     std::cout << zmin << " " << zmax << " " << zpos << " +/- " << zhalf << std::endl;
0071   }
0072 
0073   // Build lookup vectors for the copyNo->(ieta, iphi) translation
0074   //
0075   for (unsigned int i = 0; i < _neta; i++)
0076   {
0077     _ieta.push_back(i);
0078   }
0079 
0080   std::cout << "*********** Constructing PHG4EtaParameterization ***************" << std::endl;
0081   std::cout << std::endl;
0082 
0083   std::cout << "Radii = " << _radiusIn << ", " << _radiusOut << std::endl;
0084   std::cout << "Phi,dPhi = " << _startPhi << ", " << _deltaPhi << std::endl;
0085   std::cout << "Min/Max Z = " << _zpos.front() - _zhalf.front() << " / " << _zpos.back() + _zhalf.back() << std::endl;
0086 
0087   std::cout << std::endl;
0088   std::cout << "********* End Constructing PHG4EtaParameterization *************" << std::endl;
0089 }
0090 
0091 PHG4EtaParameterization::~PHG4EtaParameterization()
0092 {
0093   std::cout << "PHG4EtaParameterization::~PHG4EtaParameterization: Alas, poor Yorick! I knew him, Horatio"
0094             << std::endl;
0095 }
0096 
0097 void PHG4EtaParameterization::Print(std::ostream& os) const
0098 {
0099   os << "PhiEtaParameterization: NETA = " << _neta << std::endl;
0100   os << "Zpos: ";
0101   std::copy(_zpos.begin(), _zpos.end(), std::ostream_iterator<double>(os, " "));
0102   os << std::endl;
0103 }
0104 
0105 void PHG4EtaParameterization::ComputeTransformation(const G4int copyNo, G4VPhysicalVolume* physVol) const
0106 {
0107   int iring = copyNo;
0108   G4ThreeVector origin(0, 0, _zpos.at(iring));
0109   physVol->SetTranslation(origin);
0110   physVol->SetRotation(nullptr);
0111 }
0112 
0113 void PHG4EtaParameterization::ComputeDimensions(G4Tubs& ring, const G4int copyNo,
0114                                                 const G4VPhysicalVolume* /*unused*/) const
0115 {
0116   // int ieta = GetIEta(copyNo);
0117   ring.SetZHalfLength(_zhalf.at(copyNo));
0118   ring.SetInnerRadius(_radiusIn);
0119   ring.SetOuterRadius(_radiusOut);
0120   ring.SetStartPhiAngle(_startPhi);
0121   ring.SetDeltaPhiAngle(_deltaPhi);
0122 }