CMS 3D CMS Logo

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

Public Member Functions

void beginEvent (const edm::Event &, const edm::EventSetup &) override
 
double discriminate (const PFTauRef &) const override
 
void endEvent (edm::Event &) override
 
 PFRecoTauDiscriminationByIsolationMVA2 (const edm::ParameterSet &cfg)
 
 ~PFRecoTauDiscriminationByIsolationMVA2 () override
 
- Public Member Functions inherited from TauDiscriminationProducerBase< TauType, TauDiscriminator >
virtual double discriminate (const TauRef &tau) const =0
 
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)
 

Private Types

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

Private Attributes

std::unique_ptr< PFTauDiscriminatorcategory_output_
 
edm::EDGetTokenT< reco::PFTauDiscriminatorChargedIsoPtSum_token
 
edm::Handle< reco::PFTauDiscriminatorchargedIsoPtSums_
 
edm::FileInPath inputFileName_
 
std::vector< TFile * > inputFilesToDelete_
 
bool loadMVAfromDB_
 
std::string moduleLabel_
 
float * mvaInput_
 
std::string mvaName_
 
int mvaOpt_
 
const GBRForestmvaReader_
 
edm::EDGetTokenT< reco::PFTauDiscriminatorNeutralIsoPtSum_token
 
edm::Handle< reco::PFTauDiscriminatorneutralIsoPtSums_
 
edm::EDGetTokenT< reco::PFTauDiscriminatorPUcorrPtSum_token
 
edm::Handle< reco::PFTauDiscriminatorpuCorrPtSums_
 
edm::Handle< PFTauTIPAssociationByReftauLifetimeInfos
 
edm::Handle< TauCollectiontaus_
 
edm::EDGetTokenT< PFTauTIPAssociationByRefTauTransverseImpactParameters_token
 
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 68 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

Member Typedef Documentation

Definition at line 135 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

Member Enumeration Documentation

anonymous enum
private

Constructor & Destructor Documentation

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

Definition at line 71 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

References Exception, edm::ParameterSet::getParameter(), reco::tau::kNewDMwLT, reco::tau::kNewDMwoLT, reco::tau::kOldDMwLT, reco::tau::kOldDMwoLT, and AlCaHLTBitMon_QueryRunRegistry::string.

73  moduleLabel_(cfg.getParameter<std::string>("@module_label")),
74  mvaReader_(nullptr),
75  mvaInput_(nullptr),
77  {
78  mvaName_ = cfg.getParameter<std::string>("mvaName");
79  loadMVAfromDB_ = cfg.getParameter<bool>("loadMVAfromDB");
80  if ( !loadMVAfromDB_ ) {
81  inputFileName_ = cfg.getParameter<edm::FileInPath>("inputFileName");
82  }
83  std::string mvaOpt_string = cfg.getParameter<std::string>("mvaOpt");
84  if ( mvaOpt_string == "oldDMwoLT" ) mvaOpt_ = kOldDMwoLT;
85  else if ( mvaOpt_string == "oldDMwLT" ) mvaOpt_ = kOldDMwLT;
86  else if ( mvaOpt_string == "newDMwoLT" ) mvaOpt_ = kNewDMwoLT;
87  else if ( mvaOpt_string == "newDMwLT" ) mvaOpt_ = kNewDMwLT;
88  else throw cms::Exception("PFRecoTauDiscriminationByIsolationMVA2")
89  << " Invalid Configuration Parameter 'mvaOpt' = " << mvaOpt_string << " !!\n";
90 
91  if ( mvaOpt_ == kOldDMwoLT || mvaOpt_ == kNewDMwoLT ) mvaInput_ = new float[6];
92  else if ( mvaOpt_ == kOldDMwLT || mvaOpt_ == kNewDMwLT ) mvaInput_ = new float[12];
93  else assert(0);
94 
95  TauTransverseImpactParameters_token = consumes<PFTauTIPAssociationByRef>(cfg.getParameter<edm::InputTag>("srcTauTransverseImpactParameters"));
96 
97  ChargedIsoPtSum_token = consumes<reco::PFTauDiscriminator>(cfg.getParameter<edm::InputTag>("srcChargedIsoPtSum"));
98  NeutralIsoPtSum_token = consumes<reco::PFTauDiscriminator>(cfg.getParameter<edm::InputTag>("srcNeutralIsoPtSum"));
99  PUcorrPtSum_token = consumes<reco::PFTauDiscriminator>(cfg.getParameter<edm::InputTag>("srcPUcorrPtSum"));
100 
101  verbosity_ = cfg.getParameter<int>("verbosity");
102 
103  produces<PFTauDiscriminator>("category");
104  }
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::PFTauDiscriminator > ChargedIsoPtSum_token
edm::EDGetTokenT< reco::PFTauDiscriminator > NeutralIsoPtSum_token
edm::EDGetTokenT< PFTauTIPAssociationByRef > TauTransverseImpactParameters_token
TauDiscriminationProducerBase< reco::PFTau, reco::PFTauDiscriminator > PFTauDiscriminationProducerBase
edm::EDGetTokenT< reco::PFTauDiscriminator > PUcorrPtSum_token
PFRecoTauDiscriminationByIsolationMVA2::~PFRecoTauDiscriminationByIsolationMVA2 ( )
inlineoverride

Definition at line 112 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

References fillDescriptions().

113  {
114  if(!loadMVAfromDB_) delete mvaReader_;
115  delete[] mvaInput_;
116  for ( std::vector<TFile*>::iterator it = inputFilesToDelete_.begin();
117  it != inputFilesToDelete_.end(); ++it ) {
118  delete (*it);
119  }
120  }

Member Function Documentation

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

Reimplemented from TauDiscriminationProducerBase< TauType, TauDiscriminator >.

Definition at line 154 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

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

155 {
156  if ( !mvaReader_ ) {
157  if ( loadMVAfromDB_ ) {
159  } else {
161  }
162  }
163 
165 
169 
170  evt.getByToken(Tau_token, taus_);
172 }
edm::RefProd< TauCollection > TauRefProd
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
edm::Handle< reco::PFTauDiscriminator > chargedIsoPtSums_
edm::Handle< PFTauTIPAssociationByRef > tauLifetimeInfos
edm::EDGetTokenT< reco::PFTauDiscriminator > ChargedIsoPtSum_token
edm::EDGetTokenT< reco::PFTauDiscriminator > NeutralIsoPtSum_token
edm::EDGetTokenT< PFTauTIPAssociationByRef > TauTransverseImpactParameters_token
edm::EDGetTokenT< TauCollection > Tau_token
edm::Handle< reco::PFTauDiscriminator > neutralIsoPtSums_
edm::EDGetTokenT< reco::PFTauDiscriminator > PUcorrPtSum_token
double PFRecoTauDiscriminationByIsolationMVA2::discriminate ( const PFTauRef tau) const
override

Definition at line 174 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

References Abs(), taus_updatedMVAIds_cff::category, tauProducer_cfi::chargedIsoPtSum, reco::PFTauTransverseImpactParameter::dxy(), reco::PFTauTransverseImpactParameter::dxy_Sig(), MillePedeFileConverter_cfg::e, reco::PFTauTransverseImpactParameter::flightLength(), reco::PFTauTransverseImpactParameter::flightLengthSig(), reco::PFTauTransverseImpactParameter::hasSecondaryVertex(), edm::Ref< C, T, F >::isNull(), reco::tau::kNewDMwLT, reco::tau::kNewDMwoLT, reco::tau::kOldDMwLT, reco::tau::kOldDMwoLT, Max(), Min(), tauProducer_cfi::neutralIsoPtSum, tauProducer_cfi::puCorrPtSum, Sign(), and metsig::tau.

175 {
176  // CV: define dummy category index in order to use RecoTauDiscriminantCutMultiplexer module to appy WP cuts
177  double category = 0.;
178  category_output_->setValue(tauIndex_, category);
179 
180  // CV: computation of MVA value requires presence of leading charged hadron
181  if ( tau->leadChargedHadrCand().isNull() ) return 0.;
182 
183  int tauDecayMode = tau->decayMode();
184 
185  if ( ((mvaOpt_ == kOldDMwoLT || mvaOpt_ == kOldDMwLT) && (tauDecayMode == 0 || tauDecayMode == 1 || tauDecayMode == 2 || tauDecayMode == 10)) ||
186  ((mvaOpt_ == kNewDMwoLT || mvaOpt_ == kNewDMwLT) && (tauDecayMode == 0 || tauDecayMode == 1 || tauDecayMode == 2 || tauDecayMode == 5 || tauDecayMode == 6 || tauDecayMode == 10)) ) {
187 
188  double chargedIsoPtSum = (*chargedIsoPtSums_)[tau];
189  double neutralIsoPtSum = (*neutralIsoPtSums_)[tau];
190  double puCorrPtSum = (*puCorrPtSums_)[tau];
191 
192  const reco::PFTauTransverseImpactParameter& tauLifetimeInfo = *(*tauLifetimeInfos)[tau];
193 
194  double decayDistX = tauLifetimeInfo.flightLength().x();
195  double decayDistY = tauLifetimeInfo.flightLength().y();
196  double decayDistZ = tauLifetimeInfo.flightLength().z();
197  double decayDistMag = TMath::Sqrt(decayDistX*decayDistX + decayDistY*decayDistY + decayDistZ*decayDistZ);
198 
199  if ( mvaOpt_ == kOldDMwoLT || mvaOpt_ == kNewDMwoLT ) {
200  mvaInput_[0] = TMath::Log(TMath::Max(1., Double_t(tau->pt())));
201  mvaInput_[1] = TMath::Abs(tau->eta());
202  mvaInput_[2] = TMath::Log(TMath::Max(1.e-2, chargedIsoPtSum));
203  mvaInput_[3] = TMath::Log(TMath::Max(1.e-2, neutralIsoPtSum - 0.125*puCorrPtSum));
204  mvaInput_[4] = TMath::Log(TMath::Max(1.e-2, puCorrPtSum));
205  mvaInput_[5] = tauDecayMode;
206  } else if ( mvaOpt_ == kOldDMwLT || mvaOpt_ == kNewDMwLT ) {
207  mvaInput_[0] = TMath::Log(TMath::Max(1., Double_t(tau->pt())));
208  mvaInput_[1] = TMath::Abs(tau->eta());
209  mvaInput_[2] = TMath::Log(TMath::Max(1.e-2, chargedIsoPtSum));
210  mvaInput_[3] = TMath::Log(TMath::Max(1.e-2, neutralIsoPtSum - 0.125*puCorrPtSum));
211  mvaInput_[4] = TMath::Log(TMath::Max(1.e-2, puCorrPtSum));
212  mvaInput_[5] = tauDecayMode;
213  mvaInput_[6] = TMath::Sign(+1., tauLifetimeInfo.dxy());
214  mvaInput_[7] = TMath::Sqrt(TMath::Abs(TMath::Min(1., tauLifetimeInfo.dxy())));
215  mvaInput_[8] = TMath::Min(10., TMath::Abs(tauLifetimeInfo.dxy_Sig()));
216  mvaInput_[9] = ( tauLifetimeInfo.hasSecondaryVertex() ) ? 1. : 0.;
217  mvaInput_[10] = TMath::Sqrt(decayDistMag);
218  mvaInput_[11] = TMath::Min(10., tauLifetimeInfo.flightLengthSig());
219  }
220 
221  double mvaValue = mvaReader_->GetClassifier(mvaInput_);
222  if ( verbosity_ ) {
223  edm::LogPrint("PFTauDiscByMVAIsol2") << "<PFRecoTauDiscriminationByIsolationMVA2::discriminate>:";
224  edm::LogPrint("PFTauDiscByMVAIsol2") << " tau: Pt = " << tau->pt() << ", eta = " << tau->eta();
225  edm::LogPrint("PFTauDiscByMVAIsol2") << " isolation: charged = " << chargedIsoPtSum << ", neutral = " << neutralIsoPtSum << ", PUcorr = " << puCorrPtSum;
226  edm::LogPrint("PFTauDiscByMVAIsol2") << " decay mode = " << tauDecayMode;
227  edm::LogPrint("PFTauDiscByMVAIsol2") << " impact parameter: distance = " << tauLifetimeInfo.dxy() << ", significance = " << tauLifetimeInfo.dxy_Sig();
228  edm::LogPrint("PFTauDiscByMVAIsol2") << " has decay vertex = " << tauLifetimeInfo.hasSecondaryVertex() << ":"
229  << " distance = " << decayDistMag << ", significance = " << tauLifetimeInfo.flightLengthSig();
230  edm::LogPrint("PFTauDiscByMVAIsol2") << "--> mvaValue = " << mvaValue;
231  }
232  return mvaValue;
233  } else {
234  return -1.;
235  }
236 }
T Sign(T A, T B)
Definition: MathUtil.h:54
T Min(T a, T b)
Definition: MathUtil.h:39
T Abs(T a)
Definition: MathUtil.h:49
bool isNull() const
Checks for null.
Definition: Ref.h:248
T Max(T a, T b)
Definition: MathUtil.h:44
double GetClassifier(const float *vector) const
Definition: GBRForest.h:36
void PFRecoTauDiscriminationByIsolationMVA2::endEvent ( edm::Event evt)
overridevirtual

Reimplemented from TauDiscriminationProducerBase< TauType, TauDiscriminator >.

Definition at line 238 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

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

239 {
240  // add all category indices to event
241  evt.put(std::move(category_output_), "category");
242 }
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 PFRecoTauDiscriminationByIsolationMVA2::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 245 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

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

245  {
246  // pfRecoTauDiscriminationByIsolationMVA2
248 
249  desc.add<std::string>("mvaName");
250  desc.add<bool>("loadMVAfromDB");
251  desc.addOptional<edm::FileInPath>("inputFileName");
252  desc.add<std::string>("mvaOpt");
253 
254  desc.add<edm::InputTag>("srcTauTransverseImpactParameters");
255  desc.add<edm::InputTag>("srcChargedIsoPtSum");
256  desc.add<edm::InputTag>("srcNeutralIsoPtSum");
257  desc.add<edm::InputTag>("srcPUcorrPtSum");
258  desc.add<int>("verbosity", 0);
259 
260  fillProducerDescriptions(desc); // inherited from the base
261 
262  descriptions.add("pfRecoTauDiscriminationByIsolationMVA2", desc);
263 }
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<PFTauDiscriminator> PFRecoTauDiscriminationByIsolationMVA2::category_output_
private

Definition at line 147 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

edm::EDGetTokenT<reco::PFTauDiscriminator> PFRecoTauDiscriminationByIsolationMVA2::ChargedIsoPtSum_token
private

Definition at line 139 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

edm::Handle<reco::PFTauDiscriminator> PFRecoTauDiscriminationByIsolationMVA2::chargedIsoPtSums_
private

Definition at line 140 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

edm::FileInPath PFRecoTauDiscriminationByIsolationMVA2::inputFileName_
private

Definition at line 129 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

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

Definition at line 149 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

bool PFRecoTauDiscriminationByIsolationMVA2::loadMVAfromDB_
private

Definition at line 128 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

std::string PFRecoTauDiscriminationByIsolationMVA2::moduleLabel_
private
float* PFRecoTauDiscriminationByIsolationMVA2::mvaInput_
private

Definition at line 133 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

std::string PFRecoTauDiscriminationByIsolationMVA2::mvaName_
private

Definition at line 127 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

int PFRecoTauDiscriminationByIsolationMVA2::mvaOpt_
private

Definition at line 132 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

const GBRForest* PFRecoTauDiscriminationByIsolationMVA2::mvaReader_
private

Definition at line 130 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

edm::EDGetTokenT<reco::PFTauDiscriminator> PFRecoTauDiscriminationByIsolationMVA2::NeutralIsoPtSum_token
private

Definition at line 141 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

edm::Handle<reco::PFTauDiscriminator> PFRecoTauDiscriminationByIsolationMVA2::neutralIsoPtSums_
private

Definition at line 142 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

edm::EDGetTokenT<reco::PFTauDiscriminator> PFRecoTauDiscriminationByIsolationMVA2::PUcorrPtSum_token
private

Definition at line 143 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

edm::Handle<reco::PFTauDiscriminator> PFRecoTauDiscriminationByIsolationMVA2::puCorrPtSums_
private

Definition at line 144 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

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

Definition at line 137 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

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

Definition at line 146 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

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

Definition at line 136 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

int PFRecoTauDiscriminationByIsolationMVA2::verbosity_
private

Definition at line 151 of file PFRecoTauDiscriminationByMVAIsolation2.cc.