CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
JetDeltaRValueMapProducer< T > Class Template Reference
Inheritance diagram for JetDeltaRValueMapProducer< T >:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Types

typedef edm::ValueMap< float > JetValueMap
 
- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 

Public Member Functions

 JetDeltaRValueMapProducer (edm::ParameterSet const &params)
 
virtual ~JetDeltaRValueMapProducer ()
 
- 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
std::vector< ConsumesInfoconsumesInfo () const
 
 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
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

virtual void beginJob () override
 
virtual void endJob () override
 
virtual void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 

Private Attributes

const double distMax_
 
std::map< std::string,
StringObjectFunction< T > > 
evaluationMap_
 
const bool lazyParser_
 
const edm::EDGetTokenT
< typename edm::View< T > > 
matchedToken_
 
bool multiValue_
 
const edm::EDGetTokenT
< typename edm::View< T > > 
srcToken_
 
const std::string value_
 
const std::vector< std::string > valueLabels_
 
const std::vector< std::string > values_
 

Additional Inherited Members

- 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<class T>
class JetDeltaRValueMapProducer< T >

Definition at line 32 of file JetDeltaRValueMapProducer.cc.

Member Typedef Documentation

template<class T >
typedef edm::ValueMap<float> JetDeltaRValueMapProducer< T >::JetValueMap

Definition at line 36 of file JetDeltaRValueMapProducer.cc.

Constructor & Destructor Documentation

template<class T >
JetDeltaRValueMapProducer< T >::JetDeltaRValueMapProducer ( edm::ParameterSet const &  params)
inline

Definition at line 38 of file JetDeltaRValueMapProducer.cc.

References JetDeltaRValueMapProducer< T >::evaluationMap_, i, JetDeltaRValueMapProducer< T >::lazyParser_, JetDeltaRValueMapProducer< T >::multiValue_, JetDeltaRValueMapProducer< T >::value_, JetDeltaRValueMapProducer< T >::valueLabels_, and JetDeltaRValueMapProducer< T >::values_.

38  :
39  srcToken_( consumes< typename edm::View<T> >( params.getParameter<edm::InputTag>("src") ) ),
40  matchedToken_( consumes< typename edm::View<T> >( params.getParameter<edm::InputTag>( "matched" ) ) ),
41  distMax_( params.getParameter<double>( "distMax" ) ),
42  value_( params.existsAs<std::string>("value") ? params.getParameter<std::string>("value") : "" ),
43  values_( params.existsAs<std::vector<std::string> >("values") ? params.getParameter<std::vector<std::string> >("values") : std::vector<std::string>() ),
44  valueLabels_( params.existsAs<std::vector<std::string> >("valueLabels") ? params.getParameter<std::vector<std::string> >("valueLabels") : std::vector<std::string>() ),
45  lazyParser_( params.existsAs<bool>("lazyParser") ? params.getParameter<bool>("lazyParser") : false )
46  {
47  if( value_!="" )
48  {
49  evaluationMap_.insert( std::make_pair( value_, StringObjectFunction<T>( value_, lazyParser_ ) ) );
50  produces< JetValueMap >();
51  }
52 
53  if( valueLabels_.size()>0 || values_.size()>0 )
54  {
55  if( valueLabels_.size()==values_.size() )
56  {
57  multiValue_ = true;
58  for( size_t i=0; i<valueLabels_.size(); ++i)
59  {
60  evaluationMap_.insert( std::make_pair( valueLabels_[i], StringObjectFunction<T>( values_[i], lazyParser_ ) ) );
61  produces< JetValueMap >(valueLabels_[i]);
62  }
63  }
64  else
65  edm::LogWarning("ValueLabelMismatch") << "The number of value labels does not match the number of values. Values will not be evaluated.";
66  }
67  }
int i
Definition: DBlmapReader.cc:9
const std::vector< std::string > values_
const edm::EDGetTokenT< typename edm::View< T > > srcToken_
const std::vector< std::string > valueLabels_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
const edm::EDGetTokenT< typename edm::View< T > > matchedToken_
std::map< std::string, StringObjectFunction< T > > evaluationMap_
template<class T >
virtual JetDeltaRValueMapProducer< T >::~JetDeltaRValueMapProducer ( )
inlinevirtual

Definition at line 69 of file JetDeltaRValueMapProducer.cc.

69 {}

Member Function Documentation

template<class T >
virtual void JetDeltaRValueMapProducer< T >::beginJob ( void  )
inlineoverrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 73 of file JetDeltaRValueMapProducer.cc.

73 {}
template<class T >
virtual void JetDeltaRValueMapProducer< T >::endJob ( void  )
inlineoverrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 74 of file JetDeltaRValueMapProducer.cc.

74 {}
template<class T >
virtual void JetDeltaRValueMapProducer< T >::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
inlineoverrideprivatevirtual

Implements edm::EDProducer.

Definition at line 76 of file JetDeltaRValueMapProducer.cc.

References reco::deltaR2(), JetDeltaRValueMapProducer< T >::distMax_, JetDeltaRValueMapProducer< T >::evaluationMap_, edm::false, edm::helper::Filler< Map >::fill(), edm::Event::getByToken(), i, cmsHarvester::index, edm::helper::Filler< Map >::insert(), JetDeltaRValueMapProducer< T >::matchedToken_, JetDeltaRValueMapProducer< T >::multiValue_, edm::Event::put(), JetDeltaRValueMapProducer< T >::srcToken_, JetDeltaRValueMapProducer< T >::value_, JetDeltaRValueMapProducer< T >::valueLabels_, and makeHLTPrescaleTable::values.

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

76  {
77 
79  iEvent.getByToken( srcToken_, h_jets1 );
81  iEvent.getByToken( matchedToken_, h_jets2 );
82 
83  std::vector<float> values( h_jets1->size(), -99999 );
84  std::map<std::string, std::vector<float> > valuesMap;
85  if( multiValue_ )
86  {
87  for( size_t i=0; i<valueLabels_.size(); ++i)
88  valuesMap.insert( std::make_pair( valueLabels_[i], std::vector<float>( h_jets1->size(), -99999 ) ) );
89  }
90  std::vector<bool> jets1_locks( h_jets1->size(), false );
91 
92  for ( typename edm::View<T>::const_iterator ibegin = h_jets2->begin(),
93  iend = h_jets2->end(), ijet = ibegin;
94  ijet != iend; ++ijet )
95  {
96  float matched_dR2 = 1e9;
97  int matched_index = -1;
98 
99  for ( typename edm::View<T>::const_iterator jbegin = h_jets1->begin(),
100  jend = h_jets1->end(), jjet = jbegin;
101  jjet != jend; ++jjet )
102  {
103  int index=jjet - jbegin;
104 
105  if( jets1_locks.at(index) ) continue; // skip jets that have already been matched
106 
107  float temp_dR2 = reco::deltaR2(ijet->eta(),ijet->phi(),jjet->eta(),jjet->phi());
108  if ( temp_dR2 < matched_dR2 )
109  {
110  matched_dR2 = temp_dR2;
111  matched_index = index;
112  }
113  }// end loop over src jets
114 
115  if( matched_index>=0 )
116  {
117  if ( matched_dR2 > distMax_*distMax_ )
118  edm::LogWarning("MatchedJetsFarApart") << "Matched jets separated by dR greater than distMax=" << distMax_;
119  else
120  {
121  jets1_locks.at(matched_index) = true;
122  if( value_!="" )
123  values.at(matched_index) = (evaluationMap_.at(value_))(*ijet);
124  if( multiValue_ )
125  {
126  for( size_t i=0; i<valueLabels_.size(); ++i)
127  valuesMap.at(valueLabels_[i]).at(matched_index) = (evaluationMap_.at(valueLabels_[i]))(*ijet);
128  }
129  }
130  }
131  }// end loop over matched jets
132 
133  if( value_!="" )
134  {
135  std::auto_ptr< JetValueMap > jetValueMap ( new JetValueMap() );
136 
137  JetValueMap::Filler filler(*jetValueMap);
138  filler.insert(h_jets1, values.begin(), values.end());
139  filler.fill();
140 
141  // put in Event
142  iEvent.put(jetValueMap);
143  }
144  if( multiValue_ )
145  {
146  for( size_t i=0; i<valueLabels_.size(); ++i)
147  {
148  std::auto_ptr< JetValueMap > jetValueMap ( new JetValueMap() );
149 
150  JetValueMap::Filler filler(*jetValueMap);
151  filler.insert(h_jets1, valuesMap.at(valueLabels_[i]).begin(), valuesMap.at(valueLabels_[i]).end());
152  filler.fill();
153 
154  // put in Event
155  iEvent.put(jetValueMap, valueLabels_[i]);
156  }
157  }
158  }
int i
Definition: DBlmapReader.cc:9
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
edm::ValueMap< float > JetValueMap
const edm::EDGetTokenT< typename edm::View< T > > srcToken_
const std::vector< std::string > valueLabels_
const edm::EDGetTokenT< typename edm::View< T > > matchedToken_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
double deltaR2(const T1 &t1, const T2 &t2)
Definition: deltaR.h:36
helper::Filler< ValueMap< float > > Filler
Definition: ValueMap.h:170
std::map< std::string, StringObjectFunction< T > > evaluationMap_
volatile std::atomic< bool > shutdown_flag false

Member Data Documentation

template<class T >
const double JetDeltaRValueMapProducer< T >::distMax_
private
template<class T >
std::map<std::string, StringObjectFunction<T> > JetDeltaRValueMapProducer< T >::evaluationMap_
private
template<class T >
const bool JetDeltaRValueMapProducer< T >::lazyParser_
private
template<class T >
const edm::EDGetTokenT< typename edm::View<T> > JetDeltaRValueMapProducer< T >::matchedToken_
private
template<class T >
bool JetDeltaRValueMapProducer< T >::multiValue_
private
template<class T >
const edm::EDGetTokenT< typename edm::View<T> > JetDeltaRValueMapProducer< T >::srcToken_
private
template<class T >
const std::string JetDeltaRValueMapProducer< T >::value_
private
template<class T >
const std::vector<std::string> JetDeltaRValueMapProducer< T >::valueLabels_
private
template<class T >
const std::vector<std::string> JetDeltaRValueMapProducer< T >::values_
private