CMS 3D CMS Logo

Public Types | Public Member Functions | Private Attributes

L1GtAlgorithmEvaluation Class Reference

#include <L1GtAlgorithmEvaluation.h>

Inheritance diagram for L1GtAlgorithmEvaluation:
L1GtLogicParser

List of all members.

Public Types

typedef
ConditionEvaluationMap::const_iterator 
CItEvalMap
typedef __gnu_cxx::hash_map
< std::string,
L1GtConditionEvaluation * > 
ConditionEvaluationMap
typedef
ConditionEvaluationMap::iterator 
ItEvalMap

Public Member Functions

void evaluateAlgorithm (const int chipNumber, const std::vector< ConditionEvaluationMap > &)
 evaluate an algorithm
const std::vector
< CombinationsInCond > * 
gtAlgoCombinationVector () const
const bool & gtAlgoResult () const
 get / set the result of the algorithm
 L1GtAlgorithmEvaluation ()
 constructor
 L1GtAlgorithmEvaluation (const L1GtAlgorithm &)
 constructor from an algorithm from event setup
 L1GtAlgorithmEvaluation (L1GtAlgorithmEvaluation &)
 copy constructor
void print (std::ostream &myCout) const
void setGtAlgoResult (const bool algoResult)
virtual ~L1GtAlgorithmEvaluation ()
 destructor

Private Attributes

std::vector< CombinationsInCondm_algoCombinationVector
bool m_algoResult
 algorithm result

Detailed Description

Description: Evaluation of a L1 Global Trigger algorithm.

Implementation: <TODO: enter implementation details>

Author:
: Vasile Mihai Ghete - HEPHY Vienna

$Date$ $Revision$

Definition at line 67 of file L1GtAlgorithmEvaluation.h.


Member Typedef Documentation

typedef ConditionEvaluationMap::const_iterator L1GtAlgorithmEvaluation::CItEvalMap

Definition at line 86 of file L1GtAlgorithmEvaluation.h.

Definition at line 85 of file L1GtAlgorithmEvaluation.h.

typedef ConditionEvaluationMap::iterator L1GtAlgorithmEvaluation::ItEvalMap

Definition at line 87 of file L1GtAlgorithmEvaluation.h.


Constructor & Destructor Documentation

L1GtAlgorithmEvaluation::L1GtAlgorithmEvaluation ( )

constructor

Definition at line 48 of file L1GtAlgorithmEvaluation.cc.

References m_algoResult.

                                                 :
    L1GtLogicParser() {

    m_algoResult = false;

    // the rest is properly initialized by default
}
L1GtAlgorithmEvaluation::L1GtAlgorithmEvaluation ( const L1GtAlgorithm alg)

constructor from an algorithm from event setup

Definition at line 57 of file L1GtAlgorithmEvaluation.cc.

References L1GtAlgorithm::algoLogicalExpression(), L1GtAlgorithm::algoRpnVector(), m_algoResult, L1GtLogicParser::m_logicalExpression, and L1GtLogicParser::m_rpnVector.

                                                                         :
    L1GtLogicParser() {

    m_logicalExpression = alg.algoLogicalExpression();
    m_rpnVector = alg.algoRpnVector();
    
    m_algoResult = false;

    // the rest is properly initialized by default

}
L1GtAlgorithmEvaluation::L1GtAlgorithmEvaluation ( L1GtAlgorithmEvaluation cp)
L1GtAlgorithmEvaluation::~L1GtAlgorithmEvaluation ( ) [virtual]

destructor

Definition at line 83 of file L1GtAlgorithmEvaluation.cc.

                                                  {

    // empty

}

Member Function Documentation

void L1GtAlgorithmEvaluation::evaluateAlgorithm ( const int  chipNumber,
const std::vector< ConditionEvaluationMap > &  conditionResultMaps 
)

evaluate an algorithm

Definition at line 92 of file L1GtAlgorithmEvaluation.cc.

References Exception, spr::find(), m_algoCombinationVector, m_algoResult, L1GtLogicParser::m_logicalExpression, L1GtLogicParser::m_operandTokenVector, L1GtLogicParser::m_rpnVector, L1GtLogicParser::OP_AND, L1GtLogicParser::OP_NOT, L1GtLogicParser::OP_OPERAND, L1GtLogicParser::OP_OR, L1GtLogicParser::OperandToken::tokenName, L1GtLogicParser::OperandToken::tokenNumber, and L1GtLogicParser::OperandToken::tokenResult.

Referenced by L1GlobalTriggerGTL::run().

                                                                  {

    // set result to false if there is no expression 
    if (m_rpnVector.empty() ) {
        m_algoResult = false;

        // it should never be happen
        throw cms::Exception("FailModule")
        << "\nEmpty RPN vector for the logical expression = "
        << m_logicalExpression
        << std::endl;

    }
    
    // reserve memory
    int rpnVectorSize = m_rpnVector.size();
    
    m_algoCombinationVector.reserve(rpnVectorSize);
    m_operandTokenVector.reserve(rpnVectorSize);

    // stack containing temporary results
    std::stack<bool> resultStack;
    bool b1, b2;

    int opNumber = 0;

    for (RpnVector::const_iterator it = m_rpnVector.begin(); it != m_rpnVector.end(); it++) {

        //LogTrace("L1GtAlgorithmEvaluation")
        //<< "\nit->operation = " << it->operation
        //<< "\nit->operand =   '" << it->operand << "'\n"
        //<< std::endl;

        switch (it->operation) {

            case OP_OPERAND: {

                CItEvalMap itCond = (conditionResultMaps.at(chipNumber)).find(it->operand);
                if (itCond != (conditionResultMaps[chipNumber]).end()) {

                    //
                    bool condResult = (itCond->second)->condLastResult();

                    resultStack.push(condResult);

                    // only conditions are added to /counted in m_operandTokenVector 
                    // opNumber is the index of the condition in the logical expression
                    OperandToken opToken;
                    opToken.tokenName = it->operand;
                    opToken.tokenNumber = opNumber;
                    opToken.tokenResult = condResult;
                    
                    m_operandTokenVector.push_back(opToken);
                    opNumber++;
                    
                    //
                    CombinationsInCond* combInCondition = (itCond->second)->getCombinationsInCond();
                    m_algoCombinationVector.push_back(*combInCondition);

                }
                else {

                    // it should never be happen, all conditions are in the maps
                    throw cms::Exception("FailModule")
                    << "\nCondition " << (it->operand) << " not found in condition map"
                    << std::endl;

                }

            }

                break;
            case OP_NOT: {
                b1 = resultStack.top();
                resultStack.pop(); // pop the top
                resultStack.push(!b1); // and push the result
            }

                break;
            case OP_OR: {
                b1 = resultStack.top();
                resultStack.pop();
                b2 = resultStack.top();
                resultStack.pop();
                resultStack.push(b1 || b2);
            }

                break;
            case OP_AND: {
                b1 = resultStack.top();
                resultStack.pop();
                b2 = resultStack.top();
                resultStack.pop();
                resultStack.push(b1 && b2);
            }

                break;
            default: {
                // should not arrive here
            }

                break;
        }

    }

    // get the result in the top of the stack

    m_algoResult = resultStack.top();


}
const std::vector<CombinationsInCond>* L1GtAlgorithmEvaluation::gtAlgoCombinationVector ( ) const [inline]

get all the object combinations evaluated to true in the conditions from the algorithm

Definition at line 105 of file L1GtAlgorithmEvaluation.h.

References m_algoCombinationVector.

Referenced by L1GtAlgorithmEvaluation(), and L1GlobalTriggerGTL::run().

const bool& L1GtAlgorithmEvaluation::gtAlgoResult ( ) const [inline]

get / set the result of the algorithm

Definition at line 92 of file L1GtAlgorithmEvaluation.h.

References m_algoResult.

Referenced by L1GtAlgorithmEvaluation(), and L1GlobalTriggerGTL::run().

                                            {
        return m_algoResult;
    }
void L1GtAlgorithmEvaluation::print ( std::ostream &  myCout) const

Definition at line 207 of file L1GtAlgorithmEvaluation.cc.

References i, m_algoCombinationVector, m_algoResult, and L1GtLogicParser::m_operandTokenVector.

Referenced by L1GlobalTriggerGTL::run().

                                                            {

    myCout << std::endl;

    myCout << "    Algorithm result:          " << m_algoResult << std::endl;

    myCout << "    CombinationVector size:    " << m_algoCombinationVector.size() << std::endl;

    int operandTokenVectorSize = m_operandTokenVector.size();

    myCout << "    Operand token vector size: " << operandTokenVectorSize;

    if (operandTokenVectorSize == 0) {
        myCout << "   - not properly initialized! " << std::endl;
    }
    else {
        myCout << std::endl;

        for (int i = 0; i < operandTokenVectorSize; ++i) {

            myCout << "      " << std::setw(5) << (m_operandTokenVector[i]).tokenNumber << "\t"
            << std::setw(25) << (m_operandTokenVector[i]).tokenName << "\t" 
            << (m_operandTokenVector[i]).tokenResult 
            << std::endl;

        }

    }

    myCout << std::endl;
}
void L1GtAlgorithmEvaluation::setGtAlgoResult ( const bool  algoResult) [inline]

Definition at line 96 of file L1GtAlgorithmEvaluation.h.

References m_algoResult.

                                                       {
        m_algoResult = algoResult;
    }

Member Data Documentation

algorithm result

Definition at line 115 of file L1GtAlgorithmEvaluation.h.

Referenced by evaluateAlgorithm(), gtAlgoResult(), L1GtAlgorithmEvaluation(), print(), and setGtAlgoResult().