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

Implementation of detector resolution based on histogram. More...

#include <JResolution.hh>

Inheritance diagram for JASTRONOMY::JResolutionTH1:
JLANG::JClonable< JClonable_t, JDerived_t > JASTRONOMY::JResolutionLog

Public Types

typedef JClonable< JClonable_t >::clone_type clone_type
 

Public Member Functions

virtual ~JResolutionTH1 ()
 Virtual destructor.
 
virtual std::istream & read (std::istream &in) override
 Read detector resolution from input stream.
 
virtual std::ostream & write (std::ostream &out) const override
 Write detector resolution to output stream.
 
JDirection3D get () const override
 Get direction.
 
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
 
TH1D * h1 = NULL
 

Detailed Description

Implementation of detector resolution based on histogram.

Note that all input angles are in degrees.

Definition at line 227 of file JResolution.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

◆ ~JResolutionTH1()

virtual JASTRONOMY::JResolutionTH1::~JResolutionTH1 ( )
inlinevirtual

Virtual destructor.

Definition at line 233 of file JResolution.hh.

234 {
235 if (in != NULL) {
236 in->Close();
237 }
238 }

Member Function Documentation

◆ read()

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

Read detector resolution from input stream.

Parameters
ininput stream
Returns
input stream

Definition at line 247 of file JResolution.hh.

248 {
249 in >> this->filename
250 >> this->histname;
251
252 load();
253
254 return in;
255 }
void load()
Load histogram from file.

◆ write()

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

Write detector resolution to output stream.

Parameters
outoutput stream
Returns
output stream

Definition at line 264 of file JResolution.hh.

265 {
266 return out << this->filename << ' '
267 << this->histname;
268 }

◆ get()

JDirection3D JASTRONOMY::JResolutionTH1::get ( ) const
inlineoverride

Get direction.

Returns
direction

Definition at line 276 of file JResolution.hh.

277 {
278 using namespace JPP;
279
280 JDirection3D u(0.0, 0.0, 1.0);
281
282 if (h1 != NULL) {
283
284 const double theta = getRadians(h1->GetRandom(gRandom));
285 const double phi = gRandom->Uniform(-PI, +PI);
286
287 const JRotation3D R(JAngle3D(theta, phi));
288
289 u.rotate_back(R);
290 }
291
292 return u;
293 }
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).

◆ load()

void JASTRONOMY::JResolutionTH1::load ( )
inlineprotected

Load histogram from file.

Definition at line 303 of file JResolution.hh.

304 {
305 in = TFile::Open(filename.c_str(), "exist");
306
307 if (in == NULL || !in->IsOpen()) {
308 THROW(JFileOpenException, "File: " << filename << " not opened.");
309 }
310
311 h1 = dynamic_cast<TH1D*>(in->Get(histname.c_str()));
312
313 if (h1 == NULL) {
314 THROW(JValueOutOfRange, "Histogram: " << histname << " not found.");
315 }
316 }
#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::JResolutionTH1::filename

Definition at line 296 of file JResolution.hh.

◆ histname

std::string JASTRONOMY::JResolutionTH1::histname

Definition at line 297 of file JResolution.hh.

◆ in

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

Definition at line 318 of file JResolution.hh.

◆ h1

TH1D* JASTRONOMY::JResolutionTH1::h1 = NULL
mutableprotected

Definition at line 319 of file JResolution.hh.


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