CMS 3D CMS Logo

EGPhotonImporter.cc
Go to the documentation of this file.
8 
9 #include <memory>
10 
11 #include <unordered_map>
12 
14 public:
16 
18 
19  void importToBlock(const edm::Event&, ElementList&) const override;
20 
21 private:
23  const std::unordered_map<std::string, SelectionChoices> _selectionTypes;
25  std::unique_ptr<const PhotonSelectorAlgo> _selector;
27 };
28 
30 
32  : BlockElementImporterBase(conf, sumes),
33  _src(sumes.consumes<reco::PhotonCollection>(conf.getParameter<edm::InputTag>("source"))),
34  _selectionTypes({{"SeparateDetectorIso", EGPhotonImporter::SeparateDetectorIso},
35  {"CombinedDetectorIso", EGPhotonImporter::CombinedDetectorIso}}),
36  _superClustersArePF(conf.getParameter<bool>("superClustersArePF")) {
37  const std::string& selChoice = conf.getParameter<std::string>("SelectionChoice");
38  _selectionChoice = _selectionTypes.at(selChoice);
39  const edm::ParameterSet& selDef = conf.getParameterSet("SelectionDefinition");
40  const float minEt = selDef.getParameter<double>("minEt");
41  const float trackIso_const = selDef.getParameter<double>("trackIsoConstTerm");
42  const float trackIso_slope = selDef.getParameter<double>("trackIsoSlopeTerm");
43  const float ecalIso_const = selDef.getParameter<double>("ecalIsoConstTerm");
44  const float ecalIso_slope = selDef.getParameter<double>("ecalIsoSlopeTerm");
45  const float hcalIso_const = selDef.getParameter<double>("hcalIsoConstTerm");
46  const float hcalIso_slope = selDef.getParameter<double>("hcalIsoSlopeTerm");
47  const float hoe = selDef.getParameter<double>("HoverE");
48  const float loose_hoe = selDef.getParameter<double>("LooseHoverE");
49  const float combIso = selDef.getParameter<double>("combIsoConstTerm");
50  _selector = std::make_unique<PhotonSelectorAlgo>((float)_selectionChoice,
51  minEt,
52  trackIso_const,
53  trackIso_slope,
54  ecalIso_const,
55  ecalIso_slope,
56  hcalIso_const,
57  hcalIso_slope,
58  hoe,
59  combIso,
60  loose_hoe);
61 }
62 
65  auto photons = e.getHandle(_src);
66  elems.reserve(elems.size() + photons->size());
67  // setup our elements so that all the SCs are grouped together
68  auto SCs_end = std::partition(
69  elems.begin(), elems.end(), [](const ElementType& a) { return a->type() == reco::PFBlockElement::SC; });
70  //now add the photons
71  auto bphoton = photons->cbegin();
72  auto ephoton = photons->cend();
73  reco::PFBlockElementSuperCluster* scbe = nullptr;
74  reco::PhotonRef phoref;
75  for (auto photon = bphoton; photon != ephoton; ++photon) {
76  if (_selector->passPhotonSelection(*photon)) {
77  phoref = reco::PhotonRef(photons, std::distance(bphoton, photon));
78  const reco::SuperClusterRef& scref = photon->superCluster();
79  PFBlockElementSCEqual myEqual(scref);
80  auto sc_elem = std::find_if(elems.begin(), SCs_end, myEqual);
81  if (sc_elem != SCs_end) {
82  scbe = static_cast<reco::PFBlockElementSuperCluster*>(sc_elem->get());
83  scbe->setFromPhoton(true);
84  scbe->setPhotonRef(phoref);
85  scbe->setTrackIso(photon->trkSumPtHollowConeDR04());
86  scbe->setEcalIso(photon->ecalRecHitSumEtConeDR04());
87  scbe->setHcalIso(photon->hcalTowerSumEtConeDR04());
88  scbe->setHoE(photon->hadronicOverEm());
89  } else {
90  scbe = new reco::PFBlockElementSuperCluster(scref);
91  scbe->setFromPhoton(true);
93  scbe->setPhotonRef(phoref);
94  scbe->setTrackIso(photon->trkSumPtHollowConeDR04());
95  scbe->setEcalIso(photon->ecalRecHitSumEtConeDR04());
96  scbe->setHcalIso(photon->hcalTowerSumEtConeDR04());
97  scbe->setHoE(photon->hadronicOverEm());
98  SCs_end = elems.insert(SCs_end, ElementType(scbe));
99  ++SCs_end; // point to element *after* the new one
100  }
101  }
102  } // loop on photons
103  elems.shrink_to_fit();
104 }
reco::PFBlockElementSuperCluster::setTrackIso
void setTrackIso(float val)
set the track Iso
Definition: PFBlockElementSuperCluster.h:44
muons2muons_cfi.photon
photon
Definition: muons2muons_cfi.py:28
EGPhotonImporter::_selectionChoice
SelectionChoices _selectionChoice
Definition: EGPhotonImporter.cc:24
EGPhotonImporter
Definition: EGPhotonImporter.cc:13
edm::EDGetTokenT< reco::PhotonCollection >
edm
HLT enums.
Definition: AlignableModifier.h:19
PhotonSelectorAlgo.h
reco::PFBlockElementSuperCluster
Cluster Element.
Definition: PFBlockElementSuperCluster.h:15
reco::PFBlockElementSuperCluster::setHoE
void setHoE(float val)
set H/E
Definition: PFBlockElementSuperCluster.h:53
reco::PFBlockElement::SC
Definition: PFBlockElement.h:41
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89287
EGPhotonImporter::importToBlock
void importToBlock(const edm::Event &, ElementList &) const override
Definition: EGPhotonImporter.cc:63
EGPhotonImporter::EGPhotonImporter
EGPhotonImporter(const edm::ParameterSet &, edm::ConsumesCollector &)
Definition: EGPhotonImporter.cc:31
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
edm::Ref< PhotonCollection >
EGPhotonImporter::_superClustersArePF
bool _superClustersArePF
Definition: EGPhotonImporter.cc:26
Photon.h
BlockElementImporterBase.h
PFBlockElementSCEqual
Definition: PFBlockElementSCEqual.h:7
EgHLTOffEleSelection_cfi.minEt
minEt
Definition: EgHLTOffEleSelection_cfi.py:10
reco::PFBlockElementSuperCluster::setEcalIso
void setEcalIso(float val)
set the ecal Iso
Definition: PFBlockElementSuperCluster.h:47
PFCluster.h
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
EGPhotonImporter::CombinedDetectorIso
Definition: EGPhotonImporter.cc:15
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
BlockElementImporterBase::ElementList
std::vector< std::unique_ptr< reco::PFBlockElement > > ElementList
Definition: BlockElementImporterBase.h:16
reco::PFBlockElementSuperCluster::setFromPFSuperCluster
void setFromPFSuperCluster(bool val)
Definition: PFBlockElementSuperCluster.h:61
edm::ParameterSet
Definition: ParameterSet.h:47
a
double a
Definition: hdecay.h:119
edmplugin::PluginFactory
Definition: PluginFactory.h:34
PFBlockElementSuperCluster.h
BPHMonitor_cfi.photons
photons
Definition: BPHMonitor_cfi.py:91
reco::JetExtendedAssociation::value_type
Container::value_type value_type
Definition: JetExtendedAssociation.h:30
electrons_cff.hoe
hoe
Definition: electrons_cff.py:425
reco::PhotonRef
edm::Ref< PhotonCollection > PhotonRef
reference to an object in a collection of Photon objects
Definition: PhotonFwd.h:15
reco::PFBlockElementSuperCluster::setHcalIso
void setHcalIso(float val)
set the had Iso
Definition: PFBlockElementSuperCluster.h:50
SuperCluster.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
reco::PFBlockElementSuperCluster::setPhotonRef
void setPhotonRef(const PhotonRef &ref)
set photonRef
Definition: PFBlockElementSuperCluster.h:64
PFBlockElementSCEqual.h
reco::PhotonCollection
std::vector< Photon > PhotonCollection
collectin of Photon objects
Definition: PhotonFwd.h:9
EGPhotonImporter::_src
edm::EDGetTokenT< reco::PhotonCollection > _src
Definition: EGPhotonImporter.cc:22
EGPhotonImporter::SelectionChoices
SelectionChoices
Definition: EGPhotonImporter.cc:15
EGPhotonImporter::_selector
std::unique_ptr< const PhotonSelectorAlgo > _selector
Definition: EGPhotonImporter.cc:25
edm::Event
Definition: Event.h:73
EGPhotonImporter::_selectionTypes
const std::unordered_map< std::string, SelectionChoices > _selectionTypes
Definition: EGPhotonImporter.cc:23
HLT_FULL_cff.distance
distance
Definition: HLT_FULL_cff.py:7733
reco::PFBlockElementSuperCluster::setFromPhoton
void setFromPhoton(bool val)
set provenance
Definition: PFBlockElementSuperCluster.h:59
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
edm::ParameterSet::getParameterSet
ParameterSet const & getParameterSet(std::string const &) const
Definition: ParameterSet.cc:2128
EGPhotonImporter::SeparateDetectorIso
Definition: EGPhotonImporter.cc:15
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
BlockElementImporterBase
Definition: BlockElementImporterBase.h:14