Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:31:18

0001 #include "L1Trigger/L1TCommon/src/Setting.cc"
0002 #include "L1Trigger/L1TCommon/src/Mask.cc"
0003 #include "L1Trigger/L1TCommon/src/Tools.cc"
0004 #include "L1Trigger/L1TCommon/src/XmlConfigReader.cc"
0005 #include "L1Trigger/L1TCommon/src/TrigSystem.cc"
0006 
0007 #include <iostream>
0008 #include <fstream>
0009 
0010 #include <time.h>
0011 
0012 // To compile run these lines in your CMSSW_X_Y_Z/src/ :
0013 /*
0014 cmsenv
0015 eval "setenv `scram tool info xerces-c | sed -n -e 's/INCLUDE=/XERC_INC /gp'`"
0016 eval "setenv `scram tool info xerces-c | sed -n -e 's/LIBDIR=/XERC_LIB /gp'`"
0017 eval "setenv `scram tool info boost    | sed -n -e 's/INCLUDE=/BOOST_INC /gp'`"
0018 eval "setenv `scram tool info boost    | sed -n -e 's/LIBDIR=/BOOST_LIB /gp'`"
0019 g++ -g -std=c++11 -o test reademtf.cpp -I./ -I$CMSSW_BASE/src -I$CMSSW_RELEASE_BASE/src -I$XERC_INC -L$XERC_LIB -lxerces-c -I$BOOST_INC -L$BOOST_LIB -lboost_thread -lboost_signals -lboost_date_time -L$CMSSW_RELEASE_BASE/lib/$SCRAM_ARCH/ -lFWCoreMessageLogger -lCondFormatsL1TObjects
0020 */
0021 
0022 using namespace std;
0023 
0024 int main(int argc, char *argv[]){
0025 
0026     // read the input xml file into a string
0027     list<string> sequence;
0028     map<string,string> xmlPayload;
0029     for(int p=1; p<argc; p++){
0030 
0031         ifstream input( argv[p] );
0032         if( !input ){ cout << "Cannot open " << argv[p] << " file" << endl; return 0; }
0033         sequence.push_back( argv[p] );
0034 
0035         size_t nLinesRead=0;
0036 
0037         while( !input.eof() ){
0038             string tmp;
0039             getline( input, tmp, '\n' );
0040             xmlPayload[ argv[p] ].append( tmp );
0041             nLinesRead++;
0042         }
0043 
0044         cout << argv[p] << ": read " << nLinesRead << " lines" << endl;
0045         input.close();
0046     }
0047 
0048     // finally, push all payloads to the XML parser and construct the TrigSystem objects with each of those
0049     l1t::XmlConfigReader xmlRdr;
0050     l1t::TrigSystem trgSys;
0051 
0052 //    trgSys.addProcRole("processors", "processors");
0053 
0054     // HW settings should always go first
0055     for(auto &name : sequence){
0056         cout<<"Parsing "<<name<<endl;
0057         xmlRdr.readDOMFromString( xmlPayload[name] );
0058         xmlRdr.readRootElement  ( trgSys           );
0059     }
0060     trgSys.setConfigured();
0061 
0062     try {
0063 
0064         map<string, l1t::Setting> conf1 = trgSys.getSettings("EMTF+1");
0065         string tmp1 = conf1["control_firmware_version"].getValueAsStr();
0066         cout << "EMTF+1 control_firmware_version =" << tmp1 << endl;
0067 
0068         map<string, l1t::Setting> conf2 = trgSys.getSettings("EMTF-1");
0069         string tmp2 = conf2["control_firmware_version"].getValueAsStr();
0070         cout << "EMTF-1 control_firmware_version =" << tmp2 << endl;
0071 
0072         string core_fwv = conf2["core_firmware_version"].getValueAsStr();
0073         tm brokenTime;
0074         strptime(core_fwv.c_str(), "%Y-%m-%d %T", &brokenTime);
0075         time_t sinceEpoch = timegm(&brokenTime);
0076         cout << "core_fwv= " << core_fwv << " timestamp= " << sinceEpoch << endl;
0077 
0078         cout << "pT LUT version "<< conf2["pt_lut_version"].getValue<unsigned int>() << endl;
0079 
0080     } catch ( std::runtime_error &e ){
0081         cout << "Exception thrown: "<< e.what() << endl;
0082     }
0083 
0084     return 0;
0085 }
0086