Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restructured code of againstElectronDeadECAL tauID #29627

Merged
merged 10 commits into from
May 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,4 @@ def containerID(pset, inputID, provCfgLabel, wps):
["againstElectronTightMVA6", "_Tight"],
["againstElectronVTightMVA6", "_VTight"]
])
singleID(patTaus.tauIDSources, "hpsPFTauDiscriminationByDeadECALElectronRejection", "againstElectronDeadECAL")
1 change: 1 addition & 0 deletions PhysicsTools/PatAlgos/python/tools/tauTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ def _switchToPFTau(process,
("againstElectronMediumMVA6", "DiscriminationByMVA6MediumElectronRejection"),
("againstElectronTightMVA6", "DiscriminationByMVA6TightElectronRejection"),
("againstElectronVTightMVA6", "DiscriminationByMVA6VTightElectronRejection"),
("againstElectronDeadECAL", "DiscriminationByDeadECALElectronRejection"),
]

# switch to PFTau collection produced for fixed dR = 0.07 signal cone size
Expand Down
2 changes: 1 addition & 1 deletion RecoTauTag/Configuration/python/HPSPFTaus_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from RecoTauTag.RecoTau.PFRecoTauDiscriminationByLeadingTrackFinding_cfi import *
from RecoTauTag.RecoTau.PFRecoTauDiscriminationAgainstElectron_cfi import *
from RecoTauTag.RecoTau.PFRecoTauDiscriminationAgainstElectronMVA6_cfi import *
from RecoTauTag.RecoTau.PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi import *
from RecoTauTag.RecoTau.pfRecoTauDiscriminationAgainstElectronDeadECAL_cfi import *
from RecoTauTag.RecoTau.PFRecoTauDiscriminationAgainstMuon_cfi import *
from RecoTauTag.RecoTau.pfRecoTauDiscriminationAgainstMuon2Container_cfi import *
from RecoTauTag.RecoTau.PFRecoTauDiscriminationAgainstMuonMVA_cfi import *
Expand Down
5 changes: 5 additions & 0 deletions RecoTauTag/RecoTau/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
<use name="MagneticField/Engine"/>
<use name="MagneticField/Records"/>
<use name="Geometry/CaloTopology"/>
<use name="CondFormats/EgammaObjects"/>
<use name="CondFormats/DataRecord"/>
<use name="CondFormats/EcalObjects"/>
<use name="DataFormats/Math"/>
<use name="DataFormats/TauReco"/>
<use name="DataFormats/VertexReco"/>
<use name="DataFormats/PatCandidates"/>
<use name="DataFormats/ParticleFlowCandidate"/>
<use name="DataFormats/TrackReco"/>
<use name="DataFormats/DetId"/>
<use name="DataFormats/EcalDetId"/>
<use name="FWCore/Framework"/>
<use name="FWCore/MessageLogger"/>
<use name="FWCore/ParameterSet"/>
Expand Down
74 changes: 74 additions & 0 deletions RecoTauTag/RecoTau/interface/AntiElectronDeadECAL.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#ifndef RecoTauTag_RecoTau_AntiElectronDeadECAL_h
#define RecoTauTag_RecoTau_AntiElectronDeadECAL_h

/** \class AntiElectronDeadECAL
*
* Flag tau candidates reconstructed near dead ECAL channels,
* in order to reduce e -> tau fakes not rejected by anti-e MVA discriminator
*
* The motivation for this flag is this presentation:
* https://indico.cern.ch/getFile.py/access?contribId=0&resId=0&materialId=slides&confId=177223
*
* Code adapted from:
* RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronDeadECAL.cc
*
* \authors Lauri Andreas Wendland,
* Christian Veelken
*
*
*
*/

#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Framework/interface/ESWatcher.h"
#include "DataFormats/Candidate/interface/Candidate.h"
#include "RecoTauTag/RecoTau/interface/PositionAtECalEntranceComputer.h"

#include <vector>
#include <string>

class EcalChannelStatusRcd;
class CaloGeometryRecord;
class IdealGeometryRecord;

class AntiElectronDeadECAL {
public:
explicit AntiElectronDeadECAL(const edm::ParameterSet&);
~AntiElectronDeadECAL();

void beginEvent(const edm::EventSetup&);

bool operator()(const reco::Candidate* tau) const;

private:
const unsigned minStatus_;
const double dR2_;
const bool extrapolateToECalEntrance_;
const int verbosity_;

PositionAtECalEntranceComputer positionAtECalEntrance_;

void updateBadTowers(const edm::EventSetup&);

struct TowerInfo {
TowerInfo(uint32_t id, unsigned nBad, unsigned maxStatus, double eta, double phi)
: id_(id), nBad_(nBad), maxStatus_(maxStatus), eta_(eta), phi_(phi) {}
uint32_t id_;
unsigned nBad_;
unsigned maxStatus_;
double eta_;
double phi_;
};

std::vector<TowerInfo> badTowers_;
static const uint16_t statusMask_ = 0x1F;

edm::ESWatcher<EcalChannelStatusRcd> channelStatusWatcher_;
edm::ESWatcher<CaloGeometryRecord> caloGeometryWatcher_;
edm::ESWatcher<IdealGeometryRecord> idealGeometryWatcher_;

bool isFirstEvent_;
};

#endif // RecoTauTag_RecoTau_AntiElectronDeadECAL_h
8 changes: 4 additions & 4 deletions RecoTauTag/RecoTau/interface/AntiElectronIDMVA6.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@
#include "CondFormats/EgammaObjects/interface/GBRForest.h"
#include "DataFormats/PatCandidates/interface/Tau.h"
#include "DataFormats/PatCandidates/interface/Electron.h"

#include "CommonTools/BaseParticlePropagator/interface/BaseParticlePropagator.h"
#include "DataFormats/PatCandidates/interface/PackedCandidate.h"
#include "RecoTauTag/RecoTau/interface/PositionAtECalEntranceComputer.h"

#include "TMVA/Tools.h"
#include "TMVA/Reader.h"
Expand Down Expand Up @@ -125,7 +124,7 @@ class AntiElectronIDMVA6 {
double MVAValue(const pat::Tau& theTau, const pat::Electron& theEle);
// this function can be called for category 1 only !!
double MVAValue(const pat::Tau& theTau);
// track extrapolation to ECAL entrance (used to re-calculate varibales that might not be available on miniAOD)
// track extrapolation to ECAL entrance (used to re-calculate variables that might not be available on miniAOD)
bool atECalEntrance(const reco::Candidate* part, math::XYZPoint& pos);

private:
Expand Down Expand Up @@ -168,7 +167,8 @@ class AntiElectronIDMVA6 {

std::vector<TFile*> inputFilesToDelete_;

double bField_;
PositionAtECalEntranceComputer positionAtECalEntrance_;

int verbosity_;
};

Expand Down
33 changes: 33 additions & 0 deletions RecoTauTag/RecoTau/interface/PositionAtECalEntranceComputer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#ifndef RecoTauTag_RecoTau_PositionAtECalEntranceComputer_h
#define RecoTauTag_RecoTau_PositionAtECalEntranceComputer_h

/** \class PositionAtECalEntranceComputer
*
* Extrapolate particle (charged or neutral) to ECAL entrance,
* in order to compute the distance of the tau to ECAL cracks and/or dead ECAL channels
*
* \authors Fabio Colombo,
* Christian Veelken
*
*
*
*/

#include "FWCore/Framework/interface/EventSetup.h"
#include "DataFormats/Candidate/interface/Candidate.h"

class PositionAtECalEntranceComputer {
public:
PositionAtECalEntranceComputer();
~PositionAtECalEntranceComputer();

void beginEvent(const edm::EventSetup&);

//To do: it seems to more practical to put this to the ES
reco::Candidate::Point operator()(const reco::Candidate* particle, bool& success) const;

private:
double bField_z_;
};

#endif // RecoTauTag_RecoTau_PositionAtECalEntranceComputer_h
13 changes: 4 additions & 9 deletions RecoTauTag/RecoTau/interface/TauDiscriminationProducerBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ class TauDiscriminationProducerBase : public edm::stream::EDProducer<> {

static void fillProducerDescriptions(edm::ParameterSetDescription& desc);

/// helper method to retrieve tau type name, e.g. to build correct cfi getter
//string (i.e. PFTau/PATTauProducer)
static std::string getTauTypeString();

protected:
//value given to taus that fail prediscriminants
double prediscriminantFailValue_;
Expand Down Expand Up @@ -125,13 +129,4 @@ typedef TauDiscriminationProducerBase<pat::Tau,
PATTauDiscriminationContainerProducerBase;
typedef TauDiscriminationProducerBase<pat::Tau, pat::PATTauDiscriminator> PATTauDiscriminationProducerBase;

/// helper function retrieve the correct cfi getter string (ie PFTauProducer)
//for this tau type
template <class TauType>
std::string getProducerString() {
// this generic one shoudl never be called.
// these are specialized in TauDiscriminationProducerBase.cc
throw cms::Exception("TauDiscriminationProducerBase")
<< "Unsupported TauType used. You must use either PFTau or PATTau.";
}
#endif
Loading