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 Attributes
PFRecoTauDiscriminationAgainstMuonMVA Class Reference
Inheritance diagram for PFRecoTauDiscriminationAgainstMuonMVA:
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 &)
 
 PFRecoTauDiscriminationAgainstMuonMVA (const edm::ParameterSet &cfg)
 
 ~PFRecoTauDiscriminationAgainstMuonMVA ()
 
- 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 Attributes

std::auto_ptr< PFTauDiscriminatorcategory_output_
 
double dRmuonMatch_
 
edm::FileInPath inputFileName_
 
std::vector< TFile * > inputFilesToDelete_
 
std::string moduleLabel_
 
edm::Handle< reco::MuonCollectionmuons_
 
edm::EDGetTokenT
< reco::MuonCollection
Muons_token
 
float * mvaInput_
 
double mvaMin_
 
std::string mvaName_
 
const GBRForestmvaReader_
 
bool returnMVA_
 
edm::InputTag srcMuons_
 
size_t tauIndex_
 
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
< 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

MVA based discriminator against muon -> tau fakes

Author
Christian Veelken, LLR

Definition at line 56 of file PFRecoTauDiscriminationAgainstMuonMVA.cc.

Constructor & Destructor Documentation

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

Definition at line 59 of file PFRecoTauDiscriminationAgainstMuonMVA.cc.

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

61  moduleLabel_(cfg.getParameter<std::string>("@module_label")),
62  mvaReader_(0),
63  mvaInput_(0)
64  {
65  inputFileName_ = cfg.getParameter<edm::FileInPath>("inputFileName");
66  mvaName_ = cfg.getParameter<std::string>("mvaName");
67  mvaReader_ = loadMVAfromFile(inputFileName_, mvaName_, inputFilesToDelete_);
68  returnMVA_ = cfg.getParameter<bool>("returnMVA");
69  mvaMin_ = cfg.getParameter<double>("mvaMin");
70  mvaInput_ = new float[11];
71 
72  srcMuons_ = cfg.getParameter<edm::InputTag>("srcMuons");
73  Muons_token=consumes<reco::MuonCollection>(srcMuons_);
74  dRmuonMatch_ = cfg.getParameter<double>("dRmuonMatch");
75 
76  verbosity_ = ( cfg.exists("verbosity") ) ?
77  cfg.getParameter<int>("verbosity") : 0;
78 
79  produces<PFTauDiscriminator>("category");
80  }
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::MuonCollection > Muons_token
bool exists(std::string const &parameterName) const
checks if a parameter exists
TauDiscriminationProducerBase< reco::PFTau, reco::PFTauDiscriminator > PFTauDiscriminationProducerBase
PFRecoTauDiscriminationAgainstMuonMVA::~PFRecoTauDiscriminationAgainstMuonMVA ( )
inline

Definition at line 88 of file PFRecoTauDiscriminationAgainstMuonMVA.cc.

89  {
90  delete mvaReader_;
91  delete[] mvaInput_;
92  for ( std::vector<TFile*>::iterator it = inputFilesToDelete_.begin();
93  it != inputFilesToDelete_.end(); ++it ) {
94  delete (*it);
95  }
96  }

Member Function Documentation

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

Reimplemented from TauDiscriminationProducerBase< TauType, TauDiscriminator >.

Definition at line 123 of file PFRecoTauDiscriminationAgainstMuonMVA.cc.

References edm::Event::getByToken().

124 {
126 
127  evt.getByToken(Tau_token, taus_);
129  tauIndex_ = 0;
130 }
edm::RefProd< TauCollection > TauRefProd
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
edm::EDGetTokenT< reco::MuonCollection > Muons_token
edm::EDGetTokenT< TauCollection > Tau_token
double PFRecoTauDiscriminationAgainstMuonMVA::discriminate ( const PFTauRef tau)

Definition at line 154 of file PFRecoTauDiscriminationAgainstMuonMVA.cc.

References python.rootplot.argparse::category, reco::deltaR(), PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi::dR, edm::Ref< C, T, F >::isNonnull(), edm::Ref< C, T, F >::isNull(), siStripFEDMonitor_P5_cff::Max, moduleLabel_(), metsig::muon, reco::Muon::NoArbitration, and patZpeak::numMuons.

155 {
156  if ( verbosity_ ) {
157  edm::LogPrint("PFTauAgainstMuonMVA") << "<PFRecoTauDiscriminationAgainstMuonMVA::discriminate>:" ;
158  edm::LogPrint("PFTauAgainstMuonMVA") << " moduleLabel = " << moduleLabel_ ;
159  edm::LogPrint("PFTauAgainstMuonMVA") << " mvaMin = " << mvaMin_ ;
160  }
161 
162  // CV: define dummy category index in order to use RecoTauDiscriminantCutMultiplexer module to appy WP cuts
163  double category = 0.;
164  category_output_->setValue(tauIndex_, category);
165  ++tauIndex_;
166 
167  // CV: computation of anti-muon MVA value requires presence of leading charged hadron
168  if ( tau->leadPFChargedHadrCand().isNull() ) return 0.;
169 
170  mvaInput_[0] = TMath::Abs(tau->eta());
171  double tauCaloEnECAL = 0.;
172  double tauCaloEnHCAL = 0.;
173  const std::vector<reco::PFCandidatePtr>& tauSignalPFCands = tau->signalPFCands();
174  for ( std::vector<reco::PFCandidatePtr>::const_iterator tauSignalPFCand = tauSignalPFCands.begin();
175  tauSignalPFCand != tauSignalPFCands.end(); ++tauSignalPFCand ) {
176  tauCaloEnECAL += (*tauSignalPFCand)->ecalEnergy();
177  tauCaloEnHCAL += (*tauSignalPFCand)->hcalEnergy();
178  }
179  mvaInput_[1] = TMath::Sqrt(TMath::Max(0., tauCaloEnECAL));
180  mvaInput_[2] = TMath::Sqrt(TMath::Max(0., tauCaloEnHCAL));
181  mvaInput_[3] = tau->leadPFChargedHadrCand()->pt()/TMath::Max(1.,Double_t(tau->pt()));
182  mvaInput_[4] = TMath::Sqrt(TMath::Max(0., tau->leadPFChargedHadrCand()->ecalEnergy()));
183  mvaInput_[5] = TMath::Sqrt(TMath::Max(0., tau->leadPFChargedHadrCand()->hcalEnergy()));
184  int numMatches = 0;
185  std::vector<int> numHitsDT(4);
186  std::vector<int> numHitsCSC(4);
187  std::vector<int> numHitsRPC(4);
188  for ( int iStation = 0; iStation < 4; ++iStation ) {
189  numHitsDT[iStation] = 0;
190  numHitsCSC[iStation] = 0;
191  numHitsRPC[iStation] = 0;
192  }
193  if ( tau->leadPFChargedHadrCand().isNonnull() ) {
194  reco::MuonRef muonRef = tau->leadPFChargedHadrCand()->muonRef();
195  if ( muonRef.isNonnull() ) {
196  numMatches = muonRef->numberOfMatches(reco::Muon::NoArbitration);
197  countHits(*muonRef, numHitsDT, numHitsCSC, numHitsRPC);
198  }
199  }
200  size_t numMuons = muons_->size();
201  for ( size_t idxMuon = 0; idxMuon < numMuons; ++idxMuon ) {
202  reco::MuonRef muon(muons_, idxMuon);
203  if ( tau->leadPFChargedHadrCand().isNonnull() && tau->leadPFChargedHadrCand()->muonRef().isNonnull() && muon == tau->leadPFChargedHadrCand()->muonRef() ) {
204  continue;
205  }
206  double dR = deltaR(muon->p4(), tau->p4());
207  if ( dR < dRmuonMatch_ ) {
208  numMatches += muon->numberOfMatches(reco::Muon::NoArbitration);
209  countHits(*muon, numHitsDT, numHitsCSC, numHitsRPC);
210  }
211  }
212  mvaInput_[6] = numMatches;
213  mvaInput_[7] = numHitsDT[0] + numHitsCSC[0] + numHitsRPC[0];
214  mvaInput_[8] = numHitsDT[1] + numHitsCSC[1] + numHitsRPC[1];
215  mvaInput_[9] = numHitsDT[2] + numHitsCSC[2] + numHitsRPC[2];
216  mvaInput_[10] = numHitsDT[3] + numHitsCSC[3] + numHitsRPC[3];
217 
218  double mvaValue = mvaReader_->GetClassifier(mvaInput_);
219  if ( verbosity_ ) {
220  edm::LogPrint("PFTauAgainstMuonMVA") << "mvaValue = " << mvaValue ;
221  }
222 
223  double retVal = -1.;
224  if ( returnMVA_ ) {
225  retVal = mvaValue;
226  if ( verbosity_ ) {
227  edm::LogPrint("PFTauAgainstMuonMVA") << "--> retVal = " << retVal ;
228  }
229  } else {
230  retVal = ( mvaValue > mvaMin_ ) ? 1. : 0.;
231  if ( verbosity_ ) {
232  edm::LogPrint("PFTauAgainstMuonMVA") << "--> retVal = " << retVal << ": discriminator = ";
233  if ( retVal > 0.5 ) edm::LogPrint("PFTauAgainstMuonMVA") << "PASSED." ;
234  else edm::LogPrint("PFTauAgainstMuonMVA") << "FAILED." ;
235  }
236  }
237  return retVal;
238 }
tuple numMuons
Definition: patZpeak.py:40
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
bool isNull() const
Checks for null.
Definition: Ref.h:247
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
double GetClassifier(const float *vector) const
Definition: GBRForest.h:64
void PFRecoTauDiscriminationAgainstMuonMVA::endEvent ( edm::Event evt)
virtual

Reimplemented from TauDiscriminationProducerBase< TauType, TauDiscriminator >.

Definition at line 240 of file PFRecoTauDiscriminationAgainstMuonMVA.cc.

References edm::Event::put().

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

Member Data Documentation

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

Definition at line 115 of file PFRecoTauDiscriminationAgainstMuonMVA.cc.

double PFRecoTauDiscriminationAgainstMuonMVA::dRmuonMatch_
private

Definition at line 112 of file PFRecoTauDiscriminationAgainstMuonMVA.cc.

edm::FileInPath PFRecoTauDiscriminationAgainstMuonMVA::inputFileName_
private

Definition at line 102 of file PFRecoTauDiscriminationAgainstMuonMVA.cc.

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

Definition at line 118 of file PFRecoTauDiscriminationAgainstMuonMVA.cc.

std::string PFRecoTauDiscriminationAgainstMuonMVA::moduleLabel_
private
edm::Handle<reco::MuonCollection> PFRecoTauDiscriminationAgainstMuonMVA::muons_
private

Definition at line 110 of file PFRecoTauDiscriminationAgainstMuonMVA.cc.

edm::EDGetTokenT<reco::MuonCollection> PFRecoTauDiscriminationAgainstMuonMVA::Muons_token
private

Definition at line 111 of file PFRecoTauDiscriminationAgainstMuonMVA.cc.

float* PFRecoTauDiscriminationAgainstMuonMVA::mvaInput_
private

Definition at line 107 of file PFRecoTauDiscriminationAgainstMuonMVA.cc.

double PFRecoTauDiscriminationAgainstMuonMVA::mvaMin_
private

Definition at line 106 of file PFRecoTauDiscriminationAgainstMuonMVA.cc.

std::string PFRecoTauDiscriminationAgainstMuonMVA::mvaName_
private

Definition at line 103 of file PFRecoTauDiscriminationAgainstMuonMVA.cc.

const GBRForest* PFRecoTauDiscriminationAgainstMuonMVA::mvaReader_
private

Definition at line 104 of file PFRecoTauDiscriminationAgainstMuonMVA.cc.

bool PFRecoTauDiscriminationAgainstMuonMVA::returnMVA_
private

Definition at line 105 of file PFRecoTauDiscriminationAgainstMuonMVA.cc.

edm::InputTag PFRecoTauDiscriminationAgainstMuonMVA::srcMuons_
private

Definition at line 109 of file PFRecoTauDiscriminationAgainstMuonMVA.cc.

size_t PFRecoTauDiscriminationAgainstMuonMVA::tauIndex_
private

Definition at line 116 of file PFRecoTauDiscriminationAgainstMuonMVA.cc.

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

Definition at line 114 of file PFRecoTauDiscriminationAgainstMuonMVA.cc.

int PFRecoTauDiscriminationAgainstMuonMVA::verbosity_
private

Definition at line 120 of file PFRecoTauDiscriminationAgainstMuonMVA.cc.