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

Constructor & Destructor Documentation

◆ PATUserDataMerger() [1/2]

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

Definition at line 80 of file PATUserDataMerger.h.

80 {}

◆ PATUserDataMerger() [2/2]

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

Definition at line 101 of file PATUserDataMerger.h.

103  : userDataSrc_(iConfig.getParameter<std::vector<edm::InputTag>>("src")),
104  labelPostfixesToStrip_(iConfig.existsAs<std::vector<std::string>>("labelPostfixesToStrip")
105  ? iConfig.getParameter<std::vector<std::string>>("labelPostfixesToStrip")
106  : std::vector<std::string>()) {
107  for (std::vector<edm::InputTag>::const_iterator input_it = userDataSrc_.begin(); input_it != userDataSrc_.end();
108  ++input_it) {
109  userDataSrcTokens_.push_back(iC.consumes<typename Operation::product_type>(*input_it));
110  }
111  for (edm::InputTag tag : userDataSrc_) { // copy by value
112  for (const std::string &stripme : labelPostfixesToStrip_) {
113  auto match = tag.label().rfind(stripme);
114  if (match == (tag.label().length() - stripme.length())) {
115  tag = edm::InputTag(tag.label().substr(0, match), tag.instance(), tag.process());
116  }
117  }
118  labels_.push_back(tag.encode());
119  }
120 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
std::vector< edm::EDGetTokenT< typename Operation::product_type > > userDataSrcTokens_
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:172
std::vector< edm::InputTag > userDataSrc_
std::vector< std::string > labels_
std::vector< std::string > labelPostfixesToStrip_

◆ ~PATUserDataMerger()

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

Definition at line 82 of file PATUserDataMerger.h.

82 {}

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

Referenced by counter.Counter::register().

141  {
142  typename std::vector<edm::EDGetTokenT<typename Operation::product_type>>::const_iterator
143  token_begin = userDataSrcTokens_.begin(),
144  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.empty())
156  continue;
157  iEvent.getByToken(*token_it, userData);
158 
159  edm::Ptr<reco::Candidate> recoObject = patObject.originalObjectRef();
160  loader_.addData(patObject, encoded, (*userData)[recoObject]);
161  }
162 }
std::vector< edm::EDGetTokenT< typename Operation::product_type > > userDataSrcTokens_
int iEvent
Definition: GenABIO.cc:224
std::vector< std::string > labels_

◆ fillDescription()

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

Definition at line 165 of file PATUserDataMerger.h.

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

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

Member Data Documentation

◆ labelPostfixesToStrip_

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

Definition at line 93 of file PATUserDataMerger.h.

◆ labels_

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

Definition at line 93 of file PATUserDataMerger.h.

◆ loader_

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

Definition at line 94 of file PATUserDataMerger.h.

◆ userDataSrc_

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

Definition at line 91 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 92 of file PATUserDataMerger.h.