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 for( ; icut != cend; ++icut ) {
196 const bool needsContent =
197 icut->getParameter<
bool>(
"needsAdditionalProducts");
198 const bool ignored = icut->getParameter<
bool>(
"isIgnored");
201 if( plugin !=
nullptr ) {
205 <<
"The requested cut: " << cname <<
" is not available!";
207 needs_event_content_.push_back(needsContent);
209 std::stringstream realname;
210 if( !cut_counter.count(name) ) cut_counter[name] = 0;
211 realname << name <<
"_" << cut_counter[
name];
213 this->push_back(therealname);
214 this->set(therealname);
215 if(ignored) this->ignoreCut(therealname);
222 for( ; icut != cend; ++icut ) {
223 std::stringstream realname;
225 if( !cut_counter.count(name) ) cut_counter[name] = 0;
226 realname << name <<
"_" << cut_counter[
name];
236 #ifdef REGULAR_CPLUSPLUS
240 std::map<std::string,unsigned> names_to_index;
241 std::map<std::string,unsigned> cut_counter;
242 for(
unsigned idx = 0;
idx < cuts_.size(); ++
idx ) {
244 if( !cut_counter.count(name) ) cut_counter[name] = 0;
245 std::stringstream realname;
246 realname << name <<
"_" << cut_counter[
name];
247 names_to_index.emplace(realname.str(),
idx);
256 for(
size_t i = 0, cutssize = cuts_.size();
i < cutssize; ++
i ) {
257 if( needs_event_content_[
i] ) {
260 if(
nullptr != needsEvent ) {
265 <<
" configured to consume event products but does not "
266 <<
" inherit from CutApplicatorWithEventContenBase "
267 <<
" 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
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.
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
Container::value_type value_type
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)