42#define USE_ICT_MEAN_FREE_PATH
233 GFits fits(filename);
321 double transmission = 1.0;
327 double logE = std::log(energy);
331 double coeff = std::exp(logc) *
m_abthick;
334 transmission = std::exp(-coeff);
365 double transmission = 1.0;
371 double logE = std::log(energy);
375 double coeff = std::exp(logc) *
m_v1thick;
378 transmission = std::exp(-coeff);
414 double logE = std::log(energy);
418 double coeff = std::exp(logc) *
m_d1thick;
421 prob = 1.0 - std::exp(-coeff);
449 double logE = std::log(energy);
487 if ((n_energies > 0) && (n_zeniths > 0)) {
519 else if (prob > 1.0) {
565 double transmission = 1.0;
575 double coeff = std::exp(logc) *
m_althick;
578 transmission = std::exp(-coeff);
617 double transmission = 1.0;
627 double coeff = std::exp(logc) *
m_vthick;
630 transmission = std::exp(-coeff);
680 double coeff = std::exp(logc) *
m_d2thick;
683 prob = 1.0 - std::exp(-coeff);
737 double e_scattered = energy / (1.0 + alpha * (1.0 - cth));
744 double total_interactions = 1.0 - std::exp(-tau0);
751 double deltau = deltaz * mu;
757 double delrho = 2.0 * rho;
758 double rholow = rho - 0.5 * delrho;
759 double rhoupp = rho + 0.5 * delrho;
760 double surface = 2.0 * delrho * rho;
763 double kappa = deltau / double(nphi);
766 double contribution_rho = 0.0;
767 double total_surface = surface;
769 for (
int krho = 0; krho < 100; ++krho) {
782 rhoupp = std::sqrt(surface + rholow*rholow);
783 rho = 0.5 * (rhoupp + rholow);
786 rho = 0.5 * (rhoupp + rholow);
787 surface = (rhoupp*rhoupp - rholow*rholow);
790 total_surface += surface;
794 std::vector<double> r(nphi, 0.0);
798 for (
int lphi = 0; lphi < nphi; ++lphi) {
799 double phi = dltphi * (lphi + 0.5);
800 double term = rho * std::sin(phi);
801 r[lphi] = -rho * std::cos(phi) +
806 double contribution_z = 0.0;
807 for (
int kz = 0; kz < nz; ++kz) {
810 double z = (kz + 0.5) * deltaz;
816 double length0 = 1000.0;
819 length0 = z/std::abs(cth);
827 double contribution_phi = 0.0;
828 for (
int kphi = 0; kphi < nphi; ++kphi) {
832 double length = length0;
833 if (length * sth > r[kphi]) {
834 length = r[kphi] / sth;
839 contribution_phi += std::exp(-length * mu_scattered);
846 contribution_z += contribution_phi * std::exp(-tau);
851 contribution_rho += contribution_z * kappa * surface;
856 double transmission = contribution_rho / (total_surface * total_interactions);
890 const double a1 = 1727.9;
891 const double a2 = 2.530;
897 double psdacp = 1.0 - (1.0 / (a1 * std::pow(e1, a2) + 1.0));
919 result.append(
"=== GCOMInstChars ===");
929 result.append(
" - ");
931 result.append(
"] cm^2/g");
934 result.append(
"not defined");
945 result.append(
" - ");
947 result.append(
"] cm^2/g");
950 result.append(
"not defined");
960 result.append(
" - ");
962 result.append(
"] 1/cm");
965 result.append(
"not defined");
975 result.append(
" - ");
977 result.append(
"] 1/cm");
980 result.append(
"not defined");
990 result.append(
" - ");
992 result.append(
"] cm^2/g");
995 result.append(
"not defined");
1007 result.append(
" [");
1009 result.append(
" - ");
1014 result.append(
"not defined");
1022 result.append(
" [");
1024 result.append(
" - ");
1029 result.append(
"not defined");
1037 result.append(
" [");
1039 result.append(
" - ");
1044 result.append(
"not defined");
1257 std::vector<double>& coeffs)
1264 int num = table.
nrows();
1271 std::string coeff_name =
"COEFFICIENT";
1272 if (table.
contains(
"PROBABILITY")) {
1273 coeff_name =
"PROBABILITY";
1282 for (
int i = 0; i < num; ++i) {
1283 double energy = ptr_energy->
real(i);
1284 double coeff = ptr_coeff->
real(i);
1285 if ((energy > 0.0) && (coeff > 0.0)) {
1286 energies.
append(std::log(energy));
1287 coeffs.push_back(std::log(coeff));
1308 std::vector<double>& y)
1315 int num = table.
nrows();
1326 for (
int i = 0; i < num; ++i) {
1327 int detnum = ptr_detnum->
integer(i) - 1;
1328 x.push_back(ptr_x->
real(detnum));
1329 y.push_back(ptr_y->
real(detnum));
1357 int num = table.
nrows();
1369 std::vector<double> energies;
1370 std::vector<double> zeniths;
1373 for (
int i = 0; i < num; ++i) {
1376 double energy = ptr_energies->
real(i);
1378 for (
int k = 0; k < energies.size(); ++k) {
1379 if (energies[k] == energy) {
1385 energies.push_back(energy);
1389 double zenith = ptr_zeniths->
real(i);
1398 zeniths.push_back(zenith);
1404 std::sort(energies.begin(), energies.end());
1405 std::sort(zeniths.begin(), zeniths.end());
1419 for (
int i = 0; i < num; ++i) {
1423 double energy = ptr_energies->
real(i);
1425 for (
int k = 1; k < neng; ++k) {
1435 double zenith = ptr_zeniths->
real(i);
1437 for (
int k = 1; k < nzenith; ++k) {
1446 int index = ieng + neng*izenith;
1454 for (
int ieng = 0; ieng < neng; ++ieng) {
1457 #if defined(G_DEBUG_READ_SELFVETO)
1459 std::cout <<
" Zenith angles:";
1464 std::vector<double> values;
1465 for (
int izenith = 0; izenith < nzenith; ++izenith) {
1466 int index = ieng + neng*izenith;
1470 #if defined(G_DEBUG_READ_SELFVETO)
1478 #if defined(G_DEBUG_READ_SELFVETO)
1479 std::cout << std::endl;
1480 std::cout <<
" Interpolated zenith angles:";
1484 for (
int izenith = 0; izenith < nzenith; ++izenith) {
1485 int index = ieng + neng*izenith;
1491 else if (coeffs > 1.0) {
1495 #if defined(G_DEBUG_READ_SELFVETO)
1503 #if defined(G_DEBUG_READ_SELFVETO)
1504 std::cout << std::endl;
1529 #if defined(USE_ICT_MEAN_FREE_PATH)
1531 double logE = std::log(energy);
1537 double result = 1.0 / std::exp(logc);
1541 const double mfpath[] = {16.19, 23.21, 29.01, 34.04, 38.46,
1542 42.35, 45.64, 48.81, 51.53, 54.17,
1543 56.15, 58.09, 59.96, 61.74, 63.41,
1544 64.62, 65.80, 66.94, 68.04, 69.09,
1545 69.86, 70.61, 71.33, 72.03, 72.70,
1546 73.33, 73.93, 74.50, 75.03, 75.51};
1552 double result = 0.0;
1561 int index = int(energy) - 1;
1565 double slope = mfpath[index+1] - mfpath[index];
1566 result = mfpath[index] + slope * (energy - double(index + 1));
1596 double k1 = k + 1.0;
1597 double k2p1 = 1.0 + 2.0*k;
1598 double logk2p1 = std::log(k2p1);
1599 double kn = k1/(k*k) * (2.0*k1/k2p1 - logk2p1/k) +
1600 logk2p1/(2.0*k) - (1.0+3.0*k)/(k2p1*k2p1);
1621 if (coeffs.size() > 0) {
1627 for (
int i = 1; i < coeffs.size(); ++i) {
1628 if (coeffs[i] <
min) {
1654 if (coeffs.size() > 0) {
1660 for (
int i = 1; i < coeffs.size(); ++i) {
1661 if (coeffs[i] >
max) {
COMPTEL Instrument Characteristics interface definition.
Implementation of support function used by COMPTEL classes.
Energy value class definition.
Mathematical function definitions.
double norm(const GVector &vector)
Computes vector norm.
double min(const GVector &vector)
Computes minimum vector element.
double max(const GVector &vector)
Computes maximum vector element.
Interface for the COMPTEL Instrument Characteristics class.
double m_d1rad
D1 radius (cm)
std::vector< double > m_selfveto_coeffs
Selfveto coefficients (probability)
double trans_V1(const double &energy) const
Return V1 veto dome transmission.
double max_coeff(const std::vector< double > &coeffs) const
Return maximum coefficient.
std::vector< double > m_d2pos_x
D2 x-position (cm)
double trans_V23(const double &energy, const double &phigeo) const
Return V2+V3 veto dome transmission.
GNodeArray m_veto_energies
Veto dome attenuation coefficient energies (MeV)
GNodeArray m_d2multi_energies
D2 multihit attenuation coefficient energies (MeV)
std::vector< double > m_veto_coeffs
Veto dome attenuation coefficients.
double m_v1thick
Thickness of V1 veto dome (cm)
double trans_D1(const double &energy) const
Return transmission above D1.
std::vector< double > m_alu_coeffs
Al interaction coefficients.
GNodeArray m_aboved1_energies
Above D1 attenuation coefficient energies (MeV)
void load(const std::string &ictname)
Load COMPTEL instrument characteristics.
double m_d2rad
D2 radius (cm)
GCOMInstChars(void)
Void constructor.
double m_d2dens
D2 density (g/cm^-3)
double multi_scatter(const double &energy, const double &phigeo) const
Return multi-scatter correction.
GNodeArray m_selfveto_energies
Selfveto energies (MeV)
double prob_no_multihit(const double &energy) const
Return probability that no multihit occured.
std::vector< double > m_aboved1_coeffs
Above D1 attenuation coefficients.
double prob_no_selfveto(const double &energy, const double &zenith) const
Return probability that photon was not self vetoed.
GNodeArray m_d2inter_energies
D2 interaction coefficient energies (MeV)
double m_d2thick
D2 thickness (cm)
double ne213a_mfpath(const double &energy) const
Return NE213A mean free path.
std::vector< double > m_d1pos_y
D1 y-position (cm)
std::vector< double > m_d2pos_y
D2 y-position (cm)
double m_thbar
Average D2 incident angle (deg)
GNodeArray m_d1multi_energies
D1 multihit attenuation coefficient energies (MeV)
double m_aldens
Density of aluminium plate above D2 (g/cm^-3)
GNodeArray m_selfveto_zeniths
Selfveto zenith angle (deg)
GCOMInstChars & operator=(const GCOMInstChars &ict)
Assignment operator.
std::vector< double > m_d1multi_coeffs
D1 multihit attenuation coefficients (probability)
double kn_cross_section(const double &k) const
Return integrated Klein-Nishina cross section.
double m_althick
Thickness of aluminium plate above D2 (cm)
double m_d1thick
D1 thickness (cm)
std::vector< double > m_d1pos_x
D1 x-position (cm)
GNodeArray m_d1inter_energies
D1 interaction coefficient energies (MeV)
double m_delz
Distance between D1 and D2 levels (cm)
double trans_D2(const double &energy, const double &phigeo) const
Return transmission of material between D1 and D2.
double m_vetodens
Density of veto domes (g/cm^-3)
void read_coeffs(const GFitsTable &table, GNodeArray &energies, std::vector< double > &coeffs)
Read energy dependent coefficients.
GNodeArray m_alu_energies
Al interaction coefficient energies (MeV)
const GCaldb & caldb(void) const
Return calibration database.
void read_selfveto(const GFitsTable &table)
Read selfveto coefficients.
void copy_members(const GCOMInstChars &ict)
Copy class members.
double psd_correction(const double &energy, const double &phigeo) const
Return PSD correction.
~GCOMInstChars(void)
Destructor.
void init_members(void)
Initialise class members.
double m_vthick
Thickness of V2 and V3 veto domes together (cm)
std::vector< double > m_d1inter_coeffs
D1 interaction coefficients.
std::vector< double > m_d2multi_coeffs
D2 multihit attenuation coefficients (probability)
void read_pos(const GFitsTable &table, std::vector< double > &x, std::vector< double > &y)
Read module positions.
void clear(void)
Clear instance.
void free_members(void)
Delete class members.
double prob_D1inter(const double &energy) const
Return D1 interaction probability.
double m_abthick
Thickness above D1 (cm)
double prob_D2inter(const double &energy, const double &phigeo) const
Return D2 interaction probability.
GCOMInstChars * clone(void) const
Clone instance.
std::vector< double > m_d2inter_coeffs
D2 interaction coefficients.
double m_abdens
Density above D1 (g/cm^-3)
double m_d1dens
D1 density (g/cm^-3)
std::string print(const GChatter &chatter=NORMAL) const
Print COMPTEL instrument characteristics.
GCaldb m_caldb
Calibration database.
double min_coeff(const std::vector< double > &coeffs) const
Return minimum coefficient.
Calibration database class.
std::string rootdir(void) const
Return path to CALDB root directory.
GFilename filename(const std::string &detector, const std::string &filter, const std::string &codename, const std::string &date, const std::string &time, const std::string &expr)
Return calibration file name based on selection parameters.
void clear(void)
Clear calibration database.
std::string print(const GChatter &chatter=NORMAL) const
Print calibration database information.
bool exists(void) const
Checks whether file exists.
bool is_empty(void) const
Signal if filename is empty.
double real(const std::string &keyname) const
Return card value as double precision.
Abstract interface for FITS table column.
virtual int integer(const int &row, const int &inx=0) const =0
virtual double real(const int &row, const int &inx=0) const =0
Abstract interface for FITS table.
bool contains(const std::string &colname) const
Checks the presence of a column in table.
const int & nrows(void) const
Return number of rows in table.
void close(void)
Close FITS file.
GFitsTable * table(const int &extno)
Get pointer to table HDU.
void set_value(const double &value) const
Set indices and weighting factors for interpolation.
double interpolate(const double &value, const std::vector< double > &vector) const
Interpolate value.
const int & inx_right(void) const
Returns right node index.
const int & inx_left(void) const
Returns left node index.
const double & wgt_right(void) const
Returns right node weight.
const double & wgt_left(void) const
Returns left node weight.
void clear(void)
Clear node array.
void nodes(const int &num, const double *array)
Set node array.
int size(void) const
Return number of nodes in node array.
void append(const double &node)
Append one node to array.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
double com_energy1(const double &energy, const double &phigeo)
Return D1 energy deposit.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
std::string filepath(const std::string &pathname, const std::string &filename)
Build file path from path name and file name.
double com_energy2(const double &energy, const double &phigeo)
Return D2 energy deposit.