Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:01:02

0001 #ifndef __CommonTools_CandAlgos_ModifyObjectValueBase_h__
0002 #define __CommonTools_CandAlgos_ModifyObjectValueBase_h__
0003 
0004 #include "DataFormats/PatCandidates/interface/Electron.h"
0005 #include "DataFormats/PatCandidates/interface/Photon.h"
0006 #include "DataFormats/PatCandidates/interface/Muon.h"
0007 #include "DataFormats/PatCandidates/interface/Tau.h"
0008 #include "DataFormats/PatCandidates/interface/Jet.h"
0009 
0010 #include "FWCore/Utilities/interface/Exception.h"
0011 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0012 #include "FWCore/Framework/interface/Event.h"
0013 #include "FWCore/Framework/interface/EventSetup.h"
0014 #include "FWCore/Framework/interface/ConsumesCollector.h"
0015 
0016 #include <string>
0017 
0018 class ModifyObjectValueBase {
0019 public:
0020   ModifyObjectValueBase(const edm::ParameterSet& conf) : name_(conf.getParameter<std::string>("modifierName")) {}
0021 
0022   virtual ~ModifyObjectValueBase() {}
0023 
0024   virtual void setEvent(const edm::Event&) {}
0025   virtual void setEventContent(const edm::EventSetup&) {}
0026 
0027   virtual void modifyObject(reco::GsfElectron&) const {
0028     throw cms::Exception("InvalidConfiguration") << name_ << " is not configured to handle reco::GsfElectrons!";
0029   }
0030   virtual void modifyObject(reco::Photon&) const {
0031     throw cms::Exception("InvalidConfiguration") << name_ << " is not configured to handle reco::Photons!";
0032   }
0033   virtual void modifyObject(reco::Muon&) const {
0034     throw cms::Exception("InvalidConfiguration") << name_ << " is not configured to handle reco::Muons!";
0035   }
0036   virtual void modifyObject(reco::BaseTau&) const {
0037     throw cms::Exception("InvalidConfiguration") << name_ << " is not configured to handle reco::Taus!";
0038   }
0039   virtual void modifyObject(reco::Jet&) const {
0040     throw cms::Exception("InvalidConfiguration") << name_ << " is not configured to handle reco::Jets!";
0041   }
0042   // pat modifiers
0043   virtual void modifyObject(pat::Electron&) const {
0044     throw cms::Exception("InvalidConfiguration") << name_ << " is not configured to handle pat::Electrons!";
0045   }
0046   virtual void modifyObject(pat::Photon&) const {
0047     throw cms::Exception("InvalidConfiguration") << name_ << " is not configured to handle pat::Photons!";
0048   }
0049   virtual void modifyObject(pat::Muon&) const {
0050     throw cms::Exception("InvalidConfiguration") << name_ << " is not configured to handle pat::Muons!";
0051   }
0052   virtual void modifyObject(pat::Tau&) const {
0053     throw cms::Exception("InvalidConfiguration") << name_ << " is not configured to handle pat::Taus!";
0054   }
0055   virtual void modifyObject(pat::Jet&) const {
0056     throw cms::Exception("InvalidConfiguration") << name_ << " is not configured to handle pat::Jets!";
0057   }
0058 
0059   const std::string& name() const { return name_; }
0060 
0061 private:
0062   const std::string name_;
0063 };
0064 
0065 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
0066 #include "FWCore/PluginManager/interface/PluginFactory.h"
0067 typedef edmplugin::PluginFactory<ModifyObjectValueBase*(const edm::ParameterSet&, edm::ConsumesCollector&)>
0068     ModifyObjectValueFactory;
0069 #endif
0070 
0071 #endif