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::stream::EDProducer<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Types

typedef edm::ValueMap< float > JetValueMap
 
- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T...> CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T...> HasAbility
 
typedef
CacheTypes::LuminosityBlockCache 
LuminosityBlockCache
 
typedef
LuminosityBlockContextT
< LuminosityBlockCache,
RunCache, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase 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::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- 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 produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 

Private Attributes

const double distMax_
 
std::map< std::string,
std::unique_ptr< const
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::stream::EDProducerBase
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  multiValue_(false)
47  {
48  if( value_!="" )
49  {
50  evaluationMap_.insert( std::make_pair( value_, std::unique_ptr<StringObjectFunction<T> >( new StringObjectFunction<T>( value_, lazyParser_ ) ) ) );
51  produces< JetValueMap >();
52  }
53 
54  if( valueLabels_.size()>0 || values_.size()>0 )
55  {
56  if( valueLabels_.size()==values_.size() )
57  {
58  multiValue_ = true;
59  for( size_t i=0; i<valueLabels_.size(); ++i)
60  {
61  evaluationMap_.insert( std::make_pair( valueLabels_[i], std::unique_ptr<StringObjectFunction<T> >( new StringObjectFunction<T>( values_[i], lazyParser_ ) ) ) );
62  produces< JetValueMap >(valueLabels_[i]);
63  }
64  }
65  else
66  edm::LogWarning("ValueLabelMismatch") << "The number of value labels does not match the number of values. Values will not be evaluated.";
67  }
68  }
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, std::unique_ptr< const StringObjectFunction< T > > > evaluationMap_
template<class T >
virtual JetDeltaRValueMapProducer< T >::~JetDeltaRValueMapProducer ( )
inlinevirtual

Definition at line 70 of file JetDeltaRValueMapProducer.cc.

70 {}

Member Function Documentation

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

Implements edm::stream::EDProducerBase.

Definition at line 74 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().

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