CMS 3D CMS Logo

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

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

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

Public Member Functions

 HGCalElectronIDValueMapProducer (const edm::ParameterSet &)
 
 ~HGCalElectronIDValueMapProducer () 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::unique_ptr< HGCalEgammaIDHelpereIDHelper_
 
edm::EDGetTokenT< edm::View< reco::GsfElectron > > electronsToken_
 
std::map< const std::string, std::vector< float > > maps_
 
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 41 of file HGCalElectronIDValueMapProducer.cc.

Constructor & Destructor Documentation

◆ HGCalElectronIDValueMapProducer()

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

Definition at line 82 of file HGCalElectronIDValueMapProducer.cc.

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

83  : electronsToken_(consumes(iConfig.getParameter<edm::InputTag>("electrons"))),
84  radius_(iConfig.getParameter<double>("pcaRadius")) {
85  for (const auto& key : valuesProduced_) {
86  maps_[key] = {};
87  produces<edm::ValueMap<float>>(key);
88  }
89 
90  eIDHelper_ = std::make_unique<HGCalEgammaIDHelper>(iConfig, consumesCollector());
91 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::unique_ptr< HGCalEgammaIDHelper > eIDHelper_
std::map< const std::string, std::vector< float > > maps_
static const std::vector< std::string > valuesProduced_
edm::EDGetTokenT< edm::View< reco::GsfElectron > > electronsToken_

◆ ~HGCalElectronIDValueMapProducer()

HGCalElectronIDValueMapProducer::~HGCalElectronIDValueMapProducer ( )
override

Definition at line 93 of file HGCalElectronIDValueMapProducer.cc.

93 {}

Member Function Documentation

◆ beginStream()

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

Definition at line 214 of file HGCalElectronIDValueMapProducer.cc.

214 {}

◆ endStream()

void HGCalElectronIDValueMapProducer::endStream ( )
overrideprivate

Definition at line 217 of file HGCalElectronIDValueMapProducer.cc.

217 {}

◆ fillDescriptions()

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

Definition at line 220 of file HGCalElectronIDValueMapProducer.cc.

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

220  {
221  // Auto-generate hgcalElectronIDValueMap_cfi
223  desc.add<edm::InputTag>("electrons", edm::InputTag("ecalDrivenGsfElectronsHGC"));
224  desc.add<double>("pcaRadius", 3.0);
225  desc.add<std::vector<std::string>>("variables", valuesProduced_);
226  desc.add<std::vector<double>>("dEdXWeights")
227  ->setComment("This must be copied from dEdX_weights in RecoLocalCalo.HGCalRecProducers.HGCalRecHit_cfi");
228  desc.add<unsigned int>("isoNRings", 5);
229  desc.add<double>("isoDeltaR", 0.15);
230  desc.add<double>("isoDeltaRmin", 0.0);
231  desc.add<edm::InputTag>("EERecHits", edm::InputTag("HGCalRecHit", "HGCEERecHits"));
232  desc.add<edm::InputTag>("FHRecHits", edm::InputTag("HGCalRecHit", "HGCHEFRecHits"));
233  desc.add<edm::InputTag>("BHRecHits", edm::InputTag("HGCalRecHit", "HGCHEBRecHits"));
234  desc.add<edm::InputTag>("hitMapTag", edm::InputTag("hgcalRecHitMapProducer"));
235  descriptions.add("hgcalElectronIDValueMap", desc);
236 }
static const std::vector< std::string > valuesProduced_
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ produce()

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

Definition at line 96 of file HGCalElectronIDValueMapProducer.cc.

References eIDHelper_, HPSPFTauProducerPuppi_cfi::electron, electronsToken_, Exception, trigObjTnPSource_cfi::filler, iEvent, maps_, eostools::move(), MillePedeFileConverter_cfg::out, radius_, and valuesProduced_.

96  {
97  using namespace edm;
98 
99  auto electronsH = iEvent.getHandle(electronsToken_);
100 
101  // Clear previous map
102  for (auto&& kv : maps_) {
103  kv.second.clear();
104  kv.second.reserve(electronsH->size());
105  }
106 
107  // Set up helper tool
108  eIDHelper_->eventInit(iEvent, iSetup);
109 
110  for (const auto& electron : *electronsH) {
111  if (electron.isEB()) {
112  // Fill some dummy value
113  for (auto&& kv : maps_) {
114  kv.second.push_back(0.);
115  }
116  } else {
117  eIDHelper_->computeHGCAL(electron, radius_);
118 
119  // check the PCA has worked out
120  if (eIDHelper_->sigmaUU() == -1) {
121  for (auto&& kv : maps_) {
122  kv.second.push_back(0.);
123  }
124  continue;
125  }
126 
127  hgcal::LongDeps ld(eIDHelper_->energyPerLayer(radius_, true));
128  float measuredDepth, expectedDepth, expectedSigma;
129  float depthCompatibility = eIDHelper_->clusterDepthCompatibility(ld, measuredDepth, expectedDepth, expectedSigma);
130 
131  // Fill here all the ValueMaps from their appropriate functions
132 
133  // Energies / PT
134  const auto* eleCluster = electron.electronCluster().get();
135  const double sinTheta = eleCluster->position().rho() / eleCluster->position().r();
136  maps_["ecOrigEt"].push_back(eleCluster->energy() * sinTheta);
137  maps_["ecOrigEnergy"].push_back(eleCluster->energy());
138 
139  // energies calculated in an cylinder around the axis of the electron cluster
140  float ec_tot_energy = ld.energyEE() + ld.energyFH() + ld.energyBH();
141  maps_["ecEt"].push_back(ec_tot_energy * sinTheta);
142  maps_["ecEnergy"].push_back(ec_tot_energy);
143  maps_["ecEnergyEE"].push_back(ld.energyEE());
144  maps_["ecEnergyFH"].push_back(ld.energyFH());
145  maps_["ecEnergyBH"].push_back(ld.energyBH());
146 
147  // Cluster shapes
148  // PCA related
149  maps_["pcaEig1"].push_back(eIDHelper_->eigenValues()(0));
150  maps_["pcaEig2"].push_back(eIDHelper_->eigenValues()(1));
151  maps_["pcaEig3"].push_back(eIDHelper_->eigenValues()(2));
152  maps_["pcaSig1"].push_back(eIDHelper_->sigmas()(0));
153  maps_["pcaSig2"].push_back(eIDHelper_->sigmas()(1));
154  maps_["pcaSig3"].push_back(eIDHelper_->sigmas()(2));
155  maps_["pcaAxisX"].push_back(eIDHelper_->axis().x());
156  maps_["pcaAxisY"].push_back(eIDHelper_->axis().y());
157  maps_["pcaAxisZ"].push_back(eIDHelper_->axis().z());
158  maps_["pcaPositionX"].push_back(eIDHelper_->barycenter().x());
159  maps_["pcaPositionY"].push_back(eIDHelper_->barycenter().y());
160  maps_["pcaPositionZ"].push_back(eIDHelper_->barycenter().z());
161 
162  // transverse shapes
163  maps_["sigmaUU"].push_back(eIDHelper_->sigmaUU());
164  maps_["sigmaVV"].push_back(eIDHelper_->sigmaVV());
165  maps_["sigmaEE"].push_back(eIDHelper_->sigmaEE());
166  maps_["sigmaPP"].push_back(eIDHelper_->sigmaPP());
167 
168  // long profile
169  maps_["nLayers"].push_back(ld.nLayers());
170  maps_["firstLayer"].push_back(ld.firstLayer());
171  maps_["lastLayer"].push_back(ld.lastLayer());
172  maps_["e4oEtot"].push_back(ld.e4oEtot());
173  maps_["layerEfrac10"].push_back(ld.layerEfrac10());
174  maps_["layerEfrac90"].push_back(ld.layerEfrac90());
175 
176  // depth
177  maps_["measuredDepth"].push_back(measuredDepth);
178  maps_["expectedDepth"].push_back(expectedDepth);
179  maps_["expectedSigma"].push_back(expectedSigma);
180  maps_["depthCompatibility"].push_back(depthCompatibility);
181 
182  // Isolation
183  maps_["caloIsoRing0"].push_back(eIDHelper_->getIsolationRing(0));
184  maps_["caloIsoRing1"].push_back(eIDHelper_->getIsolationRing(1));
185  maps_["caloIsoRing2"].push_back(eIDHelper_->getIsolationRing(2));
186  maps_["caloIsoRing3"].push_back(eIDHelper_->getIsolationRing(3));
187  maps_["caloIsoRing4"].push_back(eIDHelper_->getIsolationRing(4));
188  }
189  }
190 
191  // Check we didn't make up a new variable and forget it in valuesProduced_
192  if (maps_.size() != valuesProduced_.size()) {
193  throw cms::Exception("HGCalElectronIDValueMapProducer")
194  << "We have a miscoded value map producer, since map size changed";
195  }
196 
197  for (auto&& kv : maps_) {
198  // Check we didn't forget any values
199  if (kv.second.size() != electronsH->size()) {
200  throw cms::Exception("HGCalElectronIDValueMapProducer")
201  << "We have a miscoded value map producer, since the variable " << kv.first << " wasn't filled.";
202  }
203  // Do the filling
204  auto out = std::make_unique<edm::ValueMap<float>>();
206  filler.insert(electronsH, kv.second.begin(), kv.second.end());
207  filler.fill();
208  // and put it into the event
209  iEvent.put(std::move(out), kv.first);
210  }
211 }
std::unique_ptr< HGCalEgammaIDHelper > eIDHelper_
std::map< const std::string, std::vector< float > > maps_
static const std::vector< std::string > valuesProduced_
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< edm::View< reco::GsfElectron > > electronsToken_
HLT enums.
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ eIDHelper_

std::unique_ptr<HGCalEgammaIDHelper> HGCalElectronIDValueMapProducer::eIDHelper_
private

Definition at line 60 of file HGCalElectronIDValueMapProducer.cc.

Referenced by HGCalElectronIDValueMapProducer(), and produce().

◆ electronsToken_

edm::EDGetTokenT<edm::View<reco::GsfElectron> > HGCalElectronIDValueMapProducer::electronsToken_
private

Definition at line 54 of file HGCalElectronIDValueMapProducer.cc.

Referenced by produce().

◆ maps_

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

Definition at line 58 of file HGCalElectronIDValueMapProducer.cc.

Referenced by HGCalElectronIDValueMapProducer(), and produce().

◆ radius_

float HGCalElectronIDValueMapProducer::radius_
private

Definition at line 55 of file HGCalElectronIDValueMapProducer.cc.

Referenced by produce().

◆ valuesProduced_

const std::vector< std::string > HGCalElectronIDValueMapProducer::valuesProduced_
staticprivate
Initial value:
= {
"ecOrigEt", "ecOrigEnergy", "ecEt",
"ecEnergy", "ecEnergyEE", "ecEnergyFH",
"ecEnergyBH", "pcaEig1", "pcaEig2",
"pcaEig3", "pcaSig1", "pcaSig2",
"pcaSig3", "pcaAxisX", "pcaAxisY",
"pcaAxisZ", "pcaPositionX", "pcaPositionY",
"pcaPositionZ", "sigmaUU", "sigmaVV",
"sigmaEE", "sigmaPP", "nLayers",
"firstLayer", "lastLayer", "e4oEtot",
"layerEfrac10", "layerEfrac90", "measuredDepth",
"expectedDepth", "expectedSigma", "depthCompatibility",
"caloIsoRing0", "caloIsoRing1", "caloIsoRing2",
"caloIsoRing3", "caloIsoRing4",
}

Definition at line 57 of file HGCalElectronIDValueMapProducer.cc.

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