CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
HGCalPhotonIDValueMapProducer Class Reference

#include <RecoEgamma/EgammaTools/plugins/HGCalPhotonIDValueMapProducer.cc>

Inheritance diagram for HGCalPhotonIDValueMapProducer:
edm::stream::EDProducer<>

Public Member Functions

 HGCalPhotonIDValueMapProducer (const edm::ParameterSet &)
 
 ~HGCalPhotonIDValueMapProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Member Functions

void beginStream (edm::StreamID) override
 
void endStream () override
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

std::map< const std::string, std::vector< float > > maps_
 
std::unique_ptr< HGCalEgammaIDHelperphoIDHelper_
 
edm::EDGetTokenT< edm::View< reco::Photon > > photonsToken_
 
float radius_
 

Static Private Attributes

static const std::vector< std::string > valuesProduced_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 40 of file HGCalPhotonIDValueMapProducer.cc.

Constructor & Destructor Documentation

◆ HGCalPhotonIDValueMapProducer()

HGCalPhotonIDValueMapProducer::HGCalPhotonIDValueMapProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 74 of file HGCalPhotonIDValueMapProducer.cc.

References crabWrapper::key, maps_, phoIDHelper_, and valuesProduced_.

75  : photonsToken_(consumes(iConfig.getParameter<edm::InputTag>("photons"))),
76  radius_(iConfig.getParameter<double>("pcaRadius")) {
77  for (const auto& key : valuesProduced_) {
78  maps_[key] = {};
79  produces<edm::ValueMap<float>>(key);
80  }
81 
82  phoIDHelper_ = std::make_unique<HGCalEgammaIDHelper>(iConfig, consumesCollector());
83 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::unique_ptr< HGCalEgammaIDHelper > phoIDHelper_
static const std::vector< std::string > valuesProduced_
edm::EDGetTokenT< edm::View< reco::Photon > > photonsToken_
std::map< const std::string, std::vector< float > > maps_

◆ ~HGCalPhotonIDValueMapProducer()

HGCalPhotonIDValueMapProducer::~HGCalPhotonIDValueMapProducer ( )
override

Definition at line 85 of file HGCalPhotonIDValueMapProducer.cc.

85 {}

Member Function Documentation

◆ beginStream()

void HGCalPhotonIDValueMapProducer::beginStream ( edm::StreamID  )
overrideprivate

Definition at line 198 of file HGCalPhotonIDValueMapProducer.cc.

198 {}

◆ endStream()

void HGCalPhotonIDValueMapProducer::endStream ( )
overrideprivate

Definition at line 201 of file HGCalPhotonIDValueMapProducer.cc.

201 {}

◆ fillDescriptions()

void HGCalPhotonIDValueMapProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 204 of file HGCalPhotonIDValueMapProducer.cc.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, HLT_2022v14_cff::InputTag, and valuesProduced_.

204  {
205  // hgcalPhotonIDValueMap
207  desc.add<edm::InputTag>("photons", edm::InputTag("photonsHGC"));
208  desc.add<double>("pcaRadius", 3.0);
209  desc.add<std::vector<std::string>>("variables", valuesProduced_);
210  desc.add<std::vector<double>>("dEdXWeights")
211  ->setComment("This must be copied from dEdX_weights in RecoLocalCalo.HGCalRecProducers.HGCalRecHit_cfi");
212  desc.add<unsigned int>("isoNRings", 5);
213  desc.add<double>("isoDeltaR", 0.15);
214  desc.add<double>("isoDeltaRmin", 0.0);
215  desc.add<edm::InputTag>("EERecHits", edm::InputTag("HGCalRecHit", "HGCEERecHits"));
216  desc.add<edm::InputTag>("FHRecHits", edm::InputTag("HGCalRecHit", "HGCHEFRecHits"));
217  desc.add<edm::InputTag>("BHRecHits", edm::InputTag("HGCalRecHit", "HGCHEBRecHits"));
218  desc.add<edm::InputTag>("hitMapTag", edm::InputTag("hgcalRecHitMapProducer"));
219  descriptions.add("hgcalPhotonIDValueMap", desc);
220 }
static const std::vector< std::string > valuesProduced_
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ produce()

void HGCalPhotonIDValueMapProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 88 of file HGCalPhotonIDValueMapProducer.cc.

References Exception, trigObjTnPSource_cfi::filler, iEvent, maps_, eostools::move(), MillePedeFileConverter_cfg::out, phoIDHelper_, photonsToken_, radius_, and valuesProduced_.

88  {
89  using namespace edm;
90 
91  auto photonsH = iEvent.getHandle(photonsToken_);
92 
93  // Clear previous map
94  for (auto&& kv : maps_) {
95  kv.second.clear();
96  kv.second.reserve(photonsH->size());
97  }
98 
99  // Set up helper tool
100  phoIDHelper_->eventInit(iEvent, iSetup);
101 
102  for (const auto& pho : *photonsH) {
103  if (pho.isEB()) {
104  // Fill some dummy value
105  for (auto&& kv : maps_) {
106  kv.second.push_back(0.);
107  }
108  } else {
109  phoIDHelper_->computeHGCAL(pho, radius_);
110 
111  // check the PCA has worked out
112  if (phoIDHelper_->sigmaUU() == -1) {
113  for (auto&& kv : maps_) {
114  kv.second.push_back(0.);
115  }
116  continue;
117  }
118 
119  hgcal::LongDeps ld(phoIDHelper_->energyPerLayer(radius_, true));
120  float measuredDepth, expectedDepth, expectedSigma;
121  float depthCompatibility =
122  phoIDHelper_->clusterDepthCompatibility(ld, measuredDepth, expectedDepth, expectedSigma);
123 
124  // Fill here all the ValueMaps from their appropriate functions
125 
126  // energies calculated in an cylinder around the axis of the pho cluster
127  float seed_tot_energy = ld.energyEE() + ld.energyFH() + ld.energyBH();
128  const double div_cosh_eta =
129  pho.superCluster()->seed()->position().rho() / pho.superCluster()->seed()->position().r();
130  maps_["seedEt"].push_back(seed_tot_energy * div_cosh_eta);
131  maps_["seedEnergy"].push_back(seed_tot_energy);
132  maps_["seedEnergyEE"].push_back(ld.energyEE());
133  maps_["seedEnergyFH"].push_back(ld.energyFH());
134  maps_["seedEnergyBH"].push_back(ld.energyBH());
135 
136  // Cluster shapes
137  // PCA related
138  maps_["pcaEig1"].push_back(phoIDHelper_->eigenValues()(0));
139  maps_["pcaEig2"].push_back(phoIDHelper_->eigenValues()(1));
140  maps_["pcaEig3"].push_back(phoIDHelper_->eigenValues()(2));
141  maps_["pcaSig1"].push_back(phoIDHelper_->sigmas()(0));
142  maps_["pcaSig2"].push_back(phoIDHelper_->sigmas()(1));
143  maps_["pcaSig3"].push_back(phoIDHelper_->sigmas()(2));
144 
145  // transverse shapes
146  maps_["sigmaUU"].push_back(phoIDHelper_->sigmaUU());
147  maps_["sigmaVV"].push_back(phoIDHelper_->sigmaVV());
148  maps_["sigmaEE"].push_back(phoIDHelper_->sigmaEE());
149  maps_["sigmaPP"].push_back(phoIDHelper_->sigmaPP());
150 
151  // long profile
152  maps_["nLayers"].push_back(ld.nLayers());
153  maps_["firstLayer"].push_back(ld.firstLayer());
154  maps_["lastLayer"].push_back(ld.lastLayer());
155  maps_["e4oEtot"].push_back(ld.e4oEtot());
156  maps_["layerEfrac10"].push_back(ld.layerEfrac10());
157  maps_["layerEfrac90"].push_back(ld.layerEfrac90());
158 
159  // depth
160  maps_["measuredDepth"].push_back(measuredDepth);
161  maps_["expectedDepth"].push_back(expectedDepth);
162  maps_["expectedSigma"].push_back(expectedSigma);
163  maps_["depthCompatibility"].push_back(depthCompatibility);
164 
165  // Isolation
166  maps_["caloIsoRing0"].push_back(phoIDHelper_->getIsolationRing(0));
167  maps_["caloIsoRing1"].push_back(phoIDHelper_->getIsolationRing(1));
168  maps_["caloIsoRing2"].push_back(phoIDHelper_->getIsolationRing(2));
169  maps_["caloIsoRing3"].push_back(phoIDHelper_->getIsolationRing(3));
170  maps_["caloIsoRing4"].push_back(phoIDHelper_->getIsolationRing(4));
171  }
172  }
173 
174  // Check we didn't make up a new variable and forget it in the constructor
175  // (or some other pathology)
176  if (maps_.size() != valuesProduced_.size()) {
177  throw cms::Exception("HGCalPhotonIDValueMapProducer")
178  << "We have a miscoded value map producer, since map size changed";
179  }
180 
181  for (auto&& kv : maps_) {
182  // Check we didn't forget any values
183  if (kv.second.size() != photonsH->size()) {
184  throw cms::Exception("HGCalPhotonIDValueMapProducer")
185  << "We have a miscoded value map producer, since the variable " << kv.first << " wasn't filled.";
186  }
187  // Do the filling
188  auto out = std::make_unique<edm::ValueMap<float>>();
190  filler.insert(photonsH, kv.second.begin(), kv.second.end());
191  filler.fill();
192  // and put it into the event
193  iEvent.put(std::move(out), kv.first);
194  }
195 }
std::unique_ptr< HGCalEgammaIDHelper > phoIDHelper_
int iEvent
Definition: GenABIO.cc:224
static const std::vector< std::string > valuesProduced_
HLT enums.
edm::EDGetTokenT< edm::View< reco::Photon > > photonsToken_
std::map< const std::string, std::vector< float > > maps_
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ maps_

std::map<const std::string, std::vector<float> > HGCalPhotonIDValueMapProducer::maps_
private

Definition at line 57 of file HGCalPhotonIDValueMapProducer.cc.

Referenced by HGCalPhotonIDValueMapProducer(), and produce().

◆ phoIDHelper_

std::unique_ptr<HGCalEgammaIDHelper> HGCalPhotonIDValueMapProducer::phoIDHelper_
private

Definition at line 59 of file HGCalPhotonIDValueMapProducer.cc.

Referenced by HGCalPhotonIDValueMapProducer(), and produce().

◆ photonsToken_

edm::EDGetTokenT<edm::View<reco::Photon> > HGCalPhotonIDValueMapProducer::photonsToken_
private

Definition at line 53 of file HGCalPhotonIDValueMapProducer.cc.

Referenced by produce().

◆ radius_

float HGCalPhotonIDValueMapProducer::radius_
private

Definition at line 54 of file HGCalPhotonIDValueMapProducer.cc.

Referenced by produce().

◆ valuesProduced_

const std::vector< std::string > HGCalPhotonIDValueMapProducer::valuesProduced_
staticprivate
Initial value:
= {
"seedEt", "seedEnergy", "seedEnergyEE", "seedEnergyFH", "seedEnergyBH",
"pcaEig1", "pcaEig2", "pcaEig3", "pcaSig1", "pcaSig2",
"pcaSig3", "sigmaUU", "sigmaVV", "sigmaEE", "sigmaPP",
"nLayers", "firstLayer", "lastLayer", "e4oEtot", "layerEfrac10",
"layerEfrac90", "measuredDepth", "expectedDepth", "expectedSigma", "depthCompatibility",
"caloIsoRing0", "caloIsoRing1", "caloIsoRing2", "caloIsoRing3", "caloIsoRing4",
}

Definition at line 56 of file HGCalPhotonIDValueMapProducer.cc.

Referenced by fillDescriptions(), HGCalPhotonIDValueMapProducer(), and produce().