CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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)
 
 ~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.9 2013/02/27 23:26:56 wmtan Exp

Definition at line 53 of file PATUserDataHelper.h.

Member Typedef Documentation

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

Definition at line 57 of file PATUserDataHelper.h.

Constructor & Destructor Documentation

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

Definition at line 59 of file PATUserDataHelper.h.

59 {}
template<class ObjectType >
pat::PATUserDataHelper< ObjectType >::PATUserDataHelper ( const edm::ParameterSet iConfig)

Definition at line 90 of file PATUserDataHelper.h.

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

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

Definition at line 61 of file PATUserDataHelper.h.

61 {}

Member Function Documentation

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

Definition at line 126 of file PATUserDataHelper.h.

129 {
130 
131  // Add "complex" user data to the PAT object
132  userDataMerger_.add( patObject, iEvent, iSetup );
133  userFloatMerger_.add( patObject, iEvent, iSetup );
134  userIntMerger_.add( patObject, iEvent, iSetup );
135  userCandMerger_.add( patObject, iEvent, iSetup );
136 
137  // Add "inline" user-selected functions to the PAT object
138  typename std::vector<function_type>::const_iterator funcBegin = functions_.begin(),
139  funcEnd = functions_.end(),
140  funcIt = funcBegin;
141  if ( functionLabels_.size() == functions_.size() ) {
142  for ( ; funcIt != funcEnd; ++funcIt) {
143  double d = (*funcIt)( patObject );
144  patObject.addUserFloat( functionLabels_[funcIt - funcBegin], d );
145  }
146  }
147 
148 
149 }
pat::PATUserDataMerger< ObjectType, pat::helper::AddUserFloat > userFloatMerger_
pat::PATUserDataMerger< ObjectType, pat::helper::AddUserPtr > userDataMerger_
pat::PATUserDataMerger< ObjectType, pat::helper::AddUserCand > userCandMerger_
std::vector< std::string > functionLabels_
int iEvent
Definition: GenABIO.cc:243
std::vector< function_type > functions_
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 153 of file PATUserDataHelper.h.

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

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

154 {
155  edm::ParameterSetDescription dataMergerPSet;
157  iDesc.add("userClasses", dataMergerPSet);
158  iDesc.add("userFloats", dataMergerPSet);
159  iDesc.add("userInts", dataMergerPSet);
160  iDesc.add("userCands", dataMergerPSet);
161  std::vector<std::string> emptyVectorOfStrings;
162  iDesc.add<std::vector<std::string> >("userFunctions",emptyVectorOfStrings);
163  iDesc.add<std::vector<std::string> >("userFunctionLabels",emptyVectorOfStrings);
164 }
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 79 of file PATUserDataHelper.h.

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

Definition at line 73 of file PATUserDataHelper.h.

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

Definition at line 75 of file PATUserDataHelper.h.

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

Definition at line 77 of file PATUserDataHelper.h.