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 > edm::stream::EDProducer<>

Public Member Functions

void beginEvent (const edm::Event &, const edm::EventSetup &) override
 
double discriminate (const TauRef &) const override
 
void endEvent (edm::Event &) override
 
 PATTauDiscriminationByMVAIsolationRun2 (const edm::ParameterSet &cfg)
 
 ~PATTauDiscriminationByMVAIsolationRun2 () override
 
- Public Member Functions inherited from TauDiscriminationProducerBase< TauType, TauDiscriminator >
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
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from TauDiscriminationProducerBase< TauType, TauDiscriminator >
static void fillProducerDescriptions (edm::ParameterSetDescription &desc)
 

Private Attributes

std::unique_ptr< pat::PATTauDiscriminatorcategory_output_
 
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_
 
std::string neutralIsoPtSums_
 
std::string photonPtSumOutsideSignalCone_
 
std::string puCorrPtSums_
 
edm::Handle< TauCollectiontaus_
 
int verbosity_
 

Additional Inherited Members

- Public Types inherited from TauDiscriminationProducerBase< TauType, TauDiscriminator >
typedef std::vector< TauType > TauCollection
 
typedef edm::Ref< TauCollectionTauRef
 
typedef edm::RefProd< TauCollectionTauRefProd
 
- 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
 
- Protected Attributes inherited from TauDiscriminationProducerBase< TauType, TauDiscriminator >
std::string moduleLabel_
 
double prediscriminantFailValue_
 
edm::EDGetTokenT< TauCollectionTau_token
 
size_t tauIndex_
 
edm::InputTag TauProducer_
 

Detailed Description

Definition at line 79 of file PATTauDiscriminationByMVAIsolationRun2.cc.

Constructor & Destructor Documentation

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

Definition at line 81 of file PATTauDiscriminationByMVAIsolationRun2.cc.

References Exception, edm::ParameterSet::getParameter(), reco::tau::kDBnewDMwLT, reco::tau::kDBnewDMwLTwGJ, 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.

83  moduleLabel_(cfg.getParameter<std::string>("@module_label")),
84  mvaReader_(nullptr),
85  mvaInput_(nullptr),
87  mvaName_ = cfg.getParameter<std::string>("mvaName");
88  loadMVAfromDB_ = cfg.getParameter<bool>("loadMVAfromDB");
89  if (!loadMVAfromDB_) {
90  inputFileName_ = cfg.getParameter<edm::FileInPath>("inputFileName");
91  }
92  std::string mvaOpt_string = cfg.getParameter<std::string>("mvaOpt");
93  if (mvaOpt_string == "oldDMwoLT")
95  else if (mvaOpt_string == "oldDMwLT")
97  else if (mvaOpt_string == "newDMwoLT")
99  else if (mvaOpt_string == "newDMwLT")
100  mvaOpt_ = kNewDMwLT;
101  else if (mvaOpt_string == "DBoldDMwLT")
103  else if (mvaOpt_string == "DBnewDMwLT")
105  else if (mvaOpt_string == "PWoldDMwLT")
107  else if (mvaOpt_string == "PWnewDMwLT")
109  else if (mvaOpt_string == "DBoldDMwLTwGJ")
111  else if (mvaOpt_string == "DBnewDMwLTwGJ")
113  else
114  throw cms::Exception("PATTauDiscriminationByMVAIsolationRun2")
115  << " Invalid Configuration Parameter 'mvaOpt' = " << mvaOpt_string << " !!\n";
116 
117  if (mvaOpt_ == kOldDMwoLT || mvaOpt_ == kNewDMwoLT)
118  mvaInput_ = new float[6];
119  else if (mvaOpt_ == kOldDMwLT || mvaOpt_ == kNewDMwLT)
120  mvaInput_ = new float[12];
123  mvaInput_ = new float[23];
124  else
125  assert(0);
126 
127  chargedIsoPtSums_ = cfg.getParameter<std::string>("srcChargedIsoPtSum");
128  neutralIsoPtSums_ = cfg.getParameter<std::string>("srcNeutralIsoPtSum");
129  puCorrPtSums_ = cfg.getParameter<std::string>("srcPUcorrPtSum");
130  photonPtSumOutsideSignalCone_ = cfg.getParameter<std::string>("srcPhotonPtSumOutsideSignalCone");
131  footprintCorrection_ = cfg.getParameter<std::string>("srcFootprintCorrection");
132 
133  verbosity_ = cfg.getParameter<int>("verbosity");
134 
135  produces<pat::PATTauDiscriminator>("category");
136  }
T getParameter(std::string const &) const
TauDiscriminationProducerBase< pat::Tau, pat::PATTauDiscriminator > PATTauDiscriminationProducerBase
reco::tau::PATTauDiscriminationByMVAIsolationRun2::~PATTauDiscriminationByMVAIsolationRun2 ( )
inlineoverride

Member Function Documentation

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

Reimplemented from TauDiscriminationProducerBase< TauType, TauDiscriminator >.

Definition at line 178 of file PATTauDiscriminationByMVAIsolationRun2.cc.

References edm::Event::getByToken(), and taus_updatedMVAIds_cff::loadMVAfromDB.

178  {
179  if (!mvaReader_) {
180  if (loadMVAfromDB_) {
182  } else {
184  }
185  }
186 
187  evt.getByToken(Tau_token, taus_);
189  }
edm::RefProd< TauCollection > TauRefProd
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
edm::EDGetTokenT< TauCollection > Tau_token
double reco::tau::PATTauDiscriminationByMVAIsolationRun2::discriminate ( const TauRef tau) const
overridevirtual

Implements TauDiscriminationProducerBase< TauType, TauDiscriminator >.

Definition at line 191 of file PATTauDiscriminationByMVAIsolationRun2.cc.

References taus_updatedMVAIds_cff::category, reco::tau::fillIsoMVARun2Inputs(), and edm::Ref< C, T, F >::isNull().

191  {
192  // CV: define dummy category index in order to use RecoTauDiscriminantCutMultiplexer module to appy WP cuts
193  double category = 0.;
194  category_output_->setValue(tauIndex_, category);
195 
196  // CV: computation of MVA value requires presence of leading charged hadron
197  if (tau->leadChargedHadrCand().isNull())
198  return 0.;
199 
201  *tau,
202  mvaOpt_,
208  double mvaValue = mvaReader_->GetClassifier(mvaInput_);
209  if (verbosity_) {
210  edm::LogPrint("PATTauDiscByMVAIsolRun2") << "<PATTauDiscriminationByMVAIsolationRun2::discriminate>:";
211  edm::LogPrint("PATTauDiscByMVAIsolRun2") << " tau: Pt = " << tau->pt() << ", eta = " << tau->eta();
212  edm::LogPrint("PATTauDiscByMVAIsolRun2")
213  << " isolation: charged = " << tau->tauID(chargedIsoPtSums_)
214  << ", neutral = " << tau->tauID(neutralIsoPtSums_) << ", PUcorr = " << tau->tauID(puCorrPtSums_);
215  edm::LogPrint("PATTauDiscByMVAIsolRun2") << " decay mode = " << tau->decayMode();
216  edm::LogPrint("PATTauDiscByMVAIsolRun2")
217  << " impact parameter: distance = " << tau->dxy() << ", significance = " << tau->dxy_Sig();
218  edm::LogPrint("PATTauDiscByMVAIsolRun2") << " has decay vertex = " << tau->hasSecondaryVertex() << ":"
219  << ", significance = " << tau->flightLengthSig();
220  edm::LogPrint("PATTauDiscByMVAIsolRun2") << "--> mvaValue = " << mvaValue;
221  }
222  return mvaValue;
223  }
224  return -1.;
225  }
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)
bool isNull() const
Checks for null.
Definition: Ref.h:235
double GetClassifier(const float *vector) const
Definition: GBRForest.h:34
void reco::tau::PATTauDiscriminationByMVAIsolationRun2::endEvent ( edm::Event evt)
overridevirtual

Reimplemented from TauDiscriminationProducerBase< TauType, TauDiscriminator >.

Definition at line 227 of file PATTauDiscriminationByMVAIsolationRun2.cc.

References eostools::move(), and edm::Event::put().

227  {
228  // add all category indices to event
229  evt.put(std::move(category_output_), "category");
230  }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
def move(src, dest)
Definition: eostools.py:511
void reco::tau::PATTauDiscriminationByMVAIsolationRun2::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 232 of file PATTauDiscriminationByMVAIsolationRun2.cc.

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

232  {
233  // patTauDiscriminationByMVAIsolationRun2
235 
236  desc.add<std::string>("mvaName");
237  desc.add<bool>("loadMVAfromDB");
238  desc.addOptional<edm::FileInPath>("inputFileName");
239  desc.add<std::string>("mvaOpt");
240 
241  desc.add<std::string>("srcChargedIsoPtSum");
242  desc.add<std::string>("srcNeutralIsoPtSum");
243  desc.add<std::string>("srcPUcorrPtSum");
244  desc.add<std::string>("srcPhotonPtSumOutsideSignalCone");
245  desc.add<std::string>("srcFootprintCorrection");
246  desc.add<int>("verbosity", 0);
247 
248  fillProducerDescriptions(desc); // inherited from the base
249 
250  descriptions.add("patTauDiscriminationByMVAIsolationRun2", desc);
251  }
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
static void fillProducerDescriptions(edm::ParameterSetDescription &desc)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)

Member Data Documentation

std::unique_ptr<pat::PATTauDiscriminator> reco::tau::PATTauDiscriminationByMVAIsolationRun2::category_output_
private

Definition at line 172 of file PATTauDiscriminationByMVAIsolationRun2.cc.

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

Definition at line 165 of file PATTauDiscriminationByMVAIsolationRun2.cc.

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

Definition at line 169 of file PATTauDiscriminationByMVAIsolationRun2.cc.

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

Definition at line 160 of file PATTauDiscriminationByMVAIsolationRun2.cc.

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

Definition at line 173 of file PATTauDiscriminationByMVAIsolationRun2.cc.

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

Definition at line 159 of file PATTauDiscriminationByMVAIsolationRun2.cc.

std::string reco::tau::PATTauDiscriminationByMVAIsolationRun2::moduleLabel_
private
float* reco::tau::PATTauDiscriminationByMVAIsolationRun2::mvaInput_
private

Definition at line 163 of file PATTauDiscriminationByMVAIsolationRun2.cc.

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

Definition at line 158 of file PATTauDiscriminationByMVAIsolationRun2.cc.

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

Definition at line 162 of file PATTauDiscriminationByMVAIsolationRun2.cc.

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

Definition at line 161 of file PATTauDiscriminationByMVAIsolationRun2.cc.

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

Definition at line 166 of file PATTauDiscriminationByMVAIsolationRun2.cc.

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

Definition at line 168 of file PATTauDiscriminationByMVAIsolationRun2.cc.

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

Definition at line 167 of file PATTauDiscriminationByMVAIsolationRun2.cc.

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

Definition at line 171 of file PATTauDiscriminationByMVAIsolationRun2.cc.

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

Definition at line 175 of file PATTauDiscriminationByMVAIsolationRun2.cc.