Jpp  18.2.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Member Functions | Friends | List of all members
JDATABASE::JPMTRunsetupParams< JValue_t > Class Template Reference

Auxiliary class for PMT run setup parameters. More...

#include <JPMTRunsetupParams.hh>

Inheritance diagram for JDATABASE::JPMTRunsetupParams< JValue_t >:
std::map< std::string, JPMTValue< JValue_t > >

Classes

struct  result_type
 Type definition of PMT parameter value. More...
 

Public Member Functions

 JPMTRunsetupParams ()
 Default constructor. More...
 
void configure (const int id, const int run, const std::string &parameter)
 Configure PMT run setup parameters for given detector and run. More...
 
result_type operator() (const JUPI_t &upi) const
 Get PMT parameter value for given UPI of PMT. More...
 

Friends

std::ostream & operator<< (std::ostream &out, const JPMTRunsetupParams &object)
 Write PMT run setup parameters to output stream. More...
 

Detailed Description

template<class JValue_t>
class JDATABASE::JPMTRunsetupParams< JValue_t >

Auxiliary class for PMT run setup parameters.

This class provides for an implementation of the fallback method based on the UPI of a PMT and the value of JRunsetupParams::ORDER.

Definition at line 56 of file JPMTRunsetupParams.hh.

Constructor & Destructor Documentation

template<class JValue_t>
JDATABASE::JPMTRunsetupParams< JValue_t >::JPMTRunsetupParams ( )
inline

Default constructor.

Definition at line 72 of file JPMTRunsetupParams.hh.

73  {}

Member Function Documentation

template<class JValue_t>
void JDATABASE::JPMTRunsetupParams< JValue_t >::configure ( const int  id,
const int  run,
const std::string parameter 
)
inline

Configure PMT run setup parameters for given detector and run.

Parameters
iddetector identifier
runrun number
parameterparameter name

Definition at line 83 of file JPMTRunsetupParams.hh.

84  {
85  using namespace std;
86  using namespace JPP;
87 
88  this->clear();
89 
90  string rs_oid;
91  JAllParams upars;
92 
93  {
94  ResultSet& rs = getResultSet(getTable<JRuns>(), getSelector<JRuns>(id, run));
95 
97 
98  if (rs >> parameters) {
99  rs_oid = parameters.RUNSETUPID;
100  }
101 
102  rs.Close();
103  }
104  {
105  ResultSet& rs = getResultSet(getTable<JAllParams>(), getSelector<JAllParams>(OPTICS_t));
106 
107  for (JAllParams parameters; rs >> parameters; ) {
108  if (parameters.NAME == parameter) {
109  upars = parameters;
110  }
111  }
112 
113  rs.Close();
114  }
115  {
116  ResultSet& rs = getResultSet(getTable<JRunsetupParams>(), getSelector<JRunsetupParams>(getDetector(id), rs_oid));
117 
118  for (JRunsetupParams parameters; rs >> parameters; ) {
119  if (parameters.PAR_OID == upars.OID && parameters.ISINPUT == 'Y') {
120  if (parameters.VALUE != "") {
121 
122  JPMTValue<JValue_t>& value = (*this)[parameters.UPIFILTER];
123 
124  if (parameters.ORDER > value.first) {
125 
126  value.first = parameters.ORDER;
127 
128  istringstream(parameters.VALUE) >> value.second;
129  }
130  }
131  }
132  }
133 
134  rs.Close();
135  }
136  }
Auxiliary data structure for fallback order of PMT data.
*fatal Wrong number of arguments esac JCookie sh typeset Z DETECTOR typeset Z SOURCE_RUN typeset Z TARGET_RUN set_variable PARAMETERS_FILE $WORKDIR parameters
Definition: diff-Tuna.sh:38
JDetectorsHelper & getDetector()
Auxiliary function for helper object initialisation.
Definition: JDBToolkit.hh:378
const char *const OPTICS_t
sub-system of PMT
ResultSet & getResultSet(const std::string &query)
Get result set.
Definition: JDB.hh:436
Template definition for getting table specific selector.
std::string RUNSETUPID
Definition: JRuns.hh:26
template<class JValue_t>
result_type JDATABASE::JPMTRunsetupParams< JValue_t >::operator() ( const JUPI_t upi) const
inline

Get PMT parameter value for given UPI of PMT.

Parameters
upiUPI
Returns
PMT parameter value

Definition at line 145 of file JPMTRunsetupParams.hh.

146  {
147  typename JPMTRunsetupParams::const_iterator p = this->find(upi.toString()), p0 = p, p1 = p;
148 
149  // fallbacks
150 
151  const JUPI_t buffer[] = {
154  JUPI_t(upi.getPBS(), "", JUPI_t::DEFAULT_VERSION, 0),
156  };
157 
158  for (const JUPI_t& i : buffer) {
159  if ((p = this->find(i.toString())) != this->end()) {
160  if (p1 == this->end() || p->first > p1->first) {
161  p1 = p;
162  }
163  }
164  }
165 
166  if (p1 != this->end()) {
167  return { p0 != p1, p1->second.second };
168  }
169 
170  THROW(JDatabaseException, "Invalid UPI " << upi);
171  }
TPaveText * p1
const std::string & getVariant() const
Get variant.
Definition: JUPI_t.hh:111
static const int DEFAULT_VERSION
Default version.
Definition: JUPI_t.hh:38
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
Universal product identifier (UPI).
Definition: JUPI_t.hh:30
static const int DEFAULT_NUMBER
Default number.
Definition: JUPI_t.hh:39
const JPBS_t & getPBS() const
Get PBS.
Definition: JPBS_t.hh:101
std::string toString() const
Convert UPI.
Definition: JUPI_t.hh:144

Friends And Related Function Documentation

template<class JValue_t>
std::ostream& operator<< ( std::ostream &  out,
const JPMTRunsetupParams< JValue_t > &  object 
)
friend

Write PMT run setup parameters to output stream.

Parameters
outoutput stream
objectPMT run setup parameters
Returns
output stream

Definition at line 181 of file JPMTRunsetupParams.hh.

182  {
183  using namespace std;
184 
185  for (typename JPMTRunsetupParams::const_iterator i = object.begin(); i != object.end(); ++i) {
186  out << left << setw(32) << i->first << ' ' << right << i->second.second << endl;
187  }
188 
189  return out;
190  }

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