1 #ifndef PhysicsTools_SelectorUtils_VersionedSelector_h
2 #define PhysicsTools_SelectorUtils_VersionedSelector_h
14 #if ( !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__) ) || defined(__ROOTCLING__)
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)
25 #include <boost/shared_ptr.hpp>
26 #define SHARED_PTR(T) boost::shared_ptr<T>
37 #include <openssl/md5.h>
39 namespace candf = candidate_functions;
53 constexpr unsigned length = MD5_DIGEST_LENGTH;
56 memset(
id_md5_,0,length*
sizeof(
unsigned char));
60 <<
"VersionedSelector does not allow untracked parameters"
61 <<
" in the cutflow ParameterSet!";
64 MD5((
unsigned char*)tracked.c_str(), tracked.size(),
id_md5_);
66 for(
unsigned i=0;
i<MD5_DIGEST_LENGTH; ++
i ){
81 <<
"VersionedGsfElectronSelector not initialized!" << std::endl;
83 for(
unsigned i = 0;
i <
cuts_.size(); ++
i ) {
101 for(
size_t i = 0, cutssize =
cuts_.size();
i < cutssize; ++
i ) {
141 constexpr unsigned length = MD5_DIGEST_LENGTH;
142 return ( 0 == memcmp(
id_md5_,other.
id_md5_,length*
sizeof(
unsigned char)) );
162 std::vector<SHARED_PTR(candf::CandidateCut) >
cuts_;
178 <<
"ID was already initialized!";
181 const std::vector<edm::ParameterSet>& cutflow =
183 if( cutflow.size() == 0 ) {
185 <<
"You have supplied a null/empty cutflow to VersionedIDSelector,"
186 <<
" please add content to the cuflow and try again.";
190 std::vector<edm::ParameterSet>::const_iterator cbegin(cutflow.begin()),
192 std::vector<edm::ParameterSet>::const_iterator icut = cbegin;
193 std::map<std::string,unsigned> cut_counter;
194 std::vector<std::string> ignored_cuts;
195 for( ; icut != cend; ++icut ) {
196 std::stringstream realname;
198 if( !cut_counter.count(name) ) cut_counter[name] = 0;
199 realname << name <<
"_" << cut_counter[
name];
200 const bool needsContent =
201 icut->getParameter<
bool>(
"needsAdditionalProducts");
202 const bool ignored = icut->getParameter<
bool>(
"isIgnored");
205 if( plugin !=
nullptr ) {
209 <<
"The requested cut: " << name <<
" is not available!";
211 needs_event_content_.push_back(needsContent);
213 this->push_back(therealname);
214 this->set(therealname);
215 if(ignored) ignored_cuts.push_back(therealname);
218 this->setIgnoredCuts(ignored_cuts);
223 for( ; icut != cend; ++icut ) {
224 std::stringstream realname;
226 if( !cut_counter.count(name) ) cut_counter[name] = 0;
227 realname << name <<
"_" << cut_counter[
name];
237 #ifdef REGULAR_CPLUSPLUS
241 std::map<std::string,unsigned> names_to_index;
242 std::map<std::string,unsigned> cut_counter;
243 for(
unsigned idx = 0;
idx < cuts_.size(); ++
idx ) {
245 if( !cut_counter.count(name) ) cut_counter[name] = 0;
246 std::stringstream realname;
247 realname << name <<
"_" << cut_counter[
name];
248 names_to_index.emplace(realname.str(),
idx);
257 for(
size_t i = 0, cutssize = cuts_.size();
i < cutssize; ++
i ) {
258 if( needs_event_content_[
i] ) {
261 if(
nullptr != needsEvent ) {
266 <<
" configured to consume event products but does not "
267 <<
" inherit from CutApplicatorWithEventContenBase "
268 <<
" please correct either your python or C++!";
virtual bool operator()(const T &ref, pat::strbitset &ret) overridefinal
This provides the interface for base classes to select objects.
T getParameter(std::string const &) const
VParameterSet const & getParameterSetVector(std::string const &name) const
tuple ret
prodAgent to be discontinued
const unsigned char * md55Raw() const
bool operator()(typename T::value_type const &t)
bool operator()(typename T::value_type const &t, edm::EventBase const &e)
auto_ptr< JetDefinition::Plugin > plugin
std::vector< double > values_
vid::CutFlowResult cutFlowResult() const
std::string dump(unsigned int indent=0) const
virtual bool operator()(T const &t) overridefinal
This provides an alternative signature without the second ret.
const size_t cutFlowSize() const
void setIgnored(pat::strbitset &ret)
set ignored bits
std::vector< std::shared_ptr< candf::CandidateCut > > cuts_
virtual bool operator()(const T &ref, edm::EventBase const &e, pat::strbitset &ret) overridefinal
This provides an alternative signature that includes extra information.
pat::strbitset retInternal_
internal ret if users don't care about return bits
VersionedSelector(const edm::ParameterSet &conf)
ParameterSet trackedPart() const
std::vector< bool > needs_event_content_
const std::string & name() const
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
virtual bool operator()(T const &t, edm::EventBase const &e) overridefinal
This provides an alternative signature that includes extra information.
bool ignoreCut(std::string const &s) const
ignore the cut at index "s"
const unsigned bitMap() const
Functor that operates on <T>
tuple idx
DEBUGGING if hasattr(process,"trackMonIterativeTracking2012"): print "trackMonIterativeTracking2012 D...
strbitset & set(bool val=true)
set method of all bits
const unsigned howFarInCutFlow() const
const std::string & md5String() const
pat::strbitset getBitTemplate() const
Get an empty bitset with the proper names.
void setConsumes(edm::ConsumesCollector)
unsigned char id_md5_[MD5_DIGEST_LENGTH]
volatile std::atomic< bool > shutdown_flag false
std::vector< typename Selector< T >::index_type > cut_indices_
cut-flow versioning info in the event provenance
bool operator==(const VersionedSelector &other) const
virtual void setConsumes(edm::ConsumesCollector &)=0
T get(const Candidate &c)