CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Types | Private Attributes
PFRecoTauDiscriminationByIsolationMVA2 Class Reference
Inheritance diagram for PFRecoTauDiscriminationByIsolationMVA2:
TauDiscriminationProducerBase< TauType, TauDiscriminator, TauDiscriminatorDataType, ConsumeType > edm::stream::EDProducer<>

Public Member Functions

void beginEvent (const edm::Event &, const edm::EventSetup &) override
 
reco::SingleTauDiscriminatorContainer discriminate (const PFTauRef &) const override
 
 PFRecoTauDiscriminationByIsolationMVA2 (const edm::ParameterSet &cfg)
 
 ~PFRecoTauDiscriminationByIsolationMVA2 () override
 
- Public Member Functions inherited from TauDiscriminationProducerBase< TauType, TauDiscriminator, TauDiscriminatorDataType, ConsumeType >
virtual TauDiscriminatorDataType discriminate (const TauRef &tau) const =0
 
virtual void endEvent (edm::Event &)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
 TauDiscriminationProducerBase (const edm::ParameterSet &iConfig)
 
 TauDiscriminationProducerBase ()
 
 ~TauDiscriminationProducerBase () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from TauDiscriminationProducerBase< TauType, TauDiscriminator, TauDiscriminatorDataType, ConsumeType >
static void fillProducerDescriptions (edm::ParameterSetDescription &desc)
 
static std::string getTauTypeString ()
 helper method to retrieve tau type name, e.g. to build correct cfi getter More...
 

Private Types

enum  { kOldDMwoLT, kOldDMwLT, kNewDMwoLT, kNewDMwLT }
 
typedef edm::AssociationVector< reco::PFTauRefProd, std::vector< reco::PFTauTransverseImpactParameterRef > > PFTauTIPAssociationByRef
 

Private Attributes

edm::Handle< reco::TauDiscriminatorContainerbasicTauDiscriminators_
 
edm::EDGetTokenT< reco::TauDiscriminatorContainerbasicTauDiscriminators_token_
 
int chargedIsoPtSum_index_
 
edm::FileInPath inputFileName_
 
std::vector< TFile * > inputFilesToDelete_
 
bool loadMVAfromDB_
 
std::string moduleLabel_
 
float * mvaInput_
 
std::string mvaName_
 
int mvaOpt_
 
const GBRForestmvaReader_
 
edm::ESGetToken< GBRForest, GBRWrapperRcdmvaToken_
 
int neutralIsoPtSum_index_
 
int pucorrPtSum_index_
 
edm::Handle< PFTauTIPAssociationByReftauLifetimeInfos_
 
edm::Handle< TauCollectiontaus_
 
edm::EDGetTokenT< PFTauTIPAssociationByReftauTransverseImpactParameters_token_
 
int verbosity_
 

Additional Inherited Members

- Public Types inherited from TauDiscriminationProducerBase< TauType, TauDiscriminator, TauDiscriminatorDataType, ConsumeType >
typedef std::vector< TauType > TauCollection
 
typedef edm::Ref< TauCollectionTauRef
 
typedef edm::RefProd< TauCollectionTauRefProd
 
- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 
- Protected Attributes inherited from TauDiscriminationProducerBase< TauType, TauDiscriminator, TauDiscriminatorDataType, ConsumeType >
std::string moduleLabel_
 
double prediscriminantFailValue_
 
edm::EDGetTokenT< TauCollectionTau_token
 
size_t tauIndex_
 
edm::InputTag TauProducer_
 

Detailed Description

Definition at line 62 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

Member Typedef Documentation

◆ PFTauTIPAssociationByRef

Definition at line 136 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private

Constructor & Destructor Documentation

◆ PFRecoTauDiscriminationByIsolationMVA2()

PFRecoTauDiscriminationByIsolationMVA2::PFRecoTauDiscriminationByIsolationMVA2 ( const edm::ParameterSet cfg)
inlineexplicit

Definition at line 64 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

References cms::cuda::assert(), looper::cfg, deDxTools::esConsumes(), Exception, reco::tau::kNewDMwLT, reco::tau::kNewDMwoLT, reco::tau::kOldDMwLT, reco::tau::kOldDMwoLT, and AlCaHLTBitMon_QueryRunRegistry::string.

66  moduleLabel_(cfg.getParameter<std::string>("@module_label")),
67  mvaReader_(nullptr),
68  mvaInput_(nullptr) {
69  mvaName_ = cfg.getParameter<std::string>("mvaName");
70  loadMVAfromDB_ = cfg.getParameter<bool>("loadMVAfromDB");
71  if (!loadMVAfromDB_) {
72  inputFileName_ = cfg.getParameter<edm::FileInPath>("inputFileName");
73  } else {
75  }
76  std::string mvaOpt_string = cfg.getParameter<std::string>("mvaOpt");
77  if (mvaOpt_string == "oldDMwoLT")
79  else if (mvaOpt_string == "oldDMwLT")
81  else if (mvaOpt_string == "newDMwoLT")
83  else if (mvaOpt_string == "newDMwLT")
85  else
86  throw cms::Exception("PFRecoTauDiscriminationByIsolationMVA2")
87  << " Invalid Configuration Parameter 'mvaOpt' = " << mvaOpt_string << " !!\n";
88 
89  if (mvaOpt_ == kOldDMwoLT || mvaOpt_ == kNewDMwoLT)
90  mvaInput_ = new float[6];
91  else if (mvaOpt_ == kOldDMwLT || mvaOpt_ == kNewDMwLT)
92  mvaInput_ = new float[12];
93  else
94  assert(0);
95 
97  consumes<PFTauTIPAssociationByRef>(cfg.getParameter<edm::InputTag>("srcTauTransverseImpactParameters"));
98 
100  consumes<reco::TauDiscriminatorContainer>(cfg.getParameter<edm::InputTag>("srcBasicTauDiscriminators"));
101  chargedIsoPtSum_index_ = cfg.getParameter<int>("srcChargedIsoPtSumIndex");
102  neutralIsoPtSum_index_ = cfg.getParameter<int>("srcNeutralIsoPtSumIndex");
103  pucorrPtSum_index_ = cfg.getParameter<int>("srcPUcorrPtSumIndex");
104 
105  verbosity_ = cfg.getParameter<int>("verbosity");
106  }
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
TauDiscriminationProducerBase< reco::PFTau, reco::TauDiscriminatorContainer, reco::SingleTauDiscriminatorContainer, reco::PFTauDiscriminator > PFTauDiscriminationContainerProducerBase
edm::ESGetToken< GBRForest, GBRWrapperRcd > mvaToken_
assert(be >=bs)
edm::EDGetTokenT< PFTauTIPAssociationByRef > tauTransverseImpactParameters_token_
edm::EDGetTokenT< reco::TauDiscriminatorContainer > basicTauDiscriminators_token_

◆ ~PFRecoTauDiscriminationByIsolationMVA2()

PFRecoTauDiscriminationByIsolationMVA2::~PFRecoTauDiscriminationByIsolationMVA2 ( )
inlineoverride

Member Function Documentation

◆ beginEvent()

void PFRecoTauDiscriminationByIsolationMVA2::beginEvent ( const edm::Event evt,
const edm::EventSetup es 
)
overridevirtual

Reimplemented from TauDiscriminationProducerBase< TauType, TauDiscriminator, TauDiscriminatorDataType, ConsumeType >.

Definition at line 153 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

References edm::Event::getByToken(), and edm::EventSetup::getData().

153  {
154  if (!mvaReader_) {
155  if (loadMVAfromDB_) {
157  } else {
159  }
160  }
161 
163 
165 
166  evt.getByToken(Tau_token, taus_);
167 }
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
edm::ESGetToken< GBRForest, GBRWrapperRcd > mvaToken_
edm::Handle< PFTauTIPAssociationByRef > tauLifetimeInfos_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:528
edm::EDGetTokenT< PFTauTIPAssociationByRef > tauTransverseImpactParameters_token_
edm::Handle< reco::TauDiscriminatorContainer > basicTauDiscriminators_
edm::EDGetTokenT< TauCollection > Tau_token
edm::EDGetTokenT< reco::TauDiscriminatorContainer > basicTauDiscriminators_token_

◆ discriminate()

reco::SingleTauDiscriminatorContainer PFRecoTauDiscriminationByIsolationMVA2::discriminate ( const PFTauRef tau) const
override

Definition at line 169 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

References reco::PFTauTransverseImpactParameter::dxy(), reco::PFTauTransverseImpactParameter::dxy_Sig(), MillePedeFileConverter_cfg::e, reco::PFTauTransverseImpactParameter::flightLength(), reco::PFTauTransverseImpactParameter::flightLengthSig(), reco::PFTauTransverseImpactParameter::hasSecondaryVertex(), reco::tau::kNewDMwLT, reco::tau::kNewDMwoLT, reco::tau::kOldDMwLT, reco::tau::kOldDMwoLT, METSkim_cff::Max, METSkim_cff::Min, mps_fire::result, and metsig::tau.

169  {
171  // CV: define dummy category index in order to use RecoTauDiscriminantCutMultiplexer module to apply WP cuts
172  result.rawValues = {-1., 0.};
173 
174  // CV: computation of MVA value requires presence of leading charged hadron
175  if (tau->leadChargedHadrCand().isNull())
176  return 0.;
177 
178  int tauDecayMode = tau->decayMode();
179 
180  if (((mvaOpt_ == kOldDMwoLT || mvaOpt_ == kOldDMwLT) &&
181  (tauDecayMode == 0 || tauDecayMode == 1 || tauDecayMode == 2 || tauDecayMode == 10)) ||
182  ((mvaOpt_ == kNewDMwoLT || mvaOpt_ == kNewDMwLT) &&
183  (tauDecayMode == 0 || tauDecayMode == 1 || tauDecayMode == 2 || tauDecayMode == 5 || tauDecayMode == 6 ||
184  tauDecayMode == 10))) {
185  double chargedIsoPtSum = (*basicTauDiscriminators_)[tau].rawValues.at(chargedIsoPtSum_index_);
186  double neutralIsoPtSum = (*basicTauDiscriminators_)[tau].rawValues.at(neutralIsoPtSum_index_);
187  double puCorrPtSum = (*basicTauDiscriminators_)[tau].rawValues.at(pucorrPtSum_index_);
188 
189  const reco::PFTauTransverseImpactParameter& tauLifetimeInfo = *(*tauLifetimeInfos_)[tau];
190 
191  double decayDistX = tauLifetimeInfo.flightLength().x();
192  double decayDistY = tauLifetimeInfo.flightLength().y();
193  double decayDistZ = tauLifetimeInfo.flightLength().z();
194  double decayDistMag = TMath::Sqrt(decayDistX * decayDistX + decayDistY * decayDistY + decayDistZ * decayDistZ);
195 
196  if (mvaOpt_ == kOldDMwoLT || mvaOpt_ == kNewDMwoLT) {
197  mvaInput_[0] = TMath::Log(TMath::Max(1., Double_t(tau->pt())));
198  mvaInput_[1] = TMath::Abs(tau->eta());
199  mvaInput_[2] = TMath::Log(TMath::Max(1.e-2, chargedIsoPtSum));
200  mvaInput_[3] = TMath::Log(TMath::Max(1.e-2, neutralIsoPtSum - 0.125 * puCorrPtSum));
201  mvaInput_[4] = TMath::Log(TMath::Max(1.e-2, puCorrPtSum));
202  mvaInput_[5] = tauDecayMode;
203  } else if (mvaOpt_ == kOldDMwLT || mvaOpt_ == kNewDMwLT) {
204  mvaInput_[0] = TMath::Log(TMath::Max(1., Double_t(tau->pt())));
205  mvaInput_[1] = TMath::Abs(tau->eta());
206  mvaInput_[2] = TMath::Log(TMath::Max(1.e-2, chargedIsoPtSum));
207  mvaInput_[3] = TMath::Log(TMath::Max(1.e-2, neutralIsoPtSum - 0.125 * puCorrPtSum));
208  mvaInput_[4] = TMath::Log(TMath::Max(1.e-2, puCorrPtSum));
209  mvaInput_[5] = tauDecayMode;
210  mvaInput_[6] = TMath::Sign(+1., tauLifetimeInfo.dxy());
211  mvaInput_[7] = TMath::Sqrt(TMath::Abs(TMath::Min(1., tauLifetimeInfo.dxy())));
212  mvaInput_[8] = TMath::Min(10., TMath::Abs(tauLifetimeInfo.dxy_Sig()));
213  mvaInput_[9] = (tauLifetimeInfo.hasSecondaryVertex()) ? 1. : 0.;
214  mvaInput_[10] = TMath::Sqrt(decayDistMag);
215  mvaInput_[11] = TMath::Min(10., tauLifetimeInfo.flightLengthSig());
216  }
217 
218  double mvaValue = mvaReader_->GetClassifier(mvaInput_);
219  if (verbosity_) {
220  edm::LogPrint("PFTauDiscByMVAIsol2") << "<PFRecoTauDiscriminationByIsolationMVA2::discriminate>:";
221  edm::LogPrint("PFTauDiscByMVAIsol2") << " tau: Pt = " << tau->pt() << ", eta = " << tau->eta();
222  edm::LogPrint("PFTauDiscByMVAIsol2") << " isolation: charged = " << chargedIsoPtSum
223  << ", neutral = " << neutralIsoPtSum << ", PUcorr = " << puCorrPtSum;
224  edm::LogPrint("PFTauDiscByMVAIsol2") << " decay mode = " << tauDecayMode;
225  edm::LogPrint("PFTauDiscByMVAIsol2") << " impact parameter: distance = " << tauLifetimeInfo.dxy()
226  << ", significance = " << tauLifetimeInfo.dxy_Sig();
227  edm::LogPrint("PFTauDiscByMVAIsol2")
228  << " has decay vertex = " << tauLifetimeInfo.hasSecondaryVertex() << ":"
229  << " distance = " << decayDistMag << ", significance = " << tauLifetimeInfo.flightLengthSig();
230  edm::LogPrint("PFTauDiscByMVAIsol2") << "--> mvaValue = " << mvaValue;
231  }
232  result.rawValues.at(0) = mvaValue;
233  }
234  return result;
235 }
Log< level::Warning, true > LogPrint
double GetClassifier(const float *vector) const
Definition: GBRForest.h:33

◆ fillDescriptions()

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

Definition at line 237 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, and AlCaHLTBitMon_QueryRunRegistry::string.

237  {
238  // pfRecoTauDiscriminationByIsolationMVA2
240 
241  desc.add<std::string>("mvaName");
242  desc.add<bool>("loadMVAfromDB");
243  desc.addOptional<edm::FileInPath>("inputFileName");
244  desc.add<std::string>("mvaOpt");
245 
246  desc.add<edm::InputTag>("srcTauTransverseImpactParameters");
247  desc.add<edm::InputTag>("srcBasicTauDiscriminators");
248  desc.add<int>("srcChargedIsoPtSumIndex");
249  desc.add<int>("srcNeutralIsoPtSumIndex");
250  desc.add<int>("srcPUcorrPtSumIndex");
251  desc.add<int>("verbosity", 0);
252 
253  fillProducerDescriptions(desc); // inherited from the base
254 
255  descriptions.add("pfRecoTauDiscriminationByIsolationMVA2", desc);
256 }
static void fillProducerDescriptions(edm::ParameterSetDescription &desc)
void add(std::string const &label, ParameterSetDescription const &psetDescription)

Member Data Documentation

◆ basicTauDiscriminators_

edm::Handle<reco::TauDiscriminatorContainer> PFRecoTauDiscriminationByIsolationMVA2::basicTauDiscriminators_
private

Definition at line 141 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

◆ basicTauDiscriminators_token_

edm::EDGetTokenT<reco::TauDiscriminatorContainer> PFRecoTauDiscriminationByIsolationMVA2::basicTauDiscriminators_token_
private

Definition at line 140 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

◆ chargedIsoPtSum_index_

int PFRecoTauDiscriminationByIsolationMVA2::chargedIsoPtSum_index_
private

Definition at line 142 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

◆ inputFileName_

edm::FileInPath PFRecoTauDiscriminationByIsolationMVA2::inputFileName_
private

Definition at line 129 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

◆ inputFilesToDelete_

std::vector<TFile*> PFRecoTauDiscriminationByIsolationMVA2::inputFilesToDelete_
private

Definition at line 148 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

◆ loadMVAfromDB_

bool PFRecoTauDiscriminationByIsolationMVA2::loadMVAfromDB_
private

Definition at line 128 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

◆ moduleLabel_

std::string PFRecoTauDiscriminationByIsolationMVA2::moduleLabel_
private

◆ mvaInput_

float* PFRecoTauDiscriminationByIsolationMVA2::mvaInput_
private

Definition at line 133 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

◆ mvaName_

std::string PFRecoTauDiscriminationByIsolationMVA2::mvaName_
private

Definition at line 126 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

◆ mvaOpt_

int PFRecoTauDiscriminationByIsolationMVA2::mvaOpt_
private

Definition at line 132 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

◆ mvaReader_

const GBRForest* PFRecoTauDiscriminationByIsolationMVA2::mvaReader_
private

Definition at line 130 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

◆ mvaToken_

edm::ESGetToken<GBRForest, GBRWrapperRcd> PFRecoTauDiscriminationByIsolationMVA2::mvaToken_
private

Definition at line 127 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

◆ neutralIsoPtSum_index_

int PFRecoTauDiscriminationByIsolationMVA2::neutralIsoPtSum_index_
private

Definition at line 143 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

◆ pucorrPtSum_index_

int PFRecoTauDiscriminationByIsolationMVA2::pucorrPtSum_index_
private

Definition at line 144 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

◆ tauLifetimeInfos_

edm::Handle<PFTauTIPAssociationByRef> PFRecoTauDiscriminationByIsolationMVA2::tauLifetimeInfos_
private

Definition at line 138 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

◆ taus_

edm::Handle<TauCollection> PFRecoTauDiscriminationByIsolationMVA2::taus_
private

Definition at line 146 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

◆ tauTransverseImpactParameters_token_

edm::EDGetTokenT<PFTauTIPAssociationByRef> PFRecoTauDiscriminationByIsolationMVA2::tauTransverseImpactParameters_token_
private

Definition at line 137 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

◆ verbosity_

int PFRecoTauDiscriminationByIsolationMVA2::verbosity_
private

Definition at line 150 of file PFRecoTauDiscriminationByMVAIsolation2.cc.