8 template <
class TauDiscriminator,
class TauCollection>
12 return std::make_unique<TauDiscriminator>(
TauRefProd(taus));
16 template <
class TauCollection>
19 auto result_object = std::make_unique<TauDiscriminatorContainer>();
21 std::vector<SingleTauDiscriminatorContainer>
placeholder(taus->size());
30 template <
class TauType,
class TauDiscriminator,
class TauDiscriminatorDataType,
class ConsumeType>
33 throw cms::Exception(
"TauDiscriminationProducerBase") <<
" -- default ctor called; derived classes must call "
34 <<
"TauDiscriminationProducerBase(const ParameterSet&)";
38 template <
class TauType,
class TauDiscriminator,
class TauDiscriminatorDataType,
class ConsumeType>
53 transform(pdBoolOperator.begin(), pdBoolOperator.end(), pdBoolOperator.begin(), ::tolower);
55 if (pdBoolOperator ==
"and") {
57 }
else if (pdBoolOperator ==
"or") {
61 <<
"PrediscriminantBooleanOperator defined incorrectly, options are: AND,OR";
65 std::vector<std::string> prediscriminantsNames = prediscriminantConfig.getParameterNamesForType<
edm::ParameterSet>();
67 for (std::vector<std::string>::const_iterator iDisc = prediscriminantsNames.begin();
68 iDisc != prediscriminantsNames.end();
76 thisDiscriminator.cut =
cut;
77 thisDiscriminator.disc_token = consumes<ConsumeType>(
label);
84 produces<TauDiscriminator>();
87 template <
class TauType,
class TauDiscriminator,
class TauDiscriminatorDataType,
class ConsumeType>
92 beginEvent(event, eventSetup);
96 event.getByToken(Tau_token, taus);
101 std::unique_ptr<TauDiscriminator>
output = helper<TauDiscriminator, TauCollection>::init_result_object(taus);
103 size_t nTaus = taus->size();
106 size_t nPrediscriminants = prediscriminants_.size();
107 for (
size_t iDisc = 0; iDisc < nPrediscriminants; ++iDisc) {
108 prediscriminants_[iDisc].fill(event);
112 edm::ProductID discKeyId = prediscriminants_[iDisc].handle->keyProduct().
id();
113 if (tauProductID != discKeyId) {
115 <<
"The tau collection with input tag " << TauProducer_ <<
" has product ID: " << tauProductID
116 <<
" but the pre-discriminator with input tag " << prediscriminants_[iDisc].label
117 <<
" is keyed with product ID: " << discKeyId << std::endl;
122 for (
size_t iTau = 0; iTau < nTaus; ++iTau) {
124 TauRef tauRef(taus, iTau);
126 bool passesPrediscriminants = (andPrediscriminants_ ? 1 : 0);
128 for (
size_t iDisc = 0; iDisc < nPrediscriminants; ++iDisc) {
130 double discResult = (*prediscriminants_[iDisc].handle)[tauRef];
131 uint8_t thisPasses = (discResult > prediscriminants_[iDisc].cut) ? 1 : 0;
148 if (thisPasses ^ andPrediscriminants_)
150 passesPrediscriminants = (andPrediscriminants_ ? 0 : 1);
155 TauDiscriminatorDataType
result = TauDiscriminatorDataType(prediscriminantFailValue_);
156 if (passesPrediscriminants) {
158 result = discriminate(tauRef);
163 (*output)[tauRef] =
result;
171 template <
class TauType,
class TauDiscriminator,
class TauDiscriminatorDataType,
class ConsumeType>
183 producer_params.
add<
double>(
"cut", 0.);
194 template <
class TauType,
class TauDiscriminator,
class TauDiscriminatorDataType,
class ConsumeType>
202 <<
"Unsupported TauType used. You must use either PFTau or PATTau.";
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
edm::RefProd< TauCollection > TauRefProd
double prediscriminantFailValue_
uint8_t andPrediscriminants_
std::vector< Tau > TauCollection
void placeholder(TString saveas="", Bool_t wide=false)
static void fillProducerDescriptions(edm::ParameterSetDescription &desc)
static std::string getTauTypeString()
helper method to retrieve tau type name, e.g. to build correct cfi getter
ParameterDescriptionBase * add(U const &iLabel, T const &value)
edm::InputTag TauProducer_
TauDiscriminationProducerBase()
edm::ValueMap< SingleTauDiscriminatorContainer > TauDiscriminatorContainer
T getParameter(std::string const &) const
edm::EDGetTokenT< TauCollection > Tau_token
void produce(edm::Event &, const edm::EventSetup &) override
std::vector< TauDiscInfo > prediscriminants_