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>
38 #include <openssl/md5.h>
40 namespace candf = candidate_functions;
54 constexpr unsigned length = MD5_DIGEST_LENGTH;
57 memset(
id_md5_,0,length*
sizeof(
unsigned char));
61 <<
"VersionedSelector does not allow untracked parameters"
62 <<
" in the cutflow ParameterSet!";
65 MD5((
unsigned char*)tracked.c_str(), tracked.size(),
id_md5_);
67 for(
unsigned i=0;
i<MD5_DIGEST_LENGTH; ++
i ){
82 <<
"VersionedGsfElectronSelector not initialized!" << std::endl;
84 for(
unsigned i = 0;
i <
cuts_.size(); ++
i ) {
102 for(
size_t i = 0, cutssize =
cuts_.size();
i < cutssize; ++
i ) {
142 constexpr unsigned length = MD5_DIGEST_LENGTH;
143 return ( 0 == memcmp(
id_md5_,other.
id_md5_,length*
sizeof(
unsigned char)) );
163 std::vector<SHARED_PTR(candf::CandidateCut) >
cuts_;
179 <<
"ID was already initialized!";
182 const std::vector<edm::ParameterSet>& cutflow =
184 if( cutflow.size() == 0 ) {
186 <<
"You have supplied a null/empty cutflow to VersionedIDSelector,"
187 <<
" please add content to the cuflow and try again.";
191 std::vector<edm::ParameterSet>::const_iterator cbegin(cutflow.begin()),
193 std::vector<edm::ParameterSet>::const_iterator icut = cbegin;
194 std::map<std::string,unsigned> cut_counter;
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) 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)