Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-17 23:10:25

0001 #ifndef CommonTools_Utils_ExpressionCondition_h
0002 #define CommonTools_Utils_ExpressionCondition_h
0003 /* \class reco::parser::ExpressionCondition
0004  *
0005  * Unary Operator expression
0006  *
0007  * \author original version: Chris Jones, Cornell, 
0008  *         adapted by Luca Lista, INFN
0009  *
0010  * \version $Revision: 1.2 $
0011  *
0012  */
0013 #include "CommonTools/Utils/interface/ExpressionBase.h"
0014 #include "CommonTools/Utils/interface/SelectorBase.h"
0015 #include "CommonTools/Utils/interface/SelectorStack.h"
0016 #include "CommonTools/Utils/interface/ExpressionStack.h"
0017 
0018 namespace reco {
0019   namespace parser {
0020     struct ExpressionCondition : public ExpressionBase {
0021       double value(const edm::ObjectWithDict& o) const override {
0022         return (*cond_)(o) ? true_->value(o) : false_->value(o);
0023       }
0024       ExpressionCondition(ExpressionStack& expStack, SelectorStack& selStack) {
0025         false_ = expStack.back();
0026         expStack.pop_back();
0027         true_ = expStack.back();
0028         expStack.pop_back();
0029         cond_ = selStack.back();
0030         selStack.pop_back();
0031       }
0032 
0033     private:
0034       ExpressionPtr true_, false_;
0035       SelectorPtr cond_;
0036     };
0037   }  // namespace parser
0038 }  // namespace reco
0039 
0040 #endif