From 936de202cb7259c4a899e2fec1eedc1deb195af8 Mon Sep 17 00:00:00 2001 From: Penny Slocum Date: Wed, 15 Nov 2023 13:34:39 -0500 Subject: [PATCH] Allow command-line specification of mode map filename. Define temporary mode normalization == 1.0 for uploaded mode maps, until the required interpolation is implemented. --- Source/Fields/LMCCylindricalCavity.cc | 49 ++++++++++++++++++++++----- Source/Fields/LMCCylindricalCavity.hh | 1 + Source/Fields/LMCField.hh | 1 + 3 files changed, 43 insertions(+), 8 deletions(-) diff --git a/Source/Fields/LMCCylindricalCavity.cc b/Source/Fields/LMCCylindricalCavity.cc index 0ea48b02..1c97a1c3 100644 --- a/Source/Fields/LMCCylindricalCavity.cc +++ b/Source/Fields/LMCCylindricalCavity.cc @@ -82,29 +82,29 @@ namespace locust SetCavityProbeTheta(aParam["cavity-probe-theta1"]().as_double(), 1); } - if( aParam.has( "modemap-filename" ) ) + if( aParam.has( "upload-modemap-filename" ) ) // import "realistic" test mode map { fFieldCore = new ModeMapCylindricalCavity(); scarab::path dataDir = aParam.get_value( "data-dir", ( TOSTRING(PB_DATA_INSTALL_DIR) ) ); - if (!fFieldCore->ReadModeMapTE_E((dataDir / aParam["modemap-filename"]().as_string()).string())) - + if (!fFieldCore->ReadModeMapTE_E((dataDir / aParam["upload-modemap-filename"]().as_string()).string())) { LERROR(lmclog,"There was a problem uploading the mode map."); exit(-1); } + SetNormFactorsTE( SetUnityNormFactors(GetNModes())); + SetNormFactorsTM( SetUnityNormFactors(GetNModes())); } - else + else // otherwise default to ideal Pozar mode map { fFieldCore = new PozarCylindricalCavity(); scarab::path dataDir = aParam.get_value( "data-dir", ( TOSTRING(PB_DATA_INSTALL_DIR) ) ); fFieldCore->ReadBesselZeroes((dataDir / "BesselZeros.txt").string(), 0 ); fFieldCore->ReadBesselZeroes((dataDir / "BesselPrimeZeros.txt").string(), 1 ); + SetNormFactorsTE(CalculateNormFactors(GetNModes(),1)); + SetNormFactorsTM(CalculateNormFactors(GetNModes(),0)); + CheckNormalization(GetNModes()); // E fields integrate to 1.0 for both TE and TM modes. } - SetNormFactorsTE(CalculateNormFactors(GetNModes(),1)); - SetNormFactorsTM(CalculateNormFactors(GetNModes(),0)); - - CheckNormalization(GetNModes()); // E fields integrate to 1.0 for both TE and TM modes. if( PlotModeMaps() ) { @@ -119,6 +119,39 @@ namespace locust return true; } + std::vector>> CylindricalCavity::SetUnityNormFactors(int nModes) + { + LPROG(lmclog, "Setting mode normalization factors to 1.0 ... " ); + + std::vector>> tNormFactor; + tNormFactor.resize(nModes); + + for (unsigned m=0; m>> CylindricalCavity::CalculateNormFactors(int nModes, bool bTE) { diff --git a/Source/Fields/LMCCylindricalCavity.hh b/Source/Fields/LMCCylindricalCavity.hh index ef2f5b9c..60c7ecb0 100644 --- a/Source/Fields/LMCCylindricalCavity.hh +++ b/Source/Fields/LMCCylindricalCavity.hh @@ -62,6 +62,7 @@ namespace locust virtual std::vector GetDopplerFrequency(int l, int m, int n, std::vector tKassParticleXP); virtual std::vector GetNormalizedModeField(int l, int m, int n, std::vector tKassParticleXP, bool includeOtherPols, bool teMode); virtual std::vector>> CalculateNormFactors(int nModes, bool bTE); + virtual std::vector>> SetUnityNormFactors(int nModes); virtual std::vector GetTE_E(int l, int m, int n, double r, double theta, double z, bool includeOtherPols); virtual std::vector GetTM_E(int l, int m, int n, double r, double theta, double z, bool includeOtherPols); virtual double CalculateDotProductFactor(int l, int m, int n, std::vector tKassParticleXP, std::vector anE_normalized, double tThisEventNSamples); diff --git a/Source/Fields/LMCField.hh b/Source/Fields/LMCField.hh index 42ffa3a3..a94f658a 100644 --- a/Source/Fields/LMCField.hh +++ b/Source/Fields/LMCField.hh @@ -85,6 +85,7 @@ namespace locust virtual std::vector GetNormalizedModeField(int l, int m, int n, std::vector tKassParticleXP, bool includeOtherPols, bool teMode) {return {0.};}; double NormalizedEFieldMag(std::vector field); virtual std::vector>> CalculateNormFactors(int nModes, bool bTE) {return {{{0.}}};}; + virtual std::vector>> SetUnityNormFactors(int nModes) {return {{{0.}}};}; virtual std::vector GetTE_E(int l, int m, int n, double r, double theta, double z, bool includeOtherPols) {return {0.};}; virtual std::vector GetTM_E(int l, int m, int n, double r, double theta, double z, bool includeOtherPols) {return {0.};}; virtual double CalculateDotProductFactor(int l, int m, int n, std::vector tKassParticleXP, std::vector aTE_E_normalized, double tThisEventNSamples) {return {0.};};