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
 
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::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<>
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 40 of file HGCalPhotonIDValueMapProducer.cc.

Constructor & Destructor Documentation

◆ HGCalPhotonIDValueMapProducer()

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

Definition at line 74 of file HGCalPhotonIDValueMapProducer.cc.

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

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

◆ ~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 199 of file HGCalPhotonIDValueMapProducer.cc.

199 {}

◆ endStream()

void HGCalPhotonIDValueMapProducer::endStream ( )
overrideprivate

Definition at line 202 of file HGCalPhotonIDValueMapProducer.cc.

202 {}

◆ fillDescriptions()

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

Definition at line 205 of file HGCalPhotonIDValueMapProducer.cc.

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

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

◆ produce()

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

Definition at line 88 of file HGCalPhotonIDValueMapProducer.cc.

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

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

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

HGCalEgammaIDHelper
Definition: HGCalEgammaIDHelper.h:31
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
HGCalPhotonIDValueMapProducer::radius_
float radius_
Definition: HGCalPhotonIDValueMapProducer.cc:54
HGCalPhotonIDValueMapProducer::phoIDHelper_
std::unique_ptr< HGCalEgammaIDHelper > phoIDHelper_
Definition: HGCalPhotonIDValueMapProducer.cc:59
edm::Handle
Definition: AssociativeIterator.h:50
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.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
HGCalPhotonIDValueMapProducer::valuesProduced_
static const std::vector< std::string > valuesProduced_
Definition: HGCalPhotonIDValueMapProducer.cc:56
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
eostools.move
def move(src, dest)
Definition: eostools.py:511
Exception
Definition: hltDiff.cc:246
HGCalPhotonIDValueMapProducer::maps_
std::map< const std::string, std::vector< float > > maps_
Definition: HGCalPhotonIDValueMapProducer.cc:57
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
edm::helper::Filler
Definition: ValueMap.h:22
crabWrapper.key
key
Definition: crabWrapper.py:19
HGCalPhotonIDValueMapProducer::photonsToken_
edm::EDGetTokenT< edm::View< reco::Photon > > photonsToken_
Definition: HGCalPhotonIDValueMapProducer.cc:53
edm::InputTag
Definition: InputTag.h:15