Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JEditDetector.cc File Reference

Auxiliary program to modify detector calibration. More...

#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include "TRandom3.h"
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JDetector/JDetectorHeader.hh"
#include "JDetector/JModuleRouter.hh"
#include "JDetector/JPMTIdentifier.hh"
#include "JGeometry3D/JVector3D.hh"
#include "JTools/JConstants.hh"
#include "JLang/JException.hh"
#include "JSupport/JMeta.hh"
#include "Jeep/JeepToolkit.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Auxiliary program to modify detector calibration.

Syntax:

    -M "<module identifier> (set|add|sub|randset|randadd|randsub) x0 [x1 [x2]]"
    -S "<string identifier> (set|add|sub|randset|randadd|randsub) x0 [x1 [x2]]"
    -M "<module identifier> (rot|randrot) phi"
    -S "<string identifier> (rot|randrot) phi"
    -M "<module identifier> (mul|randmul) factor"
    -S "<string identifier> (mul|randmul) factor"
    -P "<PMT identifier>    (set|reset)   PMT_STATUS"
    -@ "<key>=<value>[;<key>=<value>"

Options -M and -S refer to a module and a string, respectively.
If module identifier or string identifier is -1, the action takes place on all modules or strings in the detector, respectively.
The number of values apply to position or time calibration in the following way:

  1. time calibration (t = x0)
  2. position calibration (x = x0, y = x1, z = 0)
  3. position calibration (x = x0, y = x1, z = x2)

The rotation is anti-clockwise around the z-axis.
The multiplication applies to the z-coordinates.

Note that the angles are defined in radians.
Option -@ refers to the header information.
The list of possible keys can be obtained using JPrintDetector.cc with option -O header.

Multiple options -M, -S or -@ will be processed in order of appearance.

Note that if the output file name is the same as the input file name, the original file will be overwritten.

Author
mdejong

Definition in file JEditDetector.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 360 of file JEditDetector.cc.

361 {
362  using namespace std;
363  using namespace JPP;
364 
365  string inputFile;
366  string outputFile;
367  vector<JModifier> mod;
368  vector<JModifier> str;
369  vector<string> hdr;
371  int debug;
372 
373  try {
374 
375  JParser<> zap("Auxiliary program to modify detector.");
376 
377  zap['a'] = make_field(inputFile);
378  zap['M'] = make_field(mod) = JPARSER::initialised();
379  zap['S'] = make_field(str) = JPARSER::initialised();
380  zap['@'] = make_field(hdr) = JPARSER::initialised();
381  zap['P'] = make_field(pmt) = JPARSER::initialised();
382  zap['o'] = make_field(outputFile);
383  zap['d'] = make_field(debug) = 2;
384 
385  zap(argc, argv);
386  }
387  catch(const exception &error) {
388  FATAL(error.what() << endl);
389  }
390 
392 
393  try {
394  load(inputFile, detector);
395  }
396  catch(const JException& error) {
397  FATAL(error);
398  }
399 
400 
401  gRandom->SetSeed(0);
402 
403 
404  detector.comment.add(JMeta(argc,argv));
405 
406 
407  if (!hdr.empty()) {
408 
409  JProperties helper = detector.getProperties();
410 
411  for (vector<string>::const_iterator i = hdr.begin(); i != hdr.end(); ++i) {
412 
413  istringstream is(*i);
414 
415  is >> helper;
416  }
417  }
418 
419 
420  for (vector<JModifier>::const_iterator i = mod.begin(); i != mod.end(); ++i) {
421 
422  for (JDetector::iterator module = detector.begin(); module != detector.end(); ++module) {
423 
424  if (module->getID() == i->id || i->id == JModifier::WILD_CARD ){
425 
426  DEBUG("Modifier" << ' '
427  << "(" << setw(3) << module->getString() << "," << setw(2) << module->getFloor() << ")" << ' '
428  << setw(8) << module->getID() << ' '
429  << "action" << ' ' << i->action << endl);
430 
431  if (!i->apply(*module)) {
432  ERROR("No valid action: " << *i << endl);
433  }
434  }
435  }
436  }
437 
438 
439  for (vector<JModifier>::const_iterator i = str.begin(); i != str.end(); ++i) {
440 
441  for (JDetector::iterator module = detector.begin(); module != detector.end(); ++module) {
442 
443  if (module->getString() == i->id || i->id == JModifier::WILD_CARD) {
444 
445  DEBUG("Modifier" << ' '
446  << "(" << setw(3) << module->getString() << "," << setw(2) << module->getFloor() << ")" << ' '
447  << setw(8) << module->getID() << ' '
448  << "action" << ' ' << i->action << endl);
449 
450  if (!i->apply(*module)) {
451  ERROR("No valid action: " << *i << endl);
452  }
453  }
454  }
455  }
456 
457 
458  for (vector<JPMTModifier>::const_iterator i = pmt.begin(); i != pmt.end(); ++i) {
459 
460  for (JDetector::iterator module = detector.begin(); module != detector.end(); ++module) {
461 
462  if (module->getID() == i->getModuleID() || i->getModuleID() == JModifier::WILD_CARD) {
463 
464  DEBUG("PMT modifier" << ' '
465  << "(" << setw(8) << module->getID() << "," << setw(2) << i->getPMTAddress() << ")" << ' '
466  << "action" << ' ' << i->action << ' '
467  << "value" << ' ' << i->value << endl);
468 
469  if (i->getPMTAddress() < 0 ||
470  i->getPMTAddress() >= getNumberOfPMTs(*module) ||
471  !i->apply(module->getPMT(i->getPMTAddress()))) {
472  ERROR("No valid action: " << *i << endl);
473  }
474  }
475  }
476  }
477 
478  try {
480  }
481  catch(const JException& error) {
482  FATAL(error);
483  }
484 }
Auxiliary class for ROOT I/O of application specific meta data.
Definition: JMeta.hh:71
Utility class to parse command line options.
Definition: JParser.hh:1410
General exception.
Definition: JException.hh:40
Detector data structure.
Definition: JDetector.hh:77
Utility class to parse parameter values.
Definition: JProperties.hh:484
int getNumberOfPMTs(const JModule &module)
Get number of PMTs.
Empty structure for specification of parser element that is initialised (i.e.
Definition: JParser.hh:64
string outputFile
Detector file.
Definition: JHead.hh:126
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1836
#define ERROR(A)
Definition: JMessage.hh:64
void load(const JString &file_name, JDetector &detector)
Load detector from input file.
int debug
debug level
Definition: JSirene.cc:59
#define FATAL(A)
Definition: JMessage.hh:65
static const char WILD_CARD
Definition: JDAQTags.hh:34
void store(const JString &file_name, const JDetector &detector)
Store detector to output file.
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:60