Skip to content

Commit

Permalink
Address review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
amandalund committed Feb 13, 2024
1 parent c3292fa commit 6b0a5a8
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 37 deletions.
97 changes: 62 additions & 35 deletions app/celer-dump-data.cc
Original file line number Diff line number Diff line change
Expand Up @@ -629,50 +629,77 @@ void print_optical_material_data(ImportData::ImportOpticalMap const& iom)
CELER_LOG(info) << "Loaded optical material data map with size "
<< iom.size();

#define POM_STREAM_SCALAR(ID, NAME) \
"| " << setw(11) << ID << " | " << setw(24) << #NAME << " | " << setw(7) \
<< "" \
<< " | " << setprecision(3) << setw(9) << NAME << " | " << setw(52) \
<< "" \
#define POM_STREAM_SCALAR_COMP(ID, STRUCT, NAME, UNITS, COMP) \
"| " << setw(11) << ID << " | " << setw(20) << #NAME << COMP << " | " \
<< setw(15) << to_cstring(UNITS) << " | " << setprecision(3) \
<< setw(9) << STRUCT.NAME << " | " << setw(52) << "" \
<< " | " << setw(7) << "" \
<< " |\n"
#define POM_STREAM_VECTOR(ID, NAME) \
"| " << setw(11) << ID << " | " << setw(24) << #NAME << " | " << setw(7) \
<< NAME.x.size() << " | " << setw(9) << "" \
<< " | (" << setprecision(3) << setw(10) << NAME.x.front() << ", " \
<< setprecision(3) << setw(10) << NAME.y.front() << ") -> (" \
<< setprecision(3) << setw(10) << NAME.x.back() << ", " \
<< setprecision(3) << setw(10) << NAME.y.back() << ") |\n";
cout << R"gfm(
# Material optical property data
| Material ID | Property | Size | Scalar | Vector endpoints (MeV, value) |
| ----------- | ------------------------ | ------- | --------- | ---------------------------------------------------- |
#define POM_STREAM_SCALAR(ID, STRUCT, NAME, UNITS) \
POM_STREAM_SCALAR_COMP(ID, STRUCT, NAME, UNITS, " ")
#define POM_STREAM_VECTOR(ID, STRUCT, NAME, UNITS) \
"| " << setw(11) << ID << " | " << setw(26) << #NAME << " | " << setw(15) \
<< to_cstring(UNITS) << " | " << setw(9) << "" \
<< " | (" << setprecision(3) << setw(10) << STRUCT.NAME.x.front() \
<< ", " << setprecision(3) << setw(10) << STRUCT.NAME.y.front() \
<< ") -> (" << setprecision(3) << setw(10) << STRUCT.NAME.x.back() \
<< ", " << setprecision(3) << setw(10) << STRUCT.NAME.y.back() \
<< ") | " << setw(7) << STRUCT.NAME.x.size() << " |\n";
std::string header = R"gfm(
| Material ID | Property | Units | Scalar | Vector endpoints (MeV, value) | Size |
| ----------- | -------------------------- | --------------- | --------- | ---------------------------------------------------- | ------- |
)gfm";

for (auto const& [key, val] : iom)
using IU = ImportUnits;

cout << "\n# Optical properties\n";
cout << "\n## Common properties";
cout << header;
for (auto const& [mid, val] : iom)
{
auto const& prop = val.properties;
cout << POM_STREAM_VECTOR(mid, prop, refractive_index, IU::unitless);
}
cout << "\n## Scintillation";
cout << header;
char const* comp_str[] = {"(fast)", " (mid)", "(slow)"};
for (auto const& [mid, val] : iom)
{
auto const& scint = val.scintillation;
cout << POM_STREAM_SCALAR(key, scint.yield);
cout << POM_STREAM_SCALAR(key, scint.resolution_scale);
for (auto const& scint_comp : scint.components)
cout << POM_STREAM_SCALAR(mid, scint, yield, IU::unitless);
cout << POM_STREAM_SCALAR(mid, scint, resolution_scale, IU::unitless);
for (auto i : range(scint.components.size()))
{
cout << POM_STREAM_SCALAR(key, scint_comp.yield);
cout << POM_STREAM_SCALAR(key, scint_comp.lambda_mean);
cout << POM_STREAM_SCALAR(key, scint_comp.lambda_sigma);
cout << POM_STREAM_SCALAR(key, scint_comp.rise_time);
cout << POM_STREAM_SCALAR(key, scint_comp.fall_time);
auto const& comp = scint.components[i];
cout << POM_STREAM_SCALAR_COMP(
mid, comp, yield, IU::unitless, comp_str[i]);
cout << POM_STREAM_SCALAR_COMP(
mid, comp, lambda_mean, IU::len, comp_str[i]);
cout << POM_STREAM_SCALAR_COMP(
mid, comp, lambda_sigma, IU::len, comp_str[i]);
cout << POM_STREAM_SCALAR_COMP(
mid, comp, rise_time, IU::time, comp_str[i]);
cout << POM_STREAM_SCALAR_COMP(
mid, comp, fall_time, IU::time, comp_str[i]);
}

}
cout << "\n## Rayleigh";
cout << header;
for (auto const& [mid, val] : iom)
{
auto const& rayl = val.rayleigh;
cout << POM_STREAM_SCALAR(key, rayl.scale_factor);
cout << POM_STREAM_SCALAR(key, rayl.compressibility);
cout << POM_STREAM_VECTOR(key, rayl.mfp);

cout << POM_STREAM_SCALAR(mid, rayl, scale_factor, IU::unitless);
cout << POM_STREAM_SCALAR(
mid, rayl, compressibility, IU::len_time_sq_per_mass);
cout << POM_STREAM_VECTOR(mid, rayl, mfp, IU::len);
}
cout << "\n## Absorption";
cout << header;
for (auto const& [mid, val] : iom)
{
auto const& abs = val.absorption;
cout << POM_STREAM_VECTOR(key, abs.absorption_length);

auto const& refractive_index = val.properties.refractive_index;
cout << POM_STREAM_VECTOR(key, refractive_index);
cout << POM_STREAM_VECTOR(mid, abs, absorption_length, IU::len);
}
cout << endl;
#undef PEP_STREAM_SCALAR
Expand Down
11 changes: 10 additions & 1 deletion test/celeritas/ext/GeantImporter.test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1337,11 +1337,14 @@ TEST_F(LarSphere, optical)

real_type const tol = this->comparison_tolerance();

// Most optical properties in the geometry are pulled from the Geant4
// example examples/advanced/CaTS/gdml/LArTPC.gdml

// Check scintillation optical properties
auto const& scint = optical.scintillation;
EXPECT_TRUE(scint);
EXPECT_EQ(1, scint.resolution_scale);
EXPECT_EQ(5, scint.yield);
EXPECT_EQ(50000, scint.yield);
EXPECT_EQ(3, scint.components.size());
std::vector<double> components;
for (auto const& comp : scint.components)
Expand Down Expand Up @@ -1383,6 +1386,12 @@ TEST_F(LarSphere, optical)
EXPECT_REAL_EQ(0.000296154, to_cm(abs.absorption_length.y.back()));

// Check common optical properties
// Refractive index data in the geometry comes from the refractive index
// database https://refractiveindex.info and was calculating using the
// methods described in: E. Grace, A. Butcher, J. Monroe, J. A. Nikkel.
// Index of refraction, Rayleigh scattering length, and Sellmeier
// coefficients in solid and liquid argon and xenon, Nucl. Instr. Meth.
// Phys. Res. A 867, 204-208 (2017)
auto const& properties = optical.properties;
EXPECT_TRUE(properties);
EXPECT_EQ(101, properties.refractive_index.x.size());
Expand Down
2 changes: 1 addition & 1 deletion test/geocel/data/lar-sphere.gdml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<define>
<matrix name="RI" coldim="2" values="1.8785e-06 1.2221243542166 1.8940e-06 1.2222029377323 1.9101e-06 1.2222825413456 1.9261e-06 1.2223604051795 1.9424e-06 1.2224381070094 1.9590e-06 1.2225157688711 1.9762e-06 1.2225949497339 1.9933e-06 1.2226728864441 2.0108e-06 1.2227511290774 2.0289e-06 1.2228312481231 2.0470e-06 1.2229104393633 2.0654e-06 1.2229902616388 2.0845e-06 1.2230723199947 2.1036e-06 1.2231537374513 2.1230e-06 1.2232361043232 2.1428e-06 1.2233195267102 2.1634e-06 1.2234056897612 2.1840e-06 1.2234915704979 2.2049e-06 1.2235788347965 2.2267e-06 1.2236692538263 2.2485e-06 1.2237596566990 2.2708e-06 1.2238517915638 2.2939e-06 1.2239475391085 2.3170e-06 1.2240435454107 2.3406e-06 1.2241416640706 2.3648e-06 1.2242420302676 2.3898e-06 1.2243467108633 2.4150e-06 1.2244520480945 2.4406e-06 1.2245600757483 2.4673e-06 1.2246730352174 2.4942e-06 1.2247869894369 2.5215e-06 1.2249041417343 2.5501e-06 1.2250269429781 2.5787e-06 1.2251511263208 2.6080e-06 1.2252790990981 2.6380e-06 1.2254110795713 2.6692e-06 1.2255498628245 2.7006e-06 1.2256906509598 2.7327e-06 1.2258361874525 2.7663e-06 1.2259895862066 2.8000e-06 1.2261455681055 2.8346e-06 1.2263071887802 2.8707e-06 1.2264779455048 2.9070e-06 1.2266519928105 2.9443e-06 1.2268327625990 2.9825e-06 1.2270206659616 3.0225e-06 1.2272198383341 3.0629e-06 1.2274235186718 3.1043e-06 1.2276357672922 3.1476e-06 1.2278613234401 3.1914e-06 1.2280925883611 3.2363e-06 1.2283342192762 3.2835e-06 1.2285917000180 3.3311e-06 1.2288564336687 3.3802e-06 1.2291338166016 3.4307e-06 1.2294247402393 3.4837e-06 1.2297359753784 3.5374e-06 1.2300572815744 3.5927e-06 1.2303953408143 3.6509e-06 1.2307581975201 3.7099e-06 1.2311340756410 3.7708e-06 1.2315309395240 3.8350e-06 1.2319584795948 3.9001e-06 1.2324030531751 3.9675e-06 1.2328742967333 4.0373e-06 1.2333745182601 4.1109e-06 1.2339164497558 4.1858e-06 1.2344833000133 4.2636e-06 1.2350878388706 4.3457e-06 1.2357460538231 4.4296e-06 1.2364381478993 4.5167e-06 1.2371803058492 4.6091e-06 1.2379930862779 4.7035e-06 1.2388529939487 4.8019e-06 1.2397811112689 4.9044e-06 1.2407852902585 5.0135e-06 1.2418956339948 5.1254e-06 1.2430824604497 5.2425e-06 1.2443774409398 5.3673e-06 1.2458225245477 5.4958e-06 1.2473825079216 5.6305e-06 1.2491028277676 5.7748e-06 1.2510450704786 5.9238e-06 1.2531685960320 6.0806e-06 1.2555430061400 6.2461e-06 1.2582127677221 6.4241e-06 1.2612929591155 6.6090e-06 1.2647427641559 6.8048e-06 1.2687046921432 7.0166e-06 1.2733876575744 7.2378e-06 1.2787793729478 7.4734e-06 1.2851700143090 7.7297e-06 1.2930098842738 7.9990e-06 1.3024417515349 8.2877e-06 1.3142220339702 8.5981e-06 1.3293224516058 8.9390e-06 1.3497665943227 9.3011e-06 1.3776746680090 9.6938e-06 1.4188784984198 1.0129e-05 1.4873838729402 1.0597e-05 1.6167515615703"/>
<matrix name="RS" coldim="1" values="1.0"/>
<matrix name="SY" coldim="1" values="5.0"/>
<matrix name="SY" coldim="1" values="50000.0"/>
<matrix name="SY1" coldim="1" values="3.0"/>
<matrix name="SY2" coldim="1" values="1.0"/>
<matrix name="SY3" coldim="1" values="1.0"/>
Expand Down

0 comments on commit 6b0a5a8

Please sign in to comment.