CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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::AddUserCand
userCandMerger_
 
pat::PATUserDataMerger
< ObjectType,
pat::helper::AddUserPtr
userDataMerger_
 
pat::PATUserDataMerger
< ObjectType,
pat::helper::AddUserFloat
userFloatMerger_
 
pat::PATUserDataMerger
< ObjectType,
pat::helper::AddUserInt
userIntMerger_
 

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 48 of file PATUserDataHelper.h.

Member Typedef Documentation

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

Definition at line 50 of file PATUserDataHelper.h.

Constructor & Destructor Documentation

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

Definition at line 52 of file PATUserDataHelper.h.

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

Definition at line 80 of file PATUserDataHelper.h.

References Exception, pat::PATUserDataHelper< ObjectType >::functionLabels_, pat::PATUserDataHelper< ObjectType >::functionNames_, and pat::PATUserDataHelper< ObjectType >::functions_.

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

Definition at line 54 of file PATUserDataHelper.h.

54 {}

Member Function Documentation

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

Definition at line 113 of file PATUserDataHelper.h.

References ztail::d.

Referenced by counter.Counter::register().

115  {
116  // Add "complex" user data to the PAT object
117  userDataMerger_.add(patObject, iEvent, iSetup);
118  userFloatMerger_.add(patObject, iEvent, iSetup);
119  userIntMerger_.add(patObject, iEvent, iSetup);
120  userCandMerger_.add(patObject, iEvent, iSetup);
121 
122  // Add "inline" user-selected functions to the PAT object
123  typename std::vector<function_type>::const_iterator funcBegin = functions_.begin(), funcEnd = functions_.end(),
124  funcIt = funcBegin;
125  if (functionLabels_.size() == functions_.size()) {
126  for (; funcIt != funcEnd; ++funcIt) {
127  double d = (*funcIt)(patObject);
128  patObject.addUserFloat(functionLabels_[funcIt - funcBegin], d);
129  }
130  }
131  }
pat::PATUserDataMerger< ObjectType, pat::helper::AddUserFloat > userFloatMerger_
std::vector< function_type > functions_
pat::PATUserDataMerger< ObjectType, pat::helper::AddUserPtr > userDataMerger_
pat::PATUserDataMerger< ObjectType, pat::helper::AddUserCand > userCandMerger_
std::vector< std::string > functionLabels_
tuple d
Definition: ztail.py:151
int iEvent
Definition: GenABIO.cc:224
void add(ObjectType &patObject, edm::Event const &iEvent, edm::EventSetup const &iSetup)
pat::PATUserDataMerger< ObjectType, pat::helper::AddUserInt > userIntMerger_
template<class ObjectType >
void pat::PATUserDataHelper< ObjectType >::fillDescription ( edm::ParameterSetDescription iDesc)
static

Definition at line 134 of file PATUserDataHelper.h.

References edm::ParameterSetDescription::add(), and pat::PATUserDataMerger< ObjectType, Operation >::fillDescription().

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

134  {
135  edm::ParameterSetDescription dataMergerPSet;
137  iDesc.add("userClasses", dataMergerPSet);
138  iDesc.add("userFloats", dataMergerPSet);
139  iDesc.add("userInts", dataMergerPSet);
140  iDesc.add("userCands", dataMergerPSet);
141  std::vector<std::string> emptyVectorOfStrings;
142  iDesc.add<std::vector<std::string> >("userFunctions", emptyVectorOfStrings);
143  iDesc.add<std::vector<std::string> >("userFunctionLabels", emptyVectorOfStrings);
144  }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static void fillDescription(edm::ParameterSetDescription &iDesc)

Member Data Documentation

template<class ObjectType>
std::vector<std::string> pat::PATUserDataHelper< ObjectType >::functionLabels_
private
template<class ObjectType>
std::vector<std::string> pat::PATUserDataHelper< ObjectType >::functionNames_
private
template<class ObjectType>
std::vector<function_type> pat::PATUserDataHelper< ObjectType >::functions_
private
template<class ObjectType>
pat::PATUserDataMerger<ObjectType, pat::helper::AddUserCand> pat::PATUserDataHelper< ObjectType >::userCandMerger_
private

Definition at line 70 of file PATUserDataHelper.h.

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

Definition at line 64 of file PATUserDataHelper.h.

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

Definition at line 66 of file PATUserDataHelper.h.

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

Definition at line 68 of file PATUserDataHelper.h.