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
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

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<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache 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.

83  : electronsToken_(consumes<edm::View<reco::GsfElectron>>(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_.reset(new HGCalEgammaIDHelper(iConfig, consumesCollector()));
91 }

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

◆ ~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 215 of file HGCalElectronIDValueMapProducer.cc.

215 {}

◆ endStream()

void HGCalElectronIDValueMapProducer::endStream ( )
overrideprivate

Definition at line 218 of file HGCalElectronIDValueMapProducer.cc.

218 {}

◆ fillDescriptions()

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

Definition at line 221 of file HGCalElectronIDValueMapProducer.cc.

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

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), HLT_2018_cff::InputTag, and valuesProduced_.

◆ produce()

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

Definition at line 96 of file HGCalElectronIDValueMapProducer.cc.

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

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

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().

HGCalEgammaIDHelper
Definition: HGCalEgammaIDHelper.h:30
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
edm::Handle
Definition: AssociativeIterator.h:50
HGCalElectronIDValueMapProducer::radius_
float radius_
Definition: HGCalElectronIDValueMapProducer.cc:55
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
metsig::electron
Definition: SignAlgoResolutions.h:48
HGCalElectronIDValueMapProducer::valuesProduced_
static const std::vector< std::string > valuesProduced_
Definition: HGCalElectronIDValueMapProducer.cc:57
edm::View
Definition: CaloClusterFwd.h:14
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
trigObjTnPSource_cfi.filler
filler
Definition: trigObjTnPSource_cfi.py:21
hgcal::LongDeps
Definition: LongDeps.h:14
iEvent
int iEvent
Definition: GenABIO.cc:224
HGCalElectronIDValueMapProducer::maps_
std::map< const std::string, std::vector< float > > maps_
Definition: HGCalElectronIDValueMapProducer.cc:58
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
eostools.move
def move(src, dest)
Definition: eostools.py:511
Exception
Definition: hltDiff.cc:246
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
edm::helper::Filler
Definition: ValueMap.h:22
HGCalElectronIDValueMapProducer::eIDHelper_
std::unique_ptr< HGCalEgammaIDHelper > eIDHelper_
Definition: HGCalElectronIDValueMapProducer.cc:60
crabWrapper.key
key
Definition: crabWrapper.py:19
edm::InputTag
Definition: InputTag.h:15
HGCalElectronIDValueMapProducer::electronsToken_
edm::EDGetTokenT< edm::View< reco::GsfElectron > > electronsToken_
Definition: HGCalElectronIDValueMapProducer.cc:54