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

Implementation of nuisance based on histogram. More...

#include <JNuisance.hh>

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

Public Types

typedef JClonable< JClonable_t >::clone_type clone_type
 

Public Member Functions

virtual ~JNuisanceTH1 ()
 Virtual destructor.
 
virtual std::istream & read (std::istream &in) override
 Read nuisance from input stream.
 
virtual std::ostream & write (std::ostream &out) const override
 Write nuisance to output stream.
 
double get () const override
 Get value.
 
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 nuisance based on histogram.

Definition at line 262 of file JNuisance.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

◆ ~JNuisanceTH1()

virtual JASTRONOMY::JNuisanceTH1::~JNuisanceTH1 ( )
inlinevirtual

Virtual destructor.

Definition at line 268 of file JNuisance.hh.

269 {
270 if (in != NULL) {
271 in->Close();
272 }
273 }

Member Function Documentation

◆ read()

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

Read nuisance from input stream.

Parameters
ininput stream
Returns
input stream

Definition at line 282 of file JNuisance.hh.

283 {
284 in >> this->filename
285 >> this->histname;
286
287 load();
288
289 return in;
290 }
void load()
Load histogram from file.
Definition JNuisance.hh:324

◆ write()

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

Write nuisance to output stream.

Parameters
outoutput stream
Returns
output stream

Definition at line 299 of file JNuisance.hh.

300 {
301 return out << this->filename << ' '
302 << this->histname;
303 }

◆ get()

double JASTRONOMY::JNuisanceTH1::get ( ) const
inlineoverride

Get value.

Returns
value

Definition at line 311 of file JNuisance.hh.

312 {
313 return h1->GetRandom(gRandom);
314 }

◆ load()

void JASTRONOMY::JNuisanceTH1::load ( )
inlineprotected

Load histogram from file.

Definition at line 324 of file JNuisance.hh.

325 {
326 in = TFile::Open(filename.c_str(), "exist");
327
328 if (in == NULL || !in->IsOpen()) {
329 THROW(JFileOpenException, "File: " << filename << " not opened.");
330 }
331
332 h1 = dynamic_cast<TH1D*>(in->Get(histname.c_str()));
333
334 if (h1 == NULL) {
335 THROW(JValueOutOfRange, "Histogram: " << histname << " not found.");
336 }
337 }
#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::JNuisanceTH1::filename

Definition at line 317 of file JNuisance.hh.

◆ histname

std::string JASTRONOMY::JNuisanceTH1::histname

Definition at line 318 of file JNuisance.hh.

◆ in

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

Definition at line 339 of file JNuisance.hh.

◆ h1

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

Definition at line 340 of file JNuisance.hh.


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