forked from cms-sw/cmssw
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request cms-sw#13 from lgray/VID3_validation_74X
Vid3 validation 74 x
- Loading branch information
Showing
46 changed files
with
774 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#ifndef __DataFormats_PatCandidates_VIDResult_H__ | ||
#define __DataFormats_PatCandidates_VIDResult_H__ | ||
|
||
#include <unordered_map> | ||
#include <vector> | ||
#include <string> | ||
|
||
namespace vid { | ||
class CutFlowResult { | ||
public: | ||
template<class T> friend class VersionedSelector; | ||
|
||
CutFlowResult() : bitmap_(0) {} | ||
CutFlowResult(const std::string& name, | ||
const std::unordered_map<std::string,unsigned>& n2idx, | ||
unsigned bitmap, | ||
const std::vector<double>& values) : | ||
name_(name), | ||
bitmap_(bitmap), | ||
values_(values), | ||
name_to_index_(n2idx) {} | ||
|
||
const std::string& cutFlowName() const { return name_; } | ||
bool cutFlowPassed() const { | ||
const unsigned all_pass = name_to_index_.size()-1; | ||
return (all_pass&bitmap_) == all_pass; | ||
} | ||
size_t cutFlowSize() const { return name_to_index_.size(); } | ||
|
||
const std::string& getNameAtIndex(const unsigned idx) const; | ||
|
||
bool getCutResultByIndex(const unsigned idx) const; | ||
bool getCutResultByName(const std::string& name) const; | ||
|
||
double getValueCutUpon(const unsigned idx) const; | ||
double getValueCutUpon(const std::string& name) const; | ||
|
||
CutFlowResult getCutFlowResultMasking(const unsigned idx) const; | ||
CutFlowResult getCutFlowResultMasking(const std::string& name) const; | ||
|
||
CutFlowResult getCutFlowResultMasking(const std::vector<unsigned>& idxs) const; | ||
CutFlowResult getCutFlowResultMasking(const std::vector<std::string>& names) const; | ||
|
||
private: | ||
std::string name_; | ||
unsigned bitmap_; | ||
std::vector<double> values_; | ||
std::unordered_map<std::string,unsigned> name_to_index_; | ||
|
||
bool getCutBit(const unsigned idx) const { | ||
return (bool)(0x1&(bitmap_>>idx)); | ||
} | ||
|
||
bool getCutValue(const unsigned idx) const { | ||
return values_[idx]; | ||
} | ||
}; | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
#include "DataFormats/PatCandidates/interface/VIDCutFlowResult.h" | ||
#include "FWCore/Utilities/interface/Exception.h" | ||
|
||
namespace { | ||
static const std::string empty_str(""); | ||
} | ||
|
||
namespace vid { | ||
const std::string& CutFlowResult::getNameAtIndex(const unsigned idx) const { | ||
for( const auto& value : name_to_index_ ) { | ||
if( value.second == idx ) return value.first; | ||
} | ||
throw cms::Exception("IndexNotFound") | ||
<< "index = " << idx << " has no corresponding cut name!"; | ||
return empty_str; | ||
} | ||
|
||
bool CutFlowResult::getCutResultByIndex(const unsigned idx) const { | ||
if( idx >= name_to_index_.size() ) { | ||
throw cms::Exception("OutOfBounds") | ||
<< idx << " is out of bounds for this cut flow!"; | ||
} | ||
return getCutBit(idx); | ||
} | ||
|
||
bool CutFlowResult::getCutResultByName(const std::string& name) const { | ||
auto idx = name_to_index_.find(name); | ||
if( idx == name_to_index_.end() ) { | ||
throw cms::Exception("UnknownName") | ||
<< "Cut name: " << name | ||
<< " is not known for this cutflow!"; | ||
} | ||
return getCutBit(idx->second); | ||
} | ||
|
||
double CutFlowResult::getValueCutUpon(const unsigned idx) const { | ||
if( idx >= name_to_index_.size() ) { | ||
throw cms::Exception("OutOfBounds") | ||
<< idx << " is out of bounds for this cut flow!"; | ||
} | ||
return getCutValue(idx); | ||
} | ||
|
||
double CutFlowResult::getValueCutUpon(const std::string& name) const { | ||
auto idx = name_to_index_.find(name); | ||
if( idx == name_to_index_.end() ) { | ||
throw cms::Exception("UnknownName") | ||
<< "Cut name: " << name | ||
<< " is not known for this cutflow!"; | ||
} | ||
return getCutValue(idx->second); | ||
} | ||
|
||
CutFlowResult CutFlowResult:: | ||
getCutFlowResultMasking(const std::vector<unsigned>& idxs) const { | ||
unsigned bitmap = bitmap_; | ||
for( const unsigned idx : idxs ) { | ||
if( idx >= name_to_index_.size() ) { | ||
throw cms::Exception("OutOfBounds") | ||
<< idx << " is out of bounds for this cut flow!"; | ||
} | ||
bitmap = bitmap | 1 << idx; | ||
} | ||
return CutFlowResult(name_,name_to_index_,bitmap,values_); | ||
} | ||
|
||
CutFlowResult CutFlowResult:: | ||
getCutFlowResultMasking(const std::vector<std::string>& names) const { | ||
unsigned bitmap = bitmap_; | ||
for( const std::string& name : names ) { | ||
auto idx = name_to_index_.find(name); | ||
if( idx == name_to_index_.end() ) { | ||
throw cms::Exception("UnknownName") | ||
<< "Cut name: " << name | ||
<< " is not known for this cutflow!"; | ||
} | ||
bitmap = bitmap | 1 << idx->second; | ||
} | ||
return CutFlowResult(name_,name_to_index_,bitmap,values_); | ||
} | ||
|
||
CutFlowResult CutFlowResult:: | ||
getCutFlowResultMasking(const unsigned idx) const { | ||
unsigned bitmap = bitmap_; | ||
if( idx >= name_to_index_.size() ) { | ||
throw cms::Exception("OutOfBounds") | ||
<< idx << " is out of bounds for this cut flow!"; | ||
} | ||
bitmap = bitmap | 1 << idx; | ||
return CutFlowResult(name_,name_to_index_,bitmap,values_); | ||
} | ||
|
||
CutFlowResult CutFlowResult:: | ||
getCutFlowResultMasking(const std::string& name) const { | ||
unsigned bitmap = bitmap_; | ||
auto idx = name_to_index_.find(name); | ||
if( idx == name_to_index_.end() ) { | ||
throw cms::Exception("UnknownName") | ||
<< "Cut name: " << name | ||
<< " is not known for this cutflow!"; | ||
} | ||
bitmap = bitmap | 1 << idx->second; | ||
return CutFlowResult(name_,name_to_index_,bitmap,values_); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.