1 #ifndef RecoTauTag_RecoTau_PFTauSelectorDefinition 2 #define RecoTauTag_RecoTau_PFTauSelectorDefinition 35 std::vector<std::pair<int, double>>
rawCuts;
43 auto const&
discriminators =
cfg.getParameter<std::vector<edm::ParameterSet>>(
"discriminators");
49 newCut.
cut =
pset.getParameter<
double>(
"selectionCut");
56 auto const& rawLabels =
pset.getParameter<std::vector<std::string>>(
"rawValues");
57 auto const& rawCutValues =
pset.getParameter<std::vector<double>>(
"selectionCuts");
58 if (rawLabels.size() != rawCutValues.size()) {
60 <<
"unequal number of TauIDContainer raw value indices and cut values given to PFTauSelector.";
62 for (
size_t i = 0;
i < rawLabels.size();
i++) {
63 newCut.
rawCuts.push_back(std::pair<int, double>(-99, rawCutValues[
i]));
66 newCut.
wpLabels =
pset.getParameter<std::vector<std::string>>(
"workingPoints");
72 cut_ = std::make_unique<StringCutObjectSelector<reco::PFTau>>(
cfg.getParameter<
std::string>(
"cut"));
83 <<
"an invalid PFTau handle with ProductID" << hc.
id() <<
" passed to PFTauSelector.";
88 e.getByToken(
disc.inputToken,
disc.handle);
91 e.getByToken(
disc.inputToken,
disc.handle);
94 if (
phID_ !=
e.processHistoryID()) {
95 phID_ =
e.processHistoryID();
97 auto const& psetsFromProvenance =
edm::parameterSet(
disc.handle.provenance()->stable(),
e.processHistory());
99 if (psetsFromProvenance.exists(
"rawValues")) {
100 auto const idlist = psetsFromProvenance.
getParameter<std::vector<std::string>>(
"rawValues");
101 for (
size_t i = 0;
i <
disc.rawLabels.size(); ++
i) {
103 for (
size_t j = 0;
j < idlist.size(); ++
j) {
104 if (
disc.rawLabels[
i] == idlist[
j]) {
106 disc.rawCuts[
i].first =
j;
111 <<
"PFTauSelector: Requested working point '" <<
disc.rawLabels[
i] <<
"' not found!\n";
113 }
else if (psetsFromProvenance.exists(
"IDdefinitions")) {
114 auto const idlist = psetsFromProvenance.getParameter<std::vector<edm::ParameterSet>>(
"IDdefinitions");
115 for (
size_t i = 0;
i <
disc.rawLabels.size(); ++
i) {
117 for (
size_t j = 0;
j < idlist.size(); ++
j) {
120 disc.rawCuts[
i].first =
j;
125 <<
"PFTauSelector: Requested working point '" <<
disc.rawLabels[
i] <<
"' not found!\n";
127 }
else if (psetsFromProvenance.exists(
"VSjetWP")) {
132 throw cms::Exception(
"Configuration") <<
"PFTauSelector: No suitable ID list found in provenace config!\n";
134 if (psetsFromProvenance.exists(
"workingPoints")) {
135 auto const idlist = psetsFromProvenance.getParameter<std::vector<std::string>>(
"workingPoints");
136 for (
size_t i = 0;
i <
disc.wpLabels.size(); ++
i) {
138 for (
size_t j = 0;
j < idlist.size(); ++
j) {
139 if (
disc.wpLabels[
i] == idlist[
j]) {
146 <<
"PFTauSelector: Requested working point '" <<
disc.wpLabels[
i] <<
"' not found!\n";
148 }
else if (psetsFromProvenance.exists(
"IDWPdefinitions")) {
149 auto const idlist = psetsFromProvenance.getParameter<std::vector<edm::ParameterSet>>(
"IDWPdefinitions");
150 for (
size_t i = 0;
i <
disc.wpLabels.size(); ++
i) {
152 for (
size_t j = 0;
j < idlist.size(); ++
j) {
160 <<
"PFTauSelector: Requested working point '" <<
disc.wpLabels[
i] <<
"' not found!\n";
162 }
else if (psetsFromProvenance.exists(
"VSjetWP")) {
163 auto const idlist = psetsFromProvenance.getParameter<std::vector<std::string>>(
"VSjetWP");
164 for (
size_t i = 0;
i <
disc.wpLabels.size(); ++
i) {
166 for (
size_t j = 0;
j < idlist.size(); ++
j) {
167 if (
disc.wpLabels[
i] == idlist[
j]) {
174 <<
"PFTauSelector: Requested working point '" <<
disc.wpLabels[
i] <<
"' not found!\n";
177 throw cms::Exception(
"Configuration") <<
"PFTauSelector: No suitable ID WP list found in provenace config!\n";
181 const size_t nTaus = hc->size();
182 for (
size_t iTau = 0; iTau < nTaus; ++iTau) {
195 for (
auto const& rawCut :
disc.rawCuts) {
196 if (!((*
disc.handle)[
tau].rawValues.at(rawCut.first) > rawCut.second)) {
203 for (
auto const& wpCut :
disc.wpCuts) {
204 if (!((*
disc.handle)[
tau].workingPoints.at(wpCut))) {
231 std::unique_ptr<StringCutObjectSelector<reco::PFTau>>
cut_;
PFTauSelectorDefinition(const edm::ParameterSet &cfg, edm::ConsumesCollector &&iC)
reco::PFTauCollection collection
std::vector< std::string > wpLabels
T getParameter(std::string const &) const
std::vector< PFTau > PFTauCollection
collection of PFTau objects
DiscCutPairVec discriminators_
const_iterator end() const
void select(const HandleToCollection &hc, const edm::Event &e, const edm::EventSetup &s)
edm::Handle< reco::TauDiscriminatorContainer > handle
ParameterSet const & parameterSet(StableProvenance const &provenance, ProcessHistory const &history)
container::const_iterator const_iterator
std::vector< int > wpCuts
std::vector< DiscContainerCutPair > DiscContainerCutPairVec
std::unique_ptr< StringCutObjectSelector< reco::PFTau > > cut_
const_iterator begin() const
edm::Handle< reco::PFTauDiscriminator > handle
DiscContainerCutPairVec discriminatorContainers_
edm::EDGetTokenT< reco::PFTauDiscriminator > inputToken
std::vector< std::string > rawLabels
std::vector< DiscCutPair > DiscCutPairVec
edm::Handle< collection > HandleToCollection
edm::ProcessHistoryID phID_
edm::EDGetTokenT< reco::TauDiscriminatorContainer > inputToken
std::vector< const reco::PFTau * > container
std::vector< std::pair< int, double > > rawCuts