1 #ifndef RecoTauTag_RecoTau_PFTauSelectorDefinition
2 #define RecoTauTag_RecoTau_PFTauSelectorDefinition
35 std::vector<std::pair<int, double>>
rawCuts;
49 newCut.
cut =
pset.getParameter<
double>(
"selectionCut");
52 for (
auto const&
pset : discriminatorContainers) {
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");
85 <<
"an invalid PFTau handle with ProductID" << hc.
id() <<
" passed to PFTauSelector.";
98 for (
auto& disc : discriminatorContainers_) {
101 if (psetsFromProvenance.exists(
"rawValues")) {
102 auto const idlist = psetsFromProvenance.
getParameter<std::vector<std::string>>(
"rawValues");
103 for (
size_t i = 0;
i < disc.rawLabels.size(); ++
i) {
105 for (
size_t j = 0;
j < idlist.size(); ++
j) {
106 if (disc.rawLabels[
i] == idlist[
j]) {
108 disc.rawCuts[
i].first =
j;
113 <<
"PFTauSelector: Requested working point '" << disc.rawLabels[
i] <<
"' not found!\n";
115 }
else if (psetsFromProvenance.exists(
"IDdefinitions")) {
116 auto const idlist = psetsFromProvenance.getParameter<std::vector<edm::ParameterSet>>(
"IDdefinitions");
117 for (
size_t i = 0;
i < disc.rawLabels.size(); ++
i) {
119 for (
size_t j = 0;
j < idlist.size(); ++
j) {
120 if (disc.rawLabels[
i] == idlist[
j].getParameter<
std::string>(
"IDname")) {
122 disc.rawCuts[
i].first =
j;
127 <<
"PFTauSelector: Requested working point '" << disc.rawLabels[
i] <<
"' not found!\n";
129 }
else if (psetsFromProvenance.exists(
"VSjetWP")) {
134 throw cms::Exception(
"Configuration") <<
"PFTauSelector: No suitable ID list found in provenace config!\n";
136 if (psetsFromProvenance.exists(
"workingPoints")) {
137 auto const idlist = psetsFromProvenance.getParameter<std::vector<std::string>>(
"workingPoints");
138 for (
size_t i = 0;
i < disc.wpLabels.size(); ++
i) {
140 for (
size_t j = 0;
j < idlist.size(); ++
j) {
141 if (disc.wpLabels[
i] == idlist[
j]) {
148 <<
"PFTauSelector: Requested working point '" << disc.wpLabels[
i] <<
"' not found!\n";
150 }
else if (psetsFromProvenance.exists(
"IDWPdefinitions")) {
151 auto const idlist = psetsFromProvenance.getParameter<std::vector<edm::ParameterSet>>(
"IDWPdefinitions");
152 for (
size_t i = 0;
i < disc.wpLabels.size(); ++
i) {
154 for (
size_t j = 0;
j < idlist.size(); ++
j) {
155 if (disc.wpLabels[
i] == idlist[
j].getParameter<
std::string>(
"IDname")) {
162 <<
"PFTauSelector: Requested working point '" << disc.wpLabels[
i] <<
"' not found!\n";
164 }
else if (psetsFromProvenance.exists(
"VSjetWP")) {
165 auto const idlist = psetsFromProvenance.getParameter<std::vector<std::string>>(
"VSjetWP");
166 for (
size_t i = 0;
i < disc.wpLabels.size(); ++
i) {
168 for (
size_t j = 0;
j < idlist.size(); ++
j) {
169 if (disc.wpLabels[
i] == idlist[
j]) {
176 <<
"PFTauSelector: Requested working point '" << disc.wpLabels[
i] <<
"' not found!\n";
179 throw cms::Exception(
"Configuration") <<
"PFTauSelector: No suitable ID WP list found in provenace config!\n";
183 const size_t nTaus = hc->size();
184 for (
size_t iTau = 0; iTau < nTaus; ++iTau) {
188 for (
auto const& disc : discriminators_) {
190 if (!((*disc.handle)[tau] > disc.cut)) {
196 for (
auto const& disc : discriminatorContainers_) {
197 for (
auto const& rawCut : disc.rawCuts) {
198 if (!((*disc.handle)[tau].rawValues.at(rawCut.first) > rawCut.second)) {
205 for (
auto const& wpCut : disc.wpCuts) {
206 if (!((*disc.handle)[
tau].workingPoints.at(wpCut))) {
216 if (passed &&
cut_.get()) {
217 passed = (*cut_)(*tau);
233 std::unique_ptr<StringCutObjectSelector<reco::PFTau>>
cut_;
PFTauSelectorDefinition(const edm::ParameterSet &cfg, edm::ConsumesCollector &&iC)
reco::PFTauCollection collection
std::vector< std::string > wpLabels
const_iterator begin() const
std::vector< PFTau > PFTauCollection
collection of PFTau objects
DiscCutPairVec discriminators_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
bool exists(std::string const ¶meterName) const
checks if a parameter exists
void select(const HandleToCollection &hc, const edm::Event &e, const edm::EventSetup &s)
edm::Handle< reco::TauDiscriminatorContainer > handle
container::const_iterator const_iterator
std::vector< int > wpCuts
std::vector< DiscContainerCutPair > DiscContainerCutPairVec
std::unique_ptr< StringCutObjectSelector< reco::PFTau > > cut_
ParameterSet const & parameterSet(StableProvenance const &provenance, ProcessHistory const &history)
const_iterator end() const
edm::Handle< reco::PFTauDiscriminator > handle
tuple discriminatorContainers
DiscContainerCutPairVec discriminatorContainers_
T const * get() const
Returns C++ pointer to the item.
ProcessHistory const & processHistory() const override
edm::EDGetTokenT< reco::PFTauDiscriminator > inputToken
T getParameter(std::string const &) const
ProcessHistoryID const & processHistoryID() const
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