Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007 #include <fstream>
00008
00009 #include "Alignment/CocoaUtilities/interface/GlobalOptionMgr.h"
00010 #include <iostream>
00011 #include <iomanip>
00012 #include "Alignment/CocoaUtilities/interface/ALIUtils.h"
00013 #include "Alignment/CocoaUtilities/interface/ALIFileIn.h"
00014 #include <cstdlib>
00015
00016 GlobalOptionMgr* GlobalOptionMgr::theInstance = 0;
00017
00018 GlobalOptionMgr* GlobalOptionMgr::getInstance()
00019 {
00020 if(!theInstance) {
00021 theInstance = new GlobalOptionMgr;
00022 }
00023
00024 return theInstance;
00025 }
00026
00027
00028
00029 void GlobalOptionMgr::setDefaultGlobalOptions()
00030 {
00031 theGlobalOptions[ ALIstring("report_verbose") ] = 3;
00032 theGlobalOptions[ ALIstring("debug_verbose") ] = 0;
00033
00034 theGlobalOptions[ ALIstring("saveMatrices") ] = 1;
00035
00036 theGlobalOptions[ ALIstring("calcul_type") ] = 0;
00037 theGlobalOptions[ ALIstring("length_value_dimension") ] = 0;
00038 theGlobalOptions[ ALIstring("length_error_dimension") ] = 0;
00039 theGlobalOptions[ ALIstring("angle_value_dimension") ] = 0;
00040 theGlobalOptions[ ALIstring("angle_error_dimension") ] = 0;
00041 theGlobalOptions[ ALIstring("output_length_value_dimension") ] = 0;
00042 theGlobalOptions[ ALIstring("output_length_error_dimension") ] = 0;
00043 theGlobalOptions[ ALIstring("output_angle_value_dimension") ] = 0;
00044 theGlobalOptions[ ALIstring("output_angle_error_dimension") ] = 0;
00045 theGlobalOptions[ ALIstring("checkExtraEntries") ] = 0;
00046 theGlobalOptions[ ALIstring("cms_link") ] = 0;
00047 theGlobalOptions[ ALIstring("cms_link_halfplanes") ] = 0;
00048 theGlobalOptions[ ALIstring("cms_link_method") ] = 0;
00049 theGlobalOptions[ ALIstring("range_studies") ] = 0;
00050 theGlobalOptions[ ALIstring("histograms") ] = 0;
00051 theGlobalOptions[ ALIstring("onlyDeriv") ] = 0;
00052 theGlobalOptions[ ALIstring("onlyFirstPropagation") ] = 0;
00053
00054 theGlobalOptions[ ALIstring("VisWriteVRML") ] = 0;
00055 theGlobalOptions[ ALIstring("VisWriteIguana") ] = 0;
00056 theGlobalOptions[ ALIstring("VisOnly") ] = 0;
00057 theGlobalOptions[ ALIstring("VisWriteOptONames") ] = 1;
00058 theGlobalOptions[ ALIstring("VisGlobalRotationX") ] = 0.;
00059 theGlobalOptions[ ALIstring("VisGlobalRotationY") ] = 0.;
00060 theGlobalOptions[ ALIstring("VisGlobalRotationZ") ] = 0.;
00061 theGlobalOptions[ ALIstring("VisScale") ] = 1.;
00062 theGlobalOptions[ ALIstring("tiltmeter_meas_value_dimension") ] = 0;
00063 theGlobalOptions[ ALIstring("distancemeter_meas_value_dimension") ] = 0;
00064 theGlobalOptions[ ALIstring("dumpDateInFittedEntries") ] = 0;
00065 theGlobalOptions[ ALIstring("measurementErrorFromFile") ] = 0;
00066
00067 theGlobalOptions[ ALIstring("maxNoFitIterations") ] = 50;
00068 theGlobalOptions[ ALIstring("fitQualityCut") ] = 0.1;
00069 theGlobalOptions[ ALIstring("relativeFitQualityCut") ] = 1.E-6;
00070
00071 theGlobalOptions[ ALIstring("maxEvents") ] = 1.E6;
00072
00073
00074 theGlobalOptions[ ALIstring("deviffValDimf") ] = 1.;
00075 theGlobalOptions[ ALIstring("deviffAngDimf") ] = 1.;
00076 theGlobalOptions[ ALIstring("rotateAroundLocal") ] = 1;
00077 theGlobalOptions[ ALIstring("reportOutEntriesByShortName") ] = 0;
00078 theGlobalOptions[ ALIstring("reportOutReadValue") ] = 1;
00079 theGlobalOptions[ ALIstring("reportOutReadSigma") ] = 1;
00080 theGlobalOptions[ ALIstring("reportOutReadQuality") ] = 1;
00081 theGlobalOptions[ ALIstring("maxDeviDerivative") ] = 1.E-6;
00082
00083 theGlobalOptions[ ALIstring("stopAfter1stIteration") ] = 0;
00084 theGlobalOptions[ ALIstring("calParamInyfMatrix") ] = 0;
00085 theGlobalOptions[ ALIstring("writeXML") ] = 0;
00086 theGlobalOptions[ ALIstring("dumpInAllFrames") ] = 0;
00087 theGlobalOptions[ ALIstring("rootResults") ] = 0;
00088 theGlobalOptions[ ALIstring("writeDBAlign") ] = 0;
00089 theGlobalOptions[ ALIstring("writeDBOptAlign") ] = 0;
00090 }
00091
00092
00093 ALIdouble GlobalOptionMgr::getGlobalOption( const ALIstring& sstr )
00094 {
00095 ALIdouble val = 0.;
00096
00097 std::map< ALIstring, ALIdouble, std::less<ALIstring> >::const_iterator msdcite = GlobalOptions().find( sstr );
00098
00099
00100 if( ALIUtils::debug >= 6) {
00101 std::cout << "Global Option " << (*msdcite).first << " = " << (*msdcite).second << std::endl;
00102 }
00103
00104 if ( msdcite == GlobalOptions().end() ) {
00105
00106 std::cerr << " !!! FATAL ERROR: trying to get the value of an unknown Global Option : " << sstr << std::endl;
00107 abort();
00108 } else {
00109
00110
00111
00112 val = (*msdcite).second;
00113 }
00114
00115 return val;
00116
00117 }
00118
00119
00120 ALIint GlobalOptionMgr::getGlobalOptionValue( const ALIstring& sstr, ALIdouble& val )
00121 {
00122
00123 std::map< ALIstring, ALIdouble, std::less<ALIstring> >::const_iterator msdcite = GlobalOptions().find( sstr );
00124
00125
00126 if( ALIUtils::debug >= 6) {
00127 std::cout << "Global Option " << (*msdcite).first << " = " << (*msdcite).second << std::endl;
00128 }
00129
00130 if ( msdcite == GlobalOptions().end() ) {
00131
00132 return 0;
00133 } else {
00134
00135
00136
00137 val = (*msdcite).second;
00138 return 1;
00139 }
00140
00141 }
00142
00143
00144
00145 void GlobalOptionMgr::setGlobalOption( const ALIstring gopt, const ALIdouble val, ALIFileIn& filein )
00146 {
00147
00148 if( !setGlobalOption( gopt, val, 0 ) ){
00149 filein.ErrorInLine();
00150 std::cerr << "!!! global option not found: " << gopt << std::endl;
00151 if ( ALIUtils::debug >= 3 ) {
00152 std::cout << "ALLOWED GLOBAL OPTIONS:" << std::endl;
00153 std::map< ALIstring, ALIdouble, std::less<ALIstring> >::iterator msdite;
00154 for ( msdite = theGlobalOptions.begin();
00155 msdite != theGlobalOptions.end(); msdite++) {
00156 std::cout << (*msdite).first.c_str() << std::endl;
00157 }
00158 }
00159 exit(2);
00160 }
00161
00162 }
00163
00164
00165 bool GlobalOptionMgr::setGlobalOption( const ALIstring gopt, const ALIdouble val, bool bExit )
00166 {
00167
00168 if ( GlobalOptions().find( gopt ) != GlobalOptions().end() ){
00169 theGlobalOptions[ gopt ] = val;
00170
00171 if( gopt == "report_verbose") {
00172 ALIUtils::setReportVerbosity( ALIint(val) );
00173 }
00174 if( gopt == "debug_verbose" ) {
00175 ALIUtils::setDebugVerbosity( ALIint(val) );
00176 }
00177
00178 return 1;
00179
00180 } else {
00181 if( bExit ) {
00182 std::cerr << "!!! global option not found: " << gopt << std::endl;
00183 exit(2);
00184 }
00185 return 0;
00186 }
00187
00188 }