CMS 3D CMS Logo

EGPhotonImporter.cc
Go to the documentation of this file.
10 
11 #include <unordered_map>
12 
14 public:
16 
18 
19  void importToBlock( const edm::Event& ,
20  ElementList& ) const override;
21 
22 private:
24  const std::unordered_map<std::string,SelectionChoices> _selectionTypes;
26  std::unique_ptr<const PhotonSelectorAlgo> _selector;
28 
29 };
30 
33  "EGPhotonImporter");
34 
36  edm::ConsumesCollector& sumes) :
37  BlockElementImporterBase(conf,sumes),
38  _src(sumes.consumes<reco::PhotonCollection>(conf.getParameter<edm::InputTag>("source"))),
40  {"CombinedDetectorIso",EGPhotonImporter::CombinedDetectorIso} }),
41  _superClustersArePF(conf.getParameter<bool>("superClustersArePF")) {
42  const std::string& selChoice =
43  conf.getParameter<std::string>("SelectionChoice");
44  _selectionChoice = _selectionTypes.at(selChoice);
45  const edm::ParameterSet& selDef =
46  conf.getParameterSet("SelectionDefinition");
47  const float minEt = selDef.getParameter<double>("minEt");
48  const float trackIso_const = selDef.getParameter<double>("trackIsoConstTerm");
49  const float trackIso_slope = selDef.getParameter<double>("trackIsoSlopeTerm");
50  const float ecalIso_const = selDef.getParameter<double>("ecalIsoConstTerm");
51  const float ecalIso_slope = selDef.getParameter<double>("ecalIsoSlopeTerm");
52  const float hcalIso_const = selDef.getParameter<double>("hcalIsoConstTerm");
53  const float hcalIso_slope = selDef.getParameter<double>("hcalIsoSlopeTerm");
54  const float hoe = selDef.getParameter<double>("HoverE");
55  const float loose_hoe = selDef.getParameter<double>("LooseHoverE");
56  const float combIso = selDef.getParameter<double>("combIsoConstTerm");
57  _selector.reset(new PhotonSelectorAlgo((float)_selectionChoice,
58  minEt,
59  trackIso_const, trackIso_slope,
60  ecalIso_const, ecalIso_slope,
61  hcalIso_const, hcalIso_slope,
62  hoe,
63  combIso,
64  loose_hoe));
65 }
66 
72  e.getByToken(_src,photons);
73  elems.reserve(elems.size()+photons->size());
74  // setup our elements so that all the SCs are grouped together
75  auto SCs_end = std::partition(elems.begin(),elems.end(),
76  [](const ElementType& a){
77  return a->type() == reco::PFBlockElement::SC;
78  });
79  //now add the photons
80  auto bphoton = photons->cbegin();
81  auto ephoton = photons->cend();
82  reco::PFBlockElementSuperCluster* scbe = nullptr;
83  reco::PhotonRef phoref;
84  for( auto photon = bphoton; photon != ephoton; ++photon ) {
85  if( _selector->passPhotonSelection(*photon) ) {
86  phoref = reco::PhotonRef(photons,std::distance(bphoton,photon));
87  const reco::SuperClusterRef& scref = photon->superCluster();
88  PFBlockElementSCEqual myEqual(scref);
89  auto sc_elem = std::find_if(elems.begin(),SCs_end,myEqual);
90  if( sc_elem != SCs_end ) {
91  scbe = static_cast<reco::PFBlockElementSuperCluster*>(sc_elem->get());
92  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  } else {
99  scbe = new reco::PFBlockElementSuperCluster(scref);
100  scbe->setFromPhoton(true);
102  scbe->setPhotonRef(phoref);
103  scbe->setTrackIso(photon->trkSumPtHollowConeDR04());
104  scbe->setEcalIso(photon->ecalRecHitSumEtConeDR04());
105  scbe->setHcalIso(photon->hcalTowerSumEtConeDR04());
106  scbe->setHoE(photon->hadronicOverEm());
107  SCs_end = elems.insert(SCs_end,ElementType(scbe));
108  ++SCs_end; // point to element *after* the new one
109  }
110  }
111  }// loop on photons
112  elems.shrink_to_fit();
113 }
T getParameter(std::string const &) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
SelectionChoices _selectionChoice
void setFromPhoton(bool val)
set provenance
void setHcalIso(float val)
set the had Iso
EGPhotonImporter(const edm::ParameterSet &, edm::ConsumesCollector &)
void setTrackIso(float val)
set the track Iso
void setPhotonRef(const PhotonRef &ref)
set photonRef
void importToBlock(const edm::Event &, ElementList &) const override
ParameterSet const & getParameterSet(std::string const &) const
std::vector< Photon > PhotonCollection
collectin of Photon objects
Definition: PhotonFwd.h:9
edm::Ref< PhotonCollection > PhotonRef
reference to an object in a collection of Photon objects
Definition: PhotonFwd.h:15
fixed size matrix
HLT enums.
double a
Definition: hdecay.h:121
edm::EDGetTokenT< reco::PhotonCollection > _src
#define DEFINE_EDM_PLUGIN(factory, type, name)
std::vector< std::unique_ptr< reco::PFBlockElement > > ElementList
void setEcalIso(float val)
set the ecal Iso
std::unique_ptr< const PhotonSelectorAlgo > _selector
const std::unordered_map< std::string, SelectionChoices > _selectionTypes