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++)
81 iEvent.getByToken(src_bitmaps_[
i], src_bitmaps[
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>>();
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>
138 desc.add<std::vector<std::string>>(
"WorkingPoints")->setComment(
"working points to be saved in the bitmask");
144 modname +=
"VIDNestedWPBitmapProducer";
constexpr int32_t ceil(float num)
Analysis-level Photon class.
T getParameter(std::string const &) const
void produce(edm::Event &, const edm::EventSetup &) override
#define DEFINE_FWK_MODULE(type)
std::vector< edm::EDGetTokenT< edm::ValueMap< vid::CutFlowResult > > > src_cutflows_
void initNCuts(unsigned int)
std::vector< unsigned int > res_
VIDNestedWPBitmapProducer< pat::Electron > EleVIDNestedWPBitmapProducer
VIDNestedWPBitmapProducer(const edm::ParameterSet &iConfig)
edm::EDGetTokenT< edm::View< T > > src_
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)