Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "L1Trigger/L1TCommon/src/Parameter.cc"
0002 #include "L1Trigger/L1TCommon/src/Mask.cc"
0003 #include "L1Trigger/L1TCommon/src/XmlConfigParser.cc"
0004 #include "L1Trigger/L1TCommon/src/TriggerSystem.cc"
0005 
0006 #include <iostream>
0007 #include <fstream>
0008 #include <string>
0009 #include <list>
0010 #include <map>
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 readcalol1.cpp -I./ -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     if( argc < 3 ) return 0;
0026     // read the input xml files into a map of string
0027 
0028     list<string> sequence;
0029     map<string,string> xmlPayload;
0030     for(int p=1; p<argc; p++){
0031 
0032         ifstream input( argv[p] );
0033         if( !input ){ cout << "Cannot open " << argv[p] << " file" << endl; return 0; }
0034         sequence.push_back( argv[p] );
0035 
0036         size_t nLinesRead=0;
0037 
0038         while( !input.eof() ){
0039             string tmp;
0040             getline( input, tmp, '\n' );
0041             xmlPayload[ argv[p] ].append( tmp );
0042             nLinesRead++;
0043         }
0044 
0045         cout << argv[p] << ": read " << nLinesRead << " lines" << endl;
0046         input.close();
0047     }
0048 
0049     // parse the string using the XML reader
0050     XmlConfigParser xmlReader;
0051     l1t::TriggerSystem ts;
0052 
0053     cout << "Parsing " << sequence.front() << endl;
0054 if( false ){
0055     xmlReader.readDOMFromString( xmlPayload[sequence.front()] );
0056     xmlReader.readRootElement  ( ts, "calol1" );
0057 } else {
0058     ts.addProcessor("processor0", "processors","-1","-1");
0059     ts.addProcessor("processor1", "processors","-1","-2");
0060     ts.addProcessor("processor2", "processors","-1","-3");
0061     ts.addProcessor("processor3", "processors","-1","-4");
0062     ts.addProcessor("processor4", "processors","-1","-5");
0063     ts.addProcessor("processor5", "processors","-1","-6");
0064     ts.addProcessor("processor6", "processors","-1","-7");
0065     ts.addProcessor("processor7", "processors","-1","-8");
0066     ts.addProcessor("processor8", "processors","-1","-9");
0067     ts.addProcessor("processor9", "processors","-1","-10");
0068     ts.addProcessor("processor10", "processors","-1","-11");
0069     ts.addProcessor("processor11", "processors","-1","-12");
0070     ts.addProcessor("processor12", "processors","-1","-13");
0071     ts.addProcessor("processor13", "processors","-1","-14");
0072     ts.addProcessor("processor14", "processors","-1","-15");
0073     ts.addProcessor("processor15", "processors","-1","-16");
0074     ts.addProcessor("processor16", "processors","-1","-17");
0075     ts.addProcessor("processor17", "processors","-1","-18");
0076 
0077     ts.addProcessor("CTP7_Phi0", "processors","-2","-0");
0078     ts.addProcessor("CTP7_Phi1", "processors","-2","-1");
0079     ts.addProcessor("CTP7_Phi2", "processors","-2","-2");
0080     ts.addProcessor("CTP7_Phi3", "processors","-2","-3");
0081     ts.addProcessor("CTP7_Phi4", "processors","-2","-4");
0082     ts.addProcessor("CTP7_Phi5", "processors","-2","-5");
0083     ts.addProcessor("CTP7_Phi6", "processors","-2","-6");
0084     ts.addProcessor("CTP7_Phi7", "processors","-2","-7");
0085     ts.addProcessor("CTP7_Phi8", "processors","-2","-8");
0086     ts.addProcessor("CTP7_Phi9", "processors","-2","-9");
0087     ts.addProcessor("CTP7_Phi10","processors","-2","-10");
0088     ts.addProcessor("CTP7_Phi11","processors","-2","-11");
0089     ts.addProcessor("CTP7_Phi12","processors","-2","-12");
0090     ts.addProcessor("CTP7_Phi13","processors","-2","-13");
0091     ts.addProcessor("CTP7_Phi14","processors","-2","-14");
0092     ts.addProcessor("CTP7_Phi15","processors","-2","-15");
0093     ts.addProcessor("CTP7_Phi16","processors","-2","-16");
0094 }
0095 
0096     cout << "Parsing " << sequence.back() << endl;
0097     xmlReader.readDOMFromString( xmlPayload[sequence.back()] );
0098     xmlReader.readRootElement  ( ts, "calol1" );
0099 
0100     ts.setConfigured();
0101 
0102 //    for(auto &q : ts.getProcToRoleAssignment()) cout << q.first << " - " << q.second << endl;
0103 
0104     // feel free to play with the containers:
0105     map<string, l1t::Parameter> conf = ts.getParameters("CTP7_Phi15"); // use your context id here - Layer1Processor
0106 //    map<string, l1t::Mask>    rs   = ts.getMasks   ("processors"); // don't call a context that doesn't exist
0107 
0108     string layer1ECalScaleFactors= conf["layer1ECalScaleFactors"].getValueAsStr();
0109     string layer1HCalScaleFactors= conf["layer1HCalScaleFactors"].getValueAsStr();
0110     string layer1HFScaleFactors  = conf["layer1HFScaleFactors"].getValueAsStr();
0111     string layer1ECalScaleETBins = conf["layer1ECalScaleETBins"].getValueAsStr();
0112     string layer1HCalScaleETBins = conf["layer1HCalScaleETBins"].getValueAsStr();
0113     string layer1HFScaleETBins   = conf["layer1HFScaleETBins"].getValueAsStr();
0114 
0115     cout << "layer1ECalScaleFactors=" << layer1ECalScaleFactors << endl;
0116     cout << "layer1HCalScaleFactors=" << layer1HCalScaleFactors << endl;
0117     cout << "layer1HFScaleFactors  =" << layer1HFScaleFactors  << endl;
0118     cout << "layer1ECalScaleETBins =" << layer1ECalScaleETBins << endl;
0119     cout << "layer1HCalScaleETBins =" << layer1HCalScaleETBins << endl;
0120     cout << "layer1HFScaleETBins   =" << layer1HFScaleETBins   << endl;
0121 
0122     return 0;
0123 }
0124