8 template <
class TauDiscriminator,
class TauCollection>
16 template <
class TauCollection>
19 auto result_object = std::make_unique<TauDiscriminatorContainer>();
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>
41 : moduleLabel_(iConfig.getParameter<
std::
string>(
"@module_label")) {
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";
67 for (std::vector<std::string>::const_iterator iDisc = prediscriminantsNames.begin();
68 iDisc != prediscriminantsNames.end();
74 TauDiscInfo thisDiscriminator;
75 thisDiscriminator.label =
label;
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) {
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.";