Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-08 08:26:33

0001 
0002 #include <map>
0003 #include <vector>
0004 
0005 #include <TRef.h>
0006 #include <TObject.h>
0007 #include <TVector3.h>
0008 #include <TString.h>
0009 
0010 #ifndef _CHERENKOV_RADIATOR_
0011 #define _CHERENKOV_RADIATOR_
0012 
0013 #include "ParametricSurface.h"
0014 class G4LogicalVolume;
0015 class G4RadiatorMaterial;
0016 
0017 class CherenkovRadiator: public TObject {
0018  public:
0019   // NB: do not want to use physical volume here because a particle can cross more than one of them
0020   // (at the sector boundary), while there is no good reason to separate these contributions;
0021  CherenkovRadiator(const G4LogicalVolume *volume = 0, const G4RadiatorMaterial *material = 0): 
0022   m_LogicalVolume(volume), m_Material(material), 
0023     m_ReferenceRefractiveIndex(0.0), m_ReferenceAttenuationLength(0.0), 
0024     m_ID(0), m_Stat(0), m_AverageTheta(0.0), m_Smearing(0.0), 
0025     m_GaussianSmearing(false), m_TrajectoryBinCount_deprecated(1) {};
0026   ~CherenkovRadiator() {};
0027 
0028   double n( void )                               const { return m_ReferenceRefractiveIndex; };
0029   double GetReferenceAttenuationLength( void )   const { return m_ReferenceAttenuationLength; };
0030 
0031   void SetReferenceRefractiveIndex(double n)   { m_ReferenceRefractiveIndex   = n; };
0032   void SetReferenceAttenuationLength(double l) { m_ReferenceAttenuationLength = l; };
0033 
0034   const G4RadiatorMaterial *GetMaterial( void )  const { return m_Material; };
0035 
0036   ParametricSurface *GetFrontSide(unsigned path) {
0037     if (m_Borders.find(path) == m_Borders.end()) return 0;
0038 
0039     return dynamic_cast<ParametricSurface*>(m_Borders[path].first.GetObject());
0040   };
0041   ParametricSurface *GetRearSide(unsigned path) {
0042     if (m_Borders.find(path) == m_Borders.end()) return 0;
0043 
0044     return dynamic_cast<ParametricSurface*>(m_Borders[path].second.GetObject());
0045   };
0046   std::map<unsigned, std::pair<TRef, TRef>> m_Borders; 
0047 
0048   // Material name in dd4hep world;
0049   void SetAlternativeMaterialName(const char *name) { m_AlternativeMaterialName = name; };
0050   const char *GetAlternativeMaterialName( void ) const { 
0051     return m_AlternativeMaterialName.Data();
0052   };
0053 
0054  protected:
0055   // Run-time variables for the GEANT pass;
0056   const G4LogicalVolume *m_LogicalVolume;          //!
0057   const G4RadiatorMaterial *m_Material;            //!
0058 
0059  private:
0060 
0061   // Refractive index calculated for some fixed reference wave length (supposedly the average 
0062   // one as seen on the detected photon wave length plot);
0063   double m_ReferenceRefractiveIndex;
0064   double m_ReferenceAttenuationLength;
0065 
0066   TString m_AlternativeMaterialName;
0067 
0068  public:
0069   inline double GetSmearing( void ) const { return m_Smearing; };
0070   void SetGaussianSmearing(double sigma) { m_GaussianSmearing = true;  m_Smearing = sigma; }
0071   void SetUniformSmearing (double range) { m_GaussianSmearing = false; m_Smearing = range; }
0072   bool UseGaussianSmearing( void )  const { return m_GaussianSmearing; };
0073 
0074   // Backwards compatibility: deprecated methods for old non-thread-safe API
0075   // WARNING: These are NOT thread-safe and should only be used with mutex protection
0076   // For thread-safe code, use RadiatorHistory methods directly
0077   void SetTrajectoryBinCount(unsigned bins) { m_TrajectoryBinCount_deprecated = bins; }
0078   unsigned GetTrajectoryBinCount() const { return m_TrajectoryBinCount_deprecated; }
0079   void ResetLocations() { m_Locations_deprecated.clear(); }
0080   void AddLocation(const TVector3 &x, const TVector3 &n) { 
0081     m_Locations_deprecated.push_back(std::make_pair(x, n)); 
0082   }
0083   const std::vector<std::pair<TVector3, TVector3>>& GetLocations( void ) const { return m_Locations_deprecated; };
0084 
0085   // Transient variables for the analysis script convenience;
0086   unsigned m_ID;                                   //!
0087   unsigned m_Stat;                                 //!
0088   double m_AverageTheta;                           //!
0089   TVector3 m_AverageVertexPosition;                //!
0090   double m_AverageRefractiveIndex;                 //!
0091 
0092   // This is a hack for now;
0093   double m_Smearing;                               //!
0094   bool m_GaussianSmearing;                         //!
0095 
0096   std::vector<std::pair<double, double>> m_ri_lookup_table; //!
0097 
0098   // Deprecated members for backwards compatibility (NOT thread-safe)
0099   unsigned m_TrajectoryBinCount_deprecated;        //!
0100   std::vector<std::pair<TVector3, TVector3>> m_Locations_deprecated; //!
0101 
0102 #ifndef DISABLE_ROOT_IO
0103   ClassDef(CherenkovRadiator, 6);
0104 #endif
0105 };
0106 
0107 #endif