Jpp 19.3.0
the software that should make you happy
Loading...
Searching...
No Matches
JASTRONOMY::JMorphologyBinary Struct Reference

Implementation of binary source morphology. More...

#include <JMorphology.hh>

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

Public Member Functions

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

double x1_deg
 
double y1_deg
 
double w1
 
double s1_deg
 
double x2_deg
 
double y2_deg
 
double w2
 
double s2_deg
 

Protected Attributes

double _theta_
 
double _phi_
 

Detailed Description

Implementation of binary source morphology.

Note that all input angles are in degrees.

Definition at line 310 of file JMorphology.hh.

Member Function Documentation

◆ read() [1/2]

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

Read source morphology from input stream.

Parameters
ininput stream
Returns
input stream

Implements JASTRONOMY::JMorphology.

Definition at line 319 of file JMorphology.hh.

320 {
321 return JMorphology::read(in, *this)
322 >> this->x1_deg >> this->y1_deg >> this->w1 >> this->s1_deg
323 >> this->x2_deg >> this->y2_deg >> this->w2 >> this->s2_deg;
324 }
static std::istream & read(std::istream &in, JSourceLocation &source)
Read source location in degrees from input stream.

◆ write() [1/2]

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

Write source morphology to output stream.

Parameters
outoutput stream
Returns
output stream

Implements JASTRONOMY::JMorphology.

Definition at line 333 of file JMorphology.hh.

334 {
335 return JMorphology::write(out, *this)
336 << ' ' << this->x1_deg << ' ' << this->y1_deg << ' ' << this->w1 << ' ' << this->s1_deg
337 << ' ' << this->x2_deg << ' ' << this->y2_deg << ' ' << this->w2 << ' ' << this->s2_deg;
338 }
static std::ostream & write(std::ostream &out, const JSourceLocation &source)
Write source location in degrees to output stream.

◆ get()

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

Get location on sky.

Returns
location on sky

Implements JASTRONOMY::JMorphology.

Definition at line 346 of file JMorphology.hh.

347 {
348 using namespace JPP;
349
350 const double w = gRandom->Uniform(0.0, w1 + w2);
351
352 const double x = sin(getRadians(w < w1 ? x1_deg : x2_deg));
353 const double y = sin(getRadians(w < w1 ? y1_deg : y2_deg));
354 const double s = getRadians(w < w1 ? s1_deg : s2_deg);
355
356 JDirection3D v(x, y, sqrt(1.0 - x*x - y*y));
357
358 JDirection3D u(0.0, 0.0, 1.0);
359
360 if (s > 0.0) {
361
362 const double theta = gRandom->Gaus(0.0, s);
363 const double phi = gRandom->Uniform(-PI, +PI);
364
365 const JRotation3D R(JAngle3D(theta, phi));
366
367 u.rotate_back(R);
368 }
369 {
370 const JRotation3D R(v);
371
372 u.rotate_back(R);
373 }
374
375 const JRotation3D Rs(this->getSourceLocation());
376
377 u.rotate_back(Rs);
378
379 return JSourceLocation(u);
380 }
Data structure for angles in three dimensions.
Definition JAngle3D.hh:35
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.

◆ getSourceLocation()

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

Get source location.

Returns
source location

Definition at line 58 of file JMorphology.hh.

59 {
60 return static_cast<const JSourceLocation&>(*this);
61 }

◆ 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 71 of file JMorphology.hh.

72 {
73 angle_type_deg angle;
74
75 in >> angle;
76
77 source.set(angle);
78
79 return in;
80 }

◆ 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 90 of file JMorphology.hh.

91 {
92 return out << angle_type_deg(source);
93 }

◆ 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

◆ x1_deg

double JASTRONOMY::JMorphologyBinary::x1_deg

Definition at line 383 of file JMorphology.hh.

◆ y1_deg

double JASTRONOMY::JMorphologyBinary::y1_deg

Definition at line 383 of file JMorphology.hh.

◆ w1

double JASTRONOMY::JMorphologyBinary::w1

Definition at line 383 of file JMorphology.hh.

◆ s1_deg

double JASTRONOMY::JMorphologyBinary::s1_deg

Definition at line 383 of file JMorphology.hh.

◆ x2_deg

double JASTRONOMY::JMorphologyBinary::x2_deg

Definition at line 384 of file JMorphology.hh.

◆ y2_deg

double JASTRONOMY::JMorphologyBinary::y2_deg

Definition at line 384 of file JMorphology.hh.

◆ w2

double JASTRONOMY::JMorphologyBinary::w2

Definition at line 384 of file JMorphology.hh.

◆ s2_deg

double JASTRONOMY::JMorphologyBinary::s2_deg

Definition at line 384 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: