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 hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () 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 41 of file HGCalPhotonIDValueMapProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 100 of file HGCalPhotonIDValueMapProducer.cc.

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

100  :
101  photonsToken_(consumes<edm::View<reco::Photon>>(iConfig.getParameter<edm::InputTag>("photons"))),
102  radius_(iConfig.getParameter<double>("pcaRadius"))
103 {
104  for(const auto& key : valuesProduced_) {
105  maps_[key] = {};
106  produces<edm::ValueMap<float>>(key);
107  }
108 
109  phoIDHelper_.reset(new HGCalEgammaIDHelper(iConfig, consumesCollector()));
110 }
T getParameter(std::string const &) const
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 ( )
override

Definition at line 113 of file HGCalPhotonIDValueMapProducer.cc.

114 {
115 }

Member Function Documentation

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

Definition at line 230 of file HGCalPhotonIDValueMapProducer.cc.

231 {
232 }
void HGCalPhotonIDValueMapProducer::endStream ( )
overrideprivate

Definition at line 236 of file HGCalPhotonIDValueMapProducer.cc.

236  {
237 }
void HGCalPhotonIDValueMapProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 241 of file HGCalPhotonIDValueMapProducer.cc.

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

241  {
242  // hgcalPhotonIDValueMap
244  desc.add<edm::InputTag>("photons", edm::InputTag("photonsFromMultiCl"));
245  desc.add<double>("pcaRadius", 3.0);
246  desc.add<std::vector<std::string>>("variables", valuesProduced_);
247  desc.add<std::vector<double>>("dEdXWeights")->setComment("This must be copied from dEdX_weights in RecoLocalCalo.HGCalRecProducers.HGCalRecHit_cfi");
248  desc.add<unsigned int>("isoNRings", 5);
249  desc.add<double>("isoDeltaR", 0.15);
250  desc.add<double>("isoDeltaRmin", 0.0);
251  desc.add<edm::InputTag>("EERecHits", edm::InputTag("HGCalRecHit","HGCEERecHits"));
252  desc.add<edm::InputTag>("FHRecHits", edm::InputTag("HGCalRecHit","HGCHEFRecHits"));
253  desc.add<edm::InputTag>("BHRecHits", edm::InputTag("HGCalRecHit","HGCHEBRecHits"));
254  descriptions.add("hgcalPhotonIDValueMap", desc);
255 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static const std::vector< std::string > valuesProduced_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void HGCalPhotonIDValueMapProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 120 of file HGCalPhotonIDValueMapProducer.cc.

References Exception, objects.autophobj::filler, edm::Event::getByToken(), maps_, eostools::move(), MillePedeFileConverter_cfg::out, phoIDHelper_, photonsToken_, edm::Event::put(), radius_, and valuesProduced_.

121 {
122  using namespace edm;
123 
125  iEvent.getByToken(photonsToken_, photonsH);
126 
127  // Clear previous map
128  for(auto&& kv : maps_) {
129  kv.second.clear();
130  kv.second.reserve(photonsH->size());
131  }
132 
133  // Set up helper tool
134  phoIDHelper_->eventInit(iEvent,iSetup);
135 
136  for(const auto& pho : *photonsH) {
137  if(pho.isEB()) {
138  // Fill some dummy value
139  for(auto&& kv : maps_) {
140  kv.second.push_back(0.);
141  }
142  }
143  else {
144  phoIDHelper_->computeHGCAL(pho, radius_);
145 
146  // check the PCA has worked out
147  if (phoIDHelper_->sigmaUU() == -1){
148  for(auto&& kv : maps_) {
149  kv.second.push_back(0.);
150  }
151  continue;
152  }
153 
154  hgcal::LongDeps ld(phoIDHelper_->energyPerLayer(radius_, true));
155  float measuredDepth, expectedDepth, expectedSigma;
156  float depthCompatibility = phoIDHelper_->clusterDepthCompatibility(ld, measuredDepth, expectedDepth, expectedSigma);
157 
158  // Fill here all the ValueMaps from their appropriate functions
159 
160  // energies calculated in an cylinder around the axis of the pho cluster
161  float seed_tot_energy = ld.energyEE() + ld.energyFH() + ld.energyBH();
162  const double div_cosh_eta = pho.superCluster()->seed()->position().rho() / pho.superCluster()->seed()->position().r();
163  maps_["seedEt"].push_back(seed_tot_energy * div_cosh_eta );
164  maps_["seedEnergy"].push_back(seed_tot_energy);
165  maps_["seedEnergyEE"].push_back(ld.energyEE());
166  maps_["seedEnergyFH"].push_back(ld.energyFH());
167  maps_["seedEnergyBH"].push_back(ld.energyBH());
168 
169  // Cluster shapes
170  // PCA related
171  maps_["pcaEig1"].push_back(phoIDHelper_->eigenValues()(0));
172  maps_["pcaEig2"].push_back(phoIDHelper_->eigenValues()(1));
173  maps_["pcaEig3"].push_back(phoIDHelper_->eigenValues()(2));
174  maps_["pcaSig1"].push_back(phoIDHelper_->sigmas()(0));
175  maps_["pcaSig2"].push_back(phoIDHelper_->sigmas()(1));
176  maps_["pcaSig3"].push_back(phoIDHelper_->sigmas()(2));
177 
178  // transverse shapes
179  maps_["sigmaUU"].push_back(phoIDHelper_->sigmaUU());
180  maps_["sigmaVV"].push_back(phoIDHelper_->sigmaVV());
181  maps_["sigmaEE"].push_back(phoIDHelper_->sigmaEE());
182  maps_["sigmaPP"].push_back(phoIDHelper_->sigmaPP());
183 
184  // long profile
185  maps_["nLayers"].push_back(ld.nLayers());
186  maps_["firstLayer"].push_back(ld.firstLayer());
187  maps_["lastLayer"].push_back(ld.lastLayer());
188  maps_["e4oEtot"].push_back(ld.e4oEtot());
189  maps_["layerEfrac10"].push_back(ld.layerEfrac10());
190  maps_["layerEfrac90"].push_back(ld.layerEfrac90());
191 
192  // depth
193  maps_["measuredDepth"].push_back(measuredDepth);
194  maps_["expectedDepth"].push_back(expectedDepth);
195  maps_["expectedSigma"].push_back(expectedSigma);
196  maps_["depthCompatibility"].push_back(depthCompatibility);
197 
198  // Isolation
199  maps_["caloIsoRing0"].push_back(phoIDHelper_->getIsolationRing(0));
200  maps_["caloIsoRing1"].push_back(phoIDHelper_->getIsolationRing(1));
201  maps_["caloIsoRing2"].push_back(phoIDHelper_->getIsolationRing(2));
202  maps_["caloIsoRing3"].push_back(phoIDHelper_->getIsolationRing(3));
203  maps_["caloIsoRing4"].push_back(phoIDHelper_->getIsolationRing(4));
204  }
205  }
206 
207  // Check we didn't make up a new variable and forget it in the constructor
208  // (or some other pathology)
209  if ( maps_.size() != valuesProduced_.size() ) {
210  throw cms::Exception("HGCalPhotonIDValueMapProducer") << "We have a miscoded value map producer, since map size changed";
211  }
212 
213  for(auto&& kv : maps_) {
214  // Check we didn't forget any values
215  if ( kv.second.size() != photonsH->size() ) {
216  throw cms::Exception("HGCalPhotonIDValueMapProducer") << "We have a miscoded value map producer, since the variable " << kv.first << " wasn't filled.";
217  }
218  // Do the filling
219  auto out = std::make_unique<edm::ValueMap<float>>();
221  filler.insert(photonsH, kv.second.begin(), kv.second.end());
222  filler.fill();
223  // and put it into the event
224  iEvent.put(std::move(out), kv.first);
225  }
226 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
std::unique_ptr< HGCalEgammaIDHelper > phoIDHelper_
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

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

Definition at line 58 of file HGCalPhotonIDValueMapProducer.cc.

Referenced by HGCalPhotonIDValueMapProducer(), and produce().

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

Definition at line 60 of file HGCalPhotonIDValueMapProducer.cc.

Referenced by HGCalPhotonIDValueMapProducer(), and produce().

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

Definition at line 54 of file HGCalPhotonIDValueMapProducer.cc.

Referenced by produce().

float HGCalPhotonIDValueMapProducer::radius_
private

Definition at line 55 of file HGCalPhotonIDValueMapProducer.cc.

Referenced by produce().

const std::vector< std::string > HGCalPhotonIDValueMapProducer::valuesProduced_
staticprivate