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
DeltaRNearestObjectComputer< T > Class Template Reference
Inheritance diagram for DeltaRNearestObjectComputer< T >:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

 DeltaRNearestObjectComputer (const edm::ParameterSet &iConfig)
 
virtual void produce (edm::Event &iEvent, const edm::EventSetup &iSetup)
 
virtual ~DeltaRNearestObjectComputer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Attributes

StringCutObjectSelector< T, true > objCut_
 
edm::InputTag objects_
 
edm::InputTag probes_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- 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)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

template<typename T>
class DeltaRNearestObjectComputer< T >

Definition at line 44 of file DeltaRNearestObjectComputer.cc.

Constructor & Destructor Documentation

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

Definition at line 58 of file DeltaRNearestObjectComputer.cc.

58  :
59  probes_(iConfig.getParameter<edm::InputTag>("probes")),
60  objects_(iConfig.getParameter<edm::InputTag>("objects")),
61  objCut_(iConfig.existsAs<std::string>("objectSelection") ? iConfig.getParameter<std::string>("objectSelection") : "", true)
62 {
63  produces<edm::ValueMap<float> >();
64 }
T getParameter(std::string const &) const
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:181
StringCutObjectSelector< T, true > objCut_
template<typename T >
DeltaRNearestObjectComputer< T >::~DeltaRNearestObjectComputer ( )
virtual

Definition at line 68 of file DeltaRNearestObjectComputer.cc.

69 {
70 }

Member Function Documentation

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

Implements edm::EDProducer.

Definition at line 74 of file DeltaRNearestObjectComputer.cc.

References Geom::deltaR2(), edm::Event::getByLabel(), VarParsing::obj, edm::Event::put(), mathSSE::sqrt(), and makeHLTPrescaleTable::values.

74  {
75  using namespace edm;
76 
77  // read input
79  iEvent.getByLabel(probes_, probes);
80 
81  Handle<View<T> > objects;
82  iEvent.getByLabel(objects_, objects);
83 
84  // prepare vector for output
85  std::vector<float> values;
86 
87  // fill
88  View<reco::Candidate>::const_iterator probe, endprobes = probes->end();
89  for (probe = probes->begin(); probe != endprobes; ++probe) {
90  double dr2min = 10000;
91  for (unsigned int iObj=0; iObj<objects->size(); iObj++) {
92  const T& obj = objects->at(iObj);
93  if (!objCut_(obj)) continue;
94  double dr2 = deltaR2(*probe, obj);
95  if (dr2 < dr2min) { dr2min = dr2; }
96  }
97  values.push_back(sqrt(dr2min));
98  }
99 
100  // convert into ValueMap and store
101  std::auto_ptr<ValueMap<float> > valMap(new ValueMap<float>());
102  ValueMap<float>::Filler filler(*valMap);
103  filler.insert(probes, values.begin(), values.end());
104  filler.fill();
105  iEvent.put(valMap);
106 }
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
StringCutObjectSelector< T, true > objCut_
tuple obj
Example code starts here #.
Definition: VarParsing.py:655
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
T sqrt(T t)
Definition: SSEVec.h:28
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355
double deltaR2(const Vector1 &v1, const Vector2 &v2)
Definition: VectorUtil.h:78
long double T

Member Data Documentation

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

Definition at line 54 of file DeltaRNearestObjectComputer.cc.

template<typename T >
edm::InputTag DeltaRNearestObjectComputer< T >::objects_
private

Definition at line 53 of file DeltaRNearestObjectComputer.cc.

template<typename T >
edm::InputTag DeltaRNearestObjectComputer< T >::probes_
private

Definition at line 52 of file DeltaRNearestObjectComputer.cc.