44 static const int WILDCARD = -1;
72 static const std::string randset_t = rand_t + set_t;
73 static const std::string randadd_t = rand_t + add_t;
74 static const std::string randsub_t = rand_t + sub_t;
75 static const std::string randrot_t = rand_t + rot_t;
76 static const std::string randmul_t = rand_t + mul_t;
77 static const std::string randdiv_t = rand_t + div_t;
78 static const std::string randtilt_t = rand_t + tilt_t;
96 if (action == reset_t) {
105 for (JModule::iterator pmt = module.begin(); pmt != module.end(); ++pmt) {
110 }
else if (action == RESET_t) {
135 if (action == set_t) {
139 }
else if (action == setx_t) {
143 }
else if (action == addx_t) {
147 }
else if (action == subx_t) {
151 }
else if (action == sety_t) {
155 }
else if (action == addy_t) {
159 }
else if (action == suby_t) {
163 }
else if (action == setz_t) {
167 }
else if (action == addz_t) {
171 }
else if (action == subz_t) {
175 }
else if (action == add_t) {
179 }
else if (action == sub_t) {
183 }
else if (action == rot_t) {
193 }
else if (action == lower_t ||
202 for (JModule::iterator pmt = module.begin(); pmt != module.end(); ++pmt) {
203 if ((action == upper_t && pmt->getDZ() > 0.0) ||
204 (action == lower_t && pmt->getDZ() < 0.0)) {
211 }
else if (action == mul_t) {
226 }
else if (action == div_t) {
241 }
else if (action == SET_t) {
245 }
else if (action == ADD_t) {
249 }
else if (action == SUB_t) {
253 }
else if (action == ROT_t) {
257 }
else if (action == randadd_t) {
259 module.
add(gRandom->Gaus(0.0, value));
261 }
else if (action == randsub_t) {
263 module.
sub(gRandom->Gaus(0.0, value));
265 }
else if (action == randrot_t){
275 }
else if (action == randmul_t) {
283 }
else if (action == randdiv_t) {
291 }
else if (action == assign_t) {
293 module.
setID((
int) value);
319 if (action == tilt_t) {
321 const double Tx =
first;
322 const double Ty = second;
323 const double Tz = sqrt(1.0 - Tx*Tx - Ty*Ty);
325 const double x = Tx * module.
getZ() + module.
getX();
326 const double y = Ty * module.
getZ() + module.
getY();
327 const double z = Tz * module.
getZ();
331 }
else if (action == locate_t) {
335 }
else if (action == swap_t) {
337 std::swap(module[(
int) first], module[(
int) second]);
359 gRandom->Gaus(0.0, pos.
getY()),
360 gRandom->Gaus(0.0, pos.
getZ()));
364 else if (action == add_t)
366 else if (action == sub_t)
368 else if (action == randset_t)
370 else if (action == randadd_t)
372 else if (action == randsub_t)
393 else if (action == ADD_t)
395 else if (action == SUB_t)
420 else if (action == reset_t)
427 catch(
const std::exception&) {
447 else if (action == reset_t)
454 catch(
const std::exception&) {
478 return (action !=
"" && !
data.empty());
488 bool apply(
JModule& module)
const
490 switch (
data.size()) {
493 return ::apply(module, action);
496 return ::apply(module, action,
data[0]);
499 return ::apply(module, action,
data[0],
data[1]);
520 friend inline std::istream&
operator>>(std::istream&
in, JModifier& modifier)
522 if (in >> modifier.action) {
524 modifier.data.clear();
526 for (
double x; in >>
x; ) {
527 modifier.data.push_back(x);
530 in.clear(std::ios_base::eofbit);
544 friend inline std::ostream&
operator<<(std::ostream& out,
const JModifier& modifier)
546 out << modifier.action;
571 inline const JModifier& getModifier(
const int id,
const JModifier& modifier)
577 const string::size_type pos = modifier.action.find(rand_t);
579 if (pos != string::npos) {
581 JModifier&
result = buffer[id][modifier.action][modifier.data.size()];
583 if (!result.is_valid()) {
585 result.action = modifier.action.substr(pos + rand_t.length());
587 for (
size_t i = 0;
i != modifier.data.size(); ++
i) {
588 result.data.push_back(gRandom->Gaus(0.0, modifier.data[
i]));
604 struct JModuleModifier {
618 bool apply(
JModule& module)
const
620 return ::apply(module, action, value);
631 friend inline std::istream&
operator>>(std::istream& in, JModuleModifier& modifier)
633 return in >> modifier.action >> modifier.value;
644 friend inline std::ostream&
operator<<(std::ostream& out,
const JModuleModifier& modifier)
646 out << modifier.action;
648 out << modifier.value;
662 struct JPMTModifier {
676 bool apply(
JPMT& pmt)
const
678 return ::apply(pmt, action, value);
689 friend inline std::istream&
operator>>(std::istream& in, JPMTModifier& modifier)
691 return in >> modifier.action >> modifier.value;
702 friend inline std::ostream&
operator<<(std::ostream& out,
const JPMTModifier& modifier)
704 out << modifier.action;
706 out << modifier.value;
728 static const char SEPARATOR =
'-';
747 if (in >> range.
first) {
751 if (in.peek() == (int) JRange_t::SEPARATOR) {
776 return out << range.
first << JRange_t::SEPARATOR << range.
second;
788 inline void print(std::ostream& out,
const JModule& module,
const JModifier& modifier)
793 out <<
"Modifier" <<
' '
795 << setw(10) << module.
getID() <<
' '
796 <<
"action " << modifier << endl;
812 out <<
"module modifier" <<
' '
813 <<
"(" << setw(10) <<
id.getID() <<
")" <<
' '
814 <<
"action" <<
' ' << modifier.action <<
' '
815 <<
"value" <<
' ' << modifier.value << endl;
826 inline void print(std::ostream& out,
const JPMTIdentifier& pmt,
const JPMTModifier& modifier)
831 out <<
"PMT modifier" <<
' '
832 <<
"(" << setw(10) << pmt.
getID() <<
"," << setw(2) << pmt.
getPMTAddress() <<
")" <<
' '
833 <<
"action" <<
' ' << modifier.action <<
' '
834 <<
"value" <<
' ' << modifier.value << endl;
937 int main(
int argc,
char **argv)
951 JModuleModifier> > wip;
966 JParser<> zap(
"Auxiliary program to modify detector.");
981 zap[
'O'] =
make_field(option,
"sort modules: "\
982 "0 -> no sort; 1 -> module identifier; 2 -> module location") = 0, 1, 2;
983 zap[
'q'] =
make_field(squash,
"squash meta data");
988 catch(
const exception &error) {
989 FATAL(error.what() << endl);
994 const int ns = ((keep.empty() ? 0 : 1) +
995 (
rm .empty() ? 0 : 1) +
996 (
id .empty() ? 0 : 1) +
997 (del .empty() ? 0 : 1));
1000 FATAL(
"Use either option -k, -r, -m or -D." << endl);
1018 if (
detector.setToLatestVersion()) {
1019 NOTICE(
"Set detector version to " <<
detector.getVersion() << endl);
1033 istringstream
is(*
i);
1046 for (JDetector::iterator module =
detector.begin(); module !=
detector.end(); ) {
1048 bool __rm__ = !keep.empty() &&
rm.empty();
1063 __rm__ = find(
id.begin(),
id.end(), module->
getID()) ==
id.end();
1066 const auto range = del.equal_range(module->
getString());
1084 for (JDetector::iterator module =
detector.begin(); module !=
detector.end(); ++module) {
1086 if (module->
getID() ==
i->first ||
i->first == WILDCARD ){
1089 print(cout, *module,
i->second);
1092 if (!
i->second.apply(*module)) {
1093 ERROR(
"No valid action: " <<
i->first <<
' ' <<
i->second << endl);
1102 for (JDetector::iterator module =
detector.begin(); module !=
detector.end(); ++module) {
1104 if (module->
getString() ==
i->first ||
i->first == WILDCARD) {
1106 const JModifier modifier = getModifier(module->
getString(),
i->second);
1109 print(cout, *module,
i->second);
1112 if (!modifier.apply(*module)) {
1113 ERROR(
"No valid action: " <<
i->first <<
' ' <<
i->second << endl);
1122 for (JDetector::iterator module =
detector.begin(); module !=
detector.end(); ++module) {
1126 if (module->
getString() ==
i->first ||
i->first == WILDCARD) {
1128 const JModifier modifier = getModifier(module->
getString(),
i->second);
1131 print(cout, *module,
i->second);
1134 if (!modifier.apply(*module)) {
1135 ERROR(
"No valid action: " <<
i->first <<
' ' <<
i->second << endl);
1145 for (JDetector::iterator module =
detector.begin(); module !=
detector.end(); ++module) {
1147 if (module->
getID() ==
i->first ||
i->first == WILDCARD ){
1150 print(cout, *module,
i->second);
1153 if (!
i->second.apply(*module)) {
1154 ERROR(
"No valid action: " <<
i->first <<
' ' <<
i->second << endl);
1163 for (JDetector::iterator module =
detector.begin(); module !=
detector.end(); ++module) {
1165 if (module->
getID() ==
i->first.getModuleID() ||
i->first.getModuleID() == WILDCARD) {
1168 print(cout,
i->first,
i->second);
1171 if (
i->first.getPMTAddress() == WILDCARD) {
1174 if (!
i->second.apply(module->
getPMT(pmt))) {
1175 ERROR(
"No valid action: " <<
i->first <<
' ' <<
i->second << endl);
1179 }
else if (
i->first.getPMTAddress() >= 0 &&
1181 !
i->second.apply(module->
getPMT(
i->first.getPMTAddress()))) {
1182 ERROR(
"No valid action: " <<
i->first <<
' ' <<
i->second << endl);
1192 FATAL(
"Invalid detector identifier " <<
detector.getID() << endl);
1197 for (JDetector::iterator module =
detector.begin(); module !=
detector.end(); ++module) {
1206 print(cout,
id,
i->second);
1209 if (!
i->second.apply(module->
getPMT(
id.getPMTAddress()))) {
1210 ERROR(
"No valid action: " <<
i->first <<
' ' <<
i->second << endl);
Utility class to parse command line options.
static const JGetPMTStatusBit getPMTStatusBit
Function object to map key to PMT status bit.
Q(UTCMax_s-UTCMin_s)-livetime_s
int main(int argc, char *argv[])
JComparator< JResult_t T::*, JComparison::lt > make_comparator(JResult_t T::*member)
Helper method to create comparator between values of data member.
int getFloor() const
Get floor number.
Data structure for a composite optical module.
JQuaternion3D getConjugate() const
Get conjugate of this quaternion.
void setLocation(const JLocation &location)
Set location.
const JCalibration & getCalibration() const
Get calibration.
std::string getLabel(const JLocation &location)
Get module label for monitoring and other applications.
bool is_valid(const json &js)
Check validity of JSon data.
bool hasDetectorAddressMap(const int id)
Check if detector address map is available.
Utility class to parse parameter values.
std::iterator_traits< T >::value_type getAverage(T __begin, T __end)
Get average.
int getNumberOfPMTs(const JModule &module)
Get number of PMTs.
void subT0(const double t0)
Subtract time offset.
Lookup table for PMT addresses in detector.
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Data structure for time calibration.
static const JGetModuleStatusBit getModuleStatusBit
Function object to map key to module status bit.
JRange_t()
Default constructor.
Data structure for detector geometry and calibration.
const JModuleAddressMap & get(const int id) const
Get module address map.
then echo The file $DIR KM3NeT_00000001_00000000 root already please rename or remove it first
const JQuaternion3D & getQuaternion() const
Get quaternion.
JModule & sub(const JVector3D &pos)
Subtract position.
Lookup table for PMT addresses in optical module.
int getStatus() const
Get status.
Type definition of range.
I/O formatting auxiliaries.
Data structure for vector in three dimensions.
void setQuaternion(const JQuaternion3D &quaternion)
Set quaternion.
Logical location of module.
const JLocation & getLocation() const
Get location.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
const array_type< JValue_t > & make_array(const JValue_t(&array)[N])
Method to create array of values.
int getID() const
Get identifier.
Auxiliary class for handling status.
This class represents a rotation around the z-axis.
Data structure for PMT geometry, calibration and status.
void store(const std::string &file_name, const JDetector &detector)
Store detector to output file.
JPosition3D getPosition(const Vec &pos)
Get position.
int getPMTAddress() const
Get PMT address (= TDC).
double getY() const
Get y position.
const JPosition3D & getPosition() const
Get position.
JDetectorAddressMap & getDetectorAddressMap()
Get detector address map.
const JPMT & getPMT(const int index) const
Get PMT.
void rotate(const JRotation3D &R)
Rotate module.
General purpose messaging.
void setStatus(const JStatus &status)
Set status.
Data structure for unit quaternion in three dimensions.
Direct access to module in detector data structure.
z range($ZMAX-$ZMIN)< $MINIMAL_DZ." fi fi typeset -Z 4 STRING typeset -Z 2 FLOOR JPlot1D -f $
then JCookie sh JDataQuality D $DETECTOR_ID R
int getString() const
Get string number.
std::istream & operator>>(std::istream &in, JAANET::JHead &header)
Read header from input.
const JPMTAddressTranslator & getAddressTranslator(const int tdc) const
Get PMT address translator.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
void setT0(const double t0)
Set time offset.
Auxiliary class to define a range between two values.
Utility class to parse command line options.
Auxiliary class for object identification.
Wrapper class around string.
void setCalibration(const JCalibration &cal)
Set calibration.
void setID(const int id)
Set identifier.
double getX() const
Get x position.
Base class for data structures with artithmetic capabilities.
void addT0(const double t0)
Add time offset.
Data structure for position in three dimensions.
Data structure for PMT physical address.
JQuaternion3D & normalise()
Normalise quaternion.
do set_variable DETECTOR_TXT $WORKDIR detector
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
JModule & set(const JVector3D &pos)
Set position.
double getZ() const
Get z position.
JModule & add(const JVector3D &pos)
Add position.
double getT0() const
Get time offset.
static const std::string string_t
string