Jpp  17.3.2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Member Functions | Static 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, 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...
 

Static Public Member Functions

static std::string getUPI (const JUPI_t &upi)
 Get fallback UPI. 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.

Definition at line 38 of file JPMTRunsetupParams.hh.

Constructor & Destructor Documentation

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

Default constructor.

Definition at line 74 of file JPMTRunsetupParams.hh.

75  {}

Member Function Documentation

template<class JValue_t>
static std::string JDATABASE::JPMTRunsetupParams< JValue_t >::getUPI ( const JUPI_t upi)
inlinestatic

Get fallback UPI.

Parameters
upiUPI
Returns
UPI

Definition at line 57 of file JPMTRunsetupParams.hh.

58  {
59  std::ostringstream os;
60 
61  os << upi.getPBS()
63  << upi.getVariant()
65  << JUPI_t::DOT;
66 
67  return os.str();
68  }
const std::string & getVariant() const
Get variant.
Definition: JUPI_t.hh:108
static const char SEPARATOR
Separator between PBS, variant and version.
Definition: JUPI_t.hh:35
const JPBS_t & getPBS() const
Get PBS.
Definition: JPBS_t.hh:101
static const char DOT
Separator between PBS values.
Definition: JPBS_t.hh:33
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 85 of file JPMTRunsetupParams.hh.

86  {
87  using namespace std;
88  using namespace JPP;
89 
90  this->clear();
91 
92  string rs_oid;
93  JAllParams upars;
94 
95  {
96  ResultSet& rs = getResultSet(getTable<JRuns>(), getSelector<JRuns>(id, run));
97 
99 
100  if (rs >> parameters) {
101  rs_oid = parameters.RUNSETUPID;
102  }
103 
104  rs.Close();
105  }
106  {
107  ResultSet& rs = getResultSet(getTable<JAllParams>(), getSelector<JAllParams>(OPTICS_t));
108 
109  for (JAllParams parameters; rs >> parameters; ) {
110  if (parameters.NAME == parameter) {
111  upars = parameters;
112  }
113  }
114 
115  rs.Close();
116  }
117  {
118  ResultSet& rs = getResultSet(getTable<JRunsetupParams>(), getSelector<JRunsetupParams>(getDetector(id), rs_oid));
119 
120  for (JRunsetupParams parameters; rs >> parameters; ) {
121  if (parameters.PAR_OID == upars.OID && parameters.ISINPUT == 'Y') {
122  if (parameters.VALUE != "") {
123  istringstream(parameters.VALUE) >> (*this)[parameters.UPIFILTER];
124  }
125  }
126  }
127 
128  rs.Close();
129  }
130  }
*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:431
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 139 of file JPMTRunsetupParams.hh.

140  {
141  typename JPMTRunsetupParams::const_iterator p = this->find(upi.toString());
142 
143  const bool is_default = (p == this->end());
144 
145  if (is_default) {
146  p = this->find(getUPI(upi));
147  }
148 
149  if (p != this->end())
150  return { is_default, p->second };
151  else
152  THROW(JDatabaseException, "Invalid UPI " << upi);
153  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:696
static std::string getUPI(const JUPI_t &upi)
Get fallback UPI.
std::string toString() const
Convert UPI.
Definition: JUPI_t.hh:141

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 163 of file JPMTRunsetupParams.hh.

164  {
165  using namespace std;
166 
167  for (typename JPMTRunsetupParams::const_iterator i = object.begin(); i != object.end(); ++i) {
168  out << left << setw(32) << i->first << ' ' << right << setw(6) << i->second << endl;
169  }
170 
171  return out;
172  }

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