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 79 of file PATUserDataMerger.h.

Constructor & Destructor Documentation

◆ PATUserDataMerger() [1/2]

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

Definition at line 81 of file PATUserDataMerger.h.

81 {}

◆ PATUserDataMerger() [2/2]

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.

104  : userDataSrc_(iConfig.getParameter<std::vector<edm::InputTag>>("src")),
105  labelPostfixesToStrip_(iConfig.existsAs<std::vector<std::string>>("labelPostfixesToStrip")
106  ? iConfig.getParameter<std::vector<std::string>>("labelPostfixesToStrip")
107  : std::vector<std::string>()) {
108  for (std::vector<edm::InputTag>::const_iterator input_it = userDataSrc_.begin(); input_it != userDataSrc_.end();
109  ++input_it) {
110  userDataSrcTokens_.push_back(iC.consumes<typename Operation::product_type>(*input_it));
111  }
112  for (edm::InputTag tag : userDataSrc_) { // copy by value
113  for (const std::string &stripme : labelPostfixesToStrip_) {
114  auto match = tag.label().rfind(stripme);
115  if (match == (tag.label().length() - stripme.length())) {
116  tag = edm::InputTag(tag.label().substr(0, match), tag.instance(), tag.process());
117  }
118  }
119  labels_.push_back(tag.encode());
120  }
121 }

◆ ~PATUserDataMerger()

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

Definition at line 83 of file PATUserDataMerger.h.

83 {}

Member Function Documentation

◆ add()

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

Definition at line 140 of file PATUserDataMerger.h.

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

Referenced by counter.Counter::register().

◆ fillDescription()

template<class ObjectType , typename Operation >
void pat::PATUserDataMerger< ObjectType, Operation >::fillDescription ( edm::ParameterSetDescription iDesc)
static

Definition at line 166 of file PATUserDataMerger.h.

166  {
167  iDesc.add<std::vector<edm::InputTag>>("src");
168  iDesc.addOptional<std::vector<std::string>>("labelPostfixesToStrip", std::vector<std::string>());
169 }

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

Member Data Documentation

◆ labelPostfixesToStrip_

template<typename ObjectType, typename Operation>
std::vector<std::string> pat::PATUserDataMerger< ObjectType, Operation >::labelPostfixesToStrip_
private

Definition at line 94 of file PATUserDataMerger.h.

◆ labels_

template<typename ObjectType, typename Operation>
std::vector<std::string> pat::PATUserDataMerger< ObjectType, Operation >::labels_
private

Definition at line 94 of file PATUserDataMerger.h.

◆ loader_

template<typename ObjectType, typename Operation>
Operation pat::PATUserDataMerger< ObjectType, Operation >::loader_
private

Definition at line 95 of file PATUserDataMerger.h.

◆ userDataSrc_

template<typename ObjectType, typename Operation>
std::vector<edm::InputTag> pat::PATUserDataMerger< ObjectType, Operation >::userDataSrc_
private

Definition at line 92 of file PATUserDataMerger.h.

◆ userDataSrcTokens_

template<typename ObjectType, typename Operation>
std::vector<edm::EDGetTokenT<typename Operation::product_type> > pat::PATUserDataMerger< ObjectType, Operation >::userDataSrcTokens_
private

Definition at line 93 of file PATUserDataMerger.h.

edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89285
electronProducer_cfi.userData
userData
Definition: electronProducer_cfi.py:19
edm::ParameterSet::existsAs
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:171
edm::Handle
Definition: AssociativeIterator.h:50
edm::ParameterSetDescription::addOptional
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:105
pat::PATUserDataMerger::labels_
std::vector< std::string > labels_
Definition: PATUserDataMerger.h:94
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
edm::ConsumesCollector::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: ConsumesCollector.h:55
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
match
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::Ptr< reco::Candidate >
pat::PATUserDataMerger::labelPostfixesToStrip_
std::vector< std::string > labelPostfixesToStrip_
Definition: PATUserDataMerger.h:94
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
pat::PATUserDataMerger::loader_
Operation loader_
Definition: PATUserDataMerger.h:95
pat::PATUserDataMerger::userDataSrcTokens_
std::vector< edm::EDGetTokenT< typename Operation::product_type > > userDataSrcTokens_
Definition: PATUserDataMerger.h:93
edm::InputTag
Definition: InputTag.h:15
pat::PATUserDataMerger::userDataSrc_
std::vector< edm::InputTag > userDataSrc_
Definition: PATUserDataMerger.h:92