CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
reco::tau::PATTauDiscriminationByMVAIsolationRun2 Class Reference
Inheritance diagram for reco::tau::PATTauDiscriminationByMVAIsolationRun2:
TauDiscriminationProducerBase< TauType, TauDiscriminator, TauDiscriminatorDataType, ConsumeType > edm::stream::EDProducer<>

Public Member Functions

void beginEvent (const edm::Event &, const edm::EventSetup &) override
 
reco::SingleTauDiscriminatorContainer discriminate (const TauRef &) const override
 
 PATTauDiscriminationByMVAIsolationRun2 (const edm::ParameterSet &cfg)
 
 ~PATTauDiscriminationByMVAIsolationRun2 () override
 
- Public Member Functions inherited from TauDiscriminationProducerBase< TauType, TauDiscriminator, TauDiscriminatorDataType, ConsumeType >
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 Attributes

std::string chargedIsoPtSums_
 
std::string footprintCorrection_
 
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_
 
std::string neutralIsoPtSums_
 
std::string photonPtSumOutsideSignalCone_
 
std::string puCorrPtSums_
 
edm::Handle< TauCollectiontaus_
 
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 72 of file PATTauDiscriminationByMVAIsolationRun2.cc.

Constructor & Destructor Documentation

◆ PATTauDiscriminationByMVAIsolationRun2()

reco::tau::PATTauDiscriminationByMVAIsolationRun2::PATTauDiscriminationByMVAIsolationRun2 ( const edm::ParameterSet cfg)
inlineexplicit

Definition at line 74 of file PATTauDiscriminationByMVAIsolationRun2.cc.

References cms::cuda::assert(), looper::cfg, deDxTools::esConsumes(), Exception, reco::tau::kDBnewDMwLT, reco::tau::kDBnewDMwLTwGJ, reco::tau::kDBnewDMwLTwGJPhase2, reco::tau::kDBoldDMwLT, reco::tau::kDBoldDMwLTwGJ, reco::tau::kNewDMwLT, reco::tau::kNewDMwoLT, reco::tau::kOldDMwLT, reco::tau::kOldDMwoLT, reco::tau::kPWnewDMwLT, reco::tau::kPWoldDMwLT, and AlCaHLTBitMon_QueryRunRegistry::string.

76  moduleLabel_(cfg.getParameter<std::string>("@module_label")),
77  mvaReader_(nullptr),
78  mvaInput_(nullptr) {
79  mvaName_ = cfg.getParameter<std::string>("mvaName");
80  loadMVAfromDB_ = cfg.getParameter<bool>("loadMVAfromDB");
81  if (!loadMVAfromDB_) {
82  inputFileName_ = cfg.getParameter<edm::FileInPath>("inputFileName");
83  } else {
85  }
86  std::string mvaOpt_string = cfg.getParameter<std::string>("mvaOpt");
87  if (mvaOpt_string == "oldDMwoLT")
89  else if (mvaOpt_string == "oldDMwLT")
91  else if (mvaOpt_string == "newDMwoLT")
93  else if (mvaOpt_string == "newDMwLT")
95  else if (mvaOpt_string == "DBoldDMwLT")
97  else if (mvaOpt_string == "DBnewDMwLT")
99  else if (mvaOpt_string == "PWoldDMwLT")
101  else if (mvaOpt_string == "PWnewDMwLT")
103  else if (mvaOpt_string == "DBoldDMwLTwGJ")
105  else if (mvaOpt_string == "DBnewDMwLTwGJ")
107  else if (mvaOpt_string == "DBnewDMwLTwGJPhase2")
109  else
110  throw cms::Exception("PATTauDiscriminationByMVAIsolationRun2")
111  << " Invalid Configuration Parameter 'mvaOpt' = " << mvaOpt_string << " !!\n";
112 
113  if (mvaOpt_ == kOldDMwoLT || mvaOpt_ == kNewDMwoLT)
114  mvaInput_ = new float[6];
115  else if (mvaOpt_ == kOldDMwLT || mvaOpt_ == kNewDMwLT)
116  mvaInput_ = new float[12];
119  mvaInput_ = new float[23];
120  else if (mvaOpt_ == kDBnewDMwLTwGJPhase2)
121  mvaInput_ = new float[30];
122  else
123  assert(0);
124 
125  chargedIsoPtSums_ = cfg.getParameter<std::string>("srcChargedIsoPtSum");
126  neutralIsoPtSums_ = cfg.getParameter<std::string>("srcNeutralIsoPtSum");
127  puCorrPtSums_ = cfg.getParameter<std::string>("srcPUcorrPtSum");
128  photonPtSumOutsideSignalCone_ = cfg.getParameter<std::string>("srcPhotonPtSumOutsideSignalCone");
129  footprintCorrection_ = cfg.getParameter<std::string>("srcFootprintCorrection");
130 
131  verbosity_ = cfg.getParameter<int>("verbosity");
132  }
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
assert(be >=bs)
TauDiscriminationProducerBase< pat::Tau, reco::TauDiscriminatorContainer, reco::SingleTauDiscriminatorContainer, pat::PATTauDiscriminator > PATTauDiscriminationContainerProducerBase

◆ ~PATTauDiscriminationByMVAIsolationRun2()

reco::tau::PATTauDiscriminationByMVAIsolationRun2::~PATTauDiscriminationByMVAIsolationRun2 ( )
inlineoverride

Member Function Documentation

◆ beginEvent()

void reco::tau::PATTauDiscriminationByMVAIsolationRun2::beginEvent ( const edm::Event evt,
const edm::EventSetup es 
)
overridevirtual

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

Definition at line 172 of file PATTauDiscriminationByMVAIsolationRun2.cc.

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

172  {
173  if (!mvaReader_) {
174  if (loadMVAfromDB_) {
176  } else {
178  }
179  }
180 
181  evt.getByToken(Tau_token, taus_);
182  }
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:536
edm::EDGetTokenT< TauCollection > Tau_token

◆ discriminate()

reco::SingleTauDiscriminatorContainer reco::tau::PATTauDiscriminationByMVAIsolationRun2::discriminate ( const TauRef tau) const
overridevirtual

Implements TauDiscriminationProducerBase< TauType, TauDiscriminator, TauDiscriminatorDataType, ConsumeType >.

Definition at line 184 of file PATTauDiscriminationByMVAIsolationRun2.cc.

References reco::tau::fillIsoMVARun2Inputs(), mps_fire::result, and metsig::tau.

184  {
185  // CV: define dummy category index in order to use RecoTauDiscriminantCutMultiplexer module to appy WP cuts
187  result.rawValues = {-1.};
188 
189  // CV: computation of MVA value requires presence of leading charged hadron
190  if (tau->leadChargedHadrCand().isNull()) {
191  result.rawValues.at(0) = 0.;
192  return result;
193  }
194 
196  *tau,
197  mvaOpt_,
203  double mvaValue = mvaReader_->GetClassifier(mvaInput_);
204  if (verbosity_) {
205  edm::LogPrint("PATTauDiscByMVAIsolRun2") << "<PATTauDiscriminationByMVAIsolationRun2::discriminate>:";
206  edm::LogPrint("PATTauDiscByMVAIsolRun2") << " tau: Pt = " << tau->pt() << ", eta = " << tau->eta();
207  edm::LogPrint("PATTauDiscByMVAIsolRun2")
208  << " isolation: charged = " << tau->tauID(chargedIsoPtSums_)
209  << ", neutral = " << tau->tauID(neutralIsoPtSums_) << ", PUcorr = " << tau->tauID(puCorrPtSums_);
210  edm::LogPrint("PATTauDiscByMVAIsolRun2") << " decay mode = " << tau->decayMode();
211  edm::LogPrint("PATTauDiscByMVAIsolRun2")
212  << " impact parameter: distance = " << tau->dxy() << ", significance = " << tau->dxy_Sig();
213  edm::LogPrint("PATTauDiscByMVAIsolRun2") << " has decay vertex = " << tau->hasSecondaryVertex() << ":"
214  << ", significance = " << tau->flightLengthSig();
215  edm::LogPrint("PATTauDiscByMVAIsolRun2") << "--> mvaValue = " << mvaValue;
216  }
217  result.rawValues.at(0) = mvaValue;
218  }
219  return result;
220  }
bool fillIsoMVARun2Inputs(float *mvaInput, const pat::Tau &tau, int mvaOpt, const std::string &nameCharged, const std::string &nameNeutral, const std::string &namePu, const std::string &nameOutside, const std::string &nameFootprint)
Log< level::Warning, true > LogPrint
double GetClassifier(const float *vector) const
Definition: GBRForest.h:33

◆ fillDescriptions()

void reco::tau::PATTauDiscriminationByMVAIsolationRun2::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 222 of file PATTauDiscriminationByMVAIsolationRun2.cc.

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

222  {
223  // patTauDiscriminationByMVAIsolationRun2
225 
226  desc.add<std::string>("mvaName");
227  desc.add<bool>("loadMVAfromDB");
228  desc.addOptional<edm::FileInPath>("inputFileName");
229  desc.add<std::string>("mvaOpt");
230 
231  desc.add<std::string>("srcChargedIsoPtSum");
232  desc.add<std::string>("srcNeutralIsoPtSum");
233  desc.add<std::string>("srcPUcorrPtSum");
234  desc.add<std::string>("srcPhotonPtSumOutsideSignalCone");
235  desc.add<std::string>("srcFootprintCorrection");
236  desc.add<int>("verbosity", 0);
237 
238  fillProducerDescriptions(desc); // inherited from the base
239 
240  descriptions.add("patTauDiscriminationByMVAIsolationRun2", desc);
241  }
static void fillProducerDescriptions(edm::ParameterSetDescription &desc)
void add(std::string const &label, ParameterSetDescription const &psetDescription)

Member Data Documentation

◆ chargedIsoPtSums_

std::string reco::tau::PATTauDiscriminationByMVAIsolationRun2::chargedIsoPtSums_
private

Definition at line 160 of file PATTauDiscriminationByMVAIsolationRun2.cc.

◆ footprintCorrection_

std::string reco::tau::PATTauDiscriminationByMVAIsolationRun2::footprintCorrection_
private

Definition at line 164 of file PATTauDiscriminationByMVAIsolationRun2.cc.

◆ inputFileName_

edm::FileInPath reco::tau::PATTauDiscriminationByMVAIsolationRun2::inputFileName_
private

Definition at line 155 of file PATTauDiscriminationByMVAIsolationRun2.cc.

◆ inputFilesToDelete_

std::vector<TFile*> reco::tau::PATTauDiscriminationByMVAIsolationRun2::inputFilesToDelete_
private

Definition at line 167 of file PATTauDiscriminationByMVAIsolationRun2.cc.

◆ loadMVAfromDB_

bool reco::tau::PATTauDiscriminationByMVAIsolationRun2::loadMVAfromDB_
private

Definition at line 154 of file PATTauDiscriminationByMVAIsolationRun2.cc.

◆ moduleLabel_

std::string reco::tau::PATTauDiscriminationByMVAIsolationRun2::moduleLabel_
private

◆ mvaInput_

float* reco::tau::PATTauDiscriminationByMVAIsolationRun2::mvaInput_
private

Definition at line 158 of file PATTauDiscriminationByMVAIsolationRun2.cc.

◆ mvaName_

std::string reco::tau::PATTauDiscriminationByMVAIsolationRun2::mvaName_
private

Definition at line 152 of file PATTauDiscriminationByMVAIsolationRun2.cc.

◆ mvaOpt_

int reco::tau::PATTauDiscriminationByMVAIsolationRun2::mvaOpt_
private

Definition at line 157 of file PATTauDiscriminationByMVAIsolationRun2.cc.

◆ mvaReader_

const GBRForest* reco::tau::PATTauDiscriminationByMVAIsolationRun2::mvaReader_
private

Definition at line 156 of file PATTauDiscriminationByMVAIsolationRun2.cc.

◆ mvaToken_

edm::ESGetToken<GBRForest, GBRWrapperRcd> reco::tau::PATTauDiscriminationByMVAIsolationRun2::mvaToken_
private

Definition at line 153 of file PATTauDiscriminationByMVAIsolationRun2.cc.

◆ neutralIsoPtSums_

std::string reco::tau::PATTauDiscriminationByMVAIsolationRun2::neutralIsoPtSums_
private

Definition at line 161 of file PATTauDiscriminationByMVAIsolationRun2.cc.

◆ photonPtSumOutsideSignalCone_

std::string reco::tau::PATTauDiscriminationByMVAIsolationRun2::photonPtSumOutsideSignalCone_
private

Definition at line 163 of file PATTauDiscriminationByMVAIsolationRun2.cc.

◆ puCorrPtSums_

std::string reco::tau::PATTauDiscriminationByMVAIsolationRun2::puCorrPtSums_
private

Definition at line 162 of file PATTauDiscriminationByMVAIsolationRun2.cc.

◆ taus_

edm::Handle<TauCollection> reco::tau::PATTauDiscriminationByMVAIsolationRun2::taus_
private

Definition at line 166 of file PATTauDiscriminationByMVAIsolationRun2.cc.

◆ verbosity_

int reco::tau::PATTauDiscriminationByMVAIsolationRun2::verbosity_
private

Definition at line 169 of file PATTauDiscriminationByMVAIsolationRun2.cc.