CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_9_patch3/src/Fireworks/Core/src/FWL1TriggerTableView.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     Core
00004 // Class  :     FWL1TriggerTableView
00005 // 
00006 // Implementation:
00007 //     [Notes on implementation]
00008 //
00009 // Original Author:  
00010 //         Created:  Tue Jan 25 16:02:11 CET 2011
00011 // $Id: FWL1TriggerTableView.cc,v 1.19 2011/10/19 07:13:35 yana Exp $
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 void
00040 FWL1TriggerTableView::fillTable( fwlite::Event* event )
00041 {
00042    fwlite::Handle<L1GtTriggerMenuLite> triggerMenuLite;
00043    fwlite::Handle<L1GlobalTriggerReadoutRecord> triggerRecord;
00044 
00045    try
00046    {
00047       // FIXME: Replace magic strings with configurable ones
00048       triggerMenuLite.getByLabel( event->getRun(), "l1GtTriggerMenuLite", "", "" );
00049       triggerRecord.getByLabel( *event, "gtDigis", "", "" );
00050    }
00051    catch( cms::Exception& )
00052    {
00053       fwLog( fwlog::kWarning ) << "FWL1TriggerTableView: no L1Trigger menu is available." << std::endl;
00054       return;
00055    }
00056           
00057    if( triggerMenuLite.isValid() && triggerRecord.isValid() )
00058    {
00059      const L1GtTriggerMenuLite::L1TriggerMap& algorithmMap = triggerMenuLite->gtAlgorithmMap();
00060                                 
00061      int pfIndexTechTrig = -1;
00062      int pfIndexAlgoTrig = -1;
00063 
00064      boost::regex filter(m_regex.value());
00065 
00067      std::vector<std::vector<int> > prescaleFactorsAlgoTrig = triggerMenuLite->gtPrescaleFactorsAlgoTrig();
00068      std::vector<std::vector<int> > prescaleFactorsTechTrig = triggerMenuLite->gtPrescaleFactorsTechTrig();
00069      pfIndexAlgoTrig = ( triggerRecord->gtFdlWord()).gtPrescaleFactorIndexAlgo();
00070      pfIndexTechTrig = ( triggerRecord->gtFdlWord()).gtPrescaleFactorIndexTech();
00071 
00072      int pfIndexTechTrigValidSize = static_cast<int>(prescaleFactorsTechTrig.size());
00073      if( pfIndexTechTrigValidSize <=  pfIndexTechTrig )
00074        fwLog( fwlog::kError) << Form( "FWL1TriggerTableView: Can't get Technical Trigger pre-scale factors. Index [%d] larger that table size [%d]\n",
00075                                       pfIndexTechTrig, (int)prescaleFactorsTechTrig.size());
00076      int pfIndexAlgoTrigValidSize = static_cast<int>(prescaleFactorsAlgoTrig.size());
00077      if( pfIndexAlgoTrigValidSize <=  pfIndexAlgoTrig )
00078        fwLog( fwlog::kError) << Form( "FWL1TriggerTableView: Can't get L1 Algo pre-scale factors. Index [%d] larger that table size [%d]\n",
00079                                       pfIndexAlgoTrig, (int)prescaleFactorsAlgoTrig.size());
00080 
00081      const DecisionWord dWord = triggerRecord->decisionWord();
00082      for( L1GtTriggerMenuLite::CItL1Trig itTrig = algorithmMap.begin(), itTrigEnd = algorithmMap.end();
00083           itTrig != itTrigEnd; ++itTrig )
00084      {
00085        const unsigned int bitNumber = itTrig->first;
00086        const std::string& aName = itTrig->second;
00087        int errorCode = 0;
00088        const bool result = triggerMenuLite->gtTriggerResult( aName, dWord, errorCode );
00089 
00090        if ( !boost::regex_search(aName, filter) ) continue;
00091 
00092        m_columns.at(0).values.push_back( aName );
00093        m_columns.at(1).values.push_back( Form( "%d", result ));
00094        m_columns.at(2).values.push_back( Form( "%d", bitNumber ));
00095 
00096        if(( pfIndexAlgoTrig < pfIndexAlgoTrigValidSize )
00097           && static_cast<unsigned int>(prescaleFactorsAlgoTrig.at(pfIndexAlgoTrig).size()) > bitNumber )
00098        {         
00099          m_columns.at(3).values.push_back( Form( "%d", prescaleFactorsAlgoTrig.at( pfIndexAlgoTrig ).at( bitNumber )));
00100        }
00101        else
00102          m_columns.at(3).values.push_back( "invalid");
00103      }
00104      
00105      const static std::string kTechTriggerName = "TechTrigger";
00106      const TechnicalTriggerWord ttWord = triggerRecord->technicalTriggerWord();
00107 
00108      int tBitNumber = 0;
00109      int tBitResult = 0;
00110      if(boost::regex_search(kTechTriggerName, filter))
00111      {
00112        for( TechnicalTriggerWord::const_iterator tBitIt = ttWord.begin(), tBitEnd = ttWord.end(); 
00113             tBitIt != tBitEnd; ++tBitIt, ++tBitNumber )
00114        {
00115          if( *tBitIt )
00116            tBitResult = 1;
00117          else
00118            tBitResult = 0;
00119 
00120          m_columns.at(0).values.push_back( kTechTriggerName );
00121          m_columns.at(1).values.push_back( Form( "%d", tBitResult ));
00122          m_columns.at(2).values.push_back( Form( "%d", tBitNumber ));
00123 
00124          if (( pfIndexTechTrig < pfIndexTechTrigValidSize )
00125              && static_cast<int>(prescaleFactorsTechTrig.at(pfIndexTechTrig).size()) > tBitNumber )
00126          {            
00127            m_columns.at(3).values.push_back( Form( "%d", prescaleFactorsTechTrig.at( pfIndexTechTrig ).at( tBitNumber )));
00128          }          
00129          else
00130            m_columns.at(3).values.push_back( Form( "invalid" ));
00131        }
00132      }
00133    } // trigger valid
00134    else
00135    {
00136      m_columns.at(0).values.push_back( "No L1Trigger menu available." );
00137      m_columns.at(1).values.push_back( " " );
00138      m_columns.at(2).values.push_back( " " );
00139      m_columns.at(3).values.push_back( " " );
00140    }
00141 }