Jpp  master_rocky-40-g5f0272dcd
the software that should make you happy
Public Member Functions | Friends | List of all members
JDATABASE::JAHRSCalibration_t Struct Reference

Auxiliary class to map module identifier to AHRS calibration. More...

#include <JAHRSCalibration_t.hh>

Inheritance diagram for JDATABASE::JAHRSCalibration_t:
std::map< int, JAHRSCalibration > JLANG::JObjectStreamIO< T >

Public Member Functions

 JAHRSCalibration_t ()
 Default constructor. More...
 
 JAHRSCalibration_t (const int id, const int option)
 Constructor. More...
 
 JAHRSCalibration_t (const JDetectorIntegration_t &detector, const int option)
 Constructor. More...
 
 JAHRSCalibration_t (const char *file_name)
 Constructor. More...
 
void configure (const JDetectorIntegration_t &detector, const int option)
 Configure. More...
 
bool has (int id) const
 Check availability of AHRS calibration for given module identifier. More...
 
const JAHRSCalibrationget (int id) const
 Get AHRS calibration for given module identifier. More...
 
void load (const char *file_name)
 Load from input file. More...
 
void store (const char *file_name) const
 Store to output file. More...
 

Friends

std::istream & operator>> (std::istream &in, JAHRSCalibration_t &calibration)
 Read AHRS calibration from input stream. More...
 
std::ostream & operator<< (std::ostream &out, const JAHRSCalibration_t &calibration)
 Write AHRS calibration to output stream. More...
 

Detailed Description

Auxiliary class to map module identifier to AHRS calibration.

Definition at line 36 of file JAHRSCalibration_t.hh.

Constructor & Destructor Documentation

◆ JAHRSCalibration_t() [1/4]

JDATABASE::JAHRSCalibration_t::JAHRSCalibration_t ( )
inline

Default constructor.

Definition at line 43 of file JAHRSCalibration_t.hh.

44  {}

◆ JAHRSCalibration_t() [2/4]

JDATABASE::JAHRSCalibration_t::JAHRSCalibration_t ( const int  id,
const int  option 
)
inline

Constructor.

Parameters
iddetector identifier
optionoption

Definition at line 53 of file JAHRSCalibration_t.hh.

54  {
55  using namespace std;
56  using namespace JPP;
57 
59 
60  ResultSet& rs = getResultSet(getTable<JDetectorIntegration_t>());
61 
62  rs >> detector;
63 
64  detector.configure(getDetector(id));
65 
66  this->configure(detector, option);
67  }
ResultSet & getResultSet(const std::string &query)
Get result set.
Definition: JDB.hh:437
JDetectorsHelper & getDetector()
Auxiliary function for helper object initialisation.
Definition: JDBToolkit.hh:378
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JSTDTypes.hh:14
Detector file.
Definition: JHead.hh:227
void configure(const JDetectorIntegration_t &detector, const int option)
Configure.

◆ JAHRSCalibration_t() [3/4]

JDATABASE::JAHRSCalibration_t::JAHRSCalibration_t ( const JDetectorIntegration_t detector,
const int  option 
)
inline

Constructor.

Parameters
detectordetector integration
optionoption

Definition at line 76 of file JAHRSCalibration_t.hh.

77  {
78  this->configure(detector, option);
79  }

◆ JAHRSCalibration_t() [4/4]

JDATABASE::JAHRSCalibration_t::JAHRSCalibration_t ( const char *  file_name)
inline

Constructor.

Parameters
file_nameinput file

Definition at line 87 of file JAHRSCalibration_t.hh.

88  {
89  load(file_name);
90  }
void load(const char *file_name)
Load from input file.

Member Function Documentation

◆ configure()

void JDATABASE::JAHRSCalibration_t::configure ( const JDetectorIntegration_t detector,
const int  option 
)
inline

Configure.

The latest valid AHRS calibration data to the identifier of the parent module.
In this, the time order and validity of the AHRS calibration data are defined by AHRSComparator and JAHRSValidity, respectively.
The option corresponds to the maximal difference between latest version and latest valid version.

Parameters
detectordetector integration
optionoption

Definition at line 103 of file JAHRSCalibration_t.hh.

104  {
105  using namespace std;
106  using namespace JPP;
107 
109 
112 
113  this->clear();
114 
116 
117  ResultSet& rs = getResultSet(getTable<JAHRSCalibration>());
118 
119  rs >> calibration;
120 
121  rs.Close();
122 
123 
124  sort(calibration.begin(), calibration.end(), JAHRSCalibrationComparator());
125 
126 
127  for (vector<JAHRSCalibration>::const_iterator p = calibration.begin(); p != calibration.end(); ) {
128 
130 
131  for (++q; q != calibration.end() && q->SERIALNUMBER == p->SERIALNUMBER; ++q) {}
132 
133  const JUPI_t upi = getUPI(PBS::AHRS, p->SERIALNUMBER);
134 
135  const JDetectorIntegration_t::range_type r1 = detector.find(upi);
136 
137  if (distance(r1.first, r1.second) == 1) {
138 
139  const int id = getCLBID(detector[r1.first->second].container.getUPI());
140 
141  for (vector<JAHRSCalibration>::const_iterator i = p; i != q; ++i) {
142 
143  if (is_valid(*i) && distance(p,i) <= option) {
144 
145  this->insert(make_pair(id, *i));
146 
147  break;
148  }
149  }
150  }
151 
152  p = q;
153  }
154  }
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
static const JPBS_t AHRS(3, 4, 3, 4)
PBS of compass
JCLBIDHelper & getCLBID()
Auxiliary function for helper object initialisation.
Definition: JDBToolkit.hh:426
JUPIHelper & getUPI()
Auxiliary function for helper object initialisation.
Definition: JDBToolkit.hh:472
bool is_valid(const json &js)
Check validity of JSon data.
Calibration.
Definition: JHead.hh:330
Auxiliary data structure for sorting of AHRS calibrations.
Auxiliary data structure to check validity of AHRS calibration data.
static void initialise(JHelper_t &helper, const Args &...args)
Initialise.
Definition: JDBToolkit.hh:340
Universal product identifier (UPI).
Definition: JUPI_t.hh:32

◆ has()

bool JDATABASE::JAHRSCalibration_t::has ( int  id) const
inline

Check availability of AHRS calibration for given module identifier.

Parameters
idmodule identifier
Returns
true if AHRS calibration available; else false

Definition at line 163 of file JAHRSCalibration_t.hh.

164  {
165  return (this->find(id) != this->end());
166  }

◆ get()

const JAHRSCalibration& JDATABASE::JAHRSCalibration_t::get ( int  id) const
inline

Get AHRS calibration for given module identifier.

Parameters
idmodule identifier
Returns
AHRS calibration

Definition at line 175 of file JAHRSCalibration_t.hh.

176  {
177  const_iterator i = this->find(id);
178 
179  if (i != this->end())
180  return i->second;
181  else
182  THROW(JValueOutOfRange, "Invalid module identifier " << id);
183  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
Exception for accessing a value in a collection that is outside of its range.
Definition: JException.hh:180

◆ load()

template<class T >
void JLANG::JObjectStreamIO< T >::load ( const char *  file_name)
inlineinherited

Load from input file.

Parameters
file_namefile name

Definition at line 30 of file JObjectStreamIO.hh.

31  {
32  JLANG::load<std::ifstream>(file_name, static_cast<T&>(*this));
33  }

◆ store()

template<class T >
void JLANG::JObjectStreamIO< T >::store ( const char *  file_name) const
inlineinherited

Store to output file.

Parameters
file_namefile name

Definition at line 41 of file JObjectStreamIO.hh.

42  {
43  JLANG::store<std::ofstream>(file_name, static_cast<const T&>(*this));
44  }

Friends And Related Function Documentation

◆ operator>>

std::istream& operator>> ( std::istream &  in,
JAHRSCalibration_t calibration 
)
friend

Read AHRS calibration from input stream.

Parameters
ininput stream
calibrationAHRS calibration
Returns
input stream

Definition at line 193 of file JAHRSCalibration_t.hh.

194  {
195  int id;
196  JAHRSCalibration buffer;
197 
198  while (in >> id >> buffer) {
199  calibration[id] = buffer;
200  }
201 
202  return in;
203  }

◆ operator<<

std::ostream& operator<< ( std::ostream &  out,
const JAHRSCalibration_t calibration 
)
friend

Write AHRS calibration to output stream.

Parameters
outoutput stream
calibrationAHRS calibration
Returns
output stream

Definition at line 213 of file JAHRSCalibration_t.hh.

214  {
215  using namespace std;
216 
217  for (JAHRSCalibration_t::const_iterator i = calibration.begin(); i != calibration.end(); ++i) {
218  out << i->first << ' ' << i->second << endl;
219  }
220 
221  return out;
222  }

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