CMS 3D CMS Logo

EGPhotonImporter.cc
Go to the documentation of this file.
8 
9 #include <unordered_map>
10 
12 public:
14 
16 
17  void importToBlock(const edm::Event&, ElementList&) const override;
18 
19 private:
21  const std::unordered_map<std::string, SelectionChoices> _selectionTypes;
23  std::unique_ptr<const PhotonSelectorAlgo> _selector;
25 };
26 
28 
30  : BlockElementImporterBase(conf, sumes),
31  _src(sumes.consumes<reco::PhotonCollection>(conf.getParameter<edm::InputTag>("source"))),
32  _selectionTypes({{"SeparateDetectorIso", EGPhotonImporter::SeparateDetectorIso},
33  {"CombinedDetectorIso", EGPhotonImporter::CombinedDetectorIso}}),
34  _superClustersArePF(conf.getParameter<bool>("superClustersArePF")) {
35  const std::string& selChoice = conf.getParameter<std::string>("SelectionChoice");
36  _selectionChoice = _selectionTypes.at(selChoice);
37  const edm::ParameterSet& selDef = conf.getParameterSet("SelectionDefinition");
38  const float minEt = selDef.getParameter<double>("minEt");
39  const float trackIso_const = selDef.getParameter<double>("trackIsoConstTerm");
40  const float trackIso_slope = selDef.getParameter<double>("trackIsoSlopeTerm");
41  const float ecalIso_const = selDef.getParameter<double>("ecalIsoConstTerm");
42  const float ecalIso_slope = selDef.getParameter<double>("ecalIsoSlopeTerm");
43  const float hcalIso_const = selDef.getParameter<double>("hcalIsoConstTerm");
44  const float hcalIso_slope = selDef.getParameter<double>("hcalIsoSlopeTerm");
45  const float hoe = selDef.getParameter<double>("HoverE");
46  const float loose_hoe = selDef.getParameter<double>("LooseHoverE");
47  const float combIso = selDef.getParameter<double>("combIsoConstTerm");
48  _selector.reset(new PhotonSelectorAlgo((float)_selectionChoice,
49  minEt,
50  trackIso_const,
51  trackIso_slope,
52  ecalIso_const,
53  ecalIso_slope,
54  hcalIso_const,
55  hcalIso_slope,
56  hoe,
57  combIso,
58  loose_hoe));
59 }
60 
63  auto photons = e.getHandle(_src);
64  elems.reserve(elems.size() + photons->size());
65  // setup our elements so that all the SCs are grouped together
66  auto SCs_end = std::partition(
67  elems.begin(), elems.end(), [](const ElementType& a) { return a->type() == reco::PFBlockElement::SC; });
68  //now add the photons
69  auto bphoton = photons->cbegin();
70  auto ephoton = photons->cend();
71  reco::PFBlockElementSuperCluster* scbe = nullptr;
72  reco::PhotonRef phoref;
73  for (auto photon = bphoton; photon != ephoton; ++photon) {
74  if (_selector->passPhotonSelection(*photon)) {
75  phoref = reco::PhotonRef(photons, std::distance(bphoton, photon));
76  const reco::SuperClusterRef& scref = photon->superCluster();
77  PFBlockElementSCEqual myEqual(scref);
78  auto sc_elem = std::find_if(elems.begin(), SCs_end, myEqual);
79  if (sc_elem != SCs_end) {
80  scbe = static_cast<reco::PFBlockElementSuperCluster*>(sc_elem->get());
81  scbe->setFromPhoton(true);
82  scbe->setPhotonRef(phoref);
83  scbe->setTrackIso(photon->trkSumPtHollowConeDR04());
84  scbe->setEcalIso(photon->ecalRecHitSumEtConeDR04());
85  scbe->setHcalIso(photon->hcalTowerSumEtConeDR04());
86  scbe->setHoE(photon->hadronicOverEm());
87  } else {
88  scbe = new reco::PFBlockElementSuperCluster(scref);
89  scbe->setFromPhoton(true);
91  scbe->setPhotonRef(phoref);
92  scbe->setTrackIso(photon->trkSumPtHollowConeDR04());
93  scbe->setEcalIso(photon->ecalRecHitSumEtConeDR04());
94  scbe->setHcalIso(photon->hcalTowerSumEtConeDR04());
95  scbe->setHoE(photon->hadronicOverEm());
96  SCs_end = elems.insert(SCs_end, ElementType(scbe));
97  ++SCs_end; // point to element *after* the new one
98  }
99  }
100  } // loop on photons
101  elems.shrink_to_fit();
102 }
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:22
EGPhotonImporter
Definition: EGPhotonImporter.cc:11
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
EGPhotonImporter::importToBlock
void importToBlock(const edm::Event &, ElementList &) const override
Definition: EGPhotonImporter.cc:61
HLT_2018_cff.distance
distance
Definition: HLT_2018_cff.py:6417
EGPhotonImporter::EGPhotonImporter
EGPhotonImporter(const edm::ParameterSet &, edm::ConsumesCollector &)
Definition: EGPhotonImporter.cc:29
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
edm::Ref< PhotonCollection >
EGPhotonImporter::_superClustersArePF
bool _superClustersArePF
Definition: EGPhotonImporter.cc:24
PhotonSelectorAlgo
Definition: PhotonSelectorAlgo.h:8
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:13
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
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::ParameterSet
Definition: ParameterSet.h:36
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:404
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
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
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:20
EGPhotonImporter::SelectionChoices
SelectionChoices
Definition: EGPhotonImporter.cc:13
EGPhotonImporter::_selector
std::unique_ptr< const PhotonSelectorAlgo > _selector
Definition: EGPhotonImporter.cc:23
edm::Event
Definition: Event.h:73
EGPhotonImporter::_selectionTypes
const std::unordered_map< std::string, SelectionChoices > _selectionTypes
Definition: EGPhotonImporter.cc:21
reco::PFBlockElementSuperCluster::setFromPhoton
void setFromPhoton(bool val)
set provenance
Definition: PFBlockElementSuperCluster.h:59
edm::ConsumesCollector
Definition: ConsumesCollector.h:39
edm::ParameterSet::getParameterSet
ParameterSet const & getParameterSet(std::string const &) const
Definition: ParameterSet.cc:2121
EGPhotonImporter::SeparateDetectorIso
Definition: EGPhotonImporter.cc:13
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
BlockElementImporterBase
Definition: BlockElementImporterBase.h:14