33 const char*
const X_t =
"x";
34 const char*
const Y_t =
"y";
35 const char*
const Z_t =
"z";
36 const char*
const PHI_t =
"phi";
37 const char*
const TX_t =
"ty";
38 const char*
const TY_t =
"tx";
206 const double sigma_m,
218 center.setPosition(
JPosition3D(center.getX(), center.getY(), 0.0));
231 if (this->hasModule(module.
getID()) && range(module.
getFloor())) {
262 const double tx =
model.tx;
263 const double tz = sqrt((1.0 + tx) * (1.0 - tx));
271 const double ty =
model.ty;
272 const double tz = sqrt((1.0 + ty) * (1.0 - ty));
305 const set<string> PARAMETERS = { X_t, Y_t, Z_t, PHI_t, TX_t, TY_t };
307 string detectorFile_a;
308 string detectorFile_b;
309 bool overwriteDetector;
319 JParser<> zap(
"Auxiliary program to align two detectors.");
321 zap[
'a'] =
make_field(detectorFile_a,
"detector - subject to alignment (option -A)");
322 zap[
'b'] =
make_field(detectorFile_b,
"detector - reference for alignment");
323 zap[
'A'] =
make_field(overwriteDetector,
"overwrite detector file provided through '-a' with modified positions.");
324 zap[
'T'] =
make_field(tripodFile,
"tripods") =
"";
326 zap[
'O'] =
make_field(option,
"keep strings vertical");
333 catch(
const exception &error) {
334 FATAL(error.what() << endl);
338 if (overwriteDetector) {
339 if (tripodFile ==
"") {
340 FATAL(
"No tripod file.");
344 for (
const auto& i : parameters) {
345 if (PARAMETERS.count(i) == 0) {
346 FATAL(
"Invalid fit paramater " << i <<
", possible values: " <<
JEEPZ() << PARAMETERS << endl);
354 load(detectorFile_a, detector_a);
361 load(detectorFile_b, detector_b);
368 const JFit_t fit(detector_b, sigma_m, option, range);
372 for (JDetector::const_iterator module = detector_a.begin(); module != detector_a.end(); ++module) {
373 if (fit.hasModule(module->
getID())) {
374 data.push_back(*module);
387 if (parameters.empty()) {
388 parameters = PARAMETERS;
391 if (parameters.count(X_t)) { simplex.
step.push_back(
JModel_t(0.01, 0.00, 0.00, 0.0, 0.0, 0.0)); }
392 if (parameters.count(Y_t)) { simplex.
step.push_back(
JModel_t(0.00, 0.01, 0.00, 0.0, 0.0, 0.0)); }
393 if (parameters.count(Z_t)) { simplex.
step.push_back(
JModel_t(0.00, 0.00, 0.01, 0.0, 0.0, 0.0)); }
394 if (parameters.count(PHI_t)) { simplex.
step.push_back(
JModel_t(0.00, 0.00, 0.00, 5.0e-4, 0.0, 0.0)); }
395 if (parameters.count(TX_t)) { simplex.
step.push_back(
JModel_t(0.00, 0.00, 0.00, 0.0, 1.0e-4, 0.0)); }
396 if (parameters.count(TY_t)) { simplex.
step.push_back(
JModel_t(0.00, 0.00, 0.00, 0.0, 0.0, 1.0e-4)); }
399 const double chi2 = simplex(fit, data.begin(), data.end());
402 cout <<
"chi2/NDF " <<
FIXED(7,3) << chi2 <<
'/' << (detector_a.size() - simplex.
step.size()) << endl;
404 cout <<
"model:" << endl;
406 cout <<
"x " <<
FIXED(7,3) << simplex.
value.x << endl;
407 cout <<
"y " <<
FIXED(7,3) << simplex.
value.y << endl;
408 cout <<
"z " <<
FIXED(7,3) << simplex.
value.z << endl;
409 cout <<
"phi " <<
FIXED(9,5) << simplex.
value.phi << endl;
410 cout <<
"Tx " <<
FIXED(9,5) << simplex.
value.tx << endl;
411 cout <<
"Ty " <<
FIXED(9,5) << simplex.
value.ty << endl;
414 if (overwriteDetector) {
416 NOTICE(
"Store alignment data on files " << detectorFile_a <<
" and " << tripodFile << endl);
420 for (JDetector::iterator module = detector_a.begin(); module != detector_a.end(); ++module) {
425 module->add(p2 - p1);
429 store(detectorFile_a, detector_a);
437 tripods.
load(tripodFile.c_str());
446 tripod->add(p2 -
p1);
449 tripods.
store(tripodFile.c_str());
int main(int argc, char **argv)
Data structure for detector geometry and calibration.
Base class for data structures with artithmetic capabilities.
General purpose messaging.
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
Auxiliary class to define a range between two values.
Data structure for tripod.
int getFloor() const
Get floor number.
Router for direct addressing of module data in detector data structure.
Data structure for a composite optical module.
Simple fit method based on Powell's algorithm, see reference: Numerical Recipes in C++,...
std::vector< JModel_t > step
Data structure for position in three dimensions.
JPosition3D & rotate(const JRotation3D &R)
Rotate.
const JPosition3D & getPosition() const
Get position.
double getDistanceSquared(const JVector3D &pos) const
Get squared of distance to point.
int getID() const
Get identifier.
Utility class to parse command line options.
const JUTMPosition & getUTMPosition() const
Get UTM position.
JPosition3D getPosition(const Vec &pos)
Get position.
const JModule & getModule(const JType< JDetector_t > type, const int id, const JLocation &location=JLocation())
Get module according given detector type.
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.
void model(JModel_t &value)
Auxiliary function to constrain model during fit.
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).
Auxiliary data structure for floating point format specification.
Type definition of range.
Auxiliary wrapper for I/O of container with optional comment (see JComment).
Auxiliary data structure for streaming of STL containers.
void store(const char *file_name) const
Store to output file.
void load(const char *file_name)
Load from input file.
Auxiliary base class for aritmetic operations of derived class types.
Empty structure for specification of parser element that is initialised (i.e. does not require input)...