CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 OtherObjectVariableComputer (const edm::ParameterSet &iConfig)
 
virtual void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
virtual ~OtherObjectVariableComputer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

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 28 of file OtherObjectVariableComputer.cc.

Constructor & Destructor Documentation

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

Definition at line 46 of file OtherObjectVariableComputer.cc.

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

Definition at line 60 of file OtherObjectVariableComputer.cc.

61 {
62 }

Member Function Documentation

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

Implements edm::EDProducer.

Definition at line 66 of file OtherObjectVariableComputer.cc.

References edm::Event::getByToken(), objCut_(), dbtoconf::object, edm::Event::put(), python.multivaluedict::sort(), and makeHLTPrescaleTable::values.

66  {
67  using namespace edm;
68 
69  // read input
71  Handle<View<T> > objects;
72  iEvent.getByToken(probesToken_, probes);
73  iEvent.getByToken(objectsToken_, objects);
74 
75  // fill
76  std::vector<std::pair<double, double> > selected;
77  typename View<T>::const_iterator object, endobjects = objects->end();
78  for (object = objects->begin(); object != endobjects; ++object) {
79  if (objCut_(*object)) {
80  selected.push_back(std::pair<double, double>(objSort_(*object), objVar_(*object)));
81  if (!doSort_) break; // if we take just the first one, there's no need of computing the others
82  }
83  }
84  if (doSort_ && selected.size() > 1) std::sort(selected.begin(), selected.end()); // sorts (ascending)
85 
86  // prepare vector for output
87  std::vector<float> values(probes->size(), (selected.empty() ? default_ : selected.back().second));
88 
89  // convert into ValueMap and store
90  std::auto_ptr<ValueMap<float> > valMap(new ValueMap<float>());
91  ValueMap<float>::Filler filler(*valMap);
92  filler.insert(probes, values.begin(), values.end());
93  filler.fill();
94  iEvent.put(valMap);
95 }
StringCutObjectSelector< T, true > objCut_
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
StringObjectFunction< T, true > objSort_
StringObjectFunction< T, true > objVar_
edm::EDGetTokenT< edm::View< reco::Candidate > > probesToken_
edm::EDGetTokenT< edm::View< T > > objectsToken_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
list object
Definition: dbtoconf.py:77

Member Data Documentation

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

Definition at line 39 of file OtherObjectVariableComputer.cc.

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

Definition at line 41 of file OtherObjectVariableComputer.cc.

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

Definition at line 40 of file OtherObjectVariableComputer.cc.

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

Definition at line 37 of file OtherObjectVariableComputer.cc.

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

Definition at line 42 of file OtherObjectVariableComputer.cc.

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

Definition at line 38 of file OtherObjectVariableComputer.cc.

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

Definition at line 36 of file OtherObjectVariableComputer.cc.