47   static const std::string reset_t     = 
"reset";             
 
   48   static const std::string set_t       = 
"set";               
 
   49   static const std::string setx_t      = 
"setx";              
 
   50   static const std::string sety_t      = 
"sety";              
 
   51   static const std::string setz_t      = 
"setz";              
 
   52   static const std::string addx_t      = 
"addx";              
 
   53   static const std::string addy_t      = 
"addy";              
 
   54   static const std::string addz_t      = 
"addz";              
 
   55   static const std::string subx_t      = 
"subx";              
 
   56   static const std::string suby_t      = 
"suby";              
 
   57   static const std::string subz_t      = 
"subz";              
 
   58   static const std::string add_t       = 
"add";               
 
   59   static const std::string sub_t       = 
"sub";               
 
   60   static const std::string rot_t       = 
"rot";               
 
   61   static const std::string lower_t     = 
"lower";             
 
   62   static const std::string upper_t     = 
"upper";             
 
   63   static const std::string mul_t       = 
"mul";               
 
   64   static const std::string div_t       = 
"div";               
 
   65   static const std::string tilt_t      = 
"tilt";              
 
   66   static const std::string swap_t      = 
"swap";              
 
   68   static const std::string assign_t    = 
"assign";            
 
   69   static const std::string locate_t    = 
"locate";            
 
   70   static const std::string 
string_t    = 
"string";            
 
   72   static const std::string rand_t      = 
"rand";              
 
   73   static const std::string randset_t   =  rand_t + set_t;     
 
   74   static const std::string randadd_t   =  rand_t + add_t;     
 
   75   static const std::string randsub_t   =  rand_t + sub_t;     
 
   76   static const std::string randrot_t   =  rand_t + rot_t;     
 
   77   static const std::string randmul_t   =  rand_t + mul_t;     
 
   78   static const std::string randdiv_t   =  rand_t + div_t;     
 
   79   static const std::string randtilt_t  =  rand_t + tilt_t;    
 
   81   static const std::string RESET_t     = 
"RESET";             
 
   82   static const std::string SET_t       = 
"SET";               
 
   83   static const std::string ADD_t       = 
"ADD";               
 
   84   static const std::string SUB_t       = 
"SUB";               
 
   85   static const std::string ROT_t       = 
"ROT";               
 
   95   inline bool apply(
JModule& module, 
const std::string& action)
 
   97     if        (action == reset_t) {
 
  106       for (JModule::iterator pmt = module.begin(); pmt != module.end(); ++pmt) {
 
  111     } 
else if (action == RESET_t) {
 
  134   inline bool apply(
JModule& module, 
const std::string& action, 
const double value)
 
  136     if        (action == set_t) {                          
 
  140     } 
else if (action == setx_t) {
 
  144     } 
else if (action == addx_t) {
 
  148     } 
else if (action == subx_t) {
 
  152     } 
else if (action == sety_t) {
 
  156     } 
else if (action == addy_t) {
 
  160     } 
else if (action == suby_t) {
 
  164     } 
else if (action == setz_t) {
 
  168     } 
else if (action == addz_t) {
 
  172     } 
else if (action == subz_t) {
 
  176     } 
else if (action == add_t) {
 
  180     } 
else if (action == sub_t) {
 
  184     } 
else if (action == rot_t) {
 
  194     } 
else if (action == lower_t ||
 
  203       for (JModule::iterator pmt = module.begin(); pmt != module.end(); ++pmt) {
 
  204         if ((action == upper_t && pmt->getDZ() > 0.0) ||
 
  205             (action == lower_t && pmt->getDZ() < 0.0)) {
 
  212     } 
else if (action == mul_t) {
 
  227     } 
else if (action == div_t) {
 
  242     } 
else if (action == SET_t) {
 
  246     } 
else if (action == ADD_t) {
 
  250     } 
else if (action == SUB_t) {
 
  254     } 
else if (action == ROT_t) {
 
  258     } 
else if (action == randadd_t) {                      
 
  260       module.
add(gRandom->Gaus(0.0, value));
 
  262     } 
else if (action == randsub_t) {
 
  264       module.
sub(gRandom->Gaus(0.0, value));
 
  266     } 
else if (action == randrot_t){
 
  276     } 
else if (action == randmul_t) {
 
  284     } 
else if (action == randdiv_t) {
 
  292     } 
else if (action == assign_t) {                       
 
  294       module.
setID((
int) value);
 
  318   inline bool apply(
JModule& module, 
const std::string& action, 
const double first, 
const double second)
 
  320     if        (action == tilt_t) {                         
 
  322       const double Tx = first;
 
  323       const double Ty = second;
 
  324       const double Tz = sqrt(1.0 - Tx*Tx - Ty*Ty);
 
  326       const double x  = Tx * module.
getZ()  +  module.
getX();
 
  327       const double y  = Ty * module.
getZ()  +  module.
getY();
 
  328       const double z  = Tz * module.
getZ();
 
  332     } 
else if (action == locate_t) {
 
  336     } 
else if (action == swap_t) {
 
  338       std::swap(module[(
int) first], module[(
int) second]);
 
  357   inline bool apply(
JModule& module, 
const std::string& action, 
const JVector3D& pos)
 
  360                             gRandom->Gaus(0.0, pos.
getY()),
 
  361                             gRandom->Gaus(0.0, pos.
getZ()));
 
  365     else if (action == add_t)
 
  367     else if (action == sub_t)
 
  369     else if (action == randset_t)                      
 
  371     else if (action == randadd_t)
 
  373     else if (action == randsub_t)
 
  394     else if (action == ADD_t)
 
  396     else if (action == SUB_t)
 
  415   inline bool apply(
JModule& module, 
const std::string& action, 
const std::string& value)
 
  421       else if (action == reset_t)
 
  428     catch(
const std::exception&) {
 
  442   inline bool apply(
JPMT& pmt, 
const std::string& action, 
const std::string& value)
 
  448       else if (action == reset_t)
 
  455     catch(
const std::exception&) {
 
  479       return (action != 
"" && !
data.empty());
 
  489     bool apply(
JModule& module)
 const 
  491       switch (
data.size()) {
 
  494         return  ::apply(module, action);
 
  497         return  ::apply(module, action, 
data[0]);
 
  500         return  ::apply(module, action, 
data[0], 
data[1]);
 
  521     friend inline std::istream& 
operator>>(std::istream& in, JModifier& modifier)
 
  523       if (in >> modifier.action) {
 
  525         modifier.data.clear();
 
  527         for (
double x; in >> 
x; ) {
 
  528           modifier.data.push_back(
x);
 
  531         in.clear(std::ios_base::eofbit);
 
  545     friend inline std::ostream& 
operator<<(std::ostream& out, 
const JModifier& modifier)
 
  547       out << modifier.action;
 
  572   inline const JModifier& getModifier(
const int id, 
const JModifier& modifier)
 
  578     const string::size_type pos = modifier.action.find(rand_t);
 
  580     if (pos != string::npos) {
 
  582       JModifier& 
result = buffer[id][modifier.action][modifier.data.size()];
 
  586         result.action = modifier.action.substr(pos + rand_t.length());
 
  588         for (
size_t i = 0; i != modifier.data.size(); ++i) {
 
  589           result.data.push_back(gRandom->Gaus(0.0, modifier.data[i]));
 
  605   struct JModuleModifier {
 
  619     bool apply(
JModule& module)
 const 
  621       return ::apply(module, action, value);
 
  632     friend inline std::istream& 
operator>>(std::istream& in, JModuleModifier& modifier)
 
  634       return in >> modifier.action >> modifier.value;
 
  645     friend inline std::ostream& 
operator<<(std::ostream& out, 
const JModuleModifier& modifier)
 
  647       out << modifier.action;
 
  649       out << modifier.value;
 
  663   struct JPMTModifier {
 
  677     bool apply(
JPMT& pmt)
 const 
  679       return ::apply(pmt, action, value);
 
  690     friend inline std::istream& 
operator>>(std::istream& in, JPMTModifier& modifier)
 
  692       return in >> modifier.action >> modifier.value;
 
  703     friend inline std::ostream& 
operator<<(std::ostream& out, 
const JPMTModifier& modifier)
 
  705       out << modifier.action;
 
  707       out << modifier.value;
 
  729     static const char SEPARATOR = 
'-';
 
  748       if (in >> range.
first) {
 
  752         if (in.peek() == (
int) JRange_t::SEPARATOR) {
 
  777       return out << range.
first << JRange_t::SEPARATOR << range.
second;
 
  789   inline void print(std::ostream& out, 
const JModule& module, 
const JModifier& modifier)
 
  794     out << 
"Modifier"                     << 
' ' 
  796         << setw(10)  << module.
getID()    << 
' ' 
  797         << 
"action " << modifier          << endl;
 
  813     out << 
"module modifier"                    << 
' ' 
  814         << 
"(" << setw(10) << 
id.getID() << 
")" << 
' ' 
  815         << 
"action" << 
' ' << modifier.action << 
' '  
  816         << 
"value"  << 
' ' << modifier.value  << endl;
 
  827   inline void print(std::ostream& out, 
const JPMTIdentifier& pmt, 
const JPMTModifier& modifier)
 
  832     out << 
"PMT modifier"                                                                 << 
' ' 
  833         << 
"(" << setw(10) << pmt.
getID() << 
"," << setw(2) << pmt.
getPMTAddress() << 
")" << 
' ' 
  834         << 
"action" << 
' ' << modifier.action << 
' '  
  835         << 
"value"  << 
' ' << modifier.value  << endl;
 
  945 int main(
int argc, 
char **argv)
 
  959                JModuleModifier> >  wip;
 
  976     JParser<> zap(
"Auxiliary program to modify detector.");
 
  992     zap[
'O'] = 
make_field(option, 
"sort modules: "\
 
  993                           "0 -> no sort; 1 -> module identifier; 2 -> module location")     = 0, 1, 2;
 
  994     zap[
'q'] = 
make_field(squash, 
"squash meta data");
 
  999   catch(
const exception &error) {
 
 1000     FATAL(error.what() << endl);
 
 1003   gRandom->SetSeed(0);
 
 1005   const int ns = ((keep.empty() ? 0 : 1)  +
 
 1006                   (rm  .empty() ? 0 : 1)  +
 
 1007                   (
id  .empty() ? 0 : 1)  +
 
 1008                   (del .empty() ? 0 : 1));
 
 1011     FATAL(
"Use either option -k, -r, -m or -D." << endl);
 
 1029   if (
detector.setToLatestVersion()) {
 
 1030     NOTICE(
"Set detector version to " << 
detector.getVersion() << endl);
 
 1044       istringstream is(*i);
 
 1057     for (JDetector::iterator module = 
detector.begin(); module != 
detector.end(); ) {
 
 1059       bool __rm__ = !keep.empty() && rm.empty();
 
 1074         __rm__ = find(
id.begin(), 
id.end(), module->
getID()) == 
id.end();
 
 1077       const auto range = del.equal_range(module->
getString());
 
 1079       for (
auto i = range.
first; i != range.
second; ++i) {
 
 1080         if (i->second == module->
getFloor()) {
 
 1095     for (JDetector::iterator module = 
detector.begin(); module != 
detector.end(); ++module) {
 
 1100           print(cout, *module, i->second);
 
 1103         if (!i->second.apply(*module)) {
 
 1104           ERROR(
"No valid action: " << i->first << 
' ' << i->second << endl);
 
 1113     for (JDetector::iterator module = 
detector.begin(); module != 
detector.end(); ++module) {
 
 1117         const JModifier modifier = getModifier(module->
getString(), i->second);
 
 1120           print(cout, *module, i->second);
 
 1123         if (!modifier.apply(*module)) {
 
 1124           ERROR(
"No valid action: " << i->first << 
' ' << i->second << endl);
 
 1133     for (JDetector::iterator module = 
detector.begin(); module != 
detector.end(); ++module) {
 
 1139           const JModifier modifier = getModifier(module->
getString(), i->second);
 
 1142             print(cout, *module, i->second);
 
 1145           if (!modifier.apply(*module)) {
 
 1146             ERROR(
"No valid action: " << i->first << 
' ' << i->second << endl);
 
 1156     for (JDetector::iterator module = 
detector.begin(); module != 
detector.end(); ++module) {
 
 1161           print(cout, *module, i->second);
 
 1164         if (!i->second.apply(*module)) {
 
 1165           ERROR(
"No valid action: " << i->first << 
' ' << i->second << endl);
 
 1174     for (JDetector::iterator module = 
detector.begin(); module != 
detector.end(); ++module) {
 
 1176       if (module->
getID() == i->first.getModuleID() || i->first.getModuleID() == 
WILDCARD) {
 
 1179           print(cout, i->first, i->second);
 
 1182         if        (i->first.getPMTAddress() == 
WILDCARD) {
 
 1185             if (!i->second.apply(module->
getPMT(pmt))) {
 
 1186               ERROR(
"No valid action: " << i->first << 
' ' << i->second << endl);
 
 1190         } 
else if (i->first.getPMTAddress() >= 0                         &&
 
 1192                    !i->second.apply(module->
getPMT(i->first.getPMTAddress()))) {
 
 1193           ERROR(
"No valid action: " << i->first << 
' ' << i->second << endl);
 
 1200   if (!alt.empty() || !ring.empty()) {
 
 1203       FATAL(
"Invalid detector identifier " << 
detector.getID() << endl);
 
 1208     for (JDetector::iterator module = 
detector.begin(); module != 
detector.end(); ++module) {
 
 1217           print(cout, 
id, i->second);
 
 1220         if (!i->second.apply(module->
getPMT(
id.getPMTAddress()))) {
 
 1221           ERROR(
"No valid action: " << i->first << 
' ' << i->second << endl);
 
 1225       const auto range = ring.equal_range(module->
getID());
 
 1227       for (
auto i = range.
first; i != range.
second; ++i) {
 
 1231         modifier.
ring = (char) toupper(modifier.
ring);
 
 1233         if (modifier.
ring != 
'A') {
 
 1237           for (
size_t i = 0; i != module->size(); ++i) {
 
 1241             if (address.
ring == modifier.
ring) {
 
 1242               buffer[address] = (*module)[i];
 
 1246           for (
size_t i = 0; i != module->size(); ++i) {
 
 1250             if (address.
ring == modifier.
ring) {
 
 1254               while (position > 6) { position -= 6; }
 
 1255               while (position < 1) { position += 6; }
 
 1259               DEBUG(
"Module " << setw(10) << module->
getID() << 
' ' << address << 
" <= " << source << endl);
 
 1261               (*module)[i] = buffer[source];
 
Data structure for detector geometry and calibration.
 
int main(int argc, char **argv)
 
std::istream & operator>>(std::istream &in, JAANET::JHead &header)
Read header from input.
 
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.
 
double getT0() const
Get time offset.
 
const JCalibration & getCalibration() const
Get calibration.
 
void subT0(const double t0)
Subtract time offset.
 
void setCalibration(const JCalibration &cal)
Set calibration.
 
void setT0(const double t0)
Set time offset.
 
void addT0(const double t0)
Add time offset.
 
Lookup table for PMT addresses in detector.
 
const JModuleAddressMap & get(const int id) const
Get module address map.
 
Logical location of module.
 
int getFloor() const
Get floor number.
 
int getString() const
Get string number.
 
const JLocation & getLocation() const
Get location.
 
void setLocation(const JLocation &location)
Set location.
 
Lookup table for PMT addresses in optical module.
 
const JPMTAddressTranslator & getAddressTranslator(const int tdc) const
Get PMT address translator.
 
const JPMTPhysicalAddress & getPMTPhysicalAddress(const int tdc) const
Get PMT physical address.
 
Data structure for a composite optical module.
 
JModule & add(const JVector3D &pos)
Add position.
 
JModule & sub(const JVector3D &pos)
Subtract position.
 
const JPMT & getPMT(const int index) const
Get PMT.
 
JModule & set(const JVector3D &pos)
Set position.
 
void rotate(const JRotation3D &R)
Rotate 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 position in three dimensions.
 
const JPosition3D & getPosition() const
Get position.
 
Data structure for unit quaternion in three dimensions.
 
const JQuaternion3D & getQuaternion() const
Get quaternion.
 
void setQuaternion(const JQuaternion3D &quaternion)
Set quaternion.
 
JQuaternion3D getConjugate() const
Get conjugate of this quaternion.
 
JQuaternion3D & normalise()
Normalise quaternion.
 
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.
 
void setID(const int id)
Set identifier.
 
int getID() const
Get identifier.
 
Wrapper class around string.
 
Utility class to parse command line options.
 
JPosition3D getPosition(const Vec &pos)
Get position.
 
static const std::string string_t
string
 
std::ostream & print(std::ostream &out, const JTestSummary &summary, const char delimiter=' ', const bool useColors=true)
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.
 
static const JGetModuleStatusBit getModuleStatusBit
Function object to map key to module 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.
 
bool hasDetectorAddressMap(const int id)
Check if detector address map is available.
 
JDetectorAddressMap & getDetectorAddressMap()
Get detector address map.
 
JComparator< JResult_t T::*, JComparison::lt > make_comparator(JResult_t T::*member)
Helper method to create comparator between values of data member.
 
const array_type< JValue_t > & make_array(const JValue_t(&array)[N])
Method to create array of values.
 
std::iterator_traits< T >::value_type getAverage(T __begin, T __end)
Get average.
 
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
 
bool is_valid(const json &js)
Check validity of JSon data.
 
static const char WILDCARD
 
Type definition of range.
 
JRange_t()
Default constructor.
 
Auxiliary class for handling status.
 
int getStatus() const
Get status.
 
void setStatus(const JStatus &status)
Set status.
 
This class represents a rotation around the z-axis.
 
Empty structure for specification of parser element that is initialised (i.e. does not require input)...