1 #ifndef ConfigurableAnalysis_CachingVariable_H 2 #define ConfigurableAnalysis_CachingVariable_H 27 for (
unsigned int i = 0;
i !=
d_.size(); ++
i)
31 const std::vector<std::string>
lines() {
return d_; }
35 std::vector<std::string>
d_;
45 typedef std::map<std::string, const CachingVariable*>
vMap;
140 mutable std::map<std::string, const ComputedVariable*>
iCompute_;
197 edm::LogError(
"Splitter") <<
"trying to access slots short_label at index: " <<
i 207 edm::LogError(
"Splitter") <<
"trying to access slots label at index: " <<
i <<
"while of size: " <<
labels_.size()
227 slots_ =
arg.iConfig.getParameter<std::vector<double> >(
"slots");
229 labels_.push_back(
"underflow");
232 std::vector<std::string> confLabels;
233 if (
arg.iConfig.exists(
"labels")) {
234 confLabels =
arg.iConfig.getParameter<std::vector<std::string> >(
"labels");
237 for (
unsigned int is = 0; is !=
slots_.size() - 1; ++is) {
239 confLabels.push_back(
l);
242 for (
unsigned int i = 0;
i != confLabels.size(); ++
i) {
244 std::stringstream
ss;
245 ss <<
"_" <<
arg.n <<
"_" <<
i;
255 edm::LogError(
"Splitter") <<
"splitter with name: " <<
name() <<
" has inconsistent configuration\n" 265 unsigned int s =
slots_.size() - 1;
280 template <
typename Object, const
char* label>
290 if (
arg.iConfig.exists(
"expr") &&
arg.iConfig.exists(
"index")) {
292 index_ =
arg.iConfig.getParameter<
unsigned int>(
"index");
295 std::stringstream
ss;
298 if (
arg.iConfig.exists(
"order")) {
301 ss <<
" after sorting according to: " <<
order;
305 if (
arg.iConfig.exists(
"selection")) {
317 std::map<std::string, edm::Entry> indexEntry;
318 if (
arg.n.find(
"_N") != std::string::npos) {
320 std::vector<unsigned int> indexes =
arg.iConfig.getParameter<std::vector<unsigned int> >(
"indexes");
321 for (
unsigned int iI = 0; iI != indexes.size(); ++iI) {
324 std::stringstream
ss;
326 ss << indexes[iI] + 1;
327 indexEntry.insert(std::make_pair(
ss.str(),
e));
331 std::map<std::string, edm::Entry> varEntry;
332 if (
arg.n.find(
"_V") != std::string::npos) {
334 std::vector<std::string>
vars =
arg.iConfig.getParameter<std::vector<std::string> >(
"vars");
335 for (
unsigned int v = 0;
v !=
vars.size(); ++
v) {
336 unsigned int sep =
vars[
v].find(
':');
341 varEntry.insert(std::make_pair(
name,
e));
347 if (!varEntry.empty())
348 radical = radical.substr(0, radical.size() - 2);
350 if (!indexEntry.empty())
351 radical = radical.substr(0, radical.size() - 2);
353 if (varEntry.empty()) {
355 for (std::map<std::string, edm::Entry>::iterator iIt = indexEntry.begin(); iIt != indexEntry.end(); ++iIt) {
357 toUse.
insert(
true,
"index", iIt->second);
364 for (std::map<std::string, edm::Entry>::iterator vIt = varEntry.begin(); vIt != varEntry.end(); ++vIt) {
365 if (indexEntry.empty()) {
367 toUse.
insert(
true,
"expr", vIt->second);
373 for (std::map<std::string, edm::Entry>::iterator iIt = indexEntry.begin(); iIt != indexEntry.end(); ++iIt) {
375 toUse.
insert(
true,
"expr", vIt->second);
376 toUse.
insert(
true,
"index", iIt->second);
377 std::string newVname = radical + iIt->first + vIt->first;
403 return std::make_pair(
false, 0);
407 if (
index_ >= oH->size()) {
409 return std::make_pair(
false, 0);
414 std::vector<const Object*> copyToSort(0);
415 copyToSort.reserve(oH->size());
416 for (
unsigned int i = 0;
i != oH->size(); ++
i) {
419 copyToSort.push_back(&(*oH)[
i]);
421 if (
index_ >= copyToSort.size())
422 return std::make_pair(
false, 0);
426 const Object*
o = copyToSort[
index_];
427 return std::make_pair(
true, (*
f_)(*
o));
429 const Object&
o = (*oH)[
index_];
430 return std::make_pair(
true, (*
f_)(
o));
443 template <
typename LHS, const
char* lLHS,
typename RHS, const
char* lRHS,
typename Calculator>
454 std::stringstream
ss;
482 <<
" with: " << lhsH->size() <<
" entries.";
496 <<
" with: " << rhsH->size() <<
" entries.";
510 return calc(*
o.lhs, *
o.rhs);
515 return std::make_pair(
false, 0);
532 power_ =
arg.iConfig.getParameter<
double>(
"power");
534 std::stringstream
ss(
"Calculare X^Y, with X=");
549 template <
typename TYPE>
561 return std::make_pair(
false, 0);
563 return std::make_pair(
true, *
value);
570 template <
typename TYPE>
576 index_(
arg.iConfig.getParameter<unsigned
int>(
"index")) {
583 return std::make_pair(
false, 0);
585 return std::make_pair(
false, 0);
CachingVariable(std::string m, std::string n, const edm::ParameterSet &iConfig, edm::ConsumesCollector &iC)
void setNotCompute() const
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Log< level::Info, true > LogVerbatim
unsigned long CacheIdentifier_t
CachingVariable::evalType eval(const edm::Event &iEvent) const override
unsigned int maxSlots() const override
const Description & description() const
~ExpressionVariable() override
const std::string shortLabel(unsigned int i) const
CachingVariable::evalType eval(const edm::Event &iEvent) const override
CachingVariable::evalType eval(const edm::Event &iEvent) const override
ComputedVariable(const CachingVariableFactoryArg &arg, edm::ConsumesCollector &iC)
getObject objects(const edm::Event &iEvent) const
edm::EDGetTokenT< std::vector< LHS > > srcLhs_
evalType eval(const edm::Event &iEvent) const override
VarSplitter(const CachingVariableFactoryArg &arg, edm::ConsumesCollector &iC)
StringCutObjectSelector< Object > * selector_
virtual evalType eval(const edm::Event &iEvent) const
VariableComputer(const CachingVariable::CachingVariableFactoryArg &arg, edm::ConsumesCollector &iC)
void insert(bool ok_to_replace, char const *, Entry const &)
std::vector< std::string > short_labels_
~ComputedVariable() override
CachingVariable::evalType eval(const edm::Event &iEvent) const override=0
unsigned int maxIndex() const
Log< level::Error, false > LogError
CachingVariable::evalType eval(const edm::Event &iEvent) const override
const std::string & holderName() const
edm::Event::CacheIdentifier_t eventCacheID_
void assign(std::string var, double &value) const
const CachingVariable::CachingVariableFactoryArg & arg_
VariablePower(const CachingVariableFactoryArg &arg, edm::ConsumesCollector &iC)
std::vector< double > slots_
bool notSeenThisEventAlready(const edm::Event &iEvent) const
virtual ~VariableComputer()
TwoObjectVariable(const CachingVariableFactoryArg &arg, edm::ConsumesCollector &iC)
edm::ParameterSet & iConfig
const std::string & label(unsigned int i) const
void setHolder(std::string hn) const
std::map< std::string, const ComputedVariable * > iCompute_
const std::string & name() const
~VariablePower() override
StringObjectFunction< Object > * f_
void compute(const edm::Event &iEvent) const override
virtual ~CachingVariable()
void addDescriptionLine(const std::string &s)
Description(std::vector< std::string > &d)
edm::EDGetTokenT< TYPE > src_
const std::string & method() const
VariableComputerTest(const CachingVariable::CachingVariableFactoryArg &arg, edm::ConsumesCollector &iC)
valueType operator()(const edm::Event &iEvent) const
void doesNotCompute() const
edm::EDGetTokenT< edm::View< Object > > src_
edm::Event::CacheIdentifier_t eventCacheID_
SimpleValueVariable(const CachingVariableFactoryArg &arg, edm::ConsumesCollector &iC)
CachingVariable::evalType eval(const edm::Event &iEvent) const override
CachingVariable::vMap & m
SimpleValueVectorVariable(const CachingVariableFactoryArg &arg, edm::ConsumesCollector &iC)
StringObjectFunction< Object > * forder_
virtual CachingVariable::valueType calculate(getObject &o) const
std::vector< std::string > d_
std::unique_ptr< const VariableComputer > myComputer
Splitter(std::string method, std::string n, const edm::ParameterSet &iConfig, edm::ConsumesCollector &iC)
std::pair< OmniClusterRef, TrackingParticleRef > P
std::vector< std::string > labels_
edm::EDGetTokenT< TYPE > src_
void setCache(valueType &v) const
const std::vector< std::string > lines()
ExpressionVariable(const CachingVariableFactoryArg &arg, edm::ConsumesCollector &iC)
void addLine(const std::string &l)
virtual void compute(const edm::Event &iEvent) const =0
bool notSeenThisEventAlready(const edm::Event &iEvent) const
std::string dump(unsigned int indent=0) const
CachingVariable::evalType eval(const edm::Event &iEvent) const override
bool compute(const edm::Event &iEvent) const
const std::string & name() const
~VariableComputerTest() override
virtual unsigned int maxSlots() const
void declare(std::string var, edm::ConsumesCollector &iC)
CachingVariableFactoryArg(std::string &N, CachingVariable::vMap &M, edm::ParameterSet &P)
CachingVariableFactoryArg(const CachingVariableFactoryArg ©)
edm::EDGetTokenT< std::vector< RHS > > srcRhs_
evalType & baseEval(const edm::Event &iEvent) const
ComputedVariable(const std::string &M, std::string &N, edm::ParameterSet &P, const VariableComputer *c, edm::ConsumesCollector &iC)
std::map< std::string, const CachingVariable * > vMap
std::pair< bool, valueType > evalType