Jpp 20.0.0-rc.2
the software that should make you happy
Loading...
Searching...
No Matches
JASTRONOMY::JMorphologyHistogram Struct Reference

Implementation of histogram source morphology. More...

#include <JMorphology.hh>

Inheritance diagram for JASTRONOMY::JMorphologyHistogram:
JASTRONOMY::JMorphology JASTRONOMY::JSourceLocation JASTRONOMY::angle_type_rad JASTRONOMY::angle_type JLANG::JEquals< JFirst_t, JSecond_t >

Public Member Functions

virtual ~JMorphologyHistogram ()
 Virtual destructor.
 
virtual std::istream & read (std::istream &in) override
 Read source morphology from input stream.
 
virtual std::ostream & write (std::ostream &out) const override
 Write source morphology to output stream.
 
virtual JSourceLocation get () const override
 Get location on sky.
 
const JSourceLocationgetSourceLocation () const
 Get source location.
 
 operator JAngle3D () const
 Type conversion operator.
 
double getDeclination () const
 Get declination.
 
double getRightAscension () const
 Get right ascension.
 
double getDot (const JSourceLocation &location) const
 Dot product.
 
void set (const angle_type_deg &angle)
 Convert angle.
 
bool equals (const angle_type &angle, const double precision=std::numeric_limits< double >::min()) const
 Check equality.
 

Static Public Member Functions

static std::istream & read (std::istream &in, JSourceLocation &source)
 Read source location in degrees from input stream.
 
static std::ostream & write (std::ostream &out, const JSourceLocation &source)
 Write source location in degrees to output stream.
 

Public Attributes

std::string filename
 
std::string histname
 

Protected Member Functions

void load ()
 Load histogram from file.
 

Protected Attributes

TFile * in = NULL
 
TH2D * h2 = NULL
 
double _theta_
 
double _phi_
 

Detailed Description

Implementation of histogram source morphology.

Note that all input angles are in degrees.

Definition at line 381 of file JMorphology.hh.

Constructor & Destructor Documentation

◆ ~JMorphologyHistogram()

virtual JASTRONOMY::JMorphologyHistogram::~JMorphologyHistogram ( )
inlinevirtual

Virtual destructor.

Definition at line 387 of file JMorphology.hh.

388 {
389 if (in != NULL) {
390 in->Close();
391 }
392 }

Member Function Documentation

◆ read() [1/2]

virtual std::istream & JASTRONOMY::JMorphologyHistogram::read ( std::istream & in)
inlineoverridevirtual

Read source morphology from input stream.

Parameters
ininput stream
Returns
input stream

Implements JASTRONOMY::JMorphology.

Definition at line 401 of file JMorphology.hh.

402 {
403 JMorphology::read(in, *this)
404 >> this->filename
405 >> this->histname;
406
407 load();
408
409 return in;
410 }
void load()
Load histogram from file.
static std::istream & read(std::istream &in, JSourceLocation &source)
Read source location in degrees from input stream.

◆ write() [1/2]

virtual std::ostream & JASTRONOMY::JMorphologyHistogram::write ( std::ostream & out) const
inlineoverridevirtual

Write source morphology to output stream.

Parameters
outoutput stream
Returns
output stream

Implements JASTRONOMY::JMorphology.

Definition at line 419 of file JMorphology.hh.

420 {
421 return JMorphology::write(out, *this)
422 << ' ' << this->filename
423 << ' ' << this->histname;
424 }
static std::ostream & write(std::ostream &out, const JSourceLocation &source)
Write source location in degrees to output stream.

◆ get()

virtual JSourceLocation JASTRONOMY::JMorphologyHistogram::get ( ) const
inlineoverridevirtual

Get location on sky.

Returns
location on sky

Implements JASTRONOMY::JMorphology.

Definition at line 432 of file JMorphology.hh.

433 {
434 using namespace JPP;
435
436 Double_t x;
437 Double_t y;
438
439 h2->GetRandom2(x, y, gRandom);
440
441 x = sin(getRadians(x));
442 y = sin(getRadians(y));
443
444 JDirection3D u(x, y, sqrt(1.0 - x*x - y*y));
445
446 const JRotation3D Rs(this->getSourceLocation());
447
448 u.rotate_back(Rs);
449
450 return JSourceLocation(u);
451 }
Data structure for direction in three dimensions.
double getRadians(const double angle)
Convert angle to radians.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
const JSourceLocation & getSourceLocation() const
Get source location.
JSourceLocation()
Default constructor.

◆ load()

void JASTRONOMY::JMorphologyHistogram::load ( )
inlineprotected

Load histogram from file.

Definition at line 460 of file JMorphology.hh.

461 {
462 in = TFile::Open(filename.c_str(), "exist");
463
464 if (in == NULL || !in->IsOpen()) {
465 THROW(JFileOpenException, "File: " << filename << " not opened.");
466 }
467
468 h2 = dynamic_cast<TH2D*>(in->Get(histname.c_str()));
469
470 if (h2 == NULL) {
471 THROW(JValueOutOfRange, "Histogram: " << histname << " not found.");
472 }
473 }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.

◆ read() [2/2]

static std::istream & JASTRONOMY::JMorphology::read ( std::istream & in,
JSourceLocation & source )
inlinestaticinherited

Read source location in degrees from input stream.

Parameters
ininput stream
sourcesource
Returns
input stream

Definition at line 60 of file JMorphology.hh.

61 {
62 angle_type_deg angle;
63
64 in >> angle;
65
66 source.set(angle);
67
68 return in;
69 }

◆ write() [2/2]

static std::ostream & JASTRONOMY::JMorphology::write ( std::ostream & out,
const JSourceLocation & source )
inlinestaticinherited

Write source location in degrees to output stream.

Parameters
outoutput stream
sourcesource
Returns
output stream

Definition at line 79 of file JMorphology.hh.

80 {
81 return out << angle_type_deg(source);
82 }

◆ getSourceLocation()

const JSourceLocation & JASTRONOMY::JSourceLocation::getSourceLocation ( ) const
inlineinherited

Get source location.

Returns
source location

Definition at line 485 of file JAstronomy.hh.

486 {
487 return static_cast<const JSourceLocation&>(*this);
488 }

◆ operator JAngle3D()

JASTRONOMY::JSourceLocation::operator JAngle3D ( ) const
inlineinherited

Type conversion operator.

Returns
polar angles [rad]

Definition at line 496 of file JAstronomy.hh.

497 {
498 return JAngle3D(PI/2 - _theta_, _phi_);
499 }

◆ getDeclination()

double JASTRONOMY::JSourceLocation::getDeclination ( ) const
inlineinherited

Get declination.

Definition at line 502 of file JAstronomy.hh.

◆ getRightAscension()

double JASTRONOMY::JSourceLocation::getRightAscension ( ) const
inlineinherited

Get right ascension.

Definition at line 503 of file JAstronomy.hh.

◆ getDot()

double JASTRONOMY::JSourceLocation::getDot ( const JSourceLocation & location) const
inlineinherited

Dot product.

Parameters
locationsource location
Returns
dot product

Definition at line 512 of file JAstronomy.hh.

513 {
514 return
515 cos(this->_theta_) * cos(location._theta_) * cos(this->_phi_ - location._phi_) +
516 sin(this->_theta_) * sin(location._theta_);
517 }

◆ set()

void JASTRONOMY::angle_type_rad::set ( const angle_type_deg & angle)
inlineinherited

Convert angle.

Parameters
angleangle [rad]

Definition at line 293 of file JAstronomy.hh.

294 {
295 static_cast<angle_type_rad&>(*this) = angle_type_rad(angle);
296 }
angle_type_rad()
Default constructor.

◆ equals()

bool JASTRONOMY::angle_type::equals ( const angle_type & angle,
const double precision = std::numeric_limits<double>::min() ) const
inlineinherited

Check equality.

Parameters
anglepair of angles
precisionprecision
Returns
true if angles are equal; else false

Definition at line 194 of file JAstronomy.hh.

196 {
197 return (fabs(this->_theta_ - angle._theta_) <= precision &&
198 fabs(this->_phi_ - angle._phi_) <= precision);
199 }

Member Data Documentation

◆ filename

std::string JASTRONOMY::JMorphologyHistogram::filename

Definition at line 453 of file JMorphology.hh.

◆ histname

std::string JASTRONOMY::JMorphologyHistogram::histname

Definition at line 454 of file JMorphology.hh.

◆ in

TFile* JASTRONOMY::JMorphologyHistogram::in = NULL
mutableprotected

Definition at line 475 of file JMorphology.hh.

◆ h2

TH2D* JASTRONOMY::JMorphologyHistogram::h2 = NULL
mutableprotected

Definition at line 476 of file JMorphology.hh.

◆ _theta_

double JASTRONOMY::angle_type::_theta_
protectedinherited

Definition at line 250 of file JAstronomy.hh.

◆ _phi_

double JASTRONOMY::angle_type::_phi_
protectedinherited

Definition at line 251 of file JAstronomy.hh.


The documentation for this struct was generated from the following file: