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
std::vector< ConsumesInfoconsumesInfo () const
 
 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
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) 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 134 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 assert(), 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  if(cfg.exists("inputFileName")){
79  inputFileName_ = cfg.getParameter<edm::FileInPath>("inputFileName");
80  }else throw cms::Exception("MVA input not defined") << "Requested to load tau MVA input from ROOT file but no file provided in cfg file";
81  }
82  std::string mvaOpt_string = cfg.getParameter<std::string>("mvaOpt");
83  if ( mvaOpt_string == "oldDMwoLT" ) mvaOpt_ = kOldDMwoLT;
84  else if ( mvaOpt_string == "oldDMwLT" ) mvaOpt_ = kOldDMwLT;
85  else if ( mvaOpt_string == "newDMwoLT" ) mvaOpt_ = kNewDMwoLT;
86  else if ( mvaOpt_string == "newDMwLT" ) mvaOpt_ = kNewDMwLT;
87  else throw cms::Exception("PFRecoTauDiscriminationByIsolationMVA2")
88  << " Invalid Configuration Parameter 'mvaOpt' = " << mvaOpt_string << " !!\n";
89 
90  if ( mvaOpt_ == kOldDMwoLT || mvaOpt_ == kNewDMwoLT ) mvaInput_ = new float[6];
91  else if ( mvaOpt_ == kOldDMwLT || mvaOpt_ == kNewDMwLT ) mvaInput_ = new float[12];
92  else assert(0);
93 
94  TauTransverseImpactParameters_token = consumes<PFTauTIPAssociationByRef>(cfg.getParameter<edm::InputTag>("srcTauTransverseImpactParameters"));
95 
96  ChargedIsoPtSum_token = consumes<reco::PFTauDiscriminator>(cfg.getParameter<edm::InputTag>("srcChargedIsoPtSum"));
97  NeutralIsoPtSum_token = consumes<reco::PFTauDiscriminator>(cfg.getParameter<edm::InputTag>("srcNeutralIsoPtSum"));
98  PUcorrPtSum_token = consumes<reco::PFTauDiscriminator>(cfg.getParameter<edm::InputTag>("srcPUcorrPtSum"));
99 
100  verbosity_ = ( cfg.exists("verbosity") ) ?
101  cfg.getParameter<int>("verbosity") : 0;
102 
103  produces<PFTauDiscriminator>("category");
104  }
T getParameter(std::string const &) const
assert(m_qm.get())
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 112 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

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 
)
virtual

Reimplemented from TauDiscriminationProducerBase< TauType, TauDiscriminator >.

Definition at line 153 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

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

154 {
155  if ( !mvaReader_ ) {
156  if ( loadMVAfromDB_ ) {
158  } else {
160  }
161  }
162 
164 
168 
169  evt.getByToken(Tau_token, taus_);
171 }
edm::RefProd< TauCollection > TauRefProd
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
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:87
double PFRecoTauDiscriminationByIsolationMVA2::discriminate ( const PFTauRef tau) const

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

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

Reimplemented from TauDiscriminationProducerBase< TauType, TauDiscriminator >.

Definition at line 237 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

References edm::Event::put().

238 {
239  // add all category indices to event
240  evt.put(category_output_, "category");
241 }
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 146 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

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

Definition at line 138 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

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

Definition at line 139 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

edm::FileInPath PFRecoTauDiscriminationByIsolationMVA2::inputFileName_
private

Definition at line 128 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

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

Definition at line 148 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

bool PFRecoTauDiscriminationByIsolationMVA2::loadMVAfromDB_
private

Definition at line 127 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

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

Definition at line 132 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

std::string PFRecoTauDiscriminationByIsolationMVA2::mvaName_
private

Definition at line 126 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

int PFRecoTauDiscriminationByIsolationMVA2::mvaOpt_
private

Definition at line 131 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

const GBRForest* PFRecoTauDiscriminationByIsolationMVA2::mvaReader_
private

Definition at line 129 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

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

Definition at line 140 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

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

Definition at line 141 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

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

Definition at line 142 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

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

Definition at line 143 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

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

Definition at line 136 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

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

Definition at line 145 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

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

Definition at line 135 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

int PFRecoTauDiscriminationByIsolationMVA2::verbosity_
private

Definition at line 150 of file PFRecoTauDiscriminationByMVAIsolation2.cc.