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> 58 const EVP_MD* md = EVP_get_digestbyname(
"MD5");
59 unsigned int md_len = 0;
62 EVP_DigestInit_ex(mdctx, md,
nullptr);
63 EVP_DigestUpdate(mdctx, tracked.c_str(), tracked.size());
64 EVP_DigestFinal_ex(mdctx,
id_md5_, &md_len);
67 char tmp[EVP_MAX_MD_SIZE * 2 + 1];
68 for (
unsigned int i = 0;
i < md_len;
i++) {
83 throw cms::Exception(
"CutNotInitialized") <<
"VersionedGsfElectronSelector not initialized!" << std::endl;
85 for (
unsigned i = 0;
i <
cuts_.size(); ++
i) {
104 for (
size_t i = 0, cutssize =
cuts_.size();
i < cutssize; ++
i) {
143 constexpr
unsigned length = EVP_MAX_MD_SIZE;
144 return (0 == memcmp(
id_md5_,
other.id_md5_, length *
sizeof(
unsigned char)));
174 if (paraName !=
"isPOGApproved")
175 confWithoutIsPOGApproved.
copyFrom(conf, paraName);
176 else if (conf.
existsAs<
bool>(paraName,
true))
177 confWithoutIsPOGApproved.
copyFrom(conf, paraName);
181 throw cms::Exception(
"InvalidConfiguration") <<
"VersionedSelector does not allow untracked parameters" 182 <<
" in the cutflow ParameterSet!";
188 std::vector<SHARED_PTR(candf::CandidateCut)>
cuts_;
202 edm::LogWarning(
"VersionedPatElectronSelector") <<
"ID was already initialized!";
206 if (cutflow.empty()) {
207 throw cms::Exception(
"InvalidCutFlow") <<
"You have supplied a null/empty cutflow to VersionedIDSelector," 208 <<
" please add content to the cuflow and try again.";
212 std::vector<edm::ParameterSet>::const_iterator cbegin(cutflow.begin()), cend(cutflow.end());
213 std::vector<edm::ParameterSet>::const_iterator icut = cbegin;
214 std::map<std::string, unsigned> cut_counter;
215 std::vector<std::string> ignored_cuts;
216 for (; icut != cend; ++icut) {
217 std::stringstream realname;
219 if (!cut_counter.count(
name))
220 cut_counter[
name] = 0;
221 realname <<
name <<
"_" << cut_counter[
name];
222 const bool needsContent = icut->getParameter<
bool>(
"needsAdditionalProducts");
223 const bool ignored = icut->getParameter<
bool>(
"isIgnored");
225 needs_event_content_.push_back(needsContent);
228 this->
set(therealname);
230 ignored_cuts.push_back(therealname);
233 this->setIgnoredCuts(ignored_cuts);
238 for (; icut != cend; ++icut) {
239 std::stringstream realname;
241 if (!cut_counter.count(
name))
242 cut_counter[
name] = 0;
243 realname <<
name <<
"_" << cut_counter[
name];
251 #ifdef REGULAR_CPLUSPLUS 255 std::map<std::string, unsigned> names_to_index;
256 std::map<std::string, unsigned> cut_counter;
257 for (
unsigned idx = 0;
idx < cuts_.size(); ++
idx) {
259 if (!cut_counter.count(
name))
260 cut_counter[
name] = 0;
261 std::stringstream realname;
262 realname <<
name <<
"_" << cut_counter[
name];
263 names_to_index.emplace(realname.str(),
idx);
272 for (
size_t i = 0, cutssize = cuts_.size();
i < cutssize; ++
i) {
273 if (needs_event_content_[
i]) {
275 if (
nullptr != needsEvent) {
279 <<
" configured to consume event products but does not " 280 <<
" inherit from CutApplicatorWithEventContenBase " 281 <<
" please correct either your python or C++!";
bool ignoreCut(std::string const &s) const
ignore the cut at index "s"
bool operator()(T const &t) final
This provides an alternative signature without the second ret.
T getParameter(std::string const &) const
bool operator()(typename T::value_type const &t)
bool operator()(typename T::value_type const &t, edm::EventBase const &e)
std::vector< double > values_
ret
prodAgent to be discontinued
uint32_t cc[maxCellsPerHit]
const std::string & name() const
ParameterSet trackedPart() const
const unsigned bitMap() const
void setIgnored(pat::strbitset &ret)
set ignored bits
std::vector< std::shared_ptr< candf::CandidateCut > > cuts_
pat::strbitset retInternal_
internal ret if users don't care about return bits
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
VersionedSelector(const edm::ParameterSet &conf)
std::vector< bool > needs_event_content_
void copyFrom(ParameterSet const &from, std::string const &name)
void passCut(pat::strbitset &ret, std::string const &s)
Passing cuts.
Container::value_type value_type
void initialize(const edm::ParameterSet &)
virtual void getEventContent(const edm::EventBase &)=0
const std::string & md5String() const
bool operator==(const VersionedSelector &other) const
const size_t cutFlowSize() const
vid::CutFlowResult cutFlowResult() const
Functor that operates on <T>
const unsigned char * md55Raw() const
pat::strbitset getBitTemplate() const
Get an empty bitset with the proper names.
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.
strbitset & set(bool val=true)
set method of all bits
deadvectors [0] push_back({0.0175431, 0.538005, 6.80997, 13.29})
void setConsumes(edm::ConsumesCollector)
VParameterSet const & getParameterSetVector(std::string const &name) const
std::string dump(unsigned int indent=0) const
Log< level::Warning, false > LogWarning
static void validateParamsAreTracked(const edm::ParameterSet &conf)
const unsigned howFarInCutFlow() const
std::vector< typename Selector< T >::index_type > cut_indices_
cut-flow versioning info in the event provenance
std::vector< std::string > getParameterNames() const
virtual void setConsumes(edm::ConsumesCollector &)=0
bool operator()(const T &ref, pat::strbitset &ret) final
This provides the interface for base classes to select objects.
unsigned char id_md5_[EVP_MAX_MD_SIZE]