CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

L1GtUtils::LogicalExpressionL1Results Class Reference

#include <L1GtUtils.h>

List of all members.

Public Member Functions

const std::vector< std::pair
< std::string, bool > > & 
decisionsAfterMask ()
const std::vector< std::pair
< std::string, bool > > & 
decisionsBeforeMask ()
const std::vector< std::pair
< std::string, int > > & 
errorCodes (const edm::Event &)
const std::vector
< L1GtLogicParser::OperandToken > & 
expL1Triggers ()
 list of triggers in the logical expression, trigger decisions, prescale factors and masks, error codes
bool isValid ()
 return true if the logical expression is syntactically correct
 LogicalExpressionL1Results (const std::string &, L1GtUtils &, const edm::InputTag &, const edm::InputTag &)
 LogicalExpressionL1Results (const std::string &, L1GtUtils &)
 constructor(s)
const int logicalExpressionRunUpdate (const edm::Run &, const edm::EventSetup &, const std::string &)
const int logicalExpressionRunUpdate (const edm::Run &, const edm::EventSetup &)
 keep the logical expression given in the previous run
const std::vector< std::pair
< std::string, int > > & 
prescaleFactors ()
const std::vector< std::pair
< std::string, int > > & 
triggerMasks ()
 ~LogicalExpressionL1Results ()
 destructor

Private Member Functions

bool initialize ()
void l1Results (const edm::Event &iEvent, const edm::InputTag &l1GtRecordInputTag, const edm::InputTag &l1GtReadoutRecordInputTag)
void reset (std::vector< std::pair< std::string, int > >) const
void reset (std::vector< std::pair< std::string, bool > >) const
 reset for each L1 trigger the value from pair.second

Private Attributes

std::vector< std::pair
< std::string, bool > > 
m_decisionsAfterMask
std::vector< std::pair
< std::string, bool > > 
m_decisionsBeforeMask
std::vector< std::pair
< std::string, int > > 
m_errorCodes
bool m_expBitsTechTrigger
 flag true, if the logical expression is built from technical trigger bits
std::vector
< L1GtLogicParser::OperandToken
m_expL1Triggers
size_t m_expL1TriggersSize
std::vector
< L1GtUtils::TriggerCategory
m_expTriggerCategory
 trigger category for each L1 trigger in the logical expression
std::vector< bool > m_expTriggerInMenu
int m_l1ConfCode
 code for L1 trigger configuration
bool m_l1GtInputTagsFromProv
edm::InputTag m_l1GtReadoutRecordInputTag
edm::InputTag m_l1GtRecordInputTag
L1GtUtilsm_l1GtUtils
bool m_l1ResultsAlreadyCalled
 set to true if the method l1Results was called once
std::string m_logicalExpression
 private members as input parameters
std::vector< std::pair
< std::string, int > > 
m_prescaleFactors
std::vector< std::pair
< std::string, int > > 
m_triggerMasks
bool m_validL1Configuration
 true if valid L1 configuration - if not, reset all quantities and return
bool m_validLogicalExpression
 true if the logical expression uses accepted L1GtLogicParser operators

Detailed Description

Definition at line 79 of file L1GtUtils.h.


Constructor & Destructor Documentation

L1GtUtils::LogicalExpressionL1Results::LogicalExpressionL1Results ( const std::string &  expression,
L1GtUtils l1GtUtils 
) [explicit]

constructor(s)

trigger decisions, prescale factors and masks from GT record(s) with input tag(s) from provenance

Definition at line 2422 of file L1GtUtils.cc.

References initialize().

L1GtUtils::LogicalExpressionL1Results::LogicalExpressionL1Results ( const std::string &  expression,
L1GtUtils l1GtUtils,
const edm::InputTag l1GtRecordInputTag,
const edm::InputTag l1GtReadoutRecordInputTag 
) [explicit]

trigger decisions, prescale factors and masks from GT record(s) with input tag(s) explicitly given

Definition at line 2450 of file L1GtUtils.cc.

References initialize().

L1GtUtils::LogicalExpressionL1Results::~LogicalExpressionL1Results ( )

destructor

Definition at line 2481 of file L1GtUtils.cc.

                                                                 {

    // empty

}

Member Function Documentation

const std::vector< std::pair< std::string, bool > > & L1GtUtils::LogicalExpressionL1Results::decisionsAfterMask ( )

Definition at line 2710 of file L1GtUtils.cc.

References Exception.

Referenced by L1GtAnalyzer::analyzeL1GtUtilsCore().

                                                                                                    {

    // throw an exception if the result is not computed once per event - user usage error
    if (!m_l1ResultsAlreadyCalled) {
        throw cms::Exception("FailModule") << "\nUsage error: "
                << "\n  Method 'errorCodes' must be called in the event loop before attempting to use this method.\n"
                << std::endl;
    }

    return m_decisionsAfterMask;

}
const std::vector< std::pair< std::string, bool > > & L1GtUtils::LogicalExpressionL1Results::decisionsBeforeMask ( )

Definition at line 2697 of file L1GtUtils.cc.

References Exception.

Referenced by L1GtAnalyzer::analyzeL1GtUtilsCore().

                                                                                                     {

    // throw an exception if the result is not computed once per event - user usage error
    if (!m_l1ResultsAlreadyCalled) {
        throw cms::Exception("FailModule") << "\nUsage error: "
                << "\n  Method 'errorCodes' must be called in the event loop before attempting to use this method.\n"
                << std::endl;
    }

    return m_decisionsBeforeMask;

}
const std::vector< std::pair< std::string, int > > & L1GtUtils::LogicalExpressionL1Results::errorCodes ( const edm::Event iEvent)
const std::vector<L1GtLogicParser::OperandToken>& L1GtUtils::LogicalExpressionL1Results::expL1Triggers ( ) [inline]

list of triggers in the logical expression, trigger decisions, prescale factors and masks, error codes

Definition at line 114 of file L1GtUtils.h.

References m_expL1Triggers.

Referenced by L1GtAnalyzer::analyzeL1GtUtilsCore().

                                                                             {
            return m_expL1Triggers;
        }
bool L1GtUtils::LogicalExpressionL1Results::initialize ( ) [private]

parse the logical expression, initialize the private members to required size such that one can just reset them

Definition at line 2487 of file L1GtUtils.cc.

References L1GtUtils::AlgorithmTrigger, cms::Exception::explainSelf(), cmsPerfPublish::fail(), first, LogDebug, LogTrace, L1GtLogicParser::operandTokenVector(), edm::second(), and cms::Exception::what().

Referenced by LogicalExpressionL1Results().

                                                     {

    // get the vector of triggers corresponding to the logical expression
    // check also the logical expression - add/remove spaces if needed

    try {

        L1GtLogicParser m_l1AlgoLogicParser = L1GtLogicParser(
                m_logicalExpression);

        // list of L1 triggers from the logical expression
        m_expL1Triggers = m_l1AlgoLogicParser.operandTokenVector();
        m_expL1TriggersSize = m_expL1Triggers.size();

        m_validLogicalExpression = true;

    } catch (cms::Exception & ex) {
        m_validLogicalExpression = false;

        edm::LogWarning("L1GtUtils") << ex;
        edm::LogWarning("L1GtUtils") << ex.what();
        edm::LogWarning("L1GtUtils") << ex.explainSelf();
    }

    // try to convert the string representing each L1 trigger to bit number,
    //   to check if the logical expression is constructed from bit numbers
    // trade-off: cache it here, irrespective of the expression
    //   when the conversion fails (normally for the first seed, 
    //   if not expression of technical trigger bits), stop and 
    //   set m_expBitsTechTrigger to false

    m_expBitsTechTrigger = true;

    for (size_t iTrig = 0; iTrig < m_expL1TriggersSize; ++iTrig) {
        const std::string& bitString = (m_expL1Triggers[iTrig]).tokenName;
        std::istringstream bitStream(bitString);
        int bitInt;

        if ((bitStream >> bitInt).fail()) {

            m_expBitsTechTrigger = false;

            break;
        }

        (m_expL1Triggers[iTrig]).tokenNumber = bitInt;

    }

    // resize and fill 
    m_decisionsBeforeMask.resize(m_expL1TriggersSize);
    m_decisionsAfterMask.resize(m_expL1TriggersSize);
    m_prescaleFactors.resize(m_expL1TriggersSize);
    m_triggerMasks.resize(m_expL1TriggersSize);
    m_errorCodes.resize(m_expL1TriggersSize);
    m_expTriggerCategory.resize(m_expL1TriggersSize);
    m_expTriggerInMenu.resize(m_expL1TriggersSize);

    LogDebug("L1GtUtils") << std::endl;
    LogTrace("L1GtUtils") << "\nLogical expression\n  " << m_logicalExpression
            << "\n has " << m_expL1TriggersSize << " L1 triggers" << std::endl;
    for (size_t iTrig = 0; iTrig < m_expL1TriggersSize; ++iTrig) {

        const std::string& trigNameOrAlias = (m_expL1Triggers[iTrig]).tokenName;
        LogTrace("L1GtUtils") << "  " << trigNameOrAlias << std::endl;

        (m_decisionsBeforeMask[iTrig]).first = trigNameOrAlias;
        (m_decisionsBeforeMask[iTrig]).second = false;

        (m_decisionsAfterMask[iTrig]).first = trigNameOrAlias;
        (m_decisionsAfterMask[iTrig]).second = false;

        (m_prescaleFactors[iTrig]).first = trigNameOrAlias;
        (m_prescaleFactors[iTrig]).second = -1;

        (m_triggerMasks[iTrig]).first = trigNameOrAlias;
        (m_triggerMasks[iTrig]).second = -1;

        (m_errorCodes[iTrig]).first = trigNameOrAlias;
        (m_errorCodes[iTrig]).second = -1;

        m_expTriggerCategory[iTrig] = L1GtUtils::AlgorithmTrigger;

        m_expTriggerInMenu[iTrig] = false;

    }
    LogTrace("L1GtUtils") << std::endl;

    return true;

}
bool L1GtUtils::LogicalExpressionL1Results::isValid ( void  ) [inline]

return true if the logical expression is syntactically correct

Definition at line 99 of file L1GtUtils.h.

References m_validLogicalExpression.

Referenced by L1GtAnalyzer::beginRun().

void L1GtUtils::LogicalExpressionL1Results::l1Results ( const edm::Event iEvent,
const edm::InputTag l1GtRecordInputTag,
const edm::InputTag l1GtReadoutRecordInputTag 
) [private]

Definition at line 2799 of file L1GtUtils.cc.

References LogDebug, LogTrace, reset(), and edm::second().

                                                      {

    // reset the vectors before filling them
    reset(m_decisionsBeforeMask);
    reset(m_decisionsAfterMask);
    reset(m_prescaleFactors);
    reset(m_triggerMasks);
    reset(m_errorCodes);

    // initialization of actual values for each trigger
    bool decisionBeforeMaskValue = false;
    bool decisionAfterMaskValue = false;
    int prescaleFactorValue = -1;
    int triggerMaskValue = -1;
    int errorCode = -1;

    LogDebug("L1GtUtils") << std::endl;
    LogTrace("L1GtUtils") << "\nLogical expression\n  " << m_logicalExpression
            << std::endl;

    // for each trigger, if it is in the L1 menu, get the prescale factor and trigger mask

    for (size_t iTrig = 0; iTrig < m_expL1TriggersSize; ++iTrig) {

        const std::string& trigNameOrAlias = (m_expL1Triggers[iTrig]).tokenName;

        if (m_expTriggerInMenu[iTrig]) {
            errorCode = m_l1GtUtils.l1Results(iEvent, l1GtRecordInputTag,
                    l1GtReadoutRecordInputTag, trigNameOrAlias,
                    decisionBeforeMaskValue, decisionAfterMaskValue,
                    prescaleFactorValue, triggerMaskValue);

            if (errorCode != 0) {

                // error while retrieving the results
                //    for this trigger: set prescale factor to -1, trigger mask to -1

                decisionBeforeMaskValue = false;
                decisionAfterMaskValue = false;
                prescaleFactorValue = -1;
                triggerMaskValue = -1;

            }

        } else {
            // no trigger name or trigger alias in the menu, no bits: 
            //    for this trigger: set prescale factor to -1, set the error code

            decisionBeforeMaskValue = false;
            decisionAfterMaskValue = false;
            prescaleFactorValue = -1;
            triggerMaskValue = -1;
            errorCode = m_l1ConfCode + 1;

        }

        LogTrace("L1GtUtils") << "\n" << trigNameOrAlias << ":" << std::endl;

        (m_decisionsBeforeMask[iTrig]).second = decisionBeforeMaskValue;
        LogTrace("L1GtUtils") << "    decision before mask = "
                << decisionBeforeMaskValue << std::endl;

        (m_decisionsAfterMask[iTrig]).second = decisionAfterMaskValue;
        LogTrace("L1GtUtils") << "    decision after mask  = "
                << decisionAfterMaskValue << std::endl;

        (m_prescaleFactors[iTrig]).second = prescaleFactorValue;
        LogTrace("L1GtUtils") << "    prescale factor      = "
                << prescaleFactorValue << std::endl;

        (m_triggerMasks[iTrig]).second = triggerMaskValue;
        LogTrace("L1GtUtils") << "    trigger mask         = "
                << triggerMaskValue << std::endl;

        (m_errorCodes[iTrig]).second = errorCode;
        LogTrace("L1GtUtils") << "    error code           = " << errorCode
                << std::endl;

    }

    LogDebug("L1GtUtils") << std::endl;

}
const int L1GtUtils::LogicalExpressionL1Results::logicalExpressionRunUpdate ( const edm::Run iRun,
const edm::EventSetup evSetup,
const std::string &  logicExpression 
)

update quantities related to the logical expression at the beginning of the run new logical expression, replacing the logical expression given the in previous run

Definition at line 2580 of file L1GtUtils.cc.

Referenced by L1GtAnalyzer::beginRun().

                                          {

    // initialize error code
    int errorCode = 0;

    // logical expression has changed - one must re-initialize all quantities related to the logical expression
    // and clear the vectors

    m_logicalExpression = logicExpression;
    m_validLogicalExpression = false;

    m_l1ResultsAlreadyCalled = false;

    m_expL1TriggersSize = 0;
    m_expBitsTechTrigger = false;
    
    // 
    m_decisionsBeforeMask.clear();
    m_decisionsAfterMask.clear();
    m_prescaleFactors.clear();
    m_triggerMasks.clear();
    m_errorCodes.clear();
    m_expTriggerCategory.clear();
    m_expTriggerInMenu.clear();


    initialize();

    //
    errorCode = logicalExpressionRunUpdate(iRun, evSetup);

    return errorCode;

}
const int L1GtUtils::LogicalExpressionL1Results::logicalExpressionRunUpdate ( const edm::Run iRun,
const edm::EventSetup evSetup 
)

keep the logical expression given in the previous run

Definition at line 2618 of file L1GtUtils.cc.

References L1GtUtils::AlgorithmTrigger, first, and L1GtUtils::TechnicalTrigger.

                                                          {

    // check first that a valid L1 configuration was retrieved, 
    // to prevent also calls before the L1 configuration retrieval

    // initialize error code and L1 configuration code
    int errorCode = 0;
    int l1ConfCode = 0;

    if (!(m_l1GtUtils.availableL1Configuration(errorCode, l1ConfCode))) {

        m_validL1Configuration = false;
        return errorCode;
    } else {

        m_validL1Configuration = true;
        m_l1ConfCode = l1ConfCode;
    }

    // check if the trigger (name of alias) from the logical expression are in the menu, 
    // if names are used, set tokenNumber to the corresponding bit number
    // if technical trigger bits, set tokenName to the corresponding technical trigger name, if 
    //   a technical trigger exists on that bit
    // for each trigger, set also the trigger category

    // initialization 
    L1GtUtils::TriggerCategory trigCategory = L1GtUtils::AlgorithmTrigger;
    int bitNumber = -1;

    for (size_t iTrig = 0; iTrig < m_expL1TriggersSize; ++iTrig) {

        trigCategory = L1GtUtils::AlgorithmTrigger;
        bitNumber = -1;
        const std::string& trigNameOrAlias = (m_expL1Triggers[iTrig]).tokenName;

        if (!m_expBitsTechTrigger) {
            const bool triggerInMenu = m_l1GtUtils.l1AlgoTechTrigBitNumber(
                    trigNameOrAlias, trigCategory, bitNumber);

            (m_expL1Triggers[iTrig]).tokenNumber = bitNumber;
            m_expTriggerCategory[iTrig] = trigCategory;
            m_expTriggerInMenu[iTrig] = triggerInMenu;

        } else {

            std::string aliasL1Trigger;
            std::string nameL1Trigger;

            trigCategory = L1GtUtils::TechnicalTrigger;
            bitNumber = (m_expL1Triggers[iTrig]).tokenNumber;

            const bool triggerInMenu = m_l1GtUtils.l1TriggerNameFromBit(
                    bitNumber, trigCategory, aliasL1Trigger, nameL1Trigger);

            if (!triggerInMenu) {
                aliasL1Trigger = "Technical_trigger_bit_"
                        + (m_expL1Triggers[iTrig]).tokenName + "_empty";
            }

            (m_expL1Triggers[iTrig]).tokenName = aliasL1Trigger;
            m_expTriggerCategory[iTrig] = trigCategory;
            m_expTriggerInMenu[iTrig] = triggerInMenu;

            // put the names of the technical triggers in the returned quantities

            (m_decisionsBeforeMask[iTrig]).first = aliasL1Trigger;
            (m_decisionsAfterMask[iTrig]).first = aliasL1Trigger;
            (m_prescaleFactors[iTrig]).first = aliasL1Trigger;
            (m_triggerMasks[iTrig]).first = aliasL1Trigger;
            (m_errorCodes[iTrig]).first = aliasL1Trigger;

        }
    }

    return errorCode;

}
const std::vector< std::pair< std::string, int > > & L1GtUtils::LogicalExpressionL1Results::prescaleFactors ( )

Definition at line 2723 of file L1GtUtils.cc.

References Exception.

Referenced by L1GtAnalyzer::analyzeL1GtUtilsCore().

                                                                                                {

    // throw an exception if the result is not computed once per event - user usage error
    if (!m_l1ResultsAlreadyCalled) {
        throw cms::Exception("FailModule") << "\nUsage error: "
                << "\n  Method 'errorCodes' must be called in the event loop before attempting to use this method.\n"
                << std::endl;
    }

    return m_prescaleFactors;

}
void L1GtUtils::LogicalExpressionL1Results::reset ( std::vector< std::pair< std::string, int > >  pairVector) const [private]

Definition at line 2791 of file L1GtUtils.cc.

References edm::second().

                                                              {

    for (size_t iTrig = 0; iTrig < m_expL1TriggersSize; ++iTrig) {
        (pairVector[iTrig]).second = -1;
    }
}
void L1GtUtils::LogicalExpressionL1Results::reset ( std::vector< std::pair< std::string, bool > >  pairVector) const [private]

reset for each L1 trigger the value from pair.second

Definition at line 2783 of file L1GtUtils.cc.

References edm::second().

                                                               {

    for (size_t iTrig = 0; iTrig < m_expL1TriggersSize; ++iTrig) {
        (pairVector[iTrig]).second = false;
    }
}
const std::vector< std::pair< std::string, int > > & L1GtUtils::LogicalExpressionL1Results::triggerMasks ( )

Definition at line 2736 of file L1GtUtils.cc.

References Exception.

Referenced by L1GtAnalyzer::analyzeL1GtUtilsCore().

                                                                                             {

    // throw an exception if the result is not computed once per event - user usage error
    if (!m_l1ResultsAlreadyCalled) {
        throw cms::Exception("FailModule") << "\nUsage error: "
                << "\n  Method 'errorCodes' must be called in the event loop before attempting to use this method.\n"
                << std::endl;
    }

    return m_triggerMasks;

}

Member Data Documentation

std::vector<std::pair<std::string, bool> > L1GtUtils::LogicalExpressionL1Results::m_decisionsAfterMask [private]

Definition at line 187 of file L1GtUtils.h.

std::vector<std::pair<std::string, bool> > L1GtUtils::LogicalExpressionL1Results::m_decisionsBeforeMask [private]

Definition at line 186 of file L1GtUtils.h.

std::vector<std::pair<std::string, int> > L1GtUtils::LogicalExpressionL1Results::m_errorCodes [private]

Definition at line 190 of file L1GtUtils.h.

flag true, if the logical expression is built from technical trigger bits

Definition at line 179 of file L1GtUtils.h.

Definition at line 172 of file L1GtUtils.h.

Referenced by expL1Triggers().

Definition at line 173 of file L1GtUtils.h.

trigger category for each L1 trigger in the logical expression

Definition at line 176 of file L1GtUtils.h.

for each L1 trigger in the logical expression, true if the trigger is found in the current L1 menu

Definition at line 183 of file L1GtUtils.h.

code for L1 trigger configuration

Definition at line 157 of file L1GtUtils.h.

true if input tags for GT records are to be found from provenance (if both input tags from constructors are empty)

Definition at line 167 of file L1GtUtils.h.

Definition at line 150 of file L1GtUtils.h.

Definition at line 149 of file L1GtUtils.h.

Definition at line 147 of file L1GtUtils.h.

set to true if the method l1Results was called once

Definition at line 170 of file L1GtUtils.h.

private members as input parameters

logical expression

Definition at line 145 of file L1GtUtils.h.

std::vector<std::pair<std::string, int> > L1GtUtils::LogicalExpressionL1Results::m_prescaleFactors [private]

Definition at line 188 of file L1GtUtils.h.

std::vector<std::pair<std::string, int> > L1GtUtils::LogicalExpressionL1Results::m_triggerMasks [private]

Definition at line 189 of file L1GtUtils.h.

true if valid L1 configuration - if not, reset all quantities and return

Definition at line 160 of file L1GtUtils.h.

true if the logical expression uses accepted L1GtLogicParser operators

Definition at line 163 of file L1GtUtils.h.

Referenced by isValid().