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 hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () 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)
 
static std::string getTauTypeString ()
 helper method to retrieve tau type name, e.g. to build correct cfi getter More...
 

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 77 of file PATTauDiscriminationByMVAIsolationRun2.cc.

Constructor & Destructor Documentation

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

Definition at line 80 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.

82  moduleLabel_(cfg.getParameter<std::string>("@module_label")),
83  mvaReader_(nullptr),
84  mvaInput_(nullptr),
86  {
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" ) mvaOpt_ = kOldDMwoLT;
94  else if ( mvaOpt_string == "oldDMwLT" ) mvaOpt_ = kOldDMwLT;
95  else if ( mvaOpt_string == "newDMwoLT" ) mvaOpt_ = kNewDMwoLT;
96  else if ( mvaOpt_string == "newDMwLT" ) mvaOpt_ = kNewDMwLT;
97  else if ( mvaOpt_string == "DBoldDMwLT" ) mvaOpt_ = kDBoldDMwLT;
98  else if ( mvaOpt_string == "DBnewDMwLT" ) mvaOpt_ = kDBnewDMwLT;
99  else if ( mvaOpt_string == "PWoldDMwLT" ) mvaOpt_ = kPWoldDMwLT;
100  else if ( mvaOpt_string == "PWnewDMwLT" ) mvaOpt_ = kPWnewDMwLT;
101  else if ( mvaOpt_string == "DBoldDMwLTwGJ" ) mvaOpt_ = kDBoldDMwLTwGJ;
102  else if ( mvaOpt_string == "DBnewDMwLTwGJ" ) mvaOpt_ = kDBnewDMwLTwGJ;
103  else throw cms::Exception("PATTauDiscriminationByMVAIsolationRun2")
104  << " Invalid Configuration Parameter 'mvaOpt' = " << mvaOpt_string << " !!\n";
105 
106  if ( mvaOpt_ == kOldDMwoLT || mvaOpt_ == kNewDMwoLT ) mvaInput_ = new float[6];
107  else if ( mvaOpt_ == kOldDMwLT || mvaOpt_ == kNewDMwLT ) mvaInput_ = new float[12];
108  else if ( mvaOpt_ == kDBoldDMwLT || mvaOpt_ == kDBnewDMwLT ||
110  mvaOpt_ == kDBoldDMwLTwGJ || mvaOpt_ == kDBnewDMwLTwGJ) mvaInput_ = new float[23];
111  else assert(0);
112 
113  chargedIsoPtSums_ = cfg.getParameter<std::string>("srcChargedIsoPtSum");
114  neutralIsoPtSums_ = cfg.getParameter<std::string>("srcNeutralIsoPtSum");
115  puCorrPtSums_ = cfg.getParameter<std::string>("srcPUcorrPtSum");
116  photonPtSumOutsideSignalCone_ = cfg.getParameter<std::string>("srcPhotonPtSumOutsideSignalCone");
117  footprintCorrection_ = cfg.getParameter<std::string>("srcFootprintCorrection");
118 
119  verbosity_ = cfg.getParameter<int>("verbosity");
120 
121  produces<pat::PATTauDiscriminator>("category");
122  }
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 166 of file PATTauDiscriminationByMVAIsolationRun2.cc.

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

167 {
168  if( !mvaReader_ ) {
169  if ( loadMVAfromDB_ ) {
171  } else {
173  }
174  }
175 
176  evt.getByToken(Tau_token, taus_);
178 }
edm::RefProd< TauCollection > TauRefProd
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
edm::EDGetTokenT< TauCollection > Tau_token
double reco::tau::PATTauDiscriminationByMVAIsolationRun2::discriminate ( const TauRef tau) const
overridevirtual

Implements TauDiscriminationProducerBase< TauType, TauDiscriminator >.

Definition at line 180 of file PATTauDiscriminationByMVAIsolationRun2.cc.

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

181 {
182  // CV: define dummy category index in order to use RecoTauDiscriminantCutMultiplexer module to appy WP cuts
183  double category = 0.;
184  category_output_->setValue(tauIndex_, category);
185 
186  // CV: computation of MVA value requires presence of leading charged hadron
187  if ( tau->leadChargedHadrCand().isNull() ) return 0.;
188 
190  double mvaValue = mvaReader_->GetClassifier(mvaInput_);
191  if ( verbosity_ ) {
192  edm::LogPrint("PATTauDiscByMVAIsolRun2") << "<PATTauDiscriminationByMVAIsolationRun2::discriminate>:";
193  edm::LogPrint("PATTauDiscByMVAIsolRun2") << " tau: Pt = " << tau->pt() << ", eta = " << tau->eta();
194  edm::LogPrint("PATTauDiscByMVAIsolRun2") << " isolation: charged = " << tau->tauID(chargedIsoPtSums_) << ", neutral = " << tau->tauID(neutralIsoPtSums_) << ", PUcorr = " << tau->tauID(puCorrPtSums_);
195  edm::LogPrint("PATTauDiscByMVAIsolRun2") << " decay mode = " << tau->decayMode();
196  edm::LogPrint("PATTauDiscByMVAIsolRun2") << " impact parameter: distance = " << tau->dxy() << ", significance = " << tau->dxy_Sig();
197  edm::LogPrint("PATTauDiscByMVAIsolRun2") << " has decay vertex = " << tau->hasSecondaryVertex() << ":"
198  << ", significance = " << tau->flightLengthSig();
199  edm::LogPrint("PATTauDiscByMVAIsolRun2") << "--> mvaValue = " << mvaValue;
200  }
201  return mvaValue;
202  }
203  return -1.;
204 }
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:248
double GetClassifier(const float *vector) const
Definition: GBRForest.h:36
void reco::tau::PATTauDiscriminationByMVAIsolationRun2::endEvent ( edm::Event evt)
overridevirtual

Reimplemented from TauDiscriminationProducerBase< TauType, TauDiscriminator >.

Definition at line 206 of file PATTauDiscriminationByMVAIsolationRun2.cc.

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

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

Definition at line 213 of file PATTauDiscriminationByMVAIsolationRun2.cc.

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

213  {
214  // patTauDiscriminationByMVAIsolationRun2
216 
217  desc.add<std::string>("mvaName");
218  desc.add<bool>("loadMVAfromDB");
219  desc.addOptional<edm::FileInPath>("inputFileName");
220  desc.add<std::string>("mvaOpt");
221 
222  desc.add<std::string>("srcChargedIsoPtSum");
223  desc.add<std::string>("srcNeutralIsoPtSum");
224  desc.add<std::string>("srcPUcorrPtSum");
225  desc.add<std::string>("srcPhotonPtSumOutsideSignalCone");
226  desc.add<std::string>("srcFootprintCorrection");
227  desc.add<int>("verbosity", 0);
228 
229  fillProducerDescriptions(desc); // inherited from the base
230 
231  descriptions.add("patTauDiscriminationByMVAIsolationRun2", desc);
232 }
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 160 of file PATTauDiscriminationByMVAIsolationRun2.cc.

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

Definition at line 153 of file PATTauDiscriminationByMVAIsolationRun2.cc.

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

Definition at line 157 of file PATTauDiscriminationByMVAIsolationRun2.cc.

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

Definition at line 148 of file PATTauDiscriminationByMVAIsolationRun2.cc.

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

Definition at line 161 of file PATTauDiscriminationByMVAIsolationRun2.cc.

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

Definition at line 147 of file PATTauDiscriminationByMVAIsolationRun2.cc.

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

Definition at line 151 of file PATTauDiscriminationByMVAIsolationRun2.cc.

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

Definition at line 146 of file PATTauDiscriminationByMVAIsolationRun2.cc.

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

Definition at line 150 of file PATTauDiscriminationByMVAIsolationRun2.cc.

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

Definition at line 149 of file PATTauDiscriminationByMVAIsolationRun2.cc.

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

Definition at line 154 of file PATTauDiscriminationByMVAIsolationRun2.cc.

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

Definition at line 156 of file PATTauDiscriminationByMVAIsolationRun2.cc.

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

Definition at line 155 of file PATTauDiscriminationByMVAIsolationRun2.cc.

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

Definition at line 159 of file PATTauDiscriminationByMVAIsolationRun2.cc.

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

Definition at line 163 of file PATTauDiscriminationByMVAIsolationRun2.cc.