|
|
Go to the documentation of this file. 1 #ifndef PhysicsTools_SelectorUtils_VersionedSelector_h
2 #define PhysicsTools_SelectorUtils_VersionedSelector_h
14 #if (!defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__) && !defined(__CLING__))
16 #define REGULAR_CPLUSPLUS 1
17 #define CINT_GUARD(CODE) CODE
20 #define SHARED_PTR(T) std::shared_ptr<T>
24 #define CINT_GUARD(CODE)
26 #define SHARED_PTR(T) std::shared_ptr<T>
37 #include <openssl/md5.h>
56 constexpr
unsigned length = MD5_DIGEST_LENGTH;
58 memset(
id_md5_, 0, length *
sizeof(
unsigned char));
59 MD5((
unsigned char*)tracked.c_str(), tracked.size(),
id_md5_);
61 for (
unsigned i = 0;
i < MD5_DIGEST_LENGTH; ++
i) {
75 throw cms::Exception(
"CutNotInitialized") <<
"VersionedGsfElectronSelector not initialized!" << std::endl;
77 for (
unsigned i = 0;
i <
cuts_.size(); ++
i) {
96 for (
size_t i = 0, cutssize =
cuts_.size();
i < cutssize; ++
i) {
135 constexpr
unsigned length = MD5_DIGEST_LENGTH;
136 return (0 == memcmp(
id_md5_,
other.id_md5_, length *
sizeof(
unsigned char)));
166 if (paraName !=
"isPOGApproved")
167 confWithoutIsPOGApproved.
copyFrom(conf, paraName);
168 else if (conf.
existsAs<
bool>(paraName,
true))
169 confWithoutIsPOGApproved.
copyFrom(conf, paraName);
173 throw cms::Exception(
"InvalidConfiguration") <<
"VersionedSelector does not allow untracked parameters"
174 <<
" in the cutflow ParameterSet!";
194 edm::LogWarning(
"VersionedPatElectronSelector") <<
"ID was already initialized!";
198 if (cutflow.empty()) {
199 throw cms::Exception(
"InvalidCutFlow") <<
"You have supplied a null/empty cutflow to VersionedIDSelector,"
200 <<
" please add content to the cuflow and try again.";
204 std::vector<edm::ParameterSet>::const_iterator cbegin(cutflow.begin()), cend(cutflow.end());
205 std::vector<edm::ParameterSet>::const_iterator icut = cbegin;
206 std::map<std::string, unsigned> cut_counter;
207 std::vector<std::string> ignored_cuts;
208 for (; icut != cend; ++icut) {
209 std::stringstream realname;
211 if (!cut_counter.count(
name))
212 cut_counter[
name] = 0;
213 realname <<
name <<
"_" << cut_counter[
name];
214 const bool needsContent = icut->getParameter<
bool>(
"needsAdditionalProducts");
215 const bool ignored = icut->getParameter<
bool>(
"isIgnored");
217 needs_event_content_.push_back(needsContent);
219 this->push_back(therealname);
220 this->set(therealname);
222 ignored_cuts.push_back(therealname);
225 this->setIgnoredCuts(ignored_cuts);
230 for (; icut != cend; ++icut) {
231 std::stringstream realname;
233 if (!cut_counter.count(
name))
234 cut_counter[
name] = 0;
235 realname <<
name <<
"_" << cut_counter[
name];
243 #ifdef REGULAR_CPLUSPLUS
247 std::map<std::string, unsigned> names_to_index;
248 std::map<std::string, unsigned> cut_counter;
249 for (
unsigned idx = 0;
idx < cuts_.size(); ++
idx) {
251 if (!cut_counter.count(
name))
252 cut_counter[
name] = 0;
253 std::stringstream realname;
254 realname <<
name <<
"_" << cut_counter[
name];
255 names_to_index.emplace(realname.str(),
idx);
264 for (
size_t i = 0, cutssize = cuts_.size();
i < cutssize; ++
i) {
265 if (needs_event_content_[
i]) {
267 if (
nullptr != needsEvent) {
271 <<
" configured to consume event products but does not "
272 <<
" inherit from CutApplicatorWithEventContenBase "
273 <<
" please correct either your python or C++!";
ret
prodAgent to be discontinued
void copyFrom(ParameterSet const &from, std::string const &name)
bool operator()(const T &ref, pat::strbitset &ret) final
This provides the interface for base classes to select objects.
void setIgnored(pat::strbitset &ret)
set ignored bits
Functor that operates on <T>
bool operator()(typename T::value_type const &t)
bool operator()(typename T::value_type const &t, edm::EventBase const &e)
strbitset & set(bool val=true)
set method of all bits
pat::strbitset retInternal_
internal ret if users don't care about return bits
bool ignoreCut(std::string const &s) const
ignore the cut at index "s"
std::vector< double > values_
std::vector< std::shared_ptr< candf::CandidateCut > > cuts_
const std::string & name() const
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
const unsigned bitMap() const
Log< level::Warning, false > LogWarning
std::vector< bool > needs_event_content_
VersionedSelector(const edm::ParameterSet &conf)
std::string dump(unsigned int indent=0) const
const std::string & md5String() const
cut-flow versioning info in the event provenance
virtual void setConsumes(edm::ConsumesCollector &)=0
bool operator==(const VersionedSelector &other) const
virtual void getEventContent(const edm::EventBase &)=0
void initialize(const edm::ParameterSet &)
pat::strbitset getBitTemplate() const
Get an empty bitset with the proper names.
void passCut(pat::strbitset &ret, std::string const &s)
Passing cuts.
const unsigned char * md55Raw() const
const size_t cutFlowSize() const
std::vector< std::string > getParameterNames() const
vid::CutFlowResult cutFlowResult() const
bool operator()(const T &ref, edm::EventBase const &e, pat::strbitset &ret) final
This provides an alternative signature that includes extra information.
bool operator()(T const &t, edm::EventBase const &e) final
This provides an alternative signature that includes extra information.
Container::value_type value_type
void setConsumes(edm::ConsumesCollector)
unsigned char id_md5_[MD5_DIGEST_LENGTH]
ParameterSet trackedPart() const
T getParameter(std::string const &) const
VParameterSet const & getParameterSetVector(std::string const &name) const
std::vector< typename Selector< T >::index_type > cut_indices_
static void validateParamsAreTracked(const edm::ParameterSet &conf)
const unsigned howFarInCutFlow() const
bool operator()(T const &t) final
This provides an alternative signature without the second ret.