CMS 3D CMS Logo

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

Public Member Functions

void beginEvent (const edm::Event &, const edm::EventSetup &)
 
double discriminate (const PFTauRef &) const
 
void endEvent (edm::Event &)
 
 PFRecoTauDiscriminationByIsolationMVA2 (const edm::ParameterSet &cfg)
 
 ~PFRecoTauDiscriminationByIsolationMVA2 ()
 
- Public Member Functions inherited from TauDiscriminationProducerBase< TauType, TauDiscriminator >
virtual double discriminate (const TauRef &tau) const =0
 
void produce (edm::Event &, const edm::EventSetup &)
 
 TauDiscriminationProducerBase (const edm::ParameterSet &iConfig)
 
 TauDiscriminationProducerBase ()
 
virtual ~TauDiscriminationProducerBase ()
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Types

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

Private Attributes

std::auto_ptr< PFTauDiscriminatorcategory_output_
 
edm::EDGetTokenT
< reco::PFTauDiscriminator
ChargedIsoPtSum_token
 
edm::Handle
< reco::PFTauDiscriminator
chargedIsoPtSums_
 
edm::FileInPath inputFileName_
 
std::vector< TFile * > inputFilesToDelete_
 
bool loadMVAfromDB_
 
std::string moduleLabel_
 
float * mvaInput_
 
std::string mvaName_
 
int mvaOpt_
 
const GBRForestmvaReader_
 
edm::EDGetTokenT
< reco::PFTauDiscriminator
NeutralIsoPtSum_token
 
edm::Handle
< reco::PFTauDiscriminator
neutralIsoPtSums_
 
edm::EDGetTokenT
< reco::PFTauDiscriminator
PUcorrPtSum_token
 
edm::Handle
< reco::PFTauDiscriminator
puCorrPtSums_
 
edm::Handle
< PFTauTIPAssociationByRef
tauLifetimeInfos
 
edm::Handle< TauCollectiontaus_
 
edm::EDGetTokenT
< PFTauTIPAssociationByRef
TauTransverseImpactParameters_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
< TauCollection
TauRefProd
 
- 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, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
- 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 65 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

Member Typedef Documentation

Definition at line 132 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

Member Enumeration Documentation

anonymous enum
private

Constructor & Destructor Documentation

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

Definition at line 68 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

References edm::hlt::Exception, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), and AlCaHLTBitMon_QueryRunRegistry::string.

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

Definition at line 110 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

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

Member Function Documentation

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

Reimplemented from TauDiscriminationProducerBase< TauType, TauDiscriminator >.

Definition at line 151 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

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

152 {
153  if ( !mvaReader_ ) {
154  if ( loadMVAfromDB_ ) {
156  } else {
158  }
159  }
160 
162 
166 
167  evt.getByToken(Tau_token, taus_);
169 }
edm::RefProd< TauCollection > TauRefProd
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:446
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
tuple loadMVAfromDB
Definition: mvaPFMET_cff.py:41
double PFRecoTauDiscriminationByIsolationMVA2::discriminate ( const PFTauRef tau) const

Definition at line 171 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

References Abs(), python.rootplot.argparse::category, PFRecoTauDiscriminationByMVAIsolation2_cff::chargedIsoPtSum, reco::PFTauTransverseImpactParameter::dxy(), reco::PFTauTransverseImpactParameter::dxy_Sig(), alignCSCRings::e, reco::PFTauTransverseImpactParameter::flightLength(), reco::PFTauTransverseImpactParameter::flightLengthSig(), reco::PFTauTransverseImpactParameter::hasSecondaryVertex(), edm::Ref< C, T, F >::isNull(), Max(), Min(), PFRecoTauDiscriminationByMVAIsolation2_cff::neutralIsoPtSum, PFRecoTauDiscriminationByMVAIsolation2_cff::puCorrPtSum, Sign(), and metsig::tau.

172 {
173  // CV: define dummy category index in order to use RecoTauDiscriminantCutMultiplexer module to appy WP cuts
174  double category = 0.;
175  category_output_->setValue(tauIndex_, category);
176 
177  // CV: computation of MVA value requires presence of leading charged hadron
178  if ( tau->leadPFChargedHadrCand().isNull() ) return 0.;
179 
180  int tauDecayMode = tau->decayMode();
181 
182  if ( ((mvaOpt_ == kOldDMwoLT || mvaOpt_ == kOldDMwLT) && (tauDecayMode == 0 || tauDecayMode == 1 || tauDecayMode == 2 || tauDecayMode == 10)) ||
183  ((mvaOpt_ == kNewDMwoLT || mvaOpt_ == kNewDMwLT) && (tauDecayMode == 0 || tauDecayMode == 1 || tauDecayMode == 2 || tauDecayMode == 5 || tauDecayMode == 6 || tauDecayMode == 10)) ) {
184 
185  double chargedIsoPtSum = (*chargedIsoPtSums_)[tau];
186  double neutralIsoPtSum = (*neutralIsoPtSums_)[tau];
187  double puCorrPtSum = (*puCorrPtSums_)[tau];
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 << ", neutral = " << neutralIsoPtSum << ", PUcorr = " << puCorrPtSum;
223  edm::LogPrint("PFTauDiscByMVAIsol2") << " decay mode = " << tauDecayMode;
224  edm::LogPrint("PFTauDiscByMVAIsol2") << " impact parameter: distance = " << tauLifetimeInfo.dxy() << ", significance = " << tauLifetimeInfo.dxy_Sig();
225  edm::LogPrint("PFTauDiscByMVAIsol2") << " has decay vertex = " << tauLifetimeInfo.hasSecondaryVertex() << ":"
226  << " distance = " << decayDistMag << ", significance = " << tauLifetimeInfo.flightLengthSig();
227  edm::LogPrint("PFTauDiscByMVAIsol2") << "--> mvaValue = " << mvaValue;
228  }
229  return mvaValue;
230  } else {
231  return -1.;
232  }
233 }
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:247
T Max(T a, T b)
Definition: MathUtil.h:44
double GetClassifier(const float *vector) const
Definition: GBRForest.h:64
void PFRecoTauDiscriminationByIsolationMVA2::endEvent ( edm::Event evt)
virtual

Reimplemented from TauDiscriminationProducerBase< TauType, TauDiscriminator >.

Definition at line 235 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

References edm::Event::put().

236 {
237  // add all category indices to event
238  evt.put(category_output_, "category");
239 }
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113

Member Data Documentation

std::auto_ptr<PFTauDiscriminator> PFRecoTauDiscriminationByIsolationMVA2::category_output_
private

Definition at line 144 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

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

Definition at line 136 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

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

Definition at line 137 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

edm::FileInPath PFRecoTauDiscriminationByIsolationMVA2::inputFileName_
private

Definition at line 126 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

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

Definition at line 146 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

bool PFRecoTauDiscriminationByIsolationMVA2::loadMVAfromDB_
private

Definition at line 125 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

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

Definition at line 130 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

std::string PFRecoTauDiscriminationByIsolationMVA2::mvaName_
private

Definition at line 124 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

int PFRecoTauDiscriminationByIsolationMVA2::mvaOpt_
private

Definition at line 129 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

const GBRForest* PFRecoTauDiscriminationByIsolationMVA2::mvaReader_
private

Definition at line 127 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

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

Definition at line 138 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

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

Definition at line 139 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

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

Definition at line 140 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

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

Definition at line 141 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

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

Definition at line 134 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

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

Definition at line 143 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

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

Definition at line 133 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

int PFRecoTauDiscriminationByIsolationMVA2::verbosity_
private

Definition at line 148 of file PFRecoTauDiscriminationByMVAIsolation2.cc.