Jpp 20.0.0-rc.9-22-g74b57fa79
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:
JLANG::JClonable< JClonable_t, JDerived_t >

Public Types

typedef JClonable< JClonable_t >::clone_type clone_type
 

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.
 
virtual clone_type clone () const override
 Get clone of this object.
 

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
 

Detailed Description

Implementation of histogram source morphology.

Note that all input angles are in degrees.

Definition at line 387 of file JMorphology.hh.

Member Typedef Documentation

◆ clone_type

template<class JClonable_t , class JDerived_t >
JClonable<JClonable_t>::clone_type JLANG::JClonable< JClonable_t, JDerived_t >::clone_type
inherited

Definition at line 61 of file JClonable.hh.

Constructor & Destructor Documentation

◆ ~JMorphologyHistogram()

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

Virtual destructor.

Definition at line 393 of file JMorphology.hh.

394 {
395 if (in != NULL) {
396 in->Close();
397 }
398 }

Member Function Documentation

◆ read()

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

Read source morphology from input stream.

Parameters
ininput stream
Returns
input stream

Definition at line 407 of file JMorphology.hh.

408 {
409 JMorphology::read(in, *this)
410 >> this->filename
411 >> this->histname;
412
413 load();
414
415 return in;
416 }
void load()
Load histogram from file.
static std::istream & read(std::istream &in, JSourceLocation &source)
Read source location in degrees from input stream.

◆ write()

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

Write source morphology to output stream.

Parameters
outoutput stream
Returns
output stream

Definition at line 425 of file JMorphology.hh.

426 {
427 return JMorphology::write(out, *this)
428 << ' ' << this->filename
429 << ' ' << this->histname;
430 }
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

Definition at line 438 of file JMorphology.hh.

439 {
440 using namespace JPP;
441
442 Double_t x;
443 Double_t y;
444
445 h2->GetRandom2(x, y, gRandom);
446
447 x = sin(getRadians(x));
448 y = sin(getRadians(y));
449
450 JDirection3D u(x, y, sqrt(1.0 - x*x - y*y));
451
452 const JRotation3D Rs(this->getSourceLocation());
453
454 u.rotate_back(Rs);
455
456 return JSourceLocation(u);
457 }
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).
Location of astrophysical source.

◆ load()

void JASTRONOMY::JMorphologyHistogram::load ( )
inlineprotected

Load histogram from file.

Definition at line 466 of file JMorphology.hh.

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

◆ clone()

template<class JClonable_t , class JDerived_t >
virtual clone_type JLANG::JClonable< JClonable_t, JDerived_t >::clone ( ) const
inlineoverridevirtualinherited

Member Data Documentation

◆ filename

std::string JASTRONOMY::JMorphologyHistogram::filename

Definition at line 459 of file JMorphology.hh.

◆ histname

std::string JASTRONOMY::JMorphologyHistogram::histname

Definition at line 460 of file JMorphology.hh.

◆ in

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

Definition at line 481 of file JMorphology.hh.

◆ h2

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

Definition at line 482 of file JMorphology.hh.


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