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> 54 validateParamsAreTracked(conf);
59 constexpr unsigned length = MD5_DIGEST_LENGTH;
61 memset(id_md5_,0,length*
sizeof(
unsigned char));
62 MD5((
unsigned char*)tracked.c_str(), tracked.size(), id_md5_);
64 for(
unsigned i=0;
i<MD5_DIGEST_LENGTH; ++
i ){
65 sprintf(buf,
"%02x", id_md5_[
i]);
66 md5_string_.append( buf );
69 this->retInternal_ = this->getBitTemplate();
79 <<
"VersionedGsfElectronSelector not initialized!" << std::endl;
81 for(
unsigned i = 0;
i < cuts_.size(); ++
i ) {
83 const bool result = (*cuts_[
i])(temp);
84 values_.push_back(cuts_[
i]->
value(temp));
85 if( result || this->ignoreCut(cut_indices_[
i]) ) {
86 this->passCut(ret,cut_indices_[i]);
88 if( !failed ) ++howfar_;
93 this->setIgnored(ret);
99 for(
size_t i = 0, cutssize = cuts_.size();
i < cutssize; ++
i ) {
100 if( needs_event_content_[
i] ) {
106 return this->operator()(ref, ret);
115 return this->operator()(temp);
120 return this->operator()(temp,e);
124 this->retInternal_.set(
false);
125 this->operator()(
t, this->retInternal_);
126 this->setIgnored(this->retInternal_);
127 return (
bool)this->retInternal_;
131 this->retInternal_.set(
false);
132 this->operator()(
t,
e, this->retInternal_);
133 this->setIgnored(this->retInternal_);
134 return (
bool)this->retInternal_;
137 const unsigned char*
md55Raw()
const {
return id_md5_; }
139 constexpr unsigned length = MD5_DIGEST_LENGTH;
140 return ( 0 == memcmp(id_md5_,other.
id_md5_,length*
sizeof(
unsigned char)) );
148 const unsigned bitMap()
const {
return bitmap_; }
170 if(paraName !=
"isPOGApproved") confWithoutIsPOGApproved.
copyFrom(conf,paraName);
171 else if(conf.
existsAs<
bool>(paraName,
true)) confWithoutIsPOGApproved.
copyFrom(conf,paraName);
174 if ( tracked != untracked ) {
176 <<
"VersionedSelector does not allow untracked parameters" 177 <<
" in the cutflow ParameterSet!";
184 std::vector<SHARED_PTR(candf::CandidateCut) >
cuts_;
191 unsigned char id_md5_[MD5_DIGEST_LENGTH];
200 <<
"ID was already initialized!";
203 const std::vector<edm::ParameterSet>& cutflow =
205 if( cutflow.empty() ) {
207 <<
"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()),
214 std::vector<edm::ParameterSet>::const_iterator icut = cbegin;
215 std::map<std::string,unsigned> cut_counter;
216 std::vector<std::string> ignored_cuts;
217 for( ; icut != cend; ++icut ) {
218 std::stringstream realname;
220 if( !cut_counter.count(name) ) cut_counter[name] = 0;
221 realname << name <<
"_" << cut_counter[
name];
222 const bool needsContent =
223 icut->getParameter<
bool>(
"needsAdditionalProducts");
224 const bool ignored = icut->getParameter<
bool>(
"isIgnored");
227 if( plugin !=
nullptr ) {
231 <<
"The requested cut: " << name <<
" is not available!";
233 needs_event_content_.push_back(needsContent);
235 this->push_back(therealname);
236 this->
set(therealname);
237 if(ignored) ignored_cuts.push_back(therealname);
240 this->setIgnoredCuts(ignored_cuts);
245 for( ; icut != cend; ++icut ) {
246 std::stringstream realname;
248 if( !cut_counter.count(name) ) cut_counter[name] = 0;
249 realname << name <<
"_" << cut_counter[
name];
259 #ifdef REGULAR_CPLUSPLUS 263 std::map<std::string,unsigned> names_to_index;
264 std::map<std::string,unsigned> cut_counter;
265 for(
unsigned idx = 0;
idx < cuts_.size(); ++
idx ) {
267 if( !cut_counter.count(name) ) cut_counter[name] = 0;
268 std::stringstream realname;
269 realname << name <<
"_" << cut_counter[
name];
270 names_to_index.emplace(realname.str(),
idx);
279 for(
size_t i = 0, cutssize = cuts_.size();
i < cutssize; ++
i ) {
280 if( needs_event_content_[
i] ) {
283 if(
nullptr != needsEvent ) {
288 <<
" configured to consume event products but does not " 289 <<
" inherit from CutApplicatorWithEventContenBase " 290 <<
" please correct either your python or C++!";
T getParameter(std::string const &) const
static AlgebraicMatrix initialize()
bool operator()(T const &t) final
This provides an alternative signature without the second ret.
VParameterSet const & getParameterSetVector(std::string const &name) const
const unsigned char * md55Raw() const
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
bool operator()(typename T::value_type const &t)
bool operator()(typename T::value_type const &t, edm::EventBase const &e)
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
void copyFrom(ParameterSet const &from, std::string const &name)
Container::value_type value_type
void initialize(const edm::ParameterSet &)
virtual void getEventContent(const edm::EventBase &)=0
unique_ptr< JetDefinition::Plugin > plugin
const unsigned bitMap() const
std::vector< std::string > getParameterNames() const
Functor that operates on <T>
bool operator()(const T &ref, edm::EventBase const &e, pat::strbitset &ret) final
bool operator()(T const &t, edm::EventBase const &e) final
This provides an alternative signature that includes extra information.
const unsigned howFarInCutFlow() const
const std::string & md5String() const
void setConsumes(edm::ConsumesCollector)
unsigned char id_md5_[MD5_DIGEST_LENGTH]
static void validateParamsAreTracked(const edm::ParameterSet &conf)
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)
bool operator()(const T &ref, pat::strbitset &ret) final