Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include <boost/regex.hpp>
00015 #include "Fireworks/Core/interface/FWL1TriggerTableView.h"
00016 #include "Fireworks/Core/interface/fwLog.h"
00017
00018 #include "DataFormats/FWLite/interface/Handle.h"
00019 #include "DataFormats/FWLite/interface/Event.h"
00020 #include "FWCore/Common/interface/TriggerNames.h"
00021 #include "DataFormats/Common/interface/TriggerResults.h"
00022 #include "FWCore/Utilities/interface/Exception.h"
00023
00024 #include "DataFormats/L1GlobalTrigger/interface/L1GtTriggerMenuLite.h"
00025 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
00026
00027
00028 FWL1TriggerTableView::FWL1TriggerTableView(TEveWindowSlot* iParent)
00029 : FWTriggerTableView(iParent, FWViewType::kTableL1)
00030 {
00031 m_columns[0].title = "Algorithm Name";
00032 m_columns.push_back( Column( "Result" ) );
00033 m_columns.push_back( Column( "Bit Number" ) );
00034 m_columns.push_back( Column( "Prescale" ) );
00035
00036 dataChanged();
00037 }
00038
00039
00040
00041 void FWL1TriggerTableView::fillTable(fwlite::Event* event)
00042 {
00043 fwlite::Handle<L1GtTriggerMenuLite> triggerMenuLite;
00044 fwlite::Handle<L1GlobalTriggerReadoutRecord> triggerRecord;
00045
00046 try
00047 {
00048
00049 triggerMenuLite.getByLabel( event->getRun(), "l1GtTriggerMenuLite", "", "" );
00050 triggerRecord.getByLabel( *event, "gtDigis", "", "" );
00051 }
00052 catch( cms::Exception& )
00053 {
00054 fwLog( fwlog::kWarning ) << "FWL1TriggerTableView: no L1Trigger menu is available." << std::endl;
00055 return;
00056 }
00057
00058 if( triggerMenuLite.isValid() && triggerRecord.isValid() )
00059 {
00060 const L1GtTriggerMenuLite::L1TriggerMap& algorithmMap = triggerMenuLite->gtAlgorithmMap();
00061
00062 int pfIndexTechTrig = -1;
00063 int pfIndexAlgoTrig = -1;
00064
00065 boost::regex filter(m_regex.value());
00066
00068 std::vector<std::vector<int> > prescaleFactorsAlgoTrig = triggerMenuLite->gtPrescaleFactorsAlgoTrig();
00069 std::vector<std::vector<int> > prescaleFactorsTechTrig = triggerMenuLite->gtPrescaleFactorsTechTrig();
00070 pfIndexAlgoTrig = ( triggerRecord->gtFdlWord()).gtPrescaleFactorIndexAlgo();
00071 pfIndexTechTrig = ( triggerRecord->gtFdlWord()).gtPrescaleFactorIndexTech();
00072
00073 int pfIndexTechTrigValidSize = static_cast<int>(prescaleFactorsAlgoTrig.size());
00074 if (pfIndexTechTrigValidSize <= pfIndexTechTrig)
00075 fwLog( fwlog::kError) << Form("FWL1TriggerTableView: Can't get pre-scale factors. Index [%d] larger that table size [%d]\n", pfIndexTechTrig, (int)prescaleFactorsAlgoTrig.size());
00076
00077 const DecisionWord dWord = triggerRecord->decisionWord();
00078 for( L1GtTriggerMenuLite::CItL1Trig itTrig = algorithmMap.begin(), itTrigEnd = algorithmMap.end();
00079 itTrig != itTrigEnd; ++itTrig )
00080 {
00081 const unsigned int bitNumber = itTrig->first;
00082 const std::string& aName = itTrig->second;
00083 int errorCode = 0;
00084 const bool result = triggerMenuLite->gtTriggerResult( aName, dWord, errorCode );
00085
00086 if ( !boost::regex_search(aName, filter) ) continue;
00087
00088 m_columns.at(0).values.push_back( aName );
00089 m_columns.at(1).values.push_back( Form( "%d", result ));
00090 m_columns.at(2).values.push_back( Form( "%d", bitNumber ));
00091
00092 if ( pfIndexTechTrig < pfIndexTechTrigValidSize && static_cast<unsigned int>(prescaleFactorsTechTrig.at(pfIndexTechTrig).size()) >bitNumber )
00093 {
00094 m_columns.at(3).values.push_back( Form( "%d", prescaleFactorsTechTrig.at( pfIndexTechTrig ).at( bitNumber )));
00095 }
00096 else
00097 m_columns.at(3).values.push_back( "invalid");
00098 }
00099
00100 const static std::string kTechTriggerName = "TechTrigger";
00101 const TechnicalTriggerWord ttWord = triggerRecord->technicalTriggerWord();
00102
00103 int tBitNumber = 0;
00104 int tBitResult = 0;
00105 if(boost::regex_search(kTechTriggerName, filter))
00106 {
00107 for( TechnicalTriggerWord::const_iterator tBitIt = ttWord.begin(), tBitEnd = ttWord.end();
00108 tBitIt != tBitEnd; ++tBitIt, ++tBitNumber )
00109 {
00110 if( *tBitIt )
00111 tBitResult = 1;
00112 else
00113 tBitResult = 0;
00114
00115 m_columns.at(0).values.push_back( kTechTriggerName );
00116 m_columns.at(1).values.push_back( Form( "%d", tBitResult ));
00117 m_columns.at(2).values.push_back( Form( "%d", tBitNumber ));
00118
00119 if ( pfIndexTechTrig < pfIndexTechTrigValidSize && static_cast<int>(prescaleFactorsTechTrig.at(pfIndexTechTrig).size()) > tBitNumber)
00120 m_columns.at(3).values.push_back( Form( "%d", prescaleFactorsTechTrig.at( pfIndexTechTrig ).at( tBitNumber )));
00121 else
00122 m_columns.at(3).values.push_back( Form( "invalid" ));
00123 }
00124 }
00125 }
00126 else
00127 {
00128 m_columns.at(0).values.push_back( "No L1Trigger menu available." );
00129 m_columns.at(1).values.push_back( " " );
00130 m_columns.at(2).values.push_back( " " );
00131 m_columns.at(3).values.push_back( " " );
00132 }
00133 }