CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Member Functions | Private Attributes
pat::PATUserDataHelper< ObjectType > Class Template Reference

Assists in assimilating all pat::UserData into pat objects. More...

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

Public Types

typedef StringObjectFunction< ObjectType > function_type
 

Public Member Functions

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

Static Public Member Functions

static void fillDescription (edm::ParameterSetDescription &iDesc)
 

Private Attributes

std::vector< std::string > functionLabels_
 
std::vector< std::string > functionNames_
 
std::vector< function_typefunctions_
 
pat::PATUserDataMerger< ObjectType, pat::helper::AddUserCanduserCandMerger_
 
pat::PATUserDataMerger< ObjectType, pat::helper::AddUserPtruserDataMerger_
 
pat::PATUserDataMerger< ObjectType, pat::helper::AddUserFloatuserFloatMerger_
 
pat::PATUserDataMerger< ObjectType, pat::helper::AddUserIntuserIntMerger_
 

Detailed Description

template<class ObjectType>
class pat::PATUserDataHelper< ObjectType >

Assists in assimilating all pat::UserData into pat objects.

      This will pull the following from the event stream (if they exist) and put them into the
  object in question, all indexed by the reco objects that make up the pat objects in question:

    ValueMap<double>
    ValueMap<int>
    ValueMap<Ptr<UserData> >
    ValueMap<CandidatePtr>

  This is accomplished by using PATUserDataMergers.

  This also can add "in situ" string-parser-based methods directly.
Author
Salvatore Rappoccio
Version
Id
PATUserDataHelper.h,v 1.8 2010/02/20 21:00:13 wmtan Exp

Definition at line 49 of file PATUserDataHelper.h.

Member Typedef Documentation

◆ function_type

template<class ObjectType>
typedef StringObjectFunction<ObjectType> pat::PATUserDataHelper< ObjectType >::function_type

Definition at line 51 of file PATUserDataHelper.h.

Constructor & Destructor Documentation

◆ PATUserDataHelper() [1/2]

template<class ObjectType>
pat::PATUserDataHelper< ObjectType >::PATUserDataHelper ( )
inline

Definition at line 53 of file PATUserDataHelper.h.

53 {}

◆ PATUserDataHelper() [2/2]

template<class ObjectType >
pat::PATUserDataHelper< ObjectType >::PATUserDataHelper ( const edm::ParameterSet iConfig,
edm::ConsumesCollector &&  iC 
)

Definition at line 81 of file PATUserDataHelper.h.

82  : userDataMerger_(iConfig.getParameter<edm::ParameterSet>("userClasses"), iC),
83  userFloatMerger_(iConfig.getParameter<edm::ParameterSet>("userFloats"), iC),
84  userIntMerger_(iConfig.getParameter<edm::ParameterSet>("userInts"), iC),
85  userCandMerger_(iConfig.getParameter<edm::ParameterSet>("userCands"), iC),
86  functionNames_(iConfig.getParameter<std::vector<std::string> >("userFunctions")),
87  functionLabels_(iConfig.getParameter<std::vector<std::string> >("userFunctionLabels")) {
88  // Make sure the sizes match
89  if (functionNames_.size() != functionLabels_.size()) {
90  throw cms::Exception("Size mismatch")
91  << "userFunctions and userFunctionLabels do not have the same size, they must be the same\n";
92  }
93  // Loop over the function names, create a new string-parser function object
94  // with all of them. This operates on ObjectType
95  std::vector<std::string>::const_iterator funcBegin = functionNames_.begin(), funcEnd = functionNames_.end(),
96  funcIt = funcBegin;
97  for (; funcIt != funcEnd; ++funcIt) {
98  functions_.push_back(StringObjectFunction<ObjectType>(*funcIt));
99  }
100  }

◆ ~PATUserDataHelper()

template<class ObjectType>
pat::PATUserDataHelper< ObjectType >::~PATUserDataHelper ( )
inline

Definition at line 55 of file PATUserDataHelper.h.

55 {}

Member Function Documentation

◆ add()

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

Definition at line 114 of file PATUserDataHelper.h.

116  {
117  // Add "complex" user data to the PAT object
118  userDataMerger_.add(patObject, iEvent, iSetup);
119  userFloatMerger_.add(patObject, iEvent, iSetup);
120  userIntMerger_.add(patObject, iEvent, iSetup);
121  userCandMerger_.add(patObject, iEvent, iSetup);
122 
123  // Add "inline" user-selected functions to the PAT object
124  typename std::vector<function_type>::const_iterator funcBegin = functions_.begin(), funcEnd = functions_.end(),
125  funcIt = funcBegin;
126  if (functionLabels_.size() == functions_.size()) {
127  for (; funcIt != funcEnd; ++funcIt) {
128  double d = (*funcIt)(patObject);
129  patObject.addUserFloat(functionLabels_[funcIt - funcBegin], d);
130  }
131  }
132  }

Referenced by pat::PATJetUpdater::produce(), pat::PATMETProducer::produce(), pat::PATCompositeCandidateProducer::produce(), pat::PATGenericParticleProducer::produce(), pat::PATPFParticleProducer::produce(), pat::PATJetProducer::produce(), pat::PATTauProducer::produce(), pat::PATPhotonProducer::produce(), pat::PATElectronProducer::produce(), pat::PATMuonProducer::produce(), and counter.Counter::register().

◆ fillDescription()

template<class ObjectType >
void pat::PATUserDataHelper< ObjectType >::fillDescription ( edm::ParameterSetDescription iDesc)
static

Definition at line 135 of file PATUserDataHelper.h.

135  {
136  edm::ParameterSetDescription dataMergerPSet;
138  iDesc.add("userClasses", dataMergerPSet);
139  iDesc.add("userFloats", dataMergerPSet);
140  iDesc.add("userInts", dataMergerPSet);
141  iDesc.add("userCands", dataMergerPSet);
142  std::vector<std::string> emptyVectorOfStrings;
143  iDesc.add<std::vector<std::string> >("userFunctions", emptyVectorOfStrings);
144  iDesc.add<std::vector<std::string> >("userFunctionLabels", emptyVectorOfStrings);
145  }

Referenced by pat::PATJetUpdater::fillDescriptions(), pat::PATMETProducer::fillDescriptions(), pat::PATJetProducer::fillDescriptions(), pat::PATTauProducer::fillDescriptions(), pat::PATElectronProducer::fillDescriptions(), pat::PATPhotonProducer::fillDescriptions(), and pat::PATMuonProducer::fillDescriptions().

Member Data Documentation

◆ functionLabels_

template<class ObjectType>
std::vector<std::string> pat::PATUserDataHelper< ObjectType >::functionLabels_
private

Definition at line 75 of file PATUserDataHelper.h.

◆ functionNames_

template<class ObjectType>
std::vector<std::string> pat::PATUserDataHelper< ObjectType >::functionNames_
private

Definition at line 74 of file PATUserDataHelper.h.

◆ functions_

template<class ObjectType>
std::vector<function_type> pat::PATUserDataHelper< ObjectType >::functions_
private

Definition at line 76 of file PATUserDataHelper.h.

◆ userCandMerger_

template<class ObjectType>
pat::PATUserDataMerger<ObjectType, pat::helper::AddUserCand> pat::PATUserDataHelper< ObjectType >::userCandMerger_
private

Definition at line 71 of file PATUserDataHelper.h.

◆ userDataMerger_

template<class ObjectType>
pat::PATUserDataMerger<ObjectType, pat::helper::AddUserPtr> pat::PATUserDataHelper< ObjectType >::userDataMerger_
private

Definition at line 65 of file PATUserDataHelper.h.

◆ userFloatMerger_

template<class ObjectType>
pat::PATUserDataMerger<ObjectType, pat::helper::AddUserFloat> pat::PATUserDataHelper< ObjectType >::userFloatMerger_
private

Definition at line 67 of file PATUserDataHelper.h.

◆ userIntMerger_

template<class ObjectType>
pat::PATUserDataMerger<ObjectType, pat::helper::AddUserInt> pat::PATUserDataHelper< ObjectType >::userIntMerger_
private

Definition at line 69 of file PATUserDataHelper.h.

edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
StringObjectFunction
Definition: StringObjectFunction.h:16
pat::PATUserDataHelper::userIntMerger_
pat::PATUserDataMerger< ObjectType, pat::helper::AddUserInt > userIntMerger_
Definition: PATUserDataHelper.h:69
pat::PATUserDataHelper::userCandMerger_
pat::PATUserDataMerger< ObjectType, pat::helper::AddUserCand > userCandMerger_
Definition: PATUserDataHelper.h:71
pat::PATUserDataHelper::functionLabels_
std::vector< std::string > functionLabels_
Definition: PATUserDataHelper.h:75
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
pat::PATUserDataMerger::fillDescription
static void fillDescription(edm::ParameterSetDescription &iDesc)
Definition: PATUserDataMerger.h:166
pat::PATUserDataHelper::userFloatMerger_
pat::PATUserDataMerger< ObjectType, pat::helper::AddUserFloat > userFloatMerger_
Definition: PATUserDataHelper.h:67
pat::PATUserDataHelper::userDataMerger_
pat::PATUserDataMerger< ObjectType, pat::helper::AddUserPtr > userDataMerger_
Definition: PATUserDataHelper.h:65
pat::PATUserDataHelper::functionNames_
std::vector< std::string > functionNames_
Definition: PATUserDataHelper.h:74
edm::ParameterSet
Definition: ParameterSet.h:36
iEvent
int iEvent
Definition: GenABIO.cc:224
pat::PATUserDataMerger::add
void add(ObjectType &patObject, edm::Event const &iEvent, edm::EventSetup const &iSetup)
Definition: PATUserDataMerger.h:140
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Exception
Definition: hltDiff.cc:246
ztail.d
d
Definition: ztail.py:151
pat::PATUserDataHelper::functions_
std::vector< function_type > functions_
Definition: PATUserDataHelper.h:76