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 Member Functions | Private Attributes
PFRecoTauDiscriminationAgainstElectronMVA2 Class Reference
Inheritance diagram for PFRecoTauDiscriminationAgainstElectronMVA2:
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 &)
 
 PFRecoTauDiscriminationAgainstElectronMVA2 (const edm::ParameterSet &iConfig)
 
 ~PFRecoTauDiscriminationAgainstElectronMVA2 ()
 
- 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 ()
 
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 ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

std::string readZippedFile (const std::string &fileName)
 

Private Attributes

std::auto_ptr< PFTauDiscriminatorcategory_output_
 
edm::Handle
< reco::GsfElectronCollection
gsfElectrons_
 
edm::FileInPath inputFileName1prongBL_
 
edm::FileInPath inputFileName1prongEC_
 
edm::FileInPath inputFileName1prongNoEleMatchBL_
 
edm::FileInPath inputFileName1prongNoEleMatchEC_
 
edm::FileInPath inputFileName1prongStripsWgsfWOpfEleMvaBL_
 
edm::FileInPath inputFileName1prongStripsWgsfWOpfEleMvaEC_
 
edm::FileInPath inputFileName1prongStripsWgsfWpfEleMvaBL_
 
edm::FileInPath inputFileName1prongStripsWgsfWpfEleMvaEC_
 
edm::FileInPath inputFileName1prongStripsWOgsfBL_
 
edm::FileInPath inputFileName1prongStripsWOgsfEC_
 
std::string method_
 
double minMVA1prongBL_
 
double minMVA1prongEC_
 
double minMVA1prongNoEleMatchBL_
 
double minMVA1prongNoEleMatchEC_
 
double minMVA1prongStripsWgsfWOpfEleMvaBL_
 
double minMVA1prongStripsWgsfWOpfEleMvaEC_
 
double minMVA1prongStripsWgsfWpfEleMvaBL_
 
double minMVA1prongStripsWgsfWpfEleMvaEC_
 
double minMVA1prongStripsWOgsfBL_
 
double minMVA1prongStripsWOgsfEC_
 
std::string moduleLabel_
 
AntiElectronIDMVA2mva_
 
bool returnMVA_
 
edm::InputTag srcGsfElectrons_
 
size_t tauIndex_
 
edm::Handle< TauCollectiontaus_
 

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
 
typedef WorkerT< EDProducerWorkerType
 
- 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::EDProducer
CurrentProcessingContext const * currentContext () const
 
- 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::InputTag TauProducer_
 

Detailed Description

Definition at line 23 of file PFRecoTauDiscriminationAgainstElectronMVA2.cc.

Constructor & Destructor Documentation

PFRecoTauDiscriminationAgainstElectronMVA2::PFRecoTauDiscriminationAgainstElectronMVA2 ( const edm::ParameterSet iConfig)
inlineexplicit

Definition at line 26 of file PFRecoTauDiscriminationAgainstElectronMVA2.cc.

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

28  moduleLabel_(iConfig.getParameter<std::string>("@module_label")),
29  mva_(0),
31  {
32  //std::cout << "<PFRecoTauDiscriminationAgainstElectronMVA2::PFRecoTauDiscriminationAgainstElectronMVA2>:" << std::endl;
33  //std::cout << " moduleLabel = " << moduleLabel_ << std::endl;
34 
35  method_ = iConfig.getParameter<std::string>("method");
36  inputFileName1prongNoEleMatchBL_ = iConfig.getParameter<edm::FileInPath>("inputFileName1prongNoEleMatchBL");
37  inputFileName1prongBL_ = iConfig.getParameter<edm::FileInPath>("inputFileName1prongBL");
38  inputFileName1prongStripsWOgsfBL_ = iConfig.getParameter<edm::FileInPath>("inputFileName1prongStripsWOgsfBL");
39  inputFileName1prongStripsWgsfWOpfEleMvaBL_ = iConfig.getParameter<edm::FileInPath>("inputFileName1prongStripsWgsfWOpfEleMvaBL");
40  inputFileName1prongStripsWgsfWpfEleMvaBL_ = iConfig.getParameter<edm::FileInPath>("inputFileName1prongStripsWgsfWpfEleMvaBL");
41  inputFileName1prongNoEleMatchEC_ = iConfig.getParameter<edm::FileInPath>("inputFileName1prongNoEleMatchEC");
42  inputFileName1prongEC_ = iConfig.getParameter<edm::FileInPath>("inputFileName1prongEC");
43  inputFileName1prongStripsWOgsfEC_ = iConfig.getParameter<edm::FileInPath>("inputFileName1prongStripsWOgsfEC");
44  inputFileName1prongStripsWgsfWOpfEleMvaEC_ = iConfig.getParameter<edm::FileInPath>("inputFileName1prongStripsWgsfWOpfEleMvaEC");
45  inputFileName1prongStripsWgsfWpfEleMvaEC_ = iConfig.getParameter<edm::FileInPath>("inputFileName1prongStripsWgsfWpfEleMvaEC");
46 
47  returnMVA_ = iConfig.getParameter<bool>("returnMVA");
48  minMVA1prongNoEleMatchBL_ = iConfig.getParameter<double>("minMVA1prongNoEleMatchBL");
49  minMVA1prongBL_ = iConfig.getParameter<double>("minMVA1prongBL");
50  minMVA1prongStripsWOgsfBL_ = iConfig.getParameter<double>("minMVA1prongStripsWOgsfBL");
51  minMVA1prongStripsWgsfWOpfEleMvaBL_ = iConfig.getParameter<double>("minMVA1prongStripsWgsfWOpfEleMvaBL");
52  minMVA1prongStripsWgsfWpfEleMvaBL_ = iConfig.getParameter<double>("minMVA1prongStripsWgsfWpfEleMvaBL");
53  minMVA1prongNoEleMatchEC_ = iConfig.getParameter<double>("minMVA1prongNoEleMatchEC");
54  minMVA1prongEC_ = iConfig.getParameter<double>("minMVA1prongEC");
55  minMVA1prongStripsWOgsfEC_ = iConfig.getParameter<double>("minMVA1prongStripsWOgsfEC");
56  minMVA1prongStripsWgsfWOpfEleMvaEC_ = iConfig.getParameter<double>("minMVA1prongStripsWgsfWOpfEleMvaEC");
57  minMVA1prongStripsWgsfWpfEleMvaEC_ = iConfig.getParameter<double>("minMVA1prongStripsWgsfWpfEleMvaEC");
58 
59  srcGsfElectrons_ = iConfig.getParameter<edm::InputTag>("srcGsfElectrons");
60 
61  mva_ = new AntiElectronIDMVA2();
62  // CV: working version of file compression not implemented yet
63  //mva_->Initialize_from_string(method_,
64  // readZippedFile(inputFileName1prongNoEleMatchBL_.fullPath()),
65  // readZippedFile(inputFileName1prongBL_.fullPath()),
66  // readZippedFile(inputFileName1prongStripsWOgsfBL_.fullPath()),
67  // readZippedFile(inputFileName1prongStripsWgsfWOpfEleMvaBL_.fullPath()),
68  // readZippedFile(inputFileName1prongStripsWgsfWpfEleMvaBL_.fullPath()),
69  // readZippedFile(inputFileName1prongNoEleMatchEC_.fullPath()),
70  // readZippedFile(inputFileName1prongEC_.fullPath()),
71  // readZippedFile(inputFileName1prongStripsWOgsfEC_.fullPath()),
72  // readZippedFile(inputFileName1prongStripsWgsfWOpfEleMvaEC_.fullPath()),
73  // readZippedFile(inputFileName1prongStripsWgsfWpfEleMvaEC_.fullPath()));
74  mva_->Initialize_from_file(method_,
75  inputFileName1prongNoEleMatchBL_.fullPath(),
76  inputFileName1prongBL_.fullPath(),
77  inputFileName1prongStripsWOgsfBL_.fullPath(),
78  inputFileName1prongStripsWgsfWOpfEleMvaBL_.fullPath(),
79  inputFileName1prongStripsWgsfWpfEleMvaBL_.fullPath(),
80  inputFileName1prongNoEleMatchEC_.fullPath(),
81  inputFileName1prongEC_.fullPath(),
82  inputFileName1prongStripsWOgsfEC_.fullPath(),
83  inputFileName1prongStripsWgsfWOpfEleMvaEC_.fullPath(),
84  inputFileName1prongStripsWgsfWpfEleMvaEC_.fullPath());
85 
86  // add category index
87  if ( returnMVA_ ) {
88  produces<PFTauDiscriminator>("category");
89  }
90  }
T getParameter(std::string const &) const
TauDiscriminationProducerBase< reco::PFTau, reco::PFTauDiscriminator > PFTauDiscriminationProducerBase
std::string fullPath() const
Definition: FileInPath.cc:171
PFRecoTauDiscriminationAgainstElectronMVA2::~PFRecoTauDiscriminationAgainstElectronMVA2 ( )
inline

Definition at line 98 of file PFRecoTauDiscriminationAgainstElectronMVA2.cc.

99  {
100  delete mva_;
101  }

Member Function Documentation

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

Reimplemented from TauDiscriminationProducerBase< TauType, TauDiscriminator >.

Definition at line 158 of file PFRecoTauDiscriminationAgainstElectronMVA2.cc.

References edm::Event::getByLabel().

159 {
160  if ( returnMVA_ ) {
163  tauIndex_ = 0;
164  }
166 }
edm::RefProd< TauCollection > TauRefProd
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
double PFRecoTauDiscriminationAgainstElectronMVA2::discriminate ( const PFTauRef thePFTauRef)

Definition at line 168 of file PFRecoTauDiscriminationAgainstElectronMVA2.cc.

References python.rootplot.argparse::category, reco::deltaR(), edm::Ref< C, T, F >::isNonnull(), and siStripFEDMonitor_P5_cff::Min.

169 {
170  double mva = 1.;
171  double workingPoint = 1.;
172  double category = -1.;
173  bool isGsfElectronMatched = false;
174  if( (*thePFTauRef).leadPFChargedHadrCand().isNonnull()) {
175  for ( reco::GsfElectronCollection::const_iterator theGsfElectron = gsfElectrons_->begin();
176  theGsfElectron != gsfElectrons_->end(); ++theGsfElectron ) {
177  if ( theGsfElectron->pt() > 10. ) { // CV: only take electrons above some minimal energy/Pt into account...
178  double deltaREleTau = deltaR(theGsfElectron->p4(), thePFTauRef->p4());
179  if ( deltaREleTau < 0.3 ) {
180  double mva_match = mva_->MVAValue(*thePFTauRef, *theGsfElectron);
181  double workingPoint_match = 0.;
182 
183  size_t numSignalPFGammaCands = thePFTauRef->signalPFGammaCands().size();
184  bool hasGsfTrack = thePFTauRef->leadPFChargedHadrCand()->gsfTrackRef().isNonnull();
185  bool isPFElectron = (theGsfElectron->mvaOutput().mva > -0.1);
186 
187  if ( thePFTauRef->signalPFChargedHadrCands().size() == 1 ) {
188  double mvaCut = 999.;
189  if ( TMath::Abs(thePFTauRef->eta()) < 1.5 ) { // Barrel
190  if ( numSignalPFGammaCands == 0 ) {
191  category = 1.;
192  mvaCut = minMVA1prongBL_;
193  } else if ( numSignalPFGammaCands >= 1 && !hasGsfTrack ) {
194  category = 2.;
196  } else if ( numSignalPFGammaCands >= 1 && hasGsfTrack && !isPFElectron ) {
197  category = 3.;
199  } else if ( numSignalPFGammaCands >= 1 && hasGsfTrack && isPFElectron ) {
200  category = 4.;
202  }
203  } else { // Endcap
204  if ( numSignalPFGammaCands == 0 ) {
205  category = 6.;
206  mvaCut = minMVA1prongEC_;
207  } else if ( numSignalPFGammaCands >= 1 && !hasGsfTrack ) {
208  category = 7.;
210  } else if ( numSignalPFGammaCands >= 1 && hasGsfTrack && !isPFElectron ) {
211  category = 8.;
213  } else if ( numSignalPFGammaCands >= 1 && hasGsfTrack && isPFElectron ) {
214  category = 9.;
216  }
217  }
218  workingPoint_match = (mva_match > mvaCut);
219  } else {
220  workingPoint_match = 1.;
221  }
222 
223  mva = TMath::Min(mva, mva_match);
224  workingPoint = TMath::Min(workingPoint, workingPoint_match);
225  isGsfElectronMatched = true;
226  }
227  }
228  }
229  }
230 
231  if ( !isGsfElectronMatched ) {
232  mva = mva_->MVAValue(*thePFTauRef);
233  double mvaCut = 999.;
234  if ( TMath::Abs(thePFTauRef->eta()) < 1.5 ) { // Barrel
235  category = 0.;
236  mvaCut = minMVA1prongNoEleMatchBL_;
237  } else { // Endcap
238  category = 5.;
239  mvaCut = minMVA1prongNoEleMatchEC_;
240  }
241  workingPoint = (mva > mvaCut);
242  }
243 
244  //std::cout << "<PFRecoTauDiscriminationAgainstElectronMVA2::discriminate>:" << std::endl;
245  //std::cout << " tau: Pt = " << thePFTauRef->pt() << ", eta = " << thePFTauRef->eta() << ", phi = " << thePFTauRef->phi() << std::endl;
246  //std::cout << " mva = " << mva << ": workingPoint = " << workingPoint << std::endl;
247 
248  if ( returnMVA_ ) {
249  // add category index
250  category_output_->setValue(tauIndex_, category);
251  ++tauIndex_;
252  // return MVA output value
253  return mva;
254  } else {
255  return workingPoint;
256  }
257 }
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
double MVAValue(Float_t TauEtaAtEcalEntrance, Float_t TauPhi, Float_t TauPt, Float_t TauSignalPFChargedCands, Float_t TauSignalPFGammaCands, Float_t TauLeadPFChargedHadrHoP, Float_t TauLeadPFChargedHadrEoP, Float_t TauHasGsf, Float_t TauVisMass, Float_t TauEmFraction, const std::vector< Float_t > &GammasdEta, const std::vector< Float_t > &GammasdPhi, const std::vector< Float_t > &GammasPt, Float_t ElecEta, Float_t ElecPhi, Float_t ElecPt, Float_t ElecPFMvaOutput, Float_t ElecEe, Float_t ElecEgamma, Float_t ElecPin, Float_t ElecPout, Float_t ElecEarlyBrem, Float_t ElecLateBrem, Float_t ElecFbrem, Float_t ElecChi2KF, Float_t ElecChi2GSF, Float_t ElecNumHits, Float_t ElecGSFTrackResol, Float_t ElecGSFTracklnPt, Float_t ElecGSFTrackEta)
void PFRecoTauDiscriminationAgainstElectronMVA2::endEvent ( edm::Event evt)
virtual

Reimplemented from TauDiscriminationProducerBase< TauType, TauDiscriminator >.

Definition at line 259 of file PFRecoTauDiscriminationAgainstElectronMVA2.cc.

References edm::Event::put().

260 {
261  // add all category indices to event
262  if ( returnMVA_ ) {
263  evt.put(category_output_, "category");
264  }
265 }
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
std::string PFRecoTauDiscriminationAgainstElectronMVA2::readZippedFile ( const std::string &  fileName)
inlineprivate

Definition at line 105 of file PFRecoTauDiscriminationAgainstElectronMVA2.cc.

References mergeVDriftHistosByStation::file, and ext::basic_izstreambase< Item_t, Traits_t, Allocator_t >::rdbuf().

106  {
107  //std::cout << "<PFRecoTauDiscriminationAgainstElectronMVA2::readZippedFile>:" << std::endl;
108  //std::cout << " fileName = " << fileName << std::endl;
109  // CV: code adapted from PhysicsTools/MVAComputer/src/MVAComputer.cc
110  std::ifstream file;
111  file.open(fileName.c_str());
112  if ( !file.good() ) throw cms::Exception("InvalidFileState")
113  << "Failed to open MVA file = " << fileName << " !!\n";
114  std::ostringstream buffer_zipped;
115  while ( file.good() ) {
116  buffer_zipped << (char)file.get();
117  }
118  file.close();
119  //std::cout << " buffer (zipped) = " << buffer_zipped.str() << std::endl;
120  ext::izstream gunzip(&file);
121  std::ostringstream buffer_unzipped;
122  buffer_unzipped << gunzip.rdbuf();
123  //std::cout << " buffer (unzipped) = " << buffer_unzipped.str() << std::endl;
124  return buffer_unzipped.str();
125  }

Member Data Documentation

std::auto_ptr<PFTauDiscriminator> PFRecoTauDiscriminationAgainstElectronMVA2::category_output_
private
edm::Handle<reco::GsfElectronCollection> PFRecoTauDiscriminationAgainstElectronMVA2::gsfElectrons_
private
edm::FileInPath PFRecoTauDiscriminationAgainstElectronMVA2::inputFileName1prongBL_
private
edm::FileInPath PFRecoTauDiscriminationAgainstElectronMVA2::inputFileName1prongEC_
private
edm::FileInPath PFRecoTauDiscriminationAgainstElectronMVA2::inputFileName1prongNoEleMatchBL_
private
edm::FileInPath PFRecoTauDiscriminationAgainstElectronMVA2::inputFileName1prongNoEleMatchEC_
private
edm::FileInPath PFRecoTauDiscriminationAgainstElectronMVA2::inputFileName1prongStripsWgsfWOpfEleMvaBL_
private
edm::FileInPath PFRecoTauDiscriminationAgainstElectronMVA2::inputFileName1prongStripsWgsfWOpfEleMvaEC_
private
edm::FileInPath PFRecoTauDiscriminationAgainstElectronMVA2::inputFileName1prongStripsWgsfWpfEleMvaBL_
private
edm::FileInPath PFRecoTauDiscriminationAgainstElectronMVA2::inputFileName1prongStripsWgsfWpfEleMvaEC_
private
edm::FileInPath PFRecoTauDiscriminationAgainstElectronMVA2::inputFileName1prongStripsWOgsfBL_
private
edm::FileInPath PFRecoTauDiscriminationAgainstElectronMVA2::inputFileName1prongStripsWOgsfEC_
private
std::string PFRecoTauDiscriminationAgainstElectronMVA2::method_
private
double PFRecoTauDiscriminationAgainstElectronMVA2::minMVA1prongBL_
private
double PFRecoTauDiscriminationAgainstElectronMVA2::minMVA1prongEC_
private
double PFRecoTauDiscriminationAgainstElectronMVA2::minMVA1prongNoEleMatchBL_
private
double PFRecoTauDiscriminationAgainstElectronMVA2::minMVA1prongNoEleMatchEC_
private
double PFRecoTauDiscriminationAgainstElectronMVA2::minMVA1prongStripsWgsfWOpfEleMvaBL_
private
double PFRecoTauDiscriminationAgainstElectronMVA2::minMVA1prongStripsWgsfWOpfEleMvaEC_
private
double PFRecoTauDiscriminationAgainstElectronMVA2::minMVA1prongStripsWgsfWpfEleMvaBL_
private
double PFRecoTauDiscriminationAgainstElectronMVA2::minMVA1prongStripsWgsfWpfEleMvaEC_
private
double PFRecoTauDiscriminationAgainstElectronMVA2::minMVA1prongStripsWOgsfBL_
private
double PFRecoTauDiscriminationAgainstElectronMVA2::minMVA1prongStripsWOgsfEC_
private
std::string PFRecoTauDiscriminationAgainstElectronMVA2::moduleLabel_
private
AntiElectronIDMVA2* PFRecoTauDiscriminationAgainstElectronMVA2::mva_
private
bool PFRecoTauDiscriminationAgainstElectronMVA2::returnMVA_
private
edm::InputTag PFRecoTauDiscriminationAgainstElectronMVA2::srcGsfElectrons_
private
size_t PFRecoTauDiscriminationAgainstElectronMVA2::tauIndex_
private
edm::Handle<TauCollection> PFRecoTauDiscriminationAgainstElectronMVA2::taus_
private