Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-07-15 08:47:56

0001 #include "CommonTools/CandAlgos/interface/ModifyObjectValueBase.h"
0002 
0003 #include "FWCore/Utilities/interface/InputTag.h"
0004 #include "FWCore/Utilities/interface/EDGetToken.h"
0005 #include "DataFormats/Common/interface/ValueMap.h"
0006 
0007 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
0008 #include "DataFormats/EgammaCandidates/interface/Photon.h"
0009 
0010 namespace {
0011   const edm::InputTag empty_tag("");
0012   template <typename T, typename U, typename V>
0013   inline void make_consumes(const T& tag, edm::EDGetTokenT<U>& tok, V& sume) {
0014     if (!(empty_tag == tag))
0015       tok = sume.template consumes(tag);
0016   }
0017 }  // namespace
0018 
0019 #include <unordered_map>
0020 
0021 class EGFull5x5ShowerShapeModifierFromValueMaps : public ModifyObjectValueBase {
0022 public:
0023   struct electron_config {
0024     edm::EDGetTokenT<edm::View<pat::Electron>> tok_electron_src;
0025     edm::EDGetTokenT<edm::ValueMap<float>> tok_sigmaEtaEta;
0026     edm::EDGetTokenT<edm::ValueMap<float>> tok_sigmaIetaIeta;
0027     edm::EDGetTokenT<edm::ValueMap<float>> tok_sigmaIphiIphi;
0028     edm::EDGetTokenT<edm::ValueMap<float>> tok_e1x5;
0029     edm::EDGetTokenT<edm::ValueMap<float>> tok_e2x5Max;
0030     edm::EDGetTokenT<edm::ValueMap<float>> tok_e5x5;
0031     edm::EDGetTokenT<edm::ValueMap<float>> tok_r9;
0032     edm::EDGetTokenT<edm::ValueMap<float>> tok_hcalOverEcalDepth1;
0033     edm::EDGetTokenT<edm::ValueMap<float>> tok_hcalOverEcalDepth2;
0034     edm::EDGetTokenT<edm::ValueMap<float>> tok_hcalOverEcalDepth3;
0035     edm::EDGetTokenT<edm::ValueMap<float>> tok_hcalOverEcalDepth4;
0036     edm::EDGetTokenT<edm::ValueMap<float>> tok_hcalOverEcalDepth5;
0037     edm::EDGetTokenT<edm::ValueMap<float>> tok_hcalOverEcalDepth6;
0038     edm::EDGetTokenT<edm::ValueMap<float>> tok_hcalOverEcalDepth7;
0039     edm::EDGetTokenT<edm::ValueMap<float>> tok_hcalOverEcalBcDepth1;
0040     edm::EDGetTokenT<edm::ValueMap<float>> tok_hcalOverEcalBcDepth2;
0041     edm::EDGetTokenT<edm::ValueMap<float>> tok_hcalOverEcalBcDepth3;
0042     edm::EDGetTokenT<edm::ValueMap<float>> tok_hcalOverEcalBcDepth4;
0043     edm::EDGetTokenT<edm::ValueMap<float>> tok_hcalOverEcalBcDepth5;
0044     edm::EDGetTokenT<edm::ValueMap<float>> tok_hcalOverEcalBcDepth6;
0045     edm::EDGetTokenT<edm::ValueMap<float>> tok_hcalOverEcalBcDepth7;
0046   };
0047 
0048   struct photon_config {
0049     edm::EDGetTokenT<edm::View<pat::Photon>> tok_photon_src;
0050     edm::EDGetTokenT<edm::ValueMap<float>> tok_sigmaEtaEta;
0051     edm::EDGetTokenT<edm::ValueMap<float>> tok_sigmaIetaIeta;
0052     edm::EDGetTokenT<edm::ValueMap<float>> tok_e1x5;
0053     edm::EDGetTokenT<edm::ValueMap<float>> tok_e2x5;
0054     edm::EDGetTokenT<edm::ValueMap<float>> tok_e3x3;
0055     edm::EDGetTokenT<edm::ValueMap<float>> tok_e5x5;
0056     edm::EDGetTokenT<edm::ValueMap<float>> tok_maxEnergyXtal;
0057     edm::EDGetTokenT<edm::ValueMap<float>> tok_hcalOverEcalDepth1;
0058     edm::EDGetTokenT<edm::ValueMap<float>> tok_hcalOverEcalDepth2;
0059     edm::EDGetTokenT<edm::ValueMap<float>> tok_hcalOverEcalDepth3;
0060     edm::EDGetTokenT<edm::ValueMap<float>> tok_hcalOverEcalDepth4;
0061     edm::EDGetTokenT<edm::ValueMap<float>> tok_hcalOverEcalDepth5;
0062     edm::EDGetTokenT<edm::ValueMap<float>> tok_hcalOverEcalDepth6;
0063     edm::EDGetTokenT<edm::ValueMap<float>> tok_hcalOverEcalDepth7;
0064     edm::EDGetTokenT<edm::ValueMap<float>> tok_hcalOverEcalBcDepth1;
0065     edm::EDGetTokenT<edm::ValueMap<float>> tok_hcalOverEcalBcDepth2;
0066     edm::EDGetTokenT<edm::ValueMap<float>> tok_hcalOverEcalBcDepth3;
0067     edm::EDGetTokenT<edm::ValueMap<float>> tok_hcalOverEcalBcDepth4;
0068     edm::EDGetTokenT<edm::ValueMap<float>> tok_hcalOverEcalBcDepth5;
0069     edm::EDGetTokenT<edm::ValueMap<float>> tok_hcalOverEcalBcDepth6;
0070     edm::EDGetTokenT<edm::ValueMap<float>> tok_hcalOverEcalBcDepth7;
0071   };
0072 
0073   EGFull5x5ShowerShapeModifierFromValueMaps(const edm::ParameterSet& conf, edm::ConsumesCollector& cc);
0074 
0075   void setEvent(const edm::Event&) final;
0076 
0077   void modifyObject(pat::Electron&) const final;
0078   void modifyObject(pat::Photon&) const final;
0079 
0080 private:
0081   electron_config e_conf;
0082   photon_config ph_conf;
0083   std::vector<edm::Ptr<reco::GsfElectron>> eles_by_oop;  // indexed by original object ptr
0084   std::unordered_map<unsigned, edm::Handle<edm::ValueMap<float>>> ele_vmaps;
0085   std::vector<edm::Ptr<reco::Photon>> phos_by_oop;
0086   std::unordered_map<unsigned, edm::Handle<edm::ValueMap<float>>> pho_vmaps;
0087   mutable unsigned ele_idx,
0088       pho_idx;  // hack here until we figure out why some slimmedPhotons don't have original object ptrs
0089 };
0090 
0091 DEFINE_EDM_PLUGIN(ModifyObjectValueFactory,
0092                   EGFull5x5ShowerShapeModifierFromValueMaps,
0093                   "EGFull5x5ShowerShapeModifierFromValueMaps");
0094 
0095 EGFull5x5ShowerShapeModifierFromValueMaps::EGFull5x5ShowerShapeModifierFromValueMaps(const edm::ParameterSet& conf,
0096                                                                                      edm::ConsumesCollector& cc)
0097     : ModifyObjectValueBase(conf) {
0098   if (conf.exists("electron_config")) {
0099     auto const& electrons = conf.getParameterSet("electron_config");
0100     if (electrons.exists("electronSrc"))
0101       make_consumes(electrons.getParameter<edm::InputTag>("electronSrc"), e_conf.tok_electron_src, cc);
0102     if (electrons.exists("sigmaEtaEta"))
0103       make_consumes(electrons.getParameter<edm::InputTag>("sigmaEtaEta"), e_conf.tok_sigmaEtaEta, cc);
0104     if (electrons.exists("sigmaIetaIeta"))
0105       make_consumes(electrons.getParameter<edm::InputTag>("sigmaIetaIeta"), e_conf.tok_sigmaIetaIeta, cc);
0106     if (electrons.exists("sigmaIphiIphi"))
0107       make_consumes(electrons.getParameter<edm::InputTag>("sigmaIphiIphi"), e_conf.tok_sigmaIphiIphi, cc);
0108     if (electrons.exists("e1x5"))
0109       make_consumes(electrons.getParameter<edm::InputTag>("e1x5"), e_conf.tok_e1x5, cc);
0110     if (electrons.exists("e2x5Max"))
0111       make_consumes(electrons.getParameter<edm::InputTag>("e2x5Max"), e_conf.tok_e2x5Max, cc);
0112     if (electrons.exists("e5x5"))
0113       make_consumes(electrons.getParameter<edm::InputTag>("e5x5"), e_conf.tok_e5x5, cc);
0114     if (electrons.exists("r9"))
0115       make_consumes(electrons.getParameter<edm::InputTag>("r9"), e_conf.tok_r9, cc);
0116     if (electrons.exists("hcalOverEcalDepth1"))
0117       make_consumes(electrons.getParameter<edm::InputTag>("hcalOverEcalDepth1"), e_conf.tok_hcalOverEcalDepth1, cc);
0118     if (electrons.exists("hcalOverEcalDepth2"))
0119       make_consumes(electrons.getParameter<edm::InputTag>("hcalOverEcalDepth2"), e_conf.tok_hcalOverEcalDepth2, cc);
0120     if (electrons.exists("hcalOverEcalDepth3"))
0121       make_consumes(electrons.getParameter<edm::InputTag>("hcalOverEcalDepth3"), e_conf.tok_hcalOverEcalDepth3, cc);
0122     if (electrons.exists("hcalOverEcalDepth4"))
0123       make_consumes(electrons.getParameter<edm::InputTag>("hcalOverEcalDepth4"), e_conf.tok_hcalOverEcalDepth4, cc);
0124     if (electrons.exists("hcalOverEcalDepth5"))
0125       make_consumes(electrons.getParameter<edm::InputTag>("hcalOverEcalDepth5"), e_conf.tok_hcalOverEcalDepth5, cc);
0126     if (electrons.exists("hcalOverEcalDepth6"))
0127       make_consumes(electrons.getParameter<edm::InputTag>("hcalOverEcalDepth6"), e_conf.tok_hcalOverEcalDepth6, cc);
0128     if (electrons.exists("hcalOverEcalDepth7"))
0129       make_consumes(electrons.getParameter<edm::InputTag>("hcalOverEcalDepth7"), e_conf.tok_hcalOverEcalDepth7, cc);
0130     if (electrons.exists("hcalOverEcalBcDepth1"))
0131       make_consumes(electrons.getParameter<edm::InputTag>("hcalOverEcalBcDepth1"), e_conf.tok_hcalOverEcalBcDepth1, cc);
0132     if (electrons.exists("hcalOverEcalBcDepth2"))
0133       make_consumes(electrons.getParameter<edm::InputTag>("hcalOverEcalBcDepth2"), e_conf.tok_hcalOverEcalBcDepth2, cc);
0134     if (electrons.exists("hcalOverEcalBcDepth3"))
0135       make_consumes(electrons.getParameter<edm::InputTag>("hcalOverEcalBcDepth3"), e_conf.tok_hcalOverEcalBcDepth3, cc);
0136     if (electrons.exists("hcalOverEcalBcDepth4"))
0137       make_consumes(electrons.getParameter<edm::InputTag>("hcalOverEcalBcDepth4"), e_conf.tok_hcalOverEcalBcDepth4, cc);
0138     if (electrons.exists("hcalOverEcalBcDepth5"))
0139       make_consumes(electrons.getParameter<edm::InputTag>("hcalOverEcalBcDepth5"), e_conf.tok_hcalOverEcalBcDepth5, cc);
0140     if (electrons.exists("hcalOverEcalBcDepth6"))
0141       make_consumes(electrons.getParameter<edm::InputTag>("hcalOverEcalBcDepth6"), e_conf.tok_hcalOverEcalBcDepth6, cc);
0142     if (electrons.exists("hcalOverEcalBcDepth7"))
0143       make_consumes(electrons.getParameter<edm::InputTag>("hcalOverEcalBcDepth7"), e_conf.tok_hcalOverEcalBcDepth7, cc);
0144   }
0145   if (conf.exists("photon_config")) {
0146     auto const& photons = conf.getParameterSet("photon_config");
0147     if (photons.exists("photonSrc"))
0148       make_consumes(photons.getParameter<edm::InputTag>("photonSrc"), ph_conf.tok_photon_src, cc);
0149     if (photons.exists("sigmaEtaEta"))
0150       make_consumes(photons.getParameter<edm::InputTag>("sigmaEtaEta"), ph_conf.tok_sigmaEtaEta, cc);
0151     if (photons.exists("sigmaIetaIeta"))
0152       make_consumes(photons.getParameter<edm::InputTag>("sigmaIetaIeta"), ph_conf.tok_sigmaIetaIeta, cc);
0153     if (photons.exists("e1x5"))
0154       make_consumes(photons.getParameter<edm::InputTag>("e1x5"), ph_conf.tok_e1x5, cc);
0155     if (photons.exists("e2x5"))
0156       make_consumes(photons.getParameter<edm::InputTag>("e2x5"), ph_conf.tok_e2x5, cc);
0157     if (photons.exists("e3x3"))
0158       make_consumes(photons.getParameter<edm::InputTag>("e3x3"), ph_conf.tok_e3x3, cc);
0159     if (photons.exists("e5x5"))
0160       make_consumes(photons.getParameter<edm::InputTag>("e5x5"), ph_conf.tok_e5x5, cc);
0161     if (photons.exists("maxEnergyXtal"))
0162       make_consumes(photons.getParameter<edm::InputTag>("maxEnergyXtal"), ph_conf.tok_maxEnergyXtal, cc);
0163     if (photons.exists("hcalOverEcalDepth1"))
0164       make_consumes(photons.getParameter<edm::InputTag>("hcalOverEcalDepth1"), ph_conf.tok_hcalOverEcalDepth1, cc);
0165     if (photons.exists("hcalOverEcalDepth2"))
0166       make_consumes(photons.getParameter<edm::InputTag>("hcalOverEcalDepth2"), ph_conf.tok_hcalOverEcalDepth2, cc);
0167     if (photons.exists("hcalOverEcalDepth3"))
0168       make_consumes(photons.getParameter<edm::InputTag>("hcalOverEcalDepth3"), ph_conf.tok_hcalOverEcalDepth3, cc);
0169     if (photons.exists("hcalOverEcalDepth4"))
0170       make_consumes(photons.getParameter<edm::InputTag>("hcalOverEcalDepth4"), ph_conf.tok_hcalOverEcalDepth4, cc);
0171     if (photons.exists("hcalOverEcalDepth5"))
0172       make_consumes(photons.getParameter<edm::InputTag>("hcalOverEcalDepth5"), ph_conf.tok_hcalOverEcalDepth5, cc);
0173     if (photons.exists("hcalOverEcalDepth6"))
0174       make_consumes(photons.getParameter<edm::InputTag>("hcalOverEcalDepth6"), ph_conf.tok_hcalOverEcalDepth6, cc);
0175     if (photons.exists("hcalOverEcalDepth7"))
0176       make_consumes(photons.getParameter<edm::InputTag>("hcalOverEcalDepth7"), ph_conf.tok_hcalOverEcalDepth7, cc);
0177     if (photons.exists("hcalOverEcalBcDepth1"))
0178       make_consumes(photons.getParameter<edm::InputTag>("hcalOverEcalBcDepth1"), ph_conf.tok_hcalOverEcalBcDepth1, cc);
0179     if (photons.exists("hcalOverEcalBcDepth2"))
0180       make_consumes(photons.getParameter<edm::InputTag>("hcalOverEcalBcDepth2"), ph_conf.tok_hcalOverEcalBcDepth2, cc);
0181     if (photons.exists("hcalOverEcalBcDepth3"))
0182       make_consumes(photons.getParameter<edm::InputTag>("hcalOverEcalBcDepth3"), ph_conf.tok_hcalOverEcalBcDepth3, cc);
0183     if (photons.exists("hcalOverEcalBcDepth4"))
0184       make_consumes(photons.getParameter<edm::InputTag>("hcalOverEcalBcDepth4"), ph_conf.tok_hcalOverEcalBcDepth4, cc);
0185     if (photons.exists("hcalOverEcalBcDepth5"))
0186       make_consumes(photons.getParameter<edm::InputTag>("hcalOverEcalBcDepth5"), ph_conf.tok_hcalOverEcalBcDepth5, cc);
0187     if (photons.exists("hcalOverEcalBcDepth6"))
0188       make_consumes(photons.getParameter<edm::InputTag>("hcalOverEcalBcDepth6"), ph_conf.tok_hcalOverEcalBcDepth6, cc);
0189     if (photons.exists("hcalOverEcalBcDepth7"))
0190       make_consumes(photons.getParameter<edm::InputTag>("hcalOverEcalBcDepth7"), ph_conf.tok_hcalOverEcalBcDepth7, cc);
0191   }
0192 
0193   ele_idx = pho_idx = 0;
0194 }
0195 
0196 namespace {
0197   inline void get_product(const edm::Event& evt,
0198                           const edm::EDGetTokenT<edm::ValueMap<float>>& tok,
0199                           std::unordered_map<unsigned, edm::Handle<edm::ValueMap<float>>>& map) {
0200     if (!tok.isUninitialized())
0201       map[tok.index()] = evt.getHandle(tok);
0202   }
0203 }  // namespace
0204 
0205 void EGFull5x5ShowerShapeModifierFromValueMaps::setEvent(const edm::Event& evt) {
0206   eles_by_oop.clear();
0207   phos_by_oop.clear();
0208   ele_vmaps.clear();
0209   pho_vmaps.clear();
0210 
0211   ele_idx = pho_idx = 0;
0212 
0213   if (!e_conf.tok_electron_src.isUninitialized()) {
0214     auto eles = evt.getHandle(e_conf.tok_electron_src);
0215 
0216     eles_by_oop.resize(eles->size());
0217     std::copy(eles->ptrs().begin(), eles->ptrs().end(), eles_by_oop.begin());
0218   }
0219 
0220   get_product(evt, e_conf.tok_sigmaEtaEta, ele_vmaps);
0221   get_product(evt, e_conf.tok_sigmaIetaIeta, ele_vmaps);
0222   get_product(evt, e_conf.tok_sigmaIphiIphi, ele_vmaps);
0223   get_product(evt, e_conf.tok_e1x5, ele_vmaps);
0224   get_product(evt, e_conf.tok_e2x5Max, ele_vmaps);
0225   get_product(evt, e_conf.tok_e5x5, ele_vmaps);
0226   get_product(evt, e_conf.tok_r9, ele_vmaps);
0227   get_product(evt, e_conf.tok_hcalOverEcalDepth1, ele_vmaps);
0228   get_product(evt, e_conf.tok_hcalOverEcalDepth2, ele_vmaps);
0229   get_product(evt, e_conf.tok_hcalOverEcalDepth3, ele_vmaps);
0230   get_product(evt, e_conf.tok_hcalOverEcalDepth4, ele_vmaps);
0231   get_product(evt, e_conf.tok_hcalOverEcalDepth5, ele_vmaps);
0232   get_product(evt, e_conf.tok_hcalOverEcalDepth6, ele_vmaps);
0233   get_product(evt, e_conf.tok_hcalOverEcalDepth7, ele_vmaps);
0234   get_product(evt, e_conf.tok_hcalOverEcalBcDepth1, ele_vmaps);
0235   get_product(evt, e_conf.tok_hcalOverEcalBcDepth2, ele_vmaps);
0236   get_product(evt, e_conf.tok_hcalOverEcalBcDepth3, ele_vmaps);
0237   get_product(evt, e_conf.tok_hcalOverEcalBcDepth4, ele_vmaps);
0238   get_product(evt, e_conf.tok_hcalOverEcalBcDepth5, ele_vmaps);
0239   get_product(evt, e_conf.tok_hcalOverEcalBcDepth6, ele_vmaps);
0240   get_product(evt, e_conf.tok_hcalOverEcalBcDepth7, ele_vmaps);
0241 
0242   if (!ph_conf.tok_photon_src.isUninitialized()) {
0243     auto phos = evt.getHandle(ph_conf.tok_photon_src);
0244 
0245     phos_by_oop.resize(phos->size());
0246     std::copy(phos->ptrs().begin(), phos->ptrs().end(), phos_by_oop.begin());
0247   }
0248 
0249   get_product(evt, ph_conf.tok_sigmaEtaEta, pho_vmaps);
0250   get_product(evt, ph_conf.tok_sigmaIetaIeta, pho_vmaps);
0251   get_product(evt, ph_conf.tok_e1x5, pho_vmaps);
0252   get_product(evt, ph_conf.tok_e2x5, pho_vmaps);
0253   get_product(evt, ph_conf.tok_e3x3, pho_vmaps);
0254   get_product(evt, ph_conf.tok_e5x5, pho_vmaps);
0255   get_product(evt, ph_conf.tok_maxEnergyXtal, pho_vmaps);
0256   get_product(evt, ph_conf.tok_hcalOverEcalDepth1, pho_vmaps);
0257   get_product(evt, ph_conf.tok_hcalOverEcalDepth2, pho_vmaps);
0258   get_product(evt, ph_conf.tok_hcalOverEcalDepth3, pho_vmaps);
0259   get_product(evt, ph_conf.tok_hcalOverEcalDepth4, pho_vmaps);
0260   get_product(evt, ph_conf.tok_hcalOverEcalDepth5, pho_vmaps);
0261   get_product(evt, ph_conf.tok_hcalOverEcalDepth6, pho_vmaps);
0262   get_product(evt, ph_conf.tok_hcalOverEcalDepth7, pho_vmaps);
0263   get_product(evt, ph_conf.tok_hcalOverEcalBcDepth1, pho_vmaps);
0264   get_product(evt, ph_conf.tok_hcalOverEcalBcDepth2, pho_vmaps);
0265   get_product(evt, ph_conf.tok_hcalOverEcalBcDepth3, pho_vmaps);
0266   get_product(evt, ph_conf.tok_hcalOverEcalBcDepth4, pho_vmaps);
0267   get_product(evt, ph_conf.tok_hcalOverEcalBcDepth5, pho_vmaps);
0268   get_product(evt, ph_conf.tok_hcalOverEcalBcDepth6, pho_vmaps);
0269   get_product(evt, ph_conf.tok_hcalOverEcalBcDepth7, pho_vmaps);
0270 }
0271 
0272 namespace {
0273   template <typename T, typename U, typename V>
0274   inline void assignValue(const T& ptr, const U& tok, const V& map, float& value) {
0275     if (!tok.isUninitialized())
0276       value = map.find(tok.index())->second->get(ptr.id(), ptr.key());
0277   }
0278 }  // namespace
0279 
0280 void EGFull5x5ShowerShapeModifierFromValueMaps::modifyObject(pat::Electron& ele) const {
0281   // we encounter two cases here, either we are running AOD -> MINIAOD
0282   // and the value maps are to the reducedEG object, can use original object ptr
0283   // or we are running MINIAOD->MINIAOD and we need to fetch the pat objects to reference
0284   edm::Ptr<reco::Candidate> ptr(ele.originalObjectRef());
0285 
0286   // The calls to this function should be matched to the order of the electrons
0287   // in eles_by_oop. In case it is called too many times, it will throw thanks
0288   // to the use of std::vector<T>::at().
0289   if (!e_conf.tok_electron_src.isUninitialized())
0290     ptr = eles_by_oop.at(ele_idx);
0291 
0292   //now we go through and modify the objects using the valuemaps we read in
0293   auto full5x5 = ele.full5x5_showerShape();
0294   assignValue(ptr, e_conf.tok_sigmaEtaEta, ele_vmaps, full5x5.sigmaEtaEta);
0295   assignValue(ptr, e_conf.tok_sigmaIetaIeta, ele_vmaps, full5x5.sigmaIetaIeta);
0296   assignValue(ptr, e_conf.tok_sigmaIphiIphi, ele_vmaps, full5x5.sigmaIphiIphi);
0297   assignValue(ptr, e_conf.tok_e1x5, ele_vmaps, full5x5.e1x5);
0298   assignValue(ptr, e_conf.tok_e2x5Max, ele_vmaps, full5x5.e2x5Max);
0299   assignValue(ptr, e_conf.tok_e5x5, ele_vmaps, full5x5.e5x5);
0300   assignValue(ptr, e_conf.tok_r9, ele_vmaps, full5x5.r9);
0301   assignValue(ptr, e_conf.tok_hcalOverEcalDepth1, ele_vmaps, full5x5.hcalOverEcal[0]);
0302   assignValue(ptr, e_conf.tok_hcalOverEcalDepth2, ele_vmaps, full5x5.hcalOverEcal[1]);
0303   assignValue(ptr, e_conf.tok_hcalOverEcalDepth3, ele_vmaps, full5x5.hcalOverEcal[2]);
0304   assignValue(ptr, e_conf.tok_hcalOverEcalDepth4, ele_vmaps, full5x5.hcalOverEcal[3]);
0305   assignValue(ptr, e_conf.tok_hcalOverEcalDepth5, ele_vmaps, full5x5.hcalOverEcal[4]);
0306   assignValue(ptr, e_conf.tok_hcalOverEcalDepth6, ele_vmaps, full5x5.hcalOverEcal[5]);
0307   assignValue(ptr, e_conf.tok_hcalOverEcalDepth7, ele_vmaps, full5x5.hcalOverEcal[6]);
0308   assignValue(ptr, e_conf.tok_hcalOverEcalBcDepth1, ele_vmaps, full5x5.hcalOverEcalBc[0]);
0309   assignValue(ptr, e_conf.tok_hcalOverEcalBcDepth2, ele_vmaps, full5x5.hcalOverEcalBc[1]);
0310   assignValue(ptr, e_conf.tok_hcalOverEcalBcDepth3, ele_vmaps, full5x5.hcalOverEcalBc[2]);
0311   assignValue(ptr, e_conf.tok_hcalOverEcalBcDepth4, ele_vmaps, full5x5.hcalOverEcalBc[3]);
0312   assignValue(ptr, e_conf.tok_hcalOverEcalBcDepth5, ele_vmaps, full5x5.hcalOverEcalBc[4]);
0313   assignValue(ptr, e_conf.tok_hcalOverEcalBcDepth6, ele_vmaps, full5x5.hcalOverEcalBc[5]);
0314   assignValue(ptr, e_conf.tok_hcalOverEcalBcDepth7, ele_vmaps, full5x5.hcalOverEcalBc[6]);
0315 
0316   ele.full5x5_setShowerShape(full5x5);
0317   ++ele_idx;
0318 }
0319 
0320 void EGFull5x5ShowerShapeModifierFromValueMaps::modifyObject(pat::Photon& pho) const {
0321   // we encounter two cases here, either we are running AOD -> MINIAOD
0322   // and the value maps are to the reducedEG object, can use original object ptr
0323   // or we are running MINIAOD->MINIAOD and we need to fetch the pat objects to reference
0324   edm::Ptr<reco::Candidate> ptr(pho.originalObjectRef());
0325 
0326   // The calls to this function should be matched to the order of the electrons
0327   // in eles_by_oop. In case it is called too many times, it will throw thanks
0328   // to the use of std::vector<T>::at().
0329   if (!ph_conf.tok_photon_src.isUninitialized())
0330     ptr = phos_by_oop.at(pho_idx);
0331 
0332   //now we go through and modify the objects using the valuemaps we read in
0333   auto full5x5 = pho.full5x5_showerShapeVariables();
0334   assignValue(ptr, ph_conf.tok_sigmaEtaEta, pho_vmaps, full5x5.sigmaEtaEta);
0335   assignValue(ptr, ph_conf.tok_sigmaIetaIeta, pho_vmaps, full5x5.sigmaIetaIeta);
0336   assignValue(ptr, ph_conf.tok_e1x5, pho_vmaps, full5x5.e1x5);
0337   assignValue(ptr, ph_conf.tok_e2x5, pho_vmaps, full5x5.e2x5);
0338   assignValue(ptr, ph_conf.tok_e3x3, pho_vmaps, full5x5.e3x3);
0339   assignValue(ptr, ph_conf.tok_e5x5, pho_vmaps, full5x5.e5x5);
0340   assignValue(ptr, ph_conf.tok_maxEnergyXtal, pho_vmaps, full5x5.maxEnergyXtal);
0341   assignValue(ptr, ph_conf.tok_hcalOverEcalDepth1, pho_vmaps, full5x5.hcalOverEcal[0]);
0342   assignValue(ptr, ph_conf.tok_hcalOverEcalDepth2, pho_vmaps, full5x5.hcalOverEcal[1]);
0343   assignValue(ptr, ph_conf.tok_hcalOverEcalDepth3, pho_vmaps, full5x5.hcalOverEcal[2]);
0344   assignValue(ptr, ph_conf.tok_hcalOverEcalDepth4, pho_vmaps, full5x5.hcalOverEcal[3]);
0345   assignValue(ptr, ph_conf.tok_hcalOverEcalDepth5, pho_vmaps, full5x5.hcalOverEcal[4]);
0346   assignValue(ptr, ph_conf.tok_hcalOverEcalDepth6, pho_vmaps, full5x5.hcalOverEcal[5]);
0347   assignValue(ptr, ph_conf.tok_hcalOverEcalDepth7, pho_vmaps, full5x5.hcalOverEcal[6]);
0348   assignValue(ptr, ph_conf.tok_hcalOverEcalBcDepth1, pho_vmaps, full5x5.hcalOverEcalBc[0]);
0349   assignValue(ptr, ph_conf.tok_hcalOverEcalBcDepth2, pho_vmaps, full5x5.hcalOverEcalBc[1]);
0350   assignValue(ptr, ph_conf.tok_hcalOverEcalBcDepth3, pho_vmaps, full5x5.hcalOverEcalBc[2]);
0351   assignValue(ptr, ph_conf.tok_hcalOverEcalBcDepth4, pho_vmaps, full5x5.hcalOverEcalBc[3]);
0352   assignValue(ptr, ph_conf.tok_hcalOverEcalBcDepth5, pho_vmaps, full5x5.hcalOverEcalBc[4]);
0353   assignValue(ptr, ph_conf.tok_hcalOverEcalBcDepth6, pho_vmaps, full5x5.hcalOverEcalBc[5]);
0354   assignValue(ptr, ph_conf.tok_hcalOverEcalBcDepth7, pho_vmaps, full5x5.hcalOverEcalBc[6]);
0355 
0356   pho.full5x5_setShowerShapeVariables(full5x5);
0357   ++pho_idx;
0358 }