46 auto const& vwp = iConfig.
getParameter<std::vector<std::string>>(
"WorkingPoints");
47 for (
auto const& wp : vwp) {
52 produces<edm::ValueMap<int>>();
63 std::vector<edm::EDGetTokenT<edm::ValueMap<unsigned int>>>
src_bitmaps_;
64 std::vector<edm::EDGetTokenT<edm::ValueMap<vid::CutFlowResult>>>
src_cutflows_;
69 std::vector<unsigned int>
res_;
79 std::vector<edm::Handle<edm::ValueMap<unsigned int>>> src_bitmaps(nWP);
80 for (
unsigned int i = 0;
i < nWP;
i++)
82 std::vector<edm::Handle<edm::ValueMap<vid::CutFlowResult>>> src_cutflows(nWP);
83 for (
unsigned int i = 0; i < nWP; i++)
84 iEvent.
getByToken(src_cutflows_[i], src_cutflows[i]);
86 std::vector<unsigned int> res;
88 for (
auto const&
obj : src->ptrs()) {
89 for (
unsigned int j = 0;
j < nWP;
j++) {
90 auto cutflow = (*(src_cutflows[
j]))[
obj];
92 initNCuts(cutflow.cutFlowSize());
93 if (cutflow.cutFlowSize() != nCuts)
94 throw cms::Exception(
"Configuration",
"Trying to compress VID bitmaps for cutflows of different size");
95 auto bitmap = (*(src_bitmaps[
j]))[
obj];
96 for (
unsigned int k = 0;
k < nCuts;
k++) {
99 if (bitmap >>
k & 1) {
103 "Trying to compress VID bitmaps which are not nested in the correct order for all cuts");
110 for (
unsigned int k = 0;
k < nCuts;
k++)
111 out |= (res_[
k] << (nBits *
k));
115 auto resV = std::make_unique<edm::ValueMap<int>>();
117 filler.insert(src, res.begin(), res.end());
123 template <
typename T>
126 nBits =
ceil(log2(nWP + 1));
127 if (nBits * nCuts >
sizeof(
int) * 8)
128 throw cms::Exception(
"Configuration",
"Integer cannot contain the compressed VID bitmap information");
129 res_.resize(nCuts, 0);
134 template <
typename T>
137 desc.
add<
edm::InputTag>(
"src")->setComment(
"input physics object collection");
138 desc.
add<std::vector<std::string>>(
"WorkingPoints")->setComment(
"working points to be saved in the bitmask");
144 modname +=
"VIDNestedWPBitmapProducer";
145 descriptions.
add(modname, desc);
constexpr int32_t ceil(float num)
Analysis-level Photon class.
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
void produce(edm::Event &, const edm::EventSetup &) override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
std::vector< edm::EDGetTokenT< edm::ValueMap< vid::CutFlowResult > > > src_cutflows_
void initNCuts(unsigned int)
std::vector< unsigned int > res_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
VIDNestedWPBitmapProducer< pat::Electron > EleVIDNestedWPBitmapProducer
VIDNestedWPBitmapProducer(const edm::ParameterSet &iConfig)
edm::EDGetTokenT< edm::View< T > > src_
T getParameter(std::string const &) const
Analysis-level electron class.
void add(std::string const &label, ParameterSetDescription const &psetDescription)
VIDNestedWPBitmapProducer< pat::Photon > PhoVIDNestedWPBitmapProducer
std::vector< edm::EDGetTokenT< edm::ValueMap< unsigned int > > > src_bitmaps_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)