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 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::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 42 of file HGCalElectronIDValueMapProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 108 of file HGCalElectronIDValueMapProducer.cc.

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

108  :
110  radius_(iConfig.getParameter<double>("pcaRadius"))
111 {
112  for(const auto& key : valuesProduced_) {
113  maps_[key] = {};
114  produces<edm::ValueMap<float>>(key);
115  }
116 
117  eIDHelper_.reset(new HGCalEgammaIDHelper(iConfig, consumesCollector()));
118 }
T getParameter(std::string const &) const
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 ( )
override

Definition at line 121 of file HGCalElectronIDValueMapProducer.cc.

122 {
123 }

Member Function Documentation

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

Definition at line 248 of file HGCalElectronIDValueMapProducer.cc.

249 {
250 }
void HGCalElectronIDValueMapProducer::endStream ( )
overrideprivate

Definition at line 254 of file HGCalElectronIDValueMapProducer.cc.

254  {
255 }
void HGCalElectronIDValueMapProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 259 of file HGCalElectronIDValueMapProducer.cc.

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

259  {
260  // Auto-generate hgcalElectronIDValueMap_cfi
262  desc.add<edm::InputTag>("electrons", edm::InputTag("ecalDrivenGsfElectronsFromMultiCl"));
263  desc.add<double>("pcaRadius", 3.0);
264  desc.add<std::vector<std::string>>("variables", valuesProduced_);
265  desc.add<std::vector<double>>("dEdXWeights")->setComment("This must be copied from dEdX_weights in RecoLocalCalo.HGCalRecProducers.HGCalRecHit_cfi");
266  desc.add<unsigned int>("isoNRings", 5);
267  desc.add<double>("isoDeltaR", 0.15);
268  desc.add<double>("isoDeltaRmin", 0.0);
269  desc.add<edm::InputTag>("EERecHits", edm::InputTag("HGCalRecHit","HGCEERecHits"));
270  desc.add<edm::InputTag>("FHRecHits", edm::InputTag("HGCalRecHit","HGCHEFRecHits"));
271  desc.add<edm::InputTag>("BHRecHits", edm::InputTag("HGCalRecHit","HGCHEBRecHits"));
272  descriptions.add("hgcalElectronIDValueMap", desc);
273 }
static const std::vector< std::string > valuesProduced_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void HGCalElectronIDValueMapProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 128 of file HGCalElectronIDValueMapProducer.cc.

References eIDHelper_, metsig::electron, electronsToken_, Exception, objects.autophobj::filler, edm::Event::getByToken(), maps_, eostools::move(), MillePedeFileConverter_cfg::out, edm::Event::put(), radius_, and valuesProduced_.

129 {
130  using namespace edm;
131 
133  iEvent.getByToken(electronsToken_, electronsH);
134 
135  // Clear previous map
136  for(auto&& kv : maps_) {
137  kv.second.clear();
138  kv.second.reserve(electronsH->size());
139  }
140 
141  // Set up helper tool
142  eIDHelper_->eventInit(iEvent,iSetup);
143 
144  for(const auto& electron : *electronsH) {
145  if(electron.isEB()) {
146  // Fill some dummy value
147  for(auto&& kv : maps_) {
148  kv.second.push_back(0.);
149  }
150  }
151  else {
152  eIDHelper_->computeHGCAL(electron, radius_);
153 
154  // check the PCA has worked out
155  if (eIDHelper_->sigmaUU() == -1){
156  for(auto&& kv : maps_) {
157  kv.second.push_back(0.);
158  }
159  continue;
160  }
161 
162  hgcal::LongDeps ld(eIDHelper_->energyPerLayer(radius_, true));
163  float measuredDepth, expectedDepth, expectedSigma;
164  float depthCompatibility = eIDHelper_->clusterDepthCompatibility(ld, measuredDepth, expectedDepth, expectedSigma);
165 
166  // Fill here all the ValueMaps from their appropriate functions
167 
168  // Energies / PT
169  const auto* eleCluster = electron.electronCluster().get();
170  const double sinTheta = eleCluster->position().rho() / eleCluster->position().r();
171  maps_["ecOrigEt"].push_back(eleCluster->energy() * sinTheta );
172  maps_["ecOrigEnergy"].push_back(eleCluster->energy());
173 
174  // energies calculated in an cylinder around the axis of the electron cluster
175  float ec_tot_energy = ld.energyEE() + ld.energyFH() + ld.energyBH();
176  maps_["ecEt"].push_back(ec_tot_energy * sinTheta );
177  maps_["ecEnergy"].push_back(ec_tot_energy);
178  maps_["ecEnergyEE"].push_back(ld.energyEE());
179  maps_["ecEnergyFH"].push_back(ld.energyFH());
180  maps_["ecEnergyBH"].push_back(ld.energyBH());
181 
182  // Cluster shapes
183  // PCA related
184  maps_["pcaEig1"].push_back(eIDHelper_->eigenValues()(0));
185  maps_["pcaEig2"].push_back(eIDHelper_->eigenValues()(1));
186  maps_["pcaEig3"].push_back(eIDHelper_->eigenValues()(2));
187  maps_["pcaSig1"].push_back(eIDHelper_->sigmas()(0));
188  maps_["pcaSig2"].push_back(eIDHelper_->sigmas()(1));
189  maps_["pcaSig3"].push_back(eIDHelper_->sigmas()(2));
190  maps_["pcaAxisX"].push_back(eIDHelper_->axis().x());
191  maps_["pcaAxisY"].push_back(eIDHelper_->axis().y());
192  maps_["pcaAxisZ"].push_back(eIDHelper_->axis().z());
193  maps_["pcaPositionX"].push_back(eIDHelper_->barycenter().x());
194  maps_["pcaPositionY"].push_back(eIDHelper_->barycenter().y());
195  maps_["pcaPositionZ"].push_back(eIDHelper_->barycenter().z());
196 
197  // transverse shapes
198  maps_["sigmaUU"].push_back(eIDHelper_->sigmaUU());
199  maps_["sigmaVV"].push_back(eIDHelper_->sigmaVV());
200  maps_["sigmaEE"].push_back(eIDHelper_->sigmaEE());
201  maps_["sigmaPP"].push_back(eIDHelper_->sigmaPP());
202 
203  // long profile
204  maps_["nLayers"].push_back(ld.nLayers());
205  maps_["firstLayer"].push_back(ld.firstLayer());
206  maps_["lastLayer"].push_back(ld.lastLayer());
207  maps_["e4oEtot"].push_back(ld.e4oEtot());
208  maps_["layerEfrac10"].push_back(ld.layerEfrac10());
209  maps_["layerEfrac90"].push_back(ld.layerEfrac90());
210 
211  // depth
212  maps_["measuredDepth"].push_back(measuredDepth);
213  maps_["expectedDepth"].push_back(expectedDepth);
214  maps_["expectedSigma"].push_back(expectedSigma);
215  maps_["depthCompatibility"].push_back(depthCompatibility);
216 
217  // Isolation
218  maps_["caloIsoRing0"].push_back(eIDHelper_->getIsolationRing(0));
219  maps_["caloIsoRing1"].push_back(eIDHelper_->getIsolationRing(1));
220  maps_["caloIsoRing2"].push_back(eIDHelper_->getIsolationRing(2));
221  maps_["caloIsoRing3"].push_back(eIDHelper_->getIsolationRing(3));
222  maps_["caloIsoRing4"].push_back(eIDHelper_->getIsolationRing(4));
223  }
224  }
225 
226  // Check we didn't make up a new variable and forget it in valuesProduced_
227  if ( maps_.size() != valuesProduced_.size() ) {
228  throw cms::Exception("HGCalElectronIDValueMapProducer") << "We have a miscoded value map producer, since map size changed";
229  }
230 
231  for(auto&& kv : maps_) {
232  // Check we didn't forget any values
233  if ( kv.second.size() != electronsH->size() ) {
234  throw cms::Exception("HGCalElectronIDValueMapProducer") << "We have a miscoded value map producer, since the variable " << kv.first << " wasn't filled.";
235  }
236  // Do the filling
237  auto out = std::make_unique<edm::ValueMap<float>>();
239  filler.insert(electronsH, kv.second.begin(), kv.second.end());
240  filler.fill();
241  // and put it into the event
242  iEvent.put(std::move(out), kv.first);
243  }
244 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
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_
HLT enums.
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

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

Definition at line 61 of file HGCalElectronIDValueMapProducer.cc.

Referenced by HGCalElectronIDValueMapProducer(), and produce().

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

Definition at line 55 of file HGCalElectronIDValueMapProducer.cc.

Referenced by produce().

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

Definition at line 59 of file HGCalElectronIDValueMapProducer.cc.

Referenced by HGCalElectronIDValueMapProducer(), and produce().

float HGCalElectronIDValueMapProducer::radius_
private

Definition at line 56 of file HGCalElectronIDValueMapProducer.cc.

Referenced by produce().

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