Main Page
Namespaces
Classes
Package Documentation
CommonTools
Utils
interface
StringObjectFunction.h
Go to the documentation of this file.
1
#ifndef CommonTools_Utils_StringObjectFunction_h
2
#define CommonTools_Utils_StringObjectFunction_h
3
/* \class StringCutObjectSelector
4
*
5
* \author Luca Lista, INFN
6
*
7
* $Id: StringObjectFunction.h,v 1.4 2012/06/26 21:09:37 wmtan Exp $
8
*/
9
#include "
FWCore/Utilities/interface/EDMException.h
"
10
#include "
CommonTools/Utils/src/ExpressionPtr.h
"
11
#include "
CommonTools/Utils/src/ExpressionBase.h
"
12
#include "
CommonTools/Utils/interface/expressionParser.h
"
13
#include "
FWCore/Utilities/interface/ObjectWithDict.h
"
14
15
template
<
typename
T,
bool
DefaultLazyness=false>
16
struct
StringObjectFunction
{
17
StringObjectFunction
(
const
std::string
&
expr
,
bool
lazy=DefaultLazyness) :
18
type_
(typeid(
T
)) {
19
if
(! reco::parser::expressionParser<T>(expr,
expr_
, lazy)) {
20
throw
edm::Exception
(
edm::errors::Configuration
,
21
"failed to parse \""
+ expr +
"\""
);
22
}
23
}
24
StringObjectFunction
(
const
reco::parser::ExpressionPtr
&
expr
) :
25
expr_
(expr),
26
type_
(typeid(
T
)) {
27
}
28
double
operator()
(
const
T
&
t
)
const
{
29
edm::ObjectWithDict
o
(
type_
, const_cast<T *>(& t));
30
return
expr_
->value(o);
31
}
32
33
private
:
34
reco::parser::ExpressionPtr
expr_
;
35
edm::TypeWithDict
type_
;
36
};
37
38
template
<
typename
Object>
class
sortByStringFunction
{
39
public
:
40
sortByStringFunction
(
StringObjectFunction<Object>
*
f
) : f_(f){}
41
~sortByStringFunction
(){}
42
43
bool
operator()
(
const
Object *
o1
,
const
Object * o2) {
44
return
(*f_)(*o1) > (*f_)(*o2);
45
}
46
private
:
47
StringObjectFunction<Object>
*
f_
;
48
};
49
50
#endif
edm::ObjectWithDict
Definition:
ObjectWithDict.h:17
StringObjectFunction
Definition:
StringObjectFunction.h:16
sortByStringFunction::~sortByStringFunction
~sortByStringFunction()
Definition:
StringObjectFunction.h:41
ExpressionBase.h
Exception
Definition:
hltDiff.cc:292
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:255
reco::parser::ExpressionPtr
boost::shared_ptr< ExpressionBase > ExpressionPtr
Definition:
ExpressionBase.h:22
jets_cff.expr
expr
Definition:
jets_cff.py:179
edm::errors::Configuration
Definition:
EDMException.h:37
sortByStringFunction
Definition:
StringObjectFunction.h:38
expressionParser.h
EDMException.h
ObjectWithDict.h
StringObjectFunction::StringObjectFunction
StringObjectFunction(const reco::parser::ExpressionPtr &expr)
Definition:
StringObjectFunction.h:24
CastorDigiReco.o1
o1
Definition:
CastorDigiReco.py:84
f
double f[11][100]
Definition:
MuScleFitUtils.cc:78
StringObjectFunction::StringObjectFunction
StringObjectFunction(const std::string &expr, bool lazy=DefaultLazyness)
Definition:
StringObjectFunction.h:17
StringObjectFunction::type_
edm::TypeWithDict type_
Definition:
StringObjectFunction.h:35
connectstrParser.o
o
Definition:
connectstrParser.py:70
ExpressionPtr.h
StringObjectFunction::expr_
reco::parser::ExpressionPtr expr_
Definition:
StringObjectFunction.h:34
edm::TypeWithDict
Definition:
TypeWithDict.h:38
lumiQTWidget.t
t
Definition:
lumiQTWidget.py:50
sortByStringFunction::f_
StringObjectFunction< Object > * f_
Definition:
StringObjectFunction.h:47
T
long double T
Definition:
Basic3DVectorLD.h:66
StringObjectFunction::operator()
double operator()(const T &t) const
Definition:
StringObjectFunction.h:28
sortByStringFunction::sortByStringFunction
sortByStringFunction(StringObjectFunction< Object > *f)
Definition:
StringObjectFunction.h:40
Generated for CMSSW Reference Manual by
1.8.11