CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
OtherObjectVariableComputer< T > Class Template Reference

Matcher of number of reconstructed objects in the event to probe. More...

Inheritance diagram for OtherObjectVariableComputer< T >:
edm::stream::EDProducer<>

Public Member Functions

 OtherObjectVariableComputer (const edm::ParameterSet &iConfig)
 
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
 ~OtherObjectVariableComputer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Attributes

double default_
 
bool doSort_
 
StringCutObjectSelector< T, true > objCut_
 
edm::EDGetTokenT< edm::View< T > > objectsToken_
 
StringObjectFunction< T, true > objSort_
 
StringObjectFunction< T, true > objVar_
 
edm::EDGetTokenT< edm::View< reco::Candidate > > probesToken_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

template<typename T>
class OtherObjectVariableComputer< T >

Matcher of number of reconstructed objects in the event to probe.

Author
Kalanand Mishra

Definition at line 27 of file OtherObjectVariableComputer.cc.

Constructor & Destructor Documentation

◆ OtherObjectVariableComputer()

template<typename T >
OtherObjectVariableComputer< T >::OtherObjectVariableComputer ( const edm::ParameterSet iConfig)
explicit

Definition at line 45 of file OtherObjectVariableComputer.cc.

46  : probesToken_(consumes<edm::View<reco::Candidate>>(iConfig.getParameter<edm::InputTag>("probes"))),
47  objectsToken_(consumes<edm::View<T>>(iConfig.getParameter<edm::InputTag>("objects"))),
48  objVar_(iConfig.getParameter<std::string>("expression")),
49  default_(iConfig.getParameter<double>("default")),
50  objCut_(
51  iConfig.existsAs<std::string>("objectSelection") ? iConfig.getParameter<std::string>("objectSelection") : "",
52  true),
53  doSort_(iConfig.existsAs<std::string>("objectSortDescendingBy")),
54  objSort_(doSort_ ? iConfig.getParameter<std::string>("objectSortDescendingBy") : "1", true) {
55  produces<edm::ValueMap<float>>();
56 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:171
edm::EDGetTokenT< edm::View< reco::Candidate > > probesToken_
edm::EDGetTokenT< edm::View< T > > objectsToken_
StringCutObjectSelector< T, true > objCut_
StringObjectFunction< T, true > objVar_
StringObjectFunction< T, true > objSort_

◆ ~OtherObjectVariableComputer()

template<typename T >
OtherObjectVariableComputer< T >::~OtherObjectVariableComputer ( )
override

Definition at line 59 of file OtherObjectVariableComputer.cc.

59 {}

Member Function Documentation

◆ produce()

template<typename T >
void OtherObjectVariableComputer< T >::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 62 of file OtherObjectVariableComputer.cc.

References trigObjTnPSource_cfi::filler, iEvent, eostools::move(), resolutioncreator_cfi::object, L1TPhase2Offline_cfi::objects, jetUpdater_cfi::sort, and contentValuesCheck::values.

62  {
63  using namespace edm;
64 
65  // read input
68  iEvent.getByToken(probesToken_, probes);
69  iEvent.getByToken(objectsToken_, objects);
70 
71  // fill
72  std::vector<std::pair<double, double>> selected;
73  typename View<T>::const_iterator object, endobjects = objects->end();
74  for (object = objects->begin(); object != endobjects; ++object) {
75  if (objCut_(*object)) {
76  selected.push_back(std::pair<double, double>(objSort_(*object), objVar_(*object)));
77  if (!doSort_)
78  break; // if we take just the first one, there's no need of computing the others
79  }
80  }
81  if (doSort_ && selected.size() > 1)
82  std::sort(selected.begin(), selected.end()); // sorts (ascending)
83 
84  // prepare vector for output
85  std::vector<float> values(probes->size(), (selected.empty() ? default_ : selected.back().second));
86 
87  // convert into ValueMap and store
88  auto valMap = std::make_unique<ValueMap<float>>();
90  filler.insert(probes, values.begin(), values.end());
91  filler.fill();
92  iEvent.put(std::move(valMap));
93 }
edm::EDGetTokenT< edm::View< reco::Candidate > > probesToken_
edm::EDGetTokenT< edm::View< T > > objectsToken_
int iEvent
Definition: GenABIO.cc:224
StringCutObjectSelector< T, true > objCut_
StringObjectFunction< T, true > objVar_
HLT enums.
StringObjectFunction< T, true > objSort_
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ default_

template<typename T >
double OtherObjectVariableComputer< T >::default_
private

Definition at line 38 of file OtherObjectVariableComputer.cc.

◆ doSort_

template<typename T >
bool OtherObjectVariableComputer< T >::doSort_
private

Definition at line 40 of file OtherObjectVariableComputer.cc.

◆ objCut_

template<typename T >
StringCutObjectSelector<T, true> OtherObjectVariableComputer< T >::objCut_
private

Definition at line 39 of file OtherObjectVariableComputer.cc.

◆ objectsToken_

template<typename T >
edm::EDGetTokenT<edm::View<T> > OtherObjectVariableComputer< T >::objectsToken_
private

Definition at line 36 of file OtherObjectVariableComputer.cc.

◆ objSort_

template<typename T >
StringObjectFunction<T, true> OtherObjectVariableComputer< T >::objSort_
private

Definition at line 41 of file OtherObjectVariableComputer.cc.

◆ objVar_

template<typename T >
StringObjectFunction<T, true> OtherObjectVariableComputer< T >::objVar_
private

Definition at line 37 of file OtherObjectVariableComputer.cc.

◆ probesToken_

template<typename T >
edm::EDGetTokenT<edm::View<reco::Candidate> > OtherObjectVariableComputer< T >::probesToken_
private

Definition at line 35 of file OtherObjectVariableComputer.cc.