Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:44:33

0001 //   COCOA class implementation file

0002 //Id:  GlobalOptionMgr.cc

0003 //CAT: ALIUtils

0004 //

0005 //   History: v1.0

0006 //   Pedro Arce

0007 #include <fstream>
0008 
0009 #include "Alignment/CocoaUtilities/interface/GlobalOptionMgr.h"
0010 #include <iostream>
0011 #include <iomanip>
0012 #include "Alignment/CocoaUtilities/interface/ALIUtils.h"
0013 #include "Alignment/CocoaUtilities/interface/ALIFileIn.h"
0014 #include <cstdlib>
0015 
0016 GlobalOptionMgr* GlobalOptionMgr::theInstance = nullptr;
0017 
0018 GlobalOptionMgr* GlobalOptionMgr::getInstance() {
0019   if (!theInstance) {
0020     theInstance = new GlobalOptionMgr;
0021   }
0022 
0023   return theInstance;
0024 }
0025 
0026 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

0027 void GlobalOptionMgr::setDefaultGlobalOptions() {
0028   theGlobalOptions[ALIstring("report_verbose")] = 3;
0029   theGlobalOptions[ALIstring("debug_verbose")] = 0;
0030   //  theGlobalOptions[ ALIstring("sparse") ] = 0;

0031   theGlobalOptions[ALIstring("saveMatrices")] = 1;
0032   //  theGlobalOptions[ ALIstring("external_meas") ] = 0;

0033   theGlobalOptions[ALIstring("calcul_type")] = 0;
0034   theGlobalOptions[ALIstring("length_value_dimension")] = 0;
0035   theGlobalOptions[ALIstring("length_error_dimension")] = 0;
0036   theGlobalOptions[ALIstring("angle_value_dimension")] = 0;
0037   theGlobalOptions[ALIstring("angle_error_dimension")] = 0;
0038   theGlobalOptions[ALIstring("output_length_value_dimension")] = 0;
0039   theGlobalOptions[ALIstring("output_length_error_dimension")] = 0;
0040   theGlobalOptions[ALIstring("output_angle_value_dimension")] = 0;
0041   theGlobalOptions[ALIstring("output_angle_error_dimension")] = 0;
0042   theGlobalOptions[ALIstring("checkExtraEntries")] = 0;
0043   theGlobalOptions[ALIstring("cms_link")] = 0;
0044   theGlobalOptions[ALIstring("cms_link_halfplanes")] = 0;
0045   theGlobalOptions[ALIstring("cms_link_method")] = 0;
0046   theGlobalOptions[ALIstring("range_studies")] = 0;
0047   theGlobalOptions[ALIstring("histograms")] = 0;
0048   theGlobalOptions[ALIstring("onlyDeriv")] = 0;
0049   theGlobalOptions[ALIstring("onlyFirstPropagation")] = 0;
0050 
0051   theGlobalOptions[ALIstring("VisWriteVRML")] = 0;
0052   theGlobalOptions[ALIstring("VisWriteIguana")] = 0;
0053   theGlobalOptions[ALIstring("VisOnly")] = 0;
0054   theGlobalOptions[ALIstring("VisWriteOptONames")] = 1;
0055   theGlobalOptions[ALIstring("VisGlobalRotationX")] = 0.;
0056   theGlobalOptions[ALIstring("VisGlobalRotationY")] = 0.;
0057   theGlobalOptions[ALIstring("VisGlobalRotationZ")] = 0.;
0058   theGlobalOptions[ALIstring("VisScale")] = 1.;
0059   theGlobalOptions[ALIstring("tiltmeter_meas_value_dimension")] = 0;
0060   theGlobalOptions[ALIstring("distancemeter_meas_value_dimension")] = 0;
0061   theGlobalOptions[ALIstring("dumpDateInFittedEntries")] = 0;
0062   theGlobalOptions[ALIstring("measurementErrorFromFile")] = 0;
0063 
0064   theGlobalOptions[ALIstring("maxNoFitIterations")] = 50;
0065   theGlobalOptions[ALIstring("fitQualityCut")] = 0.1;
0066   theGlobalOptions[ALIstring("relativeFitQualityCut")] = 1.E-6;
0067 
0068   theGlobalOptions[ALIstring("maxEvents")] = 1.E6;
0069 
0070   //dimension factor to multiply the values in the files that give you the deviatin when traversing an ALMY. Files have numbers in microns, so it has to be 1 if 'length_value_dimension 2', 0.001 if 'length_value_dimension 1' (the same for angles)

0071   theGlobalOptions[ALIstring("deviffValDimf")] = 1.;
0072   theGlobalOptions[ALIstring("deviffAngDimf")] = 1.;
0073   theGlobalOptions[ALIstring("rotateAroundLocal")] = 1;
0074   theGlobalOptions[ALIstring("reportOutEntriesByShortName")] = 0;
0075   theGlobalOptions[ALIstring("reportOutReadValue")] = 1;
0076   theGlobalOptions[ALIstring("reportOutReadSigma")] = 1;
0077   theGlobalOptions[ALIstring("reportOutReadQuality")] = 1;
0078   theGlobalOptions[ALIstring("maxDeviDerivative")] = 1.E-6;
0079 
0080   theGlobalOptions[ALIstring("stopAfter1stIteration")] = 0;
0081   theGlobalOptions[ALIstring("calParamInyfMatrix")] = 0;
0082   theGlobalOptions[ALIstring("writeXML")] = 1;
0083   theGlobalOptions[ALIstring("dumpInAllFrames")] = 0;
0084   theGlobalOptions[ALIstring("rootResults")] = 0;
0085   theGlobalOptions[ALIstring("writeDBAlign")] = 0;
0086   theGlobalOptions[ALIstring("writeDBOptAlign")] = 0;
0087 }
0088 
0089 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

0090 ALIdouble GlobalOptionMgr::getGlobalOption(const ALIstring& sstr) {
0091   ALIdouble val = 0.;
0092   //---------- Find Global Option by name

0093   std::map<ALIstring, ALIdouble, std::less<ALIstring> >::const_iterator msdcite = GlobalOptions().find(sstr);
0094 
0095   //---------- Dump Global Option found

0096   if (ALIUtils::debug >= 6) {
0097     std::cout << "Global Option " << (*msdcite).first << " = " << (*msdcite).second << std::endl;
0098   }
0099 
0100   if (msdcite == GlobalOptions().end()) {
0101     //---------- return 0 if GLobal Option not found

0102     std::cerr << " !!! FATAL ERROR: trying to get the value of an unknown Global Option : " << sstr << std::endl;
0103     abort();
0104   } else {
0105     //---------- return 1 if Global Option found

0106     //-std::cout << "SSparam" << (*msdcite).first << (*msdcite).second << "len" << OptOList().size() << std::endl;

0107     //----- set val to Global Option value

0108     val = (*msdcite).second;
0109   }
0110 
0111   return val;
0112 }
0113 
0114 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

0115 ALIint GlobalOptionMgr::getGlobalOptionValue(const ALIstring& sstr, ALIdouble& val) {
0116   //---------- Find Global Option by name

0117   std::map<ALIstring, ALIdouble, std::less<ALIstring> >::const_iterator msdcite = GlobalOptions().find(sstr);
0118 
0119   //---------- Dump Global Option found

0120   if (ALIUtils::debug >= 6) {
0121     std::cout << "Global Option " << (*msdcite).first << " = " << (*msdcite).second << std::endl;
0122   }
0123 
0124   if (msdcite == GlobalOptions().end()) {
0125     //---------- return 0 if GLobal Option not found

0126     return 0;
0127   } else {
0128     //---------- return 1 if Global Option found

0129     //-std::cout << "SSparam" << (*msdcite).first << (*msdcite).second << "len" << OptOList().size() << std::endl;

0130     //----- set val to Global Option value

0131     val = (*msdcite).second;
0132     return 1;
0133   }
0134 }
0135 
0136 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

0137 void GlobalOptionMgr::setGlobalOption(const ALIstring gopt, const ALIdouble val, ALIFileIn& filein) {
0138   if (!setGlobalOption(gopt, val, false)) {
0139     filein.ErrorInLine();
0140     std::cerr << "!!! global option not found: " << gopt << std::endl;
0141     if (ALIUtils::debug >= 3) {
0142       std::cout << "ALLOWED GLOBAL OPTIONS:" << std::endl;
0143       std::map<ALIstring, ALIdouble, std::less<ALIstring> >::iterator msdite;
0144       for (msdite = theGlobalOptions.begin(); msdite != theGlobalOptions.end(); ++msdite) {
0145         std::cout << (*msdite).first.c_str() << std::endl;
0146       }
0147     }
0148     exit(2);
0149   }
0150 }
0151 
0152 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

0153 bool GlobalOptionMgr::setGlobalOption(const ALIstring gopt, const ALIdouble val, bool bExit) {
0154   //----- If global option exists: set it to value read

0155   if (GlobalOptions().find(gopt) != GlobalOptions().end()) {
0156     theGlobalOptions[gopt] = val;
0157     //------ Verbosity global options change static data

0158     if (gopt == "report_verbose") {
0159       ALIUtils::setReportVerbosity(ALIint(val));
0160     }
0161     if (gopt == "debug_verbose") {
0162       ALIUtils::setDebugVerbosity(ALIint(val));
0163     }
0164 
0165     return true;
0166     //----- if global option does not exist: error

0167   } else {
0168     if (bExit) {
0169       std::cerr << "!!! global option not found: " << gopt << std::endl;
0170       exit(2);
0171     }
0172     return false;
0173   }
0174 }