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::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

void beginEvent (const edm::Event &, const edm::EventSetup &)
 
double discriminate (const PFTauRef &)
 
void endEvent (edm::Event &)
 
 PFRecoTauDiscriminationByIsolationMVA2 (const edm::ParameterSet &cfg)
 
 ~PFRecoTauDiscriminationByIsolationMVA2 ()
 
- Public Member Functions inherited from TauDiscriminationProducerBase< TauType, TauDiscriminator >
virtual double discriminate (const TauRef &tau)=0
 
void produce (edm::Event &, const edm::EventSetup &)
 
 TauDiscriminationProducerBase (const edm::ParameterSet &iConfig)
 
 TauDiscriminationProducerBase ()
 
virtual ~TauDiscriminationProducerBase ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- 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_
 
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_
 
size_t tauIndex_
 
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::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
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
 
edm::InputTag TauProducer_
 

Detailed Description

Definition at line 56 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

Member Typedef Documentation

Definition at line 120 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

Member Enumeration Documentation

anonymous enum
private

Constructor & Destructor Documentation

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

Definition at line 59 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

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

61  moduleLabel_(cfg.getParameter<std::string>("@module_label")),
62  mvaReader_(0),
63  mvaInput_(0),
65  {
66  inputFileName_ = cfg.getParameter<edm::FileInPath>("inputFileName");
67  mvaName_ = cfg.getParameter<std::string>("mvaName");
68  mvaReader_ = loadMVAfromFile(inputFileName_, mvaName_, inputFilesToDelete_);
69  std::string mvaOpt_string = cfg.getParameter<std::string>("mvaOpt");
70  if ( mvaOpt_string == "oldDMwoLT" ) mvaOpt_ = kOldDMwoLT;
71  else if ( mvaOpt_string == "oldDMwLT" ) mvaOpt_ = kOldDMwLT;
72  else if ( mvaOpt_string == "newDMwoLT" ) mvaOpt_ = kNewDMwoLT;
73  else if ( mvaOpt_string == "newDMwLT" ) mvaOpt_ = kNewDMwLT;
74  else throw cms::Exception("PFRecoTauDiscriminationByIsolationMVA2")
75  << " Invalid Configuration Parameter 'mvaOpt' = " << mvaOpt_string << " !!\n";
76 
77  if ( mvaOpt_ == kOldDMwoLT || mvaOpt_ == kNewDMwoLT ) mvaInput_ = new float[6];
78  else if ( mvaOpt_ == kOldDMwLT || mvaOpt_ == kNewDMwLT ) mvaInput_ = new float[12];
79  else assert(0);
80 
81  TauTransverseImpactParameters_token = consumes<PFTauTIPAssociationByRef>(cfg.getParameter<edm::InputTag>("srcTauTransverseImpactParameters"));
82 
83  ChargedIsoPtSum_token = consumes<reco::PFTauDiscriminator>(cfg.getParameter<edm::InputTag>("srcChargedIsoPtSum"));
84  NeutralIsoPtSum_token = consumes<reco::PFTauDiscriminator>(cfg.getParameter<edm::InputTag>("srcNeutralIsoPtSum"));
85  PUcorrPtSum_token = consumes<reco::PFTauDiscriminator>(cfg.getParameter<edm::InputTag>("srcPUcorrPtSum"));
86 
87  verbosity_ = ( cfg.exists("verbosity") ) ?
88  cfg.getParameter<int>("verbosity") : 0;
89 
90  produces<PFTauDiscriminator>("category");
91  }
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 99 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

100  {
101  delete mvaReader_;
102  delete[] mvaInput_;
103  for ( std::vector<TFile*>::iterator it = inputFilesToDelete_.begin();
104  it != inputFilesToDelete_.end(); ++it ) {
105  delete (*it);
106  }
107  }

Member Function Documentation

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

Reimplemented from TauDiscriminationProducerBase< TauType, TauDiscriminator >.

Definition at line 140 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

References edm::Event::getByToken().

141 {
143 
147 
148  evt.getByToken(Tau_token, taus_);
150  tauIndex_ = 0;
151 }
edm::RefProd< TauCollection > TauRefProd
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
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)

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

154 {
155  // CV: define dummy category index in order to use RecoTauDiscriminantCutMultiplexer module to appy WP cuts
156  double category = 0.;
157  category_output_->setValue(tauIndex_, category);
158  ++tauIndex_;
159 
160  // CV: computation of MVA value requires presence of leading charged hadron
161  if ( tau->leadPFChargedHadrCand().isNull() ) return 0.;
162 
163  int tauDecayMode = tau->decayMode();
164 
165  if ( ((mvaOpt_ == kOldDMwoLT || mvaOpt_ == kOldDMwLT) && (tauDecayMode == 0 || tauDecayMode == 1 || tauDecayMode == 2 || tauDecayMode == 10)) ||
166  ((mvaOpt_ == kNewDMwoLT || mvaOpt_ == kNewDMwLT) && (tauDecayMode == 0 || tauDecayMode == 1 || tauDecayMode == 2 || tauDecayMode == 5 || tauDecayMode == 6 || tauDecayMode == 10)) ) {
167 
168  double chargedIsoPtSum = (*chargedIsoPtSums_)[tau];
169  double neutralIsoPtSum = (*neutralIsoPtSums_)[tau];
170  double puCorrPtSum = (*puCorrPtSums_)[tau];
171 
172  const reco::PFTauTransverseImpactParameter& tauLifetimeInfo = *(*tauLifetimeInfos)[tau];
173 
174  double decayDistX = tauLifetimeInfo.flightLength().x();
175  double decayDistY = tauLifetimeInfo.flightLength().y();
176  double decayDistZ = tauLifetimeInfo.flightLength().z();
177  double decayDistMag = TMath::Sqrt(decayDistX*decayDistX + decayDistY*decayDistY + decayDistZ*decayDistZ);
178 
179  if ( mvaOpt_ == kOldDMwoLT || mvaOpt_ == kNewDMwoLT ) {
180  mvaInput_[0] = TMath::Log(TMath::Max(1., Double_t(tau->pt())));
181  mvaInput_[1] = TMath::Abs(tau->eta());
182  mvaInput_[2] = TMath::Log(TMath::Max(1.e-2, chargedIsoPtSum));
183  mvaInput_[3] = TMath::Log(TMath::Max(1.e-2, neutralIsoPtSum - 0.125*puCorrPtSum));
184  mvaInput_[4] = TMath::Log(TMath::Max(1.e-2, puCorrPtSum));
185  mvaInput_[5] = tauDecayMode;
186  } else if ( mvaOpt_ == kOldDMwLT || mvaOpt_ == kNewDMwLT ) {
187  mvaInput_[0] = TMath::Log(TMath::Max(1., Double_t(tau->pt())));
188  mvaInput_[1] = TMath::Abs(tau->eta());
189  mvaInput_[2] = TMath::Log(TMath::Max(1.e-2, chargedIsoPtSum));
190  mvaInput_[3] = TMath::Log(TMath::Max(1.e-2, neutralIsoPtSum - 0.125*puCorrPtSum));
191  mvaInput_[4] = TMath::Log(TMath::Max(1.e-2, puCorrPtSum));
192  mvaInput_[5] = tauDecayMode;
193  mvaInput_[6] = TMath::Sign(+1., tauLifetimeInfo.dxy());
194  mvaInput_[7] = TMath::Sqrt(TMath::Abs(TMath::Min(1., tauLifetimeInfo.dxy())));
195  mvaInput_[8] = TMath::Min(10., TMath::Abs(tauLifetimeInfo.dxy_Sig()));
196  mvaInput_[9] = ( tauLifetimeInfo.hasSecondaryVertex() ) ? 1. : 0.;
197  mvaInput_[10] = TMath::Sqrt(decayDistMag);
198  mvaInput_[11] = TMath::Min(10., tauLifetimeInfo.flightLengthSig());
199  }
200 
201  double mvaValue = mvaReader_->GetClassifier(mvaInput_);
202  if ( verbosity_ ) {
203  edm::LogPrint("PFTauDiscByMVAIsol2") << "<PFRecoTauDiscriminationByIsolationMVA2::discriminate>:" ;
204  edm::LogPrint("PFTauDiscByMVAIsol2") << " tau: Pt = " << tau->pt() << ", eta = " << tau->eta() ;
205  edm::LogPrint("PFTauDiscByMVAIsol2") << " isolation: charged = " << chargedIsoPtSum << ", neutral = " << neutralIsoPtSum << ", PUcorr = " << puCorrPtSum ;
206  edm::LogPrint("PFTauDiscByMVAIsol2") << " decay mode = " << tauDecayMode ;
207  edm::LogPrint("PFTauDiscByMVAIsol2") << " impact parameter: distance = " << tauLifetimeInfo.dxy() << ", significance = " << tauLifetimeInfo.dxy_Sig() ;
208  edm::LogPrint("PFTauDiscByMVAIsol2") << " has decay vertex = " << tauLifetimeInfo.hasSecondaryVertex() << ":"
209  << " distance = " << decayDistMag << ", significance = " << tauLifetimeInfo.flightLengthSig() ;
210  edm::LogPrint("PFTauDiscByMVAIsol2") << "--> mvaValue = " << mvaValue ;
211  }
212  return mvaValue;
213  } else {
214  return -1.;
215  }
216 }
T Sign(T A, T B)
Definition: MathUtil.h:54
T Min(T a, T b)
Definition: MathUtil.h:39
bool isNull() const
Checks for null.
Definition: Ref.h:247
T Abs(T a)
Definition: MathUtil.h:49
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 218 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

References edm::Event::put().

219 {
220  // add all category indices to event
221  evt.put(category_output_, "category");
222 }
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116

Member Data Documentation

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

Definition at line 132 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

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

Definition at line 124 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

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

Definition at line 125 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

edm::FileInPath PFRecoTauDiscriminationByIsolationMVA2::inputFileName_
private

Definition at line 113 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

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

Definition at line 135 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

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

Definition at line 118 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

std::string PFRecoTauDiscriminationByIsolationMVA2::mvaName_
private

Definition at line 114 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

int PFRecoTauDiscriminationByIsolationMVA2::mvaOpt_
private

Definition at line 117 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

const GBRForest* PFRecoTauDiscriminationByIsolationMVA2::mvaReader_
private

Definition at line 115 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

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

Definition at line 126 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

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

Definition at line 127 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

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

Definition at line 128 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

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

Definition at line 129 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

size_t PFRecoTauDiscriminationByIsolationMVA2::tauIndex_
private

Definition at line 133 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

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

Definition at line 122 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

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

Definition at line 131 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

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

Definition at line 121 of file PFRecoTauDiscriminationByMVAIsolation2.cc.

int PFRecoTauDiscriminationByIsolationMVA2::verbosity_
private

Definition at line 137 of file PFRecoTauDiscriminationByMVAIsolation2.cc.