CMS 3D CMS Logo

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>

List of all members.

Public Types

typedef StringObjectFunction
< ObjectType > 
function_type

Public Member Functions

void add (ObjectType &patObject, edm::Event const &iEvent, edm::EventSetup const &iSetup)
 PATUserDataHelper (const edm::ParameterSet &iConfig)
 PATUserDataHelper ()
 ~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 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.

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

Definition at line 90 of file PATUserDataHelper.h.

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

                                                                                :
  userDataMerger_   (iConfig.getParameter<edm::ParameterSet>("userClasses")),
  userFloatMerger_  (iConfig.getParameter<edm::ParameterSet>("userFloats")),
  userIntMerger_    (iConfig.getParameter<edm::ParameterSet>("userInts")),
  userCandMerger_   (iConfig.getParameter<edm::ParameterSet>("userCands")),
  functionNames_    (iConfig.getParameter<std::vector<std::string> >("userFunctions")),
  functionLabels_   (iConfig.getParameter<std::vector<std::string> >("userFunctionLabels"))
{

  // Make sure the sizes match
  if ( functionNames_.size() != functionLabels_.size() ) {
    throw cms::Exception("Size mismatch") << "userFunctions and userFunctionLabels do not have the same size, they must be the same\n";
  }
  // Loop over the function names, create a new string-parser function object 
  // with all of them. This operates on ObjectType
  std::vector<std::string>::const_iterator funcBegin = functionNames_.begin(),
    funcEnd = functionNames_.end(),
    funcIt = funcBegin;
  for ( ; funcIt != funcEnd; ++funcIt) {
    functions_.push_back(  StringObjectFunction<ObjectType>( *funcIt ) );
  }
}
template<class ObjectType>
pat::PATUserDataHelper< ObjectType >::~PATUserDataHelper ( ) [inline]

Definition at line 61 of file PATUserDataHelper.h.

{}

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.

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

{

  // Add "complex" user data to the PAT object
  userDataMerger_.add(   patObject, iEvent, iSetup );
  userFloatMerger_.add(  patObject, iEvent, iSetup );
  userIntMerger_.add(    patObject, iEvent, iSetup );
  userCandMerger_.add(   patObject, iEvent, iSetup );

  // Add "inline" user-selected functions to the PAT object
  typename std::vector<function_type>::const_iterator funcBegin = functions_.begin(),
    funcEnd = functions_.end(),
    funcIt = funcBegin;
  if ( functionLabels_.size() == functions_.size() ) {
    for ( ; funcIt != funcEnd; ++funcIt) {
      double d = (*funcIt)( patObject );
      patObject.addUserFloat( functionLabels_[funcIt - funcBegin], d );
    }
  }

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

Definition at line 153 of file PATUserDataHelper.h.

References edm::ParameterSetDescription::add().

{
  edm::ParameterSetDescription dataMergerPSet;
  pat::PATUserDataMerger<ObjectType, pat::helper::AddUserPtr>::fillDescription(dataMergerPSet);
  iDesc.add("userClasses", dataMergerPSet);
  iDesc.add("userFloats", dataMergerPSet);
  iDesc.add("userInts", dataMergerPSet);
  iDesc.add("userCands", dataMergerPSet);
  std::vector<std::string> emptyVectorOfStrings;
  iDesc.add<std::vector<std::string> >("userFunctions",emptyVectorOfStrings);
  iDesc.add<std::vector<std::string> >("userFunctionLabels",emptyVectorOfStrings);
}

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.