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
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () 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
 
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::vector< ModuleDescription const * > &modules, 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
 
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 MultiTokenT< EcalRecHitCollectionebRecHits_
 
const MultiTokenT< EcalRecHitCollectioneeRecHits_
 
int ele3Q_
 
int eleIndex_
 
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 MultiTokenT< 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 MultiTokenT< std::vector< PileupSummaryInfo > > pileup_
 
const double ptThreshold_
 
const MultiTokenT< 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< reco::GsfElectronvariableHelper_
 
std::vector< float > vars_
 
const MultiTokenT< 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)
 
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<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)
 

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 ( const edm::ParameterSet iConfig)
explicit

Definition at line 153 of file ElectronMVANtuplizer.cc.

References edm::EDConsumerBase::consumes(), doEnergyMatrix_, ele3Q_, eleIndex_, eleIsEB_, eleIsEBEEGap_, eleIsEBEtaGap_, eleIsEBPhiGap_, eleIsEE_, eleIsEEDeeGap_, eleIsEERingGap_, eleMapBranchNames_, eleMapTags_, eleMapTokens_, eleQ_, energyMatrix_, genNpu_, MVAVariableManager< ParticleType >::getName(), mps_fire::i, isMC_, gen::k, TFileService::kSharedResource, TFileService::make(), matchedToGenEle_, mvaCatBranchNames_, mvaCats_, mvaCatTags_, mvaCatTokens_, mvaPasses_, mvaValues_, mvaVarMngr_, nCats_, nEleMaps_, nEvent_, nLumi_, nRun_, nValMaps_, nVars_, GlobalPosition_Frontier_DevDB_cff::tag, tree_, valMapBranchNames_, valMapTags_, valMapTokens_, vars_, and vtxN_.

154  : isMC_ (iConfig.getParameter<bool>("isMC"))
155  , deltaR_ (iConfig.getParameter<double>("deltaR"))
156  , ptThreshold_ (iConfig.getParameter<double>("ptThreshold"))
157  , eleMapTags_ (iConfig.getParameter<std::vector<std::string>>("eleMVAs"))
158  , eleMapBranchNames_ (iConfig.getParameter<std::vector<std::string>>("eleMVALabels"))
159  , nEleMaps_ (eleMapBranchNames_.size())
160  , valMapTags_ (iConfig.getParameter<std::vector<std::string>>("eleMVAValMaps"))
161  , valMapBranchNames_ (iConfig.getParameter<std::vector<std::string>>("eleMVAValMapLabels"))
162  , nValMaps_ (valMapBranchNames_.size())
163  , mvaCatTags_ (iConfig.getParameter<std::vector<std::string>>("eleMVACats"))
164  , mvaCatBranchNames_ (iConfig.getParameter<std::vector<std::string>>("eleMVACatLabels"))
165  , nCats_ (mvaCatBranchNames_.size())
166  , src_ (consumesCollector(), iConfig, "src" , "srcMiniAOD")
167  , vertices_ (src_, consumesCollector(), iConfig, "vertices" , "verticesMiniAOD")
168  , pileup_ (src_, consumesCollector(), iConfig, "pileup" , "pileupMiniAOD")
169  , genParticles_ (src_, consumesCollector(), iConfig, "genParticles", "genParticlesMiniAOD")
170  , ebRecHits_ (src_, consumesCollector(), iConfig, "ebReducedRecHitCollection", "ebReducedRecHitCollectionMiniAOD")
171  , eeRecHits_ (src_, consumesCollector(), iConfig, "eeReducedRecHitCollection", "eeReducedRecHitCollectionMiniAOD")
174  , mvaCats_ (nCats_)
176  , mvaVarMngr_ (iConfig.getParameter<std::string>("variableDefinition"))
178  , vars_ (nVars_)
179  , doEnergyMatrix_ (iConfig.getParameter<bool>("doEnergyMatrix"))
180  , energyMatrixSize_ (iConfig.getParameter<int>("energyMatrixSize"))
181 {
182  // eleMaps
183  for (auto const& tag : eleMapTags_) {
185  }
186  // valMaps
187  for (auto const& tag : valMapTags_) {
189  }
190  // categories
191  for (auto const& tag : mvaCatTags_) {
193  }
194 
195  // Book tree
196  usesResource(TFileService::kSharedResource);
198  tree_ = fs->make<TTree>("tree","tree");
199 
200  tree_->Branch("nEvent", &nEvent_);
201  tree_->Branch("nRun", &nRun_);
202  tree_->Branch("nLumi", &nLumi_);
203  if (isMC_) 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_) tree_->Branch("energyMatrix",&energyMatrix_);
210 
211  if (isMC_) tree_->Branch("matchedToGenEle", &matchedToGenEle_);
212 
213  for (int i = 0; i < nVars_; ++i) tree_->Branch(mvaVarMngr_.getName(i).c_str(), &vars_[i]);
214 
215  tree_->Branch("ele_isEB",&eleIsEB_);
216  tree_->Branch("ele_isEE",&eleIsEE_);
217  tree_->Branch("ele_isEBEtaGap",&eleIsEBEtaGap_);
218  tree_->Branch("ele_isEBPhiGap",&eleIsEBPhiGap_);
219  tree_->Branch("ele_isEBEEGap", &eleIsEBEEGap_);
220  tree_->Branch("ele_isEEDeeGap",&eleIsEEDeeGap_);
221  tree_->Branch("ele_isEERingGap",&eleIsEERingGap_);
222 
223  tree_->Branch("ele_index",&eleIndex_);
224 
225  // IDs
226  for (size_t k = 0; k < nValMaps_; ++k) {
227  tree_->Branch(valMapBranchNames_[k].c_str() , &mvaValues_[k]);
228  }
229 
230  for (size_t k = 0; k < nEleMaps_; ++k) {
231  tree_->Branch(eleMapBranchNames_[k].c_str() , &mvaPasses_[k]);
232  }
233 
234  for (size_t k = 0; k < nCats_; ++k) {
235  tree_->Branch(mvaCatBranchNames_[k].c_str() , &mvaCats_[k]);
236  }
237 }
static const std::string kSharedResource
Definition: TFileService.h:76
T getParameter(std::string const &) const
const std::string & getName(int index) const
const MVAVariableHelper< reco::GsfElectron > variableHelper_
const MultiTokenT< edm::View< reco::GenParticle > > genParticles_
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
std::vector< edm::EDGetTokenT< edm::ValueMap< int > > > mvaCatTokens_
std::vector< float > mvaValues_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
const MultiTokenT< EcalRecHitCollection > ebRecHits_
std::vector< float > energyMatrix_
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
std::vector< int > mvaPasses_
const std::vector< std::string > valMapBranchNames_
std::vector< int > mvaCats_
int k[5][pyjets_maxn]
const std::vector< std::string > eleMapBranchNames_
std::vector< float > vars_
const MultiTokenT< std::vector< PileupSummaryInfo > > pileup_
MVAVariableManager< reco::GsfElectron > mvaVarMngr_
std::vector< edm::EDGetTokenT< edm::ValueMap< float > > > valMapTokens_
const MultiTokenT< EcalRecHitCollection > eeRecHits_
const MultiTokenT< std::vector< reco::Vertex > > vertices_
const std::vector< std::string > mvaCatTags_
std::vector< edm::EDGetTokenT< edm::ValueMap< bool > > > eleMapTokens_
const MultiTokenT< edm::View< reco::GsfElectron > > src_
const std::vector< std::string > mvaCatBranchNames_
const std::vector< std::string > eleMapTags_
const std::vector< std::string > valMapTags_

Member Function Documentation

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

Definition at line 242 of file ElectronMVANtuplizer.cc.

References doEnergyMatrix_, ebRecHits_, eeRecHits_, ele3Q_, eleIndex_, eleIsEB_, eleIsEBEEGap_, eleIsEBEtaGap_, eleIsEBPhiGap_, eleIsEE_, eleIsEEDeeGap_, eleIsEERingGap_, eleMapTokens_, eleQ_, energyMatrix_, energyMatrixSize_, edm::EventID::event(), genNpu_, GenHFHadronMatcher_cfi::genParticles, genParticles_, MVAVariableHelper< ParticleType >::getAuxVariables(), edm::Event::getByToken(), MultiTokenT< T >::getHandle(), MultiTokenT< T >::getValidHandle(), MVAVariableManager< ParticleType >::getValue(), edm::EventBase::id(), iEvent, isMC_, gen::k, edm::EventBase::luminosityBlock(), matchedToGenEle_, matchToTruth(), mvaCats_, mvaCatTokens_, mvaValues_, mvaVarMngr_, nCats_, nEleMaps_, nEvent_, nLumi_, nRun_, nValMaps_, nVars_, estimatePileup_makeJSON::pileup, pileup_, ptThreshold_, muons2muons_cfi::pu, edm::EventID::run(), SurveyInfoScenario_cff::seed, TrackRefitter_38T_cff::src, src_, tree_, valMapTokens_, MuonErrorMatrixValues_cff::values, variableHelper_, vars_, electrons_cff::vertices, vertices_, and vtxN_.

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

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 56 of file ElectronMVANtuplizer.cc.

56 {};
void ElectronMVANtuplizer::endJob ( void  )
inlineoverrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 58 of file ElectronMVANtuplizer.cc.

References metsig::electron, GenHFHadronMatcher_cfi::genParticles, and matchToTruth().

58 {};
void ElectronMVANtuplizer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 377 of file ElectronMVANtuplizer.cc.

References edm::ParameterSetDescription::add(), edm::ConfigurationDescriptions::addDefault(), DEFINE_FWK_MODULE, and AlCaHLTBitMon_QueryRunRegistry::string.

378 {
380  desc.add<edm::InputTag>("src", edm::InputTag("gedGsfElectrons"));
381  desc.add<edm::InputTag>("vertices", edm::InputTag("offlinePrimaryVertices"));
382  desc.add<edm::InputTag>("pileup", edm::InputTag("addPileupInfo"));
383  desc.add<edm::InputTag>("genParticles", edm::InputTag("genParticles"));
384  desc.add<edm::InputTag>("srcMiniAOD", edm::InputTag("slimmedElectrons"));
385  desc.add<edm::InputTag>("verticesMiniAOD", edm::InputTag("offlineSlimmedPrimaryVertices"));
386  desc.add<edm::InputTag>("pileupMiniAOD", edm::InputTag("slimmedAddPileupInfo"));
387  desc.add<edm::InputTag>("genParticlesMiniAOD", edm::InputTag("prunedGenParticles"));
388  desc.add<edm::InputTag>("ebReducedRecHitCollection", edm::InputTag("reducedEcalRecHitsEB"));
389  desc.add<edm::InputTag>("eeReducedRecHitCollection", edm::InputTag("reducedEcalRecHitsEE"));
390  desc.add<edm::InputTag>("ebReducedRecHitCollectionMiniAOD", edm::InputTag("reducedEgamma","reducedEBRecHits"));
391  desc.add<edm::InputTag>("eeReducedRecHitCollectionMiniAOD", edm::InputTag("reducedEgamma","reducedEERecHits"));
392  desc.add<std::string>("variableDefinition");
393  desc.add<bool>("doEnergyMatrix", false);
394  desc.add<int>("energyMatrixSize", 2)->setComment("extension of crystals in each direction away from the seed");
395  desc.add<bool>("isMC", true);
396  desc.add<double>("deltaR", 0.1);
397  desc.add<double>("ptThreshold", 5.0);
398  desc.add<std::vector<std::string>>("eleMVAs", {});
399  desc.add<std::vector<std::string>>("eleMVALabels", {});
400  desc.add<std::vector<std::string>>("eleMVAValMaps", {});
401  desc.add<std::vector<std::string>>("eleMVAValMapLabels", {});
402  desc.add<std::vector<std::string>>("eleMVACats", {});
403  desc.add<std::vector<std::string>>("eleMVACatLabels", {});
404  descriptions.addDefault(desc);
405 
406 }
void addDefault(ParameterSetDescription const &psetDescription)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
int ElectronMVANtuplizer::matchToTruth ( reco::GsfElectron const &  electron,
edm::View< reco::GenParticle > const &  genParticles 
) const
private

Definition at line 343 of file ElectronMVANtuplizer.cc.

References funct::abs(), HiRegitMuonDetachedTripletStep_cff::DeltaR, deltaR_, reco::GenParticle::fromHardProcessFinalState(), reco::GenParticle::isDirectHardProcessTauDecayProductFinalState(), reco::GsfElectron::p4(), TRUE_ELECTRON_FROM_TAU, TRUE_NON_PROMPT_ELECTRON, TRUE_PROMPT_ELECTRON, and UNMATCHED.

Referenced by analyze(), and endJob().

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

Member Data Documentation

const double ElectronMVANtuplizer::deltaR_
private

Definition at line 92 of file ElectronMVANtuplizer.cc.

Referenced by matchToTruth().

const bool ElectronMVANtuplizer::doEnergyMatrix_
private

Definition at line 135 of file ElectronMVANtuplizer.cc.

Referenced by analyze(), and ElectronMVANtuplizer().

const MultiTokenT<EcalRecHitCollection> ElectronMVANtuplizer::ebRecHits_
private

Definition at line 117 of file ElectronMVANtuplizer.cc.

Referenced by analyze().

const MultiTokenT<EcalRecHitCollection> ElectronMVANtuplizer::eeRecHits_
private

Definition at line 118 of file ElectronMVANtuplizer.cc.

Referenced by analyze().

int ElectronMVANtuplizer::ele3Q_
private

Definition at line 74 of file ElectronMVANtuplizer.cc.

Referenced by analyze(), and ElectronMVANtuplizer().

int ElectronMVANtuplizer::eleIndex_
private

Definition at line 88 of file ElectronMVANtuplizer.cc.

Referenced by analyze(), and ElectronMVANtuplizer().

bool ElectronMVANtuplizer::eleIsEB_
private

Definition at line 80 of file ElectronMVANtuplizer.cc.

Referenced by analyze(), and ElectronMVANtuplizer().

bool ElectronMVANtuplizer::eleIsEBEEGap_
private

Definition at line 84 of file ElectronMVANtuplizer.cc.

Referenced by analyze(), and ElectronMVANtuplizer().

bool ElectronMVANtuplizer::eleIsEBEtaGap_
private

Definition at line 82 of file ElectronMVANtuplizer.cc.

Referenced by analyze(), and ElectronMVANtuplizer().

bool ElectronMVANtuplizer::eleIsEBPhiGap_
private

Definition at line 83 of file ElectronMVANtuplizer.cc.

Referenced by analyze(), and ElectronMVANtuplizer().

bool ElectronMVANtuplizer::eleIsEE_
private

Definition at line 81 of file ElectronMVANtuplizer.cc.

Referenced by analyze(), and ElectronMVANtuplizer().

bool ElectronMVANtuplizer::eleIsEEDeeGap_
private

Definition at line 85 of file ElectronMVANtuplizer.cc.

Referenced by analyze(), and ElectronMVANtuplizer().

bool ElectronMVANtuplizer::eleIsEERingGap_
private

Definition at line 86 of file ElectronMVANtuplizer.cc.

Referenced by analyze(), and ElectronMVANtuplizer().

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

Definition at line 98 of file ElectronMVANtuplizer.cc.

Referenced by ElectronMVANtuplizer().

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

Definition at line 96 of file ElectronMVANtuplizer.cc.

Referenced by ElectronMVANtuplizer().

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

Definition at line 97 of file ElectronMVANtuplizer.cc.

Referenced by analyze(), and ElectronMVANtuplizer().

float ElectronMVANtuplizer::eleQ_
private

Definition at line 73 of file ElectronMVANtuplizer.cc.

Referenced by analyze(), and ElectronMVANtuplizer().

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

Definition at line 77 of file ElectronMVANtuplizer.cc.

Referenced by analyze(), and ElectronMVANtuplizer().

const int ElectronMVANtuplizer::energyMatrixSize_
private

Definition at line 136 of file ElectronMVANtuplizer.cc.

Referenced by analyze().

int ElectronMVANtuplizer::genNpu_
private

Definition at line 69 of file ElectronMVANtuplizer.cc.

Referenced by analyze(), and ElectronMVANtuplizer().

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

Definition at line 116 of file ElectronMVANtuplizer.cc.

Referenced by analyze().

const bool ElectronMVANtuplizer::isMC_
private

Definition at line 91 of file ElectronMVANtuplizer.cc.

Referenced by analyze(), and ElectronMVANtuplizer().

int ElectronMVANtuplizer::matchedToGenEle_
private

Definition at line 75 of file ElectronMVANtuplizer.cc.

Referenced by analyze(), and ElectronMVANtuplizer().

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

Definition at line 109 of file ElectronMVANtuplizer.cc.

Referenced by ElectronMVANtuplizer().

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

Definition at line 123 of file ElectronMVANtuplizer.cc.

Referenced by analyze(), and ElectronMVANtuplizer().

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

Definition at line 107 of file ElectronMVANtuplizer.cc.

Referenced by ElectronMVANtuplizer().

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

Definition at line 108 of file ElectronMVANtuplizer.cc.

Referenced by analyze(), and ElectronMVANtuplizer().

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

Definition at line 121 of file ElectronMVANtuplizer.cc.

Referenced by ElectronMVANtuplizer().

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

Definition at line 122 of file ElectronMVANtuplizer.cc.

Referenced by analyze(), and ElectronMVANtuplizer().

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

Definition at line 131 of file ElectronMVANtuplizer.cc.

Referenced by analyze(), and ElectronMVANtuplizer().

const size_t ElectronMVANtuplizer::nCats_
private

Definition at line 110 of file ElectronMVANtuplizer.cc.

Referenced by analyze(), and ElectronMVANtuplizer().

const size_t ElectronMVANtuplizer::nEleMaps_
private

Definition at line 99 of file ElectronMVANtuplizer.cc.

Referenced by analyze(), and ElectronMVANtuplizer().

int ElectronMVANtuplizer::nEvent_
private

Definition at line 66 of file ElectronMVANtuplizer.cc.

Referenced by analyze(), and ElectronMVANtuplizer().

int ElectronMVANtuplizer::nLumi_
private

Definition at line 68 of file ElectronMVANtuplizer.cc.

Referenced by analyze(), and ElectronMVANtuplizer().

int ElectronMVANtuplizer::nRun_
private

Definition at line 67 of file ElectronMVANtuplizer.cc.

Referenced by analyze(), and ElectronMVANtuplizer().

const size_t ElectronMVANtuplizer::nValMaps_
private

Definition at line 105 of file ElectronMVANtuplizer.cc.

Referenced by analyze(), and ElectronMVANtuplizer().

const int ElectronMVANtuplizer::nVars_
private

Definition at line 132 of file ElectronMVANtuplizer.cc.

Referenced by analyze(), and ElectronMVANtuplizer().

const MultiTokenT<std::vector<PileupSummaryInfo> > ElectronMVANtuplizer::pileup_
private

Definition at line 115 of file ElectronMVANtuplizer.cc.

Referenced by analyze().

const double ElectronMVANtuplizer::ptThreshold_
private

Definition at line 93 of file ElectronMVANtuplizer.cc.

Referenced by analyze().

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

Definition at line 113 of file ElectronMVANtuplizer.cc.

Referenced by analyze().

TTree* ElectronMVANtuplizer::tree_
private

Definition at line 129 of file ElectronMVANtuplizer.cc.

Referenced by analyze(), and ElectronMVANtuplizer().

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

Definition at line 104 of file ElectronMVANtuplizer.cc.

Referenced by ElectronMVANtuplizer().

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

Definition at line 102 of file ElectronMVANtuplizer.cc.

Referenced by ElectronMVANtuplizer().

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

Definition at line 103 of file ElectronMVANtuplizer.cc.

Referenced by analyze(), and ElectronMVANtuplizer().

const MVAVariableHelper<reco::GsfElectron> ElectronMVANtuplizer::variableHelper_
private

Definition at line 126 of file ElectronMVANtuplizer.cc.

Referenced by analyze().

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

Definition at line 133 of file ElectronMVANtuplizer.cc.

Referenced by analyze(), and ElectronMVANtuplizer().

const MultiTokenT<std::vector<reco::Vertex> > ElectronMVANtuplizer::vertices_
private

Definition at line 114 of file ElectronMVANtuplizer.cc.

Referenced by analyze().

int ElectronMVANtuplizer::vtxN_
private

Definition at line 70 of file ElectronMVANtuplizer.cc.

Referenced by analyze(), and ElectronMVANtuplizer().