46 static const int WILDCARD = -1;
48 static const std::string
reset_t =
"reset";
49 static const std::string
set_t =
"set";
50 static const std::string
setx_t =
"setx";
51 static const std::string
sety_t =
"sety";
52 static const std::string
setz_t =
"setz";
53 static const std::string
addx_t =
"addx";
54 static const std::string
addy_t =
"addy";
55 static const std::string
addz_t =
"addz";
56 static const std::string
subx_t =
"subx";
57 static const std::string
suby_t =
"suby";
58 static const std::string
subz_t =
"subz";
59 static const std::string
add_t =
"add";
60 static const std::string
sub_t =
"sub";
61 static const std::string
rot_t =
"rot";
62 static const std::string
lower_t =
"lower";
63 static const std::string
upper_t =
"upper";
64 static const std::string
mul_t =
"mul";
65 static const std::string
div_t =
"div";
66 static const std::string
tilt_t =
"tilt";
67 static const std::string
swap_t =
"swap";
69 static const std::string
assign_t =
"assign";
70 static const std::string
locate_t =
"locate";
71 static const std::string
string_t =
"string";
73 static const std::string
rand_t =
"rand";
82 static const std::string
RESET_t =
"RESET";
83 static const std::string
SET_t =
"SET";
84 static const std::string
ADD_t =
"ADD";
85 static const std::string
SUB_t =
"SUB";
86 static const std::string
ROT_t =
"ROT";
102 module.setCalibration(JCalibration());
103 module.setStatus(JStatus());
104 module.setQuaternion(JQuaternion3D());
105 module.set(getModule<JKM3NeT_t>(1).getPosition());
107 for (JModule::iterator pmt =
module.begin(); pmt !=
module.end(); ++pmt) {
112 }
else if (action ==
RESET_t) {
114 module.setCalibration(JCalibration());
115 module.setQuaternion(JQuaternion3D());
116 module.setCalibration(getAverage(make_array(module.begin(), module.end(), &JPMT::getT0), 0.0));
135 inline bool apply(
JModule&
module,
const std::string& action,
const double value)
137 if (action ==
set_t) {
141 }
else if (action ==
setx_t) {
143 module.set(JVector3D(value, module.getY(), module.getZ()));
145 }
else if (action ==
addx_t) {
147 module.add(JVector3D(value, 0.0, 0.0));
149 }
else if (action ==
subx_t) {
151 module.sub(JVector3D(value, 0.0, 0.0));
153 }
else if (action ==
sety_t) {
155 module.set(JVector3D(module.getX(), value, module.getZ()));
157 }
else if (action ==
addy_t) {
159 module.add(JVector3D(0.0, value, 0.0));
161 }
else if (action ==
suby_t) {
163 module.sub(JVector3D(0.0, value, 0.0));
165 }
else if (action ==
setz_t) {
167 module.set(JVector3D(module.getX(), module.getY(), value));
169 }
else if (action ==
addz_t) {
171 module.add(JVector3D(0.0, 0.0, value));
173 }
else if (action ==
subz_t) {
175 module.sub(JVector3D(0.0, 0.0, value));
177 }
else if (action ==
add_t) {
181 }
else if (action ==
sub_t) {
185 }
else if (action ==
rot_t) {
187 const JVector3D center =
module.getPosition();
191 module.rotate(JRotation3Z(value));
195 }
else if (action ==
lower_t ||
198 const JVector3D center =
module.getPosition();
204 for (JModule::iterator pmt =
module.begin(); pmt !=
module.end(); ++pmt) {
205 if ((action ==
upper_t && pmt->getDZ() > 0.0) ||
206 (action ==
lower_t && pmt->getDZ() < 0.0)) {
213 }
else if (action ==
mul_t) {
219 module.getPosition().getY(),
220 module.getPosition().getZ() * (1.0 + value));
223 module.getPosition().getY(),
224 module.getPosition().getZ() / (1.0 - value));
228 }
else if (action ==
div_t) {
234 module.getPosition().getY(),
235 module.getPosition().getZ() / (1.0 + value));
238 module.getPosition().getY(),
239 module.getPosition().getZ() * (1.0 - value));
243 }
else if (action ==
SET_t) {
245 module.getCalibration().setT0(value);
247 }
else if (action ==
ADD_t) {
249 module.getCalibration().addT0(value);
251 }
else if (action ==
SUB_t) {
253 module.getCalibration().subT0(value);
255 }
else if (action ==
ROT_t) {
257 module.setQuaternion(JQuaternion3Z(value) * module.getQuaternion());
261 module.add(gRandom->Gaus(0.0, value));
265 module.sub(gRandom->Gaus(0.0, value));
269 const JVector3D center =
module.getPosition();
273 module.rotate(JRotation3Z(gRandom->Gaus(0.0, value)));
280 module.getPosition().getY(),
288 module.getPosition().getY(),
295 module.setID((int) value);
299 module.setLocation(JLocation((int) value, module.getFloor()));
319 inline bool apply(
JModule&
module,
const std::string& action,
const double first,
const double second)
323 const double Tx = first;
324 const double Ty = second;
327 const double x =
Tx *
module.getZ() + module.getX();
328 const double y =
Ty *
module.getZ() + module.getY();
329 const double z =
Tz *
module.getZ();
331 module.set(JPosition3D(x,y,z));
335 module.setLocation(JLocation((int) first, (int) second));
337 }
else if (action ==
swap_t) {
366 else if (action ==
add_t)
368 else if (action ==
sub_t)
394 module.setQuaternion(Q);
395 else if (action ==
ADD_t)
396 module.setQuaternion(Q * module.getQuaternion());
397 else if (action ==
SUB_t)
398 module.setQuaternion(Q.getConjugate() * module.getQuaternion());
402 module.getQuaternion().normalise();
416 inline bool apply(
JModule&
module,
const std::string& action,
const std::string& value)
421 module.getStatus().set (getModuleStatusBit(value));
423 module.getStatus().reset(getModuleStatusBit(value));
429 catch(
const std::exception&) {
443 inline bool apply(
JPMT& pmt,
const std::string& action,
const std::string& value)
456 catch(
const std::exception&) {
480 return (action !=
"" && !
data.empty());
492 switch (
data.size()) {
495 return ::apply(
module, action);
498 return ::apply(
module, action, data[0]);
501 return ::apply(
module, action, data[0], data[1]);
528 for (
double x; in >>
x; ) {
532 in.clear(std::ios_base::eofbit);
581 if (pos != string::npos) {
589 for (
size_t i = 0; i !=
modifier.data.size(); ++i) {
606 struct JModuleModifier {
622 return ::apply(
module, action, value);
646 friend inline std::ostream&
operator<<(std::ostream& out,
const JModuleModifier&
modifier)
664 struct JPMTModifier {
678 bool apply(
JPMT& pmt)
const
680 return ::apply(pmt, action, value);
704 friend inline std::ostream&
operator<<(std::ostream& out,
const JPMTModifier&
modifier)
730 static const char SEPARATOR =
'-';
749 if (in >> range.
first) {
753 if (in.peek() == (
int) JRange_t::SEPARATOR) {
778 return out << range.
first << JRange_t::SEPARATOR << range.
second;
795 out <<
"Modifier" <<
' '
797 <<
setw(10) <<
module.getID() << ' '
798 << "action " << modifier << endl;
814 out <<
"module modifier" <<
' '
815 <<
"(" <<
setw(10) <<
id.getID() <<
")" <<
' '
816 <<
"action" <<
' ' <<
modifier.action <<
' '
833 out <<
"PMT modifier" <<
' '
835 <<
"action" <<
' ' <<
modifier.action <<
' '
963 JModuleModifier> >
wip;
999 "0 -> no sort; 1 -> module identifier; 2 -> module location") = 0, 1, 2;
1005 catch(
const exception &error) {
1011 const int ns = ((
keep.empty() ? 0 : 1) +
1012 (
rm .empty() ? 0 : 1) +
1013 (
id .empty() ? 0 : 1) +
1014 (del .empty() ? 0 : 1));
1017 FATAL(
"Use either option -k, -r, -m or -D." <<
endl);
1035 if (
detector.setToLatestVersion()) {
1063 for (JDetector::iterator
module =
detector.begin();
module != detector.end(); ) {
1068 if (
module->getString() >= i->first &&
module->getString() <= i->second) {
1074 if (
module->getString() >= i->first &&
module->getString() <= i->second) {
1080 __rm__ = find(
id.begin(),
id.end(),
module->getID()) ==
id.end();
1083 const auto range = del.equal_range(
module->getString());
1085 for (
auto i = range.
first; i != range.
second; ++i) {
1086 if (i->second ==
module->getFloor()) {
1092 module = detector.erase(module);
1103 if (
module->getID() == i->first || i->first == WILDCARD ){
1109 if (!i->second.apply(*
module)) {
1110 ERROR(
"No valid action: " << i->first <<
' ' << i->second <<
endl);
1121 if (
module->getString() == i->first || i->first == WILDCARD) {
1130 ERROR(
"No valid action: " << i->first <<
' ' << i->second <<
endl);
1140 const string action(
"fix distance between floors 0 and 1");
1144 DEBUG(
"String " <<
setw(4) << i->first <<
' ' << action <<
' ' <<
FIXED(7,3) << i->second <<
endl);
1149 if (router.hasLocation(
L0) && router.hasLocation(
L1)) {
1151 const double z1 =
detector[router.getAddress(
L1).first].getZ();
1153 JModule&
module = detector[router.getAddress(L0).first];
1155 module.set(JVector3D(module.getX(), module.getY(), z1 - i->second));
1159 ERROR(
"No valid action: " << i->first <<
' ' << action <<
endl);
1169 if (
module->getFloor() != 0) {
1171 if (
module->getString() == i->first || i->first == WILDCARD) {
1180 ERROR(
"No valid action: " << i->first <<
' ' << i->second <<
endl);
1192 if (
module->getID() == i->first || i->first == WILDCARD ){
1198 if (!i->second.apply(*
module)) {
1199 ERROR(
"No valid action: " << i->first <<
' ' << i->second <<
endl);
1210 if (
module->getID() == i->first.getModuleID() || i->first.getModuleID() == WILDCARD) {
1216 if (i->first.getPMTAddress() == WILDCARD) {
1219 if (!i->second.apply(
module->getPMT(pmt))) {
1220 ERROR(
"No valid action: " << i->first <<
' ' << i->second <<
endl);
1224 }
else if (i->first.getPMTAddress() >= 0 &&
1226 !i->second.apply(
module->getPMT(i->first.getPMTAddress()))) {
1227 ERROR(
"No valid action: " << i->first <<
' ' << i->second <<
endl);
1234 if (!
alt.empty() || !ring.empty()) {
1244 if (
module->getFloor() != 0) {
1256 if (!i->second.apply(
module->getPMT(
id.getPMTAddress()))) {
1257 ERROR(
"No valid action: " << i->first <<
' ' << i->second <<
endl);
1261 const auto range = ring.equal_range(
module->getID());
1263 for (
auto i = range.
first; i != range.
second; ++i) {
1273 for (
size_t i = 0; i !=
module->size(); ++i) {
1278 buffer[address] = (*module)[i];
1282 for (
size_t i = 0; i !=
module->size(); ++i) {
1290 while (position > 6) { position -= 6; }
1291 while (position < 1) { position += 6; }
1295 DEBUG(
"Module " <<
setw(10) <<
module->getID() <<
' ' << address <<
" <= " << source <<
endl);
1297 (*module)[i] = buffer[source];
Data structure for detector geometry and calibration.
int main(int argc, char **argv)
Direct access to location in detector data structure.
Base class for data structures with artithmetic capabilities.
General purpose messaging.
#define DEBUG(A)
Message macros.
Direct access to module in detector data structure.
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
I/O formatting auxiliaries.
Auxiliary class to define a range between two values.
Data structure for time calibration.
Lookup table for PMT addresses in detector.
Router for direct addressing of location data in detector data structure.
Logical location of module.
const JLocation & getLocation() const
Get location.
Lookup table for PMT addresses in optical module.
Data structure for a composite optical module.
int getPMTAddress() const
Get PMT address (= TDC).
Data structure for PMT physical address.
char ring
ring number ['A','F']
int position
position within ring [1,6]
Data structure for PMT geometry, calibration and status.
Utility class to parse parameter values.
Data structure for unit quaternion in three dimensions.
Data structure for vector in three dimensions.
double getY() const
Get y position.
double getZ() const
Get z position.
double getX() const
Get x position.
Auxiliary class for object identification.
int getID() const
Get identifier.
Wrapper class around string.
Template definition of a multi-dimensional oscillation probability interpolation table.
static const std::string string_t
string
std::ostream & operator<<(std::ostream &out, const morphology_type &object)
Write morphology to output stream.
std::istream & operator>>(std::istream &in, morphology_type &object)
Read morphology from input stream.
std::ostream & print(std::ostream &out, const JTestSummary &summary, T __begin, T __end, const bool useColors=true, const JFormat_t &formatting=JFormat_t(18, 3, std::ios::fixed))
Print test summary.
std::string getLabel(const JLocation &location)
Get module label for monitoring and other applications.
int getNumberOfPMTs(const JModule &module)
Get number of PMTs.
static const JGetPMTStatusBit getPMTStatusBit
Function object to map key to PMT status bit.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
void store(const std::string &file_name, const JDetector &detector)
Store detector to output file.
JDetectorAddressMap & getDetectorAddressMap()
Get detector address map.
bool hasDetectorAddressMap(const int id)
Check if detector address map is available.
JComparator< JResult_t T::*, JComparison::lt > make_comparator(JResult_t T::*member)
Helper method to create comparator between values of data member.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
bool is_valid(const json &js)
Check validity of JSon data.
Auxiliary data structure for floating point format specification.
Type definition of range.
JRange_t()
Default constructor.
Auxiliary class for handling status.
status_type getStatus(const JType< status_type > &type) const
Get status.
Empty structure for specification of parser element that is initialised (i.e. does not require input)...