|
|
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>
38 #include <openssl/md5.h>
57 constexpr
unsigned length = MD5_DIGEST_LENGTH;
59 memset(
id_md5_, 0, length *
sizeof(
unsigned char));
60 MD5((
unsigned char*)tracked.c_str(), tracked.size(),
id_md5_);
62 for (
unsigned i = 0;
i < MD5_DIGEST_LENGTH; ++
i) {
76 throw cms::Exception(
"CutNotInitialized") <<
"VersionedGsfElectronSelector not initialized!" << std::endl;
78 for (
unsigned i = 0;
i <
cuts_.size(); ++
i) {
97 for (
size_t i = 0, cutssize =
cuts_.size();
i < cutssize; ++
i) {
136 constexpr
unsigned length = MD5_DIGEST_LENGTH;
137 return (0 == memcmp(
id_md5_,
other.id_md5_, length *
sizeof(
unsigned char)));
167 if (paraName !=
"isPOGApproved")
168 confWithoutIsPOGApproved.
copyFrom(conf, paraName);
169 else if (conf.
existsAs<
bool>(paraName,
true))
170 confWithoutIsPOGApproved.
copyFrom(conf, paraName);
174 throw cms::Exception(
"InvalidConfiguration") <<
"VersionedSelector does not allow untracked parameters"
175 <<
" in the cutflow ParameterSet!";
195 edm::LogWarning(
"VersionedPatElectronSelector") <<
"ID was already initialized!";
199 if (cutflow.empty()) {
200 throw cms::Exception(
"InvalidCutFlow") <<
"You have supplied a null/empty cutflow to VersionedIDSelector,"
201 <<
" please add content to the cuflow and try again.";
205 std::vector<edm::ParameterSet>::const_iterator cbegin(cutflow.begin()), cend(cutflow.end());
206 std::vector<edm::ParameterSet>::const_iterator icut = cbegin;
207 std::map<std::string, unsigned> cut_counter;
208 std::vector<std::string> ignored_cuts;
209 for (; icut != cend; ++icut) {
210 std::stringstream realname;
212 if (!cut_counter.count(
name))
213 cut_counter[
name] = 0;
214 realname <<
name <<
"_" << cut_counter[
name];
215 const bool needsContent = icut->getParameter<
bool>(
"needsAdditionalProducts");
216 const bool ignored = icut->getParameter<
bool>(
"isIgnored");
218 needs_event_content_.push_back(needsContent);
220 this->push_back(therealname);
221 this->set(therealname);
223 ignored_cuts.push_back(therealname);
226 this->setIgnoredCuts(ignored_cuts);
231 for (; icut != cend; ++icut) {
232 std::stringstream realname;
234 if (!cut_counter.count(
name))
235 cut_counter[
name] = 0;
236 realname <<
name <<
"_" << cut_counter[
name];
244 #ifdef REGULAR_CPLUSPLUS
248 std::map<std::string, unsigned> names_to_index;
249 std::map<std::string, unsigned> cut_counter;
250 for (
unsigned idx = 0;
idx < cuts_.size(); ++
idx) {
252 if (!cut_counter.count(
name))
253 cut_counter[
name] = 0;
254 std::stringstream realname;
255 realname <<
name <<
"_" << cut_counter[
name];
256 names_to_index.emplace(realname.str(),
idx);
265 for (
size_t i = 0, cutssize = cuts_.size();
i < cutssize; ++
i) {
266 if (needs_event_content_[
i]) {
268 if (
nullptr != needsEvent) {
272 <<
" configured to consume event products but does not "
273 <<
" inherit from CutApplicatorWithEventContenBase "
274 <<
" 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.