Jpp  master_rocky-43-ge265d140c
the software that should make you happy
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Attributes | Static Private Member Functions | Friends | List of all members
JDETECTOR::JHVCalibration_t Struct Reference

Data structure for PMT high-voltage calibration. More...

#include <JDetectorCalibration.hh>

Inheritance diagram for JDETECTOR::JHVCalibration_t:
JDATABASE::JUPI_t JDATABASE::JPBS_t std::vector< int >

Public Member Functions

 JHVCalibration_t ()
 Default constructor. More...
 
 JHVCalibration_t (const JUPI_t &upi, const std::string &result, const double hv, const std::vector< int > runNumberList=std::vector< int >(0), const double gain=1.0)
 Constructor. More...
 
const JUPI_tgetUPI () const
 Get UPI. More...
 
const std::string & getVariant () const
 Get variant. More...
 
int getVersion () const
 Get version. More...
 
int getNumber () const
 Get serial number. More...
 
std::string toString () const
 Convert UPI. More...
 
 ClassDefNV (JUPI_t, 1)
 
 ClassDefNV (JPBS_t, 1)
 
const JPBS_tgetPBS () const
 Get PBS. More...
 
bool is_valid () const
 Check validity. More...
 

Static Public Member Functions

static int getVersion ()
 Get HV-tuning database test type. More...
 
static void setVersion (const int version)
 Set HV-tuning database test type. More...
 

Public Attributes

std::string result
 
double supplyVoltage
 
std::vector< int > runNumbers
 
double PMTgain
 

Static Public Attributes

static const char SEPARATOR = '/'
 Separator between PBS, variant and version. More...
 
static const int DEFAULT_VERSION = -1
 Default version. More...
 
static const int DEFAULT_NUMBER = -1
 Default number. More...
 
static const char DOT = '.'
 Separator between PBS values. More...
 

Protected Attributes

std::string variant
 
int version
 
int number
 

Static Private Member Functions

static int & get_version ()
 Get reference to HV-tuning database test type. More...
 

Friends

void to_json (json &js, const JHVCalibration_t &object)
 Convert PMT high-voltage calibration to JSon. More...
 
void from_json (const json &js, JHVCalibration_t &object)
 Convert JSon to PMT high-voltage calibration. More...
 

Detailed Description

Data structure for PMT high-voltage calibration.

Definition at line 249 of file JDetectorCalibration.hh.

Constructor & Destructor Documentation

◆ JHVCalibration_t() [1/2]

JDETECTOR::JHVCalibration_t::JHVCalibration_t ( )
inline

Default constructor.

Definition at line 255 of file JDetectorCalibration.hh.

255  :
256  JUPI_t (),
257  result (Fail_t),
258  supplyVoltage(0.0),
260  PMTgain (0.0)
261  {}
static const std::string Fail_t
JUPI_t()
Default constructor.
Definition: JUPI_t.hh:44

◆ JHVCalibration_t() [2/2]

JDETECTOR::JHVCalibration_t::JHVCalibration_t ( const JUPI_t upi,
const std::string &  result,
const double  hv,
const std::vector< int >  runNumberList = std::vector<int>(0),
const double  gain = 1.0 
)
inline

Constructor.

Parameters
upiUPI
resultresult
hvHV
runNumberListrun numbers
gaingain

Definition at line 273 of file JDetectorCalibration.hh.

277  :
278  JUPI_t (upi),
279  result (result),
280  supplyVoltage(hv),
281  runNumbers (runNumberList),
282  PMTgain (gain)
283  {}

Member Function Documentation

◆ getVersion() [1/2]

static int JDETECTOR::JHVCalibration_t::getVersion ( )
inlinestatic

Get HV-tuning database test type.

Returns
HV-tuning database test type

Definition at line 291 of file JDetectorCalibration.hh.

292  {
293  return get_version();
294  }
static int & get_version()
Get reference to HV-tuning database test type.

◆ setVersion()

static void JDETECTOR::JHVCalibration_t::setVersion ( const int  version)
inlinestatic

Set HV-tuning database test type.

Parameters
versionHV-tuning database test type

Definition at line 302 of file JDetectorCalibration.hh.

303  {
304  get_version() = version;
305  }

◆ get_version()

static int& JDETECTOR::JHVCalibration_t::get_version ( )
inlinestaticprivate

Get reference to HV-tuning database test type.

Returns
HV-tuning database test type

Definition at line 404 of file JDetectorCalibration.hh.

405  {
406  static int version = 3;
407 
408  return version;
409  }

◆ getUPI()

const JUPI_t& JDATABASE::JUPI_t::getUPI ( ) const
inlineinherited

Get UPI.

Returns
UPI

Definition at line 100 of file JUPI_t.hh.

101  {
102  return static_cast<const JUPI_t&>(*this);
103  }
Universal product identifier (UPI).
Definition: JUPI_t.hh:32

◆ getVariant()

const std::string& JDATABASE::JUPI_t::getVariant ( ) const
inlineinherited

Get variant.

Returns
variant

Definition at line 111 of file JUPI_t.hh.

112  {
113  return variant;
114  }
std::string variant
Definition: JUPI_t.hh:279

◆ getVersion() [2/2]

int JDATABASE::JUPI_t::getVersion ( ) const
inlineinherited

Get version.

Returns
version

Definition at line 122 of file JUPI_t.hh.

123  {
124  return version;
125  }

◆ getNumber()

int JDATABASE::JUPI_t::getNumber ( ) const
inlineinherited

Get serial number.

Returns
serial number

Definition at line 133 of file JUPI_t.hh.

134  {
135  return number;
136  }

◆ toString()

std::string JDATABASE::JUPI_t::toString ( ) const
inlineinherited

Convert UPI.

Returns
UPI

Definition at line 144 of file JUPI_t.hh.

145  {
146  std::ostringstream os;
147 
148  os << *this;
149 
150  return os.str();
151  }

◆ ClassDefNV() [1/2]

JDATABASE::JUPI_t::ClassDefNV ( JUPI_t  ,
 
)
inherited

◆ ClassDefNV() [2/2]

JDATABASE::JPBS_t::ClassDefNV ( JPBS_t  ,
 
)
inherited

◆ getPBS()

const JPBS_t& JDATABASE::JPBS_t::getPBS ( ) const
inlineinherited

Get PBS.

Returns
PBS

Definition at line 101 of file JPBS_t.hh.

102  {
103  return static_cast<const JPBS_t&>(*this);
104  }
Product breakdown structure (PBS).
Definition: JPBS_t.hh:29

◆ is_valid()

bool JDATABASE::JPBS_t::is_valid ( ) const
inlineinherited

Check validity.

Returns
true if valid; else false

Definition at line 112 of file JPBS_t.hh.

113  {
114  return !this->empty();
115  }

Friends And Related Function Documentation

◆ to_json

void to_json ( json js,
const JHVCalibration_t object 
)
friend

Convert PMT high-voltage calibration to JSon.

Parameters
jsjson2
objectPMT high-voltage calibration

Definition at line 314 of file JDetectorCalibration.hh.

315  {
316  using namespace std;
317 
318  ostringstream os;
319 
320  os << object.getUPI();
321 
322  js[UPI_t] = os.str();
323  js[Test_t + Result_t] = object.result;
325  { Unit_t, Volt_t },
326  { Values_t, get_string_array(object.supplyVoltage) } };
327 
328  if (JHVCalibration_t::getVersion() < 2) {
329 
330  js[Test_t + Parameters_t][2] = json{ { Name_t, PMTGain_t },
331  { Unit_t, Unitless_t },
332  { Values_t, get_string_array(object.PMTgain) } };
333  }
334 
335 
336  if (JHVCalibration_t::getVersion() < 3) {
337 
338  vector<string> runNumberList;
339 
340  for (vector<int>::const_iterator i = object.runNumbers.cbegin(); i != object.runNumbers.cend(); ++i) {
341  runNumberList.push_back(to_string(*i));
342  }
343 
344  js[Test_t + Parameters_t][1] = json{ { Name_t, RunNumber_t },
345  { Unit_t, Unitless_t },
346  { Values_t, runNumberList } };
347  }
348  }
nlohmann::json json
std::vector< std::string > get_string_array(T value)
Cast single value to array of strings, conform the DB-format.
std::string to_string(const T &value)
Convert value to string.
static const std::string Name_t
static const std::string RunNumber_t
static const std::string Parameters_t
static const std::string Unit_t
static const std::string Unitless_t
static const std::string Result_t
static const std::string PMTSupplyVoltage_t
static const std::string Values_t
static const std::string Test_t
static const std::string UPI_t
static const std::string Volt_t
static const std::string PMTGain_t
Definition: JSTDTypes.hh:14
static int getVersion()
Get HV-tuning database test type.

◆ from_json

void from_json ( const json js,
JHVCalibration_t object 
)
friend

Convert JSon to PMT high-voltage calibration.

Parameters
jsjson
objectPMT high-voltage calibration

Definition at line 357 of file JDetectorCalibration.hh.

358  {
359  using namespace std;
360 
361  stringstream is(js.at(UPI_t).get<string>());
362 
363  is >> static_cast<JUPI_t&>(object);
364 
365  json parameters = js.at(Test_t + Parameters_t);
366 
367  if (JHVCalibration_t::getVersion() > 0 && parameters.size() > 0) {
368 
369  object.result = js.at(Test_t + Result_t).get<string>();
370  object.supplyVoltage = retrieve_value(parameters[0].at(Values_t).get<vector<string>>());
371 
372  if (JHVCalibration_t::getVersion() < 3 && parameters.size() > 1) {
373 
374  vector<string> runNumberList = parameters[1].at(Values_t).get<vector<string>>();
375 
376  for (vector<string>::const_iterator i = runNumberList.begin(); i != runNumberList.end(); ++i) {
377  object.runNumbers.push_back(stoi(*i));
378  }
379  }
380 
381  if (JHVCalibration_t::getVersion() < 2 && parameters.size() > 2) {
382  object.PMTgain = retrieve_value(parameters[2].at(Values_t).get<vector<string>>());
383  }
384 
385  } else {
386 
387  THROW(JValueOutOfRange, "JHVCalibration_t::from_json(): No " << MAKE_STRING(Test_t + Parameters_t) << " found." << endl);
388  }
389  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
#define MAKE_STRING(A)
Make string.
Definition: JPrint.hh:63
double retrieve_value(std::vector< std::string > string_value_array)
Retrieve value from json array of strings.

Member Data Documentation

◆ result

std::string JDETECTOR::JHVCalibration_t::result

Definition at line 392 of file JDetectorCalibration.hh.

◆ supplyVoltage

double JDETECTOR::JHVCalibration_t::supplyVoltage

Definition at line 393 of file JDetectorCalibration.hh.

◆ runNumbers

std::vector<int> JDETECTOR::JHVCalibration_t::runNumbers

Definition at line 394 of file JDetectorCalibration.hh.

◆ PMTgain

double JDETECTOR::JHVCalibration_t::PMTgain

Definition at line 395 of file JDetectorCalibration.hh.

◆ SEPARATOR

const char JDATABASE::JUPI_t::SEPARATOR = '/'
staticinherited

Separator between PBS, variant and version.

Definition at line 36 of file JUPI_t.hh.

◆ DEFAULT_VERSION

const int JDATABASE::JUPI_t::DEFAULT_VERSION = -1
staticinherited

Default version.

Definition at line 38 of file JUPI_t.hh.

◆ DEFAULT_NUMBER

const int JDATABASE::JUPI_t::DEFAULT_NUMBER = -1
staticinherited

Default number.

Definition at line 39 of file JUPI_t.hh.

◆ variant

std::string JDATABASE::JUPI_t::variant
protectedinherited

Definition at line 279 of file JUPI_t.hh.

◆ version

int JDATABASE::JUPI_t::version
protectedinherited

Definition at line 280 of file JUPI_t.hh.

◆ number

int JDATABASE::JUPI_t::number
protectedinherited

Definition at line 281 of file JUPI_t.hh.

◆ DOT

const char JDATABASE::JPBS_t::DOT = '.'
staticinherited

Separator between PBS values.

Definition at line 33 of file JPBS_t.hh.


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