CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
pat::PATUserDataMerger< ObjectType, Operation > Class Template Reference

Assimilates pat::UserData into pat objects. More...

#include "PhysicsTools/PatAlgos/interface/PATUserDataMerger.h"

Public Member Functions

void add (ObjectType &patObject, edm::Event const &iEvent, edm::EventSetup const &iSetup)
 
 PATUserDataMerger ()
 
 PATUserDataMerger (const edm::ParameterSet &iConfig, edm::ConsumesCollector &iC)
 
 ~PATUserDataMerger ()
 

Static Public Member Functions

static void fillDescription (edm::ParameterSetDescription &iDesc)
 

Private Attributes

std::vector< std::string > labelPostfixesToStrip_
 
std::vector< std::string > labels_
 
Operation loader_
 
std::vector< edm::InputTaguserDataSrc_
 
std::vector< edm::EDGetTokenT< typename Operation::product_type > > userDataSrcTokens_
 

Detailed Description

template<typename ObjectType, typename Operation>
class pat::PATUserDataMerger< ObjectType, Operation >

Assimilates pat::UserData into pat objects.

This expects one input: src: The data to add to the objects that get passed to this object, which are ValueMaps to some type (like UserData or double).

This will be called from PATUserDataHelper to handle the templated cases like UserData or double. PATUserDataHelper will then add all the instantiated cases.

Author
Salvatore Rappoccio
Version
Id
PATUserDataMerger.h,v 1.10 2011/10/26 17:01:25 vadler Exp

Definition at line 74 of file PATUserDataMerger.h.

Constructor & Destructor Documentation

template<typename ObjectType, typename Operation>
pat::PATUserDataMerger< ObjectType, Operation >::PATUserDataMerger ( )
inline

Definition at line 78 of file PATUserDataMerger.h.

78 {}
template<typename ObjectType , typename Operation >
pat::PATUserDataMerger< ObjectType, Operation >::PATUserDataMerger ( const edm::ParameterSet iConfig,
edm::ConsumesCollector iC 
)

Definition at line 102 of file PATUserDataMerger.h.

References edm::ConsumesCollector::consumes(), pat::PATUserDataMerger< ObjectType, Operation >::labelPostfixesToStrip_, pat::PATUserDataMerger< ObjectType, Operation >::labels_, match(), AlCaHLTBitMon_QueryRunRegistry::string, GlobalPosition_Frontier_DevDB_cff::tag, pat::PATUserDataMerger< ObjectType, Operation >::userDataSrc_, and pat::PATUserDataMerger< ObjectType, Operation >::userDataSrcTokens_.

102  :
103  userDataSrc_(iConfig.getParameter<std::vector<edm::InputTag> >("src")),
104  labelPostfixesToStrip_(iConfig.existsAs<std::vector<std::string>>("labelPostfixesToStrip") ? iConfig.getParameter<std::vector<std::string>>("labelPostfixesToStrip") : std::vector<std::string>())
105 {
106  for ( std::vector<edm::InputTag>::const_iterator input_it = userDataSrc_.begin(); input_it != userDataSrc_.end(); ++input_it ) {
107  userDataSrcTokens_.push_back( iC.consumes< typename Operation::product_type >( *input_it ) );
108  }
109  for (edm::InputTag tag : userDataSrc_) { // copy by value
110  for (const std::string & stripme : labelPostfixesToStrip_) {
111  auto match = tag.label().rfind(stripme);
112  if (match == (tag.label().length() - stripme.length())) {
113  tag = edm::InputTag(tag.label().substr(0, match), tag.instance(), tag.process());
114  }
115  }
116  labels_.push_back(tag.encode());
117  }
118 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
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:186
std::vector< edm::EDGetTokenT< typename Operation::product_type > > userDataSrcTokens_
std::vector< edm::InputTag > userDataSrc_
std::vector< std::string > labels_
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
std::vector< std::string > labelPostfixesToStrip_
template<typename ObjectType, typename Operation>
pat::PATUserDataMerger< ObjectType, Operation >::~PATUserDataMerger ( )
inline

Definition at line 80 of file PATUserDataMerger.h.

80 {}

Member Function Documentation

template<typename ObjectType, typename Operation>
void pat::PATUserDataMerger< ObjectType, Operation >::add ( ObjectType &  patObject,
edm::Event const &  iEvent,
edm::EventSetup const &  iSetup 
)

Definition at line 139 of file PATUserDataMerger.h.

References edm::Event::getByToken(), pat::PATUserDataMerger< ObjectType, Operation >::labels_, pat::PATUserDataMerger< ObjectType, Operation >::loader_, AlCaHLTBitMon_QueryRunRegistry::string, electronProducer_cfi::userData, and pat::PATUserDataMerger< ObjectType, Operation >::userDataSrcTokens_.

Referenced by pat::PATUserDataHelper< ObjectType >::add(), and counter.Counter::register().

142 {
143 
144  typename std::vector<edm::EDGetTokenT<typename Operation::product_type> >::const_iterator token_begin = userDataSrcTokens_.begin(), token_it = userDataSrcTokens_.begin(), token_end = userDataSrcTokens_.end();
145 
146  for ( ; token_it != token_end; ++token_it ) {
147  const std::string & encoded = (labels_.at(token_it - token_begin));
148 
149  // Declare the object handles:
150  // ValueMap containing the values, or edm::Ptr's to the UserData that
151  // is associated to those PAT Objects
153 
154  // Get the objects by label
155  if ( encoded.size() == 0 ) continue;
156  iEvent.getByToken( *token_it, userData );
157 
158  edm::Ptr<reco::Candidate> recoObject = patObject.originalObjectRef();
159  loader_.addData( patObject, encoded, (*userData)[recoObject]);
160 
161  }
162 
163 }
std::vector< edm::EDGetTokenT< typename Operation::product_type > > userDataSrcTokens_
int iEvent
Definition: GenABIO.cc:230
std::vector< std::string > labels_
template<class ObjectType , typename Operation >
void pat::PATUserDataMerger< ObjectType, Operation >::fillDescription ( edm::ParameterSetDescription iDesc)
static

Definition at line 167 of file PATUserDataMerger.h.

References edm::ParameterSetDescription::add(), and edm::ParameterSetDescription::addOptional().

Referenced by pat::PATUserDataHelper< ObjectType >::fillDescription().

168 {
169  iDesc.add<std::vector<edm::InputTag> >("src");
170  iDesc.addOptional<std::vector<std::string>>("labelPostfixesToStrip", std::vector<std::string>());
171 }
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
ParameterDescriptionBase * add(U const &iLabel, T const &value)

Member Data Documentation

template<typename ObjectType, typename Operation>
std::vector<std::string> pat::PATUserDataMerger< ObjectType, Operation >::labelPostfixesToStrip_
private
template<typename ObjectType, typename Operation>
std::vector<std::string> pat::PATUserDataMerger< ObjectType, Operation >::labels_
private
template<typename ObjectType, typename Operation>
Operation pat::PATUserDataMerger< ObjectType, Operation >::loader_
private
template<typename ObjectType, typename Operation>
std::vector<edm::InputTag> pat::PATUserDataMerger< ObjectType, Operation >::userDataSrc_
private
template<typename ObjectType, typename Operation>
std::vector<edm::EDGetTokenT<typename Operation::product_type> > pat::PATUserDataMerger< ObjectType, Operation >::userDataSrcTokens_
private