CMS 3D CMS Logo

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

#include <RecoEgamma/ElectronIdentification/plugins/ElectronMVANtuplizer.cc>

Inheritance diagram for ElectronMVANtuplizer:
edm::one::EDAnalyzer< edm::one::SharedResources > edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 ElectronMVANtuplizer (const edm::ParameterSet &)
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::SharedResources >
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void beginJob () override
 
void endJob () override
 
int matchToTruth (reco::GsfElectron const &electron, edm::View< reco::GenParticle > const &genParticles) const
 

Private Attributes

const double deltaR_
 
const bool doEnergyMatrix_
 
const edm::EDGetTokenT< EcalRecHitCollectionebRecHits_
 
const EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_
 
const edm::EDGetTokenT< EcalRecHitCollectioneeRecHits_
 
int ele3Q_
 
bool eleIsEB_
 
bool eleIsEBEEGap_
 
bool eleIsEBEtaGap_
 
bool eleIsEBPhiGap_
 
bool eleIsEE_
 
bool eleIsEEDeeGap_
 
bool eleIsEERingGap_
 
const std::vector< std::string > eleMapBranchNames_
 
const std::vector< std::string > eleMapTags_
 
std::vector< edm::EDGetTokenT< edm::ValueMap< bool > > > eleMapTokens_
 
float eleQ_
 
std::vector< float > energyMatrix_
 
const int energyMatrixSize_
 
int genNpu_
 
const edm::EDGetTokenT< edm::View< reco::GenParticle > > genParticles_
 
const bool isMC_
 
int matchedToGenEle_
 
const std::vector< std::string > mvaCatBranchNames_
 
std::vector< int > mvaCats_
 
const std::vector< std::string > mvaCatTags_
 
std::vector< edm::EDGetTokenT< edm::ValueMap< int > > > mvaCatTokens_
 
std::vector< int > mvaPasses_
 
std::vector< float > mvaValues_
 
MVAVariableManager< reco::GsfElectronmvaVarMngr_
 
const size_t nCats_
 
const size_t nEleMaps_
 
int nEvent_
 
int nLumi_
 
int nRun_
 
const size_t nValMaps_
 
const int nVars_
 
const edm::EDGetTokenT< std::vector< PileupSummaryInfo > > pileup_
 
const double ptThreshold_
 
const edm::EDGetTokenT< edm::View< reco::GsfElectron > > src_
 
TTree * tree_
 
const std::vector< std::string > valMapBranchNames_
 
const std::vector< std::string > valMapTags_
 
std::vector< edm::EDGetTokenT< edm::ValueMap< float > > > valMapTokens_
 
const MVAVariableHelper variableHelper_
 
std::vector< float > vars_
 
const edm::EDGetTokenT< std::vector< reco::Vertex > > vertices_
 
int vtxN_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Description: Ntuplizer for training and testing electron MVA IDs.

Implementation: [Notes on implementation]

Definition at line 46 of file ElectronMVANtuplizer.cc.

Constructor & Destructor Documentation

◆ ElectronMVANtuplizer()

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

Definition at line 152 of file ElectronMVANtuplizer.cc.

References edm::EDConsumerBase::consumesCollector().

153  : isMC_(iConfig.getParameter<bool>("isMC")),
154  deltaR_(iConfig.getParameter<double>("deltaR")),
155  ptThreshold_(iConfig.getParameter<double>("ptThreshold")),
156  eleMapTags_(iConfig.getParameter<std::vector<std::string>>("eleMVAs")),
157  eleMapBranchNames_(iConfig.getParameter<std::vector<std::string>>("eleMVALabels")),
159  valMapTags_(iConfig.getParameter<std::vector<std::string>>("eleMVAValMaps")),
160  valMapBranchNames_(iConfig.getParameter<std::vector<std::string>>("eleMVAValMapLabels")),
162  mvaCatTags_(iConfig.getParameter<std::vector<std::string>>("eleMVACats")),
163  mvaCatBranchNames_(iConfig.getParameter<std::vector<std::string>>("eleMVACatLabels")),
164  nCats_(mvaCatBranchNames_.size()),
166  vertices_(consumes<std::vector<reco::Vertex>>(iConfig.getParameter<edm::InputTag>("vertices"))),
167  pileup_(consumes<std::vector<PileupSummaryInfo>>(iConfig.getParameter<edm::InputTag>("pileup"))),
169  ebRecHits_(consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("ebReducedRecHitCollection"))),
170  eeRecHits_(consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("eeReducedRecHitCollection"))),
174  mvaCats_(nCats_),
176  mvaVarMngr_(iConfig.getParameter<std::string>("variableDefinition"), MVAVariableHelper::indexMap()),
178  vars_(nVars_),
179  doEnergyMatrix_(iConfig.getParameter<bool>("doEnergyMatrix")),
180  energyMatrixSize_(iConfig.getParameter<int>("energyMatrixSize")) {
181  // eleMaps
182  for (auto const& tag : eleMapTags_) {
184  }
185  // valMaps
186  for (auto const& tag : valMapTags_) {
188  }
189  // categories
190  for (auto const& tag : mvaCatTags_) {
192  }
193 
194  // Book tree
195  usesResource(TFileService::kSharedResource);
197  tree_ = fs->make<TTree>("tree", "tree");
198 
199  tree_->Branch("nEvent", &nEvent_);
200  tree_->Branch("nRun", &nRun_);
201  tree_->Branch("nLumi", &nLumi_);
202  if (isMC_)
203  tree_->Branch("genNpu", &genNpu_);
204  tree_->Branch("vtxN", &vtxN_);
205 
206  tree_->Branch("ele_q", &eleQ_);
207  tree_->Branch("ele_3q", &ele3Q_);
208 
209  if (doEnergyMatrix_)
210  tree_->Branch("energyMatrix", &energyMatrix_);
211 
212  if (isMC_)
213  tree_->Branch("matchedToGenEle", &matchedToGenEle_);
214 
215  for (int i = 0; i < nVars_; ++i)
216  tree_->Branch(mvaVarMngr_.getName(i).c_str(), &vars_[i]);
217 
218  tree_->Branch("ele_isEB", &eleIsEB_);
219  tree_->Branch("ele_isEE", &eleIsEE_);
220  tree_->Branch("ele_isEBEtaGap", &eleIsEBEtaGap_);
221  tree_->Branch("ele_isEBPhiGap", &eleIsEBPhiGap_);
222  tree_->Branch("ele_isEBEEGap", &eleIsEBEEGap_);
223  tree_->Branch("ele_isEEDeeGap", &eleIsEEDeeGap_);
224  tree_->Branch("ele_isEERingGap", &eleIsEERingGap_);
225 
226  // IDs
227  for (size_t k = 0; k < nValMaps_; ++k) {
228  tree_->Branch(valMapBranchNames_[k].c_str(), &mvaValues_[k]);
229  }
230 
231  for (size_t k = 0; k < nEleMaps_; ++k) {
232  tree_->Branch(eleMapBranchNames_[k].c_str(), &mvaPasses_[k]);
233  }
234 
235  for (size_t k = 0; k < nCats_; ++k) {
236  tree_->Branch(mvaCatBranchNames_[k].c_str(), &mvaCats_[k]);
237  }
238 }
static const std::string kSharedResource
Definition: TFileService.h:76
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::vector< edm::EDGetTokenT< edm::ValueMap< bool > > > eleMapTokens_
const edm::EDGetTokenT< std::vector< PileupSummaryInfo > > pileup_
const edm::EDGetTokenT< EcalRecHitCollection > ebRecHits_
std::vector< edm::EDGetTokenT< edm::ValueMap< int > > > mvaCatTokens_
const std::vector< std::string > mvaCatBranchNames_
std::vector< float > mvaValues_
std::vector< edm::EDGetTokenT< edm::ValueMap< float > > > valMapTokens_
const EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_
static std::unordered_map< std::string, int > indexMap()
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
const std::string & getName(int index) const
const std::vector< std::string > eleMapBranchNames_
const std::vector< std::string > valMapTags_
const std::vector< std::string > mvaCatTags_
const edm::EDGetTokenT< std::vector< reco::Vertex > > vertices_
const std::vector< std::string > valMapBranchNames_
std::vector< float > energyMatrix_
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
std::vector< int > mvaPasses_
const MVAVariableHelper variableHelper_
std::vector< int > mvaCats_
const edm::EDGetTokenT< edm::View< reco::GsfElectron > > src_
const edm::EDGetTokenT< edm::View< reco::GenParticle > > genParticles_
const std::vector< std::string > eleMapTags_
std::vector< float > vars_
MVAVariableManager< reco::GsfElectron > mvaVarMngr_
const edm::EDGetTokenT< EcalRecHitCollection > eeRecHits_

Member Function Documentation

◆ analyze()

void ElectronMVANtuplizer::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 241 of file ElectronMVANtuplizer.cc.

References simKBmtfDigis_cfi::bx, doEnergyMatrix_, ebRecHits_, ecalClusterToolsESGetTokens_, eeRecHits_, ele3Q_, eleIsEB_, eleIsEBEEGap_, eleIsEBEtaGap_, eleIsEBPhiGap_, eleIsEE_, eleIsEEDeeGap_, eleIsEERingGap_, eleMapTokens_, eleQ_, energyMatrix_, energyMatrixSize_, genNpu_, AJJGenJetFilter_cfi::genParticles, genParticles_, EcalClusterLazyToolsBase::ESGetTokens::get(), MVAVariableHelper::getAuxVariables(), MVAVariableManager< ParticleType >::getValue(), iEvent, isMC_, dqmdumpme::k, matchedToGenEle_, matchToTruth(), mvaCats_, mvaCatTokens_, mvaPasses_, mvaValues_, mvaVarMngr_, nCats_, nEleMaps_, nEvent_, nLumi_, nRun_, nValMaps_, nVars_, mixOne_premix_on_sim_cfi::pileup, pileup_, ptThreshold_, displacedMuons_cfi::pu, fileCollector::seed, TrackRefitter_38T_cff::src, src_, tree_, valMapTokens_, contentValuesCheck::values, variableHelper_, vars_, AlignmentTracksFromVertexSelector_cfi::vertices, vertices_, and vtxN_.

241  {
242  // Fill global event info
243  nEvent_ = iEvent.id().event();
244  nRun_ = iEvent.id().run();
245  nLumi_ = iEvent.luminosityBlock();
246 
247  // Get Handles
248  auto src = iEvent.getHandle(src_);
249  auto vertices = iEvent.getHandle(vertices_);
250 
251  // initialize cluster tools
252  std::unique_ptr<noZS::EcalClusterLazyTools> lazyTools;
253  if (doEnergyMatrix_) {
254  // Configure Lazy Tools, which will compute 5x5 quantities
255  lazyTools = std::make_unique<noZS::EcalClusterLazyTools>(
257  }
258 
259  // Get MC only Handles, which are allowed to be non-valid
260  auto genParticles = iEvent.getHandle(genParticles_);
261  auto pileup = iEvent.getHandle(pileup_);
262 
263  vtxN_ = vertices->size();
264 
265  // Fill with true number of pileup
266  if (isMC_) {
267  for (const auto& pu : *pileup) {
268  int bx = pu.getBunchCrossing();
269  if (bx == 0) {
270  genNpu_ = pu.getPU_NumInteractions();
271  break;
272  }
273  }
274  }
275 
276  // Get MVA decisions
278  for (size_t k = 0; k < nEleMaps_; ++k) {
279  iEvent.getByToken(eleMapTokens_[k], decisions[k]);
280  }
281 
282  // Get MVA values
284  for (size_t k = 0; k < nValMaps_; ++k) {
285  iEvent.getByToken(valMapTokens_[k], values[k]);
286  }
287 
288  // Get MVA categories
290  for (size_t k = 0; k < nCats_; ++k) {
291  iEvent.getByToken(mvaCatTokens_[k], mvaCats[k]);
292  }
293 
294  std::vector<float> extraVariables = variableHelper_.getAuxVariables(iEvent);
295 
296  for (auto const& ele : src->ptrs()) {
297  if (ele->pt() < ptThreshold_)
298  continue;
299 
300  // Fill the energy matrix around the seed
301  if (doEnergyMatrix_) {
302  const auto& seed = *(ele->superCluster()->seed());
303  energyMatrix_ = lazyTools->energyMatrix(seed, energyMatrixSize_);
304  }
305 
306  // Fill various tree variable
307  eleQ_ = ele->charge();
308  ele3Q_ = ele->chargeInfo().isGsfCtfScPixConsistent;
309 
310  for (int iVar = 0; iVar < nVars_; ++iVar) {
311  vars_[iVar] = mvaVarMngr_.getValue(iVar, *ele, extraVariables);
312  }
313 
314  if (isMC_) {
316  }
317 
318  // gap variables
319  eleIsEB_ = ele->isEB();
320  eleIsEE_ = ele->isEE();
321  eleIsEBEEGap_ = ele->isEBEEGap();
322  eleIsEBEtaGap_ = ele->isEBEtaGap();
323  eleIsEBPhiGap_ = ele->isEBPhiGap();
324  eleIsEEDeeGap_ = ele->isEEDeeGap();
325  eleIsEERingGap_ = ele->isEERingGap();
326 
327  //
328  // Look up and save the ID decisions
329  //
330  for (size_t k = 0; k < nEleMaps_; ++k)
331  mvaPasses_[k] = static_cast<int>((*decisions[k])[ele]);
332  for (size_t k = 0; k < nValMaps_; ++k)
333  mvaValues_[k] = (*values[k])[ele];
334  for (size_t k = 0; k < nCats_; ++k)
335  mvaCats_[k] = (*mvaCats[k])[ele];
336 
337  tree_->Fill();
338  }
339 }
std::vector< edm::EDGetTokenT< edm::ValueMap< bool > > > eleMapTokens_
const edm::EDGetTokenT< std::vector< PileupSummaryInfo > > pileup_
const edm::EDGetTokenT< EcalRecHitCollection > ebRecHits_
std::vector< edm::EDGetTokenT< edm::ValueMap< int > > > mvaCatTokens_
std::vector< float > mvaValues_
std::vector< edm::EDGetTokenT< edm::ValueMap< float > > > valMapTokens_
const EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_
ESData get(edm::EventSetup const &eventSetup) const
int iEvent
Definition: GenABIO.cc:224
const edm::EDGetTokenT< std::vector< reco::Vertex > > vertices_
std::vector< float > energyMatrix_
std::vector< int > mvaPasses_
const MVAVariableHelper variableHelper_
std::vector< int > mvaCats_
const edm::EDGetTokenT< edm::View< reco::GsfElectron > > src_
const edm::EDGetTokenT< edm::View< reco::GenParticle > > genParticles_
int matchToTruth(reco::GsfElectron const &electron, edm::View< reco::GenParticle > const &genParticles) const
float getValue(int index, const ParticleType &particle, const std::vector< float > &auxVariables) const
std::vector< float > vars_
MVAVariableManager< reco::GsfElectron > mvaVarMngr_
const edm::EDGetTokenT< EcalRecHitCollection > eeRecHits_
const std::vector< float > getAuxVariables(const edm::Event &iEvent) const

◆ beginJob()

void ElectronMVANtuplizer::beginJob ( void  )
inlineoverrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 56 of file ElectronMVANtuplizer.cc.

56 {};

◆ endJob()

void ElectronMVANtuplizer::endJob ( void  )
inlineoverrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 58 of file ElectronMVANtuplizer.cc.

58 {};

◆ fillDescriptions()

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

Definition at line 376 of file ElectronMVANtuplizer.cc.

References edm::ConfigurationDescriptions::addDefault(), submitPVResolutionJobs::desc, HLT_2022v11_cff::InputTag, and AlCaHLTBitMon_QueryRunRegistry::string.

376  {
378  desc.add<edm::InputTag>("src", edm::InputTag("slimmedElectrons"));
379  desc.add<edm::InputTag>("vertices", edm::InputTag("offlineSlimmedPrimaryVertices"));
380  desc.add<edm::InputTag>("pileup", edm::InputTag("slimmedAddPileupInfo"));
381  desc.add<edm::InputTag>("genParticles", edm::InputTag("prunedGenParticles"));
382  desc.add<edm::InputTag>("ebReducedRecHitCollection", edm::InputTag("reducedEgamma", "reducedEBRecHits"));
383  desc.add<edm::InputTag>("eeReducedRecHitCollection", edm::InputTag("reducedEgamma", "reducedEERecHits"));
384  desc.add<std::string>("variableDefinition");
385  desc.add<bool>("doEnergyMatrix", false);
386  desc.add<int>("energyMatrixSize", 2)->setComment("extension of crystals in each direction away from the seed");
387  desc.add<bool>("isMC", true);
388  desc.add<double>("deltaR", 0.1);
389  desc.add<double>("ptThreshold", 5.0);
390  desc.add<std::vector<std::string>>("eleMVAs", {});
391  desc.add<std::vector<std::string>>("eleMVALabels", {});
392  desc.add<std::vector<std::string>>("eleMVAValMaps", {});
393  desc.add<std::vector<std::string>>("eleMVAValMapLabels", {});
394  desc.add<std::vector<std::string>>("eleMVACats", {});
395  desc.add<std::vector<std::string>>("eleMVACatLabels", {});
396  descriptions.addDefault(desc);
397 }
void addDefault(ParameterSetDescription const &psetDescription)

◆ matchToTruth()

int ElectronMVANtuplizer::matchToTruth ( reco::GsfElectron const &  electron,
edm::View< reco::GenParticle > const &  genParticles 
) const
private

Definition at line 341 of file ElectronMVANtuplizer.cc.

References funct::abs(), electronAnalyzer_cfi::DeltaR, deltaR_, HGC3DClusterGenMatchSelector_cfi::dR, HPSPFTauProducerPuppi_cfi::electron, reco::GenParticle::fromHardProcessFinalState(), AJJGenJetFilter_cfi::genParticles, reco::GenParticle::isDirectHardProcessTauDecayProductFinalState(), TRUE_ELECTRON_FROM_TAU, TRUE_NON_PROMPT_ELECTRON, TRUE_PROMPT_ELECTRON, and UNMATCHED.

Referenced by analyze().

342  {
343  //
344  // Explicit loop and geometric matching method (advised by Josh Bendavid)
345  //
346 
347  // Find the closest status 1 gen electron to the reco electron
348  double dR = 999;
349  reco::GenParticle const* closestElectron = nullptr;
350  for (auto const& particle : genParticles) {
351  // Drop everything that is not electron or not status 1
352  if (std::abs(particle.pdgId()) != 11 || particle.status() != 1)
353  continue;
354  //
355  double dRtmp = ROOT::Math::VectorUtil::DeltaR(electron.p4(), particle.p4());
356  if (dRtmp < dR) {
357  dR = dRtmp;
358  closestElectron = &particle;
359  }
360  }
361  // See if the closest electron is close enough. If not, no match found.
362  if (closestElectron == nullptr || dR >= deltaR_)
363  return UNMATCHED;
364 
365  if (closestElectron->fromHardProcessFinalState())
366  return TRUE_PROMPT_ELECTRON;
367 
368  if (closestElectron->isDirectHardProcessTauDecayProductFinalState())
369  return TRUE_ELECTRON_FROM_TAU;
370 
371  // What remains is true non-prompt electrons
373 }
bool isDirectHardProcessTauDecayProductFinalState() const
Definition: GenParticle.h:85
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool fromHardProcessFinalState() const
Definition: GenParticle.h:75

Member Data Documentation

◆ deltaR_

const double ElectronMVANtuplizer::deltaR_
private

Definition at line 89 of file ElectronMVANtuplizer.cc.

Referenced by matchToTruth().

◆ doEnergyMatrix_

const bool ElectronMVANtuplizer::doEnergyMatrix_
private

Definition at line 134 of file ElectronMVANtuplizer.cc.

Referenced by analyze().

◆ ebRecHits_

const edm::EDGetTokenT<EcalRecHitCollection> ElectronMVANtuplizer::ebRecHits_
private

Definition at line 114 of file ElectronMVANtuplizer.cc.

Referenced by analyze().

◆ ecalClusterToolsESGetTokens_

const EcalClusterLazyTools::ESGetTokens ElectronMVANtuplizer::ecalClusterToolsESGetTokens_
private

Definition at line 117 of file ElectronMVANtuplizer.cc.

Referenced by analyze().

◆ eeRecHits_

const edm::EDGetTokenT<EcalRecHitCollection> ElectronMVANtuplizer::eeRecHits_
private

Definition at line 115 of file ElectronMVANtuplizer.cc.

Referenced by analyze().

◆ ele3Q_

int ElectronMVANtuplizer::ele3Q_
private

Definition at line 73 of file ElectronMVANtuplizer.cc.

Referenced by analyze().

◆ eleIsEB_

bool ElectronMVANtuplizer::eleIsEB_
private

Definition at line 79 of file ElectronMVANtuplizer.cc.

Referenced by analyze().

◆ eleIsEBEEGap_

bool ElectronMVANtuplizer::eleIsEBEEGap_
private

Definition at line 83 of file ElectronMVANtuplizer.cc.

Referenced by analyze().

◆ eleIsEBEtaGap_

bool ElectronMVANtuplizer::eleIsEBEtaGap_
private

Definition at line 81 of file ElectronMVANtuplizer.cc.

Referenced by analyze().

◆ eleIsEBPhiGap_

bool ElectronMVANtuplizer::eleIsEBPhiGap_
private

Definition at line 82 of file ElectronMVANtuplizer.cc.

Referenced by analyze().

◆ eleIsEE_

bool ElectronMVANtuplizer::eleIsEE_
private

Definition at line 80 of file ElectronMVANtuplizer.cc.

Referenced by analyze().

◆ eleIsEEDeeGap_

bool ElectronMVANtuplizer::eleIsEEDeeGap_
private

Definition at line 84 of file ElectronMVANtuplizer.cc.

Referenced by analyze().

◆ eleIsEERingGap_

bool ElectronMVANtuplizer::eleIsEERingGap_
private

Definition at line 85 of file ElectronMVANtuplizer.cc.

Referenced by analyze().

◆ eleMapBranchNames_

const std::vector<std::string> ElectronMVANtuplizer::eleMapBranchNames_
private

Definition at line 95 of file ElectronMVANtuplizer.cc.

◆ eleMapTags_

const std::vector<std::string> ElectronMVANtuplizer::eleMapTags_
private

Definition at line 93 of file ElectronMVANtuplizer.cc.

◆ eleMapTokens_

std::vector<edm::EDGetTokenT<edm::ValueMap<bool> > > ElectronMVANtuplizer::eleMapTokens_
private

Definition at line 94 of file ElectronMVANtuplizer.cc.

Referenced by analyze().

◆ eleQ_

float ElectronMVANtuplizer::eleQ_
private

Definition at line 72 of file ElectronMVANtuplizer.cc.

Referenced by analyze().

◆ energyMatrix_

std::vector<float> ElectronMVANtuplizer::energyMatrix_
private

Definition at line 76 of file ElectronMVANtuplizer.cc.

Referenced by analyze().

◆ energyMatrixSize_

const int ElectronMVANtuplizer::energyMatrixSize_
private

Definition at line 135 of file ElectronMVANtuplizer.cc.

Referenced by analyze().

◆ genNpu_

int ElectronMVANtuplizer::genNpu_
private

Definition at line 68 of file ElectronMVANtuplizer.cc.

Referenced by analyze().

◆ genParticles_

const edm::EDGetTokenT<edm::View<reco::GenParticle> > ElectronMVANtuplizer::genParticles_
private

Definition at line 113 of file ElectronMVANtuplizer.cc.

Referenced by analyze().

◆ isMC_

const bool ElectronMVANtuplizer::isMC_
private

Definition at line 88 of file ElectronMVANtuplizer.cc.

Referenced by analyze().

◆ matchedToGenEle_

int ElectronMVANtuplizer::matchedToGenEle_
private

Definition at line 74 of file ElectronMVANtuplizer.cc.

Referenced by analyze().

◆ mvaCatBranchNames_

const std::vector<std::string> ElectronMVANtuplizer::mvaCatBranchNames_
private

Definition at line 106 of file ElectronMVANtuplizer.cc.

◆ mvaCats_

std::vector<int> ElectronMVANtuplizer::mvaCats_
private

Definition at line 122 of file ElectronMVANtuplizer.cc.

Referenced by analyze().

◆ mvaCatTags_

const std::vector<std::string> ElectronMVANtuplizer::mvaCatTags_
private

Definition at line 104 of file ElectronMVANtuplizer.cc.

◆ mvaCatTokens_

std::vector<edm::EDGetTokenT<edm::ValueMap<int> > > ElectronMVANtuplizer::mvaCatTokens_
private

Definition at line 105 of file ElectronMVANtuplizer.cc.

Referenced by analyze().

◆ mvaPasses_

std::vector<int> ElectronMVANtuplizer::mvaPasses_
private

Definition at line 120 of file ElectronMVANtuplizer.cc.

Referenced by analyze().

◆ mvaValues_

std::vector<float> ElectronMVANtuplizer::mvaValues_
private

Definition at line 121 of file ElectronMVANtuplizer.cc.

Referenced by analyze().

◆ mvaVarMngr_

MVAVariableManager<reco::GsfElectron> ElectronMVANtuplizer::mvaVarMngr_
private

Definition at line 130 of file ElectronMVANtuplizer.cc.

Referenced by analyze().

◆ nCats_

const size_t ElectronMVANtuplizer::nCats_
private

Definition at line 107 of file ElectronMVANtuplizer.cc.

Referenced by analyze().

◆ nEleMaps_

const size_t ElectronMVANtuplizer::nEleMaps_
private

Definition at line 96 of file ElectronMVANtuplizer.cc.

Referenced by analyze().

◆ nEvent_

int ElectronMVANtuplizer::nEvent_
private

Definition at line 65 of file ElectronMVANtuplizer.cc.

Referenced by analyze().

◆ nLumi_

int ElectronMVANtuplizer::nLumi_
private

Definition at line 67 of file ElectronMVANtuplizer.cc.

Referenced by analyze().

◆ nRun_

int ElectronMVANtuplizer::nRun_
private

Definition at line 66 of file ElectronMVANtuplizer.cc.

Referenced by analyze().

◆ nValMaps_

const size_t ElectronMVANtuplizer::nValMaps_
private

Definition at line 102 of file ElectronMVANtuplizer.cc.

Referenced by analyze().

◆ nVars_

const int ElectronMVANtuplizer::nVars_
private

Definition at line 131 of file ElectronMVANtuplizer.cc.

Referenced by analyze().

◆ pileup_

const edm::EDGetTokenT<std::vector<PileupSummaryInfo> > ElectronMVANtuplizer::pileup_
private

Definition at line 112 of file ElectronMVANtuplizer.cc.

Referenced by analyze().

◆ ptThreshold_

const double ElectronMVANtuplizer::ptThreshold_
private

Definition at line 90 of file ElectronMVANtuplizer.cc.

Referenced by analyze().

◆ src_

const edm::EDGetTokenT<edm::View<reco::GsfElectron> > ElectronMVANtuplizer::src_
private

Definition at line 110 of file ElectronMVANtuplizer.cc.

Referenced by analyze().

◆ tree_

TTree* ElectronMVANtuplizer::tree_
private

Definition at line 128 of file ElectronMVANtuplizer.cc.

Referenced by analyze().

◆ valMapBranchNames_

const std::vector<std::string> ElectronMVANtuplizer::valMapBranchNames_
private

Definition at line 101 of file ElectronMVANtuplizer.cc.

◆ valMapTags_

const std::vector<std::string> ElectronMVANtuplizer::valMapTags_
private

Definition at line 99 of file ElectronMVANtuplizer.cc.

◆ valMapTokens_

std::vector<edm::EDGetTokenT<edm::ValueMap<float> > > ElectronMVANtuplizer::valMapTokens_
private

Definition at line 100 of file ElectronMVANtuplizer.cc.

Referenced by analyze().

◆ variableHelper_

const MVAVariableHelper ElectronMVANtuplizer::variableHelper_
private

Definition at line 125 of file ElectronMVANtuplizer.cc.

Referenced by analyze().

◆ vars_

std::vector<float> ElectronMVANtuplizer::vars_
private

Definition at line 132 of file ElectronMVANtuplizer.cc.

Referenced by analyze().

◆ vertices_

const edm::EDGetTokenT<std::vector<reco::Vertex> > ElectronMVANtuplizer::vertices_
private

Definition at line 111 of file ElectronMVANtuplizer.cc.

Referenced by analyze().

◆ vtxN_

int ElectronMVANtuplizer::vtxN_
private

Definition at line 69 of file ElectronMVANtuplizer.cc.

Referenced by analyze().