42 #define USE_ICT_MEAN_FREE_PATH
233 GFits fits(filename);
321 double transmission = 1.0;
365 double transmission = 1.0;
487 if ((n_energies > 0) && (n_zeniths > 0)) {
519 else if (prob > 1.0) {
565 double transmission = 1.0;
617 double transmission = 1.0;
731 double cth =
std::cos(phigeo * gammalib::deg2rad);
737 double e_scattered = energy / (1.0 + alpha * (1.0 - cth));
744 double total_interactions = 1.0 -
std::exp(-tau0);
750 double deltaz = m_d1thick / double(nz);
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);
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;
822 length0 = (m_d1thick-z)/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)) {
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)
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;
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.
double m_delz
Distance between D1 and D2 levels (cm)
int size(void) const
Return number of nodes in node array.
std::vector< double > m_d2pos_x
D2 x-position (cm)
GFitsTable * table(const int &extno)
Get pointer to table HDU.
double norm(const GVector &vector)
Computes vector norm.
void read_selfveto(const GFitsTable &table)
Read selfveto coefficients.
double prob_no_multihit(const double &energy) const
Return probability that no multihit occured.
Energy value class definition.
std::vector< double > m_d2inter_coeffs
D2 interaction coefficients.
GNodeArray m_d2inter_energies
D2 interaction coefficient energies (MeV)
double trans_D2(const double &energy, const double &phigeo) const
Return transmission of material between D1 and D2.
double prob_D2inter(const double &energy, const double &phigeo) const
Return D2 interaction probability.
double trans_D1(const double &energy) const
Return transmission above D1.
double max_coeff(const std::vector< double > &coeffs) const
Return maximum coefficient.
double m_abdens
Density above D1 (g/cm^-3)
GVector abs(const GVector &vector)
Computes absolute of vector elements.
double prob_D1inter(const double &energy) const
Return D1 interaction probability.
std::vector< double > m_d2multi_coeffs
D2 multihit attenuation coefficients (probability)
GNodeArray m_alu_energies
Al interaction coefficient energies (MeV)
GVector cos(const GVector &vector)
Computes cosine of vector elements.
double m_vetodens
Density of veto domes (g/cm^-3)
GCaldb m_caldb
Calibration database.
double com_energy2(const double &energy, const double &phigeo)
Return D2 energy deposit.
bool is_empty(void) const
Signal if filename is empty.
bool contains(const std::string &colname) const
Checks the presence of a column in table.
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.
const double & wgt_left(void) const
Returns left node weight.
void free_members(void)
Delete class members.
void clear(void)
Clear node array.
void read_pos(const GFitsTable &table, std::vector< double > &x, std::vector< double > &y)
Read module positions.
Interface for the COMPTEL Instrument Characteristics class.
GNodeArray m_aboved1_energies
Above D1 attenuation coefficient energies (MeV)
GNodeArray m_d1multi_energies
D1 multihit attenuation coefficient energies (MeV)
double m_aldens
Density of aluminium plate above D2 (g/cm^-3)
void set_value(const double &value) const
Set indices and weighting factors for interpolation.
double min(const GVector &vector)
Computes minimum vector element.
double m_d2dens
D2 density (g/cm^-3)
void copy_members(const GCOMInstChars &ict)
Copy class members.
Implementation of support function used by COMPTEL classes.
double m_vthick
Thickness of V2 and V3 veto domes together (cm)
GCOMInstChars * clone(void) const
Clone instance.
double psd_correction(const double &energy, const double &phigeo) const
Return PSD correction.
double real(const std::string &keyname) const
Return card value as double precision.
std::vector< double > m_d1pos_y
D1 y-position (cm)
double ne213a_mfpath(const double &energy) const
Return NE213A mean free path.
GVector sqrt(const GVector &vector)
Computes square root of vector elements.
Calibration database class.
const double & wgt_right(void) const
Returns right node weight.
std::vector< double > m_d2pos_y
D2 y-position (cm)
double m_abthick
Thickness above D1 (cm)
Abstract interface for FITS table column.
double m_v1thick
Thickness of V1 veto dome (cm)
void load(const std::string &ictname)
Load COMPTEL instrument characteristics.
bool exists(void) const
Checks whether file exists.
GVector log(const GVector &vector)
Computes natural logarithm of vector elements.
void read_coeffs(const GFitsTable &table, GNodeArray &energies, std::vector< double > &coeffs)
Read energy dependent coefficients.
std::vector< double > m_d1pos_x
D1 x-position (cm)
double interpolate(const double &value, const std::vector< double > &vector) const
Interpolate value.
double m_d1dens
D1 density (g/cm^-3)
std::string print(const GChatter &chatter=NORMAL) const
Print COMPTEL instrument characteristics.
Abstract interface for FITS table.
void init_members(void)
Initialise class members.
GNodeArray m_selfveto_energies
Selfveto energies (MeV)
GNodeArray m_d2multi_energies
D2 multihit attenuation coefficient energies (MeV)
const int & inx_left(void) const
Returns left node index.
const GCaldb & caldb(void) const
Return calibration database.
double m_d2thick
D2 thickness (cm)
std::vector< double > m_d1multi_coeffs
D1 multihit attenuation coefficients (probability)
double max(const GVector &vector)
Computes maximum vector element.
void nodes(const int &num, const double *array)
Set node array.
const int & inx_right(void) const
Returns right node index.
const int & nrows(void) const
Return number of rows in table.
std::vector< double > m_aboved1_coeffs
Above D1 attenuation coefficients.
GNodeArray m_selfveto_zeniths
Selfveto zenith angle (deg)
double prob_no_selfveto(const double &energy, const double &zenith) const
Return probability that photon was not self vetoed.
GCOMInstChars(void)
Void constructor.
virtual int integer(const int &row, const int &inx=0) const =0
virtual double real(const int &row, const int &inx=0) const =0
GVector pow(const GVector &vector, const double &power)
Computes tanh of vector elements.
GVector sin(const GVector &vector)
Computes sine of vector elements.
std::string print(const GChatter &chatter=NORMAL) const
Print calibration database information.
double m_d1thick
D1 thickness (cm)
void clear(void)
Clear instance.
double m_d1rad
D1 radius (cm)
GVector exp(const GVector &vector)
Computes exponential of vector elements.
double kn_cross_section(const double &k) const
Return integrated Klein-Nishina cross section.
std::vector< double > m_selfveto_coeffs
Selfveto coefficients (probability)
double m_althick
Thickness of aluminium plate above D2 (cm)
std::string filepath(const std::string &pathname, const std::string &filename)
Build file path from path name and file name.
double trans_V1(const double &energy) const
Return V1 veto dome transmission.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
double m_thbar
Average D2 incident angle (deg)
double m_d2rad
D2 radius (cm)
void append(const double &node)
Append one node to array.
double com_energy1(const double &energy, const double &phigeo)
Return D1 energy deposit.
GNodeArray m_d1inter_energies
D1 interaction coefficient energies (MeV)
double trans_V23(const double &energy, const double &phigeo) const
Return V2+V3 veto dome transmission.
void close(void)
Close FITS file.
std::vector< double > m_alu_coeffs
Al interaction coefficients.
GCOMInstChars & operator=(const GCOMInstChars &ict)
Assignment operator.
std::vector< double > m_d1inter_coeffs
D1 interaction coefficients.
void clear(void)
Clear calibration database.
std::vector< double > m_veto_coeffs
Veto dome attenuation coefficients.
double min_coeff(const std::vector< double > &coeffs) const
Return minimum coefficient.
std::string rootdir(void) const
Return path to CALDB root directory.
GNodeArray m_veto_energies
Veto dome attenuation coefficient energies (MeV)
Mathematical function definitions.
double multi_scatter(const double &energy, const double &phigeo) const
Return multi-scatter correction.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
~GCOMInstChars(void)
Destructor.