CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
EgammaHLTHGCalIDVarProducer.cc
Go to the documentation of this file.
20 
22 public:
25 
26  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
27  void produce(edm::Event&, const edm::EventSetup&) override;
28 
29  class PCAAssocMap {
30  public:
32 
34  assocMap_ = std::make_unique<reco::RecoEcalCandidateIsolationMap>(candHandle);
35  }
36 
38  assocMap_->insert(ref, showerWidths.*var_);
39  }
40 
41  std::unique_ptr<reco::RecoEcalCandidateIsolationMap> releaseMap() { return std::move(assocMap_); }
42  const std::string& name() const { return name_; }
43 
44  private:
47  std::unique_ptr<reco::RecoEcalCandidateIsolationMap> assocMap_;
48  };
49 
50 private:
51  // ----------member data ---------------------------
52  float rCylinder_;
53  float hOverECone_;
54  std::vector<PCAAssocMap> pcaAssocMaps_;
59 };
60 
62  : rCylinder_(config.getParameter<double>("rCylinder")),
63  hOverECone_(config.getParameter<double>("hOverECone")),
64  recoEcalCandidateToken_(
65  consumes<reco::RecoEcalCandidateCollection>(config.getParameter<edm::InputTag>("recoEcalCandidateProducer"))),
66  hgcalRecHitToken_(consumes<reco::PFRecHitCollection>(config.getParameter<edm::InputTag>("hgcalRecHits"))),
67  layerClusterToken_(consumes<reco::CaloClusterCollection>(config.getParameter<edm::InputTag>("layerClusters"))),
68  ssHelper_(consumesCollector()) {
78 
79  produces<reco::RecoEcalCandidateIsolationMap>("rVar");
80  produces<reco::RecoEcalCandidateIsolationMap>("hForHOverE");
81  for (auto& var : pcaAssocMaps_) {
82  produces<reco::RecoEcalCandidateIsolationMap>(var.name());
83  }
84 }
85 
87 
90  desc.add<edm::InputTag>("recoEcalCandidateProducer", edm::InputTag("hltL1SeededRecoEcalCandidate"));
91  desc.add<edm::InputTag>("hgcalRecHits", edm::InputTag("hgcalRecHits"));
92  desc.add<edm::InputTag>("layerClusters", edm::InputTag("layerClusters"));
93  desc.add<double>("rCylinder", EgammaHGCALIDParamDefaults::kRCylinder);
94  desc.add<double>("hOverECone", 0.15);
95  descriptions.add(("hltEgammaHLTHGCalIDVarProducer"), desc);
96 }
97 
99  auto recoEcalCandHandle = iEvent.getHandle(recoEcalCandidateToken_);
100  const auto& hgcalRecHits = iEvent.get(hgcalRecHitToken_);
101  const auto& layerClusters = iEvent.get(layerClusterToken_);
102 
104 
105  auto rVarMap = std::make_unique<reco::RecoEcalCandidateIsolationMap>(recoEcalCandHandle);
106  auto hForHoverEMap = std::make_unique<reco::RecoEcalCandidateIsolationMap>(recoEcalCandHandle);
107  for (auto& pcaMap : pcaAssocMaps_) {
108  pcaMap.initMap(recoEcalCandHandle);
109  }
110 
111  for (size_t candNr = 0; candNr < recoEcalCandHandle->size(); candNr++) {
112  reco::RecoEcalCandidateRef candRef(recoEcalCandHandle, candNr);
113  auto ssCalc = ssHelper_.createCalc(*candRef->superCluster());
114  rVarMap->insert(candRef, ssCalc.getRvar(rCylinder_));
115 
116  float hForHoverE = HGCalClusterTools::hadEnergyInCone(
117  candRef->superCluster()->eta(), candRef->superCluster()->phi(), layerClusters, 0., hOverECone_, 0., 0.);
118  hForHoverEMap->insert(candRef, hForHoverE);
119  auto pcaWidths = ssCalc.getPCAWidths(rCylinder_);
120  for (auto& pcaMap : pcaAssocMaps_) {
121  pcaMap.insert(candRef, pcaWidths);
122  }
123  }
124  iEvent.put(std::move(rVarMap), "rVar");
125  iEvent.put(std::move(hForHoverEMap), "hForHOverE");
126  for (auto& pcaMap : pcaAssocMaps_) {
127  iEvent.put(pcaMap.releaseMap(), pcaMap.name());
128  }
129 }
130 
const edm::EDGetTokenT< reco::CaloClusterCollection > layerClusterToken_
HGCalShowerShapeHelper::ShowerShapeCalc createCalc(const std::vector< std::pair< DetId, float > > &hitsAndFracs, double rawEnergy, double minHitE=0, double minHitET=0, int minLayer=1, int maxLayer=-1, DetId::Detector subDet=DetId::HGCalEE) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
PCAAssocMap(double HGCalShowerShapeHelper::ShowerWidths::*var, const std::string &name)
std::vector< PFRecHit > PFRecHitCollection
collection of PFRecHit objects
Definition: PFRecHitFwd.h:9
Handle< PROD > getHandle(EDGetTokenT< PROD > token) const
Definition: Event.h:563
int iEvent
Definition: GenABIO.cc:224
std::vector< PCAAssocMap > pcaAssocMaps_
EgammaHLTHGCalIDVarProducer(const edm::ParameterSet &)
std::unique_ptr< reco::RecoEcalCandidateIsolationMap > assocMap_
void initPerEvent(const std::vector< reco::PFRecHit > &recHits)
const edm::EDGetTokenT< reco::RecoEcalCandidateCollection > recoEcalCandidateToken_
list var
if using global norm cols_to_minmax = [&#39;t_delta&#39;, &#39;t_hmaxNearP&#39;,&#39;t_emaxNearP&#39;, &#39;t_hAnnular&#39;, &#39;t_eAnnular&#39;,&#39;t_pt&#39;,&#39;t_nVtx&#39;,&#39;t_ieta&#39;,&#39;t_eHcal10&#39;, &#39;t_eHcal30&#39;,&#39;t_rhoh&#39;,&#39;t_eHcal&#39;] df[cols_to_minmax] = df[cols_to_minmax].apply(lambda x: (x - x.min()) / (x.max() - x.min()) if (x.max() - x.min() &gt; 0) else 1.0/200.0)
def move
Definition: eostools.py:511
bool get(ProductID const &oid, Handle< PROD > &result) const
Definition: Event.h:346
std::vector< CaloCluster > CaloClusterCollection
collection of CaloCluster objects
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void insert(reco::RecoEcalCandidateRef &ref, const HGCalShowerShapeHelper::ShowerWidths &showerWidths)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
const edm::EDGetTokenT< reco::PFRecHitCollection > hgcalRecHitToken_
void produce(edm::Event &, const edm::EventSetup &) override
std::vector< RecoEcalCandidate > RecoEcalCandidateCollection
collectin of RecoEcalCandidate objects
tuple config
parse the configuration file
double HGCalShowerShapeHelper::ShowerWidths::* var_
std::unique_ptr< reco::RecoEcalCandidateIsolationMap > releaseMap()
static float hadEnergyInCone(const float eta, const float phi, const std::vector< reco::CaloCluster > &layerClusters, const float minDR, const float maxDR, const float minEt, const float minEnergy, const HGCalClusterTools::EType &eType=EType::ENERGY)
void initMap(const edm::Handle< reco::RecoEcalCandidateCollection > &candHandle)