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) 25 #include <boost/shared_ptr.hpp> 26 #define SHARED_PTR(T) boost::shared_ptr<T> 37 #include <openssl/md5.h> 53 constexpr unsigned length = MD5_DIGEST_LENGTH;
56 memset(id_md5_,0,length*
sizeof(
unsigned char));
58 if ( tracked != untracked ) {
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 ){
67 sprintf(buf,
"%02x", id_md5_[
i]);
68 md5_string_.append( buf );
71 this->retInternal_ = this->getBitTemplate();
81 <<
"VersionedGsfElectronSelector not initialized!" << std::endl;
83 for(
unsigned i = 0;
i < cuts_.size(); ++
i ) {
85 const bool result = (*cuts_[
i])(temp);
86 values_.push_back(cuts_[
i]->
value(temp));
87 if( result || this->ignoreCut(cut_indices_[
i]) ) {
88 this->passCut(ret,cut_indices_[i]);
90 if( !failed ) ++howfar_;
95 this->setIgnored(ret);
101 for(
size_t i = 0, cutssize = cuts_.size();
i < cutssize; ++
i ) {
102 if( needs_event_content_[
i] ) {
108 return this->operator()(ref, ret);
117 return this->operator()(temp);
122 return this->operator()(temp,e);
126 this->retInternal_.set(
false);
127 this->operator()(
t, this->retInternal_);
128 this->setIgnored(this->retInternal_);
129 return (
bool)this->retInternal_;
133 this->retInternal_.set(
false);
134 this->operator()(
t,
e, this->retInternal_);
135 this->setIgnored(this->retInternal_);
136 return (
bool)this->retInternal_;
139 const unsigned char*
md55Raw()
const {
return id_md5_; }
141 constexpr unsigned length = MD5_DIGEST_LENGTH;
142 return ( 0 == memcmp(id_md5_,other.
id_md5_,length*
sizeof(
unsigned char)) );
150 const unsigned bitMap()
const {
return bitmap_; }
162 std::vector<SHARED_PTR(candf::CandidateCut) >
cuts_;
169 unsigned char id_md5_[MD5_DIGEST_LENGTH];
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++!";
T getParameter(std::string const &) const
static AlgebraicMatrix initialize()
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_
def create(alignables, pedeDump, additionalData, outputFile, config)
vid::CutFlowResult cutFlowResult() const
std::string dump(unsigned int indent=0) const
const size_t cutFlowSize() const
std::vector< std::shared_ptr< candf::CandidateCut > > cuts_
VersionedSelector(const edm::ParameterSet &conf)
ParameterSet trackedPart() const
std::vector< bool > needs_event_content_
const std::string & name() const
Container::value_type value_type
void initialize(const edm::ParameterSet &)
virtual void getEventContent(const edm::EventBase &)=0
const unsigned bitMap() const
Functor that operates on <T>
virtual bool operator()(const T &ref, pat::strbitset &ret) override final
virtual bool operator()(T const &t, edm::EventBase const &e) override final
This provides an alternative signature that includes extra information.
const unsigned howFarInCutFlow() const
const std::string & md5String() const
void setConsumes(edm::ConsumesCollector)
virtual bool operator()(T const &t) override final
This provides an alternative signature without the second ret.
unsigned char id_md5_[MD5_DIGEST_LENGTH]
std::vector< typename Selector< T >::index_type > cut_indices_
cut-flow versioning info in the event provenance
virtual bool operator()(const T &ref, edm::EventBase const &e, pat::strbitset &ret) override final
bool operator==(const VersionedSelector &other) const
virtual void setConsumes(edm::ConsumesCollector &)=0
T get(const Candidate &c)