CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
VIDNestedWPBitmapProducer< T > Class Template Reference

#include <PhysicsTools/NanoAOD/plugins/VIDNestedWPBitmapProducer.cc>

Inheritance diagram for VIDNestedWPBitmapProducer< T >:
edm::stream::EDProducer<>

Public Member Functions

 VIDNestedWPBitmapProducer (const edm::ParameterSet &iConfig)
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Member Functions

void initNCuts (unsigned int)
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

bool isInit_
 
unsigned int nBits
 
unsigned int nCuts = 0
 
unsigned int nWP
 
std::vector< unsigned int > res_
 
edm::EDGetTokenT< edm::View< T > > src_
 
std::vector< edm::EDGetTokenT< edm::ValueMap< unsigned int > > > src_bitmaps_
 
std::vector< edm::EDGetTokenT< edm::ValueMap< vid::CutFlowResult > > > src_cutflows_
 
edm::EDGetTokenT< edm::View< T > > srcForIDToken_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

template<typename T>
class VIDNestedWPBitmapProducer< T >

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 70 of file VIDNestedWPBitmapProducer.cc.

Constructor & Destructor Documentation

◆ VIDNestedWPBitmapProducer()

template<typename T >
VIDNestedWPBitmapProducer< T >::VIDNestedWPBitmapProducer ( const edm::ParameterSet iConfig)
inlineexplicit

Definition at line 72 of file VIDNestedWPBitmapProducer.cc.

References edm::ParameterSet::getParameter(), VIDNestedWPBitmapProducer< T >::nWP, VIDNestedWPBitmapProducer< T >::src_bitmaps_, VIDNestedWPBitmapProducer< T >::src_cutflows_, AlCaHLTBitMon_QueryRunRegistry::string, and pfClustersFromHGC3DClusters_cfi::wp.

73  : src_(consumes<edm::View<T>>(iConfig.getParameter<edm::InputTag>("src"))),
74  srcForIDToken_(consumes<edm::View<T>>(iConfig.getParameter<edm::InputTag>("srcForID"))),
75  isInit_(false) {
76  auto const& vwp = iConfig.getParameter<std::vector<std::string>>("WorkingPoints");
77  for (auto const& wp : vwp) {
78  src_bitmaps_.push_back(consumes<edm::ValueMap<unsigned int>>(edm::InputTag(wp + std::string("Bitmap"))));
80  }
81  nWP = src_bitmaps_.size();
82  produces<edm::ValueMap<int>>();
83  }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
std::vector< edm::EDGetTokenT< edm::ValueMap< vid::CutFlowResult > > > src_cutflows_
edm::EDGetTokenT< edm::View< T > > srcForIDToken_
edm::EDGetTokenT< edm::View< T > > src_
std::vector< edm::EDGetTokenT< edm::ValueMap< unsigned int > > > src_bitmaps_

Member Function Documentation

◆ fillDescriptions()

template<typename T >
void VIDNestedWPBitmapProducer< T >::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 170 of file VIDNestedWPBitmapProducer.cc.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, ProducerED_cfi::InputTag, timingPdfMaker::modname, and AlCaHLTBitMon_QueryRunRegistry::string.

170  {
172  desc.add<edm::InputTag>("src")->setComment("input physics object collection");
173  desc.add<edm::InputTag>("srcForID", edm::InputTag())->setComment("physics object collection the ID value maps are ");
174  desc.add<std::vector<std::string>>("WorkingPoints")->setComment("working points to be saved in the bitmask");
176  if (typeid(T) == typeid(reco::GsfElectron))
177  modname += "Ele";
178  else if (typeid(T) == typeid(reco::Photon))
179  modname += "Pho";
180  modname += "VIDNestedWPBitmapProducer";
181  descriptions.add(modname, desc);
182 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)
long double T

◆ initNCuts()

template<typename T >
void VIDNestedWPBitmapProducer< T >::initNCuts ( unsigned int  n)
private

Definition at line 159 of file VIDNestedWPBitmapProducer.cc.

References reco::ceil(), Exception, and dqmiodumpmetadata::n.

159  {
160  nCuts = n;
161  nBits = ceil(log2(nWP + 1));
162  if (nBits * nCuts > sizeof(int) * 8)
163  throw cms::Exception("Configuration", "Integer cannot contain the compressed VID bitmap information");
164  res_.resize(nCuts, 0);
165  isInit_ = true;
166 }
constexpr int32_t ceil(float num)
std::vector< unsigned int > res_

◆ produce()

template<typename T >
void VIDNestedWPBitmapProducer< T >::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 107 of file VIDNestedWPBitmapProducer.cc.

References Exception, trigObjTnPSource_cfi::filler, mps_fire::i, iEvent, dqmiolumiharvest::j, dqmdumpme::k, eostools::move(), getGTfromDQMFile::obj, MillePedeFileConverter_cfg::out, and TrackRefitter_38T_cff::src.

107  {
109  iEvent.getByToken(src_, src);
110 
111  auto srcForIDHandle = iEvent.getHandle(srcForIDToken_);
112 
113  std::vector<edm::Handle<edm::ValueMap<unsigned int>>> src_bitmaps(nWP);
114  for (unsigned int i = 0; i < nWP; i++)
115  iEvent.getByToken(src_bitmaps_[i], src_bitmaps[i]);
116  std::vector<edm::Handle<edm::ValueMap<vid::CutFlowResult>>> src_cutflows(nWP);
117  for (unsigned int i = 0; i < nWP; i++)
118  iEvent.getByToken(src_cutflows_[i], src_cutflows[i]);
119 
120  std::vector<unsigned int> res;
121 
122  for (auto const& obj : src->ptrs()) {
123  auto objForID = getObjInColl(obj, srcForIDHandle);
124  for (unsigned int j = 0; j < nWP; j++) {
125  auto cutflow = (*(src_cutflows[j]))[objForID];
126  if (!isInit_)
127  initNCuts(cutflow.cutFlowSize());
128  if (cutflow.cutFlowSize() != nCuts)
129  throw cms::Exception("Configuration", "Trying to compress VID bitmaps for cutflows of different size");
130  auto bitmap = (*(src_bitmaps[j]))[objForID];
131  for (unsigned int k = 0; k < nCuts; k++) {
132  if (j == 0)
133  res_[k] = 0;
134  if (bitmap >> k & 1) {
135  if (res_[k] != j)
136  throw cms::Exception(
137  "Configuration",
138  "Trying to compress VID bitmaps which are not nested in the correct order for all cuts");
139  res_[k]++;
140  }
141  }
142  }
143 
144  int out = 0;
145  for (unsigned int k = 0; k < nCuts; k++)
146  out |= (res_[k] << (nBits * k));
147  res.push_back(out);
148  }
149 
150  auto resV = std::make_unique<edm::ValueMap<int>>();
152  filler.insert(src, res.begin(), res.end());
153  filler.fill();
154 
155  iEvent.put(std::move(resV));
156 }
std::vector< edm::EDGetTokenT< edm::ValueMap< vid::CutFlowResult > > > src_cutflows_
Definition: Electron.h:6
int iEvent
Definition: GenABIO.cc:224
std::vector< unsigned int > res_
edm::EDGetTokenT< edm::View< T > > srcForIDToken_
edm::EDGetTokenT< edm::View< T > > src_
std::vector< edm::EDGetTokenT< edm::ValueMap< unsigned int > > > src_bitmaps_
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ isInit_

template<typename T >
bool VIDNestedWPBitmapProducer< T >::isInit_
private

Definition at line 101 of file VIDNestedWPBitmapProducer.cc.

◆ nBits

template<typename T >
unsigned int VIDNestedWPBitmapProducer< T >::nBits
private

Definition at line 98 of file VIDNestedWPBitmapProducer.cc.

◆ nCuts

template<typename T >
unsigned int VIDNestedWPBitmapProducer< T >::nCuts = 0
private

Definition at line 99 of file VIDNestedWPBitmapProducer.cc.

◆ nWP

template<typename T >
unsigned int VIDNestedWPBitmapProducer< T >::nWP
private

◆ res_

template<typename T >
std::vector<unsigned int> VIDNestedWPBitmapProducer< T >::res_
private

Definition at line 100 of file VIDNestedWPBitmapProducer.cc.

◆ src_

template<typename T >
edm::EDGetTokenT<edm::View<T> > VIDNestedWPBitmapProducer< T >::src_
private

Definition at line 92 of file VIDNestedWPBitmapProducer.cc.

◆ src_bitmaps_

template<typename T >
std::vector<edm::EDGetTokenT<edm::ValueMap<unsigned int> > > VIDNestedWPBitmapProducer< T >::src_bitmaps_
private

◆ src_cutflows_

template<typename T >
std::vector<edm::EDGetTokenT<edm::ValueMap<vid::CutFlowResult> > > VIDNestedWPBitmapProducer< T >::src_cutflows_
private

◆ srcForIDToken_

template<typename T >
edm::EDGetTokenT<edm::View<T> > VIDNestedWPBitmapProducer< T >::srcForIDToken_
private

Definition at line 93 of file VIDNestedWPBitmapProducer.cc.