Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JDATABASE::JRunsetups Struct Reference

Auxiliary class for run setup evaluation. More...

#include <JRunsetups.hh>

Inheritance diagram for JDATABASE::JRunsetups:
std::map< int, JRunsetup_t >

Public Types

enum  JRuntype_t {
  CALIB = 100 , NANOCALIB = 200 , TEST = 300 , WRONG_TEST = 400 ,
  PHYS = 1000 , OTHER = -1
}
 Main run setup category. More...
 

Public Member Functions

void put (const int run, const std::string setup)
 Put run parameters.
 
void put (const JRuns &parameters)
 Put run parameters.
 
bool has (const int run) const
 Check if run setup is vailable.
 
float get (const int run) const
 Get run setup value.
 

Static Public Member Functions

static int getType (const std::string &setup)
 Get run setup type.
 

Static Public Attributes

static const char SEPARATOR = '.'
 separator between tokens in setup name
 
static const int MAX_NUMBER_OF_SETUPS = 1000
 maximal number of setups for a main category
 

Protected Attributes

std::map< int, std::vector< std::string > > data
 

Detailed Description

Auxiliary class for run setup evaluation.

The run number is mapped to a unique floating point value according the setup name.

Definition at line 34 of file JRunsetups.hh.

Member Enumeration Documentation

◆ JRuntype_t

Main run setup category.

Enumerator
CALIB 

Calibration.

NANOCALIB 

Nano-beacon calibration.

TEST 

Test.

WRONG_TEST 

Wrong test.

PHYS 

Physics.

OTHER 

Other.

Definition at line 45 of file JRunsetups.hh.

45 {
46 CALIB = 100, //!< Calibration
47 NANOCALIB = 200, //!< Nano-beacon calibration
48 TEST = 300, //!< Test
49 WRONG_TEST = 400, //!< Wrong test
50 PHYS = 1000, //!< Physics
51 OTHER = -1 //!< Other
52 };
@ NANOCALIB
Nano-beacon calibration.
Definition JRunsetups.hh:47
@ WRONG_TEST
Wrong test.
Definition JRunsetups.hh:49
@ CALIB
Calibration.
Definition JRunsetups.hh:46

Member Function Documentation

◆ getType()

static int JDATABASE::JRunsetups::getType ( const std::string & setup)
inlinestatic

Get run setup type.

Parameters
setuprun setup name
Returns
type

Definition at line 61 of file JRunsetups.hh.

62 {
63 using namespace std;
64 using namespace JPP;
65
66 static std::map<std::string, int> buffer;
67
68 if (buffer.empty()) {
69
70#define MAKE_ENTRY(A) std::make_pair(getClassname(#A), A)
71
72 buffer.insert(MAKE_ENTRY(CALIB));
73 buffer.insert(MAKE_ENTRY(NANOCALIB));
74 buffer.insert(MAKE_ENTRY(TEST));
75 buffer.insert(MAKE_ENTRY(WRONG_TEST));
76 buffer.insert(MAKE_ENTRY(PHYS));
77 buffer.insert(MAKE_ENTRY(OTHER));
78
79#undef MAKE_ENTRY
80 }
81
82 string key = setup;
83
84 string::size_type pos = key.find(SEPARATOR);
85
86 if (pos != string::npos) {
87 key = key.substr(0,pos);
88 }
89
91
92 if (i != buffer.end())
93 return i->second;
94 else
95 return OTHER;
96 }
#define MAKE_ENTRY(A)
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
static const char SEPARATOR
separator between tokens in setup name
Definition JRunsetups.hh:38

◆ put() [1/2]

void JDATABASE::JRunsetups::put ( const int run,
const std::string setup )
inline

Put run parameters.

Parameters
runrun number
setuprun setup name

Definition at line 105 of file JRunsetups.hh.

107 {
108 using namespace std;
109 using namespace JPP;
110
111 const int type = getType(setup);
112 vector<string>& buffer = data[type];
113
114 vector<string>::iterator p = std::find(buffer.begin(), buffer.end(), setup);
115
116 if (p == buffer.end()) {
117
118 buffer.push_back(setup);
119
120 p = buffer.rbegin().base();
121 }
122
123 const int index = distance(buffer.begin(),p) + 1;
124
125 if (index >= MAX_NUMBER_OF_SETUPS) {
126 cerr << "Index of " << setup << ' ' << index << " >= " << MAX_NUMBER_OF_SETUPS << endl;
127 }
128
129 if (type > 0)
130 (*this)[run] = { setup, type + (float) index / (float) MAX_NUMBER_OF_SETUPS };
131 else
132 (*this)[run] = { setup, type - (float) index / (float) MAX_NUMBER_OF_SETUPS };
133 }
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 int MAX_NUMBER_OF_SETUPS
maximal number of setups for a main category
Definition JRunsetups.hh:39
static int getType(const std::string &setup)
Get run setup type.
Definition JRunsetups.hh:61
std::map< int, std::vector< std::string > > data

◆ put() [2/2]

void JDATABASE::JRunsetups::put ( const JRuns & parameters)
inline

Put run parameters.

Parameters
parametersrun parameters

Definition at line 141 of file JRunsetups.hh.

142 {
143 put(parameters.RUN, parameters.RUNSETUPNAME);
144 }
void put(const int run, const std::string setup)
Put run parameters.

◆ has()

bool JDATABASE::JRunsetups::has ( const int run) const
inline

Check if run setup is vailable.

Parameters
runrun number
Returns
true if available; else false

Definition at line 153 of file JRunsetups.hh.

154 {
155 return this->find(run) != this->end();
156 }

◆ get()

float JDATABASE::JRunsetups::get ( const int run) const
inline

Get run setup value.

Parameters
runrun number
Returns
value

Definition at line 165 of file JRunsetups.hh.

166 {
167 const_iterator p = this->find(run);
168
169 if (p != this->end())
170 return p->second.value;
171 else
172 return 0.0;
173 }

Member Data Documentation

◆ SEPARATOR

const char JDATABASE::JRunsetups::SEPARATOR = '.'
static

separator between tokens in setup name

Definition at line 38 of file JRunsetups.hh.

◆ MAX_NUMBER_OF_SETUPS

const int JDATABASE::JRunsetups::MAX_NUMBER_OF_SETUPS = 1000
static

maximal number of setups for a main category

Definition at line 39 of file JRunsetups.hh.

◆ data

std::map<int, std::vector<std::string> > JDATABASE::JRunsetups::data
mutableprotected

Definition at line 176 of file JRunsetups.hh.


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